Search in sources :

Example 1 with ProxyConnectorRuleConfiguration

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

the class ConfigurationRegistryReader method readProxyConnectorRuleConfiguration.

private ProxyConnectorRuleConfiguration readProxyConnectorRuleConfiguration(String prefix, Registry registry) {
    ProxyConnectorRuleConfiguration value = new ProxyConnectorRuleConfiguration();
    // String ruleType = registry.getString( prefix + "ruleType", value.getRuleType() );
    List<String> ruleTypeList = registry.getList(prefix + "ruleType");
    String ruleType = value.getRuleType();
    if (ruleTypeList != null && !ruleTypeList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = ruleTypeList.size(); i < size; i++) {
            sb.append(ruleTypeList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        ruleType = sb.toString();
    }
    value.setRuleType(ruleType);
    // String pattern = registry.getString( prefix + "pattern", value.getPattern() );
    List<String> patternList = registry.getList(prefix + "pattern");
    String pattern = value.getPattern();
    if (patternList != null && !patternList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = patternList.size(); i < size; i++) {
            sb.append(patternList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        pattern = sb.toString();
    }
    value.setPattern(pattern);
    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);
    return value;
}
Also used : List(java.util.List) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) Iterator(java.util.Iterator) List(java.util.List) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration)

Example 2 with ProxyConnectorRuleConfiguration

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

the class DefaultProxyConnectorRuleAdmin method deleteProxyConnectorRule.

@Override
public void deleteProxyConnectorRule(ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    // key is the pattern !!
    // recreate a list without the pattern
    boolean toSave = false;
    List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations = new ArrayList<>();
    for (ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : configuration.getProxyConnectorRuleConfigurations()) {
        if (StringUtils.equals(proxyConnectorRuleConfiguration.getPattern(), proxyConnectorRule.getPattern()) && StringUtils.equals(proxyConnectorRuleConfiguration.getRuleType(), proxyConnectorRule.getProxyConnectorRuleType().getRuleType())) {
            toSave = true;
        } else {
            proxyConnectorRuleConfigurations.add(proxyConnectorRuleConfiguration);
        }
    }
    if (toSave) {
        configuration.setProxyConnectorRuleConfigurations(proxyConnectorRuleConfigurations);
        saveConfiguration(configuration);
    }
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) ArrayList(java.util.ArrayList)

Example 3 with ProxyConnectorRuleConfiguration

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

the class DefaultProxyConnectorRuleAdmin method updateProxyConnectorRule.

@Override
public void updateProxyConnectorRule(ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    for (ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : configuration.getProxyConnectorRuleConfigurations()) {
        if (StringUtils.equals(proxyConnectorRuleConfiguration.getPattern(), proxyConnectorRule.getPattern()) && StringUtils.equals(proxyConnectorRuleConfiguration.getRuleType(), proxyConnectorRule.getProxyConnectorRuleType().getRuleType())) {
            List<ProxyConnectorConfiguration> proxyConnectors = new ArrayList<>(proxyConnectorRule.getProxyConnectors().size());
            for (ProxyConnector proxyConnector : proxyConnectorRule.getProxyConnectors()) {
                ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
                proxyConnectorConfiguration.setSourceRepoId(proxyConnector.getSourceRepoId());
                proxyConnectorConfiguration.setTargetRepoId(proxyConnector.getTargetRepoId());
                proxyConnectors.add(proxyConnectorConfiguration);
            }
            proxyConnectorRuleConfiguration.setProxyConnectors(proxyConnectors);
            saveConfiguration(configuration);
        }
    }
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) ArrayList(java.util.ArrayList) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 4 with ProxyConnectorRuleConfiguration

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

the class DefaultProxyConnectorRuleAdmin method addProxyConnectorRule.

@Override
public void addProxyConnectorRule(ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation) throws RepositoryAdminException {
    ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration = new ProxyConnectorRuleConfiguration();
    proxyConnectorRuleConfiguration.setPattern(proxyConnectorRule.getPattern());
    proxyConnectorRuleConfiguration.setRuleType(proxyConnectorRule.getProxyConnectorRuleType().getRuleType());
    for (ProxyConnector proxyConnector : proxyConnectorRule.getProxyConnectors()) {
        ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
        proxyConnectorConfiguration.setSourceRepoId(proxyConnector.getSourceRepoId());
        proxyConnectorConfiguration.setTargetRepoId(proxyConnector.getTargetRepoId());
        proxyConnectorRuleConfiguration.getProxyConnectors().add(proxyConnectorConfiguration);
    }
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    configuration.getProxyConnectorRuleConfigurations().add(proxyConnectorRuleConfiguration);
    saveConfiguration(configuration);
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 5 with ProxyConnectorRuleConfiguration

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

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