use of org.apache.archiva.configuration.model.Configuration 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.Configuration 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);
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class DefaultNetworkProxyAdmin method addNetworkProxy.
@Override
public void addNetworkProxy(NetworkProxy networkProxy, AuditInformation auditInformation) throws RepositoryAdminException {
if (networkProxy == null) {
return;
}
if (getNetworkProxy(networkProxy.getId()) != null) {
throw new RepositoryAdminException("cannot add NetworkProxy with id " + networkProxy.getId() + " already exist");
}
Configuration configuration = getArchivaConfiguration().getConfiguration();
configuration.addNetworkProxy(getNetworkProxyConfiguration(networkProxy));
triggerAuditEvent(networkProxy.getId(), null, AuditEvent.ADD_NETWORK_PROXY, auditInformation);
saveConfiguration(configuration);
}
use of org.apache.archiva.configuration.model.Configuration 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;
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class DefaultArchivaRuntimeConfigurationAdmin method updateArchivaRuntimeConfiguration.
@Override
public void updateArchivaRuntimeConfiguration(ArchivaRuntimeConfiguration archivaRuntimeConfiguration) throws RepositoryAdminException {
Configuration configuration = archivaConfiguration.getConfiguration();
configuration.setArchivaRuntimeConfiguration(build(archivaRuntimeConfiguration));
try {
archivaConfiguration.save(configuration);
} catch (RegistryException e) {
throw new RepositoryAdminException(e.getMessage(), e);
} catch (IndeterminateConfigurationException e) {
throw new RepositoryAdminException(e.getMessage(), e);
}
}
Aggregations