use of org.apache.archiva.configuration.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 = repositorySessionFactory.createSession();
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.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryConverterTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
ArtifactRepositoryFactory factory = plexusSisuBridge.lookup(ArtifactRepositoryFactory.class);
// (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
ArtifactRepositoryLayout layout = plexusSisuBridge.lookup(ArtifactRepositoryLayout.class, "legacy");
// (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
Path sourceBase = Paths.get("src/test/source-repository");
sourceRepository = factory.createArtifactRepository("source", sourceBase.toUri().toURL().toString(), layout, null, null);
layout = plexusSisuBridge.lookup(ArtifactRepositoryLayout.class, "default");
// (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
Path targetBase = Paths.get("target/test-target-repository");
copyDirectoryStructure(Paths.get("src/test/target-repository"), targetBase);
targetRepository = new ManagedRepositoryConfiguration();
targetRepository.setId("target");
targetRepository.setName("Target Repo");
targetRepository.setLocation(targetBase.toAbsolutePath().toString());
targetRepository.setLayout("default");
// repositoryConverter = (LegacyRepositoryConverter) lookup( LegacyRepositoryConverter.ROLE, "default" );
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractProxyTestCase method saveManagedRepositoryConfig.
protected void saveManagedRepositoryConfig(String id, String name, String path, String layout) {
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId(id);
repoConfig.setName(name);
repoConfig.setLayout(layout);
repoConfig.setLocation(path);
int count = config.getConfiguration().getManagedRepositories().size();
config.getConfiguration().addManagedRepository(repoConfig);
String prefix = "managedRepositories.managedRepository(" + count + ")";
config.triggerChange(prefix + ".id", repoConfig.getId());
config.triggerChange(prefix + ".name", repoConfig.getName());
config.triggerChange(prefix + ".location", repoConfig.getLocation());
config.triggerChange(prefix + ".layout", repoConfig.getLayout());
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractSecurityTest method setupRepository.
protected void setupRepository(String repoId) throws Exception {
// Add repo to configuration.
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId(repoId);
repoConfig.setName("Testable repo <" + repoId + ">");
repoConfig.setLocation(Paths.get("target/test-repo/" + repoId).toString());
if (!archivaConfiguration.getConfiguration().getManagedRepositoriesAsMap().containsKey(repoId)) {
repositoryRegistry.putRepository(repoConfig);
}
// Add repo roles to security.
userRepos.createMissingRepositoryRoles(repoId);
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class DefaultRepositoryArchivaTaskScheduler method configurationEvent.
@Override
public void configurationEvent(ConfigurationEvent event) {
if (event.getType() == ConfigurationEvent.SAVED) {
for (String job : jobs) {
try {
scheduler.unscheduleJob(job, REPOSITORY_SCAN_GROUP);
} catch (SchedulerException e) {
log.error("Error restarting the repository scanning job after property change.");
}
}
jobs.clear();
List<ManagedRepositoryConfiguration> repositories = archivaConfiguration.getConfiguration().getManagedRepositories();
for (ManagedRepositoryConfiguration repoConfig : repositories) {
if (repoConfig.getRefreshCronExpression() != null) {
try {
scheduleRepositoryJobs(repoConfig);
} catch (SchedulerException e) {
log.error("error restarting job: '{}' : '{}'", REPOSITORY_JOB, repoConfig.getId());
}
}
}
}
}
Aggregations