diff options
author | Martin Stockhammer <martin_s@apache.org> | 2020-06-16 21:24:16 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2020-06-16 21:24:16 +0200 |
commit | 1201ef39745d153cd369eb72b80c80a9ecb72553 (patch) | |
tree | 60ef5ec41f01314217f8b08dcb82d50f9f729b09 /archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers | |
parent | add9451d9eb36a753051ea7ff007ea85b500198f (diff) | |
download | archiva-1201ef39745d153cd369eb72b80c80a9ecb72553.tar.gz archiva-1201ef39745d153cd369eb72b80c80a9ecb72553.zip |
Switching to new repository API
Diffstat (limited to 'archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers')
3 files changed, 19 insertions, 44 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml index 4fe1100cf..c362ca7f9 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml @@ -67,10 +67,6 @@ </dependency> <dependency> <groupId>org.apache.archiva</groupId> - <artifactId>archiva-storage-fs</artifactId> - </dependency> - <dependency> - <groupId>org.apache.archiva</groupId> <artifactId>archiva-model</artifactId> </dependency> <dependency> diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java index cbe3dc5a1..5996a06f3 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java @@ -19,23 +19,23 @@ package org.apache.archiva.consumers.core; * under the License. */ -import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.consumers.AbstractMonitoredConsumer; import org.apache.archiva.consumers.ConsumerException; import org.apache.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; -import org.apache.archiva.repository.ManagedRepositoryContent; +import org.apache.archiva.repository.BaseRepositoryContentLayout; import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.ManagedRepository; -import org.apache.archiva.repository.BaseRepositoryContentLayout; +import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.RepositoryNotFoundException; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.content.Artifact; -import org.apache.archiva.repository.metadata.base.MetadataTools; +import org.apache.archiva.repository.content.Project; import org.apache.archiva.repository.metadata.RepositoryMetadataException; +import org.apache.archiva.repository.metadata.base.MetadataTools; import org.apache.archiva.repository.storage.StorageAsset; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,9 +75,6 @@ public class MetadataUpdaterConsumer private MetadataTools metadataTools; @Inject - private ArchivaConfiguration configuration; - - @Inject private FileTypes filetypes; private static final String TYPE_METADATA_BAD_INTERNAL_REF = "metadata-bad-internal-ref"; @@ -195,24 +192,22 @@ public class MetadataUpdaterConsumer private void updateProjectMetadata( Artifact artifact, String path ) { - ProjectReference projectRef = new ProjectReference( ); - projectRef.setGroupId( artifact.getNamespace( ).getId() ); - projectRef.setArtifactId( artifact.getId( ) ); - try { - String metadataPath = this.metadataTools.toPath( projectRef ); + Project proj = artifact.getProject( ); + + String metadataPath = repository.toPath( proj ); StorageAsset projectMetadata = this.repositoryDir.resolve( metadataPath ); if ( projectMetadata.exists() && ( projectMetadata.getModificationTime().toEpochMilli() >= this.scanStartTimestamp ) ) { // This metadata is up to date. skip it. - log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( projectRef ) ); + log.debug( "Skipping uptodate metadata: {}", metadataPath ); return; } metadataTools.updateMetadata( this.repository, metadataPath ); - log.debug( "Updated metadata: {}", this.metadataTools.toPath( projectRef ) ); + log.debug( "Updated metadata: {}", metadataPath ); } catch ( RepositoryMetadataException e ) { @@ -253,23 +248,6 @@ public class MetadataUpdaterConsumer } } - /* - @Override - public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - if ( ConfigurationNames.isRepositoryScanning( propertyName ) ) - { - initIncludes(); - } - } - - @Override - public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - // do nothing here - } - */ - private void initIncludes( ) { includes = new ArrayList<>( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java index c1c99651d..b0383affb 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java @@ -204,18 +204,19 @@ public class CleanupReleasedSnapshotsRepositoryPurge @SuppressWarnings( "deprecation" ) private void updateMetadata( Artifact artifact ) { - VersionedReference versionRef = new VersionedReference( ); - versionRef.setGroupId( artifact.getNamespace().getId( ) ); - versionRef.setArtifactId( artifact.getId( ) ); - versionRef.setVersion( artifact.getVersion().getId( ) ); - ProjectReference projectRef = new ProjectReference( ); - projectRef.setGroupId( artifact.getNamespace().getId( ) ); - projectRef.setArtifactId( artifact.getId( ) ); + ItemSelector versionRef = ArchivaItemSelector.builder( ) + .withNamespace( artifact.getNamespace( ).getId( ) ) + .withProjectId( artifact.getId( ) ) + .withVersion( artifact.getVersion( ).getId( ) ).build( ); + + ItemSelector projectRef = ArchivaItemSelector.builder() + .withNamespace( artifact.getNamespace().getId( ) ) + .withProjectId( artifact.getId( ) ).build(); try { - metadataTools.updateMetadata( repository, versionRef ); + metadataTools.updateVersionMetadata( repository, versionRef ); } catch ( ContentNotFoundException e ) { @@ -228,7 +229,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge try { - metadataTools.updateMetadata( repository, projectRef ); + metadataTools.updateProjectMetadata( repository, projectRef ); } catch ( ContentNotFoundException | RepositoryMetadataException | IOException | LayoutException e ) { |