* @param response the servlet response
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestContext context = null;
try {
LOGGER.finer("Query string="+request.getQueryString());
String sEncoding = request.getCharacterEncoding();
if ((sEncoding == null) || (sEncoding.trim().length() == 0)) {
request.setCharacterEncoding("UTF-8");
}
context = RequestContext.extract(request);
String action = Val.chkStr(request.getParameter("action"));
if (action.equalsIgnoreCase("isSynchronizerRunning")) {
boolean isRunning = LuceneIndexSynchronizer.RUNNING;
this.writeCharacterResponse(response,
""+isRunning,"UTF-8","text/plain; charset=UTF-8");
return;
}
context.getObjectMap().put("lucene.useRemoteWriter",false);
StringAttributeMap params = context.getCatalogConfiguration().getParameters();
String param = Val.chkStr(params.getValue("lucene.useSingleSearcher"));
boolean useSingleWriter = param.equalsIgnoreCase("true");
param = Val.chkStr(params.getValue("lucene.useLocalWriter"));
boolean bUseLocalWriter = !param.equalsIgnoreCase("false");
param = Val.chkStr(params.getValue("lucene.useRemoteWriter"));
boolean useRemoteWriter = param.equalsIgnoreCase("true");
String remoteWriterUrl = Val.chkStr(params.getValue("lucene.remoteWriterUrl"));
boolean bOk = true;
if (!useSingleWriter || !bUseLocalWriter) {
bOk = false;
String s = "Inconsistent configuration parameters,"+
" lucene.useSingleWriter lucene.useLocalWriter";
LOGGER.severe(s);
response.sendError(500,"Inconsistent configuration parameters on server.");
}
if (bOk) {
String sIds = Val.chkStr(request.getParameter("ids"));
String[] ids = sIds.split(",");
if (action.equalsIgnoreCase("delete")) {
this.executeDelete(request,response,context,ids);
} else if (action.equalsIgnoreCase("publish")) {
this.executePublish(request,response,context,ids);
} else if (action.equalsIgnoreCase("runSynchronizer")) {
StringAttributeMap syncParams = new StringAttributeMap();
//syncParams.set("feedbackSeconds","30");
LuceneIndexSynchronizer lis = new LuceneIndexSynchronizer(syncParams);
lis.syncronize();
} else if (action.equalsIgnoreCase("touch")) {
LuceneIndexAdapter adapter = new LuceneIndexAdapter(context);
adapter.touch();
} else {
String s = "Unrecognized action: "+action;
LOGGER.log(Level.WARNING,s);
}
}
} catch (Throwable t) {
String sErr = "Exception occured while processing servlet request.";
LOGGER.log(Level.SEVERE,sErr,t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
} finally {
if (context != null) context.onExecutionPhaseCompleted();
}
}