コード例 #1
0
  @Override
  protected void doDelete(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    if (userManager != null) {
      // validation user permissions
      if (!CommonJiraPluginUtils.isAnAuthorizedJiraAdministrator(req, userManager)) {
        CommonJiraPluginUtils.unauthorize(res, templateRenderer);
        return;
      }

      // load resources and show template
      loadWebResources();

      // if exist configuration delete the access key
      if (pluginConfigService.hasConfiguration()) {
        aIMSService.deleteAccessKeyId();
      }

      if (pluginConfigService.deleteConfiguration()) {
        res.setContentType("application/json");
        JSONObject obj = new JSONObject();
        obj.put("success", "true");
        res.getWriter().write(obj.toString());
      } else {
        res.sendError(HttpServletResponse.SC_BAD_REQUEST);
      }
    }
  }
コード例 #2
0
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    if (userManager != null) {
      // validation user permissions
      if (!CommonJiraPluginUtils.isAnAuthorizedJiraAdministrator(req, userManager)) {
        CommonJiraPluginUtils.unauthorize(res, templateRenderer);
        return;
      }

      // load resources and show template
      loadWebResources();

      // store if has data
      if (req.getParameterMap().size() > 0) {

        String jiraUser = userManager.getRemoteUsername(req);
        String ciUser = req.getParameter("ciUser");
        String ciUrl = req.getParameter("ciUrl");
        String ciAccessKeyId = req.getParameter("ciAccessKeyId");
        String ciSecretKey = req.getParameter("ciSecretKey");

        if (pluginConfigService.hasConfiguration()) {
          aIMSService.deleteAccessKeyId();
        }

        PluginConfig pluginConfig =
            pluginConfigService.createOrUpdateConfiguration(
                jiraUser, ciUser, ciUrl, ciAccessKeyId, ciSecretKey);

        if (pluginConfig != null) {
          res.setContentType("application/json");
          JSONObject obj = new JSONObject();
          obj.put("success", "true");
          res.getWriter().write(obj.toString());
        } else {
          res.sendError(HttpServletResponse.SC_BAD_REQUEST);
        }
      }
    }
  }