hudson.Util.rawEncode()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(139)

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

Util.rawEncode介绍

[英]Encode a single path component for use in an HTTP URL. Escapes all non-ASCII, general unsafe (space and "#%<>[]^{|}~}) and HTTP special characters ( /;:?) as specified in RFC1738. (so alphanumeric and !@$&*()-_=+',. are not encoded) Note that slash ( /) is encoded, so the given string should be a single path component used in constructing a URL. Method name inspired by PHP's rawurlencode. [中]对单个路径组件进行编码,以便在HTTP URL中使用。转义所有非ASCII、一般不安全(空格和“#%<>[\]^{124;}})和HTTP特殊字符(/;:?)按照RFC1738的规定。(所以字母数字和!@$&*()-=+',),。请注意,斜杠(/)是经过编码的,因此给定的字符串应该是用于构建URL的单个路径组件。方法名的灵感来源于PHP的rawurlencode。

代码示例

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

public String getSearchUrl() {
  return Util.rawEncode(name);
}

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

public String getUrl() {
  return "computer/" + Util.rawEncode(getName()) + "/";
}

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

public @Nonnull
String getUrl() {
  return "user/" + Util.rawEncode(idStrategy().keyFor(id));
}

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

public @Nonnull
String getSearchUrl() {
  return "/user/" + Util.rawEncode(idStrategy().keyFor(id));
}

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

/**
 * Same as {@link #getUrl()} except this returns a view/{name} path
 * even for the default view.
 */
public String getViewUrl() {
  return (owner!=null ? owner.getUrl() : "") + "view/" + Util.rawEncode(getViewName()) + '/';
}

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

/**
 * When there are multiple suggested items, this method can narrow down the resultset
 * to the SuggestedItem that has a url that contains the query. This is useful is one
 * job has a display name that matches another job's project name.
 * @param r A list of Suggested items. It is assumed that there is at least one 
 * SuggestedItem in r.
 * @param query A query string
 * @return Returns the SuggestedItem which has a search url that contains the query.
 * If no SuggestedItems have a search url which contains the query, then the first
 * SuggestedItem in the List is returned.
 */
static SuggestedItem findClosestSuggestedItem(List<SuggestedItem> r, String query) {
  for(SuggestedItem curItem : r) {
    if(LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine(String.format("item's searchUrl:%s;query=%s", curItem.item.getSearchUrl(), query));
    }
    if(curItem.item.getSearchUrl().contains(Util.rawEncode(query))) {
      return curItem;
    }
  }
  
  // couldn't find an item with the query in the url so just
  // return the first one
  return r.get(0);        
}

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

public String getShortUrl() {
  String prefix = getParent().getUrlChildPrefix();
  String subdir = Util.rawEncode(getName());
  return prefix.equals(".") ? subdir + '/' : prefix + '/' + subdir + '/';
}

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

public String getSearchUrl() {
  Computer c = toComputer();
  if (c != null) {
    return c.getUrl();
  }
  return "computer/" + Util.rawEncode(getNodeName());
}

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

private StringBuilder retrieveProjectUrl(Job<?, ?> project) {
  return new StringBuilder()
      .append(Jenkins.getInstance().getRootUrl())
      .append(GitLabWebHook.WEBHOOK_URL)
      .append(retrieveParentUrl(project))
      .append('/').append(Util.rawEncode(project.getName()));
}

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

public HttpResponse doIndex() {
  return new HttpRedirect("view/" + Util.rawEncode(getPrimaryView().getViewName()) + "/");
}

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

public HttpResponse doTest() {
  String referer = Stapler.getCurrentRequest().getReferer();
  Jenkins j = Jenkins.getInstance();
  // May need to send an absolute URL, since handling of HttpRedirect with a relative URL does not currently honor X-Forwarded-Proto/Port at all.
  String redirect = j.getRootUrl() + "administrativeMonitor/" + id + "/testForReverseProxySetup/" + (referer != null ? Util.rawEncode(referer) : "NO-REFERER") + "/";
  LOGGER.log(Level.FINE, "coming from {0} and redirecting to {1}", new Object[] {referer, redirect});
  return new HttpRedirect(redirect);
}

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

private StringBuilder retrieveParentUrl(Item item) {
  if (item.getParent() instanceof Item) {
    Item parent = (Item) item.getParent();
    return retrieveParentUrl(parent).append('/').append(Util.rawEncode(parent.getName()));
  } else {
    return new StringBuilder();
  }
}

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

Path p = new Path(Util.rawEncode(f.getName()), f.getName(), f.isDirectory(), f.length(), f.canRead(), f.lastModified());
if(!f.isDirectory()) {
  r.add(Collections.singletonList(p));
  String relPath = Util.rawEncode(f.getName());
  while(true) {
      break;
    f = sub.get(0);
    relPath += '/'+Util.rawEncode(f.getName());
    l.add(new Path(relPath,f.getName(),true, f.length(), f.canRead(), f.lastModified()));

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

/**
 * Builds the path list and href recursively top-down.
 */
private static void buildPathList(VirtualFile baseDir, VirtualFile filePath, List<Path> pathList, StringBuilder href) throws IOException {
  VirtualFile parent = filePath.getParent();
  if (!baseDir.equals(parent)) {
    buildPathList(baseDir, parent, pathList, href);
  }
  href.append(Util.rawEncode(filePath.getName()));
  if (filePath.isDirectory()) {
    href.append("/");
  }
  Path path = new Path(href.toString(), filePath.getName(), filePath.isDirectory(), filePath.length(), filePath.canRead(), filePath.lastModified());
  pathList.add(path);
}

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

String child = sub.getName();
String childPath = path + child;
String childHref = pathHref + Util.rawEncode(child);
String length = sub.isFile() ? String.valueOf(sub.length()) : "";
boolean collapsed = (kids.length==1 && parent!=null);

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

/**
 * Accepts submission from the configuration page.
 */
@RequirePOST
public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
  JSONObject src = req.getSubmittedForm();
  String newName = src.getString("name"), redirect = ".";
  XmlFile oldFile = null;
  if(!name.equals(newName)) {
    Jenkins.checkGoodName(newName);
    oldFile = getConfigFile();
    // rename
    getParent().logRecorders.remove(name);
    this.name = newName;
    getParent().logRecorders.put(name,this);
    redirect = "../" + Util.rawEncode(newName) + '/';
  }
  List<Target> newTargets = req.bindJSONToList(Target.class, src.get("targets"));
  for (Target t : newTargets)
    t.enable();
  targets.replaceBy(newTargets);
  save();
  if (oldFile!=null) oldFile.delete();
  rsp.sendRedirect2(redirect);
}

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

/**
 * Accepts submission from the configuration page.
 *
 * Subtypes should override the {@link #submit(StaplerRequest)} method.
 */
@RequirePOST
public final synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
  checkPermission(CONFIGURE);
  submit(req);
  description = Util.nullify(req.getParameter("description"));
  filterExecutors = req.getParameter("filterExecutors") != null;
  filterQueue = req.getParameter("filterQueue") != null;
  rename(req.getParameter("name"));
  getProperties().rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors());
  save();
  FormApply.success("../" + Util.rawEncode(name)).generateResponse(req,rsp,this);
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * Return the store relative URL of this domain.
 *
 * @return the store relative URL of this domain.
 */
@SuppressFBWarnings(value = "NP_NULL_PARAM_DEREF",
          justification = "isGlobal() check implies that domain.getName() is null")
public String getUrl() {
  return isGlobal() ? "domain/_/" : "domain/" + Util.rawEncode(name) + "/";
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

/**
 * Return the URL name.
 *
 * @return the URL name.
 */
@Exported
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
          justification = "isGlobal() check implies that domain.getName() is null")
public String getUrlName() {
  return isGlobal() ? "_" : Util.rawEncode(domain.getName());
}

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

public HttpResponse doTest() {
  String referer = Stapler.getCurrentRequest().getReferer();
  Jenkins j = Jenkins.getInstance();
  // May need to send an absolute URL, since handling of HttpRedirect with a relative URL does not currently honor X-Forwarded-Proto/Port at all.
  String redirect = j.getRootUrl() + "administrativeMonitor/" + id + "/testForReverseProxySetup/" + (referer != null ? Util.rawEncode(referer) : "NO-REFERER") + "/";
  LOGGER.log(Level.FINE, "coming from {0} and redirecting to {1}", new Object[] {referer, redirect});
  return new HttpRedirect(redirect);
}

相关文章

微信公众号

最新文章

更多