diff options
author | Martin Schreier <martin_s@apache.org> | 2022-01-11 23:17:58 +0100 |
---|---|---|
committer | Martin Schreier <martin_s@apache.org> | 2022-01-11 23:17:58 +0100 |
commit | f73e942e0ad2406fd81355855eca344fafd29857 (patch) | |
tree | 509841ed02cc9b6634b282dd9411a748adc46340 /archiva-modules/archiva-maven/archiva-maven-repository | |
parent | 9a102721d6f0e4ef951901427c43f5c0dc936fd7 (diff) | |
download | archiva-f73e942e0ad2406fd81355855eca344fafd29857.tar.gz archiva-f73e942e0ad2406fd81355855eca344fafd29857.zip |
Refactoring of repository feature interface
Diffstat (limited to 'archiva-modules/archiva-maven/archiva-maven-repository')
3 files changed, 31 insertions, 31 deletions
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/maven/repository/MavenRepositoryProvider.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/maven/repository/MavenRepositoryProvider.java index 87a263a03..8319e2704 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/maven/repository/MavenRepositoryProvider.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/maven/repository/MavenRepositoryProvider.java @@ -231,17 +231,17 @@ public class MavenRepositoryProvider implements RepositoryProvider { repo.removeActiveReleaseScheme(ReleaseScheme.SNAPSHOT); } - StagingRepositoryFeature stagingRepositoryFeature = repo.getFeature(StagingRepositoryFeature.class).get(); + StagingRepositoryFeature stagingRepositoryFeature = repo.getFeature( StagingRepositoryFeature.class ); stagingRepositoryFeature.setStageRepoNeeded(cfg.isStageRepoNeeded()); - IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get(); + IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ); indexCreationFeature.setSkipPackedIndexCreation(cfg.isSkipPackedIndexCreation()); String indexDir = StringUtils.isEmpty( cfg.getIndexDir() ) ? DEFAULT_INDEX_PATH : cfg.getIndexDir(); String packedIndexDir = StringUtils.isEmpty( cfg.getPackedIndexDir() ) ? DEFAULT_PACKED_INDEX_PATH : cfg.getPackedIndexDir(); indexCreationFeature.setIndexPath(getURIFromString(indexDir)); indexCreationFeature.setPackedIndexPath(getURIFromString(packedIndexDir)); - ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature(ArtifactCleanupFeature.class).get(); + ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature( ArtifactCleanupFeature.class ); artifactCleanupFeature.setDeleteReleasedSnapshots(cfg.isDeleteReleasedSnapshots()); artifactCleanupFeature.setRetentionCount(cfg.getRetentionCount()); @@ -285,7 +285,7 @@ public class MavenRepositoryProvider implements RepositoryProvider { throw new RepositoryException("The url config is not a valid uri: " + cfg.getUrl()); } repo.setTimeout(Duration.ofSeconds(cfg.getTimeout())); - RemoteIndexFeature remoteIndexFeature = repo.getFeature(RemoteIndexFeature.class).get(); + RemoteIndexFeature remoteIndexFeature = repo.getFeature( RemoteIndexFeature.class ); remoteIndexFeature.setDownloadRemoteIndex(cfg.isDownloadRemoteIndex()); remoteIndexFeature.setDownloadRemoteIndexOnStartup(cfg.isDownloadRemoteIndexOnStartup()); remoteIndexFeature.setDownloadTimeout(Duration.ofSeconds(cfg.getRemoteDownloadTimeout())); @@ -313,7 +313,7 @@ public class MavenRepositoryProvider implements RepositoryProvider { } else { credentials.setPassword(new char[0]); } - IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get(); + IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ); if ( !StringUtils.isEmpty( cfg.getIndexDir( ) ) ) { indexCreationFeature.setIndexPath( getURIFromString( cfg.getIndexDir( ) ) ); @@ -347,7 +347,7 @@ public class MavenRepositoryProvider implements RepositoryProvider { repositoryGroup.setMergedIndexTTL(configuration.getMergedIndexTtl()); repositoryGroup.setSchedulingDefinition(configuration.getCronExpression()); if (repositoryGroup.supportsFeature( IndexCreationFeature.class )) { - IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ); indexCreationFeature.setIndexPath( getURIFromString(configuration.getMergedIndexPath()) ); Path localPath = Paths.get(configuration.getMergedIndexPath()); Path repoGroupPath = repositoryGroup.getRoot().getFilePath().toAbsolutePath(); @@ -395,11 +395,11 @@ public class MavenRepositoryProvider implements RepositoryProvider { cfg.setExtraHeaders(remoteRepository.getExtraHeaders()); cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition()); - IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get(); + IndexCreationFeature indexCreationFeature = remoteRepository.getFeature( IndexCreationFeature.class ); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); - RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get(); + RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature( RemoteIndexFeature.class ); if ( remoteIndexFeature.getIndexUri( ) == null ) { cfg.setRemoteIndexUrl( "" ); @@ -442,14 +442,14 @@ public class MavenRepositoryProvider implements RepositoryProvider { cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition()); cfg.setScanned(managedRepository.isScanned()); cfg.setBlockRedeployments(managedRepository.blocksRedeployments()); - StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get(); + StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature( StagingRepositoryFeature.class ); cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); - IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); + IndexCreationFeature indexCreationFeature = managedRepository.getFeature( IndexCreationFeature.class ); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); - ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); + ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature( ArtifactCleanupFeature.class ); cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount()); cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays()); cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); @@ -470,7 +470,7 @@ public class MavenRepositoryProvider implements RepositoryProvider { cfg.setName(repositoryGroup.getName()); if (repositoryGroup.supportsFeature( IndexCreationFeature.class )) { - IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ); cfg.setMergedIndexPath( indexCreationFeature.getIndexPath().toString() ); } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/MavenRepositoryProviderTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/MavenRepositoryProviderTest.java index 98472de02..002dd7e2a 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/MavenRepositoryProviderTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/MavenRepositoryProviderTest.java @@ -134,18 +134,18 @@ public class MavenRepositoryProviderTest assertTrue(mr.blocksRedeployments()); assertEquals("4 0 0 ? * TUE", mr.getSchedulingDefinition()); assertTrue(mr.isScanned()); - ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature( ArtifactCleanupFeature.class ); assertEquals( Period.ofDays( 37), artifactCleanupFeature.getRetentionPeriod()); assertTrue(artifactCleanupFeature.isDeleteReleasedSnapshots()); assertEquals(33, artifactCleanupFeature.getRetentionCount()); - IndexCreationFeature indexCreationFeature = mr.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature indexCreationFeature = mr.getFeature( IndexCreationFeature.class ); assertNotNull(indexCreationFeature.getIndexPath()); assertEquals("testmanaged/.index", indexCreationFeature.getIndexPath().toString()); assertFalse(indexCreationFeature.getIndexPath().isAbsolute()); assertTrue(indexCreationFeature.isSkipPackedIndexCreation()); - StagingRepositoryFeature stagingRepositoryFeature = mr.getFeature( StagingRepositoryFeature.class ).get(); + StagingRepositoryFeature stagingRepositoryFeature = mr.getFeature( StagingRepositoryFeature.class ); assertTrue(stagingRepositoryFeature.isStageRepoNeeded()); assertNull(stagingRepositoryFeature.getStagingRepository()); @@ -202,22 +202,22 @@ public class MavenRepositoryProviderTest assertEquals( "maven2", mr.getLayout()); try { - ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature( ArtifactCleanupFeature.class ).get( ); + ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature( ArtifactCleanupFeature.class ); throw new Exception("artifactCleanupFeature should not be available"); } catch ( UnsupportedFeatureException e ) { // correct } - IndexCreationFeature indexCreationFeature = mr.getFeature( IndexCreationFeature.class ).get( ); + IndexCreationFeature indexCreationFeature = mr.getFeature( IndexCreationFeature.class ); assertEquals("local/.index", indexCreationFeature.getIndexPath().toString()); try { - StagingRepositoryFeature stagingRepositoryFeature = mr.getFeature( StagingRepositoryFeature.class ).get( ); + StagingRepositoryFeature stagingRepositoryFeature = mr.getFeature( StagingRepositoryFeature.class ); throw new Exception("stagingRepositoryFeature should not be available"); } catch (UnsupportedFeatureException e) { // correct } - RemoteIndexFeature remoteIndexFeature = mr.getFeature( RemoteIndexFeature.class ).get(); + RemoteIndexFeature remoteIndexFeature = mr.getFeature( RemoteIndexFeature.class ); assertNull(remoteIndexFeature.getProxyId()); } @@ -234,12 +234,12 @@ public class MavenRepositoryProviderTest repo.setSchedulingDefinition( "0 0 05 ? * WED" ); repo.addActiveReleaseScheme( ReleaseScheme.RELEASE ); repo.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT ); - StagingRepositoryFeature stagingFeat = repo.getFeature( StagingRepositoryFeature.class ).get( ); + StagingRepositoryFeature stagingFeat = repo.getFeature( StagingRepositoryFeature.class ); stagingFeat.setStageRepoNeeded( true ); - IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ); indexCreationFeature.setIndexPath( new URI("test/.indexes") ); indexCreationFeature.setSkipPackedIndexCreation( true ); - ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature( ArtifactCleanupFeature.class ).get(); + ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature( ArtifactCleanupFeature.class ); artifactCleanupFeature.setRetentionPeriod( Period.ofDays( 5 ) ); artifactCleanupFeature.setRetentionCount( 7 ); artifactCleanupFeature.setDeleteReleasedSnapshots( true ); @@ -276,13 +276,13 @@ public class MavenRepositoryProviderTest repo.setLayout( "maven2" ); repo.setName( repo.getPrimaryLocale(), "test0003" ); repo.setSchedulingDefinition( "0 0 05 ? * WED" ); - RemoteIndexFeature remoteIndexFeature = repo.getFeature( RemoteIndexFeature.class ).get(); + RemoteIndexFeature remoteIndexFeature = repo.getFeature( RemoteIndexFeature.class ); remoteIndexFeature.setProxyId( "proxyabc" ); remoteIndexFeature.setDownloadTimeout( Duration.ofSeconds( 54 ) ); remoteIndexFeature.setDownloadRemoteIndex( false ); remoteIndexFeature.setIndexUri( new URI("/this/remote/.index") ); remoteIndexFeature.setDownloadRemoteIndexOnStartup( true ); - IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ); indexCreationFeature.setIndexPath( new URI("/this/local/.index") ); RemoteRepositoryConfiguration cfg = provider.getRemoteConfiguration( repo ); @@ -310,7 +310,7 @@ public class MavenRepositoryProviderTest repositoryGroup.setDescription(repositoryGroup.getPrimaryLocale(), "Repository group"); repositoryGroup.setLayout("non-default"); - IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ); indexCreationFeature.setIndexPath( new URI(".index2") ); repositoryGroup.setName(repositoryGroup.getPrimaryLocale(), "Repo Group 1"); repositoryGroup.setMergedIndexTTL(1005); @@ -358,7 +358,7 @@ public class MavenRepositoryProviderTest assertEquals("group2", grp.getId()); assertEquals("Group 2", grp.getName()); assertEquals("0 0 03 ? * MON", grp.getSchedulingDefinition()); - IndexCreationFeature indexCreationFeature = grp.getFeature( IndexCreationFeature.class ).get(); + IndexCreationFeature indexCreationFeature = grp.getFeature( IndexCreationFeature.class ); try { assertEquals(new URI(".index-abc"), indexCreationFeature.getIndexPath()); } catch (URISyntaxException e) { diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/mock/ArchivaIndexManagerMock.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/mock/ArchivaIndexManagerMock.java index e10df3148..2591a344a 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/mock/ArchivaIndexManagerMock.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/mock/ArchivaIndexManagerMock.java @@ -251,7 +251,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( ); @@ -277,7 +277,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( ) ); @@ -517,7 +517,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) { @@ -534,7 +534,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(); @@ -587,7 +587,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 |