Search in sources :

Example 11 with RepositoryGroupConfiguration

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

the class RepositoryProviderMock method getRepositoryGroupConfiguration.

@Override
public RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup) throws RepositoryException {
    RepositoryGroupConfiguration cfg = new RepositoryGroupConfiguration();
    cfg.setId(repositoryGroup.getId());
    cfg.setName(repositoryGroup.getName());
    if (repositoryGroup.supportsFeature(IndexCreationFeature.class)) {
        IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature(IndexCreationFeature.class);
        cfg.setMergedIndexPath(indexCreationFeature.getIndexPath().toString());
    }
    cfg.setMergedIndexTtl(repositoryGroup.getMergedIndexTTL());
    cfg.setRepositories(repositoryGroup.getRepositories().stream().map(Repository::getId).collect(Collectors.toList()));
    cfg.setCronExpression(repositoryGroup.getSchedulingDefinition());
    return cfg;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) BasicRemoteRepository(org.apache.archiva.repository.base.remote.BasicRemoteRepository) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository)

Example 12 with RepositoryGroupConfiguration

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

the class MavenRepositoryProviderTest method createRepositoryGroupWithCfg.

@Test
public void createRepositoryGroupWithCfg() throws RepositoryException {
    RepositoryGroupConfiguration cfg = new RepositoryGroupConfiguration();
    cfg.setId("group2");
    cfg.setName("Group 2");
    cfg.setCronExpression("0 0 03 ? * MON");
    cfg.setMergedIndexTtl(504);
    cfg.setMergedIndexPath(".index-abc");
    ArrayList<String> repos = new ArrayList<>();
    repos.add("test01");
    repos.add("test02");
    cfg.setRepositories(repos);
    RepositoryGroup grp = provider.createRepositoryGroup(cfg);
    assertEquals("group2", grp.getId());
    assertEquals("Group 2", grp.getName());
    assertEquals("0 0 03 ? * MON", grp.getSchedulingDefinition());
    IndexCreationFeature indexCreationFeature = grp.getFeature(IndexCreationFeature.class);
    try {
        assertEquals(new URI(".index-abc"), indexCreationFeature.getIndexPath());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    assertEquals(504, grp.getMergedIndexTTL());
    assertEquals(0, grp.getRepositories().size());
// assertTrue(grp.getRepositories().stream().anyMatch(r -> "test01".equals(r.getId())));
// assertTrue(grp.getRepositories().stream().anyMatch(r -> "test02".equals(r.getId())));
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Test(org.junit.Test)

Example 13 with RepositoryGroupConfiguration

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

the class ConfigurationRegistryReader method readConfiguration.

private Configuration readConfiguration(String prefix, Registry registry) {
    Configuration value = new Configuration();
    // String version = registry.getString( prefix + "version", value.getVersion() );
    List<String> versionList = registry.getList(prefix + "version");
    String version = value.getVersion();
    if (versionList != null && !versionList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = versionList.size(); i < size; i++) {
            sb.append(versionList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        version = sb.toString();
    }
    value.setVersion(version);
    // String metadataStore = registry.getString( prefix + "metadataStore", value.getMetadataStore() );
    List<String> metadataStoreList = registry.getList(prefix + "metadataStore");
    String metadataStore = value.getMetadataStore();
    if (metadataStoreList != null && !metadataStoreList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = metadataStoreList.size(); i < size; i++) {
            sb.append(metadataStoreList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        metadataStore = sb.toString();
    }
    value.setMetadataStore(metadataStore);
    java.util.List repositoryGroups = new java.util.ArrayList();
    List repositoryGroupsSubsets = registry.getSubsetList(prefix + "repositoryGroups.repositoryGroup");
    for (Iterator i = repositoryGroupsSubsets.iterator(); i.hasNext(); ) {
        RepositoryGroupConfiguration v = readRepositoryGroupConfiguration("", (Registry) i.next());
        repositoryGroups.add(v);
    }
    value.setRepositoryGroups(repositoryGroups);
    java.util.List managedRepositories = new java.util.ArrayList();
    List managedRepositoriesSubsets = registry.getSubsetList(prefix + "managedRepositories.managedRepository");
    for (Iterator i = managedRepositoriesSubsets.iterator(); i.hasNext(); ) {
        ManagedRepositoryConfiguration v = readManagedRepositoryConfiguration("", (Registry) i.next());
        managedRepositories.add(v);
    }
    value.setManagedRepositories(managedRepositories);
    java.util.List remoteRepositories = new java.util.ArrayList();
    List remoteRepositoriesSubsets = registry.getSubsetList(prefix + "remoteRepositories.remoteRepository");
    for (Iterator i = remoteRepositoriesSubsets.iterator(); i.hasNext(); ) {
        RemoteRepositoryConfiguration v = readRemoteRepositoryConfiguration("", (Registry) i.next());
        remoteRepositories.add(v);
    }
    value.setRemoteRepositories(remoteRepositories);
    java.util.List proxyConnectors = new java.util.ArrayList();
    List proxyConnectorsSubsets = registry.getSubsetList(prefix + "proxyConnectors.proxyConnector");
    for (Iterator i = proxyConnectorsSubsets.iterator(); i.hasNext(); ) {
        ProxyConnectorConfiguration v = readProxyConnectorConfiguration("", (Registry) i.next());
        proxyConnectors.add(v);
    }
    value.setProxyConnectors(proxyConnectors);
    java.util.List networkProxies = new java.util.ArrayList();
    List networkProxiesSubsets = registry.getSubsetList(prefix + "networkProxies.networkProxy");
    for (Iterator i = networkProxiesSubsets.iterator(); i.hasNext(); ) {
        NetworkProxyConfiguration v = readNetworkProxyConfiguration("", (Registry) i.next());
        networkProxies.add(v);
    }
    value.setNetworkProxies(networkProxies);
    java.util.List legacyArtifactPaths = new java.util.ArrayList();
    List legacyArtifactPathsSubsets = registry.getSubsetList(prefix + "legacyArtifactPaths.legacyArtifactPath");
    for (Iterator i = legacyArtifactPathsSubsets.iterator(); i.hasNext(); ) {
        LegacyArtifactPath v = readLegacyArtifactPath("", (Registry) i.next());
        legacyArtifactPaths.add(v);
    }
    value.setLegacyArtifactPaths(legacyArtifactPaths);
    RepositoryScanningConfiguration repositoryScanning = readRepositoryScanningConfiguration(prefix + "repositoryScanning.", registry);
    value.setRepositoryScanning(repositoryScanning);
    WebappConfiguration webapp = readWebappConfiguration(prefix + "webapp.", registry);
    value.setWebapp(webapp);
    OrganisationInformation organisationInfo = readOrganisationInformation(prefix + "organisationInfo.", registry);
    value.setOrganisationInfo(organisationInfo);
    NetworkConfiguration networkConfiguration = readNetworkConfiguration(prefix + "networkConfiguration.", registry);
    value.setNetworkConfiguration(networkConfiguration);
    RedbackRuntimeConfiguration redbackRuntimeConfiguration = readRedbackRuntimeConfiguration(prefix + "redbackRuntimeConfiguration.", registry);
    value.setRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
    ArchivaRuntimeConfiguration archivaRuntimeConfiguration = readArchivaRuntimeConfiguration(prefix + "archivaRuntimeConfiguration.", registry);
    value.setArchivaRuntimeConfiguration(archivaRuntimeConfiguration);
    java.util.List proxyConnectorRuleConfigurations = new java.util.ArrayList();
    List proxyConnectorRuleConfigurationsSubsets = registry.getSubsetList(prefix + "proxyConnectorRuleConfigurations.proxyConnectorRuleConfiguration");
    for (Iterator i = proxyConnectorRuleConfigurationsSubsets.iterator(); i.hasNext(); ) {
        ProxyConnectorRuleConfiguration v = readProxyConnectorRuleConfiguration("", (Registry) i.next());
        proxyConnectorRuleConfigurations.add(v);
    }
    value.setProxyConnectorRuleConfigurations(proxyConnectorRuleConfigurations);
    ArchivaDefaultConfiguration archivaDefaultConfiguration = readArchivaDefaultConfiguration(prefix + "archivaDefaultConfiguration.", registry);
    value.setArchivaDefaultConfiguration(archivaDefaultConfiguration);
    return value;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) LdapConfiguration(org.apache.archiva.configuration.model.LdapConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) NetworkConfiguration(org.apache.archiva.configuration.model.NetworkConfiguration) RedbackRuntimeConfiguration(org.apache.archiva.configuration.model.RedbackRuntimeConfiguration) AbstractRepositoryConfiguration(org.apache.archiva.configuration.model.AbstractRepositoryConfiguration) ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) AbstractRepositoryConnectorConfiguration(org.apache.archiva.configuration.model.AbstractRepositoryConnectorConfiguration) FileLockConfiguration(org.apache.archiva.configuration.model.FileLockConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) CacheConfiguration(org.apache.archiva.configuration.model.CacheConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) SyncConnectorConfiguration(org.apache.archiva.configuration.model.SyncConnectorConfiguration) ArchivaDefaultConfiguration(org.apache.archiva.configuration.model.ArchivaDefaultConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) Iterator(java.util.Iterator) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) List(java.util.List) NetworkConfiguration(org.apache.archiva.configuration.model.NetworkConfiguration) ArchivaDefaultConfiguration(org.apache.archiva.configuration.model.ArchivaDefaultConfiguration) ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) List(java.util.List) LegacyArtifactPath(org.apache.archiva.configuration.model.LegacyArtifactPath) OrganisationInformation(org.apache.archiva.configuration.model.OrganisationInformation) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RedbackRuntimeConfiguration(org.apache.archiva.configuration.model.RedbackRuntimeConfiguration)

Example 14 with RepositoryGroupConfiguration

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

the class ConfigurationRegistryReader method readRepositoryGroupConfiguration.

private RepositoryGroupConfiguration readRepositoryGroupConfiguration(String prefix, Registry registry) {
    RepositoryGroupConfiguration value = new RepositoryGroupConfiguration();
    // String id = registry.getString( prefix + "id", value.getId() );
    List<String> idList = registry.getList(prefix + "id");
    String id = value.getId();
    if (idList != null && !idList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = idList.size(); i < size; i++) {
            sb.append(idList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        id = sb.toString();
    }
    value.setId(id);
    value.setName(registry.getString(prefix + "name"));
    value.setType(registry.getString(prefix + "type"));
    // String mergedIndexPath = registry.getString( prefix + "mergedIndexPath", value.getMergedIndexPath() );
    List<String> mergedIndexPathList = registry.getList(prefix + "mergedIndexPath");
    String mergedIndexPath = value.getMergedIndexPath();
    if (mergedIndexPathList != null && !mergedIndexPathList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = mergedIndexPathList.size(); i < size; i++) {
            sb.append(mergedIndexPathList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        mergedIndexPath = sb.toString();
    }
    value.setMergedIndexPath(mergedIndexPath);
    int mergedIndexTtl = registry.getInt(prefix + "mergedIndexTtl", value.getMergedIndexTtl());
    value.setMergedIndexTtl(mergedIndexTtl);
    // String cronExpression = registry.getString( prefix + "cronExpression", value.getCronExpression() );
    value.setLocation(registry.getString(prefix + "location"));
    List<String> cronExpressionList = registry.getList(prefix + "cronExpression");
    String cronExpression = value.getCronExpression();
    if (cronExpressionList != null && !cronExpressionList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = cronExpressionList.size(); i < size; i++) {
            sb.append(cronExpressionList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        cronExpression = sb.toString();
    }
    value.setCronExpression(cronExpression);
    java.util.List repositories = new java.util.ArrayList();
    repositories.addAll(registry.getList(prefix + "repositories.repository"));
    value.setRepositories(repositories);
    return value;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) List(java.util.List)

Example 15 with RepositoryGroupConfiguration

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

the class ConfigurationRegistryWriter method writeConfiguration.

private void writeConfiguration(String prefix, Configuration value, Registry registry) {
    if (value != null) {
        if (value.getVersion() != null) {
            String version = "version";
            registry.setString(prefix + version, value.getVersion());
        }
        if (value.getMetadataStore() != null && !value.getMetadataStore().equals("jcr")) {
            String metadataStore = "metadataStore";
            registry.setString(prefix + metadataStore, value.getMetadataStore());
        }
        if (value.getRepositoryGroups() != null && value.getRepositoryGroups().size() > 0) {
            registry.removeSubset(prefix + "repositoryGroups");
            int count = 0;
            for (Iterator iter = value.getRepositoryGroups().iterator(); iter.hasNext(); count++) {
                String name = "repositoryGroups.repositoryGroup(" + count + ")";
                RepositoryGroupConfiguration o = (RepositoryGroupConfiguration) iter.next();
                writeRepositoryGroupConfiguration(prefix + name + ".", o, registry);
            }
        }
        if (value.getManagedRepositories() != null && value.getManagedRepositories().size() > 0) {
            registry.removeSubset(prefix + "managedRepositories");
            int count = 0;
            for (Iterator iter = value.getManagedRepositories().iterator(); iter.hasNext(); count++) {
                String name = "managedRepositories.managedRepository(" + count + ")";
                ManagedRepositoryConfiguration o = (ManagedRepositoryConfiguration) iter.next();
                writeManagedRepositoryConfiguration(prefix + name + ".", o, registry);
            }
        }
        if (value.getRemoteRepositories() != null && value.getRemoteRepositories().size() > 0) {
            registry.removeSubset(prefix + "remoteRepositories");
            int count = 0;
            for (Iterator iter = value.getRemoteRepositories().iterator(); iter.hasNext(); count++) {
                String name = "remoteRepositories.remoteRepository(" + count + ")";
                RemoteRepositoryConfiguration o = (RemoteRepositoryConfiguration) iter.next();
                writeRemoteRepositoryConfiguration(prefix + name + ".", o, registry);
            }
        }
        if (value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0) {
            registry.removeSubset(prefix + "proxyConnectors");
            int count = 0;
            for (Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++) {
                String name = "proxyConnectors.proxyConnector(" + count + ")";
                ProxyConnectorConfiguration o = (ProxyConnectorConfiguration) iter.next();
                writeProxyConnectorConfiguration(prefix + name + ".", o, registry);
            }
        }
        if (value.getNetworkProxies() != null && value.getNetworkProxies().size() > 0) {
            registry.removeSubset(prefix + "networkProxies");
            int count = 0;
            for (Iterator iter = value.getNetworkProxies().iterator(); iter.hasNext(); count++) {
                String name = "networkProxies.networkProxy(" + count + ")";
                NetworkProxyConfiguration o = (NetworkProxyConfiguration) iter.next();
                writeNetworkProxyConfiguration(prefix + name + ".", o, registry);
            }
        }
        if (value.getLegacyArtifactPaths() != null && value.getLegacyArtifactPaths().size() > 0) {
            registry.removeSubset(prefix + "legacyArtifactPaths");
            int count = 0;
            for (Iterator iter = value.getLegacyArtifactPaths().iterator(); iter.hasNext(); count++) {
                String name = "legacyArtifactPaths.legacyArtifactPath(" + count + ")";
                LegacyArtifactPath o = (LegacyArtifactPath) iter.next();
                writeLegacyArtifactPath(prefix + name + ".", o, registry);
            }
        }
        if (value.getRepositoryScanning() != null) {
            writeRepositoryScanningConfiguration(prefix + "repositoryScanning.", value.getRepositoryScanning(), registry);
        }
        if (value.getWebapp() != null) {
            writeWebappConfiguration(prefix + "webapp.", value.getWebapp(), registry);
        }
        if (value.getOrganisationInfo() != null) {
            writeOrganisationInformation(prefix + "organisationInfo.", value.getOrganisationInfo(), registry);
        }
        if (value.getNetworkConfiguration() != null) {
            writeNetworkConfiguration(prefix + "networkConfiguration.", value.getNetworkConfiguration(), registry);
        }
        if (value.getRedbackRuntimeConfiguration() != null) {
            writeRedbackRuntimeConfiguration(prefix + "redbackRuntimeConfiguration.", value.getRedbackRuntimeConfiguration(), registry);
        }
        if (value.getArchivaRuntimeConfiguration() != null) {
            writeArchivaRuntimeConfiguration(prefix + "archivaRuntimeConfiguration.", value.getArchivaRuntimeConfiguration(), registry);
        }
        if (value.getProxyConnectorRuleConfigurations() != null && value.getProxyConnectorRuleConfigurations().size() > 0) {
            registry.removeSubset(prefix + "proxyConnectorRuleConfigurations");
            int count = 0;
            for (Iterator iter = value.getProxyConnectorRuleConfigurations().iterator(); iter.hasNext(); count++) {
                String name = "proxyConnectorRuleConfigurations.proxyConnectorRuleConfiguration(" + count + ")";
                ProxyConnectorRuleConfiguration o = (ProxyConnectorRuleConfiguration) iter.next();
                writeProxyConnectorRuleConfiguration(prefix + name + ".", o, registry);
            }
        }
        if (value.getArchivaDefaultConfiguration() != null) {
            writeArchivaDefaultConfiguration(prefix + "archivaDefaultConfiguration.", value.getArchivaDefaultConfiguration(), registry);
        }
    }
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) LegacyArtifactPath(org.apache.archiva.configuration.model.LegacyArtifactPath) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) Iterator(java.util.Iterator) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration)

Aggregations

RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)28 EditableRepositoryGroup (org.apache.archiva.repository.EditableRepositoryGroup)11 RepositoryException (org.apache.archiva.repository.RepositoryException)10 Configuration (org.apache.archiva.configuration.model.Configuration)9 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)9 RepositoryGroup (org.apache.archiva.repository.RepositoryGroup)9 ArrayList (java.util.ArrayList)8 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)7 Map (java.util.Map)5 ValidationError (org.apache.archiva.repository.validation.ValidationError)5 Test (org.junit.Test)5 Test (org.junit.jupiter.api.Test)5 ContextConfiguration (org.springframework.test.context.ContextConfiguration)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4 List (java.util.List)4 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)4 RepositoryProvider (org.apache.archiva.repository.RepositoryProvider)4 RepositoryType (org.apache.archiva.repository.RepositoryType)4 Path (java.nio.file.Path)3