本文整理汇总了Java中org.kohsuke.stapler.StaplerResponse.sendError方法的典型用法代码示例。如果您正苦于以下问题:Java StaplerResponse.sendError方法的具体用法?Java StaplerResponse.sendError怎么用?Java StaplerResponse.sendError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kohsuke.stapler.StaplerResponse
的用法示例。
在下文中一共展示了StaplerResponse.sendError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSourceFile
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
* 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);
}
示例2: doContainer
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
* Gets a container {@link Fingerprint} page.
* @param req Stapler request
* @param rsp Stapler response
* @param id Container ID. Method supports full 64-char IDs only.
* @throws IOException Request processing error
* @throws ServletException Servlet error
*/
public void doContainer(StaplerRequest req, StaplerResponse rsp,
@QueryParameter(required = true) String id)
throws IOException, ServletException {
checkPermission(Jenkins.READ);
Jenkins j = Jenkins.getInstance();
if (j == null) {
rsp.sendError(500, "Jenkins is not ready");
return;
}
String fingerPrintHash = DockerTraceabilityHelper.getContainerHash(id);
rsp.sendRedirect2(j.getRootUrl()+"fingerprint/"+fingerPrintHash);
}
示例3: doImage
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
* Gets an image {@link Fingerprint} page.
* @param req Stapler request
* @param rsp Stapler response
* @param id Image ID. Method supports full 64-char IDs only.
* @throws IOException Request processing error
* @throws ServletException Servlet error
*/
public void doImage(StaplerRequest req, StaplerResponse rsp,
@QueryParameter(required = true) String id)
throws IOException, ServletException {
checkPermission(Jenkins.READ);
Jenkins j = Jenkins.getInstance();
if (j == null) {
rsp.sendError(500, "Jenkins is not ready");
return;
}
String fingerPrintHash = DockerTraceabilityHelper.getImageHash(id);
rsp.sendRedirect2(j.getRootUrl()+"fingerprint/"+fingerPrintHash);
}
示例4: doBrowse
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void doBrowse(StaplerRequest request, StaplerResponse response) throws IOException
{
String requestedPath = FauxPasUtils.pathByRemovingLeadingSlash(request.getRestOfPath());
if (requestedPath == null)
response.sendError(404);
if (!APPROVED_REPORT_REQUEST_PATTERN.matcher(requestedPath).matches())
{
System.err.println("Someone is requesting unapproved content: " + requestedPath);
response.sendError(404);
return;
}
FilePath reportsPath = new FilePath(build.getRootDir());
FilePath requestedFilePath = new FilePath(reportsPath, FauxPasUtils.pathByRemovingLeadingSlash(requestedPath));
try
{
if (!requestedFilePath.exists())
{
System.err.println("Unable to locate report: " + request.getRestOfPath());
response.sendError(404);
return;
}
response.serveFile(request, requestedFilePath.toURI().toURL());
}
catch(Exception e)
{
System.err.println("FAILED TO SERVE FILE: " + request.getRestOfPath() + " -> " + e.getLocalizedMessage());
response.sendError(500);
}
}
示例5: doLaunchSlaveAgent
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
@Override
public void doLaunchSlaveAgent(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
rsp.sendError(SC_NOT_FOUND);
}