@Test public void testAddCollectorApplication() throws IOException { CollectorServlet.addCollectorApplication("test", "http: CollectorServlet.removeCollectorApplication("test"); }
private void addCollectorApplication(HttpServletRequest req, HttpServletResponse resp) throws IOException { final String appName = req.getParameter("appName"); final String appUrls = req.getParameter("appUrls"); final String action = req.getParameter("action"); final String[] aggregatedApps = req.getParameterValues("aggregatedApps"); try { if (appName == null || appUrls == null && aggregatedApps == null) { throw new IllegalArgumentException(I18N.getString("donnees_manquantes")); } if (appUrls != null && !appUrls.startsWith("http: && !appUrls.startsWith("https: throw new IllegalArgumentException(I18N.getString("urls_format")); } final CollectorController collectorController = new CollectorController( collectorServer); if ("unregisterNode".equals(action)) { collectorController.removeCollectorApplicationNodes(appName, appUrls); LOGGER.info("monitored application node removed: " + appName + ", url: " + appUrls); } else if (appUrls != null) { collectorController.addCollectorApplication(appName, appUrls); LOGGER.info("monitored application added: " + appName); LOGGER.info("urls of the monitored application: " + appUrls); } else { assert aggregatedApps != null; collectorController.addCollectorAggregationApplication(appName, Arrays.asList(aggregatedApps)); LOGGER.info("aggregation application added: " + appName); LOGGER.info("aggregated applications of the aggregation application: " + Arrays.asList(aggregatedApps)); } CollectorController.showAlertAndRedirectTo(resp, I18N.getFormattedString("application_ajoutee", appName), "?application=" + appName); } catch (final FileNotFoundException e) { final String message = I18N.getString("monitoring_configure"); throw new IllegalStateException(message + '\n' + e, e); } catch (final StreamCorruptedException e) { final String message = I18N.getFormattedString("reponse_non_comprise", appUrls); throw new IllegalStateException(message + '\n' + e, e); } }
CollectorServlet extends HttpServlet { private void addCollectorApplication(HttpServletRequest req, HttpServletResponse resp) throws IOException { final String appName = req.getParameter("appName"); final String appUrls = req.getParameter("appUrls"); final String action = req.getParameter("action"); final String[] aggregatedApps = req.getParameterValues("aggregatedApps"); try { if (appName == null || appUrls == null && aggregatedApps == null) { throw new IllegalArgumentException(I18N.getString("donnees_manquantes")); } if (appUrls != null && !appUrls.startsWith("http: && !appUrls.startsWith("https: throw new IllegalArgumentException(I18N.getString("urls_format")); } final CollectorController collectorController = new CollectorController( collectorServer); if ("unregisterNode".equals(action)) { collectorController.removeCollectorApplicationNodes(appName, appUrls); LOGGER.info("monitored application node removed: " + appName + ", url: " + appUrls); } else if (appUrls != null) { collectorController.addCollectorApplication(appName, appUrls); LOGGER.info("monitored application added: " + appName); LOGGER.info("urls of the monitored application: " + appUrls); } else { assert aggregatedApps != null; collectorController.addCollectorAggregationApplication(appName, Arrays.asList(aggregatedApps)); LOGGER.info("aggregation application added: " + appName); LOGGER.info("aggregated applications of the aggregation application: " + Arrays.asList(aggregatedApps)); } CollectorController.showAlertAndRedirectTo(resp, I18N.getFormattedString("application_ajoutee", appName), "?application=" + appName); } catch (final FileNotFoundException e) { final String message = I18N.getString("monitoring_configure"); throw new IllegalStateException(message + '\n' + e, e); } catch (final StreamCorruptedException e) { final String message = I18N.getFormattedString("reponse_non_comprise", appUrls); throw new IllegalStateException(message + '\n' + e, e); } } }
CollectorServlet extends HttpServlet { private void addCollectorApplication(HttpServletRequest req, HttpServletResponse resp) throws IOException { final String appName = req.getParameter("appName"); final String appUrls = req.getParameter("appUrls"); final String action = req.getParameter("action"); final String[] aggregatedApps = req.getParameterValues("aggregatedApps"); try { if (appName == null || appUrls == null && aggregatedApps == null) { throw new IllegalArgumentException(I18N.getString("donnees_manquantes")); } if (appUrls != null && !appUrls.startsWith("http: && !appUrls.startsWith("https: throw new IllegalArgumentException(I18N.getString("urls_format")); } final CollectorController collectorController = new CollectorController( collectorServer); if ("unregisterNode".equals(action)) { collectorController.removeCollectorApplicationNodes(appName, appUrls); LOGGER.info("monitored application node removed: " + appName + ", url: " + appUrls); } else if (appUrls != null) { collectorController.addCollectorApplication(appName, appUrls); LOGGER.info("monitored application added: " + appName); LOGGER.info("urls of the monitored application: " + appUrls); } else { assert aggregatedApps != null; collectorController.addCollectorAggregationApplication(appName, Arrays.asList(aggregatedApps)); LOGGER.info("aggregation application added: " + appName); LOGGER.info("aggregated applications of the aggregation application: " + Arrays.asList(aggregatedApps)); } CollectorController.showAlertAndRedirectTo(resp, I18N.getFormattedString("application_ajoutee", appName), "?application=" + appName); } catch (final FileNotFoundException e) { final String message = I18N.getString("monitoring_configure"); throw new IllegalStateException(message + '\n' + e, e); } catch (final StreamCorruptedException e) { final String message = I18N.getFormattedString("reponse_non_comprise", appUrls); throw new IllegalStateException(message + '\n' + e, e); } }  }
CollectorServlet extends HttpServlet { private void addCollectorApplication(HttpServletRequest req, HttpServletResponse resp) throws IOException { final String appName = req.getParameter("appName"); final String appUrls = req.getParameter("appUrls"); final String action = req.getParameter("action"); final String[] aggregatedApps = req.getParameterValues("aggregatedApps"); try { if (appName == null || appUrls == null && aggregatedApps == null) { throw new IllegalArgumentException(I18N.getString("donnees_manquantes")); } if (appUrls != null && !appUrls.startsWith("http: && !appUrls.startsWith("https: throw new IllegalArgumentException(I18N.getString("urls_format")); } final CollectorController collectorController = new CollectorController( collectorServer); if ("unregisterNode".equals(action)) { collectorController.removeCollectorApplicationNodes(appName, appUrls); LOGGER.info("monitored application node removed: " + appName + ", url: " + appUrls); } else if (appUrls != null) { collectorController.addCollectorApplication(appName, appUrls); LOGGER.info("monitored application added: " + appName); LOGGER.info("urls of the monitored application: " + appUrls); } else { assert aggregatedApps != null; collectorController.addCollectorAggregationApplication(appName, Arrays.asList(aggregatedApps)); LOGGER.info("aggregation application added: " + appName); LOGGER.info("aggregated applications of the aggregation application: " + Arrays.asList(aggregatedApps)); } CollectorController.showAlertAndRedirectTo(resp, I18N.getFormattedString("application_ajoutee", appName), "?application=" + appName); } catch (final FileNotFoundException e) { final String message = I18N.getString("monitoring_configure"); throw new IllegalStateException(message + '\n' + e, e); } catch (final StreamCorruptedException e) { final String message = I18N.getFormattedString("reponse_non_comprise", appUrls); throw new IllegalStateException(message + '\n' + e, e); } }  @Override void init(ServletConfig config); @Override void destroy(); static void addCollectorApplication(String application, String urls); static void removeCollectorApplication(String application); }
CollectorServlet extends HttpServlet { private void addCollectorApplication(HttpServletRequest req, HttpServletResponse resp) throws IOException { final String appName = req.getParameter("appName"); final String appUrls = req.getParameter("appUrls"); final String action = req.getParameter("action"); final String[] aggregatedApps = req.getParameterValues("aggregatedApps"); try { if (appName == null || appUrls == null && aggregatedApps == null) { throw new IllegalArgumentException(I18N.getString("donnees_manquantes")); } if (appUrls != null && !appUrls.startsWith("http: && !appUrls.startsWith("https: throw new IllegalArgumentException(I18N.getString("urls_format")); } final CollectorController collectorController = new CollectorController( collectorServer); if ("unregisterNode".equals(action)) { collectorController.removeCollectorApplicationNodes(appName, appUrls); LOGGER.info("monitored application node removed: " + appName + ", url: " + appUrls); } else if (appUrls != null) { collectorController.addCollectorApplication(appName, appUrls); LOGGER.info("monitored application added: " + appName); LOGGER.info("urls of the monitored application: " + appUrls); } else { assert aggregatedApps != null; collectorController.addCollectorAggregationApplication(appName, Arrays.asList(aggregatedApps)); LOGGER.info("aggregation application added: " + appName); LOGGER.info("aggregated applications of the aggregation application: " + Arrays.asList(aggregatedApps)); } CollectorController.showAlertAndRedirectTo(resp, I18N.getFormattedString("application_ajoutee", appName), "?application=" + appName); } catch (final FileNotFoundException e) { final String message = I18N.getString("monitoring_configure"); throw new IllegalStateException(message + '\n' + e, e); } catch (final StreamCorruptedException e) { final String message = I18N.getFormattedString("reponse_non_comprise", appUrls); throw new IllegalStateException(message + '\n' + e, e); } }  @Override void init(ServletConfig config); @Override void destroy(); static void addCollectorApplication(String application, String urls); static void removeCollectorApplication(String application);  }