diff --git a/perseo-main/src/main/java/com/telefonica/iot/perseo/EventsServlet.java b/perseo-main/src/main/java/com/telefonica/iot/perseo/EventsServlet.java index 5117213..0bf7314 100644 --- a/perseo-main/src/main/java/com/telefonica/iot/perseo/EventsServlet.java +++ b/perseo-main/src/main/java/com/telefonica/iot/perseo/EventsServlet.java @@ -96,8 +96,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } catch (IOException exception) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } - - } } diff --git a/perseo-main/src/main/java/com/telefonica/iot/perseo/LogLevelServlet.java b/perseo-main/src/main/java/com/telefonica/iot/perseo/LogLevelServlet.java index 8eb554b..0ae1d7c 100644 --- a/perseo-main/src/main/java/com/telefonica/iot/perseo/LogLevelServlet.java +++ b/perseo-main/src/main/java/com/telefonica/iot/perseo/LogLevelServlet.java @@ -103,12 +103,12 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.debug("getting log level"); synchronized (mutex) { - try { - String currentLevel = LogManager.getRootLogger().getLevel().toString(); - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json"); - response.setStatus(HttpServletResponse.SC_OK); - response.getOutputStream().print(String.format("{\"level\":\"%s\"}",Encode.forHtmlContent(currentLevel))); + try { + String currentLevel = LogManager.getRootLogger().getLevel().toString(); + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json"); + response.setStatus(HttpServletResponse.SC_OK); + response.getOutputStream().print(String.format("{\"level\":\"%s\"}",Encode.forHtmlContent(currentLevel))); } catch (IOException e) { logger.error("IOException in log level"); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); diff --git a/perseo-main/src/main/java/com/telefonica/iot/perseo/RulesServlet.java b/perseo-main/src/main/java/com/telefonica/iot/perseo/RulesServlet.java index 82c8af6..ee0c05d 100644 --- a/perseo-main/src/main/java/com/telefonica/iot/perseo/RulesServlet.java +++ b/perseo-main/src/main/java/com/telefonica/iot/perseo/RulesServlet.java @@ -114,7 +114,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) response.setContentType("application/json;charset=UTF-8"); try { - String body = Utils.getBodyAsString(request); + String body = Utils.getBodyAsString(request); // Save temporary rules, not triggered by events external to the core TimeRulesStore.getInstance().saveTimeRules(body); @@ -143,8 +143,7 @@ protected void doPut(HttpServletRequest request, HttpServletResponse response) Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); - try { - + try { String body = Utils.getBodyAsString(request); // Save timed rules, which are not activated by events external to the core @@ -154,11 +153,9 @@ protected void doPut(HttpServletRequest request, HttpServletResponse response) 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); + logger.error(String.format("error: %s" ,je)); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } - - } /** @@ -175,9 +172,7 @@ protected void doDelete(HttpServletRequest request, HttpServletResponse response Utils.putCorrelatorAndTrans(request); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=UTF-8"); - - try { - + try { logger.info(String.format("delete rule %s", request.getPathInfo())); //request.getPathInfo() returns null or the extra path information //that follows the servlet path but precedes the query string and will @@ -198,7 +193,6 @@ protected void doDelete(HttpServletRequest request, HttpServletResponse response } catch (Exception je) { logger.error(String.format("error: %s" ,je)); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - } } diff --git a/perseo-main/src/test/java/com/telefonica/iot/perseo/EventsServletTest.java b/perseo-main/src/test/java/com/telefonica/iot/perseo/EventsServletTest.java index 1792f52..7329ec4 100644 --- a/perseo-main/src/test/java/com/telefonica/iot/perseo/EventsServletTest.java +++ b/perseo-main/src/test/java/com/telefonica/iot/perseo/EventsServletTest.java @@ -62,7 +62,7 @@ public void tearDown() { */ @Test public void testDoPost() throws Exception { - logger.info("doPost"); + logger.info("doPost"); Server server = Help.getServer(EventsServlet.class); server.start(); try { diff --git a/perseo-main/src/test/java/com/telefonica/iot/perseo/GenericListenerTest.java b/perseo-main/src/test/java/com/telefonica/iot/perseo/GenericListenerTest.java index 4e48668..8ad7c43 100644 --- a/perseo-main/src/test/java/com/telefonica/iot/perseo/GenericListenerTest.java +++ b/perseo-main/src/test/java/com/telefonica/iot/perseo/GenericListenerTest.java @@ -65,7 +65,7 @@ public void tearDown() { */ @Test public void testUpdate() { - logger.info("update"); + logger.info("update"); EventBean[] newEvents = new EventBean[0]; EventBean[] oldEvents = new EventBean[0]; GenericListener instance = new GenericListener(); @@ -83,7 +83,7 @@ public void testUpdate() { */ @Test public void testUpdateTimerRule() { - logger.info("update with timed rule"); + logger.info("update with timed rule"); // Add RuleTest in TimeRulesStore Singleton TimeRulesStore tRInfoInstance = TimeRulesStore.getInstance(); tRInfoInstance.cleanAllRules(); diff --git a/perseo-main/src/test/java/com/telefonica/iot/perseo/LogLevelServletTest.java b/perseo-main/src/test/java/com/telefonica/iot/perseo/LogLevelServletTest.java index a3a3bd0..5e2ffba 100644 --- a/perseo-main/src/test/java/com/telefonica/iot/perseo/LogLevelServletTest.java +++ b/perseo-main/src/test/java/com/telefonica/iot/perseo/LogLevelServletTest.java @@ -65,7 +65,7 @@ public void tearDown() { */ @Test public void testDoPutOK() throws Exception { - logger.info("doPut log level valid"); + logger.info("doPut log level valid"); Server server = Help.getServer(LogLevelServlet.class); server.start(); try { @@ -87,7 +87,7 @@ public void testDoPutOK() throws Exception { */ @Test public void testDoPutBad() throws Exception { - logger.info("doPut log level invalid"); + logger.info("doPut log level invalid"); Server server = Help.getServer(LogLevelServlet.class); server.start(); try { diff --git a/perseo-main/src/test/java/com/telefonica/iot/perseo/RulesManagerTest.java b/perseo-main/src/test/java/com/telefonica/iot/perseo/RulesManagerTest.java index ea9d9e1..92dce81 100644 --- a/perseo-main/src/test/java/com/telefonica/iot/perseo/RulesManagerTest.java +++ b/perseo-main/src/test/java/com/telefonica/iot/perseo/RulesManagerTest.java @@ -79,7 +79,7 @@ public void tearDown() { */ @Test public void testGet() { - logger.info("get"); + logger.info("get"); String ruleName = "ccc"; String epl = Help.ExampleRules()[0]; EPStatement st = epService.getEPAdministrator().createEPL(epl, ruleName); @@ -96,7 +96,7 @@ public void testGet() { */ @Test public void testMake() { - logger.info("make"); + logger.info("make"); String ruleName = "ccc"; String epl = Help.ExampleRules()[0]; String text = String.format("{\"name\":\"%s\",\"text\":\"%s\"}", ruleName, epl); @@ -113,7 +113,7 @@ public void testMake() { */ @Test public void testUpdateAll() { - logger.info("updateAll"); + logger.info("updateAll"); String ruleName = "ccc"; String epl = Help.ExampleRules()[0]; String text = String.format("[{\"name\":\"%s\",\"text\":\"%s\"}]", ruleName, epl); @@ -133,7 +133,7 @@ public void testUpdateAll() { */ @Test public void testDelete() { - logger.info("delete"); + logger.info("delete"); String ruleName = "ccc"; String epl = Help.ExampleRules()[0]; EPStatement st = epService.getEPAdministrator().createEPL(epl, ruleName); diff --git a/perseo-main/src/test/java/com/telefonica/iot/perseo/RulesServletTest.java b/perseo-main/src/test/java/com/telefonica/iot/perseo/RulesServletTest.java index 3354ff2..92c204c 100644 --- a/perseo-main/src/test/java/com/telefonica/iot/perseo/RulesServletTest.java +++ b/perseo-main/src/test/java/com/telefonica/iot/perseo/RulesServletTest.java @@ -65,7 +65,7 @@ public void tearDown() { */ @Test public void testDoGet() throws Exception { - logger.info("doGet"); + logger.info("doGet"); Server server = Help.getServer(RulesServlet.class); server.start(); try { @@ -86,7 +86,7 @@ public void testDoGet() throws Exception { */ @Test public void testDoPost() throws Exception { - logger.info("doPost"); + logger.info("doPost"); Server server = Help.getServer(RulesServlet.class); server.start(); try { @@ -114,7 +114,7 @@ public void testDoPost() throws Exception { */ @Test public void testDoPut() throws Exception { - logger.info("doPut"); + logger.info("doPut"); Server server = Help.getServer(RulesServlet.class); server.start(); try { @@ -142,7 +142,7 @@ public void testDoPut() throws Exception { */ @Test public void testDoPutLongSet() throws Exception { - logger.info("doPutLongSet"); + logger.info("doPutLongSet"); Server server = Help.getServer(RulesServlet.class); server.start(); try { @@ -162,7 +162,7 @@ public void testDoPutLongSet() throws Exception { */ @Test public void testDoDelete() throws Exception { - logger.info("doDelete"); + logger.info("doDelete"); Server server = Help.getServer(RulesServlet.class); server.start(); try { diff --git a/perseo-main/src/test/java/com/telefonica/iot/perseo/UtilsTest.java b/perseo-main/src/test/java/com/telefonica/iot/perseo/UtilsTest.java index ff9b9b5..3e66782 100644 --- a/perseo-main/src/test/java/com/telefonica/iot/perseo/UtilsTest.java +++ b/perseo-main/src/test/java/com/telefonica/iot/perseo/UtilsTest.java @@ -78,7 +78,7 @@ public void tearDown() { */ @Test public void testInitEPService() { - logger.info("initEPService"); + logger.info("initEPService"); ServletContext sc = new ServletContextMock(); EPServiceProvider result = Utils.initEPService(sc); assertEquals(sc.getAttribute("epService"), result); @@ -93,7 +93,7 @@ public void testInitEPService() { */ @Test public void testDestroyEPService() { - logger.info("destroyEPService"); + logger.info("destroyEPService"); ServletContextMock sc = new ServletContextMock(); //Empty sc Utils.destroyEPService(sc); @@ -109,7 +109,7 @@ public void testDestroyEPService() { */ @Test public void testJSONObject2Map() { - logger.info("JSONObject2Map"); + logger.info("JSONObject2Map"); HashMap m = new HashMap(); m.put("one", "1"); m.put("two", 2); @@ -123,7 +123,7 @@ public void testJSONObject2Map() { */ @Test public void testEvent2JSONObject() { - logger.info("Event2JSONObject"); + logger.info("Event2JSONObject"); HashMap m = new HashMap(); m.put("one", "1"); m.put("two", 2); @@ -163,7 +163,7 @@ public void testStatement2JSONObject() { */ @Test public void testDoHTTPPost() { - logger.info("DoHTTPPost"); + logger.info("DoHTTPPost"); InetSocketAddress address = new InetSocketAddress(Help.PORT); HttpServer httpServer = null; try { @@ -190,7 +190,7 @@ public void handle(HttpExchange exchange) throws IOException { assertEquals(false, result); } catch (IOException ex) { - logger.error(ex.toString()); + logger.error(ex.toString()); fail(ex.toString()); } finally { if (httpServer != null) {