use of com.willshex.service.IService in project blogwt by billy1380.
the class SearchIndexServlet method doGet.
/* (non-Javadoc)
*
* @see com.willshex.service.ContextAwareServlet#doGet() */
@Override
protected void doGet() throws ServletException, IOException {
super.doGet();
String appEngineQueue = REQUEST.get().getHeader("X-AppEngine-QueueName");
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, String.format("appEngineQueue is [%s]", appEngineQueue));
}
boolean isQueue = appEngineQueue != null && "default".toLowerCase().equals(appEngineQueue.toLowerCase());
if (!isQueue) {
RESPONSE.get().setStatus(401);
RESPONSE.get().getOutputStream().print("failure");
LOG.log(Level.WARNING, "Attempt to run script directly, this is not permitted");
return;
}
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, String.format("Call from [%s] allowed to proceed", appEngineQueue));
}
String nameParam = REQUEST.get().getParameter(SearchHelper.ENTITY_NAME_KEY);
String idParam = REQUEST.get().getParameter(SearchHelper.ENTITY_ID_KEY);
if (nameParam != null && idParam != null) {
Long id = Long.valueOf(idParam);
IService service = ServiceDiscovery.getService(nameParam);
if (service != null && service instanceof ISearch) {
SearchHelper.index((ISearch<?>) service, id);
}
}
}