/** * Backward compatibility. Redirect to the thread dump. */ // TODO annotate @GET once baseline includes Stapler version XXX public void doClassicThreadDump(StaplerResponse rsp) throws IOException, ServletException { rsp.sendRedirect2("threadDump"); }
/** * RSS feed for log entries. * * @deprecated * As on 1.267, moved to "/log/rss..." */ @Deprecated public void doLogRss( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { String qs = req.getQueryString(); rsp.sendRedirect2("./log/rss"+(qs==null?"":'?'+qs)); }
/** * Returns the image that shows the current buildCommand status. */ public void doBuildStatus(StaplerRequest req, StaplerResponse rsp) throws IOException { rsp.sendRedirect2(req.getContextPath() + "/images/48x48/" + getBuildStatusUrl()); }
/** * Cancel all scheduled jenkins restarts */ @RequirePOST public void doCancelRestart(StaplerResponse response) throws IOException, ServletException { synchronized (jobs) { for (UpdateCenterJob job : jobs) { if (job instanceof RestartJenkinsJob) { if (((RestartJenkinsJob) job).cancel()) { LOGGER.info("Scheduled Jenkins reboot unscheduled"); } } } } response.sendRedirect2("."); }
public void doBuildStatus( StaplerRequest req, StaplerResponse rsp ) throws IOException { rsp.sendRedirect2(req.getContextPath()+"/images/48x48/"+getBuildStatusUrl()); }
/** * Changes the icon size by changing the cookie */ public void doIconSize( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { String qs = req.getQueryString(); if(qs==null) throw new ServletException(); Cookie cookie = new Cookie("iconSize", Functions.validateIconSize(qs)); cookie.setMaxAge(/* ~4 mo. */9999999); // #762 rsp.addCookie(cookie); String ref = req.getHeader("Referer"); if(ref==null) ref="."; rsp.sendRedirect2(ref); }
/** * Ignore the problem and go back to using Hudson. */ @RequirePOST public void doIgnore(StaplerRequest req, StaplerResponse rsp) throws IOException { ignore = true; Jenkins.getInstance().servletContext.setAttribute("app", Jenkins.getInstance()); rsp.sendRedirect2(req.getContextPath()+'/'); }
/** * URL binding to disable this monitor. */ @RequirePOST public void doDisable(StaplerRequest req, StaplerResponse rsp) throws IOException { disable(true); rsp.sendRedirect2(req.getContextPath()+"/manage"); }
@RequirePOST public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { j.forceSetSlaveAgentPort(getExpectedPort()); rsp.sendRedirect2(req.getContextPath() + "/manage"); }
/** * Performs hudson downgrade. */ @RequirePOST public void doRestart(StaplerResponse rsp) throws IOException, ServletException { HudsonDowngradeJob job = new HudsonDowngradeJob(getCoreSource(), Jenkins.getAuthentication()); LOGGER.info("Scheduling the core downgrade"); addJob(job); rsp.sendRedirect2("."); }
/** * Schedules a Jenkins restart. */ @RequirePOST public void doSafeRestart(StaplerRequest request, StaplerResponse response) throws IOException, ServletException { synchronized (jobs) { if (!isRestartScheduled()) { addJob(new RestartJenkinsJob(getCoreSource())); LOGGER.info("Scheduling Jenkins reboot"); } } response.sendRedirect2("."); }
/** * Perform a restart of Jenkins, if we can. * * This first replaces "app" to {@link HudsonIsRestarting} */ @CLIMethod(name="restart") public void doRestart(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, RestartNotSupportedException { checkPermission(ADMINISTER); if (req != null && req.getMethod().equals("GET")) { req.getView(this,"_restart.jelly").forward(req,rsp); return; } if (req == null || req.getMethod().equals("POST")) { restart(); } if (rsp != null) { rsp.sendRedirect2("."); } }
/** * Deletes this recorder, then go back to the parent. */ @RequirePOST public synchronized void doDoDelete(StaplerResponse rsp) throws IOException, ServletException { getConfigFile().delete(); getParent().logRecorders.remove(name); // Disable logging for all our targets, // then reenable all other loggers in case any also log the same targets for (Target t : targets) t.disable(); for (LogRecorder log : getParent().logRecorders.values()) for (Target t : log.targets) t.enable(); rsp.sendRedirect2(".."); }
/** * Deletes this view. */ @RequirePOST public synchronized void doDoDelete(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { checkPermission(DELETE); owner.deleteView(this); rsp.sendRedirect2(req.getContextPath()+"/" + owner.getUrl()); }
/** * Performs hudson downgrade. */ @RequirePOST public void doDowngrade(StaplerResponse rsp) throws IOException, ServletException { if(!isDowngradable()) { sendError("Jenkins downgrade is not possible, probably backup does not exist"); return; } HudsonDowngradeJob job = new HudsonDowngradeJob(getCoreSource(), Jenkins.getAuthentication()); LOGGER.info("Scheduling the core downgrade"); addJob(job); rsp.sendRedirect2("."); }
/** * Schedules a Jenkins upgrade. */ @RequirePOST public void doUpgrade(StaplerResponse rsp) throws IOException, ServletException { HudsonUpgradeJob job = new HudsonUpgradeJob(getCoreSource(), Jenkins.getAuthentication()); if(!Lifecycle.get().canRewriteHudsonWar()) { sendError("Jenkins upgrade not supported in this running mode"); return; } LOGGER.info("Scheduling the core upgrade"); addJob(job); rsp.sendRedirect2("."); }
/** * Checks if the user was successfully authenticated. * * @see BasicAuthenticationFilter */ public void doSecured( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { // TODO fire something in SecurityListener? (seems to be used only for REST calls when LegacySecurityRealm is active) if(req.getUserPrincipal()==null) { // authentication must have failed rsp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return; } // the user is now authenticated, so send him back to the target String path = req.getContextPath()+req.getOriginalRestOfPath(); String q = req.getQueryString(); if(q!=null) path += '?'+q; rsp.sendRedirect2(path); }
/** * Really creates a new agent. */ @RequirePOST public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type ) throws IOException, ServletException, FormException { final Jenkins app = Jenkins.getInstance(); app.checkPermission(Computer.CREATE); String fixedName = Util.fixEmptyAndTrim(name); checkName(fixedName); JSONObject formData = req.getSubmittedForm(); formData.put("name", fixedName); // TODO type is probably NodeDescriptor.id but confirm Node result = NodeDescriptor.all().find(type).newInstance(req, formData); app.addNode(result); // take the user back to the agent list top page rsp.sendRedirect2("."); }
/** * Deletes this user from Hudson. */ @RequirePOST public void doDoDelete(StaplerRequest req, StaplerResponse rsp) throws IOException { checkPermission(Jenkins.ADMINISTER); if (idStrategy().equals(id, Jenkins.getAuthentication().getName())) { rsp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Cannot delete self"); return; } delete(); rsp.sendRedirect2("../.."); }
/** * Do a finger-print check. */ @RequirePOST public void doDoFingerprintCheck( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { // Parse the request try (MultipartFormDataParser p = new MultipartFormDataParser(req)) { if (isUseCrumbs() && !getCrumbIssuer().validateCrumb(req, p)) { // TODO investigate whether this check can be removed rsp.sendError(HttpServletResponse.SC_FORBIDDEN, "No crumb found"); } rsp.sendRedirect2(req.getContextPath()+"/fingerprint/"+ Util.getDigestOf(p.getFileItem("name").getInputStream())+'/'); } }