Search in sources :

Example 46 with Configuration

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;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.Configuration)

Example 47 with Configuration

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);
}
Also used : Configuration(org.apache.archiva.configuration.Configuration) NetworkProxyConfiguration(org.apache.archiva.configuration.NetworkProxyConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 48 with 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);
}
Also used : Configuration(org.apache.archiva.configuration.Configuration) NetworkProxyConfiguration(org.apache.archiva.configuration.NetworkProxyConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.NetworkProxyConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 49 with 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);
}
Also used : Configuration(org.apache.archiva.configuration.Configuration) NetworkProxyConfiguration(org.apache.archiva.configuration.NetworkProxyConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.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 50 with 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;
}
Also used : RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) RemoteRepository(org.apache.archiva.repository.RemoteRepository) RepositoryException(org.apache.archiva.repository.RepositoryException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Aggregations

Configuration (org.apache.archiva.configuration.Configuration)63 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)30 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)29 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)21 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)19 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)18 ContextConfiguration (org.springframework.test.context.ContextConfiguration)16 NetworkConfiguration (org.apache.archiva.admin.model.beans.NetworkConfiguration)13 UiConfiguration (org.apache.archiva.admin.model.beans.UiConfiguration)13 WebappConfiguration (org.apache.archiva.configuration.WebappConfiguration)13 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)11 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)11 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)11 Before (org.junit.Before)11 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 Path (java.nio.file.Path)8 RepositoryException (org.apache.archiva.repository.RepositoryException)7 IOException (java.io.IOException)4 NetworkProxyConfiguration (org.apache.archiva.configuration.NetworkProxyConfiguration)4