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);
}
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);
}
Aggregations