/** * Depending on whether the user said "dismiss" or "correct", send him to the right place. */ public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if(req.hasParameter("correct")) { rsp.sendRedirect(req.getContextPath()+"/pluginManager"); } }
@RequirePOST public HttpResponse doScan(StaplerRequest req) throws IOException, GeneralSecurityException { if(req.hasParameter("background")) { start(false); } else if(req.hasParameter("schedule")) { scanOnBoot.on(); } else if(req.hasParameter("dismiss")) { disable(true); } else throw HttpResponses.error(400,"Invalid request submission: " + req.getParameterMap()); return HttpResponses.redirectViaContextPath("/manage"); }
long lastModified = fileParameter.lastModified(); long contentLength = fileParameter.length(); if (request.hasParameter("view")) { response.serveFile(request, data, lastModified, contentLength, "plain.txt"); } else {
private WebHookAction onGet(Job<?, ?> project, String restOfPath, StaplerRequest request) { Matcher commitMatcher = COMMIT_STATUS_PATTERN.matcher(restOfPath); if (restOfPath.isEmpty() && request.hasParameter("ref")) { return new BranchBuildPageRedirectAction(project, request.getParameter("ref")); } else if (restOfPath.endsWith("status.png")) { return onGetStatusPng(project, request); } else if (commitMatcher.matches()) { return onGetCommitStatus(project, commitMatcher.group("sha1"), commitMatcher.group("statusJson")); } LOGGER.log(Level.FINE, "Unknown GET request: {0}", restOfPath); return new NoopAction(); }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ @RequirePOST public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if (req.hasParameter("no")) { disable(true); return HttpResponses.redirectViaContextPath("/manage"); } else { return new HttpRedirect("manage"); } }
/** * Gets the list of suggestions that match the given query. * * @return * can be empty but never null. The size of the list is always smaller than * a certain threshold to avoid showing too many options. */ public SearchResult getSuggestions(StaplerRequest req, String query) { Set<String> paths = new HashSet<String>(); // paths already added, to control duplicates SearchResultImpl r = new SearchResultImpl(); int max = req.hasParameter("max") ? Integer.parseInt(req.getParameter("max")) : 100; SearchableModelObject smo = findClosestSearchableModelObject(req); for (SuggestedItem i : suggest(makeSuggestIndex(req), query, smo)) { if(r.size()>=max) { r.hasMoreResults = true; break; } if(paths.add(i.getPath())) r.add(i); } return r; }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ @RequirePOST public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if(req.hasParameter("no")) { disable(true); rsp.sendRedirect(req.getContextPath()+"/manage"); } else { rsp.sendRedirect(req.getContextPath()+"/newView"); } }
/** * Called from the management screen. */ @RequirePOST public HttpResponse doAct(StaplerRequest req) throws ServletException, IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); if(req.hasParameter("n")) { // we'll shut up disable(true); return HttpResponses.redirectViaContextPath("/manage"); } return new HttpRedirect("confirm"); }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ @RequirePOST public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if(req.hasParameter("no")) { disable(true); rsp.sendRedirect(req.getContextPath()+"/manage"); } else { rsp.sendRedirect(req.getContextPath()+"/configureSecurity"); } } }
private WebHookAction onGetStatusPng(Job<?, ?> project, StaplerRequest request) { if (request.hasParameter("ref")) { return new BranchStatusPngAction(project, request.getParameter("ref")); } else { return new CommitStatusPngAction(project, request.getParameter("sha1")); } }
@RequirePOST public HttpResponse doUpdateSources(StaplerRequest req) throws IOException { Jenkins.getInstance().checkPermission(CONFIGURE_UPDATECENTER); if (req.hasParameter("remove")) { UpdateCenter uc = Jenkins.getInstance().getUpdateCenter(); BulkChange bc = new BulkChange(uc); try { for (String id : req.getParameterValues("sources")) uc.getSites().remove(uc.getById(id)); } finally { bc.commit(); } } else if (req.hasParameter("add")) return new HttpRedirect("addSite"); return new HttpRedirect("./sites"); }
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException { Jenkins j = Jenkins.get(); try { // for compatibility reasons, this value is stored in Jenkins String num = json.getString("numExecutors"); if (!num.matches("\\d+")) { throw new FormException(Messages.Hudson_Computer_IncorrectNumberOfExecutors(),"numExecutors"); } j.setNumExecutors(json.getInt("numExecutors")); if (req.hasParameter("master.mode")) j.setMode(Mode.valueOf(req.getParameter("master.mode"))); else j.setMode(Mode.NORMAL); j.setLabelString(json.optString("labelString", "")); return true; } catch (IOException e) { throw new FormException(e,"numExecutors"); } } }
blockBuildWhenUpstreamBuilding = json.optBoolean("blockBuildWhenUpstreamBuilding"); if(req.hasParameter("customWorkspace.directory")) { } else if(req.hasParameter("_.assignedLabelString")) {
/** * Depending on whether the user said "dismiss" or "correct", send him to the right place. */ public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if(req.hasParameter("correct")) { rsp.sendRedirect(req.getContextPath()+"/pluginManager"); } }
@Override protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException { super.submit(req, rsp); setCustomWorkspace( req.hasParameter("customWorkspace") ? req.getParameter("customWorkspace.directory") : null); }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if (req.hasParameter("no")) { disable(true); return HttpResponses.redirectViaContextPath("/manage"); } else { return new HttpRedirect("manage"); } }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ @RequirePOST public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if (req.hasParameter("no")) { disable(true); return HttpResponses.redirectViaContextPath("/manage"); } else { return new HttpRedirect("manage"); } }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if(req.hasParameter("no")) { disable(true); rsp.sendRedirect(req.getContextPath()+"/manage"); } else { rsp.sendRedirect(req.getContextPath()+"/newView"); } }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if(req.hasParameter("no")) { disable(true); rsp.sendRedirect(req.getContextPath()+"/manage"); } else { rsp.sendRedirect(req.getContextPath()+"/newView"); } }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ @RequirePOST public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if(req.hasParameter("no")) { disable(true); rsp.sendRedirect(req.getContextPath()+"/manage"); } else { rsp.sendRedirect(req.getContextPath()+"/newView"); } }