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 doDynamic(StaplerResponse rsp) throws IOException { // Compromise to handle both browsers (auto-redirect) and programmatic access // (want accurate 404 response).. send 404 with javscript to redirect browsers. rsp.setStatus(HttpServletResponse.SC_NOT_FOUND); rsp.setContentType("text/html;charset=UTF-8"); PrintWriter out = rsp.getWriter(); out.println("<html><head>" + "<meta http-equiv='refresh' content='1;url=..'/>" + "<script>window.location.replace('..');</script>" + "</head>" + "<body style='background-color:white; color:white;'>" + "Not found</body></html>"); out.flush(); } }
/** * This is where we receive inputs from the client. */ public synchronized void upload(StaplerRequest req, StaplerResponse rsp) throws InterruptedException, IOException { rsp.setStatus(HttpServletResponse.SC_OK); InputStream in = req.getInputStream(); if (DIY_CHUNKING) { in = new ChunkedInputStream(in); } // publish the upload channel upload = in; LOGGER.log(Level.FINE, "Recording upload stream {0} for {1}: {2}", new Object[] {upload, uuid, this}); notify(); // wait until we are done while (!completed) { wait(); } }
/** * Handles incremental log output. */ public void doProgressiveLog( StaplerRequest req, StaplerResponse rsp) throws IOException { AnnotatedLargeText text = obtainLog(); if(text!=null) { text.doProgressText(req,rsp); return; } rsp.setStatus(HttpServletResponse.SC_OK); }
/** * Handles incremental log output. */ public void doProgressiveHtml( StaplerRequest req, StaplerResponse rsp) throws IOException { AnnotatedLargeText text = obtainLog(); if(text!=null) { text.doProgressiveHtml(req,rsp); return; } rsp.setStatus(HttpServletResponse.SC_OK); }
/** * Parses trackback ping. */ public static void doTrackback( Object it, StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { String url = req.getParameter("url"); rsp.setStatus(HttpServletResponse.SC_OK); rsp.setContentType("application/xml; charset=UTF-8"); try (PrintWriter pw = rsp.getWriter()) { pw.println("<response>"); pw.println("<error>" + (url != null ? 0 : 1) + "</error>"); if (url == null) { pw.println("<message>url must be specified</message>"); } pw.println("</response>"); } }
public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException { // this is legacy --- all views should be eventually converted to // the permission based model. if(required!=null && !Hudson.adminCheck(req, rsp)) { // check failed. commit the FORBIDDEN response, then abort. rsp.setStatus(HttpServletResponse.SC_FORBIDDEN); rsp.getOutputStream().close(); throw new ServletException("Unauthorized access"); } // make sure the user owns the necessary permission to access this page. if(permission!=null) checkPermission(permission); }
/** * Returns the build time stamp in the body. */ public void doBuildTimestamp( StaplerRequest req, StaplerResponse rsp, @QueryParameter String format) throws IOException { rsp.setContentType("text/plain"); rsp.setCharacterEncoding("US-ASCII"); rsp.setStatus(HttpServletResponse.SC_OK); DateFormat df = format==null ? DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT, Locale.ENGLISH) : new SimpleDateFormat(format,req.getLocale()); rsp.getWriter().print(df.format(getTime())); }
/** * For debugging. Expose URL to perform GC. */ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("DM_GC") @RequirePOST public void doGc(StaplerResponse rsp) throws IOException { checkPermission(Jenkins.ADMINISTER); System.gc(); rsp.setStatus(HttpServletResponse.SC_OK); rsp.setContentType("text/plain"); rsp.getWriter().println("GCed"); }
/** * Returns the build number in the body. */ public void doBuildNumber(StaplerResponse rsp) throws IOException { rsp.setContentType("text/plain"); rsp.setCharacterEncoding("US-ASCII"); rsp.setStatus(HttpServletResponse.SC_OK); rsp.getWriter().print(number); }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType("text/html;charset=UTF-8"); rsp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); rsp.setHeader("X-Jenkins-Select-Error", selectionCleared ? "clear" : "retain"); rsp.getWriter().print(renderHtml()); }
/** * Exposes assets in the core classloader over HTTP. */ public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { String path = req.getRestOfPath(); URL resource = findResource(path); if (resource == null) { rsp.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } // Stapler routes requests like the "/static/.../foo/bar/zot" to be treated like "/foo/bar/zot" // and this is used to serve long expiration header, by using Jenkins.VERSION_HASH as "..." // to create unique URLs. Recognize that and set a long expiration header. String requestPath = req.getRequestURI().substring(req.getContextPath().length()); boolean staticLink = requestPath.startsWith("/static/"); long expires = staticLink ? TimeUnit.DAYS.toMillis(365) : -1; // use serveLocalizedFile to support automatic locale selection rsp.serveLocalizedFile(req, resource, expires); }
@RequirePOST public void doWorkspaceCleanup(StaplerResponse rsp) throws IOException { checkPermission(ADMINISTER); WorkspaceCleanupThread.invoke(); rsp.setStatus(HttpServletResponse.SC_OK); rsp.setContentType("text/plain"); rsp.getWriter().println("Invoked"); }
@RequirePOST public void doFingerprintCleanup(StaplerResponse rsp) throws IOException { checkPermission(ADMINISTER); FingerprintCleanupThread.invoke(); rsp.setStatus(HttpServletResponse.SC_OK); rsp.setContentType("text/plain"); rsp.getWriter().println("Invoked"); }
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); }
public static void checkPermission(Job<?,?> project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException { if (!Jenkins.getInstance().isUseSecurity()) return; // everyone is authorized if(token!=null && token.token != null) { //check the provided token String providedToken = req.getParameter("token"); if (providedToken != null && providedToken.equals(token.token)) return; if (providedToken != null) throw new AccessDeniedException(Messages.BuildAuthorizationToken_InvalidTokenProvided()); } project.checkPermission(Item.BUILD); if (req.getMethod().equals("POST")) { return; } if (req.getAttribute(ApiTokenProperty.class.getName()) instanceof User) { return; } rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); rsp.addHeader("Allow", "POST"); throw HttpResponses.forwardToView(project, "requirePOST.jelly"); }
/** * 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); }