From 8f42ce002cc96da7e2fc45321ede494c29961748 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sun, 25 Aug 2019 19:55:00 +0200 Subject: [PATCH] Changing method names and adding javadoc for metarepository --- .../repository/AbstractRepositoryPurge.java | 6 +- ...pReleasedSnapshotsRepositoryPurgeTest.java | 4 +- .../DaysOldRepositoryPurgeTest.java | 6 +- .../RepositoryPurgeConsumerTest.java | 11 +- .../RetentionCountRepositoryPurgeTest.java | 6 +- .../rest/services/DefaultBrowseService.java | 6 +- .../services/DefaultRepositoriesService.java | 6 +- .../AbstractMetadataRepository.java | 29 +- .../repository/DefaultMetadataResolver.java | 4 +- .../repository/MetadataRepository.java | 579 ++++++++++-------- .../AbstractMetadataRepositoryTest.java | 26 +- .../RepositoryWalkingStatisticsProvider.java | 2 +- .../CassandraMetadataRepository.java | 45 +- .../file/FileMetadataRepository.java | 33 +- .../repository/jcr/JcrMetadataRepository.java | 35 +- .../RepositoryStatisticsManagerTest.java | 16 +- 16 files changed, 402 insertions(+), 412 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java index a8cf4b7f2..a00e444e6 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java @@ -259,7 +259,7 @@ public abstract class AbstractRepositoryPurge } else { - // metadataRepository.removeArtifact( artifactMetadata, baseVersion ); + // metadataRepository.removeTimestampedArtifact( artifactMetadata, baseVersion ); metaRemovalList.put( info, artifactMetadata ); } } @@ -366,7 +366,7 @@ public abstract class AbstractRepositoryPurge version = artifactInfo.getProjectVersion( ); MavenArtifactFacet mavenArtifactFacetToCompare = new MavenArtifactFacet( ); mavenArtifactFacetToCompare.setClassifier( artifactInfo.getClassifier( ) ); - metadataRepository.removeArtifact(repositorySession , repository.getId( ), groupId, + metadataRepository.removeFacetFromArtifact(repositorySession , repository.getId( ), groupId, artifactId, version, mavenArtifactFacetToCompare ); try { repositorySession.save( ); @@ -377,7 +377,7 @@ public abstract class AbstractRepositoryPurge } else { - metadataRepository.removeArtifact(repositorySession , artifactMetadata, artifactInfo.getProjectVersion( ) ); + metadataRepository.removeTimestampedArtifact(repositorySession , artifactMetadata, artifactInfo.getProjectVersion( ) ); } } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java index 9d44b28b7..18c3d2877 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java @@ -345,8 +345,8 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest verify(metadataRepository, never()).removeProjectVersion(eq(repositorySession) , eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); verify(metadataRepository, never()).removeProjectVersion(eq(repositorySession) , eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq("2.0.3-SNAPSHOT") ); verify(metadataRepository, never()).removeProjectVersion(eq(repositorySession) , eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq("2.0.4-SNAPSHOT") ); - verify(metadataRepository, never()).removeArtifact(eq(repositorySession) , any(ArtifactMetadata.class), any(String.class) ); - verify(metadataRepository, never()).removeArtifact(eq(repositorySession) , any(String.class), any(String.class), any(String.class), any(String.class), any( MetadataFacet.class) ); + verify(metadataRepository, never()).removeTimestampedArtifact(eq(repositorySession) , any(ArtifactMetadata.class), any(String.class) ); + verify(metadataRepository, never()).removeFacetFromArtifact(eq(repositorySession) , any(String.class), any(String.class), any(String.class), any(String.class), any( MetadataFacet.class) ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java index 848d4eda6..66651d37b 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java @@ -134,7 +134,7 @@ public class DaysOldRepositoryPurgeTest // Verify the metadataRepository invocations verify(metadataRepository, never()).removeProjectVersion(eq(repositorySession) , eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, times(2)).removeArtifact(eq(repositorySession) , metadataArg.capture(), eq(projectVersion) ); + verify(metadataRepository, times(2)).removeTimestampedArtifact(eq(repositorySession) , metadataArg.capture(), eq(projectVersion) ); List metaL = metadataArg.getAllValues(); for (ArtifactMetadata meta : metaL) { assertTrue(meta.getId().startsWith(projectName)); @@ -229,7 +229,7 @@ public class DaysOldRepositoryPurgeTest // Verify the metadataRepository invocations verify(metadataRepository, never()).removeProjectVersion(eq(repositorySession) , eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, times(deletedVersions.size())).removeArtifact(eq(repositorySession) , metadataArg.capture(), eq(projectVersion) ); + verify(metadataRepository, times(deletedVersions.size())).removeTimestampedArtifact(eq(repositorySession) , metadataArg.capture(), eq(projectVersion) ); List metaL = metadataArg.getAllValues(); for (ArtifactMetadata meta : metaL) { assertTrue(meta.getId().startsWith(projectName)); @@ -337,7 +337,7 @@ public class DaysOldRepositoryPurgeTest // Verify the metadataRepository invocations verify(metadataRepository, never()).removeProjectVersion(eq(repositorySession) , eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, times(deletedVersions.size())).removeArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); + verify(metadataRepository, times(deletedVersions.size())).removeTimestampedArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); List metaL = metadataArg.getAllValues(); for (ArtifactMetadata meta : metaL) { assertTrue(meta.getId().startsWith(projectName)); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java index 318144563..3172a3d3f 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java @@ -27,7 +27,6 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.MetadataFacet; -import org.apache.archiva.mock.MockRepositorySessionFactory; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.features.ArtifactCleanupFeature; import org.custommonkey.xmlunit.XMLAssert; @@ -210,7 +209,7 @@ public class RepositoryPurgeConsumerTest // Verify the metadataRepository invocations verify(metadataRepository, never()).removeProjectVersion( eq(repositorySession), eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, times(2)).removeArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); + verify(metadataRepository, times(2)).removeTimestampedArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); List metaL = metadataArg.getAllValues(); for (ArtifactMetadata meta : metaL) { assertTrue(meta.getId().startsWith(projectName)); @@ -323,7 +322,7 @@ public class RepositoryPurgeConsumerTest // Verify the metadataRepository invocations verify(metadataRepository, never()).removeProjectVersion( eq(repositorySession), eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, times(2)).removeArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); + verify(metadataRepository, times(2)).removeTimestampedArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); List metaL = metadataArg.getAllValues(); assertTrue( metaL.size( ) > 0 ); for (ArtifactMetadata meta : metaL) { @@ -403,8 +402,8 @@ public class RepositoryPurgeConsumerTest verify(metadataRepository, never()).removeProjectVersion( eq(repositorySession), eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, never()).removeArtifact( eq(repositorySession), any(), any() ); - verify(metadataRepository, never()).removeArtifact( eq(repositorySession), any(), any(), any(), any(), any(MetadataFacet.class) ); + verify(metadataRepository, never()).removeTimestampedArtifact( eq(repositorySession), any(), any() ); + verify(metadataRepository, never()).removeFacetFromArtifact( eq(repositorySession), any(), any(), any(), any(), any(MetadataFacet.class) ); // check if the snapshot wasn't removed @@ -473,7 +472,7 @@ public class RepositoryPurgeConsumerTest verify(metadataRepository, times(1)).removeProjectVersion( eq(repositorySession), eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, never()).removeArtifact( eq(repositorySession), any(), any() ); + verify(metadataRepository, never()).removeTimestampedArtifact( eq(repositorySession), any(), any() ); // check if the snapshot was removed assertDeleted( projectRoot + "/2.3-SNAPSHOT" ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java index e8ffc78b3..3a06774f1 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java @@ -137,7 +137,7 @@ public class RetentionCountRepositoryPurgeTest // Verify the metadataRepository invocations verify(metadataRepository, never()).removeProjectVersion( eq(repositorySession), eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, times(deletedVersions.size())).removeArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); + verify(metadataRepository, times(deletedVersions.size())).removeTimestampedArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); List metaL = metadataArg.getAllValues(); for (ArtifactMetadata meta : metaL) { assertTrue(meta.getId().startsWith(projectName)); @@ -223,7 +223,7 @@ public class RetentionCountRepositoryPurgeTest // Verify the metadataRepository invocations verify(metadataRepository, never()).removeProjectVersion( eq(repositorySession), eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, times(deletedVersions.size())).removeArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); + verify(metadataRepository, times(deletedVersions.size())).removeTimestampedArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); List metaL = metadataArg.getAllValues(); for (ArtifactMetadata meta : metaL) { assertTrue(meta.getId().startsWith(projectName)); @@ -311,7 +311,7 @@ public class RetentionCountRepositoryPurgeTest // Verify the metadataRepository invocations verify(metadataRepository, never()).removeProjectVersion( eq(repositorySession), eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion) ); ArgumentCaptor metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class); - verify(metadataRepository, times(deletedVersions.size())).removeArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); + verify(metadataRepository, times(deletedVersions.size())).removeTimestampedArtifact( eq(repositorySession), metadataArg.capture(), eq(projectVersion) ); List metaL = metadataArg.getAllValues(); for (ArtifactMetadata meta : metaL) { assertTrue(meta.getId().startsWith(projectName)); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java index adc2c0af0..8012d6be3 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java @@ -1019,7 +1019,7 @@ public class DefaultBrowseService } try { - List artifactMetadatas = repositorySession.getRepository().getArtifactsByProjectVersionMetadata(repositorySession , key, value, repositoryId ); + List artifactMetadatas = repositorySession.getRepository().getArtifactsByProjectVersionFacet(repositorySession , key, value, repositoryId ); return buildArtifacts( artifactMetadatas, repositoryId ); } catch ( MetadataRepositoryException e ) @@ -1047,7 +1047,7 @@ public class DefaultBrowseService } try { - List artifactMetadatas = repositorySession.getRepository().getArtifactsByMetadata(repositorySession , key, value, repositoryId ); + List artifactMetadatas = repositorySession.getRepository().getArtifactsByAttribute(repositorySession , key, value, repositoryId ); return buildArtifacts( artifactMetadatas, repositoryId ); } catch ( MetadataRepositoryException e ) @@ -1075,7 +1075,7 @@ public class DefaultBrowseService } try { - List artifactMetadatas = repositorySession.getRepository().getArtifactsByProperty(repositorySession , key, value, repositoryId ); + List artifactMetadatas = repositorySession.getRepository().getArtifactsByProjectVersionAttribute(repositorySession , key, value, repositoryId ); return buildArtifacts( artifactMetadatas, repositoryId ); } catch ( MetadataRepositoryException e ) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java index faa07e80a..fd7ae90ec 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java @@ -703,7 +703,7 @@ public class DefaultRepositoriesService for ( ArtifactMetadata artifactMetadata : artifacts ) { - metadataRepository.removeArtifact(repositorySession , artifactMetadata, version ); + metadataRepository.removeTimestampedArtifact(repositorySession , artifactMetadata, version ); } metadataRepository.removeProjectVersion(repositorySession , repositoryId, namespace, projectId, version ); @@ -920,7 +920,7 @@ public class DefaultRepositoriesService artifact.getVersion(); MavenArtifactFacet mavenArtifactFacetToCompare = new MavenArtifactFacet(); mavenArtifactFacetToCompare.setClassifier( artifact.getClassifier() ); - metadataRepository.removeArtifact(repositorySession , repositoryId, groupId, artifactId, + metadataRepository.removeFacetFromArtifact(repositorySession , repositoryId, groupId, artifactId, version, mavenArtifactFacetToCompare ); repositorySession.save(); } @@ -930,7 +930,7 @@ public class DefaultRepositoriesService { if ( snapshotVersion ) { - metadataRepository.removeArtifact(repositorySession , + metadataRepository.removeTimestampedArtifact(repositorySession , artifactMetadata, VersionUtil.getBaseVersion( artifact.getVersion() ) ); } else diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/AbstractMetadataRepository.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/AbstractMetadataRepository.java index 248e194fd..db2fc8339 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/AbstractMetadataRepository.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/AbstractMetadataRepository.java @@ -28,8 +28,6 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionReference; import org.apache.commons.collections4.ComparatorUtils; -import javax.annotation.Nonnull; -import javax.management.Query; import java.time.ZonedDateTime; import java.util.*; import java.util.stream.Stream; @@ -127,21 +125,21 @@ public abstract class AbstractMetadataRepository } @Override - public List getArtifactsByProjectVersionMetadata( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByProjectVersionFacet( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { throw new UnsupportedOperationException(); } @Override - public List getArtifactsByMetadata( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByAttribute( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { throw new UnsupportedOperationException(); } @Override - public List getArtifactsByProperty( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByProjectVersionAttribute( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { throw new UnsupportedOperationException(); @@ -155,15 +153,15 @@ public abstract class AbstractMetadataRepository } @Override - public void removeArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion ) + public void removeTimestampedArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion ) throws MetadataRepositoryException { throw new UnsupportedOperationException(); } @Override - public void removeArtifact( RepositorySession session, String repositoryId, String namespace, String project, String version, - MetadataFacet metadataFacet ) + public void removeFacetFromArtifact( RepositorySession session, String repositoryId, String namespace, String project, String version, + MetadataFacet metadataFacet ) throws MetadataRepositoryException { throw new UnsupportedOperationException(); @@ -229,7 +227,7 @@ public abstract class AbstractMetadataRepository } @Override - public Collection getNamespaces( RepositorySession session, String repoId, String namespace ) + public Collection getChildNamespaces( RepositorySession session, String repoId, String namespace ) throws MetadataResolutionException { throw new UnsupportedOperationException(); @@ -317,19 +315,6 @@ public abstract class AbstractMetadataRepository { } - @Override - public boolean canObtainAccess( Class aClass ) - { - throw new UnsupportedOperationException(); - } - - @Override - public T obtainAccess( RepositorySession session, Class aClass ) - throws MetadataRepositoryException - { - throw new UnsupportedOperationException(); - } - @Override public List searchArtifacts( RepositorySession session, String repositoryId, String text, boolean exact ) throws MetadataRepositoryException diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java index ba8e0fc41..a86696ec5 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java @@ -249,7 +249,7 @@ public class DefaultMetadataResolver Collection namespaces = namespacesCache.get( cacheKey ); if ( namespaces == null ) { - namespaces = metadataRepository.getNamespaces( session, repoId, namespace ); + namespaces = metadataRepository.getChildNamespaces( session, repoId, namespace ); namespacesCache.put( cacheKey, namespaces ); } Collection exclusions = new ArrayList<>( namespaces ); @@ -302,7 +302,7 @@ public class DefaultMetadataResolver Collection namespaces = namespacesCache.get( cacheKey ); if ( namespaces == null ) { - namespaces = metadataRepository.getNamespaces( session, repoId, namespace ); + namespaces = metadataRepository.getChildNamespaces( session, repoId, namespace ); namespacesCache.put( cacheKey, namespaces ); } diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java index bf3d8bab5..321ed2ef8 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java @@ -37,35 +37,35 @@ import java.util.stream.Stream; * A Metadata repository provides information about artifact metadata. It does not provide the artifact data itself. * It may be possible to use the same backend for metadata and storage, but this depends on the backends and they are * provided by different APIs. - * + *

* The motivation for this API is to provide fast access to the repository metadata and fulltext search. Also dependencies * are stored in this repository. - * + *

* The methods here do not update the artifacts itself. They are only updating the data in the metadata repository. * That means, if you want to update some artifact, you should make sure to update the artifact itself and the metadata * repository (either directly or by repository scanning). - * + *

* Currently we are providing JCR, File based and Cassandra as backend for the metadata. - * + *

* The metadata repository uses sessions for accessing the data. Please make sure to always close the sessions after using it. * Best idiom for using the sessions: * * try(RepositorySession session = sessionFactory.createSession() { - * // do your stuff + * // do your stuff * } * - * + *

* It is implementation dependent, if the sessions are really used by the backend. E.g. the file based implementation ignores * the sessions completely. - * + *

* Sessions should be closed immediately after usage. If it is expensive to open a session for a given backend. The backend * should provide a session pool if possible. There are methods for refreshing a session if needed. - * - * You should avoid stacking sessions, that means, do not create a new session in the same thread, when a session is opened already. - * + *

+ * You should avoid stacking sessions, which means, you should not create a new session in the same thread, when a session is opened already. + *

* Some backend implementations (JCR) update the metadata in the background, that means update of the metadata is not reflected * immediately. - * + *

* The base metadata coordinates are: *

    *
  • Repository ID: The identifier of the repository, where the artifact resides
  • @@ -74,10 +74,10 @@ import java.util.stream.Stream; *
  • Version: Each project may have different versions.
  • *
  • Artifact: Artifacts correspond to files / blob data. Each artifact has additional metadata, like name, version, modification time, ...
  • *
- * + *

* As the repository connects to some backend either locally or remote, the access to the repository may fail. The methods capsule the * backend errors into {@link MetadataRepositoryException}. - * + *

* Facets are the way to provide additional metadata that is not part of the base API. It depends on the repository type (e.g. Maven, NPM, * not the metadata backend) what facets are stored in addition to the standard metadata. * Facets have a specific facet ID that represents the schema for the data stored. For creating specific objects for a given @@ -86,154 +86,150 @@ import java.util.stream.Stream; * a hierarchical path. * The data in each facet instance is stored in properties (key-value pairs). The properties are converted into / from the specific * facet object. - * + *

* Facets can be stored on repository, project, version and artifact level. - * + *

* For retrieving artifacts there are methods that return lists and streaming based methods. Some implementations (e.g. JCR) use * lazy loading for the retrieved objects. So the streaming methods may be faster and use less memory than the list based methods. * But for some backends there is no difference. - * */ +@SuppressWarnings( "NullableProblems" ) @ParametersAreNonnullByDefault public interface MetadataRepository { - /** * Update metadata for a particular project in the metadata repository, or create it, if it does not already exist. * - * @param session The session used for updating. + * @param session The session used for updating. * @param repositoryId the repository the project is in * @param project the project metadata to create or update * @throws MetadataRepositoryException if the update fails */ - void updateProject( RepositorySession session, String repositoryId, ProjectMetadata project ) + void updateProject( RepositorySession session, String repositoryId, ProjectMetadata project ) throws MetadataRepositoryException; /** * Update the metadata of a given artifact. If the artifact, namespace, version, project does not exist in the repository it will be created. * - * @param session The repository session - * @param repositoryId The repository id - * @param namespace The namespace ('.' separated) - * @param projectId The project id + * @param session The repository session + * @param repositoryId The repository id + * @param namespace The namespace ('.' separated) + * @param projectId The project id * @param projectVersion The project version - * @param artifactMeta Information about the artifact itself. + * @param artifactMeta Information about the artifact itself. * @throws MetadataRepositoryException if something goes wrong during update. */ - void updateArtifact( RepositorySession session, String repositoryId, - String namespace, String projectId, String projectVersion, - ArtifactMetadata artifactMeta ) + void updateArtifact( RepositorySession session, String repositoryId, + String namespace, String projectId, String projectVersion, + ArtifactMetadata artifactMeta ) throws MetadataRepositoryException; /** * Updates the metadata for a specific version of a given project. If the namespace, project, version does not exist, * it will be created. * - * @param session The repository session - * @param repositoryId The repository id - * @param namespace The namespace ('.' separated) - * @param projectId The project id + * @param session The repository session + * @param repositoryId The repository id + * @param namespace The namespace ('.' separated) + * @param projectId The project id * @param versionMetadata The metadata for the version * @throws MetadataRepositoryException if something goes wrong during update */ - void updateProjectVersion( RepositorySession session, String repositoryId, - String namespace, String projectId, - ProjectVersionMetadata versionMetadata ) + void updateProjectVersion( RepositorySession session, String repositoryId, + String namespace, String projectId, + ProjectVersionMetadata versionMetadata ) throws MetadataRepositoryException; /** * Create the namespace in the repository, if it does not exist. * Namespaces do not have specific metadata attached. * - * @param session The repository session + * @param session The repository session * @param repositoryId The repository id - * @param namespace The namespace ('.' separated) + * @param namespace The namespace ('.' separated) * @throws MetadataRepositoryException if something goes wrong during update */ - void updateNamespace( RepositorySession session, String repositoryId, String namespace ) + void updateNamespace( RepositorySession session, String repositoryId, String namespace ) throws MetadataRepositoryException; /** * Return the facet names stored for the given facet id on the repository level. * - * @param session The repository session + * @param session The repository session * @param repositoryId The repository id - * @param facetId The facet id + * @param facetId The facet id * @return The list of facet names, or an empty list, if there are no facets stored on this repository for the given facet id. * @throws MetadataRepositoryException if something goes wrong */ - List getMetadataFacets( RepositorySession session, String repositoryId, String facetId ) + List getMetadataFacets( RepositorySession session, String repositoryId, String facetId ) throws MetadataRepositoryException; /** - * - * The same as - * @see #getMetadataFacetStream(RepositorySession, String, Class, QueryParameter queryParameter) + * The same as {@link #getMetadataFacetStream(RepositorySession, String, Class, QueryParameter)} * but uses default query parameters. - * + *

* There is no limitation of the number of result objects returned, but implementations may have a hard upper bound for * the number of results. * - * @param session - * @param repositoryId - * @param facetClazz - * @param - * @return - * @throws MetadataRepositoryException + * @param session The repository session. + * @param repositoryId The repository id. + * @param facetClazz The facet class + * @param The facet type + * @return A stream of facet objects, or a empty stream if no facet was found. + * @throws MetadataRepositoryException if the facet retrieval fails. * @since 3.0 */ - Stream getMetadataFacetStream( RepositorySession session, - String repositoryId, Class facetClazz) + Stream getMetadataFacetStream( RepositorySession session, + String repositoryId, Class facetClazz ) throws MetadataRepositoryException; /** * Returns a stream of MetadataFacet elements that match the given facet class. * Implementations should order the resulting stream by facet name. * - * - * @param session The repository session + * @param session The repository session * @param repositoryId The repository id - * @param facetClazz The class of the facet - * @param The facet type - * @return - * @throws MetadataRepositoryException + * @param facetClazz The class of the facet + * @param The facet type + * @return A stream of facet objects, or a empty stream if no facet was found. + * @throws MetadataRepositoryException if the facet retrieval fails * @since 3.0 */ Stream getMetadataFacetStream( RepositorySession session, - String repositoryId, Class facetClazz, - QueryParameter queryParameter) + String repositoryId, Class facetClazz, + QueryParameter queryParameter ) throws MetadataRepositoryException; /** * Returns true, if there is facet data stored for the given facet id on the repository on repository level. The facet data itself * may be empty. It's just checking if there is an object stored for the given facet id. * - * @param session The repository session + * @param session The repository session * @param repositoryId The repository id - * @param facetId The facet id + * @param facetId The facet id * @return true if there is data stored this facetId on repository level. * @throws MetadataRepositoryException if something goes wrong * @since 1.4-M4 */ - boolean hasMetadataFacet( RepositorySession session, String repositoryId, String facetId ) + boolean hasMetadataFacet( RepositorySession session, String repositoryId, String facetId ) throws MetadataRepositoryException; /** * Returns the facet data stored on the repository level. The facet instance is identified by the facet id and the * facet name. The returned object is a instance created by using {@link org.apache.archiva.metadata.model.MetadataFacetFactory}. * - * @param session The repository session + * @param session The repository session * @param repositoryId The repository id - * @param facetId The facet id - * @param name The attribute name + * @param facetId The facet id + * @param name The attribute name * @return The facet values * @throws MetadataRepositoryException if something goes wrong. */ - MetadataFacet getMetadataFacet( RepositorySession session, String repositoryId, String facetId, - String name ) + MetadataFacet getMetadataFacet( RepositorySession session, String repositoryId, String facetId, + String name ) throws MetadataRepositoryException; /** @@ -241,231 +237,248 @@ public interface MetadataRepository * If the given name does not point to a instance that can be represented by this class, null will be returned. * If the facet is not found the method returns null. * - * @param session The repository session + * @param session The repository session * @param repositoryId The id of the repository - * @param clazz The facet object class - * @param name The name of the facet (name or path) - * @param The type of the facet object + * @param clazz The facet object class + * @param name The name of the facet (name or path) + * @param The type of the facet object * @return The facet instance, if it exists. * @throws MetadataRepositoryException if the data cannot be retrieved from the backend * @since 3.0 */ - T getMetadataFacet( RepositorySession session, String repositoryId, - Class clazz, String name) - throws MetadataRepositoryException; + T getMetadataFacet( RepositorySession session, String repositoryId, + Class clazz, String name ) + throws MetadataRepositoryException; /** * Adds a facet to the repository level. * - * @param session The repository session - * @param repositoryId The id of the repository + * @param session The repository session + * @param repositoryId The id of the repository * @param metadataFacet The facet to add * @throws MetadataRepositoryException if the facet cannot be stored. */ - void addMetadataFacet( RepositorySession session, String repositoryId, - MetadataFacet metadataFacet ) + void addMetadataFacet( RepositorySession session, String repositoryId, + MetadataFacet metadataFacet ) throws MetadataRepositoryException; /** * Removes all facets with the given facetId from the repository level. * - * @param session The repository session + * @param session The repository session * @param repositoryId The id of the repository - * @param facetId The facet id + * @param facetId The facet id * @throws MetadataRepositoryException if the removal fails */ - void removeMetadataFacets( RepositorySession session, String repositoryId, String facetId ) + void removeMetadataFacets( RepositorySession session, String repositoryId, String facetId ) throws MetadataRepositoryException; /** * Removes the given facet from the repository level, if it exists. * - * @param session The repository session + * @param session The repository session * @param repositoryId The id of the repository - * @param facetId The facet id - * @param name The facet name or path + * @param facetId The facet id + * @param name The facet name or path */ - void removeMetadataFacet( RepositorySession session, String repositoryId, String facetId, String name ) + void removeMetadataFacet( RepositorySession session, String repositoryId, String facetId, String name ) throws MetadataRepositoryException; /** * Is the same as {@link #getArtifactsByDateRange(RepositorySession, String, ZonedDateTime, ZonedDateTime, QueryParameter)}, but * uses default query parameters. - * */ - List getArtifactsByDateRange( RepositorySession session, String repositoryId, + List getArtifactsByDateRange( RepositorySession session, String repositoryId, @Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime ) throws MetadataRepositoryException; /** - * * Searches for artifacts where the 'whenGathered' attribute value is between the given start and end time. * If start or end time or both are null, the time range for the search is unbounded for this parameter. * - * - * @param session The repository session - * @param repositoryId The repository id - * @param startTime The start time/date as zoned date, can be null - * @param endTime The end time/date as zoned date, can be null + * @param session The repository session + * @param repositoryId The repository id + * @param startTime The start time/date as zoned date, can be null + * @param endTime The end time/date as zoned date, can be null * @param queryParameter Additional parameters for the query that affect ordering and returned results * @return The list of metadata objects for the found instances. * @throws MetadataRepositoryException if the query fails. * @since 3.0 */ - List getArtifactsByDateRange( RepositorySession session, String repositoryId, - @Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime, + List getArtifactsByDateRange( RepositorySession session, String repositoryId, + @Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime, QueryParameter queryParameter ) - throws MetadataRepositoryException; + throws MetadataRepositoryException; /** * Returns all the artifacts who's 'whenGathered' attribute value is inside the given time range (inclusive) as stream of objects. - * + *

* Implementations should return a stream of sorted objects. The objects should be sorted by the 'whenGathered' date in ascending order. * - * @param session The repository session + * @param session The repository session * @param repositoryId The repository id - * @param startTime The start time, can be null - * @param endTime The end time, can be null - * @return A stream of artifact metadata objects. - * @throws MetadataRepositoryException + * @param startTime The start time, can be null + * @param endTime The end time, can be null + * @return A stream of artifact metadata objects, or a empty stream if no artifact was found. + * @throws MetadataRepositoryException if the artifact retrieval fails. * @since 3.0 */ - Stream getArtifactByDateRangeStream( RepositorySession session, String repositoryId, + Stream getArtifactByDateRangeStream( RepositorySession session, String repositoryId, @Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime ) throws MetadataRepositoryException; /** * Returns all the artifacts who's 'whenGathered' attribute value is inside the given time range (inclusive) as stream of objects. - * + *

* If no sort attributes are given by the queryParameter, the result is sorted by the 'whenGathered' date. * - * @param session The repository session - * @param repositoryId The repository id - * @param startTime The start time, can be null - * @param endTime The end time, can be null + * @param session The repository session + * @param repositoryId The repository id + * @param startTime The start time, can be null + * @param endTime The end time, can be null * @param queryParameter Additional parameters for the query that affect ordering and number of returned results. * @return A stream of artifact metadata objects. - * @throws MetadataRepositoryException + * @throws MetadataRepositoryException if the artifact retrieval fails. * @since 3.0 */ - Stream getArtifactByDateRangeStream( RepositorySession session, String repositoryId, + Stream getArtifactByDateRangeStream( RepositorySession session, String repositoryId, @Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime, - QueryParameter queryParameter) + QueryParameter queryParameter ) throws MetadataRepositoryException; /** * Returns the artifacts that match the given checksum. All checksum types are searched. * - * @param session The repository session - * @param repositoryId The repository id - * @param checksum The checksum as string of numbers + * @param session The repository session + * @param repositoryId The repository id + * @param checksum The checksum as string of numbers * @return The list of artifacts that match the given checksum. - * @throws MetadataRepositoryException + * @throws MetadataRepositoryException if the artifact retrieval fails */ - List getArtifactsByChecksum( RepositorySession session, String repositoryId, String checksum ) + List getArtifactsByChecksum( RepositorySession session, String repositoryId, String checksum ) throws MetadataRepositoryException; /** * Get artifacts with a project version metadata key that matches the passed value. - * * - * @param session - * @param key - * @param value - * @param repositoryId can be null, meaning search in all repositories - * @return a list of artifacts - * @throws MetadataRepositoryException + * @param session The repository session + * @param key The attribute key to search + * @param value The attribute value used for search + * @param repositoryId can be null, meaning search in all repositories + * @return a list of artifacts. A empty list, if no artifact was found. + * @throws MetadataRepositoryException if the artifact retrieval fails. */ - List getArtifactsByProjectVersionMetadata( RepositorySession session, String key, String value, - @Nullable String repositoryId ) + List getArtifactsByProjectVersionFacet( RepositorySession session, String key, String value, + @Nullable String repositoryId ) throws MetadataRepositoryException; /** * Get artifacts with an artifact metadata key that matches the passed value. - * + * key ist the string representation of one of the metadata attributes. Only artifacts are returned where + * the attribute value matches exactly the given search value. * - * @param session - * @param key - * @param value - * @param repositoryId can be null, meaning search in all repositories - * @return a list of artifacts - * @throws MetadataRepositoryException + * @param session The repository session. + * @param key The string representation of the artifact metadata attribute. + * @param value The search value. + * @param repositoryId can be null, meaning search in all repositories + * @return a list of artifact objects for each artifact that matches the search string + * @throws MetadataRepositoryException if the artifact retrieval fails. */ - List getArtifactsByMetadata( RepositorySession session, String key, String value, String repositoryId ) + List getArtifactsByAttribute( RepositorySession session, String key, String value, @Nullable String repositoryId ) throws MetadataRepositoryException; /** - * Get artifacts with a property key that matches the passed value. + * Get artifacts with a attribute on project version level that matches the passed value. * Possible keys are 'scm.url', 'org.name', 'url', 'mailingList.0.name', 'license.0.name',... - * * - * @param session - * @param key - * @param value - * @param repositoryId can be null, meaning search in all repositories - * @return a list of artifacts - * @throws MetadataRepositoryException + * @param session the repository session. + * @param key The name of the attribute (may be nested like scm.url, mailinglist.0.name) + * @param value The value to search for + * @param repositoryId can be null, which means to search in all repositories + * @return a list of artifacts or a empty list, if no artifact was found + * @throws MetadataRepositoryException if the artifact retrieval fails */ - List getArtifactsByProperty( RepositorySession session, String key, String value, String repositoryId ) + List getArtifactsByProjectVersionAttribute( RepositorySession session, String key, String value, @Nullable String repositoryId ) throws MetadataRepositoryException; + /** + * Removes the data for the artifact with the given coordinates from the metadata repository. This will not remove the artifact itself + * from the storage. It will only remove the metadata. + * + * @param session The repository session + * @param repositoryId The repository id + * @param namespace The namespace of the project + * @param project The project name + * @param version The project version + * @param id The artifact id + * @throws MetadataRepositoryException if the artifact retrieval fails, or if the artifact cannot be found. + */ void removeArtifact( RepositorySession session, String repositoryId, String namespace, String project, String version, String id ) throws MetadataRepositoryException; /** - * used for deleting timestamped version of SNAPSHOT artifacts - * + * Remove timestamped version of artifact. This removes a snapshot artifact by giving the artifact metadata + * and the base version of the project. * - * @param session + * @param session The repository session * @param artifactMetadata the artifactMetadata with the timestamped version (2.0-20120618.214135-2) * @param baseVersion the base version of the snapshot (2.0-SNAPSHOT) - * @throws MetadataRepositoryException + * @throws MetadataRepositoryException if the removal fails. * @since 1.4-M3 */ - void removeArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion ) + void removeTimestampedArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion ) throws MetadataRepositoryException; /** * FIXME need a unit test!!! - * Only remove {@link MetadataFacet} for the artifact - * - * - * @param session - * @param repositoryId - * @param namespace - * @param project - * @param version - * @param metadataFacet - * @throws MetadataRepositoryException + * Removes the {@link MetadataFacet} of the given artifact. + * + * @param session The repository session + * @param repositoryId The repository id. + * @param namespace The namespace + * @param project The project name + * @param version The project version + * @param metadataFacet The facet data + * @throws MetadataRepositoryException if the removal failed * @since 1.4-M3 */ - void removeArtifact( RepositorySession session, String repositoryId, String namespace, String project, String version, - MetadataFacet metadataFacet ) + void removeFacetFromArtifact( RepositorySession session, String repositoryId, String namespace, String project, String version, + MetadataFacet metadataFacet ) throws MetadataRepositoryException; /** - * Delete a repository's metadata. This includes all associated metadata facets. + * Deletes all metadata of the given repository. This includes artifact metadata and all associated metadata facets. * - * @param session + * @param session The repository session * @param repositoryId the repository to delete + * @throws MetadataRepositoryException if the removal failed */ void removeRepository( RepositorySession session, String repositoryId ) throws MetadataRepositoryException; /** + * Removes the given namespace and its contents from the metadata repository. * - * @param session - * @param repositoryId - * @param namespace (groupId for maven ) - * @throws MetadataRepositoryException + * @param session The repository session + * @param repositoryId The repository id + * @param namespace The namespace '.' separated ( it's the groupId for maven ) + * @throws MetadataRepositoryException if the removal failed * @since 1.4-M3 */ void removeNamespace( RepositorySession session, String repositoryId, String namespace ) throws MetadataRepositoryException; + /** + * Returns the metadata for all artifacts of the given repository. + * + * @param session The repository session + * @param repositoryId The repository id + * @return a list of artifact metadata objects. A empty list if no artifacts where found. + * @throws MetadataRepositoryException if the retrieval failed. + */ List getArtifacts( RepositorySession session, String repositoryId ) throws MetadataRepositoryException; @@ -477,12 +490,12 @@ public interface MetadataRepository * If there are no sortFields defined in the query parameter, the order of elements in the stream is undefined and depends * on the implementation. * - * @param session - * @param repositoryId + * @param session The repository session. + * @param repositoryId The repository id. * @return A stream of artifact metadata objects for each artifact found in the repository. * @since 3.0 */ - Stream getArtifactStream( RepositorySession session, String repositoryId, QueryParameter queryParameter ) + Stream getArtifactStream( RepositorySession session, String repositoryId, QueryParameter queryParameter ) throws MetadataResolutionException; /** @@ -490,68 +503,92 @@ public interface MetadataRepository * The order of the artifacts returned in the stream depends on the implementation. * The number of elements in the stream is unlimited, but there may be some implementations that have to put a hard * limit on the elements returned. - * For further information see {@link #getArtifactStream(RepositorySession, String, QueryParameter)} + * For further information see {@link #getArtifactStream(RepositorySession, String, QueryParameter)} * - * @param session The repository session + * @param session The repository session * @param repositoryId The repository id * @return A (unlimited) stream of artifact metadata elements that are found in this repository - * @since 3.0 * @see #getArtifactStream(RepositorySession, String, QueryParameter) + * @since 3.0 */ - Stream getArtifactStream( RepositorySession session, String repositoryId) + Stream getArtifactStream( RepositorySession session, String repositoryId ) throws MetadataResolutionException; /** * Returns a stream of artifacts found for the given artifact coordinates and using the queryParameter * - * @param session The repository session. May not be null. - * @param repoId The repository id. May not be null. - * @param namespace The namespace. May not be null. - * @param projectId The project id. May not be null. + * @param session The repository session. May not be null. + * @param repoId The repository id. May not be null. + * @param namespace The namespace. May not be null. + * @param projectId The project id. May not be null. * @param projectVersion The project version. May not be null. * @return A stream of artifact metadata object. Order and number of elements returned, depends on the queryParameter. - * @since 3.0 * @throws MetadataResolutionException if there are no elements for the given artifact coordinates. + * @since 3.0 */ - Stream getArtifactStream( RepositorySession session, String repoId, - String namespace, String projectId, - String projectVersion, QueryParameter queryParameter ) + Stream getArtifactStream( RepositorySession session, String repoId, + String namespace, String projectId, + String projectVersion, QueryParameter queryParameter ) throws MetadataResolutionException; /** * Returns a stream of artifacts found for the given artifact coordinates. The order of elements returned, depends on the * implementation. * - * @param session The repository session. May not be null. - * @param repoId The repository id. May not be null. - * @param namespace The namespace. May not be null. - * @param projectId The project id. May not be null. + * @param session The repository session. May not be null. + * @param repoId The repository id. May not be null. + * @param namespace The namespace. May not be null. + * @param projectId The project id. May not be null. * @param projectVersion The project version. May not be null. * @return A stream of artifact metadata object. Order and number of elements returned, depends on the queryParameter. - * @since 3.0 * @throws MetadataResolutionException if there are no elements for the given artifact coordinates. + * @since 3.0 */ - Stream getArtifactStream( RepositorySession session, String repoId, - String namespace, String projectId, - String projectVersion) + Stream getArtifactStream( RepositorySession session, String repoId, + String namespace, String projectId, + String projectVersion ) throws MetadataResolutionException; + /** - * basically just checking it exists not complete data returned + * Returns the metadata for the given project. If there are no custom properties stored on the project, it will + * just return a ProjectMetadata object with the data provided by parameters. * - * - * @param session - * @param repoId - * @param namespace - * @param projectId - * @return - * @throws MetadataResolutionException + * @param session The session id + * @param repoId The repository id + * @param namespace The namespace '.'-separated. + * @param projectId The project name + * @return The project metadata or null if not found. + * @throws MetadataResolutionException if the metadata retrieval failed */ ProjectMetadata getProject( RepositorySession session, String repoId, String namespace, String projectId ) throws MetadataResolutionException; + /** + * Returns the metadata for the project version. + * + * @param session The repository session. + * @param repoId The repository id. + * @param namespace The namespace '.'-separated + * @param projectId The project name + * @param projectVersion The project version + * @return The version metadata object, or null, if not found. + * @throws MetadataResolutionException if the retrieval of the metadata failed. + */ ProjectVersionMetadata getProjectVersion( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion ) throws MetadataResolutionException; + /** + * Returns all artifact version strings for a given project version. This is for snapshot versions and returns the timestamped + * versions, if available. + * + * @param session The repository session. + * @param repoId The repository id. + * @param namespace The namespace '.'-separated + * @param projectId The project name. + * @param projectVersion The project version. + * @return A list of version strings, or a empty list if no versions are found, or this is not a snapshot version. + * @throws MetadataResolutionException if the retrieval of the metadata failed. + */ Collection getArtifactVersions( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion ) throws MetadataResolutionException; @@ -560,131 +597,145 @@ public interface MetadataRepository * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual * project is, and we want to avoid adding a stub model to the content repository. * - * - * @param session - * @param repoId the repository ID to look within - * @param namespace the namespace of the project to get references to - * @param projectId the identifier of the project to get references to - * @param projectVersion the version of the project to get references to + * @param session The repository session. + * @param repoId The repository ID to look within + * @param namespace The namespace of the project to get references to + * @param projectId The identifier of the project to get references to + * @param projectVersion The version of the project to get references to * @return a list of project references + * @throws MetadataResolutionException if the version could not be found. */ Collection getProjectReferences( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion ) throws MetadataResolutionException; + /** + * Returns the names of the root namespaces stored for this repository. + * + * @param session The repository session. + * @param repoId The repository id. + * @return A list of namespace names, or empty list, if no namespace is stored for this repository. + * @throws MetadataResolutionException If the retrieval failed. + */ Collection getRootNamespaces( RepositorySession session, String repoId ) throws MetadataResolutionException; /** + * Returns the list of namespace names that are children of the given namespace. It does not descend recursively. * - * @param session - * @param repoId - * @param namespace - * @return {@link Collection} of child namespaces of the namespace argument - * @throws MetadataResolutionException + * @param session The repository session. + * @param repoId The repository id. + * @param namespace The parent namespace '.'-separated. + * @return {@link Collection} of child namespace names, or a empty list, if there are no children for the given parent namespace. + * @throws MetadataResolutionException if the retrieval failed. */ - Collection getNamespaces( RepositorySession session, String repoId, String namespace ) + Collection getChildNamespaces( RepositorySession session, String repoId, String namespace ) throws MetadataResolutionException; /** + * Return the project names that of all projects stored under the given namespace. * - * @param session - * @param repoId - * @param namespace - * @return - * @throws MetadataResolutionException + * @param session The repository session. + * @param repoId The repository id. + * @param namespace The namespace '.'-separated. + * @return The list of project names or empty list if no project exists at the given namespace. + * @throws MetadataResolutionException if the retrieval failed. */ Collection getProjects( RepositorySession session, String repoId, String namespace ) throws MetadataResolutionException; /** + * Returns the names of all versions stored under the given project. * - * @param session - * @param repoId - * @param namespace - * @param projectId - * @return - * @throws MetadataResolutionException + * @param session The repository session. + * @param repoId The repository id. + * @param namespace The namespace '.'-separated. + * @param projectId The project name. + * @return The list of versions or a empty list, if not version was found. + * @throws MetadataResolutionException if the retrieval failed. */ Collection getProjectVersions( RepositorySession session, String repoId, String namespace, String projectId ) throws MetadataResolutionException; /** + * Removes a project version and all its artifact and facet metadata under it. * - * @param session - * @param repoId - * @param namespace - * @param projectId - * @param projectVersion - * @throws MetadataRepositoryException + * @param session The repository session. + * @param repoId The repository id. + * @param namespace The namespace '.'-separated. + * @param projectId The project name + * @param projectVersion The project version. + * @throws MetadataRepositoryException if the removal failed. * @since 1.4-M4 */ void removeProjectVersion( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion ) throws MetadataRepositoryException; /** + * Returns the metadata of all artifacts stored for the given project version. * - * @param session - * @param repoId - * @param namespace - * @param projectId - * @param projectVersion - * @return - * @throws MetadataResolutionException + * @param session The repository session. + * @param repoId The repository id. + * @param namespace The namespace '.'-separated. + * @param projectId The project name. + * @param projectVersion The project version. + * @return The list of artifact metadata objects, or a empty list, if no artifact exists for this version. + * @throws MetadataResolutionException if the retrieval failed. */ Collection getArtifacts( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion ) throws MetadataResolutionException; /** - * remove a project - * + * Removes the project metadata and metadata for all stored versions, artifacts and facets of this project. * - * @param session - * @param repositoryId - * @param namespace - * @param projectId - * @throws MetadataRepositoryException + * @param session The repository session. + * @param repositoryId The repository id. + * @param namespace The namespace '.'-separated. + * @param projectId The project name. + * @throws MetadataRepositoryException if the removal failed. * @since 1.4-M4 */ void removeProject( RepositorySession session, String repositoryId, String namespace, String projectId ) throws MetadataRepositoryException; - - void close() + /** + * Closes the repository. + * Repositories are normally opened during startup and closed on shutdown. The closing of a repository stops all + * invalidates all connections to it. + * Sessions that are open are invalidated too. The repository will throw exceptions if it is used after closing. + * + * @throws MetadataRepositoryException if the something went wrong or if the repository was closed already. + */ + void close( ) throws MetadataRepositoryException; - boolean canObtainAccess( Class aClass ); - - T obtainAccess( RepositorySession session, Class aClass ) - throws MetadataRepositoryException; - /** - * Full text artifacts search. - * + * Full text artifacts search. Searches for the given string in all metadata and returns artifacts where the + * text was found. * - * @param session - * @param repositoryId can be null to search in all repositories - * @param text - * @param exact running an exact search, the value must exactly match the text. - * @return a list of artifacts - * @throws MetadataRepositoryException + * @param session The repository session. + * @param repositoryId can be null to search in all repositories + * @param text The search text + * @param exact if true, the value must exactly match the text. + * @return a list of artifacts or empty list if no results where found. + * @throws MetadataRepositoryException if the retrieval failed. */ List searchArtifacts( RepositorySession session, String repositoryId, String text, boolean exact ) throws MetadataRepositoryException; /** - * Full text artifacts search inside the specified key. - * + * Full text artifacts search inside the specified key. Searches for the given text in all attributes with the given + * name. * - * @param session - * @param repositoryId can be null to search in all repositories - * @param key search only inside this key - * @param text - * @param exact running an exact search, the value must exactly match the text. - * @return a list of artifacts - * @throws MetadataRepositoryException + * @param session The repository session. + * @param repositoryId can be null to search in all repositories + * @param key search only inside this attribute. + * @param text The search string. + * @param exact if true, the value must exactly match the text. + * @return a list of artifacts or empty list if no results were found. + * @throws MetadataRepositoryException if the retrieval failed. */ List searchArtifacts( RepositorySession session, String repositoryId, String key, String text, boolean exact ) throws MetadataRepositoryException; diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java index e24f45628..668f45cae 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java +++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java @@ -177,7 +177,7 @@ public abstract class AbstractMetadataRepositoryTest } } ); - // for the getArtifactsByProjectVersionMetadata tests + // for the getArtifactsByProjectVersionFacet tests factories.add( new GenericMetadataFacetFactory( ) ); return factories; @@ -1540,13 +1540,13 @@ public abstract class AbstractMetadataRepositoryTest assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "org" ); - namespaces = getRepository( ).getNamespaces( session, TEST_REPO_ID, "org" ); + namespaces = getRepository( ).getChildNamespaces( session, TEST_REPO_ID, "org" ); assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "apache" ); - namespaces = getRepository( ).getNamespaces( session, TEST_REPO_ID, "org.apache" ); + namespaces = getRepository( ).getChildNamespaces( session, TEST_REPO_ID, "org.apache" ); assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "maven" ); - namespaces = getRepository( ).getNamespaces( session, TEST_REPO_ID, "org.apache.maven" ); + namespaces = getRepository( ).getChildNamespaces( session, TEST_REPO_ID, "org.apache.maven" ); assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "shared" ); } ); @@ -1566,7 +1566,7 @@ public abstract class AbstractMetadataRepositoryTest metadata.setId( TEST_PROJECT_VERSION ); getRepository( ).updateProjectVersion( session, TEST_REPO_ID, namespace, TEST_PROJECT, metadata ); - Collection namespaces = getRepository( ).getNamespaces( session, TEST_REPO_ID, namespace ); + Collection namespaces = getRepository( ).getChildNamespaces( session, TEST_REPO_ID, namespace ); assertThat( namespaces ).isNotNull( ).isEmpty( ); @@ -1754,7 +1754,7 @@ public abstract class AbstractMetadataRepositoryTest tryAssert( ( ) -> { Collection artifactsByMetadata = - getRepository( ).getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, TEST_REPO_ID ); + getRepository( ).getArtifactsByProjectVersionFacet( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, TEST_REPO_ID ); assertThat( artifactsByMetadata ).hasSize( 1 ); ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator( ).next( ); @@ -1775,7 +1775,7 @@ public abstract class AbstractMetadataRepositoryTest tryAssert( ( ) -> { Collection artifactsByMetadata = - getRepository( ).getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, null ); + getRepository( ).getArtifactsByProjectVersionFacet( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, null ); assertThat( artifactsByMetadata ).hasSize( 1 ); assertThat( artifactsByMetadata.iterator( ).next( ).getRepositoryId( ) ).isNotNull( ).isNotEmpty( ); } ); @@ -1792,7 +1792,7 @@ public abstract class AbstractMetadataRepositoryTest tryAssert( ( ) -> { Collection artifactsByMetadata = - getRepository( ).getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, null ); + getRepository( ).getArtifactsByProjectVersionFacet( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, null ); assertThat( artifactsByMetadata ).hasSize( 1 ); } ); } @@ -1807,7 +1807,7 @@ public abstract class AbstractMetadataRepositoryTest createArtifactWithMavenArtifactFacet( session ); tryAssert( ( ) -> { Collection artifactsByMetadata = - getRepository( ).getArtifactsByMetadata( session, "foo", TEST_METADATA_VALUE, null ); + getRepository( ).getArtifactsByAttribute( session, "foo", TEST_METADATA_VALUE, null ); assertThat( artifactsByMetadata ).hasSize( 1 ); ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator( ).next( ); assertThat( artifactMetadata.getId( ) ).isEqualTo( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + ".jar" ); @@ -1828,10 +1828,10 @@ public abstract class AbstractMetadataRepositoryTest { createArtifactWithData( session ); // only works on JCR implementation - // Collection artifactsByProperty = getRepository().getArtifactsByProperty( "org.name", TEST_ORGANIZATION.getName(), TEST_REPO_ID ); + // Collection artifactsByProperty = getRepository().getArtifactsByProjectVersionAttribute( "org.name", TEST_ORGANIZATION.getName(), TEST_REPO_ID ); tryAssert( ( ) -> { - Collection artifactsByProperty = getRepository( ).getArtifactsByProperty( session, "url", TEST_URL, TEST_REPO_ID ); + Collection artifactsByProperty = getRepository( ).getArtifactsByProjectVersionAttribute( session, "url", TEST_URL, TEST_REPO_ID ); assertThat( artifactsByProperty ).hasSize( 1 ); ArtifactMetadata artifactMetadata = artifactsByProperty.iterator( ).next( ); assertThat( artifactMetadata.getId( ) ).isEqualTo( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + ".jar" ); @@ -2046,13 +2046,13 @@ public abstract class AbstractMetadataRepositoryTest log.info( "artifactMetadatas: {}", artifactMetadatas ); - getRepository( ).removeArtifact( session, artifactOne, "2.0-SNAPSHOT" ); + getRepository( ).removeTimestampedArtifact( session, artifactOne, "2.0-SNAPSHOT" ); artifactMetadatas = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" ); assertThat( artifactMetadatas ).isNotNull( ).isNotEmpty( ).hasSize( 1 ); - getRepository( ).removeArtifact( session, artifactTwo, "2.0-SNAPSHOT" ); + getRepository( ).removeTimestampedArtifact( session, artifactTwo, "2.0-SNAPSHOT" ); artifactMetadatas = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" ); diff --git a/archiva-modules/metadata/metadata-statistics-api/src/main/java/org/apache/archiva/metadata/repository/stats/model/RepositoryWalkingStatisticsProvider.java b/archiva-modules/metadata/metadata-statistics-api/src/main/java/org/apache/archiva/metadata/repository/stats/model/RepositoryWalkingStatisticsProvider.java index 7cc7528ac..4f06928c0 100644 --- a/archiva-modules/metadata/metadata-statistics-api/src/main/java/org/apache/archiva/metadata/repository/stats/model/RepositoryWalkingStatisticsProvider.java +++ b/archiva-modules/metadata/metadata-statistics-api/src/main/java/org/apache/archiva/metadata/repository/stats/model/RepositoryWalkingStatisticsProvider.java @@ -73,7 +73,7 @@ public class RepositoryWalkingStatisticsProvider implements RepositoryStatistics String ns ) throws MetadataResolutionException { - for ( String namespace : metadataRepository.getNamespaces( repositorySession , repositoryId, ns ) ) + for ( String namespace : metadataRepository.getChildNamespaces( repositorySession , repositoryId, ns ) ) { walkRepository( repositorySession, metadataRepository, stats, repositoryId, ns + "." + namespace ); } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java index 1b6646a3b..f3a0fee9e 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java @@ -482,7 +482,7 @@ public class CassandraMetadataRepository // FIXME this one need peformance improvement maybe a cache? @Override - public Collection getNamespaces( RepositorySession session, final String repoId, final String namespaceId ) + public Collection getChildNamespaces( RepositorySession session, final String repoId, final String namespaceId ) throws MetadataResolutionException { @@ -2032,17 +2032,17 @@ public class CassandraMetadataRepository /** * Project version and artifact level metadata are stored in the same place, no distinctions in Cassandra - * implementation, just calls {@link MetadataRepository#getArtifactsByMetadata(RepositorySession, String, String, String)} + * implementation, just calls {@link MetadataRepository#getArtifactsByAttribute(RepositorySession, String, String, String)} */ @Override - public List getArtifactsByProjectVersionMetadata( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByProjectVersionFacet( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { - return getArtifactsByMetadata( session, key, value, repositoryId ); + return this.getArtifactsByAttribute( session, key, value, repositoryId ); } @Override - public List getArtifactsByMetadata( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByAttribute( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { RangeSlicesQuery query = @@ -2101,7 +2101,7 @@ public class CassandraMetadataRepository } @Override - public List getArtifactsByProperty( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByProjectVersionAttribute( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { QueryResult> result = @@ -2146,7 +2146,7 @@ public class CassandraMetadataRepository final String version, final String id ) throws MetadataRepositoryException { - logger.debug( "removeArtifact repositoryId: '{}', namespace: '{}', project: '{}', version: '{}', id: '{}'", + logger.debug( "removeTimestampedArtifact repositoryId: '{}', namespace: '{}', project: '{}', version: '{}', id: '{}'", repositoryId, namespace, project, version, id ); String key = new ArtifactMetadataModel.KeyBuilder().withRepositoryId( repositoryId ).withNamespace( namespace ).withId( @@ -2166,10 +2166,10 @@ public class CassandraMetadataRepository } @Override - public void removeArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion ) + public void removeTimestampedArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion ) throws MetadataRepositoryException { - logger.debug( "removeArtifact repositoryId: '{}', namespace: '{}', project: '{}', version: '{}', id: '{}'", + logger.debug( "removeTimestampedArtifact repositoryId: '{}', namespace: '{}', project: '{}', version: '{}', id: '{}'", artifactMetadata.getRepositoryId(), artifactMetadata.getNamespace(), artifactMetadata.getProject(), baseVersion, artifactMetadata.getId() ); String key = @@ -2182,8 +2182,8 @@ public class CassandraMetadataRepository } @Override - public void removeArtifact( RepositorySession session, final String repositoryId, final String namespace, final String project, - final String version, final MetadataFacet metadataFacet ) + public void removeFacetFromArtifact( RepositorySession session, final String repositoryId, final String namespace, final String project, + final String version, final MetadataFacet metadataFacet ) throws MetadataRepositoryException { @@ -2447,21 +2447,6 @@ public class CassandraMetadataRepository } - @Override - public boolean canObtainAccess( Class aClass ) - { - return false; - } - - @Override - public T obtainAccess( RepositorySession session, Class aClass ) - throws MetadataRepositoryException - { - throw new IllegalArgumentException( - "Access using " + aClass + " is not supported on the cassandra metadata storage" ); - } - - private static class ModelMapperHolder { private static ModelMapper MODEL_MAPPER = new ModelMapper(); @@ -2473,7 +2458,7 @@ public class CassandraMetadataRepository } /** - * This implementation just calls getArtifactsByMetadata( null, text, repositoryId ). We can't search artifacts by + * This implementation just calls getArtifactsByAttribute( null, text, repositoryId ). We can't search artifacts by * any property. */ @Override @@ -2481,7 +2466,7 @@ public class CassandraMetadataRepository final String text, final boolean exact ) throws MetadataRepositoryException { - return getArtifactsByMetadata( session, null, text, repositoryId ); + return this.getArtifactsByAttribute( session, null, text, repositoryId ); } /** @@ -2494,8 +2479,8 @@ public class CassandraMetadataRepository { // TODO optimize List artifacts = new LinkedList(); - artifacts.addAll( getArtifactsByMetadata( session, key, text, repositoryId ) ); - artifacts.addAll( getArtifactsByProperty( session, key, text, repositoryId ) ); + artifacts.addAll( this.getArtifactsByAttribute( session, key, text, repositoryId ) ); + artifacts.addAll( this.getArtifactsByProjectVersionAttribute( session, key, text, repositoryId ) ); return artifacts; } diff --git a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index aa4e25ab3..e694ec915 100644 --- a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -476,7 +476,7 @@ public class FileMetadataRepository ZonedDateTime endTime) throws MetadataRepositoryException { try { - for (String namespace : getNamespaces(session, repoId, ns)) { + for (String namespace : this.getChildNamespaces(session, repoId, ns)) { getArtifactsByDateRange(session, artifacts, repoId, ns + "." + namespace, startTime, endTime); } @@ -580,17 +580,6 @@ public class FileMetadataRepository } - @Override - public boolean canObtainAccess(Class aClass) { - return false; - } - - @Override - public T obtainAccess(RepositorySession session, Class aClass) { - throw new IllegalArgumentException( - "Access using " + aClass + " is not supported on the file metadata storage"); - } - private void updateArtifactFacets(ArtifactMetadata artifact, Properties properties) { String propertyPrefix = "artifact:facet:" + artifact.getId() + ":"; for (MetadataFacet facet : artifact.getFacetList()) { @@ -634,7 +623,7 @@ public class FileMetadataRepository } @Override - public void removeArtifact(RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion) + public void removeTimestampedArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion) throws MetadataRepositoryException { try { @@ -712,8 +701,8 @@ public class FileMetadataRepository * @throws MetadataRepositoryException */ @Override - public void removeArtifact(RepositorySession session, String repositoryId, String namespace, String project, String projectVersion, - MetadataFacet metadataFacet) + public void removeFacetFromArtifact( RepositorySession session, String repositoryId, String namespace, String project, String projectVersion, + MetadataFacet metadataFacet) throws MetadataRepositoryException { throw new UnsupportedOperationException("not implemented"); } @@ -731,21 +720,21 @@ public class FileMetadataRepository @Override - public List getArtifactsByProjectVersionMetadata(RepositorySession session, String key, String value, String repositoryId) + public List getArtifactsByProjectVersionFacet( RepositorySession session, String key, String value, String repositoryId) throws MetadataRepositoryException { throw new UnsupportedOperationException("not yet implemented in File backend"); } @Override - public List getArtifactsByMetadata(RepositorySession session, String key, String value, String repositoryId) + public List getArtifactsByAttribute( RepositorySession session, String key, String value, String repositoryId) throws MetadataRepositoryException { throw new UnsupportedOperationException("not yet implemented in File backend"); } @Override - public List getArtifactsByProperty(RepositorySession session, String key, String value, String repositoryId) + public List getArtifactsByProjectVersionAttribute( RepositorySession session, String key, String value, String repositoryId) throws MetadataRepositoryException { - throw new UnsupportedOperationException("getArtifactsByProperty not yet implemented in File backend"); + throw new UnsupportedOperationException("getArtifactsByProjectVersionAttribute not yet implemented in File backend"); } private Path getMetadataDirectory(String repoId, String facetId) @@ -1057,7 +1046,7 @@ public class FileMetadataRepository @Override public Collection getRootNamespaces(RepositorySession session, String repoId) throws MetadataResolutionException { - return getNamespaces(session, repoId, null); + return this.getChildNamespaces(session, repoId, null); } private Stream getAllNamespacesStream(RepositorySession session, String repoId) { @@ -1087,7 +1076,7 @@ public class FileMetadataRepository } @Override - public Collection getNamespaces(RepositorySession session, String repoId, String baseNamespace) + public Collection getChildNamespaces( RepositorySession session, String repoId, String baseNamespace) throws MetadataResolutionException { try { List allNamespaces; @@ -1305,7 +1294,7 @@ public class FileMetadataRepository private void getArtifacts(RepositorySession session, List artifacts, String repoId, String ns) throws MetadataResolutionException { - for (String namespace : getNamespaces(session, repoId, ns)) { + for (String namespace : this.getChildNamespaces(session, repoId, ns)) { getArtifacts(session, artifacts, repoId, ns + "." + namespace); } diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java index 07ef40c29..2efdf9681 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java @@ -963,7 +963,7 @@ public class JcrMetadataRepository } @Override - public List getArtifactsByProjectVersionMetadata( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByProjectVersionFacet( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { final Session jcrSession = getSession( session ); @@ -973,7 +973,7 @@ public class JcrMetadataRepository @Override - public List getArtifactsByMetadata( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByAttribute( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { final Session jcrSession = getSession( session ); @@ -983,7 +983,7 @@ public class JcrMetadataRepository @Override - public List getArtifactsByProperty( RepositorySession session, String key, String value, String repositoryId ) + public List getArtifactsByProjectVersionAttribute( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { final Session jcrSession = getSession( session ); @@ -1367,11 +1367,11 @@ public class JcrMetadataRepository public Collection getRootNamespaces( RepositorySession session, String repositoryId ) throws MetadataResolutionException { - return getNamespaces(session , repositoryId, null ); + return this.getChildNamespaces(session , repositoryId, null ); } @Override - public Collection getNamespaces( RepositorySession session, String repositoryId, String baseNamespace ) + public Collection getChildNamespaces( RepositorySession session, String repositoryId, String baseNamespace ) throws MetadataResolutionException { String path = baseNamespace != null @@ -1417,7 +1417,7 @@ public class JcrMetadataRepository } @Override - public void removeArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion ) + public void removeTimestampedArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion ) throws MetadataRepositoryException { final Session jcrSession = getSession( session ); @@ -1525,8 +1525,8 @@ public class JcrMetadataRepository } @Override - public void removeArtifact( RepositorySession session, String repositoryId, String namespace, String project, String projectVersion, - MetadataFacet metadataFacet ) + public void removeFacetFromArtifact( RepositorySession session, String repositoryId, String namespace, String project, String projectVersion, + MetadataFacet metadataFacet ) throws MetadataRepositoryException { final Session jcrSession = getSession( session ); @@ -1603,25 +1603,6 @@ public class JcrMetadataRepository } - @Override - public boolean canObtainAccess( Class aClass ) - { - return aClass == Session.class; - } - - @SuppressWarnings( "unchecked" ) - @Override - public T obtainAccess( RepositorySession session, Class aClass ) - throws MetadataRepositoryException - { - if ( aClass == Session.class ) - { - return (T) getSession( session ); - } - throw new IllegalArgumentException( - "Access using " + aClass + " is not supported on the JCR metadata storage" ); - } - @Override public void close() throws MetadataRepositoryException diff --git a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java index f888f1f1a..8d7f92e1b 100644 --- a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java +++ b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java @@ -628,9 +628,9 @@ public class RepositoryStatisticsManagerTest expect( metadataRepository.getProjects(session , TEST_REPO_ID, "com" ) ).andReturn( Arrays.asList() ); - expect( metadataRepository.getNamespaces(session , TEST_REPO_ID, "com" ) ).andReturn( Arrays.asList( "example" ) ); + expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "com" ) ).andReturn( Arrays.asList( "example" ) ); - expect( metadataRepository.getNamespaces(session , TEST_REPO_ID, "com.example" ) ).andReturn( + expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "com.example" ) ).andReturn( Arrays.asList() ); expect( metadataRepository.getProjects(session , TEST_REPO_ID, "com.example" ) ).andReturn( @@ -650,14 +650,14 @@ public class RepositoryStatisticsManagerTest createArtifact( "com.example", "example-project", "1.1", "pom" ) ) ); - expect( metadataRepository.getNamespaces(session , TEST_REPO_ID, "org" ) ).andReturn( Arrays.asList( "apache", "codehaus" ) ); + expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org" ) ).andReturn( Arrays.asList( "apache", "codehaus" ) ); - expect( metadataRepository.getNamespaces(session , TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.asList( "archiva", "maven" ) ); + expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.asList( "archiva", "maven" ) ); expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.asList() ); - expect( metadataRepository.getNamespaces(session , TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.asList() ); + expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.asList() ); expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.asList( "metadata-repository-api", "metadata-model" ) ); @@ -685,7 +685,7 @@ public class RepositoryStatisticsManagerTest .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3", "jar" ), createArtifact( "org.apache.archiva", "metadata-model", "1.3", "pom" ) ) ); - expect( metadataRepository.getNamespaces(session , TEST_REPO_ID, "org.apache.maven" ) ).andReturn( Arrays.asList() ); + expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.apache.maven" ) ).andReturn( Arrays.asList() ); expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.apache.maven" ) ) .andReturn( Arrays.asList( "maven-model" ) ); @@ -697,14 +697,14 @@ public class RepositoryStatisticsManagerTest .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "jar" ), createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "pom" ) ) ); - expect( metadataRepository.getNamespaces(session , TEST_REPO_ID, "org.codehaus" ) ).andReturn( Arrays.asList( "plexus" ) ); + expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.codehaus" ) ).andReturn( Arrays.asList( "plexus" ) ); expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org" ) ).andReturn( Arrays.asList( ) ); expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.codehaus" ) ) .andReturn( Arrays.asList( ) ); - expect( metadataRepository.getNamespaces(session , TEST_REPO_ID, "org.codehaus.plexus" ) ) + expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.codehaus.plexus" ) ) .andReturn( Arrays.asList( ) ); expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.codehaus.plexus" ) ) -- 2.39.5