Example #1
0
 @Override
 public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws IOException, ServletException {
   int socketId = extractSocketId(request);
   WsOutbound clientStream = null;
   if (socketId != -1) {
     ResponseChannel channel = channels.get(socketId);
     if (channel != null) {
       clientStream = channel.getWsOutbound();
     }
   }
   int provId = extractProvenanceId(request);
   WsOutbound provenanceStream = null;
   if (provId != -1) {
     ProvenanceChannel channel = provenanceChannels.get(provId);
     if (channel != null) {
       provenanceStream = channel.getWsOutbound();
     }
   }
   if (!request.getServletPath().startsWith("/rest")) {
     response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
     response.setHeader("Accept", "HEAD GET");
     PrintStream ps =
         new PrintStream(
             response.getOutputStream(), true, SemantEcoConfiguration.get().getEncoding());
     ps.println(Messages.METHOD_ONLYGET);
     ps.close();
     return;
   }
   log.debug("Handling POST call");
   invokeRestCall(request, response, clientStream, provenanceStream);
 }
Example #2
0
 @Override
 public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws IOException, ServletException {
   if (request.getServletPath().equals("/log")) {
     super.doGet(request, response);
     return;
   }
   if (request.getServletPath().equals("/provenance")) {
     super.doGet(request, response);
     return;
   }
   int socketId = extractSocketId(request);
   WsOutbound clientStream = null;
   if (socketId != -1) {
     ResponseChannel channel = channels.get(socketId);
     if (channel != null) {
       clientStream = channel.getWsOutbound();
     }
   }
   int provId = extractProvenanceId(request);
   WsOutbound provenanceStream = null;
   if (provId != -1) {
     ProvenanceChannel channel = provenanceChannels.get(provId);
     if (channel != null) {
       provenanceStream = channel.getWsOutbound();
     }
   }
   PrintStream ps = null;
   if (request.getServletPath().equals("/js/config.js")) {
     printConfig(request, response);
   } else if (request.getServletPath().equals("/js/modules")) {
     printAjax(request, response);
   } else if (request.getServletPath().startsWith("/rest")) {
     invokeRestCall(request, response, clientStream, provenanceStream);
   } else {
     ps =
         new PrintStream(
             response.getOutputStream(), true, SemantEcoConfiguration.get().getEncoding());
     ps.println("<h1>It works!</h1>");
     ps.close();
   }
 }