Search in sources :

Example 26 with ProxyConnectorConfiguration

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

the class DefaultProxyConnectorAdmin method getProxyConnectors.

@Override
public List<ProxyConnector> getProxyConnectors() throws RepositoryAdminException {
    List<ProxyConnectorConfiguration> proxyConnectorConfigurations = getArchivaConfiguration().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 27 with ProxyConnectorConfiguration

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

the class DefaultProxyConnectorAdmin method addProxyConnector.

@Override
public Boolean addProxyConnector(ProxyConnector proxyConnector, AuditInformation auditInformation) throws RepositoryAdminException {
    if (getProxyConnector(proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId()) != null) {
        throw new RepositoryAdminException("Unable to add proxy connector, as one already exists with source repository id [" + proxyConnector.getSourceRepoId() + "] and target repository id [" + proxyConnector.getTargetRepoId() + "].");
    }
    validateProxyConnector(proxyConnector);
    proxyConnector.setBlackListPatterns(unescapePatterns(proxyConnector.getBlackListPatterns()));
    proxyConnector.setWhiteListPatterns(unescapePatterns(proxyConnector.getWhiteListPatterns()));
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    ProxyConnectorConfiguration proxyConnectorConfiguration = getProxyConnectorConfiguration(proxyConnector);
    configuration.addProxyConnector(proxyConnectorConfiguration);
    saveConfiguration(configuration);
    triggerAuditEvent(proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null, AuditEvent.ADD_PROXY_CONNECTOR, auditInformation);
    return Boolean.TRUE;
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 28 with ProxyConnectorConfiguration

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

Example 29 with ProxyConnectorConfiguration

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

the class ArchivaProxyRegistry method updateConnectors.

private void updateConnectors() {
    List<ProxyConnectorConfiguration> proxyConnectorConfigurations = getArchivaConfiguration().getConfiguration().getProxyConnectors();
    connectorList = proxyConnectorConfigurations.stream().map(this::buildProxyConnector).filter(Optional::isPresent).map(Optional::get).sorted(comparator).collect(Collectors.toList());
    connectorMap = connectorList.stream().collect(Collectors.groupingBy(a -> a.getSourceRepository().getId()));
    for (RepositoryProxyHandler handler : repositoryProxyHandlers) {
        handler.setProxyConnectors(connectorList);
    }
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryProxyHandler(org.apache.archiva.proxy.model.RepositoryProxyHandler)

Example 30 with ProxyConnectorConfiguration

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

the class MetadataTools method initConfigVariables.

private void initConfigVariables() {
    assert (this.artifactPatterns != null);
    assert (proxies != null);
    synchronized (this.artifactPatterns) {
        this.artifactPatterns.clear();
        this.artifactPatterns.addAll(filetypes.getFileTypePatterns(FileTypes.ARTIFACTS));
    }
    synchronized (proxies) {
        this.proxies.clear();
        List<ProxyConnectorConfiguration> proxyConfigs = configuration.getConfiguration().getProxyConnectors();
        for (ProxyConnectorConfiguration proxyConfig : proxyConfigs) {
            String key = proxyConfig.getSourceRepoId();
            Set<String> remoteRepoIds = this.proxies.get(key);
            if (remoteRepoIds == null) {
                remoteRepoIds = new HashSet<String>();
            }
            remoteRepoIds.add(proxyConfig.getTargetRepoId());
            this.proxies.put(key, remoteRepoIds);
        }
    }
}
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