* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
getServletContext().log("-> DirIndexSvr.doPost()\nParameters= " + request.getParameterMap().toString());
// Extract request parameters
JsonAdminCmd cmd = null;
try {
cmd = JsonAdminCmd.decode(request.getInputStream());
}
catch (Exception ex) {
getServletContext().log("Cannot get POSTed administrative command", ex);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
getServletContext().log("Process administrative command: " + cmd.getCmd() + "(" + Arrays.toString(cmd.getParams())+")");
for (String dirPath: cmd.getParams()) {
try {
DirectoryIndexer indexer = new DirectoryIndexer();
if (cmd.getCmd().equals(Configuration.indexCmd)) {
// force indexing
indexer.indexDirectory(dirPath, true, request);
// Complete thumbnails and web images if necessary
indexer.checkAndUpdateThumbnails(dirPath);
indexer.checkAndUpdateWebImg(dirPath);
}
else if (cmd.getCmd().equals(Configuration.resetIndexCmd)) {
// delete directory index
indexer.deleteDirectoryIndex(dirPath, request);
}
else if (cmd.getCmd().equals(Configuration.deleteCmd)) {
// delete directory index and images
indexer.deleteDirectoryIndexAndImages(dirPath, request);
}
} catch (AuthenticationException e) {
// TODO Auto-generated catch block