use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
c = new Configuration();
c.setVersion("2.0");
testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
testRepo.setReleases(true);
testRepo.setSnapshots(true);
c.addManagedRepository(testRepo);
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
testRemoteRepo.setLayout("default");
testRemoteRepo.setName("Central Repository");
testRemoteRepo.setUrl("http://central.repo.com/maven2");
testRemoteRepo.setTimeout(10);
c.addRemoteRepository(testRemoteRepo);
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
proxyConnector.setSourceRepoId(TEST_REPO_ID);
proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnector.setDisabled(false);
c.addProxyConnector(proxyConnector);
RepositoryScanningConfiguration scCfg = new RepositoryScanningConfiguration();
c.setRepositoryScanning(scCfg);
configuration.save(c);
assertFalse(configuration.isDefaulted());
repositoryRegistry.reload();
assertTrue(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).isReleases());
wagonFactory = mock(WagonFactory.class);
storage.setWagonFactory(wagonFactory);
Wagon wagon = new MockWagon();
when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryProvider method getStageRepoConfig.
private ManagedRepositoryConfiguration getStageRepoConfig(ManagedRepositoryConfiguration repository) {
ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
stagingRepository.setId(repository.getId() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
stagingRepository.setLayout(repository.getLayout());
stagingRepository.setName(repository.getName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
stagingRepository.setBlockRedeployments(repository.isBlockRedeployments());
stagingRepository.setRetentionPeriod(repository.getRetentionPeriod());
stagingRepository.setDeleteReleasedSnapshots(repository.isDeleteReleasedSnapshots());
stagingRepository.setStageRepoNeeded(false);
String path = repository.getLocation();
int lastIndex = path.replace('\\', '/').lastIndexOf('/');
stagingRepository.setLocation(path.substring(0, lastIndex) + "/" + stagingRepository.getId());
if (StringUtils.isNotBlank(repository.getIndexDir())) {
Path indexDir = null;
try {
indexDir = Paths.get(new URI(repository.getIndexDir().startsWith("file://") ? repository.getIndexDir() : "file://" + repository.getIndexDir()));
if (indexDir.isAbsolute()) {
Path newDir = indexDir.getParent().resolve(indexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
log.debug("Changing index directory {} -> {}", indexDir, newDir);
stagingRepository.setIndexDir(newDir.toString());
} else {
log.debug("Keeping index directory {}", repository.getIndexDir());
stagingRepository.setIndexDir(repository.getIndexDir());
}
} catch (URISyntaxException e) {
log.error("Could not parse index path as uri {}", repository.getIndexDir());
stagingRepository.setIndexDir("");
}
// in case of absolute dir do not use the same
}
if (StringUtils.isNotBlank(repository.getPackedIndexDir())) {
Path packedIndexDir = null;
try {
packedIndexDir = Paths.get(new URI(repository.getPackedIndexDir().startsWith("file://") ? repository.getPackedIndexDir() : "file://" + repository.getPackedIndexDir()));
if (packedIndexDir.isAbsolute()) {
Path newDir = packedIndexDir.getParent().resolve(packedIndexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
log.debug("Changing index directory {} -> {}", packedIndexDir, newDir);
stagingRepository.setPackedIndexDir(newDir.toString());
} else {
log.debug("Keeping index directory {}", repository.getPackedIndexDir());
stagingRepository.setPackedIndexDir(repository.getPackedIndexDir());
}
} catch (URISyntaxException e) {
log.error("Could not parse index path as uri {}", repository.getPackedIndexDir());
stagingRepository.setPackedIndexDir("");
}
// in case of absolute dir do not use the same
}
stagingRepository.setRefreshCronExpression(repository.getRefreshCronExpression());
stagingRepository.setReleases(repository.isReleases());
stagingRepository.setRetentionCount(repository.getRetentionCount());
stagingRepository.setScanned(repository.isScanned());
stagingRepository.setSnapshots(repository.isSnapshots());
stagingRepository.setSkipPackedIndexCreation(repository.isSkipPackedIndexCreation());
// stagingRepository.getDescription("")
return stagingRepository;
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryProviderMock method getManagedConfiguration.
@Override
public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException {
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
configuration.setId(managedRepository.getId());
configuration.setName(managedRepository.getName());
configuration.setLocation(managedRepository.getLocation() == null ? "" : managedRepository.getLocation().toString());
configuration.setBlockRedeployments(managedRepository.blocksRedeployments());
configuration.setDescription(managedRepository.getDescription());
configuration.setLayout(managedRepository.getLayout());
configuration.setScanned(managedRepository.isScanned());
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();
configuration.setRetentionPeriod(acf.getRetentionPeriod().getDays());
configuration.setDeleteReleasedSnapshots(acf.isDeleteReleasedSnapshots());
configuration.setRetentionCount(acf.getRetentionCount());
IndexCreationFeature icf = managedRepository.getFeature(IndexCreationFeature.class).get();
configuration.setSkipPackedIndexCreation(icf.isSkipPackedIndexCreation());
configuration.setIndexDir(icf.getIndexPath() == null ? "" : icf.getIndexPath().toString());
StagingRepositoryFeature srf = managedRepository.getFeature(StagingRepositoryFeature.class).get();
configuration.setStageRepoNeeded(srf.isStageRepoNeeded());
return configuration;
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class Maven2RepositoryMergerTest method testMergeWithOutConflictArtifacts.
@Test
public void testMergeWithOutConflictArtifacts() throws Exception {
String sourceRepoId = "source-repo";
ArtifactMetadata artifact1 = new ArtifactMetadata();
artifact1.setNamespace("org.testng");
artifact1.setProject("testng");
artifact1.setVersion("5.8");
artifact1.setProjectVersion("5.8");
artifact1.setId("testng-5.8-jdk15.jar");
artifact1.setRepositoryId(sourceRepoId);
List<ArtifactMetadata> sourceRepoArtifactsList = getArtifacts();
sourceRepoArtifactsList.add(artifact1);
List<ArtifactMetadata> targetRepoArtifactsList = getArtifacts();
Configuration c = new Configuration();
ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation("target/test-repository");
String sourceRepo = "src/test/resources/test-repository-with-conflict-artifacts";
ManagedRepositoryConfiguration testRepoWithConflicts = new ManagedRepositoryConfiguration();
testRepoWithConflicts.setId(sourceRepoId);
testRepoWithConflicts.setLocation(sourceRepo);
RepositoryScanningConfiguration repoScanConfig = new RepositoryScanningConfiguration();
List<String> knownContentConsumers = new ArrayList<>();
knownContentConsumers.add("metadata-updater");
repoScanConfig.setKnownContentConsumers(knownContentConsumers);
c.setRepositoryScanning(repoScanConfig);
c.addManagedRepository(testRepo);
c.addManagedRepository(testRepoWithConflicts);
configuration.save(c);
Path targetRepoFile = Paths.get("/target/test-repository/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.jar");
targetRepoFile.toFile().setReadOnly();
when(metadataRepository.getArtifacts(sourceRepoId)).thenReturn(sourceRepoArtifactsList);
when(metadataRepository.getArtifacts(TEST_REPO_ID)).thenReturn(targetRepoArtifactsList);
assertEquals(1, repositoryMerger.getConflictingArtifacts(metadataRepository, sourceRepoId, TEST_REPO_ID).size());
verify(metadataRepository).getArtifacts(TEST_REPO_ID);
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class DefaultManagedRepositoryAdmin method getRepositoryConfiguration.
private ManagedRepositoryConfiguration getRepositoryConfiguration(ManagedRepository repo) {
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
setBaseRepoAttributes(repoConfig, repo);
repoConfig.setBlockRedeployments(repo.isBlockRedeployments());
repoConfig.setReleases(repo.isReleases());
repoConfig.setSnapshots(repo.isSnapshots());
repoConfig.setScanned(repo.isScanned());
repoConfig.setLocation(getRepositoryCommonValidator().removeExpressions(repo.getLocation()));
repoConfig.setRefreshCronExpression(repo.getCronExpression());
repoConfig.setRetentionPeriod(repo.getRetentionPeriod());
repoConfig.setRetentionCount(repo.getRetentionCount());
repoConfig.setDeleteReleasedSnapshots(repo.isDeleteReleasedSnapshots());
repoConfig.setSkipPackedIndexCreation(repo.isSkipPackedIndexCreation());
repoConfig.setStageRepoNeeded(repo.isStageRepoNeeded());
return repoConfig;
}
Aggregations