@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); } } }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { if (userManager != null) { if (!CommonJiraPluginUtils.isAnAuthorizedJiraUser(req, userManager)) { CommonJiraPluginUtils.unauthorize(res, templateRenderer); return; } loadWebResources(); Map<String, Object> context = Maps.newHashMap(); context.put("jiraIssueId", req.getParameter("id")); templateRenderer.render(CONFIG_BROWSER_TEMPLATE, context, res.getWriter()); } }
@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); } } } }
@Override protected void doGet(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(); Map<String, Object> context = Maps.newHashMap(); if (pluginConfigService.hasConfiguration()) { context.put("ciUser", pluginConfigService.getConfiguration().getCiUser()); context.put("ciUrl", pluginConfigService.getConfiguration().getCiUrl()); context.put("ciAccessKeyId", pluginConfigService.getConfiguration().getCiAccessKeyId()); } templateRenderer.render(CONFIG_BROWSER_TEMPLATE, context, res.getWriter()); } }