/**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();

    try {

      ApplicationContext appContext =
          WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
      ceaService = appContext.getBean(ICountryEnvironmentApplicationService.class);
      factoryCea = appContext.getBean(IFactoryCountryEnvironmentApplication.class);
      PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);

      String id = policy.sanitize(request.getParameter("id"));
      String system = id.split("System&#61;")[1].split("&amp;")[0];
      String country = id.split("Country&#61;")[1].split("&amp;")[0];
      String env = id.split("Env&#61;")[1].split("&amp;")[0];
      String app = id.split("App&#61;")[1].split("&amp;")[0];

      response.setContentType("text/html");
      ceaService.delete(factoryCea.create(system, country, env, app, null, null, null, null));
    } catch (CerberusException ex) {
      Logger.getLogger(DeleteCountryEnvironmentParameter.class.getName())
          .log(Level.SEVERE, null, ex);
    }
  }
Ejemplo n.º 2
0
  @Override
  public List<JSONObject> findActiveEnvironmentBySystemCountryApplication(
      String system, String country, String application) throws CerberusException {
    List<JSONObject> result = new ArrayList();
    CountryEnvParam countryEnvParam = countryEnvParamFactory.create(system, country, true);
    CountryEnvironmentApplication countryEnvironmentApplication =
        countryEnvironmentApplicationFactory.create(
            system, country, null, application, null, null, null, null);

    List<CountryEnvironmentApplication> ceaList =
        countryEnvironmentApplicationService.findCountryEnvironmentApplicationByCriteria(
            countryEnvironmentApplication);
    List<CountryEnvParam> ceList = this.findCountryEnvParamByCriteria(countryEnvParam);

    try {
      for (CountryEnvironmentApplication cea : ceaList) {
        for (CountryEnvParam ce : ceList) {
          if (cea.getEnvironment().equals(ce.getEnvironment())) {

            JSONObject jsonObject = new JSONObject();
            jsonObject.put("environment", ce.getEnvironment());
            jsonObject.put("build", ce.getBuild());
            jsonObject.put("revision", ce.getRevision());
            jsonObject.put("ip", cea.getIp());
            jsonObject.put("url", cea.getUrl());
            result.add(jsonObject);
          }
        }
      }
    } catch (JSONException ex) {
      Logger.getLogger(CountryEnvParamService.class.getName()).log(Level.SEVERE, null, ex);
    }
    return result;
  }