try {
try {
getMavenRepository().storeItem(request, is, userAttributes);
}
catch (IOException e) {
throw new LocalStorageException(String.format("Could not store item to repository %s, path %s",
RepositoryStringUtils.getHumanizedNameString(getMavenRepository()), request), e);
}
// NXCM-4861: Doing "local only" lookup, same code should be used as in
// org.sonatype.nexus.proxy.repository.AbstractProxyRepository#doCacheItem
// Note: ResourceStoreRequest( ResourceStoreRequest ) creates a "subordinate" request from passed with same
// path but localOnly=true
StorageFileItem storedFile =
(StorageFileItem) getMavenRepository().retrieveItem(false, new ResourceStoreRequest(request));
String sha1Hash = storedFile.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_SHA1_KEY);
String md5Hash = storedFile.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_MD5_KEY);
if (!StringUtils.isEmpty(sha1Hash)) {
request.setRequestPath(storedFile.getPath() + ".sha1");
getMavenRepository().storeItem(
false,
new DefaultStorageFileItem(getMavenRepository(), request, true, true, new StringContentLocator(
sha1Hash)));
}
if (!StringUtils.isEmpty(md5Hash)) {
request.setRequestPath(storedFile.getPath() + ".md5");
getMavenRepository().storeItem(
false,
new DefaultStorageFileItem(getMavenRepository(), request, true, true, new StringContentLocator(
md5Hash)));
}
}
catch (ItemNotFoundException e) {
throw new LocalStorageException("Storage inconsistency!", e);
}
finally {
request.setRequestPath(originalPath);
}
}