use of org.commonjava.maven.galley.io.checksum.ContentDigest in project indy by Commonjava.
the class FoloTrackingListener method createEntry.
private TrackedContentEntry createEntry(final TrackingKey trackingKey, final StoreKey affectedStore, final AccessChannel accessChannel, final String path, final StoreEffect effect, final EventMetadata eventMetadata) throws IndyWorkflowException {
TrackedContentEntry entry = null;
final Transfer txfr = downloadManager.getStorageReference(affectedStore, path);
if (txfr != null) {
try {
String remoteUrl = null;
if (StoreType.remote == affectedStore.getType()) {
final RemoteRepository repo = (RemoteRepository) storeManager.getArtifactStore(affectedStore);
if (repo != null) {
remoteUrl = UrlUtils.buildUrl(repo.getUrl(), path);
}
}
TransferMetadata artifactData = contentDigester.digest(affectedStore, path, eventMetadata);
Map<ContentDigest, String> digests = artifactData.getDigests();
//TODO: As localUrl needs a apiBaseUrl which is from REST service context, to avoid deep propagate
// of it, this step will be done in REST layer. Will think better way in the future.
entry = new TrackedContentEntry(trackingKey, affectedStore, accessChannel, remoteUrl, path, effect, artifactData.getSize(), digests.get(ContentDigest.MD5), digests.get(ContentDigest.SHA_1), digests.get(ContentDigest.SHA_256));
} catch (final IndyDataException e) {
throw new IndyWorkflowException("Cannot retrieve RemoteRepository: %s to calculate remote URL for: %s. Reason: %s", e, trackingKey, path, e.getMessage());
} catch (final MalformedURLException e) {
throw new IndyWorkflowException("Cannot format URL. Reason: %s", e, e.getMessage());
}
}
return entry;
}
use of org.commonjava.maven.galley.io.checksum.ContentDigest in project indy by Commonjava.
the class FoloAdminController method recalculate.
private TrackedContentEntry recalculate(final TrackedContentEntry entry) throws IndyWorkflowException {
StoreKey affectedStore = entry.getStoreKey();
String path = entry.getPath();
AccessChannel channel = entry.getAccessChannel();
Transfer transfer = contentManager.getTransfer(affectedStore, path, entry.getEffect() == StoreEffect.UPLOAD ? TransferOperation.UPLOAD : TransferOperation.DOWNLOAD);
contentDigester.removeMetadata(transfer);
TransferMetadata artifactData = contentDigester.digest(affectedStore, path, new EventMetadata(channel.packageType()));
Map<ContentDigest, String> digests = artifactData.getDigests();
return new TrackedContentEntry(entry.getTrackingKey(), affectedStore, channel, entry.getOriginUrl(), path, entry.getEffect(), artifactData.getSize(), digests.get(ContentDigest.MD5), digests.get(ContentDigest.SHA_1), digests.get(ContentDigest.SHA_256));
}
Aggregations