Search in sources :

Example 6 with RepositoryGroupConfiguration

use of org.apache.archiva.configuration.RepositoryGroupConfiguration in project archiva by apache.

the class RepositoryServletRepositoryGroupTest method createRepositoryGroup.

protected RepositoryGroupConfiguration createRepositoryGroup(String id, List<String> repositories) {
    RepositoryGroupConfiguration repoGroupConfiguration = new RepositoryGroupConfiguration();
    repoGroupConfiguration.setId(id);
    repoGroupConfiguration.setRepositories(repositories);
    return repoGroupConfiguration;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration)

Example 7 with RepositoryGroupConfiguration

use of org.apache.archiva.configuration.RepositoryGroupConfiguration in project archiva by apache.

the class DefaultRepositoryGroupAdmin method addRepositoryGroup.

@Override
public Boolean addRepositoryGroup(RepositoryGroup repositoryGroup, AuditInformation auditInformation) throws RepositoryAdminException {
    validateRepositoryGroup(repositoryGroup, false);
    validateManagedRepositoriesExists(repositoryGroup.getRepositories());
    RepositoryGroupConfiguration repositoryGroupConfiguration = new RepositoryGroupConfiguration();
    repositoryGroupConfiguration.setId(repositoryGroup.getId());
    repositoryGroupConfiguration.setRepositories(repositoryGroup.getRepositories());
    repositoryGroupConfiguration.setMergedIndexPath(repositoryGroup.getMergedIndexPath());
    repositoryGroupConfiguration.setMergedIndexTtl(repositoryGroup.getMergedIndexTtl());
    repositoryGroupConfiguration.setCronExpression(repositoryGroup.getCronExpression());
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    configuration.addRepositoryGroup(repositoryGroupConfiguration);
    saveConfiguration(configuration);
    triggerAuditEvent(repositoryGroup.getId(), null, AuditEvent.ADD_REPO_GROUP, auditInformation);
    mergedRemoteIndexesScheduler.schedule(repositoryGroup, getMergedIndexDirectory(repositoryGroup.getId()));
    return Boolean.TRUE;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.Configuration)

Example 8 with RepositoryGroupConfiguration

use of org.apache.archiva.configuration.RepositoryGroupConfiguration in project archiva by apache.

the class DefaultRepositoryGroupAdmin method updateRepositoryGroup.

private Boolean updateRepositoryGroup(RepositoryGroup repositoryGroup, AuditInformation auditInformation, boolean triggerAuditEvent) throws RepositoryAdminException {
    validateRepositoryGroup(repositoryGroup, true);
    validateManagedRepositoriesExists(repositoryGroup.getRepositories());
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    RepositoryGroupConfiguration repositoryGroupConfiguration = configuration.getRepositoryGroupsAsMap().get(repositoryGroup.getId());
    configuration.removeRepositoryGroup(repositoryGroupConfiguration);
    repositoryGroupConfiguration.setRepositories(repositoryGroup.getRepositories());
    repositoryGroupConfiguration.setMergedIndexPath(repositoryGroup.getMergedIndexPath());
    repositoryGroupConfiguration.setMergedIndexTtl(repositoryGroup.getMergedIndexTtl());
    repositoryGroupConfiguration.setCronExpression(repositoryGroup.getCronExpression());
    configuration.addRepositoryGroup(repositoryGroupConfiguration);
    saveConfiguration(configuration);
    if (triggerAuditEvent) {
        triggerAuditEvent(repositoryGroup.getId(), null, AuditEvent.MODIFY_REPO_GROUP, auditInformation);
    }
    mergedRemoteIndexesScheduler.unschedule(repositoryGroup);
    mergedRemoteIndexesScheduler.schedule(repositoryGroup, getMergedIndexDirectory(repositoryGroup.getId()));
    return Boolean.TRUE;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.Configuration)

Example 9 with RepositoryGroupConfiguration

use of org.apache.archiva.configuration.RepositoryGroupConfiguration in project archiva by apache.

the class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    c = new Configuration();
    testRepo = new ManagedRepositoryConfiguration();
    testRepo.setId(TEST_REPO_ID);
    testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
    testRepo.setReleases(true);
    testRepo.setSnapshots(false);
    c.addManagedRepository(testRepo);
    testRepoS = new ManagedRepositoryConfiguration();
    testRepoS.setId(TEST_SNAP_REPO_ID);
    testRepoS.setLocation(Paths.get("target/test-repositorys").toAbsolutePath().toString());
    testRepoS.setReleases(false);
    testRepoS.setSnapshots(true);
    c.addManagedRepository(testRepoS);
    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);
    ProxyConnectorConfiguration proxyConnectors = new ProxyConnectorConfiguration();
    proxyConnectors.setSourceRepoId(TEST_SNAP_REPO_ID);
    proxyConnectors.setTargetRepoId(TEST_REMOTE_REPO_ID);
    proxyConnectors.setDisabled(false);
    c.addProxyConnector(proxyConnectors);
    List<String> repos = new ArrayList<>();
    repos.add(TEST_REPO_ID);
    repos.add(TEST_SNAP_REPO_ID);
    RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
    repoGroup.setId(TEST_REPO_GROUP_ID);
    repoGroup.setRepositories(repos);
    c.addRepositoryGroup(repoGroup);
    configuration.save(c);
    repositoryRegistry.reload();
    assertFalse(c.getManagedRepositories().get(0).isSnapshots());
    assertTrue(c.getManagedRepositories().get(0).isReleases());
    assertTrue(c.getManagedRepositories().get(1).isSnapshots());
    assertFalse(c.getManagedRepositories().get(1).isReleases());
    wagonFactory = mock(WagonFactory.class);
    storage.setWagonFactory(wagonFactory);
    Wagon wagon = new MockWagon();
    when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) WagonFactoryRequest(org.apache.archiva.proxy.common.WagonFactoryRequest) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) WagonFactory(org.apache.archiva.proxy.common.WagonFactory) Wagon(org.apache.maven.wagon.Wagon) Before(org.junit.Before)

Aggregations

RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)9 ArrayList (java.util.ArrayList)5 Configuration (org.apache.archiva.configuration.Configuration)4 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)3 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)3 DavException (org.apache.jackrabbit.webdav.DavException)3 Path (java.nio.file.Path)2 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)2 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 List (java.util.List)1 RemoteRepository (org.apache.archiva.admin.model.beans.RemoteRepository)1 RepositoryGroup (org.apache.archiva.admin.model.beans.RepositoryGroup)1 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)1 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)1 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)1 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)1 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)1 RepositorySession (org.apache.archiva.metadata.repository.RepositorySession)1