/** * Gets an existing {@link TriggerEntry}, or null if no such thing exists. * * @param sha the {@link PushNotification#sha()}. * @return the entry if found. * @throws IOException if so * @throws InterruptedException if so */ @CheckForNull public synchronized TriggerEntry getEntry(String sha) throws IOException, InterruptedException { Fingerprint fingerprint = jenkins.getFingerprintMap().get(sha); if (fingerprint==null) return null; return fingerprint.getFacet(TriggerEntry.class); }
@Nonnull private synchronized TriggerEntry getOrCreateEntry(@Nonnull final PushNotification pushNotification) throws IOException, InterruptedException { Fingerprint fingerprint = jenkins.getFingerprintMap().getOrCreate(null, pushNotification.getRepoName(), pushNotification.sha()); TriggerEntry entry = fingerprint.getFacet(TriggerEntry.class); if (entry==null) fingerprint.getFacets().add(entry=new TriggerEntry(fingerprint,pushNotification)); return entry; }
/** * Registers a fingerprint for the given workspace's id. * * @param exws the workspace to register the fingerprint for * @throws IOException if fingerprint load operation fails */ private void registerFingerprint(ExternalWorkspace exws) throws IOException { FingerprintMap map = Jenkins.getActiveInstance().getFingerprintMap(); Fingerprint f = map.getOrCreate(run, exws.getDisplayName(), exws.getId()); if (f.getFacet(WorkspaceBrowserFacet.class) == null) { f.getFacets().add(new WorkspaceBrowserFacet(f, System.currentTimeMillis(), exws)); } f.save(); }
/** * Method accessed by the Stapler framework when the following url is accessed: * <i>JENKINS_ROOT_URL/exws/browse/workspaceId/</i> * * @param workspaceId the workspace's unique id * @return the workspace whose id matches the given input id, or {@link NoFingerprintMatch} if fingerprint is not found * @throws IOException if fingerprint load operation fails * @throws IllegalArgumentException if {@link WorkspaceBrowserFacet} is not registered for the matching fingerprint */ @Restricted(NoExternalUse.class) @SuppressWarnings("unused") @Nonnull public Object getBrowse(String workspaceId) throws IOException { Fingerprint fingerprint = Jenkins.getActiveInstance()._getFingerprint(workspaceId); if (fingerprint == null) { return new NoFingerprintMatch(workspaceId); } WorkspaceBrowserFacet facet = fingerprint.getFacet(WorkspaceBrowserFacet.class); if (facet == null) { throw new IllegalArgumentException("Couldn't find the Fingerprint Facet that holds the Workspace metadata"); } return facet.getWorkspace(); } }