/** * For reusing code between text/html and text/plain, we run them both through the same code path * and use this request attribute to differentiate. */ private boolean isHtml() { StaplerRequest req = Stapler.getCurrentRequest(); return req!=null && req.getAttribute("html")!=null; }
protected void exportVariables(StaplerRequest req, StaplerResponse rsp, Script script, Object it, JellyContext context) { Enumeration en = req.getAttributeNames(); // expose request attributes, just like JSP while (en.hasMoreElements()) { String name = (String) en.nextElement(); context.setVariable(name,req.getAttribute(name)); } context.setVariable("request",req); context.setVariable("response",rsp); context.setVariable("it",it); ServletContext servletContext = req.getServletContext(); context.setVariable("servletContext",servletContext); context.setVariable("app",servletContext.getAttribute("app")); // property bag to store request scope variables context.setVariable("requestScope",context.getVariables()); // this variable is needed to make "jelly:fmt" taglib work correctly context.setVariable("org.apache.commons.jelly.tags.fmt.locale",req.getLocale()); }
/** * @since 1.402 */ public static String getCurrentDescriptorByNameUrl() { StaplerRequest req = Stapler.getCurrentRequest(); // this override allows RenderOnDemandClosure to preserve the proper value Object url = req.getAttribute("currentDescriptorByNameUrl"); if (url!=null) return url.toString(); Ancestor a = req.findAncestor(DescriptorByNameOwner.class); return a.getUrl(); }
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"); }
/** * Used for getting the error message to show on the page. * * @param request the request where the message might be. * @return the error message to show. */ public String getErrorMessage(StaplerRequest request) { return (String)request.getAttribute(REQUEST_CAUSE_MANAGEMENT_ERROR); }
/** * Convenience method for jelly. * * @param request the request where the message might be. * @return true if there is an error message to display. */ public boolean isError(StaplerRequest request) { return Util.fixEmpty((String)request.getAttribute(REQUEST_CAUSE_MANAGEMENT_ERROR)) != null; }
/** * For reusing code between text/html and text/plain, we run them both through the same code path * and use this request attribute to differentiate. */ private boolean isHtml() { StaplerRequest req = Stapler.getCurrentRequest(); return req!=null && req.getAttribute("html")!=null; }
/** * For reusing code between text/html and text/plain, we run them both through the same code path * and use this request attribute to differentiate. */ private boolean isHtml() { return Stapler.getCurrentRequest().getAttribute("html")!=null; }
/** * For reusing code between text/html and text/plain, we run them both * through the same code path and use this request attribute to * differentiate. */ private boolean isHtml() { return Stapler.getCurrentRequest().getAttribute("html") != null; }
/** * For reusing code between text/html and text/plain, we run them both through the same code path * and use this request attribute to differentiate. */ private boolean isHtml() { return Stapler.getCurrentRequest().getAttribute("html")!=null; }
/** * For reusing code between text/html and text/plain, we run them both through the same code path * and use this request attribute to differentiate. */ private boolean isHtml() { return Stapler.getCurrentRequest().getAttribute("html")!=null; }
private Binding getGroovyBinding() { StaplerRequest currentRequest = Stapler.getCurrentRequest(); Binding groovyBinding = (Binding)currentRequest.getAttribute(ATTR_REQUEST_GROOVY_BINDING); if(groovyBinding == null) { groovyBinding = new Binding(); currentRequest.setAttribute(ATTR_REQUEST_GROOVY_BINDING, groovyBinding); } return groovyBinding; }
public static EvaluationTrace get(StaplerRequest req) { EvaluationTrace et = (EvaluationTrace) req.getAttribute(KEY); if(et==null) req.setAttribute(KEY,et=new EvaluationTrace()); return et; }
public static EvaluationTrace get(StaplerRequest req) { EvaluationTrace et = (EvaluationTrace) req.getAttribute(KEY); if(et==null) req.setAttribute(KEY,et=new EvaluationTrace()); return et; }
public static EvaluationTrace get(StaplerRequest req) { EvaluationTrace et = (EvaluationTrace) req.getAttribute(KEY); if(et==null) req.setAttribute(KEY,et=new EvaluationTrace()); return et; }
/** * @since 1.402 */ public static String getCurrentDescriptorByNameUrl() { StaplerRequest req = Stapler.getCurrentRequest(); // this override allows RenderOnDemandClosure to preserve the proper value Object url = req.getAttribute("currentDescriptorByNameUrl"); if (url!=null) return url.toString(); Ancestor a = req.findAncestor(DescriptorByNameOwner.class); return a.getUrl(); }
String format(Object[] args) { // notify the listener if set InternationalizedStringExpressionListener listener = (InternationalizedStringExpressionListener)Stapler.getCurrentRequest().getAttribute(LISTENER_NAME); if(listener!=null) listener.onUsed(this,args); return resourceBundle.format(LocaleProvider.getLocale(),key,args); }
private Object format(Object[] args) { // notify the listener if set InternationalizedStringExpressionListener listener = (InternationalizedStringExpressionListener) Stapler.getCurrentRequest().getAttribute(LISTENER_NAME); if(listener!=null) listener.onUsed(this, args); return resourceBundle.format(LocaleProvider.getLocale(), key, args); }
/** * Obtains the instance associated with the current request of the given {@link StaplerRequest}. * * <p> * This method is handy when the caller already have the request object around, * so that we can save {@link Stapler#getCurrentRequest()} call. */ public static AdjunctsInPage get(StaplerRequest request) { AdjunctsInPage aip = (AdjunctsInPage) request.getAttribute(KEY); if(aip==null) request.setAttribute(KEY,aip=new AdjunctsInPage(AdjunctManager.get(request.getServletContext()),request)); return aip; }
/** * Obtains the instance associated with the current request of the given {@link StaplerRequest}. * * <p> * This method is handy when the caller already have the request object around, * so that we can save {@link Stapler#getCurrentRequest()} call. */ public static AdjunctsInPage get(StaplerRequest request) { AdjunctsInPage aip = (AdjunctsInPage) request.getAttribute(KEY); if(aip==null) request.setAttribute(KEY,aip=new AdjunctsInPage(AdjunctManager.get(request.getServletContext()),request)); return aip; }