本文整理了Java中org.kohsuke.stapler.StaplerRequest.getRestOfPath()
方法的一些代码示例,展示了StaplerRequest.getRestOfPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.getRestOfPath()
方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:getRestOfPath
[英]Returns the additional URL portion that wasn't used by the stapler, excluding the query string.
For example, if the requested URL is "foo/bar/zot/abc?def=ghi" and "foo/bar" portion matched bar.jsp, this method returns "/zot/abc".
If this method is invoked from getters or StaplerProxy#getTarget()during the object traversal, this method returns the path portion that is not yet processed.
[中]返回订书机未使用的其他URL部分,不包括查询字符串。
例如,如果请求的URL是“foo/bar/zot/abc?def=ghi”和“foo/bar”部分匹配。这个方法返回“/zot/abc”。
如果在对象遍历期间从getter或StaplerProxy#getTarget()调用此方法,则此方法返回尚未处理的路径部分。
代码示例来源:origin: jenkinsci/jenkins
private String getPath(StaplerRequest req) {
String path = req.getRestOfPath();
if(path.length()==0)
path = "/";
return path;
}
代码示例来源:origin: jenkinsci/jenkins
public Slave.JnlpJar doJnlpJars(StaplerRequest req) {
return new Slave.JnlpJar(req.getRestOfPath().substring(1));
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Serves static resources placed along with Jelly view files.
* <p>
* This method can serve a lot of files, so care needs to be taken
* to make this method secure. It's not clear to me what's the best
* strategy here, though the current implementation is based on
* file extensions.
*/
public void doResources(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
String path = req.getRestOfPath();
// cut off the "..." portion of /resources/.../path/to/file
// as this is only used to make path unique (which in turn
// allows us to set a long expiration date
path = path.substring(path.indexOf('/',1)+1);
int idx = path.lastIndexOf('.');
String extension = path.substring(idx+1);
if(ALLOWED_RESOURCE_EXTENSIONS.contains(extension)) {
URL url = pluginManager.uberClassLoader.getResource(path);
if(url!=null) {
long expires = MetaClass.NO_CACHE ? 0 : 365L * 24 * 60 * 60 * 1000; /*1 year*/
rsp.serveFile(req,url,expires);
return;
}
}
rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* This method serves static resources in the plugin under {@code hudson/plugin/SHORTNAME}.
*/
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
String path = req.getRestOfPath();
String pathUC = path.toUpperCase(Locale.ENGLISH);
if (path.isEmpty() || path.contains("..") || path.startsWith(".") || path.contains("%")
|| pathUC.contains("META-INF") || pathUC.contains("WEB-INF")
// ClassicPluginStrategy#explode produce that file to know if a new explosion is required or not
|| pathUC.equals("/.TIMESTAMP2")
) {
LOGGER.warning("rejecting possibly malicious " + req.getRequestURIWithQueryString());
rsp.sendError(HttpServletResponse.SC_BAD_REQUEST);
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, new URL(wrapper.baseResourceURL, '.' + path), expires);
}
代码示例来源:origin: jenkinsci/gitlab-plugin
public WebHookAction resolve(final String projectName, StaplerRequest request) {
Iterator<String> restOfPathParts = Splitter.on('/').omitEmptyStrings().split(request.getRestOfPath()).iterator();
Item project = resolveProject(projectName, restOfPathParts);
if (project == null) {
throw HttpResponses.notFound();
}
return resolveAction(project, Joiner.on('/').join(restOfPathParts), request);
}
代码示例来源:origin: jenkinsci/jenkins
public Object getTarget() {
try {
checkPermission(READ);
} catch (AccessDeniedException e) {
if (!isSubjectToMandatoryReadPermissionCheck(Stapler.getCurrentRequest().getRestOfPath())) {
return this;
}
throw e;
}
return this;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* 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);
}
代码示例来源:origin: jenkinsci/jenkins
if (("/" + originalFileName).equals(request.getRestOfPath())) {
AbstractBuild build = (AbstractBuild)request.findAncestor(AbstractBuild.class).getObject();
File fileParameter = getLocationUnderBuild(build);
代码示例来源:origin: jenkinsci/jenkins
public void doCommand(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
final Jenkins jenkins = Jenkins.getActiveInstance();
jenkins.checkPermission(Jenkins.READ);
// Strip trailing slash
final String commandName = req.getRestOfPath().substring(1);
CLICommand command = CLICommand.clone(commandName);
if (command == null) {
rsp.sendError(HttpServletResponse.SC_NOT_FOUND, "No such command");
return;
}
req.setAttribute("command", command);
req.getView(this, "command.jelly").forward(req, rsp);
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public Object getTarget() {
StaplerRequest req = Stapler.getCurrentRequest();
if (req.getRestOfPath().length()==0 && "POST".equals(req.getMethod())) {
// CLI connection request
if ("false".equals(req.getParameter("remoting"))) {
throw new PlainCliEndpointResponse();
} else if (jenkins.CLI.get().isEnabled()) {
throw new RemotingCliEndpointResponse();
} else {
throw HttpResponses.forbidden();
}
} else {
return this;
}
}
代码示例来源:origin: jenkinsci/jenkins
String path = req.getRestOfPath();
if(path.contains("..")) throw new ServletException("Illegal path: "+path);
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private String getPath(StaplerRequest req) {
String path = req.getRestOfPath();
if(path.length()==0)
path = "/";
return path;
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
private String getPath(StaplerRequest req) {
String path = req.getRestOfPath();
if(path.length()==0)
path = "/";
return path;
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
private String getPath(StaplerRequest req) {
String path = req.getRestOfPath();
if (path.length() == 0) {
path = "/";
}
return path;
}
代码示例来源:origin: groupon/DotCi
public void doRepoAction(final StaplerRequest req, final StaplerResponse rsp) throws InvocationTargetException, IllegalAccessException {
final String[] tokens = StringUtils.split(req.getRestOfPath(), "/");
final GithubRepoAction repoAction = getRepoAction(tokens[0]);
if (repoAction != null) {
final String methodToken = tokens.length > 1 ? tokens[1] : "index";
final String methodName = "do" + StringUtils.capitalize(methodToken);
final Method method = ReflectionUtils.getPublicMethodNamed(repoAction.getClass(), methodName);
method.invoke(repoAction, req, rsp);
}
}
代码示例来源:origin: groupon/DotCi
private boolean useNewUi(final String token, final StaplerRequest req) {
return isNewUi() &&
(StringUtils.startsWith(token, "dotCI") || //job pages
(NumberUtils.isNumber(token) && (StringUtils.isEmpty(req.getRestOfPath()) || StringUtils.contains(req.getRestOfPath(), "dotCI")))); // buildpages
}
代码示例来源:origin: groupon/DotCi
public void doBranchBuilds(final StaplerRequest req, final StaplerResponse rsp) throws IOException, ServletException, InterruptedException {
final String tab = req.getRestOfPath().replace("/", "");
handleBranchTabs(tab, req);
rsp.forwardToPreviousPage(req);
}
代码示例来源:origin: org.jvnet.hudson.main/ui-samples-plugin
/**
* Binds {@link SourceFile}s into URL.
*/
public void doSourceFile(StaplerRequest req, StaplerResponse rsp) throws IOException {
String name = req.getRestOfPath().substring(1); // Remove leading /
for (SourceFile sf : getSourceFiles())
if (sf.name.equals(name)) {
sf.doIndex(rsp);
return;
}
rsp.sendError(rsp.SC_NOT_FOUND);
}
代码示例来源:origin: org.jenkins-ci.plugins/nested-view
public Object getTarget() {
// Proxy to handle redirect when a default subview is configured
return (getDefaultView() != null &&
"".equals(Stapler.getCurrentRequest().getRestOfPath()))
? new DefaultViewProxy() : this;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public Object getTarget() {
try {
checkPermission(READ);
} catch (AccessDeniedException e) {
if (!isSubjectToMandatoryReadPermissionCheck(Stapler.getCurrentRequest().getRestOfPath())) {
return this;
}
throw e;
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!