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";
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 )
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( ) ) );
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;
}
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( ) );
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 )
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 )
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( ) ) );
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;
}
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( ) );
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() );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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()));
}
{
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;
}
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() );
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() ) );
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()) {
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");
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;
{
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 );
}
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
}
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( ) );
}
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( ) );
{
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( );
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( ) );
@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) {
}
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();
// 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
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.
}
}
- @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.
private String proxyId = "";
- @Override
- public RemoteIndexFeature get() {
- return this;
- }
-
/**
* True, if the remote index should be downloaded.
* @return True if download, otherwise false.
return this.getClass().equals(clazz);
}
- /**
- * Returns the concrete feature instance.
- * @return the feature instance.
- */
- T get();
}
this.stageRepoNeeded = stageRepoNeeded;
}
- @Override
- public StagingRepositoryFeature get() {
- return this;
- }
-
/**
* Returns the staging repository, if it exists.
*
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)
{
}
if (supportsFeature(StagingRepositoryFeature.class)) {
- StagingRepositoryFeature sf = getFeature(StagingRepositoryFeature.class).get();
+ StagingRepositoryFeature sf = getFeature( StagingRepositoryFeature.class );
if (sf.getStagingRepository() != null) {
sf.getStagingRepository().close();
}
{
if ( group != null )
{
- return group.getFeature( IndexCreationFeature.class ).get( ).getLocalIndexPath( );
+ return group.getFeature( IndexCreationFeature.class ).getLocalIndexPath( );
}
else
{
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 );
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 );
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 );
}
{
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( ) ) );
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 )
throw new RepositoryException(e);
}
updateManagedInstance( managedRepository, configuration );
- managedRepository.getFeature(StagingRepositoryFeature.class).get().setStageRepoNeeded(false);
+ managedRepository.getFeature( StagingRepositoryFeature.class ).setStageRepoNeeded(false);
return managedRepository;
}
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( ) ) );
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;
}
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() );
}
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( ) );
{
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( );
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( ) );
@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));
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");
}
}
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);
}
// 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
}
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;
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;
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();
repositoryRegistry.reload();
Repository rRepo2 = repositoryRegistry.getRepository( repository );
- icf = rRepo2.getFeature(IndexCreationFeature.class).get();
+ icf = rRepo2.getFeature( IndexCreationFeature.class );
archivaCtx = rRepo2.getIndexingContext();
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 )
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 )
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;
}
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( ) );
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());
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()));
} 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( ) ) );
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();
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( "" );
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());
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() );
}
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());
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());
}
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 );
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 );
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);
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) {
{
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( );
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( ) );
@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) {
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();
// 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
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 )
{
{
continue;
}
- RemoteIndexFeature rif = remoteRepository.getFeature(RemoteIndexFeature.class).get();
+ RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class );
// TODO record jobs from configuration
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() ) )
{
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" );
{
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();
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;
}
{
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( );
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(
@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) {
}
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();
// 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
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():"" );
}
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() );
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() );
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 ) )
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();
}
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() ) ) )
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)
{