本文整理汇总了Java中hudson.model.Job.hasPermission方法的典型用法代码示例。如果您正苦于以下问题:Java Job.hasPermission方法的具体用法?Java Job.hasPermission怎么用?Java Job.hasPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hudson.model.Job
的用法示例。
在下文中一共展示了Job.hasPermission方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProject
import hudson.model.Job; //导入方法依赖的package包/类
/**
* TO DO
* @param job
* @return
*/
private Job<?, ?> getProject(String job) {
Job<?, ?> p;
// as the user might have ViewStatus permission only (e.g. as anonymous)
// we get get the project impersonate and
// check for permission after getting the project
SecurityContext orig = impersonate(SYSTEM);
try {
p = getInstance().getItemByFullName(job, Job.class);
} finally {
setContext(orig);
}
// check if user has permission to view the status
if (p == null || !(p.hasPermission(VIEW_STATUS))) {
throw notFound();
}
return p;
}
示例2: doAutoCompleteProjects
import hudson.model.Job; //导入方法依赖的package包/类
/**
* Autocompletion method
*
* Copied from hudson.tasks.BuildTrigger.doAutoCompleteChildProjects(String value)
*
* @param value
* @return
*/
public AutoCompletionCandidates doAutoCompleteProjects(@QueryParameter String value, @AncestorInPath ItemGroup context) {
AutoCompletionCandidates candidates = new AutoCompletionCandidates();
List<Job> jobs = Jenkins.getInstance().getAllItems(Job.class);
for (Job job: jobs) {
String relativeName = job.getRelativeNameFrom(context);
if (relativeName.startsWith(value)) {
if (job.hasPermission(Item.READ)) {
candidates.add(relativeName);
}
}
}
return candidates;
}
示例3: doCheckUpstreamProjectName
import hudson.model.Job; //导入方法依赖的package包/类
/**
* Validates a form input to "Upstream Project Name"
*
* @param project Ancestor project.
* @param upstreamProjectName Upstream project name.
* @return the form validation result.
*/
public FormValidation doCheckUpstreamProjectName(
@AncestorInPath Job<?,?> project,
@QueryParameter String upstreamProjectName
) {
upstreamProjectName = StringUtils.trim(upstreamProjectName);
if (StringUtils.isBlank(upstreamProjectName)) {
return FormValidation.error(Messages.DownstreamRunFilter_UpstreamProjectName_Required());
}
if (containsVariable(upstreamProjectName)) {
return FormValidation.ok();
}
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
// Jenkins is unavailable and validation is useless.
return FormValidation.ok();
}
if (project == null) {
// Context is unknown and validation is useless.
return FormValidation.ok(org.jenkinsci.plugins.runselector.Messages.RunSelector_AncestorIsNull());
}
Job<?,?> upstreamRoot = (project instanceof AbstractProject)
? ((AbstractProject<?,?>) project).getRootProject()
: project;
Job<?,?> upstreamProject = jenkins.getItem(
upstreamProjectName, upstreamRoot, Job.class
);
if (upstreamProject == null || !upstreamProject.hasPermission(Item.READ)) {
return FormValidation.error(Messages.DownstreamRunFilter_UpstreamProjectName_NotFound());
}
if (!(upstreamProject instanceof AbstractProject)) {
return FormValidation.error(
Messages.DownstreamRunFilter_UpstreamProjectName_NotAbstractProject(
upstreamProject.getClass().getName()
)
);
}
return FormValidation.ok();
}