Search in sources :

Example 6 with ProxyConnectorRuleConfiguration

use of org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration 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)

Example 7 with ProxyConnectorRuleConfiguration

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

the class DefaultProxyConnectorRuleAdmin method getProxyConnectorRules.

@Override
public List<ProxyConnectorRule> getProxyConnectorRules() throws RepositoryAdminException {
    List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations = getArchivaConfiguration().getConfiguration().getProxyConnectorRuleConfigurations();
    if (proxyConnectorRuleConfigurations.isEmpty()) {
        return Collections.emptyList();
    }
    List<ProxyConnectorRule> proxyConnectorRules = new ArrayList<>(proxyConnectorRuleConfigurations.size());
    for (ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : proxyConnectorRuleConfigurations) {
        ProxyConnectorRule proxyConnectorRule = new ProxyConnectorRule();
        proxyConnectorRule.setPattern(proxyConnectorRuleConfiguration.getPattern());
        proxyConnectorRule.setProxyConnectorRuleType(getProxyConnectorRuleType(proxyConnectorRuleConfiguration.getRuleType()));
        for (ProxyConnectorConfiguration proxyConnectorConfiguration : proxyConnectorRuleConfiguration.getProxyConnectors()) {
            ProxyConnector proxyConnector = new ProxyConnector();
            proxyConnector.setSourceRepoId(proxyConnectorConfiguration.getSourceRepoId());
            proxyConnector.setTargetRepoId(proxyConnectorConfiguration.getTargetRepoId());
            proxyConnectorRule.getProxyConnectors().add(proxyConnector);
        }
        proxyConnectorRules.add(proxyConnectorRule);
    }
    return proxyConnectorRules;
}
Also used : ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) ProxyConnectorRule(org.apache.archiva.admin.model.beans.ProxyConnectorRule) ArrayList(java.util.ArrayList) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Aggregations

ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)7 ProxyConnectorRuleConfiguration (org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration)7 Configuration (org.apache.archiva.configuration.model.Configuration)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)3 List (java.util.List)2 LegacyArtifactPath (org.apache.archiva.configuration.model.LegacyArtifactPath)2 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)2 NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)2 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)2 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)2 ProxyConnectorRule (org.apache.archiva.admin.model.beans.ProxyConnectorRule)1 AbstractRepositoryConfiguration (org.apache.archiva.configuration.model.AbstractRepositoryConfiguration)1 AbstractRepositoryConnectorConfiguration (org.apache.archiva.configuration.model.AbstractRepositoryConnectorConfiguration)1 ArchivaDefaultConfiguration (org.apache.archiva.configuration.model.ArchivaDefaultConfiguration)1 ArchivaRuntimeConfiguration (org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration)1 CacheConfiguration (org.apache.archiva.configuration.model.CacheConfiguration)1 FileLockConfiguration (org.apache.archiva.configuration.model.FileLockConfiguration)1 LdapConfiguration (org.apache.archiva.configuration.model.LdapConfiguration)1