public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException { rsp.setStatus(SC_SERVICE_UNAVAILABLE); req.getView(this,"index.jelly").forward(req,rsp); } }
/** * Serve all URLs with the index view. */ public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { rsp.setStatus(SC_INTERNAL_SERVER_ERROR); req.getView(this,"index.jelly").forward(req,rsp); }
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException { rsp.setStatus(SC_SERVICE_UNAVAILABLE); req.getView(this,"index.jelly").forward(req,rsp); } }
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException { rsp.setStatus(SC_SERVICE_UNAVAILABLE); req.getView(this,"index.jelly").forward(req,rsp); } }
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { req.getView(this,chooseAction()).forward(req,rsp); }
public static boolean hasView(Object it, String path) throws IOException { if(it==null) return false; return Stapler.getCurrentRequest().getView(it,path)!=null; }
/** * Sign up for the user account. */ public void doSignup( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { if (getSecurityRealm().allowsSignup()) { req.getView(getSecurityRealm(), "signup.jelly").forward(req, rsp); return; } req.getView(SecurityRealm.class, "signup.jelly").forward(req, rsp); }
/** * Handles the form submission from the "/computer/new" page, which is the first form for creating a new node. * By default, it shows the configuration page for entering details, but subtypes can override this differently. * * @param name * Name of the new node. */ public void handleNewNodePage(ComputerSet computerSet, String name, StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { computerSet.checkName(name); req.setAttribute("descriptor", this); req.getView(computerSet,"_new.jelly").forward(req,rsp); }
/** * Run arbitrary Groovy script and return result as plain text. */ public void doScriptText(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { _doScript(req, rsp, req.getView(this, "_scriptText.jelly"), FilePath.localChannel, getACL()); }
/** * @param req the request to get the form data from (is also used for redirection) * @param rsp the response to use for forwarding if the creation fails * @param validateCaptcha whether to attempt to validate a captcha in the request * @param formView the view to redirect to if creation fails * * @return * null if failed. The browser is already redirected to retry by the time this method returns. * a valid {@link User} object if the user creation was successful. */ private User createAccount(StaplerRequest req, StaplerResponse rsp, boolean validateCaptcha, String formView) throws ServletException, IOException { SignupInfo si = validateAccountCreationForm(req, validateCaptcha); if (!si.errors.isEmpty()) { // failed. ask the user to try again. req.getView(this, formView).forward(req, rsp); return null; } return createAccount(si); }
/** * For system diagnostics. * Run arbitrary Groovy script. */ public void doScript(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { _doScript(req, rsp, req.getView(this, "_script.jelly"), FilePath.localChannel, getACL()); }
@RequirePOST @Override public void doLaunchSlaveAgent(StaplerRequest req, StaplerResponse rsp) throws IOException { checkPermission(CONNECT); if(channel!=null) { try { req.getView(this, "already-launched.jelly").forward(req, rsp); } catch (IOException x) { throw x; } catch (/*Servlet*/Exception x) { throw new IOException(x); } return; } connect(true); // TODO: would be nice to redirect the user to "launching..." wait page, // then spend a few seconds there and poll for the completion periodically. rsp.sendRedirect("log"); }
protected void _doScript(StaplerRequest req, StaplerResponse rsp, String view) throws IOException, ServletException { Jenkins._doScript(req, rsp, req.getView(this, view), getChannel(), getACL()); }
public String getHelpFile(Klass<?> clazz, String fieldName) { HelpRedirect r = helpRedirect.get(fieldName); if (r!=null) return r.resolve(); for (Klass<?> c : clazz.getAncestors()) { String page = "/descriptor/" + getId() + "/help"; String suffix; if(fieldName==null) { suffix=""; } else { page += '/'+fieldName; suffix='-'+fieldName; } try { if(Stapler.getCurrentRequest().getView(c,"help"+suffix)!=null) return page; } catch (IOException e) { throw new Error(e); } if(getStaticHelpUrl(c, suffix) !=null) return page; } return null; }
public void doCommand(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException { final Jenkins jenkins = Jenkins.getActiveInstance(); jenkins.checkPermission(Jenkins.READ); // Strip trailing slash final String commandName = req.getRestOfPath().substring(1); CLICommand command = CLICommand.clone(commandName); if (command == null) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND, "No such command"); return; } req.setAttribute("command", command); req.getView(this, "command.jelly").forward(req, rsp); }
/** * 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("."); } }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { SecurityRealm sr = Jenkins.getInstance().getSecurityRealm(); if (sr.allowsSignup()) { try { sr.commenceSignup(identity).generateResponse(req,rsp,node); return; } catch (UnsupportedOperationException e) { // fall through } } // this security realm doesn't support user registration. // just report an error req.getView(this,"error").forward(req,rsp); } }
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { List<Ancestor> l = req.getAncestors(); for( int i=l.size()-1; i>=0; i-- ) { Ancestor a = l.get(i); if (a.getObject() instanceof SearchableModelObject) { SearchableModelObject smo = (SearchableModelObject) a.getObject(); if(LOGGER.isLoggable(Level.FINE)){ LOGGER.fine(String.format("smo.displayName=%s, searchName=%s",smo.getDisplayName(), smo.getSearchName())); } SearchIndex index = smo.getSearchIndex(); String query = req.getParameter("q"); if(query!=null) { SuggestedItem target = find(index, query, smo); if(target!=null) { // found rsp.sendRedirect2(req.getContextPath()+target.getUrl()); return; } } } } // no exact match. show the suggestions rsp.setStatus(SC_NOT_FOUND); req.getView(this,"search-failed.jelly").forward(req,rsp); }
/** * Sends the RSS feed to the client. * * @param title * Title of the feed. * @param url * URL of the model object that owns this feed. Relative to the context root. * @param entries * Entries to be listed in the RSS feed. * @param adapter * Controls how to render entries to RSS. */ public static <E> void forwardToRss(String title, String url, Collection<? extends E> entries, FeedAdapter<E> adapter, StaplerRequest req, HttpServletResponse rsp) throws IOException, ServletException { req.setAttribute("adapter",adapter); req.setAttribute("title",title); req.setAttribute("url",url); req.setAttribute("entries",entries); req.setAttribute("rootURL", Jenkins.getInstance().getRootUrl()); String flavor = req.getParameter("flavor"); if(flavor==null) flavor="atom"; flavor = flavor.replace('/', '_'); // Don't allow path to any jelly req.getView(Jenkins.getInstance(),"/hudson/"+flavor+".jelly").forward(req,rsp); } }
/** * Lets the current user silently login as the given user and report back accordingly. */ @SuppressWarnings("ACL.impersonate") private void loginAndTakeBack(StaplerRequest req, StaplerResponse rsp, User u) throws ServletException, IOException { HttpSession session = req.getSession(false); if (session != null) { // avoid session fixation session.invalidate(); } req.getSession(true); // ... and let him login Authentication a = new UsernamePasswordAuthenticationToken(u.getId(),req.getParameter("password1")); a = this.getSecurityComponents().manager.authenticate(a); SecurityContextHolder.getContext().setAuthentication(a); SecurityListener.fireLoggedIn(u.getId()); // then back to top req.getView(this,"success.jelly").forward(req,rsp); }