类hudson.model.AbstractItem源码实例Demo

下面列出了怎么用hudson.model.AbstractItem的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: DotCi   文件: DynamicSubProject.java
@Override
public void onLoad(final ItemGroup<? extends Item> parent, final String name) throws IOException {
    try {
        final Field parentField = AbstractItem.class.getDeclaredField("parent");
        parentField.setAccessible(true);
        ReflectionUtils.setField(parentField, this, parent);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }

    doSetName(name);
    if (this.transientActions == null) {
        this.transientActions = new Vector<>();
    }
    updateTransientActions();
    getBuildersList().setOwner(this);
    getPublishersList().setOwner(this);
    getBuildWrappersList().setOwner(this);

    initRepos();
}
 
/**
 * Get all {@link AbstractFolder}s in the system
 *
 * @return full names of all {@link AbstractFolder}s in the system
 */
@GET
@Nonnull
@Restricted(NoExternalUse.class)
public JSONArray doGetAllFolders() {
    Jenkins jenkins = Jenkins.get();
    jenkins.checkPermission(Jenkins.ADMINISTER);
    List<AbstractFolder> folders;

    try (ACLContext ignored = ACL.as(ACL.SYSTEM)) {
        folders = jenkins.getAllItems(AbstractFolder.class);
    }

    return JSONArray.fromObject(folders.stream().map(AbstractItem::getFullName).collect(Collectors.toList()));
}
 
/**
 * {@inheritDoc}
 */
@Nonnull
@Override
public SidACL getACL(AbstractItem item) {
    String fullName = item.getFullName();
    SidACL acl = jobAclCache.getIfPresent(fullName);

    if (acl != null) {
        return acl;
    }

    String[] splits = fullName.split(FOLDER_SEPARATOR);
    StringBuilder sb = new StringBuilder(fullName.length());
    acl = globalAcl;

    // Roles on a folder are applicable to all children
    for (String str : splits) {
        sb.append(str);
        SidACL newAcl = jobAcls.get(sb.toString());
        if (newAcl != null) {
            acl = acl.newInheritingACL(newAcl);
        }
        sb.append(FOLDER_SEPARATOR);
    }

    jobAclCache.put(fullName, acl);
    return acl;
}
 
源代码4 项目: audit-log-plugin   文件: ItemChangeListenerTest.java
@Issue("JENKINS-56641")
@Test
public void testAuditOnItemUpdate() throws Exception {
    FreeStyleProject project = j.createFreeStyleProject("Test build");
    AbstractItem item = (AbstractItem) project;
    item.setDescription("Item created for testing the updates");
    item.save();

    List<LogEvent> events = app.getEvents();

    assertThat(events).hasSize(2);
    assertThat(events).extracting(event -> ((AuditMessage) event.getMessage()).getId().toString()).containsSequence("createItem", "updateItem");
}
 
源代码5 项目: blueocean-plugin   文件: AbstractPipelineImpl.java
public static Map<String, Boolean> getPermissions(AbstractItem item){
    return ImmutableMap.of(
        BluePipeline.CREATE_PERMISSION, item.getACL().hasPermission(Item.CREATE),
        BluePipeline.CONFIGURE_PERMISSION, item.getACL().hasPermission(Item.CONFIGURE),
        BluePipeline.READ_PERMISSION, item.getACL().hasPermission(Item.READ),
        BluePipeline.START_PERMISSION, item.getACL().hasPermission(Item.BUILD),
        BluePipeline.STOP_PERMISSION, item.getACL().hasPermission(Item.CANCEL)
    );
}
 
源代码6 项目: blueocean-plugin   文件: PipelineFolderImpl.java
@Override
public String getName() {
    if(folder instanceof AbstractItem)
        return ((AbstractItem) folder).getName();
    else
        return folder.getDisplayName();
}
 
源代码7 项目: blueocean-plugin   文件: PipelineFolderImpl.java
@Override
public Map<String, Boolean> getPermissions() {
    if(folder instanceof AbstractItem){
        AbstractItem item = (AbstractItem) folder;
        return AbstractPipelineImpl.getPermissions(item);
    }else{
        return null;
    }

}
 
/**
 * Gets the {@link ACL} for a {@link Job}
 *
 * @return the {@link ACL} for the {@link Job}
 */
@Nonnull
@Override
public SidACL getACL(Job<?, ?> project) {
    return getACL((AbstractItem) project);
}
 
@Override
public ACL getACL(AbstractItem item) {
    return new ACLImpl(item.getFullName());
}
 
@Override
public ACL getACL(Job<?, ?> project) {
    return getACL((AbstractItem) project); // stupid overload
}
 
源代码11 项目: DotCi   文件: DbBackedProject.java
@PostLoad
private void restoreName(final DBObject dbObj) {
    GReflectionUtils.setField(AbstractItem.class, "name", this, dbObj.get("name"));
}
 
 类所在包
 类方法
 同包方法