use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class DefaultRepositoryArchivaTaskScheduler method startup.
@PostConstruct
public void startup() throws ArchivaException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
archivaConfiguration.addListener(this);
List<ManagedRepositoryConfiguration> repositories = archivaConfiguration.getConfiguration().getManagedRepositories();
RepositorySession repositorySession = null;
try {
repositorySession = repositorySessionFactory.createSession();
} catch (MetadataRepositoryException e) {
e.printStackTrace();
}
try {
MetadataRepository metadataRepository = repositorySession.getRepository();
for (ManagedRepositoryConfiguration repoConfig : repositories) {
if (repoConfig.isScanned()) {
try {
scheduleRepositoryJobs(repoConfig);
} catch (SchedulerException e) {
throw new ArchivaException("Unable to start scheduler: " + e.getMessage(), e);
}
try {
if (!isPreviouslyScanned(repoConfig, metadataRepository)) {
queueInitialRepoScan(repoConfig);
}
} catch (MetadataRepositoryException e) {
log.warn("Unable to determine if a repository is already scanned, skipping initial scan: {}", e.getMessage(), e);
}
}
}
} finally {
repositorySession.close();
}
stopWatch.stop();
log.info("Time to initalize DefaultRepositoryArchivaTaskScheduler: {} ms", stopWatch.getTime());
}
use of org.apache.archiva.configuration.model.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(session, sourceRepoId)).thenReturn(sourceRepoArtifactsList);
when(metadataRepository.getArtifacts(session, TEST_REPO_ID)).thenReturn(targetRepoArtifactsList);
assertEquals(1, repositoryMerger.getConflictingArtifacts(metadataRepository, sourceRepoId, TEST_REPO_ID).size());
verify(metadataRepository).getArtifacts(session, TEST_REPO_ID);
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class Maven2RepositoryMergerTest method testMerge.
@Test
public void testMerge() throws Exception {
String targetRepoPath = "target/test-repository-target";
Path mergedArtifact = Paths.get(targetRepoPath, "com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.jar");
Path mavenMetadata = Paths.get(targetRepoPath, "com/example/test/test-artifact/maven-metadata.xml");
Path pom = Paths.get(targetRepoPath, "com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.pom");
for (Path testArtifact : new Path[] { mergedArtifact, mavenMetadata, pom }) {
Files.deleteIfExists(testArtifact);
}
assertFalse("Artifact file exists already", Files.exists(mergedArtifact));
assertFalse("Metadata file exists already", Files.exists(mavenMetadata));
assertFalse("Pom File exists already", Files.exists(pom));
Configuration c = new Configuration();
ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation("target/test-repository");
RepositoryScanningConfiguration repoScanConfig = new RepositoryScanningConfiguration();
List<String> knownContentConsumers = new ArrayList<>();
knownContentConsumers.add("metadata-updater12");
repoScanConfig.setKnownContentConsumers(knownContentConsumers);
c.setRepositoryScanning(repoScanConfig);
ManagedRepositoryConfiguration targetRepo = new ManagedRepositoryConfiguration();
targetRepo.setId("target-rep");
targetRepo.setLocation(targetRepoPath);
c.addManagedRepository(testRepo);
c.addManagedRepository(targetRepo);
configuration.save(c);
when(metadataRepository.getArtifacts(session, TEST_REPO_ID)).thenReturn(getArtifacts());
repositoryMerger.merge(metadataRepository, TEST_REPO_ID, "target-rep");
verify(metadataRepository).getArtifacts(session, TEST_REPO_ID);
assertTrue(Files.exists(mergedArtifact));
assertTrue(Files.exists(mavenMetadata));
assertTrue(Files.exists(pom));
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractRepositoryServletTestCase method createManagedRepository.
protected ManagedRepositoryConfiguration createManagedRepository(String id, String name, Path location, String layout, boolean blockRedeployments) {
ManagedRepositoryConfiguration repo = createManagedRepository(id, name, location, blockRedeployments);
repo.setLayout(layout);
return repo;
}
use of org.apache.archiva.configuration.model.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);
configuration.setRetentionPeriod(acf.getRetentionPeriod().getDays());
configuration.setDeleteReleasedSnapshots(acf.isDeleteReleasedSnapshots());
configuration.setRetentionCount(acf.getRetentionCount());
IndexCreationFeature icf = managedRepository.getFeature(IndexCreationFeature.class);
configuration.setSkipPackedIndexCreation(icf.isSkipPackedIndexCreation());
configuration.setIndexDir(icf.getIndexPath() == null ? "" : icf.getIndexPath().toString());
StagingRepositoryFeature srf = managedRepository.getFeature(StagingRepositoryFeature.class);
configuration.setStageRepoNeeded(srf.isStageRepoNeeded());
return configuration;
}
Aggregations