Search in sources :

Example 6 with ProxyConnectorConfiguration

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

Example 7 with ProxyConnectorConfiguration

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

Example 8 with ProxyConnectorConfiguration

use of org.apache.archiva.configuration.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.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 9 with ProxyConnectorConfiguration

use of org.apache.archiva.configuration.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.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ArrayList(java.util.ArrayList) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 10 with ProxyConnectorConfiguration

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

the class RepositoryRegistry method doRemoveRepo.

private void doRemoveRepo(RemoteRepository repo, Configuration configuration) {
    repo.close();
    RemoteRepositoryConfiguration cfg = configuration.findRemoteRepositoryById(repo.getId());
    if (cfg != null) {
        configuration.removeRemoteRepository(cfg);
    }
    List<ProxyConnectorConfiguration> proxyConnectors = new ArrayList<>(configuration.getProxyConnectors());
    for (ProxyConnectorConfiguration proxyConnector : proxyConnectors) {
        if (StringUtils.equals(proxyConnector.getTargetRepoId(), repo.getId())) {
            configuration.removeProxyConnector(proxyConnector);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration)

Aggregations

ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)23 Configuration (org.apache.archiva.configuration.Configuration)9 ArrayList (java.util.ArrayList)7 ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)4 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)4 ProxyConnectorRuleConfiguration (org.apache.archiva.configuration.ProxyConnectorRuleConfiguration)4 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)4 Path (java.nio.file.Path)3 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)3 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)3 WagonFactory (org.apache.archiva.proxy.common.WagonFactory)3 WagonFactoryRequest (org.apache.archiva.proxy.common.WagonFactoryRequest)3 Wagon (org.apache.maven.wagon.Wagon)3 Before (org.junit.Before)3 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 WebRequest (com.gargoylesoftware.htmlunit.WebRequest)2 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)2 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)2 HashMap (java.util.HashMap)1 List (java.util.List)1