Search in sources :

Example 21 with ManagedRepositoryConfiguration

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());
}
Also used : MetadataRepositoryException(org.apache.archiva.metadata.repository.MetadataRepositoryException) MetadataRepository(org.apache.archiva.metadata.repository.MetadataRepository) SchedulerException(org.quartz.SchedulerException) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArchivaException(org.apache.archiva.common.ArchivaException) RepositorySession(org.apache.archiva.metadata.repository.RepositorySession) StopWatch(org.apache.commons.lang.time.StopWatch) PostConstruct(javax.annotation.PostConstruct)

Example 22 with ManagedRepositoryConfiguration

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" );
}
Also used : ArtifactRepositoryLayout(org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout) Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArtifactRepositoryFactory(org.apache.maven.artifact.repository.ArtifactRepositoryFactory) Before(org.junit.Before)

Example 23 with ManagedRepositoryConfiguration

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());
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration)

Example 24 with ManagedRepositoryConfiguration

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);
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration)

Example 25 with ManagedRepositoryConfiguration

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());
                }
            }
        }
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration)

Aggregations

ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)46 Configuration (org.apache.archiva.configuration.Configuration)17 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)14 Path (java.nio.file.Path)9 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)9 Before (org.junit.Before)9 ContextConfiguration (org.springframework.test.context.ContextConfiguration)9 Test (org.junit.Test)8 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)7 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)7 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)7 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)7 ArrayList (java.util.ArrayList)6 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)5 IndexUpdateFailedException (org.apache.archiva.indexer.IndexUpdateFailedException)5 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)5 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)5 IOException (java.io.IOException)4 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)4 RepositoryException (org.apache.archiva.repository.RepositoryException)4