public void nutchPerform(ComponentContext tileContext,
HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext) throws ServletException, IOException {
ServiceLocator locator = getServiceLocator(request);
Search search;
// key used for caching results, should really be something else but a part of user
// definable String
String key = request.getQueryString().replace("?","_").replace("&","_");
StringBuffer cacheKey=new StringBuffer(key.length()*2);
for(int i=0;i<key.length();i++){
cacheKey.append(key.charAt(i)).append(java.io.File.separatorChar);
}
if(LOG.isDebugEnabled()){
LOG.debug("cache key:" + cacheKey);
}
if (cacheKey != null) {
try {
search = manager.getSearch(cacheKey.toString(), locator);
request.setAttribute(Search.REQ_ATTR_SEARCH, search);
if(LOG.isDebugEnabled()) {
LOG.debug("Using cached");
}
} catch (NeedsRefreshException e) {
try{
super.nutchPerform(tileContext, request, response, servletContext);
search = (Search) locator.getSearch();
manager.putSearch(cacheKey.toString(),
search);
} catch (Exception ex){
LOG.info("Cancelling update");
manager.cancelUpdate(cacheKey.toString());