当前位置: 首页>>代码示例>>Java>>正文


Java Job.hasPermission方法代码示例

本文整理汇总了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;
}
 
开发者ID:SxMShaDoW,项目名称:embeddable-badges-plugin,代码行数:26,代码来源:PublicBadgeAction.java

示例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;
}
 
开发者ID:damienbiggs,项目名称:parameter-pool-plugin,代码行数:22,代码来源:ParameterPoolBuilder.java

示例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();
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:54,代码来源:DownstreamRunFilter.java


注:本文中的hudson.model.Job.hasPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。