本文整理了Java中hudson.model.AbstractProject.checkPermission()
方法的一些代码示例,展示了AbstractProject.checkPermission()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractProject.checkPermission()
方法的具体详情如下:
包路径:hudson.model.AbstractProject
类名称:AbstractProject
方法名:checkPermission
暂无
代码示例来源:origin: jenkinsci/jenkins
public void checkAbortPermission() {
checkPermission(CANCEL);
}
代码示例来源:origin: jenkinsci/jenkins
protected int run() throws Exception {
Jenkins h = Jenkins.getActiveInstance();
h.checkPermission(Jenkins.READ);
// where is this build running?
BuildIDs id = checkChannel().call(new BuildIDs());
if (!id.isComplete())
throw new IllegalStateException("This command can be only invoked from a build executing inside Hudson");
AbstractProject p = h.getItemByFullName(id.job, AbstractProject.class);
if (p==null)
throw new IllegalStateException("No such job found: "+id.job);
p.checkPermission(Item.CONFIGURE);
List<String> toolTypes = new ArrayList<>();
for (ToolDescriptor<?> d : ToolInstallation.all()) {
toolTypes.add(d.getDisplayName());
if (d.getDisplayName().equals(toolType)) {
List<String> toolNames = new ArrayList<>();
for (ToolInstallation t : d.getInstallations()) {
toolNames.add(t.getName());
if (t.getName().equals(toolName))
return install(t, id, p);
}
// didn't find the right tool name
error(toolNames, toolName, "name");
}
}
// didn't find the tool type
error(toolTypes, toolType, "type");
// will never be here
throw new AssertionError();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Serves the workspace files.
*/
public DirectoryBrowserSupport doWs( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
checkPermission(Item.WORKSPACE);
FilePath ws = getSomeWorkspace();
if ((ws == null) || (!ws.exists())) {
// if there's no workspace, report a nice error message
// Would be good if when asked for *plain*, do something else!
// (E.g. return 404, or send empty doc.)
// Not critical; client can just check if content type is not text/plain,
// which also serves to detect old versions of Hudson.
req.getView(this,"noWorkspace.jelly").forward(req,rsp);
return null;
} else {
Computer c = ws.toComputer();
String title;
if (c == null) {
title = Messages.AbstractProject_WorkspaceTitle(getDisplayName());
} else {
title = Messages.AbstractProject_WorkspaceTitleOnComputer(getDisplayName(), c.getDisplayName());
}
return new DirectoryBrowserSupport(this, ws, title, "folder.png", true);
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Wipes out the workspace.
*/
@RequirePOST
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
checkPermission(Functions.isWipeOutPermissionEnabled() ? WIPEOUT : BUILD);
R b = getSomeBuildWithWorkspace();
FilePath ws = b!=null ? b.getWorkspace() : null;
if (ws!=null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
ws.deleteRecursive();
for (WorkspaceListener wl : WorkspaceListener.all()) {
wl.afterDelete(this);
}
return new HttpRedirect(".");
} else {
// If we get here, that means the SCM blocked the workspace deletion.
return new ForwardToView(this,"wipeOutWorkspaceBlocked.jelly");
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
@Override
protected int act(List<AbstractBuild<?, ?>> builds) throws IOException {
job.checkPermission(Run.DELETE);
for (AbstractBuild build : builds) {
build.delete();
}
stdout.println("Deleted " + builds.size() + " builds");
return 0;
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
@Override
protected int act(List<AbstractBuild<?, ?>> builds) throws IOException {
job.checkPermission(Run.DELETE);
for (AbstractBuild build : builds)
build.delete();
stdout.println("Deleted "+builds.size()+" builds");
return 0;
}
代码示例来源:origin: org.hudsonci.plugins/rest-plugin-api
@GET
@Path("{projectName}/permissions")
public PermissionsDTO getPermissions(final @PathParam("projectName") String projectName) {
log.debug("Getting permissions for project: {}", projectName);
AbstractProject project = support.getProject(projectName);
project.checkPermission(READ);
return permissions.create(project);
}
}
代码示例来源:origin: org.hudsonci.plugins/rest-plugin-api
@GET
@Path("{projectName}/config")
@Produces({ TEXT_XML })
public String getProjectConfig(final @PathParam("projectName") String projectName) throws IOException {
log.debug("Fetching project configuration: {}", projectName);
AbstractProject project = support.getProject(projectName);
project.checkPermission(EXTENDED_READ);
XmlFile file = project.getConfigFile();
return file.asString();
}
代码示例来源:origin: org.hudsonci.plugins/rest-plugin-api
@DELETE
@Path("{projectName}")
public void deleteProject(final @PathParam("projectName") String projectName) throws Exception {
log.debug("Deleting project: {}", projectName);
AbstractProject project = support.getProject(projectName);
project.checkPermission(DELETE);
project.delete();
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
public static void checkPermission(AbstractProject project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException {
if (!Hudson.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(AbstractProject.BUILD);
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* Cancels a scheduled build.
*/
public void doCancelQueue(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
checkPermission(BUILD);
Hudson.getInstance().getQueue().cancel(this);
rsp.forwardToPreviousPage(req);
}
代码示例来源:origin: hudson/hudson-2.x
/**
* Cancels a scheduled build.
*/
public void doCancelQueue( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(BUILD);
Hudson.getInstance().getQueue().cancel(this);
rsp.forwardToPreviousPage(req);
}
代码示例来源:origin: hudson/hudson-2.x
@CLIMethod(name="enable-job")
public HttpResponse doEnable() throws IOException, ServletException {
requirePOST();
checkPermission(CONFIGURE);
makeDisabled(false);
return new HttpRedirect(".");
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
@CLIMethod(name = "disable-job")
public HttpResponse doDisable() throws IOException, ServletException {
requirePOST();
checkPermission(CONFIGURE);
makeDisabled(true);
return new HttpRedirect(".");
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Cancels a scheduled build.
*/
public void doCancelQueue( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(BUILD);
Hudson.getInstance().getQueue().cancel(this);
rsp.forwardToPreviousPage(req);
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
@CLIMethod(name = "enable-job")
public HttpResponse doEnable() throws IOException, ServletException {
requirePOST();
checkPermission(CONFIGURE);
makeDisabled(false);
return new HttpRedirect(".");
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
@CLIMethod(name = "enable-job")
public HttpResponse doEnable() throws IOException, ServletException {
requirePOST();
checkPermission(CONFIGURE);
makeDisabled(false);
return new HttpRedirect(".");
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
public boolean cleanWorkspace() throws IOException, InterruptedException{
checkPermission(BUILD);
R b = getSomeBuildWithWorkspace();
FilePath ws = b != null ? b.getWorkspace() : null;
if (ws != null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
ws.deleteRecursive();
return true;
} else{
// If we get here, that means the SCM blocked the workspace deletion.
return false;
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
public boolean cleanWorkspace() throws IOException, InterruptedException {
checkPermission(BUILD);
R b = getSomeBuildWithWorkspace();
FilePath ws = b != null ? b.getWorkspace() : null;
if (ws != null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
ws.deleteRecursive();
return true;
} else {
// If we get here, that means the SCM blocked the workspace deletion.
return false;
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
public boolean cleanWorkspace() throws IOException, InterruptedException {
checkPermission(BUILD);
R b = getSomeBuildWithWorkspace();
FilePath ws = b != null ? b.getWorkspace() : null;
if (ws != null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
ws.deleteRecursive();
return true;
} else {
// If we get here, that means the SCM blocked the workspace deletion.
return false;
}
}
内容来源于网络,如有侵权,请联系作者删除!