Browse Source

Refactoring of repository feature interface

pull/62/head
Martin Schreier 2 years ago
parent
commit
f73e942e0a
41 changed files with 135 additions and 160 deletions
  1. 1
    1
      archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java
  2. 8
    8
      archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java
  3. 1
    1
      archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
  4. 8
    8
      archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java
  5. 1
    1
      archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
  6. 3
    3
      archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
  7. 4
    4
      archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
  8. 1
    1
      archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java
  9. 1
    1
      archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java
  10. 2
    2
      archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java
  11. 7
    7
      archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
  12. 1
    1
      archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java
  13. 2
    2
      archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
  14. 5
    5
      archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/ArchivaIndexManagerMock.java
  15. 0
    5
      archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/ArtifactCleanupFeature.java
  16. 0
    5
      archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationFeature.java
  17. 0
    5
      archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RemoteIndexFeature.java
  18. 0
    5
      archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java
  19. 0
    5
      archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/StagingRepositoryFeature.java
  20. 1
    1
      archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/base/DefaultMergedRemoteIndexesScheduler.java
  21. 1
    1
      archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/AbstractRepository.java
  22. 1
    1
      archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/group/RepositoryGroupHandler.java
  23. 4
    4
      archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/managed/ManagedRepositoryHandler.java
  24. 10
    10
      archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
  25. 7
    7
      archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/maven/indexer/MavenIndexManager.java
  26. 2
    2
      archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/maven/indexer/MavenIndexManagerTest.java
  27. 2
    2
      archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/maven/indexer/search/AbstractMavenRepositorySearch.java
  28. 9
    9
      archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/maven/proxy/mock/repository/RepositoryProviderMock.java
  29. 12
    12
      archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/maven/repository/MavenRepositoryProvider.java
  30. 14
    14
      archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/MavenRepositoryProviderTest.java
  31. 5
    5
      archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/mock/ArchivaIndexManagerMock.java
  32. 1
    1
      archiva-modules/archiva-maven/archiva-maven-scheduler/src/main/java/org/apache/archiva/maven/scheduler/indexing/ArchivaIndexingTaskExecutor.java
  33. 2
    2
      archiva-modules/archiva-maven/archiva-maven-scheduler/src/main/java/org/apache/archiva/maven/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java
  34. 1
    1
      archiva-modules/archiva-maven/archiva-maven-scheduler/src/main/java/org/apache/archiva/maven/scheduler/indexing/DownloadRemoteIndexTask.java
  35. 1
    1
      archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/maven/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
  36. 2
    2
      archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/maven/scheduler/indexing/DownloadRemoteIndexTaskTest.java
  37. 5
    5
      archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/mock/ArchivaIndexManagerMock.java
  38. 3
    3
      archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/v2/model/MavenManagedRepository.java
  39. 1
    1
      archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/v2/model/RepositoryGroup.java
  40. 2
    2
      archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/v2/model/map/MavenRepositoryMapper.java
  41. 4
    4
      archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java

+ 1
- 1
archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java View File

@@ -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";

+ 8
- 8
archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java View File

@@ -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( ) );

+ 1
- 1
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java View File

@@ -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 )

+ 8
- 8
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java View File

@@ -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( ) );

+ 1
- 1
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java View File

@@ -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() );

+ 3
- 3
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java View File

@@ -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<RepositoryListener> 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<RepositoryListener> listeners = Collections.singletonList( listener );

when( sessionFactory.createSession( ) ).thenReturn( repositorySession );

+ 4
- 4
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java View File

@@ -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 );


+ 1
- 1
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java View File

@@ -53,7 +53,7 @@ public class RetentionCountRepositoryPurgeTest

org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
List<RepositoryListener> 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 );

+ 1
- 1
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java View File

@@ -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()));
}

+ 2
- 2
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java View File

@@ -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() );

+ 7
- 7
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java View File

@@ -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 );

+ 1
- 1
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java View File

@@ -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

+ 2
- 2
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java View File

@@ -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( ) );

+ 5
- 5
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/ArchivaIndexManagerMock.java View File

@@ -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

+ 0
- 5
archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/ArtifactCleanupFeature.java View File

@@ -43,11 +43,6 @@ public class ArtifactCleanupFeature implements RepositoryFeature<ArtifactCleanup
this.retentionCount = retentionCount;
}

@Override
public ArtifactCleanupFeature get() {
return this;
}

/**
* Returns true, if snapshot artifacts should be deleted, when artifacts with release version
* exist in one of the managed repositories.

+ 0
- 5
archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/IndexCreationFeature.java View File

@@ -85,11 +85,6 @@ public class IndexCreationFeature extends AbstractFeature implements RepositoryF
}
}

@Override
public IndexCreationFeature get() {
return this;
}

/**
* Returns true, if no packed index files should be created.
* @return True, if no packed index files are created, otherwise false.

+ 0
- 5
archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RemoteIndexFeature.java View File

@@ -47,11 +47,6 @@ public class RemoteIndexFeature implements RepositoryFeature<RemoteIndexFeature>
private String proxyId = "";


@Override
public RemoteIndexFeature get() {
return this;
}

/**
* True, if the remote index should be downloaded.
* @return True if download, otherwise false.

+ 0
- 5
archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java View File

@@ -69,9 +69,4 @@ public interface RepositoryFeature<T extends RepositoryFeature<T>> {
return this.getClass().equals(clazz);
}

/**
* Returns the concrete feature instance.
* @return the feature instance.
*/
T get();
}

+ 0
- 5
archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/StagingRepositoryFeature.java View File

@@ -42,11 +42,6 @@ public class StagingRepositoryFeature implements RepositoryFeature<StagingReposi
this.stageRepoNeeded = stageRepoNeeded;
}

@Override
public StagingRepositoryFeature get() {
return this;
}

/**
* Returns the staging repository, if it exists.
*

+ 1
- 1
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/base/DefaultMergedRemoteIndexesScheduler.java View File

@@ -76,7 +76,7 @@ public class DefaultMergedRemoteIndexesScheduler
if (repositoryGroup.supportsFeature( IndexCreationFeature.class ))
{

IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class );
Path indexPath = indexCreationFeature.getLocalIndexPath().getFilePath();
if (indexPath!=null)
{

+ 1
- 1
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/AbstractRepository.java View File

@@ -319,7 +319,7 @@ public abstract class AbstractRepository implements EditableRepository, EventHan

}
if (supportsFeature(StagingRepositoryFeature.class)) {
StagingRepositoryFeature sf = getFeature(StagingRepositoryFeature.class).get();
StagingRepositoryFeature sf = getFeature( StagingRepositoryFeature.class );
if (sf.getStagingRepository() != null) {
sf.getStagingRepository().close();
}

+ 1
- 1
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/group/RepositoryGroupHandler.java View File

@@ -179,7 +179,7 @@ public class RepositoryGroupHandler
{
if ( group != null )
{
return group.getFeature( IndexCreationFeature.class ).get( ).getLocalIndexPath( );
return group.getFeature( IndexCreationFeature.class ).getLocalIndexPath( );
}
else
{

+ 4
- 4
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/managed/ManagedRepositoryHandler.java View File

@@ -136,7 +136,7 @@ public class ManagedRepositoryHandler
result.put( repo.getId( ), repo );
if ( repo.supportsFeature( StagingRepositoryFeature.class ) )
{
StagingRepositoryFeature stagF = repo.getFeature( StagingRepositoryFeature.class ).get( );
StagingRepositoryFeature stagF = repo.getFeature( StagingRepositoryFeature.class );
if ( stagF.getStagingRepository( ) != null )
{
ManagedRepository stagingRepo = getStagingRepository( repo );
@@ -191,7 +191,7 @@ public class ManagedRepositoryHandler
result.put( id, repo );
if ( repo.supportsFeature( StagingRepositoryFeature.class ) )
{
StagingRepositoryFeature stagF = repo.getFeature( StagingRepositoryFeature.class ).get( );
StagingRepositoryFeature stagF = repo.getFeature( StagingRepositoryFeature.class );
if ( stagF.getStagingRepository( ) != null )
{
String stagingId = getStagingId( id );
@@ -272,7 +272,7 @@ public class ManagedRepositoryHandler
stageRepo = provider.createStagingInstance( cfg );
if ( stageRepo.supportsFeature( StagingRepositoryFeature.class ) )
{
stageRepo.getFeature( StagingRepositoryFeature.class ).get( ).setStageRepoNeeded( false );
stageRepo.getFeature( StagingRepositoryFeature.class ).setStageRepoNeeded( false );
}
updateReferences( stageRepo, cfg );
}
@@ -509,7 +509,7 @@ public class ManagedRepositoryHandler
{
Configuration configuration = getConfigurationHandler( ).getBaseConfiguration( );
RepositoryProvider provider = getProvider( repo.getType( ) );
StagingRepositoryFeature feature = repo.getFeature( StagingRepositoryFeature.class ).get( );
StagingRepositoryFeature feature = repo.getFeature( StagingRepositoryFeature.class );
if ( feature.isStageRepoNeeded( ) && feature.getStagingRepository( ) == null )
{
ManagedRepository stageRepo = get( getStagingId( repo.getId( ) ) );

+ 10
- 10
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java View File

@@ -126,14 +126,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 )
@@ -154,7 +154,7 @@ public class RepositoryProviderMock implements RepositoryProvider
throw new RepositoryException(e);
}
updateManagedInstance( managedRepository, configuration );
managedRepository.getFeature(StagingRepositoryFeature.class).get().setStageRepoNeeded(false);
managedRepository.getFeature( StagingRepositoryFeature.class ).setStageRepoNeeded(false);
return managedRepository;
}

@@ -189,7 +189,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( ) ) );
@@ -235,14 +235,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;
}
@@ -254,7 +254,7 @@ public class RepositoryProviderMock 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() );
}
@@ -292,7 +292,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( ) );

+ 7
- 7
archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/maven/indexer/MavenIndexManager.java View File

@@ -272,7 +272,7 @@ public class MavenIndexManager 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( );
@@ -298,7 +298,7 @@ public class MavenIndexManager 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( ) );
@@ -535,7 +535,7 @@ public class MavenIndexManager 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));
icf.setLocalPackedIndexPath(getPackedIndexPath(repo));
@@ -559,7 +559,7 @@ public class MavenIndexManager implements ArchivaIndexManager {
log.error("Could not create temporary directory for merged index: {}", e.getMessage(), e);
throw new IndexCreationFailedException("IO error while creating temporary directory for merged index: "+e.getMessage(), e);
}
IndexCreationFeature indexCreationFeature = destinationRepo.getFeature(IndexCreationFeature.class).get();
IndexCreationFeature indexCreationFeature = destinationRepo.getFeature( IndexCreationFeature.class );
if (indexCreationFeature.getLocalIndexPath()== null) {
throw new IllegalArgumentException("The given repository does not have a local index path");
}
@@ -643,12 +643,12 @@ public class MavenIndexManager implements ArchivaIndexManager {
}

private StorageAsset getIndexPath( Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class );
return getIndexPath( icf.getIndexPath(), repo, DEFAULT_INDEX_PATH);
}

private StorageAsset getPackedIndexPath(Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class );
return getIndexPath(icf.getPackedIndexPath(), repo, DEFAULT_PACKED_INDEX_PATH);
}

@@ -669,7 +669,7 @@ public class MavenIndexManager 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

+ 2
- 2
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/maven/indexer/MavenIndexManagerTest.java View File

@@ -205,7 +205,7 @@ public class MavenIndexManagerTest {
}
repository = MavenManagedRepository.newLocalInstance("test-repo", "Test Repo", Paths.get("target/repositories"));
// repository.setLocation(new URI("test-repo"));
IndexCreationFeature icf = repository.getFeature(IndexCreationFeature.class).get();
IndexCreationFeature icf = repository.getFeature( IndexCreationFeature.class );
icf.setIndexPath(new URI(indexPathName));
ctx = mavenIndexManager.createContext(repository);
return ctx;
@@ -216,7 +216,7 @@ public class MavenIndexManagerTest {
Path repoPath = Paths.get("target/repositories").toAbsolutePath();
repositoryRemote = MavenRemoteRepository.newLocalInstance("test-repo", "Test Repo", repoPath);
repositoryRemote.setLocation(repoPath.resolve("test-repo").toUri());
RemoteIndexFeature icf = repositoryRemote.getFeature(RemoteIndexFeature.class).get();
RemoteIndexFeature icf = repositoryRemote.getFeature( RemoteIndexFeature.class );
icf.setIndexUri(new URI(indexPath.getFileName().toString()));
ctx = mavenIndexManager.createContext(repositoryRemote);
return ctx;

+ 2
- 2
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/maven/indexer/search/AbstractMavenRepositorySearch.java View File

@@ -207,7 +207,7 @@ public abstract class AbstractMavenRepositorySearch
throws Exception
{
final Repository rRepo = repositoryRegistry.getRepository(repository);
IndexCreationFeature icf = rRepo.getFeature(IndexCreationFeature.class).get();
IndexCreationFeature icf = rRepo.getFeature( IndexCreationFeature.class );


ArchivaIndexingContext archivaCtx = rRepo.getIndexingContext();
@@ -269,7 +269,7 @@ public abstract class AbstractMavenRepositorySearch
repositoryRegistry.reload();

Repository rRepo2 = repositoryRegistry.getRepository( repository );
icf = rRepo2.getFeature(IndexCreationFeature.class).get();
icf = rRepo2.getFeature( IndexCreationFeature.class );


archivaCtx = rRepo2.getIndexingContext();

+ 9
- 9
archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/maven/proxy/mock/repository/RepositoryProviderMock.java View File

@@ -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 )
@@ -190,13 +190,13 @@ 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( ) ) );
rif.setDownloadTimeout( Duration.ofSeconds( configuration.getRemoteDownloadTimeout( ) ) );
rif.setProxyId( configuration.getRemoteDownloadNetworkProxyId( ) );
IndexCreationFeature icf = remoteRepository.getFeature(IndexCreationFeature.class).get();
IndexCreationFeature icf = remoteRepository.getFeature( IndexCreationFeature.class );
icf.setIndexPath(new URI(".index" ));
}
catch ( Exception e )
@@ -232,14 +232,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;
}
@@ -278,7 +278,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( ) );

+ 12
- 12
archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/maven/repository/MavenRepositoryProvider.java View File

@@ -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() );
}

+ 14
- 14
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/MavenRepositoryProviderTest.java View File

@@ -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) {

+ 5
- 5
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/maven/repository/mock/ArchivaIndexManagerMock.java View File

@@ -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

+ 1
- 1
archiva-modules/archiva-maven/archiva-maven-scheduler/src/main/java/org/apache/archiva/maven/scheduler/indexing/ArchivaIndexingTaskExecutor.java View File

@@ -259,7 +259,7 @@ public class ArchivaIndexingTaskExecutor

if ( repository.supportsFeature( IndexCreationFeature.class ) )
{
IndexCreationFeature icf = repository.getFeature( IndexCreationFeature.class ).get( );
IndexCreationFeature icf = repository.getFeature( IndexCreationFeature.class );
if ( !icf.isSkipPackedIndexCreation( ) && icf.getLocalPackedIndexPath( ) != null && icf.getLocalIndexPath().getFilePath()!=null )
{


+ 2
- 2
archiva-modules/archiva-maven/archiva-maven-scheduler/src/main/java/org/apache/archiva/maven/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java View File

@@ -96,7 +96,7 @@ public class DefaultDownloadRemoteIndexScheduler
{
continue;
}
RemoteIndexFeature rif = remoteRepository.getFeature(RemoteIndexFeature.class).get();
RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class );


// TODO record jobs from configuration
@@ -133,7 +133,7 @@ public class DefaultDownloadRemoteIndexScheduler
log.warn("ignore scheduleDownloadRemote for repo with id {}. Does not support remote index.", repositoryId);
return;
}
RemoteIndexFeature rif = remoteRepo.getFeature(RemoteIndexFeature.class).get();
RemoteIndexFeature rif = remoteRepo.getFeature( RemoteIndexFeature.class );
NetworkProxy networkProxy = null;
if ( StringUtils.isNotBlank( rif.getProxyId() ) )
{

+ 1
- 1
archiva-modules/archiva-maven/archiva-maven-scheduler/src/main/java/org/apache/archiva/maven/scheduler/indexing/DownloadRemoteIndexTask.java View File

@@ -121,7 +121,7 @@ public class DownloadRemoteIndexTask
if (!this.remoteRepository.supportsFeature(RemoteIndexFeature.class)) {
throw new RepositoryException("Repository does not support RemotIndexFeature "+remoteRepository.getId());
}
RemoteIndexFeature rif = this.remoteRepository.getFeature(RemoteIndexFeature.class).get();
RemoteIndexFeature rif = this.remoteRepository.getFeature( RemoteIndexFeature.class );
IndexingContext indexingContext = this.remoteRepository.getIndexingContext().getBaseContext(IndexingContext.class);
// create a temp directory to download files
tempIndexDirectory = Paths.get(indexingContext.getIndexDirectoryFile().getParent(), ".tmpIndex" );

+ 1
- 1
archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/maven/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java View File

@@ -279,7 +279,7 @@ public class ArchivaIndexingTaskExecutorTest
{

Path basePath = repo.getRoot().getFilePath();
IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get();
IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class );
StorageAsset packedIndexDirectory = icf.getLocalPackedIndexPath();
StorageAsset indexerDirectory = icf.getLocalIndexPath();


+ 2
- 2
archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/maven/scheduler/indexing/DownloadRemoteIndexTaskTest.java View File

@@ -189,12 +189,12 @@ public class DownloadRemoteIndexTaskTest
Files.createDirectories( indexDirectory );
remoteRepository.setLocation( new URI( "http://localhost:" + port ) );
repoDirectory.toFile().deleteOnExit();
RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get();
RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class );
rif.setDownloadRemoteIndex( true );
rif.setIndexUri( new URI("http://localhost:" + port + "/index-updates/" ) );
createIndexingContext( remoteRepository );

// IndexCreationFeature icf = remoteRepository.getFeature( IndexCreationFeature.class ).get( );
// IndexCreationFeature icf = remoteRepository.getFeature( IndexCreationFeature.class );
// icf.setLocalIndexPath( remoteRepository.getAsset( "index" ) );
return remoteRepository;
}

+ 5
- 5
archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/mock/ArchivaIndexManagerMock.java View File

@@ -246,7 +246,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( );
@@ -272,7 +272,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 );

final StreamWagon wagon = (StreamWagon) wagonFactory.getWagon(
new WagonFactoryRequest( wagonProtocol, remoteRepository.getExtraHeaders( ) ).networkProxy(
@@ -493,7 +493,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) {
@@ -508,7 +508,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();
@@ -561,7 +561,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

+ 3
- 3
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/v2/model/MavenManagedRepository.java View File

@@ -84,16 +84,16 @@ public class MavenManagedRepository extends Repository
repo.setName( beanRepo.getName());
repo.setScanned( beanRepo.isScanned() );
repo.setSchedulingDefinition( beanRepo.getSchedulingDefinition() );
ArtifactCleanupFeature artifactCleanupFeature = beanRepo.getFeature( ArtifactCleanupFeature.class ).get( );
ArtifactCleanupFeature artifactCleanupFeature = beanRepo.getFeature( ArtifactCleanupFeature.class );
repo.setDeleteSnapshotsOfRelease( artifactCleanupFeature.isDeleteReleasedSnapshots());
repo.setRetentionCount( artifactCleanupFeature.getRetentionCount());
repo.setRetentionPeriod( artifactCleanupFeature.getRetentionPeriod() );
IndexCreationFeature icf = beanRepo.getFeature( IndexCreationFeature.class ).get( );
IndexCreationFeature icf = beanRepo.getFeature( IndexCreationFeature.class );
repo.setIndex( icf.hasIndex( ) );
repo.setIndexPath( icf.getIndexPath( ).getPath( ) );
repo.setPackedIndexPath( icf.getPackedIndexPath( ).getPath( ) );
repo.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation() );
StagingRepositoryFeature srf = beanRepo.getFeature( StagingRepositoryFeature.class ).get( );
StagingRepositoryFeature srf = beanRepo.getFeature( StagingRepositoryFeature.class );
repo.setHasStagingRepository( srf.isStageRepoNeeded( ) );
repo.setStagingRepository( srf.getStagingRepository()!=null?srf.getStagingRepository().getId():"" );
}

+ 1
- 1
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/v2/model/RepositoryGroup.java View File

@@ -75,7 +75,7 @@ public class RepositoryGroup implements Serializable, RestModel
result.setLocation( modelObj.getLocation().toString() );
result.setRepositories( modelObj.getRepositories().stream().map( Repository::getId ).collect( Collectors.toList()) );
if (modelObj.supportsFeature( IndexCreationFeature.class )) {
IndexCreationFeature icf = modelObj.getFeature( IndexCreationFeature.class ).get();
IndexCreationFeature icf = modelObj.getFeature( IndexCreationFeature.class );
mergeConfig.setMergedIndexPath( icf.getIndexPath( ).toString() );
mergeConfig.setMergedIndexTtlMinutes( modelObj.getMergedIndexTTL( ) );
mergeConfig.setIndexMergeSchedule( modelObj.getSchedulingDefinition() );

+ 2
- 2
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/v2/model/map/MavenRepositoryMapper.java View File

@@ -74,8 +74,8 @@ public class MavenRepositoryMapper extends RestServiceMapper<MavenManagedReposit
public MavenManagedRepository reverseMap( ManagedRepository source )
{
MavenManagedRepository result = new MavenManagedRepository( );
StagingRepositoryFeature srf = source.getFeature( StagingRepositoryFeature.class ).get( );
ArtifactCleanupFeature acf = source.getFeature( ArtifactCleanupFeature.class ).get( );
StagingRepositoryFeature srf = source.getFeature( StagingRepositoryFeature.class );
ArtifactCleanupFeature acf = source.getFeature( ArtifactCleanupFeature.class );
result.setHasStagingRepository( srf.isStageRepoNeeded() );
result.setBlocksRedeployments( source.blocksRedeployments() );
result.setIndex( source.hasIndex() );

+ 4
- 4
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java View File

@@ -416,7 +416,7 @@ public class ArchivaDavResourceFactory

String mergedIndexPath = "/";
if (repoGroup.supportsFeature( IndexCreationFeature.class )) {
mergedIndexPath = repoGroup.getFeature( IndexCreationFeature.class ).get().getIndexPath().getPath();
mergedIndexPath = repoGroup.getFeature( IndexCreationFeature.class ).getIndexPath().getPath();
}

if ( StringUtils.endsWith( rootPath, mergedIndexPath ) )
@@ -1051,7 +1051,7 @@ public class ArchivaDavResourceFactory
String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/" );
String mergedIndexPath = "/";
if (repositoryGroup.supportsFeature( IndexCreationFeature.class )) {
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class );
mergedIndexPath = indexCreationFeature.getIndexPath().getPath();
}

@@ -1113,7 +1113,7 @@ public class ArchivaDavResourceFactory
if ( resourceFile.exists() && managedRepository.getRepository().supportsFeature( IndexCreationFeature.class ))
{
// in case of group displaying index directory doesn't have sense !!
IndexCreationFeature idf = managedRepository.getRepository().getFeature(IndexCreationFeature.class).get();
IndexCreationFeature idf = managedRepository.getRepository().getFeature( IndexCreationFeature.class );
StorageAsset repoIndexDirectory = idf.getLocalIndexPath();
if ( !StringUtils.equals( FilenameUtils.normalize( repoIndexDirectory.getPath() ),
FilenameUtils.normalize( logicalResource.getPath() ) ) )
@@ -1369,7 +1369,7 @@ public class ArchivaDavResourceFactory
log.info( "generate temporary merged index for repository group '{}' for repositories '{}'",
id, authzRepos );

IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class );
Path indexPath = indexCreationFeature.getLocalIndexPath().getFilePath();
if (indexPath!=null)
{

Loading…
Cancel
Save