@Test public void testDoPut() throws Exception { logger.info("doPut"); Server server = Help.getServer(RulesServlet.class); server.start(); try { String url = String.format("http: JSONArray ja = new JSONArray(); JSONObject jr = new JSONObject(); jr.put("name", "test doPost rule 1"); jr.put("text", Help.ExampleRules()[0]); ja.put(jr); jr = new JSONObject(); jr.put("name", "test doPost rule 2"); jr.put("text", Help.ExampleRules()[1]); Help.Res r = Help.sendPut(url, ja.toString(2)); assertEquals(200, r.getCode()); } finally { server.stop(); } }
@Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { String body = Utils.getBodyAsString(request); TimeRulesStore.getInstance().saveTimeRules(body); Result r = RulesManager.updateAll(epService, body); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }
RulesServlet extends HttpServlet { @Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { String body = Utils.getBodyAsString(request); TimeRulesStore.getInstance().saveTimeRules(body); Result r = RulesManager.updateAll(epService, body); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } } }
RulesServlet extends HttpServlet { @Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { String body = Utils.getBodyAsString(request); TimeRulesStore.getInstance().saveTimeRules(body); Result r = RulesManager.updateAll(epService, body); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }  }
RulesServlet extends HttpServlet { @Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { String body = Utils.getBodyAsString(request); TimeRulesStore.getInstance().saveTimeRules(body); Result r = RulesManager.updateAll(epService, body); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }  @Override void init(); @Override void destroy(); @Override String getServletInfo(); }
RulesServlet extends HttpServlet { @Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); try { String body = Utils.getBodyAsString(request); TimeRulesStore.getInstance().saveTimeRules(body); Result r = RulesManager.updateAll(epService, body); response.setStatus(r.getStatusCode()); response.getOutputStream().print(Encode.forHtmlContent(r.getMessage())); } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }  @Override void init(); @Override void destroy(); @Override String getServletInfo();  }