Search in sources :

Example 1 with ProxyConnectorConfiguration

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

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

the class MetadataToolsTest method removeProxyConnector.

private void removeProxyConnector(String sourceRepoId, String targetRepoId) {
    ProxyConnectorConfiguration toRemove = null;
    for (ProxyConnectorConfiguration pcc : config.getConfiguration().getProxyConnectors()) {
        if (pcc.getTargetRepoId().equals(targetRepoId) && pcc.getSourceRepoId().equals(sourceRepoId)) {
            toRemove = pcc;
        }
    }
    if (toRemove != null) {
        config.getConfiguration().removeProxyConnector(toRemove);
        // XXX
        String prefix = "proxyConnectors.proxyConnector(" + "1" + ")";
        config.triggerChange(prefix + ".sourceRepoId", toRemove.getSourceRepoId());
        config.triggerChange(prefix + ".targetRepoId", toRemove.getTargetRepoId());
        config.triggerChange(prefix + ".proxyId", toRemove.getProxyId());
        config.triggerChange(prefix + ".policies.releases", toRemove.getPolicy("releases", ""));
        config.triggerChange(prefix + ".policies.checksum", toRemove.getPolicy("checksum", ""));
        config.triggerChange(prefix + ".policies.snapshots", toRemove.getPolicy("snapshots", ""));
        config.triggerChange(prefix + ".policies.cache-failures", toRemove.getPolicy("cache-failures", ""));
    }
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration)

Example 3 with ProxyConnectorConfiguration

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

the class MetadataToolsTest method createProxyConnector.

private void createProxyConnector(String sourceRepoId, String targetRepoId) {
    ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
    connectorConfig.setSourceRepoId(sourceRepoId);
    connectorConfig.setTargetRepoId(targetRepoId);
    connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE.getId());
    connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS.getId());
    connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.ALWAYS.getId());
    connectorConfig.addPolicy(ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO.getId());
    int count = config.getConfiguration().getProxyConnectors().size();
    config.getConfiguration().addProxyConnector(connectorConfig);
    // Proper Triggering ...
    String prefix = "proxyConnectors.proxyConnector(" + count + ")";
    config.triggerChange(prefix + ".sourceRepoId", connectorConfig.getSourceRepoId());
    config.triggerChange(prefix + ".targetRepoId", connectorConfig.getTargetRepoId());
    config.triggerChange(prefix + ".proxyId", connectorConfig.getProxyId());
    config.triggerChange(prefix + ".policies.releases", connectorConfig.getPolicy("releases", ""));
    config.triggerChange(prefix + ".policies.checksum", connectorConfig.getPolicy("checksum", ""));
    config.triggerChange(prefix + ".policies.snapshots", connectorConfig.getPolicy("snapshots", ""));
    config.triggerChange(prefix + ".policies.cache-failures", connectorConfig.getPolicy("cache-failures", ""));
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration)

Example 4 with ProxyConnectorConfiguration

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

the class MockRepoAdmin method getProxyConnectors.

@Override
public List<ProxyConnector> getProxyConnectors() throws RepositoryAdminException {
    List<ProxyConnectorConfiguration> proxyConnectorConfigurations = archivaConfiguration.getConfiguration().getProxyConnectors();
    List<ProxyConnector> proxyConnectors = new ArrayList<>(proxyConnectorConfigurations.size());
    for (ProxyConnectorConfiguration configuration : proxyConnectorConfigurations) {
        proxyConnectors.add(getProxyConnector(configuration));
    }
    Collections.sort(proxyConnectors, ProxyConnectorOrderComparator.getInstance());
    return proxyConnectors;
}
Also used : ArrayList(java.util.ArrayList) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 5 with ProxyConnectorConfiguration

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

the class AbstractRepositoryServletProxiedTestCase method setupConnector.

private void setupConnector(String repoId, RemoteRepoInfo remoteRepo, PolicyOption releasesPolicy, PolicyOption snapshotsPolicy) {
    ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
    connector.setSourceRepoId(repoId);
    connector.setTargetRepoId(remoteRepo.id);
    connector.addPolicy(ProxyConnectorConfiguration.POLICY_RELEASES, releasesPolicy.getId());
    connector.addPolicy(ProxyConnectorConfiguration.POLICY_SNAPSHOTS, snapshotsPolicy.getId());
    connector.addPolicy(ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE.getId());
    connector.addPolicy(ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO.getId());
    archivaConfiguration.getConfiguration().addProxyConnector(connector);
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration)

Aggregations

ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)35 ArrayList (java.util.ArrayList)11 Configuration (org.apache.archiva.configuration.model.Configuration)11 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)9 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)9 Path (java.nio.file.Path)6 ProxyConnectorRuleConfiguration (org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration)6 ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)5 Iterator (java.util.Iterator)4 List (java.util.List)4 NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)4 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)4 Wagon (org.apache.maven.wagon.Wagon)4 Before (org.junit.Before)4 ContextConfiguration (org.springframework.test.context.ContextConfiguration)4 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)3 LegacyArtifactPath (org.apache.archiva.configuration.model.LegacyArtifactPath)3 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)3 ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)3 WagonFactory (org.apache.archiva.maven.common.proxy.WagonFactory)3