Search in sources :

Example 11 with ProxyConnectorConfiguration

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

the class DefaultProxyConnectorAdmin method updateProxyConnector.

// FIXME care take of proxyConnectorRules !
@Override
public Boolean updateProxyConnector(ProxyConnector proxyConnector, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    ProxyConnectorConfiguration proxyConnectorConfiguration = findProxyConnector(proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration);
    configuration.removeProxyConnector(proxyConnectorConfiguration);
    configuration.addProxyConnector(getProxyConnectorConfiguration(proxyConnector));
    saveConfiguration(configuration);
    triggerAuditEvent(proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null, AuditEvent.MODIFY_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)

Example 12 with ProxyConnectorConfiguration

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

the class DefaultProxyConnectorAdmin method deleteProxyConnector.

// FIXME take care of proxyConnectorRules !
@Override
public Boolean deleteProxyConnector(ProxyConnector proxyConnector, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    ProxyConnectorConfiguration proxyConnectorConfiguration = findProxyConnector(proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration);
    if (proxyConnectorConfiguration == null) {
        throw new RepositoryAdminException("unable to find ProxyConnector with source " + proxyConnector.getSourceRepoId() + " and target " + proxyConnector.getTargetRepoId());
    }
    configuration.removeProxyConnector(proxyConnectorConfiguration);
    saveConfiguration(configuration);
    triggerAuditEvent(proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null, AuditEvent.DELETE_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 13 with ProxyConnectorConfiguration

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

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

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

the class ProxyConnectorConfigurationOrderComparatorTest method assertProxyOrder.

private void assertProxyOrder(String[] ids, List<ProxyConnectorConfiguration> proxies) {
    assertEquals("Proxies.size() == ids.length", ids.length, proxies.size());
    int orderFailedAt = -1;
    for (int i = 0; i < ids.length; i++) {
        if (!StringUtils.equals(ids[i], proxies.get(i).getProxyId())) {
            orderFailedAt = i;
            break;
        }
    }
    if (orderFailedAt >= 0) {
        StringBuilder msg = new StringBuilder();
        msg.append("Failed expected order of the proxies <");
        msg.append(StringUtils.join(ids, ", "));
        msg.append(">, actual <");
        boolean needsComma = false;
        for (ProxyConnectorConfiguration proxy : proxies) {
            if (needsComma) {
                msg.append(", ");
            }
            msg.append(proxy.getProxyId());
            needsComma = true;
        }
        msg.append("> failure at index <").append(orderFailedAt).append(">.");
        fail(msg.toString());
    }
}
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