From f73e942e0ad2406fd81355855eca344fafd29857 Mon Sep 17 00:00:00 2001 From: Martin Schreier Date: Tue, 11 Jan 2022 23:17:58 +0100 Subject: [PATCH] Refactoring of repository feature interface --- .../functors/ConsumerWantsFilePredicate.java | 2 +- .../src/test/java/RepositoryProviderMock.java | 16 +++++------ .../repository/RepositoryPurgeConsumer.java | 2 +- .../repository/RepositoryProviderMock.java | 16 +++++------ .../AbstractRepositoryPurgeTest.java | 2 +- .../DaysOldRepositoryPurgeTest.java | 6 ++-- .../RepositoryPurgeConsumerTest.java | 8 +++--- .../RetentionCountRepositoryPurgeTest.java | 2 +- .../repository/AbstractRepositoryAdmin.java | 2 +- .../group/DefaultRepositoryGroupAdmin.java | 4 +-- .../DefaultManagedRepositoryAdmin.java | 14 +++++----- .../DefaultNetworkProxyAdmin.java | 2 +- .../remote/DefaultRemoteRepositoryAdmin.java | 4 +-- .../admin/mock/ArchivaIndexManagerMock.java | 10 +++---- .../features/ArtifactCleanupFeature.java | 5 ---- .../features/IndexCreationFeature.java | 5 ---- .../features/RemoteIndexFeature.java | 5 ---- .../features/RepositoryFeature.java | 5 ---- .../features/StagingRepositoryFeature.java | 5 ---- .../DefaultMergedRemoteIndexesScheduler.java | 2 +- .../repository/base/AbstractRepository.java | 2 +- .../base/group/RepositoryGroupHandler.java | 2 +- .../managed/ManagedRepositoryHandler.java | 8 +++--- .../mock/RepositoryProviderMock.java | 20 ++++++------- .../maven/indexer/MavenIndexManager.java | 14 +++++----- .../maven/indexer/MavenIndexManagerTest.java | 4 +-- .../search/AbstractMavenRepositorySearch.java | 4 +-- .../repository/RepositoryProviderMock.java | 18 ++++++------ .../repository/MavenRepositoryProvider.java | 24 ++++++++-------- .../MavenRepositoryProviderTest.java | 28 +++++++++---------- .../mock/ArchivaIndexManagerMock.java | 10 +++---- .../indexing/ArchivaIndexingTaskExecutor.java | 2 +- .../DefaultDownloadRemoteIndexScheduler.java | 4 +-- .../indexing/DownloadRemoteIndexTask.java | 2 +- .../ArchivaIndexingTaskExecutorTest.java | 2 +- .../indexing/DownloadRemoteIndexTaskTest.java | 4 +-- .../mock/ArchivaIndexManagerMock.java | 10 +++---- .../api/v2/model/MavenManagedRepository.java | 6 ++-- .../rest/api/v2/model/RepositoryGroup.java | 2 +- .../v2/model/map/MavenRepositoryMapper.java | 4 +-- .../webdav/ArchivaDavResourceFactory.java | 8 +++--- 41 files changed, 135 insertions(+), 160 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java index 6ee08b43d..e8fa5c03a 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java @@ -138,7 +138,7 @@ public class ConsumerWantsFilePredicate String indexDirectory; if ( managedRepository.supportsFeature( IndexCreationFeature.class ) ) { - IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); + IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ); if ( icf.getIndexPath( ) == null ) { indexDirectory = ".index"; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java index a77d0ebc4..e05488b13 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java @@ -127,14 +127,14 @@ public class RepositoryProviderMock implements RepositoryProvider if (configuration.isSnapshots()) { managedRepository.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT ); } - ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); + ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ); acf.setRetentionPeriod( Period.ofDays( configuration.getRetentionPeriod( ) ) ); acf.setDeleteReleasedSnapshots( configuration.isDeleteReleasedSnapshots( ) ); acf.setRetentionCount( configuration.getRetentionCount( ) ); - IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); + IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ); icf.setIndexPath( new URI( configuration.getIndexDir( ) ) ); icf.setSkipPackedIndexCreation( configuration.isSkipPackedIndexCreation( ) ); - StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); + StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ); srf.setStageRepoNeeded( configuration.isStageRepoNeeded( ) ); } catch ( Exception e ) @@ -187,7 +187,7 @@ public class RepositoryProviderMock implements RepositoryProvider char[] pwd = configuration.getPassword()==null ? "".toCharArray() : configuration.getPassword().toCharArray(); remoteRepository.setCredentials( new PasswordCredentials( configuration.getUsername( ), pwd ) ); remoteRepository.setLocation( new URI( configuration.getUrl( )==null ? "" : configuration.getUrl() ) ); - RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); + RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ); rif.setDownloadRemoteIndexOnStartup( configuration.isDownloadRemoteIndexOnStartup( ) ); rif.setDownloadRemoteIndex( configuration.isDownloadRemoteIndex( ) ); rif.setIndexUri( new URI( configuration.getIndexDir( ) ) ); @@ -215,14 +215,14 @@ public class RepositoryProviderMock implements RepositoryProvider configuration.setRefreshCronExpression( managedRepository.getSchedulingDefinition( ) ); configuration.setReleases( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE) ); configuration.setSnapshots( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT) ); - ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); + ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ); configuration.setRetentionPeriod( acf.getRetentionPeriod( ).getDays( ) ); configuration.setDeleteReleasedSnapshots( acf.isDeleteReleasedSnapshots( ) ); configuration.setRetentionCount( acf.getRetentionCount( ) ); - IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); + IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ); configuration.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation( ) ); configuration.setIndexDir( icf.getIndexPath( ) == null ? "" : icf.getIndexPath().toString( ) ); - StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); + StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ); configuration.setStageRepoNeeded( srf.isStageRepoNeeded( ) ); return configuration; } @@ -249,7 +249,7 @@ public class RepositoryProviderMock implements RepositoryProvider configuration.setPassword( new String( pwdCreds.getPassword( ) ) ); } configuration.setUrl( remoteRepository.getLocation( ) == null ? "" : remoteRepository.getLocation().toString( ) ); - RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); + RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ); configuration.setDownloadRemoteIndex( rif.isDownloadRemoteIndex( ) ); configuration.setDownloadRemoteIndexOnStartup( rif.isDownloadRemoteIndexOnStartup( ) ); configuration.setIndexDir( rif.getIndexUri( )==null ? "" : rif.getIndexUri().toString( ) ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java index 86bf774bf..5240c06b7 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java @@ -148,7 +148,7 @@ public class RepositoryPurgeConsumer if (repository.supportsFeature( ArtifactCleanupFeature.class )) { - ArtifactCleanupFeature acf = repository.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature acf = repository.getFeature( ArtifactCleanupFeature.class ); int retentionPeriodInDays = acf.getRetentionPeriod( ).getDays( ); int retentionCount = acf.getRetentionCount(); if ( retentionPeriodInDays != 0 ) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java index 3cb612339..dcff3d367 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java @@ -133,14 +133,14 @@ public class RepositoryProviderMock implements RepositoryProvider if (configuration.isSnapshots()) { managedRepository.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT ); } - ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); + ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ); acf.setRetentionPeriod( Period.ofDays( configuration.getRetentionPeriod( ) ) ); acf.setDeleteReleasedSnapshots( configuration.isDeleteReleasedSnapshots( ) ); acf.setRetentionCount( configuration.getRetentionCount( ) ); - IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); + IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ); icf.setIndexPath( new URI( configuration.getIndexDir( ) ) ); icf.setSkipPackedIndexCreation( configuration.isSkipPackedIndexCreation( ) ); - StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); + StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ); srf.setStageRepoNeeded( configuration.isStageRepoNeeded( ) ); } catch ( Exception e ) @@ -196,7 +196,7 @@ public class RepositoryProviderMock implements RepositoryProvider char[] pwd = configuration.getPassword()==null ? "".toCharArray() : configuration.getPassword().toCharArray(); remoteRepository.setCredentials( new PasswordCredentials( configuration.getUsername( ), pwd ) ); remoteRepository.setLocation( new URI( configuration.getUrl( )==null ? "" : configuration.getUrl() ) ); - RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); + RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ); rif.setDownloadRemoteIndexOnStartup( configuration.isDownloadRemoteIndexOnStartup( ) ); rif.setDownloadRemoteIndex( configuration.isDownloadRemoteIndex( ) ); rif.setIndexUri( new URI( configuration.getIndexDir( ) ) ); @@ -236,14 +236,14 @@ public class RepositoryProviderMock implements RepositoryProvider configuration.setReleases( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE) ); configuration.setSnapshots( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT) ); configuration.setLayout( managedRepository.getLayout() ); - ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); + ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ); configuration.setRetentionPeriod( acf.getRetentionPeriod( ).getDays( ) ); configuration.setDeleteReleasedSnapshots( acf.isDeleteReleasedSnapshots( ) ); configuration.setRetentionCount( acf.getRetentionCount( ) ); - IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); + IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ); configuration.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation( ) ); configuration.setIndexDir( icf.getIndexPath( ) == null ? "" : icf.getIndexPath().toString( ) ); - StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); + StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ); configuration.setStageRepoNeeded( srf.isStageRepoNeeded( ) ); return configuration; } @@ -282,7 +282,7 @@ public class RepositoryProviderMock implements RepositoryProvider configuration.setPassword( new String( pwdCreds.getPassword( ) ) ); } configuration.setUrl( remoteRepository.getLocation( ) == null ? "" : remoteRepository.getLocation().toString( ) ); - RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); + RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ); configuration.setDownloadRemoteIndex( rif.isDownloadRemoteIndex( ) ); configuration.setDownloadRemoteIndexOnStartup( rif.isDownloadRemoteIndexOnStartup( ) ); configuration.setIndexDir( rif.getIndexUri( )==null ? "" : rif.getIndexUri().toString( ) ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java index 9dd1d7639..d87fe01e9 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java @@ -152,7 +152,7 @@ public abstract class AbstractRepositoryPurgeTest config = BasicManagedRepository.newFilesystemInstance( repoId, repoName, basePath.resolve(repoId)); config.addActiveReleaseScheme( ReleaseScheme.RELEASE ); config.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT ); - ArtifactCleanupFeature atf = config.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature atf = config.getFeature( ArtifactCleanupFeature.class ); atf.setRetentionPeriod( Period.ofDays( TEST_DAYS_OLDER) ); String path = AbstractRepositoryPurgeTest.fixPath( basePath.resolve( repoId ).toAbsolutePath().toString() ); 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 62a894f0c..4b473f14a 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 @@ -69,7 +69,7 @@ public class DaysOldRepositoryPurgeTest throws Exception { org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); - ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ); when( sessionFactory.createSession( ) ).thenReturn( repositorySession ); @@ -163,7 +163,7 @@ public class DaysOldRepositoryPurgeTest throws Exception { org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); - ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ); List listeners = Collections.singletonList( listener ); when( sessionFactory.createSession( ) ).thenReturn( repositorySession ); @@ -242,7 +242,7 @@ public class DaysOldRepositoryPurgeTest throws Exception { org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); - ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ); List listeners = Collections.singletonList( listener ); when( sessionFactory.createSession( ) ).thenReturn( repositorySession ); 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 ba5568ad3..2f8288fda 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 @@ -166,7 +166,7 @@ public class RepositoryPurgeConsumerTest RepositoryPurgeConsumer.class ); repoPurgeConsumer.setRepositorySessionFactory( sessionFactory ); org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); - ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ); atf.setRetentionPeriod( Period.ofDays( 0 ) ); // force days older off to allow retention count purge to execute. atf.setRetentionCount( TEST_RETENTION_COUNT ); addRepoToConfiguration( "retention-count", repoConfiguration ); @@ -277,7 +277,7 @@ public class RepositoryPurgeConsumerTest repoPurgeConsumer.setRepositorySessionFactory( sessionFactory ); org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); - ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ); atf.setRetentionPeriod( Period.ofDays( TEST_DAYS_OLDER ) ); addRepoToConfiguration( "days-old", repoConfiguration ); @@ -366,7 +366,7 @@ public class RepositoryPurgeConsumerTest KnownRepositoryContentConsumer.class ); org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); - ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ); acf.setDeleteReleasedSnapshots( false ); // Set to NOT delete released snapshots. addRepoToConfiguration( "retention-count", repoConfiguration ); @@ -425,7 +425,7 @@ public class RepositoryPurgeConsumerTest RepositoryPurgeConsumer.class ); repoPurgeConsumer.setRepositorySessionFactory( sessionFactory ); org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); - ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ); acf.setDeleteReleasedSnapshots( true ); addRepoToConfiguration( "days-old", repoConfiguration ); 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 1081380d9..0483b5204 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 @@ -53,7 +53,7 @@ public class RetentionCountRepositoryPurgeTest org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); List listeners = Collections.singletonList( listener ); - ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ); Mockito.when( sessionFactory.createSession( ) ).thenReturn( repositorySession ); Mockito.when( repositorySession.getRepository()).thenReturn( metadataRepository ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java index d2cbb499a..cfaa585f4 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java @@ -123,7 +123,7 @@ public abstract class AbstractRepositoryAdmin adminRepo.setDescription( repo.getDescription() ); adminRepo.setType(repo.getType()==null?"MAVEN": repo.getType().name()); if (repo.supportsFeature( IndexCreationFeature.class )) { - IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ); adminRepo.setIndexDirectory( convertUriToString( icf.getIndexPath() ) ); adminRepo.setPackedIndexDirectory(convertUriToString(icf.getPackedIndexPath())); } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java index f30c849a6..bafaafb10 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java @@ -88,7 +88,7 @@ public class DefaultRepositoryGroupAdmin { org.apache.archiva.repository.RepositoryGroup group = repositoryRegistry.getRepositoryGroup(repositoryGroupId); if (group!=null) { - return group.getFeature(IndexCreationFeature.class).get().getLocalIndexPath(); + return group.getFeature( IndexCreationFeature.class ).getLocalIndexPath(); } else { return null; } @@ -397,7 +397,7 @@ public class DefaultRepositoryGroupAdmin RepositoryGroup rg = new RepositoryGroup( group.getId( ), group.getRepositories().stream().map(r -> r.getId()).collect( Collectors.toList()) ); if (group.supportsFeature( IndexCreationFeature.class )) { - IndexCreationFeature indexCreationFeature = group.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature indexCreationFeature = group.getFeature( IndexCreationFeature.class ); rg.setMergedIndexPath( indexCreationFeature.getIndexPath().getPath() ); } rg.setCronExpression( group.getSchedulingDefinition() ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index 5b6dae25b..99ed422f3 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -150,19 +150,19 @@ public class DefaultManagedRepositoryAdmin adminRepo.setBlockRedeployments( repo.blocksRedeployments() ); adminRepo.setCronExpression( repo.getSchedulingDefinition() ); if (repo.supportsFeature( IndexCreationFeature.class )) { - IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ); adminRepo.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation() ); } adminRepo.setScanned( repo.isScanned() ); if (repo.supportsFeature( ArtifactCleanupFeature.class) ) { - ArtifactCleanupFeature acf = repo.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature acf = repo.getFeature( ArtifactCleanupFeature.class ); adminRepo.setRetentionPeriod( acf.getRetentionPeriod().getDays() ); adminRepo.setRetentionCount( acf.getRetentionCount() ); adminRepo.setDeleteReleasedSnapshots( acf.isDeleteReleasedSnapshots() ); } if (repo.supportsFeature( StagingRepositoryFeature.class )) { - StagingRepositoryFeature stf = repo.getFeature( StagingRepositoryFeature.class ).get(); + StagingRepositoryFeature stf = repo.getFeature( StagingRepositoryFeature.class ); adminRepo.setStageRepoNeeded( stf.isStageRepoNeeded() ); if (stf.getStagingRepository()!=null) { adminRepo.setStagingRepository( convertRepo( stf.getStagingRepository() ) ); @@ -240,7 +240,7 @@ public class DefaultManagedRepositoryAdmin scanRepository( newRepo.getId(), true ); } - org.apache.archiva.repository.ManagedRepository stagingRepo = newRepo.getFeature( StagingRepositoryFeature.class ).get( ).getStagingRepository( ); + org.apache.archiva.repository.ManagedRepository stagingRepo = newRepo.getFeature( StagingRepositoryFeature.class ).getStagingRepository( ); if ( stagingRepo!=null) { if (stagingRepo.isScanned()) { @@ -285,7 +285,7 @@ public class DefaultManagedRepositoryAdmin org.apache.archiva.repository.ManagedRepository stagingRepository = null; if (repo != null) { if (repo.supportsFeature(StagingRepositoryFeature.class)) { - stagingRepository = repo.getFeature(StagingRepositoryFeature.class).get().getStagingRepository(); + stagingRepository = repo.getFeature( StagingRepositoryFeature.class ).getStagingRepository(); } } else { throw new RepositoryAdminException("A repository with that id does not exist"); @@ -427,7 +427,7 @@ public class DefaultManagedRepositoryAdmin org.apache.archiva.repository.ManagedRepository oldRepo = repositoryRegistry.getManagedRepository( managedRepository.getId( ) ); boolean stagingExists = false; if (oldRepo.supportsFeature( StagingRepositoryFeature.class ) ){ - stagingExists = oldRepo.getFeature( StagingRepositoryFeature.class ).get().getStagingRepository() != null; + stagingExists = oldRepo.getFeature( StagingRepositoryFeature.class ).getStagingRepository() != null; } boolean updateIndexContext = !StringUtils.equals( updatedRepoConfig.getIndexDir(), managedRepository.getIndexDirectory() ); org.apache.archiva.repository.ManagedRepository newRepo; @@ -436,7 +436,7 @@ public class DefaultManagedRepositoryAdmin { newRepo = repositoryRegistry.putRepository( updatedRepoConfig ); if (newRepo.supportsFeature( StagingRepositoryFeature.class )) { - org.apache.archiva.repository.ManagedRepository stagingRepo = newRepo.getFeature( StagingRepositoryFeature.class ).get( ).getStagingRepository( ); + org.apache.archiva.repository.ManagedRepository stagingRepo = newRepo.getFeature( StagingRepositoryFeature.class ).getStagingRepository( ); if (stagingRepo!=null && !stagingExists) { triggerAuditEvent( stagingRepo.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java index 7fd43ec3c..f72285a23 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java @@ -135,7 +135,7 @@ public class DefaultNetworkProxyAdmin } for ( RemoteRepository repo : repositoryRegistry.getRemoteRepositories()) { if (repo.supportsFeature( RemoteIndexFeature.class )) { - RemoteIndexFeature rif = repo.getFeature( RemoteIndexFeature.class ).get(); + RemoteIndexFeature rif = repo.getFeature( RemoteIndexFeature.class ); if (networkProxyId.equals(rif.getProxyId())) { rif.setProxyId( null ); try diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java index 427f52e27..f089e9de8 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java @@ -89,7 +89,7 @@ public class DefaultRemoteRepositoryAdmin } if ( repo.supportsFeature( RemoteIndexFeature.class ) ) { - RemoteIndexFeature rif = repo.getFeature( RemoteIndexFeature.class ).get( ); + RemoteIndexFeature rif = repo.getFeature( RemoteIndexFeature.class ); adminRepo.setRemoteIndexUrl( convertUriToString( rif.getIndexUri( ) ) ); adminRepo.setDownloadRemoteIndex( rif.isDownloadRemoteIndex( ) ); adminRepo.setRemoteDownloadNetworkProxyId( rif.getProxyId( ) ); @@ -98,7 +98,7 @@ public class DefaultRemoteRepositoryAdmin } if ( repo.supportsFeature( IndexCreationFeature.class ) ) { - IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get( ); + IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ); adminRepo.setIndexDirectory( PathUtil.getPathFromUri( icf.getIndexPath( ) ).toString( ) ); } adminRepo.setDescription( repo.getDescription( ) ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/ArchivaIndexManagerMock.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/ArchivaIndexManagerMock.java index 0557fdb7b..def27d1aa 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/ArchivaIndexManagerMock.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/ArchivaIndexManagerMock.java @@ -249,7 +249,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { { throw new IndexUpdateFailedException( "The context is not associated to a remote repository with remote index " + context.getId( ) ); } else { - RemoteIndexFeature rif = context.getRepository().getFeature(RemoteIndexFeature.class).get(); + RemoteIndexFeature rif = context.getRepository().getFeature( RemoteIndexFeature.class ); remoteUpdateUri = context.getRepository().getLocation().resolve(rif.getIndexUri()); } final RemoteRepository remoteRepository = (RemoteRepository) context.getRepository( ); @@ -275,7 +275,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { NetworkProxy networkProxy = null; if ( remoteRepository.supportsFeature( RemoteIndexFeature.class ) ) { - RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); + RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ); if ( StringUtils.isNotBlank( rif.getProxyId( ) ) ) { networkProxy = proxyRegistry.getNetworkProxy( rif.getProxyId( ) ); @@ -506,7 +506,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { @Override public void updateLocalIndexPath(Repository repo) { if (repo.supportsFeature(IndexCreationFeature.class)) { - IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get(); + IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ); try { icf.setLocalIndexPath(getIndexPath(repo)); } catch (IOException e) { @@ -521,7 +521,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { } private StorageAsset getIndexPath( Repository repo) throws IOException { - IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get(); + IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ); Path repoDir = repo.getRoot().getFilePath(); URI indexDir = icf.getIndexPath(); String indexPath = indexDir.getPath(); @@ -574,7 +574,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { // is there configured indexDirectory ? if ( remoteRepository.supportsFeature( RemoteIndexFeature.class ) ) { - RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); + RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ); indexDirectory = getIndexPath(remoteRepository); String remoteIndexUrl = calculateIndexRemoteUrl( remoteRepository.getLocation( ), rif ); try diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/ArtifactCleanupFeature.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/ArtifactCleanupFeature.java index 57c683043..812d73b80 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/ArtifactCleanupFeature.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/ArtifactCleanupFeature.java @@ -43,11 +43,6 @@ public class ArtifactCleanupFeature implements RepositoryFeature private String proxyId = ""; - @Override - public RemoteIndexFeature get() { - return this; - } - /** * True, if the remote index should be downloaded. * @return True if download, otherwise false. diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java index 813d39d5c..82cc4cfca 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java @@ -69,9 +69,4 @@ public interface RepositoryFeature> { return this.getClass().equals(clazz); } - /** - * Returns the concrete feature instance. - * @return the feature instance. - */ - T get(); } diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/StagingRepositoryFeature.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/StagingRepositoryFeature.java index 3e4ba1257..f919ebeb1 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/StagingRepositoryFeature.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/StagingRepositoryFeature.java @@ -42,11 +42,6 @@ public class StagingRepositoryFeature implements RepositoryFeature