use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultRepositoryGroupAdmin method updateRepositoryGroup.
private Boolean updateRepositoryGroup(RepositoryGroup repositoryGroup, AuditInformation auditInformation, boolean triggerAuditEvent) throws RepositoryAdminException {
validateRepositoryGroup(repositoryGroup, true);
validateManagedRepositoriesExists(repositoryGroup.getRepositories());
Configuration configuration = getArchivaConfiguration().getConfiguration();
RepositoryGroupConfiguration repositoryGroupConfiguration = configuration.getRepositoryGroupsAsMap().get(repositoryGroup.getId());
configuration.removeRepositoryGroup(repositoryGroupConfiguration);
repositoryGroupConfiguration.setRepositories(repositoryGroup.getRepositories());
repositoryGroupConfiguration.setMergedIndexPath(repositoryGroup.getMergedIndexPath());
repositoryGroupConfiguration.setMergedIndexTtl(repositoryGroup.getMergedIndexTtl());
repositoryGroupConfiguration.setCronExpression(repositoryGroup.getCronExpression());
configuration.addRepositoryGroup(repositoryGroupConfiguration);
saveConfiguration(configuration);
if (triggerAuditEvent) {
triggerAuditEvent(repositoryGroup.getId(), null, AuditEvent.MODIFY_REPO_GROUP, auditInformation);
}
mergedRemoteIndexesScheduler.unschedule(repositoryGroup);
mergedRemoteIndexesScheduler.schedule(repositoryGroup, getMergedIndexDirectory(repositoryGroup.getId()));
return Boolean.TRUE;
}
use of org.apache.archiva.configuration.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.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.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");
}
Configuration configuration = getArchivaConfiguration().getConfiguration();
NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration(networkProxy);
configuration.removeNetworkProxy(networkProxyConfiguration);
for (RemoteRepository repo : repositoryRegistry.getRemoteRepositories()) {
if (repo.supportsFeature(RemoteIndexFeature.class)) {
RemoteIndexFeature rif = repo.getFeature(RemoteIndexFeature.class).get();
if (networkProxyId.equals(rif.getProxyId())) {
rif.setProxyId(null);
try {
repositoryRegistry.putRepository(repo, configuration);
} catch (RepositoryException e) {
log.error("Could not update repository {}", repo.getId(), e);
}
}
}
}
triggerAuditEvent(networkProxy.getId(), null, AuditEvent.DELETE_NETWORK_PROXY, auditInformation);
saveConfiguration(configuration);
}
use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultRemoteRepositoryAdmin method deleteRemoteRepository.
@Override
public Boolean deleteRemoteRepository(String repositoryId, AuditInformation auditInformation) throws RepositoryAdminException {
triggerAuditEvent(repositoryId, null, AuditEvent.DELETE_REMOTE_REPO, auditInformation);
Configuration configuration = getArchivaConfiguration().getConfiguration();
RemoteRepository repo = repositoryRegistry.getRemoteRepository(repositoryId);
if (repo == null) {
throw new RepositoryAdminException("Could not delete repository " + repositoryId + ". The repository does not exist.");
}
try {
repositoryRegistry.removeRepository(repo, configuration);
} catch (RepositoryException e) {
log.error("Deletion of remote repository failed {}: {}", repo.getId(), e.getMessage(), e);
throw new RepositoryAdminException("Could not delete remote repository" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
}
saveConfiguration(configuration);
return Boolean.TRUE;
}
Aggregations