Java Code Examples for hudson.model.Fingerprint#getFacets()

The following examples show how to use hudson.model.Fingerprint#getFacets() . 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: DockerFingerprints.java    From docker-commons-plugin with MIT License 5 votes vote down vote up
/**
 * Retrieves a facet from the {@link Fingerprint}.
 * @param <TFacet> Facet type to be retrieved
 * @param fingerprint Fingerprint, which stores facets
 * @param facetClass Class to be retrieved
 * @return First matching facet.
 */
 @SuppressWarnings("unchecked")
public static @CheckForNull <TFacet extends FingerprintFacet> TFacet getFacet
        (@Nonnull Fingerprint fingerprint, @Nonnull Class<TFacet> facetClass) {  
    for ( FingerprintFacet facet : fingerprint.getFacets()) {
        if (facetClass.isAssignableFrom(facet.getClass())) {
            return (TFacet)facet;
        }
    }
    return null;      
}
 
Example 2
Source File: DockerFingerprints.java    From docker-commons-plugin with MIT License 5 votes vote down vote up
/**
 * Retrieves facets from the {@link Fingerprint}.
 * @param <TFacet> Facet type to be retrieved
 * @param fingerprint Fingerprint, which stores facets
 * @param facetClass Facet class to be retrieved
 * @return All found facets
 */
public static @Nonnull @SuppressWarnings("unchecked")
        <TFacet extends FingerprintFacet> Collection<TFacet> getFacets
        (@Nonnull Fingerprint fingerprint, @Nonnull Class<TFacet> facetClass) { 
    final List<TFacet> res = new LinkedList<TFacet>();
    for ( FingerprintFacet facet : fingerprint.getFacets()) {
        if (facetClass.isAssignableFrom(facet.getClass())) {
            res.add((TFacet)facet);
        }
    }
    return res;      
}
 
Example 3
Source File: DockerFingerprints.java    From docker-commons-plugin with MIT License 5 votes vote down vote up
/**
 * Adds a new {@link ContainerRecord} for the specified image, creating necessary intermediate objects as it goes.
 */
public static void addRunFacet(@Nonnull ContainerRecord record, @Nonnull Run<?,?> run) throws IOException {
    String imageId = record.getImageId();
    Fingerprint f = forImage(run, imageId);
    synchronized (f) {
    Collection<FingerprintFacet> facets = f.getFacets();
    DockerRunFingerprintFacet runFacet = null;
    for (FingerprintFacet facet : facets) {
        if (facet instanceof DockerRunFingerprintFacet) {
            runFacet = (DockerRunFingerprintFacet) facet;
            break;
        }
    }
    BulkChange bc = new BulkChange(f);
    try {
        if (runFacet == null) {
            runFacet = new DockerRunFingerprintFacet(f, System.currentTimeMillis(), imageId);
            facets.add(runFacet);
        }
        runFacet.add(record);
        runFacet.addFor(run);
        DockerFingerprintAction.addToRun(f, imageId, run);
        bc.commit();
    } finally {
        bc.abort();
    }
    }
}
 
Example 4
Source File: DockerFingerprintAction.java    From docker-commons-plugin with MIT License 5 votes vote down vote up
public List<DockerFingerprintFacet> getDockerFacets(String imageId) {
    List<DockerFingerprintFacet> res = new LinkedList<DockerFingerprintFacet>();
    final Fingerprint fp = getFingerprint(imageId);
    if (fp != null) {
        for (final FingerprintFacet f : fp.getFacets()) {
            if (f instanceof DockerFingerprintFacet) {
                res.add((DockerFingerprintFacet) f);
            }
        }
    }
    return res;
}
 
Example 5
Source File: FingerprintsHelper.java    From docker-traceability-plugin with MIT License 5 votes vote down vote up
public static @CheckForNull @SuppressWarnings("unchecked")
        <TFacet extends FingerprintFacet> TFacet getFacet
        (@Nonnull Fingerprint fingerprint, @Nonnull Class<TFacet> facetClass) {  
    for ( FingerprintFacet facet : fingerprint.getFacets()) {
        if (facetClass.isAssignableFrom(facet.getClass())) {
            return (TFacet)facet;
        }
    }
    return null;      
}