private void doGetWelcome(HttpServletRequest request, HttpServletResponse resp) throws Exception { JSONObject result = new JSONObject(); result.put("ok", true); result.put("service", "date"); sendJsonResponse(resp, result); } }
dateSource = new DateSourceCouchWithCluster(configuration.getAtlasDesignDocument()); } catch (Exception e) { throw new ServletException("Unable to create date source",e); actions = new DateServiceActions(dateSource); robot = new DateRobotThread(configuration.getAtlasDesignDocument(), dateSource.getClusterTree()); robot.start(); } catch (Exception e) { throw new ServletException("Unable to start date robot",e);
private void initDate(ServletContext servletContext) throws ServletException { try { DateServletConfiguration config = new DateServletConfiguration(); CouchDb couchDb = couchDd.getDatabase(); config.setCouchDb(couchDb); CouchDesignDocument atlasDesign = couchDb.getDesignDocument("atlas"); config.setAtlasDesignDocument(atlasDesign); servletContext.setAttribute(DateServletConfiguration.CONFIGURATION_KEY, config); } catch(Exception e) { logger.error("Error configuring date service",e); throw new ServletException("Error configuring date service",e); } }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { List<String> paths = computeRequestPath(request); doGetWelcome(request, response); interval = new TimeInterval(min,NowReference.now()); } else { interval = new TimeInterval(min,max); JSONObject result = actions.getDocIdsFromInterval(interval); sendJsonResponse(response, result); PrintWriter pw = new PrintWriter(osw); actions.getInfo(pw); PrintWriter pw = new PrintWriter(osw); actions.getDotInfo(pw); reportError(e, response);
ServletHolder servletHolder = new ServletHolder(new DateServlet()); servletHolder.setInitOrder(2); context.addServlet(servletHolder,"/servlet/date/*");