hudson.model.TopLevelItemDescriptor Java Examples

The following examples show how to use hudson.model.TopLevelItemDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPipelineCreateRequest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
protected @Nonnull TopLevelItem createProject(String name, String descriptorName, Class<? extends TopLevelItemDescriptor> descriptorClass, BlueOrganization organization) throws IOException {
    ModifiableTopLevelItemGroup p = getParent(organization);

    final ACL acl = (p instanceof AccessControlled) ? ((AccessControlled) p).getACL() : Jenkins.getInstance().getACL();
    Authentication a = Jenkins.getAuthentication();
    if(!acl.hasPermission(a, Item.CREATE)){
        throw new ServiceException.ForbiddenException(
                String.format("Failed to create pipeline: %s. User %s doesn't have Job create permission", name, a.getName()));
    }
    TopLevelItemDescriptor descriptor = Items.all().findByName(descriptorName);
    if(descriptor == null || !(descriptorClass.isAssignableFrom(descriptor.getClass()))){
        throw new ServiceException.BadRequestException(String.format("Failed to create pipeline: %s, descriptor %s is not found", name, descriptorName));
    }

    if (!descriptor.isApplicableIn(p)) {
        throw new ServiceException.ForbiddenException(
                String.format("Failed to create pipeline: %s. Pipeline can't be created in Jenkins root folder", name));
    }

    if (!acl.hasCreatePermission(a, p, descriptor)) {
        throw new ServiceException.ForbiddenException("Missing permission: " + Item.CREATE.group.title+"/"+Item.CREATE.name + " " + Item.CREATE + "/" + descriptor.getDisplayName());
    }
    return p.createProject(descriptor, name, true);
}
 
Example #2
Source File: UserImplPermissionTest.java    From blueocean-plugin with MIT License 4 votes vote down vote up
@Override
public TopLevelItem createProject(TopLevelItemDescriptor type, String name, boolean notify) throws IOException {
    return null;
}
 
Example #3
Source File: BlueOceanWebURLBuilderTest.java    From blueocean-plugin with MIT License 4 votes vote down vote up
@Override
public TopLevelItem createProject(TopLevelItemDescriptor type, String name, boolean notify) throws IOException {
    return null;
}
 
Example #4
Source File: MockFolder.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
@Override public TopLevelItem createProject(TopLevelItemDescriptor type, String name, boolean notify) throws IOException {
    return mixin().createProject(type, name, notify);
}
 
Example #5
Source File: MockFolder.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
/** Convenience method to create a {@link FreeStyleProject} or similar. */
public <T extends TopLevelItem> T createProject(Class<T> type, String name) throws IOException {
    return type.cast(createProject((TopLevelItemDescriptor) Jenkins.getInstance().getDescriptor(type), name, true));
}
 
Example #6
Source File: MockFolder.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
@Override public TopLevelItemDescriptor getDescriptor() {
    return Jenkins.getInstance().getDescriptorByType(DescriptorImpl.class);
}
 
Example #7
Source File: OrganizationContainer.java    From DotCi with MIT License 4 votes vote down vote up
@Override
public TopLevelItemDescriptor getDescriptor() {
    return (DescriptorImpl) Hudson.getInstance().getDescriptorOrDie(getClass());
}
 
Example #8
Source File: OrganizationContainer.java    From DotCi with MIT License 4 votes vote down vote up
public DynamicProject createProject(final Class<DynamicProject> type, final String projectName) throws IOException {
    return type.cast(createProject((TopLevelItemDescriptor) Hudson.getInstance().getDescriptor(type), projectName));
}
 
Example #9
Source File: OrganizationContainer.java    From DotCi with MIT License 4 votes vote down vote up
public TopLevelItem createProject(final TopLevelItemDescriptor type, final String name) throws IOException {
    return createProject(type, name, true);
}
 
Example #10
Source File: OrganizationContainer.java    From DotCi with MIT License 4 votes vote down vote up
public TopLevelItem createProject(final TopLevelItemDescriptor type, final String name, final boolean notify) throws IOException {
    return this.mixin.createProject(type, name, notify);
}