@Test public void getManagedConfiguration() throws Exception { MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( "test01", "My Test repo", Paths.get("target/repositories") ); repo.setLocation( new URI("target/this.is/a/test") ); repo.setScanned( true ); repo.setDescription( repo.getPrimaryLocale(), "This is a description" ); repo.setLayout( "maven2" ); repo.setBlocksRedeployment( true ); repo.setName( repo.getPrimaryLocale(), "test0002" ); repo.setSchedulingDefinition( "0 0 05 ? * WED" ); repo.addActiveReleaseScheme( ReleaseScheme.RELEASE ); repo.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT ); StagingRepositoryFeature stagingFeat = repo.getFeature( StagingRepositoryFeature.class ).get( ); stagingFeat.setStageRepoNeeded( true ); IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ).get(); indexCreationFeature.setIndexPath( new URI("test/.indexes") ); indexCreationFeature.setSkipPackedIndexCreation( true ); ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature( ArtifactCleanupFeature.class ).get(); artifactCleanupFeature.setRetentionPeriod( Period.ofDays( 5 ) ); artifactCleanupFeature.setRetentionCount( 7 ); artifactCleanupFeature.setDeleteReleasedSnapshots( true ); ManagedRepositoryConfiguration cfg = provider.getManagedConfiguration( repo ); assertEquals("target/this.is/a/test", cfg.getLocation()); assertTrue(cfg.isScanned()); assertEquals( "This is a description", cfg.getDescription() ); assertEquals("maven2", cfg.getLayout()); assertTrue(cfg.isBlockRedeployments()); assertEquals("test0002", cfg.getName()); assertEquals("0 0 05 ? * WED", cfg.getRefreshCronExpression()); assertTrue(cfg.isStageRepoNeeded()); assertEquals("test/.indexes", cfg.getIndexDir()); assertTrue(cfg.isSkipPackedIndexCreation()); assertEquals(5, cfg.getRetentionPeriod()); assertEquals(7, cfg.getRetentionCount()); assertTrue(cfg.isDeleteReleasedSnapshots()); assertTrue(cfg.isReleases()); assertTrue(cfg.isSnapshots()); assertTrue(cfg.isScanned()); }
@Override public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException { if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository )) { log.error("Wrong remote repository type " + managedRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName()); } ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration(); cfg.setType(managedRepository.getType().toString()); cfg.setId(managedRepository.getId()); cfg.setName(managedRepository.getName()); cfg.setDescription(managedRepository.getDescription()); cfg.setLocation(convertUriToPath(managedRepository.getLocation())); cfg.setLayout(managedRepository.getLayout()); cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition()); cfg.setScanned(managedRepository.isScanned()); cfg.setBlockRedeployments(managedRepository.blocksRedeployments()); StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get(); cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount()); cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays()); cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE)) { cfg.setReleases(true); } else { cfg.setReleases(false); } if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT)) { cfg.setSnapshots(true); } else { cfg.setSnapshots(false); } return cfg; }
MavenRepositoryProvider implements RepositoryProvider { @Override public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException { if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository )) { log.error("Wrong remote repository type " + managedRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName()); } ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration(); cfg.setType(managedRepository.getType().toString()); cfg.setId(managedRepository.getId()); cfg.setName(managedRepository.getName()); cfg.setDescription(managedRepository.getDescription()); cfg.setLocation(convertUriToPath(managedRepository.getLocation())); cfg.setLayout(managedRepository.getLayout()); cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition()); cfg.setScanned(managedRepository.isScanned()); cfg.setBlockRedeployments(managedRepository.blocksRedeployments()); StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get(); cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount()); cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays()); cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE)) { cfg.setReleases(true); } else { cfg.setReleases(false); } if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT)) { cfg.setSnapshots(true); } else { cfg.setSnapshots(false); } return cfg; } }
MavenRepositoryProvider implements RepositoryProvider { @Override public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException { if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository )) { log.error("Wrong remote repository type " + managedRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName()); } ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration(); cfg.setType(managedRepository.getType().toString()); cfg.setId(managedRepository.getId()); cfg.setName(managedRepository.getName()); cfg.setDescription(managedRepository.getDescription()); cfg.setLocation(convertUriToPath(managedRepository.getLocation())); cfg.setLayout(managedRepository.getLayout()); cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition()); cfg.setScanned(managedRepository.isScanned()); cfg.setBlockRedeployments(managedRepository.blocksRedeployments()); StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get(); cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount()); cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays()); cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE)) { cfg.setReleases(true); } else { cfg.setReleases(false); } if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT)) { cfg.setSnapshots(true); } else { cfg.setSnapshots(false); } return cfg; }  }
MavenRepositoryProvider implements RepositoryProvider { @Override public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException { if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository )) { log.error("Wrong remote repository type " + managedRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName()); } ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration(); cfg.setType(managedRepository.getType().toString()); cfg.setId(managedRepository.getId()); cfg.setName(managedRepository.getName()); cfg.setDescription(managedRepository.getDescription()); cfg.setLocation(convertUriToPath(managedRepository.getLocation())); cfg.setLayout(managedRepository.getLayout()); cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition()); cfg.setScanned(managedRepository.isScanned()); cfg.setBlockRedeployments(managedRepository.blocksRedeployments()); StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get(); cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount()); cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays()); cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE)) { cfg.setReleases(true); } else { cfg.setReleases(false); } if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT)) { cfg.setSnapshots(true); } else { cfg.setSnapshots(false); } return cfg; }  @Override Set<RepositoryType> provides(); @Override MavenManagedRepository createManagedInstance(String id, String name); MavenManagedRepository createManagedInstance(String id, String name, Path baseDir); @Override MavenRemoteRepository createRemoteInstance(String id, String name); MavenRemoteRepository createRemoteInstance(String id, String name, Path baseDir); @Override EditableRepositoryGroup createRepositoryGroup(String id, String name); MavenRepositoryGroup createRepositoryGroup(String id, String name, Path baseDir); @Override ManagedRepository createManagedInstance(ManagedRepositoryConfiguration cfg); @Override void updateManagedInstance(EditableManagedRepository repo, ManagedRepositoryConfiguration cfg); @Override ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration); @Override RemoteRepository createRemoteInstance(RemoteRepositoryConfiguration cfg); @Override void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration cfg); @Override RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration); @Override void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration); @Override RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository); @Override ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository); @Override RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup); ArchivaConfiguration getArchivaConfiguration(); void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration); @Override void handle(Event event); }
MavenRepositoryProvider implements RepositoryProvider { @Override public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException { if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository )) { log.error("Wrong remote repository type " + managedRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName()); } ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration(); cfg.setType(managedRepository.getType().toString()); cfg.setId(managedRepository.getId()); cfg.setName(managedRepository.getName()); cfg.setDescription(managedRepository.getDescription()); cfg.setLocation(convertUriToPath(managedRepository.getLocation())); cfg.setLayout(managedRepository.getLayout()); cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition()); cfg.setScanned(managedRepository.isScanned()); cfg.setBlockRedeployments(managedRepository.blocksRedeployments()); StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get(); cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount()); cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays()); cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE)) { cfg.setReleases(true); } else { cfg.setReleases(false); } if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT)) { cfg.setSnapshots(true); } else { cfg.setSnapshots(false); } return cfg; }  @Override Set<RepositoryType> provides(); @Override MavenManagedRepository createManagedInstance(String id, String name); MavenManagedRepository createManagedInstance(String id, String name, Path baseDir); @Override MavenRemoteRepository createRemoteInstance(String id, String name); MavenRemoteRepository createRemoteInstance(String id, String name, Path baseDir); @Override EditableRepositoryGroup createRepositoryGroup(String id, String name); MavenRepositoryGroup createRepositoryGroup(String id, String name, Path baseDir); @Override ManagedRepository createManagedInstance(ManagedRepositoryConfiguration cfg); @Override void updateManagedInstance(EditableManagedRepository repo, ManagedRepositoryConfiguration cfg); @Override ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration); @Override RemoteRepository createRemoteInstance(RemoteRepositoryConfiguration cfg); @Override void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration cfg); @Override RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration); @Override void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration); @Override RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository); @Override ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository); @Override RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup); ArchivaConfiguration getArchivaConfiguration(); void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration); @Override void handle(Event event);  }