hudson.model.ModelObject Java Examples

The following examples show how to use hudson.model.ModelObject. 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: TryBlueOceanMenu.java    From blueocean-plugin with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Nonnull
@Override
public Collection<? extends Action> createFor(@Nonnull ModelObject target) {
    // we do not report actions as it might appear multiple times, we simply add it to Actionable
    BlueOceanUrlObjectFactory f = getFirst();
    if(f != null) {
        // TODO remove this if block once we are using a core > 2.126
        // Work around JENKINS-51584
        if (target instanceof hudson.model.Queue.Item) {
            return Collections.emptyList();
        }
        BlueOceanUrlObject blueOceanUrlObject = f.get(target);
        BlueOceanUrlAction a = new BlueOceanUrlAction(blueOceanUrlObject);
        return Collections.singleton(a);
    }
    return Collections.emptyList();
}
 
Example #2
Source File: BlueOceanUrlMapperImpl.java    From blueocean-plugin with MIT License 6 votes vote down vote up
private @CheckForNull BluePipeline getJobResource(ModelObject modelObject){
    BluePipeline blueResource = null;
    if(modelObject instanceof Job){
        ItemGroup parent = ((Job) modelObject).getParent();
        if(parent instanceof ComputedFolder){
            blueResource =  (BluePipeline) BluePipelineFactory
                    .resolve((ComputedFolder)parent);
            if(blueResource instanceof BlueMultiBranchPipeline){
                return blueResource;
            }
        }else {
            blueResource =  (BluePipeline) BluePipelineFactory
                    .resolve((Job)modelObject);
        }
    }
    return blueResource;
}
 
Example #3
Source File: BlueOceanCredentialsProvider.java    From blueocean-plugin with MIT License 6 votes vote down vote up
private static FolderPropertyImpl propertyOf(ModelObject object) {
    if (object instanceof AbstractFolder) {
        FolderPropertyImpl prop = ((AbstractFolder<?>)object).getProperties().get(FolderPropertyImpl.class);

        if(prop == null){
            ItemGroup parent = ((AbstractFolder)object).getParent();
            if(parent instanceof Jenkins){
                return null;
            }
            return propertyOf(parent);
        }else{
            return prop;
        }
    }
    return null;
}
 
Example #4
Source File: BlueOceanUrlObjectImpl.java    From blueocean-plugin with MIT License 5 votes vote down vote up
private String computeUrl(ModelObject modelObject){
    String url = null;
    for(BlueOceanUrlMapper mapper: BlueOceanUrlMapper.all()){
        url = mapper.getUrl(modelObject);
        if(url != null){
            break;
        }
    }
    if(url == null){
        url = BlueOceanUrlMapperImpl.getLandingPagePath();
    }
    return url;
}
 
Example #5
Source File: BlueOceanUrlMapperImpl.java    From blueocean-plugin with MIT License 5 votes vote down vote up
private boolean isBranch(ModelObject modelObject){
    if(modelObject instanceof Job){
        ItemGroup parent = ((Job) modelObject).getParent();
        if(parent instanceof ComputedFolder){
            BluePipeline blueResource = (BluePipeline) BluePipelineFactory
                    .resolve((Job)modelObject);
            return (blueResource instanceof BlueMultiBranchPipeline);
        }
    }
    return false;
}
 
Example #6
Source File: BlueOceanUrlMapperImpl.java    From blueocean-plugin with MIT License 5 votes vote down vote up
private BlueOrganization getOrganization(ModelObject modelObject ){
    BlueOrganization organization = null;
    if(modelObject instanceof Item){
        organization = OrganizationFactory.getInstance().getContainingOrg((Item) modelObject);
    }else if(modelObject instanceof ItemGroup){
        organization = OrganizationFactory.getInstance().getContainingOrg((ItemGroup) modelObject);
    }else if(modelObject instanceof Run){
        organization = OrganizationFactory.getInstance().getContainingOrg(((Run) modelObject).getParent());
    }
    return organization;
}
 
Example #7
Source File: DetailFactoryTest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("ParameterNumber")
private <T extends ModelObject> T createTrendDetails(final String link, final Run<?, ?> owner,
        final AnalysisResult result,
        final Report allIssues, final Report newIssues,
        final Report outstandingIssues, final Report fixedIssues,
        final Charset sourceEncoding, final IssuesDetail parent, final Class<T> actualType) {
    DetailFactory detailFactory = new DetailFactory();
    Object details = detailFactory.createTrendDetails(link, owner,
            result, allIssues, newIssues, outstandingIssues, fixedIssues, sourceEncoding, parent);
    assertThat(details).isInstanceOf(actualType);
    return actualType.cast(details);
}
 
Example #8
Source File: BlueOceanWebURLBuilderTest.java    From blueocean-plugin with MIT License 4 votes vote down vote up
@Override
public String getUrl(@Nonnull ModelObject modelObject) {
    return modelObject instanceof FreeStyleProject ? "/customerUrlMapper/"+((FreeStyleProject)modelObject).getName() : null;
}
 
Example #9
Source File: CredentialsTestUtil.java    From credentials-binding-plugin with MIT License 4 votes vote down vote up
/**
 * Registers the given value as a {@link StringCredentials} into the default {@link CredentialsProvider} using the
 * specified credentials id.
 */
public static void setStringCredentials(ModelObject context, String credentialsId, String value) throws IOException {
    StringCredentials creds = new StringCredentialsImpl(CredentialsScope.GLOBAL, credentialsId, null, Secret.fromString(value));
    CredentialsProvider.lookupStores(context).iterator().next().addCredentials(Domain.global(), creds);
}
 
Example #10
Source File: CredentialsTestUtil.java    From credentials-binding-plugin with MIT License 4 votes vote down vote up
/**
 * Registers the given value as a {@link StringCredentials} into the default {@link CredentialsProvider}.
 * Returns the generated credential id for the registered credentials.
 */
public static String registerStringCredentials(ModelObject context, String value) throws IOException {
    String credentialsId = UUID.randomUUID().toString();
    setStringCredentials(context, credentialsId, value);
    return credentialsId;
}
 
Example #11
Source File: BlueOceanCredentialsProvider.java    From blueocean-plugin with MIT License 4 votes vote down vote up
@Nonnull
@Override
public ModelObject getContext() {
    return owner;
}
 
Example #12
Source File: BlueOceanCredentialsProvider.java    From blueocean-plugin with MIT License 4 votes vote down vote up
private boolean isApplicable(ModelObject object){
    return object instanceof AbstractFolder &&
            ((AbstractFolder)object).getProperties().get(FolderPropertyImpl.class) != null;
}
 
Example #13
Source File: BlueOceanCredentialsProvider.java    From blueocean-plugin with MIT License 4 votes vote down vote up
@Override
public Set<CredentialsScope> getScopes(ModelObject object) {
    return Collections.singleton(CredentialsScope.GLOBAL);
}
 
Example #14
Source File: BlueOceanCredentialsProvider.java    From blueocean-plugin with MIT License 4 votes vote down vote up
@Override
public CredentialsStore getStore(@CheckForNull ModelObject object) {
    FolderPropertyImpl property = propertyOf(object);
    return property != null ? property.getStore() : null;
}
 
Example #15
Source File: BlueOceanUrlObjectFactoryImpl.java    From blueocean-plugin with MIT License 4 votes vote down vote up
@Nonnull
@Override
public BlueOceanUrlObject get(@Nonnull final ModelObject object) {
    return new BlueOceanUrlObjectImpl(object);
}
 
Example #16
Source File: TryBlueOceanMenu.java    From blueocean-plugin with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Class<ModelObject> type() {
    return ModelObject.class;
}
 
Example #17
Source File: BlueOceanUrlObjectImpl.java    From blueocean-plugin with MIT License 4 votes vote down vote up
public BlueOceanUrlObjectImpl(ModelObject modelObject) {
    this.mappedUrl = computeUrl(modelObject);
}
 
Example #18
Source File: BlueOceanUrlMapper.java    From blueocean-plugin with MIT License 2 votes vote down vote up
/**
 * Gives BlueOcean URL for given Jenkins {@link ModelObject}.
 *
 * @param modelObject Jenkins ModelObject
 * @return Gives url for this model object, returns null if it can't compute URL for this model object
 */
@CheckForNull
public abstract String getUrl(@Nonnull ModelObject modelObject);
 
Example #19
Source File: BlueOceanUrlObjectFactory.java    From blueocean-plugin with MIT License votes vote down vote up
/**
 * Gives {@link BlueOceanUrlObject} for given {@link ModelObject}.
 *
 * @param object Jenkins {@link ModelObject}
 * @return BlueOceanUrlObject
 */

public abstract @Nonnull BlueOceanUrlObject get(@Nonnull ModelObject object);