public HttpResponse doDoMove(StaplerRequest req, @QueryParameter String destination) throws IOException { if (getStore().getDomains().size() <= 1) { return HttpResponses.status(400); int split = destination.lastIndexOf(splitKey); if (split == -1) { return HttpResponses.status(400); return HttpResponses.status(400); return HttpResponses.status(400); return HttpResponses.status(400);
public HttpResponse doDoMove(StaplerRequest req, @QueryParameter String destination) throws IOException { if (getStore().getDomains().size() <= 1) { return HttpResponses.status(400); int split = destination.lastIndexOf(splitKey); if (split == -1) { return HttpResponses.status(400); return HttpResponses.status(400); return HttpResponses.status(400); return HttpResponses.status(400);
return HttpResponses.ok(); } else { return HttpResponses.status(HttpServletResponse.SC_CONFLICT);
return HttpResponses.ok(); } else { return HttpResponses.status(HttpServletResponse.SC_CONFLICT);
/** * Web binding for {@literal /healthcheck} * * @param req the request * @return the response */ @Restricted(NoExternalUse.class) // only for use by stapler web binding public HttpResponse doHealthcheck(StaplerRequest req) { long ifModifiedSince = req.getDateHeader("If-Modified-Since"); long maxAge = getCacheControlMaxAge(req); Metrics.HealthCheckData data = Metrics.getHealthCheckData(); if (data == null || (maxAge != -1 && data.getLastModified() + maxAge < System.currentTimeMillis())) { // if the max-age was specified, get live data data = new Metrics.HealthCheckData(Metrics.healthCheckRegistry().runHealthChecks()); } else if (ifModifiedSince != -1 && data.getLastModified() < ifModifiedSince) { return HttpResponses.status(HttpServletResponse.SC_NOT_MODIFIED); } return new HealthCheckResponse(data); }
/** * Stapler web binding for adding credentials to the domain. * * @param req the request. * @param rsp the response. * @throws IOException if something goes wrong. * @throws ServletException if something goes wrong. */ @RequirePOST public void doAddCredentials(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { if (!store.isDomainsModifiable()) { hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null); FormApply.applyResponse("window.alert('Domain is read-only')").generateResponse(req, rsp, null); } store.checkPermission(CredentialsStoreAction.CREATE); JSONObject data = req.getSubmittedForm(); String domainName = data.getString("domain"); CredentialsStoreAction.DomainWrapper wrapper = getWrappers().get(domainName); if (!store.getDomains().contains(wrapper.getDomain())) { hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null); FormApply.applyResponse("window.alert('Store does not have selected domain')") .generateResponse(req, rsp, null); } store.checkPermission(CredentialsStoreAction.CREATE); Credentials credentials = req.bindJSON(Credentials.class, data.getJSONObject("credentials")); store.addCredentials(wrapper.getDomain(), credentials); FormApply.applyResponse("window.credentials.refreshAll();").generateResponse(req, rsp, null); }
/** * Stapler web binding for adding credentials to the domain. * * @param req the request. * @param rsp the response. * @throws IOException if something goes wrong. * @throws ServletException if something goes wrong. */ @RequirePOST public void doAddCredentials(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { if (!store.isDomainsModifiable()) { hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null); FormApply.applyResponse("window.alert('Domain is read-only')").generateResponse(req, rsp, null); } store.checkPermission(CredentialsStoreAction.CREATE); JSONObject data = req.getSubmittedForm(); String domainName = data.getString("domain"); CredentialsStoreAction.DomainWrapper wrapper = getWrappers().get(domainName); if (!store.getDomains().contains(wrapper.getDomain())) { hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null); FormApply.applyResponse("window.alert('Store does not have selected domain')") .generateResponse(req, rsp, null); } store.checkPermission(CredentialsStoreAction.CREATE); Credentials credentials = req.bindJSON(Credentials.class, data.getJSONObject("credentials")); store.addCredentials(wrapper.getDomain(), credentials); FormApply.applyResponse("window.credentials.refreshAll();").generateResponse(req, rsp, null); }
/** * Binds the health checks to the CORS aware URL {@code /metrics/healthcheck} where the metrics access key is * provided in the form field {@code key} or an {@code Authorization: Jenkins-Metrics-Key {key}} header * * @param req the request * @param key the key from the form field. * @return the {@link HttpResponse} * @throws IllegalAccessException if the access attempt is invalid. */ @SuppressWarnings("unused") // stapler binding @Restricted(NoExternalUse.class) // stapler binding public HttpResponse doHealthcheck(StaplerRequest req, @QueryParameter("key") String key) throws IllegalAccessException { requireCorrectMethod(req); if (StringUtils.isBlank(key)) { key = getKeyFromAuthorizationHeader(req); } Metrics.checkAccessKeyHealthCheck(key); long ifModifiedSince = req.getDateHeader("If-Modified-Since"); long maxAge = getCacheControlMaxAge(req); Metrics.HealthCheckData data = Metrics.getHealthCheckData(); if (data == null || (maxAge != -1 && data.getLastModified() + maxAge < System.currentTimeMillis())) { data = new Metrics.HealthCheckData(Metrics.healthCheckRegistry().runHealthChecks()); } else if (ifModifiedSince != -1 && data.getLastModified() < ifModifiedSince) { return Metrics.cors(key, HttpResponses.status(HttpServletResponse.SC_NOT_MODIFIED)); } return Metrics.cors(key, new HealthCheckResponse(data)); }
/** * Deletes a domain. * * @param req the request. * @return the response. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doDoDelete(StaplerRequest req) throws IOException { if (!getStore().isDomainsModifiable()) { return HttpResponses.status(400); } getStore().checkPermission(MANAGE_DOMAINS); if (getStore().removeDomain(domain)) { return HttpResponses.redirectTo("../.."); } return HttpResponses.redirectToDot(); }
/** * Deletes a domain. * * @param req the request. * @return the response. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doDoDelete(StaplerRequest req) throws IOException { if (!getStore().isDomainsModifiable()) { return HttpResponses.status(400); } getStore().checkPermission(MANAGE_DOMAINS); if (getStore().removeDomain(domain)) { return HttpResponses.redirectTo("../.."); } return HttpResponses.redirectToDot(); }
data = new Metrics.HealthCheckData(Metrics.healthCheckRegistry().runHealthChecks()); } else if (ifModifiedSince != -1 && data.getLastModified() < ifModifiedSince) { return HttpResponses.status(HttpServletResponse.SC_NOT_MODIFIED);
/** * Updates the domain configuration. * * @param req the request. * @return the response. * @throws ServletException if something goes wrong. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doConfigSubmit(StaplerRequest req) throws ServletException, IOException { if (!getStore().isDomainsModifiable()) { return HttpResponses.status(400); } getStore().checkPermission(MANAGE_DOMAINS); JSONObject data = req.getSubmittedForm(); Domain domain = req.bindJSON(Domain.class, data); String domainName = domain.getName(); if (domainName != null && getStore().updateDomain(this.domain, domain)) { return HttpResponses.redirectTo("../../domain/" + Util.rawEncode(domainName)); } return HttpResponses.redirectToDot(); }
/** * Updates the domain configuration. * * @param req the request. * @return the response. * @throws ServletException if something goes wrong. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doConfigSubmit(StaplerRequest req) throws ServletException, IOException { if (!getStore().isDomainsModifiable()) { return HttpResponses.status(400); } getStore().checkPermission(MANAGE_DOMAINS); JSONObject data = req.getSubmittedForm(); Domain domain = req.bindJSON(Domain.class, data); String domainName = domain.getName(); if (domainName != null && getStore().updateDomain(this.domain, domain)) { return HttpResponses.redirectTo("../../domain/" + Util.rawEncode(domainName)); } return HttpResponses.redirectToDot(); }