hudson.Functions.getNearestAncestorUrl()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(108)

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

Functions.getNearestAncestorUrl介绍

[英]Finds the given object in the ancestor list and returns its URL. This is used to determine the "current" URL assigned to the given object, so that one can compute relative URLs from it.
[中]在祖先列表中查找给定对象并返回其URL。这用于确定分配给给定对象的“当前”URL,以便可以从中计算相对URL。

代码示例

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

/**
 * Used to render the side panel "Back to project" link.
 *
 * <p>
 * In a rare situation where a build can be reached from multiple paths,
 * returning different URLs from this method based on situations might
 * be desirable.
 *
 * <p>
 * If you override this method, you'll most likely also want to override
 * {@link #getDisplayName()}.
 */
public String getUpUrl() {
  return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),getParent())+'/';
}

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

/**
 * Returns the URL of this {@link Run}, relative to the context root of Hudson.
 *
 * @return
 *      String like "job/foo/32/" with trailing slash but no leading slash. 
 */
// I really messed this up. I'm hoping to fix this some time
// it shouldn't have trailing '/', and instead it should have leading '/'
public @Nonnull String getUrl() {
  // RUN may be accessed using permalinks, as "/lastSuccessful" or other, so try to retrieve this base URL
  // looking for "this" in the current request ancestors
  // @see also {@link AbstractItem#getUrl}
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    String seed = Functions.getNearestAncestorUrl(req,this);
    if(seed!=null) {
      // trim off the context path portion and leading '/', but add trailing '/'
      return seed.substring(req.getContextPath().length()+1)+'/';
    }
  }
  return project.getUrl()+getNumber()+'/';
}

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

/**
 * @param owner
 *      The parent model object that owns this widget.
 */
public HistoryWidget(O owner, Iterable<T> baseList, Adapter<? super T> adapter) {
  StaplerRequest currentRequest = Stapler.getCurrentRequest();
  this.adapter = adapter;
  this.baseList = baseList;
  this.baseUrl = Functions.getNearestAncestorUrl(currentRequest,owner);
  this.owner = owner;
  this.newerThan = getPagingParam(currentRequest, "newer-than");
  this.olderThan = getPagingParam(currentRequest, "older-than");
  this.searchString = currentRequest.getParameter("search");;
}

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

String uri = req == null ? null : req.getRequestURI();
if (req != null) {
  String seed = Functions.getNearestAncestorUrl(req,this);
  LOGGER.log(Level.FINER, "seed={0} for {1} from {2}", new Object[] {seed, this, uri});
  if(seed!=null) {

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

/**
 * @param owner
 *      The parent model object that owns this widget.
 */
public HistoryWidget(O owner, Iterable<T> baseList, Adapter<? super T> adapter) {
  this.adapter = adapter;
  this.baseList = baseList;
  this.baseUrl = Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),owner);
  this.owner = owner;
}

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

/**
 * @param owner
 *      The parent model object that owns this widget.
 */
public HistoryWidget(O owner, Iterable<T> baseList, Adapter<? super T> adapter) {
  this.adapter = adapter;
  this.baseList = baseList;
  this.baseUrl = Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),owner);
  this.owner = owner;
}

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

/**
 * @param owner
 *      The parent model object that owns this widget.
 */
public HistoryWidget(O owner, Iterable<T> baseList, Adapter<? super T> adapter) {
  this.adapter = adapter;
  this.baseList = baseList;
  this.baseUrl = Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),owner);
  this.owner = owner;
}

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

/**
 * @param owner The parent model object that owns this widget.
 */
public HistoryWidget(O owner, Iterable<T> baseList, Adapter<? super T> adapter) {
  this.adapter = adapter;
  this.baseList = baseList;
  this.baseUrl = Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(), owner);
  this.owner = owner;
}

代码示例来源:origin: jenkinsci/testng-plugin-plugin

/** Generalizes {@link AbstractBuild#getUpUrl} to {@link Run}. */
public String getUpUrl() {
  return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(), job) + '/';
}

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

/**
 * Used to render the side panel "Back to project" link.
 *
 * <p> In a rare situation where a build can be reached from multiple paths,
 * returning different URLs from this method based on situations might be
 * desirable.
 *
 * <p> If you override this method, you'll most likely also want to override
 * {@link #getDisplayName()}.
 */
public String getUpUrl() {
  return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(), getParent()) + '/';
}

代码示例来源:origin: jenkinsci/testng-plugin-plugin

/** cf. {@link AbstractBuild#getUpUrl} */
private static String getUpUrl(Run<?,?> run) {
  return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(), run.getParent()) + '/';
}

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

/**
 * Used to render the side panel "Back to project" link.
 *
 * <p>
 * In a rare situation where a build can be reached from multiple paths,
 * returning different URLs from this method based on situations might
 * be desirable.
 *
 * <p>
 * If you override this method, you'll most likely also want to override
 * {@link #getDisplayName()}.
 */
public String getUpUrl() {
  return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),getParent())+'/';
}

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

/**
 * Used to render the side panel "Back to project" link.
 *
 * <p>
 * In a rare situation where a build can be reached from multiple paths,
 * returning different URLs from this method based on situations might
 * be desirable.
 *
 * <p>
 * If you override this method, you'll most likely also want to override
 * {@link #getDisplayName()}.
 */
public String getUpUrl() {
  return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),getParent())+'/';
}

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

/**
 * Used to render the side panel "Back to project" link.
 *
 * <p>
 * In a rare situation where a build can be reached from multiple paths,
 * returning different URLs from this method based on situations might
 * be desirable.
 *
 * <p>
 * If you override this method, you'll most likely also want to override
 * {@link #getDisplayName()}.
 */
public String getUpUrl() {
  return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),getParent())+'/';
}

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

/**
 * Used to render the side panel "Back to project" link.
 *
 * <p>
 * In a rare situation where a build can be reached from multiple paths,
 * returning different URLs from this method based on situations might
 * be desirable.
 *
 * <p>
 * If you override this method, you'll most likely also want to override
 * {@link #getDisplayName()}.
 */
public String getUpUrl() {
  return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),getParent())+'/';
}

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

public final String getUrl() {
  // try to stick to the current view if possible
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    String seed = Functions.getNearestAncestorUrl(req, this);
    if (seed != null) {
      // trim off the context path portion and leading '/', but add trailing '/'
      return seed.substring(Functions.getRequestRootPath(req).length() + 1) + '/';
    }
  }
  // otherwise compute the path normally
  return getParent().getUrl() + getShortUrl();
}

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

public final String getUrl() {
  // try to stick to the current view if possible
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    String seed = Functions.getNearestAncestorUrl(req,this);
    if(seed!=null) {
      // trim off the context path portion and leading '/', but add trailing '/'
      return seed.substring(req.getContextPath().length()+1)+'/';
    }
  }
  // otherwise compute the path normally
  return getParent().getUrl()+getShortUrl();
}

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

public final String getUrl() {
  // try to stick to the current view if possible
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    String seed = Functions.getNearestAncestorUrl(req,this);
    if(seed!=null) {
      // trim off the context path portion and leading '/', but add trailing '/'
      return seed.substring(req.getContextPath().length()+1)+'/';
    }
  }
  // otherwise compute the path normally
  return getParent().getUrl()+getShortUrl();
}

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

public final String getUrl() {
  // try to stick to the current view if possible
  StaplerRequest req = Stapler.getCurrentRequest();
  if (req != null) {
    String seed = Functions.getNearestAncestorUrl(req,this);
    if(seed!=null) {
      // trim off the context path portion and leading '/', but add trailing '/'
      return seed.substring(req.getContextPath().length()+1)+'/';
    }
  }
  // otherwise compute the path normally
  return getParent().getUrl()+getShortUrl();
}

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

/**
 * @param owner
 *      The parent model object that owns this widget.
 */
public HistoryWidget(O owner, Iterable<T> baseList, Adapter<? super T> adapter) {
  StaplerRequest currentRequest = Stapler.getCurrentRequest();
  this.adapter = adapter;
  this.baseList = baseList;
  this.baseUrl = Functions.getNearestAncestorUrl(currentRequest,owner);
  this.owner = owner;
  this.newerThan = getPagingParam(currentRequest, "newer-than");
  this.olderThan = getPagingParam(currentRequest, "older-than");
  this.searchString = currentRequest.getParameter("search");;
}

相关文章

微信公众号

最新文章

更多