Search in sources :

Example 11 with NetworkProxyConfiguration

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

the class DefaultNetworkProxyAdmin method deleteNetworkProxy.

@Override
public void deleteNetworkProxy(String networkProxyId, AuditInformation auditInformation) throws RepositoryAdminException {
    NetworkProxy networkProxy = getNetworkProxy(networkProxyId);
    if (networkProxy == null) {
        throw new RepositoryAdminException("cannot delete NetworkProxy with id " + networkProxyId + " as not exist");
    }
    for (RemoteRepository repo : repositoryRegistry.getRemoteRepositories()) {
        if (repo.supportsFeature(RemoteIndexFeature.class)) {
            RemoteIndexFeature rif = repo.getFeature(RemoteIndexFeature.class);
            if (networkProxyId.equals(rif.getProxyId())) {
                rif.setProxyId(null);
                try {
                    repositoryRegistry.putRepository(repo);
                } catch (RepositoryException e) {
                    log.error("Could not update repository {}", repo.getId(), e);
                }
            }
        }
    }
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration(networkProxy);
    configuration.removeNetworkProxy(networkProxyConfiguration);
    saveConfiguration(configuration);
    triggerAuditEvent(networkProxy.getId(), null, AuditEvent.DELETE_NETWORK_PROXY, auditInformation);
}
Also used : NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) RemoteIndexFeature(org.apache.archiva.repository.features.RemoteIndexFeature) RemoteRepository(org.apache.archiva.repository.RemoteRepository) RepositoryException(org.apache.archiva.repository.RepositoryException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) NetworkProxy(org.apache.archiva.admin.model.beans.NetworkProxy)

Example 12 with NetworkProxyConfiguration

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

the class DefaultNetworkProxyAdmin method updateNetworkProxy.

@Override
public void updateNetworkProxy(NetworkProxy networkProxy, AuditInformation auditInformation) throws RepositoryAdminException {
    if (networkProxy == null) {
        return;
    }
    if (getNetworkProxy(networkProxy.getId()) == null) {
        throw new RepositoryAdminException("cannot update NetworkProxy with id " + networkProxy.getId() + " as not exist");
    }
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration(networkProxy);
    configuration.removeNetworkProxy(networkProxyConfiguration);
    configuration.addNetworkProxy(networkProxyConfiguration);
    triggerAuditEvent(networkProxy.getId(), null, AuditEvent.MODIFY_NETWORK_PROXY, auditInformation);
    saveConfiguration(configuration);
}
Also used : NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Aggregations

NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)12 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)6 Configuration (org.apache.archiva.configuration.model.Configuration)5 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)5 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)4 Path (java.nio.file.Path)3 LegacyArtifactPath (org.apache.archiva.configuration.model.LegacyArtifactPath)3 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)3 Test (org.junit.Test)3 Iterator (java.util.Iterator)2 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)2 ProxyConnectorRuleConfiguration (org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration)2 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)2 WebappConfiguration (org.apache.archiva.configuration.model.WebappConfiguration)2 RepositoryProxyHandler (org.apache.archiva.proxy.model.RepositoryProxyHandler)2 List (java.util.List)1 Properties (java.util.Properties)1 StringTokenizer (java.util.StringTokenizer)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1