org.kohsuke.stapler.StaplerRequest.getAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(64)

本文整理了Java中org.kohsuke.stapler.StaplerRequest.getAttribute()方法的一些代码示例,展示了StaplerRequest.getAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.getAttribute()方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:getAttribute

StaplerRequest.getAttribute介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * 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;
}

代码示例来源:origin: stapler/stapler

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());
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * @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();
}

代码示例来源:origin: jenkinsci/jenkins

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");
}

代码示例来源:origin: jenkinsci/build-failure-analyzer-plugin

/**
 * 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);
}

代码示例来源:origin: jenkinsci/build-failure-analyzer-plugin

/**
 * 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;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * 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;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * 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;
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * 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;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * 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;
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * 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;
}

代码示例来源:origin: org.jenkins-ci.plugins/extended-choice-parameter

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;
}

代码示例来源:origin: stapler/stapler

public static EvaluationTrace get(StaplerRequest req) {
  EvaluationTrace et = (EvaluationTrace) req.getAttribute(KEY);
  if(et==null)
    req.setAttribute(KEY,et=new EvaluationTrace());
  return et;
}

代码示例来源:origin: org.hudsonci.stapler/stapler-core

public static EvaluationTrace get(StaplerRequest req) {
  EvaluationTrace et = (EvaluationTrace) req.getAttribute(KEY);
  if(et==null)
    req.setAttribute(KEY,et=new EvaluationTrace());
  return et;
}

代码示例来源:origin: org.kohsuke.stapler/stapler

public static EvaluationTrace get(StaplerRequest req) {
  EvaluationTrace et = (EvaluationTrace) req.getAttribute(KEY);
  if(et==null)
    req.setAttribute(KEY,et=new EvaluationTrace());
  return et;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * @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();
}

代码示例来源:origin: org.eclipse.hudson.stapler/stapler-jelly

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);
}

代码示例来源:origin: stapler/stapler

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);
}

代码示例来源:origin: org.eclipse.hudson.stapler/stapler-jelly

/**
 * 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;
}

代码示例来源:origin: stapler/stapler

/**
 * 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;
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法