@Override protected RemoteHashResponse retrieveRemoteHash(final AbstractStorageItem item, final ProxyRepository proxy, final String baseUrl) throws LocalStorageException { final P2ProxyRepository p2repo = proxy.adaptToFacet(P2ProxyRepository.class); Map<String, ArtifactPath> paths; try { final ArtifactMapping artifactMapping = p2repo.getArtifactMappings().get(baseUrl); if (artifactMapping == null) { log.debug("Unable to retrive remote has for " + item.getPath()); return null; } paths = artifactMapping.getArtifactsPath(); } catch (StorageException e) { throw new LocalStorageException(e); } catch (final IllegalOperationException e) { log.error("Unable to open artifactsMapping.xml", e); return null; } final String md5 = paths.get(item.getPath()).getMd5(); if (md5 == null) { return null; } return new RemoteHashResponse(DigestCalculatingInspector.DIGEST_MD5_KEY, md5, null); }
ProxyRepository proxy = repository.adaptToFacet( ProxyRepository.class );
resource.setArtifactMaxAge(repository.adaptToFacet(MavenProxyRepository.class).getArtifactMaxAge()); resource.setMetadataMaxAge(repository.adaptToFacet(MavenProxyRepository.class).getMetadataMaxAge()); resource.setItemMaxAge(repository.adaptToFacet(MavenProxyRepository.class).getItemMaxAge());
@Override protected ChecksumPolicy getChecksumPolicy( ProxyRepository proxy, AbstractStorageItem item ) { if ( isChecksum( item.getRepositoryItemUid().getPath() ) ) { // do not validate checksum files return null; } if ( !proxy.getRepositoryKind().isFacetAvailable( MavenProxyRepository.class ) ) { // we work only with maven proxy reposes, all others are neglected return null; } MavenProxyRepository mpr = proxy.adaptToFacet( MavenProxyRepository.class ); ChecksumPolicy checksumPolicy = mpr.getChecksumPolicy(); if ( checksumPolicy == null || !checksumPolicy.shouldCheckChecksum() || !( item instanceof DefaultStorageFileItem ) ) { // there is either no need to validate or we can't validate the item content return null; } return checksumPolicy; }
@Override protected ChecksumPolicy getChecksumPolicy(final ProxyRepository proxy, final AbstractStorageItem item) throws LocalStorageException { if (P2ProxyMetadataSource.isP2MetadataItem(item.getRepositoryItemUid().getPath())) { // the checksum is on metadata files return ChecksumPolicy.IGNORE; } if (!proxy.getRepositoryKind().isFacetAvailable(P2ProxyRepository.class)) { return ChecksumPolicy.IGNORE; } final P2ProxyRepository p2repo = proxy.adaptToFacet(P2ProxyRepository.class); final ChecksumPolicy checksumPolicy = p2repo.getChecksumPolicy(); if (checksumPolicy == null || !checksumPolicy.shouldCheckChecksum() || !(item instanceof DefaultStorageFileItem)) { // there is either no need to validate or we can't validate the item content return ChecksumPolicy.IGNORE; } final ResourceStoreRequest req = new ResourceStoreRequest(P2Constants.ARTIFACT_MAPPINGS_XML); req.setRequestLocalOnly(true); try { p2repo.retrieveItem(true, req); } catch (final Exception e) { // no way to calculate log.debug("Unable to find artifact-mapping.xml", e); return ChecksumPolicy.IGNORE; } return checksumPolicy; }
if (!repository.adaptToFacet(MavenProxyRepository.class).isDownloadRemoteIndexes()) { return;
resource.setArtifactMaxAge( repository.adaptToFacet( MavenProxyRepository.class ).getArtifactMaxAge() ); resource.setMetadataMaxAge( repository.adaptToFacet( MavenProxyRepository.class ).getMetadataMaxAge() );
MavenProxyRepository mpr = repository.adaptToFacet( MavenProxyRepository.class );