- public void doFilter(HttpSession httpSession,
- HttpServletRequest request, HttpServletResponse response,
- FilterChain filterChain) throws IOException, ServletException {
-
- // Authenticate from session
- if (isSessionAuthenticated(httpSession)) {
- filterChain.doFilter(request, response);
- return;
+ public HttpService addingService(ServiceReference<HttpService> reference) {
+ long begin = System.currentTimeMillis();
+ if (log.isTraceEnabled())
+ log.trace("HTTP prepare starts...");
+ HttpService httpService = addHttpService(reference);
+ if (log.isTraceEnabled())
+ log.trace("HTTP prepare duration: " + (System.currentTimeMillis() - begin) + "ms");
+ return httpService;
+ }
+
+ @Override
+ public void removedService(ServiceReference<HttpService> reference, HttpService service) {
+ // if (dataHttp != null)
+ // dataHttp.destroy();
+ // dataHttp = null;
+ // if (nodeHttp != null)
+ // nodeHttp.destroy();
+ // nodeHttp = null;
+ // destroy();
+ repositories.close();
+ repositories = null;
+ }
+
+ private HttpService addHttpService(ServiceReference<HttpService> sr) {
+ HttpService httpService = bc.getService(sr);
+ // TODO find constants
+ Object httpPort = sr.getProperty("http.port");
+ Object httpsPort = sr.getProperty("https.port");
+
+ try {
+ httpService.registerServlet("/!", new LinkServlet(), null, null);
+ httpService.registerServlet("/robots.txt", new RobotServlet(), null, null);
+ } catch (Exception e) {
+ throw new CmsException("Cannot register filters", e);