Search in sources :

Example 11 with Configuration

use of org.apache.archiva.configuration.Configuration in project archiva by apache.

the class DefaultProxyConnectorAdmin method updateProxyConnector.

// FIXME care take of proxyConnectorRules !
@Override
public Boolean updateProxyConnector(ProxyConnector proxyConnector, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    ProxyConnectorConfiguration proxyConnectorConfiguration = findProxyConnector(proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration);
    configuration.removeProxyConnector(proxyConnectorConfiguration);
    configuration.addProxyConnector(getProxyConnectorConfiguration(proxyConnector));
    saveConfiguration(configuration);
    triggerAuditEvent(proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null, AuditEvent.MODIFY_PROXY_CONNECTOR, auditInformation);
    return Boolean.TRUE;
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration)

Example 12 with Configuration

use of org.apache.archiva.configuration.Configuration in project archiva by apache.

the class DefaultProxyConnectorRuleAdmin method deleteProxyConnectorRule.

@Override
public void deleteProxyConnectorRule(ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    // key is the pattern !!
    // recreate a list without the pattern
    boolean toSave = false;
    List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations = new ArrayList<>();
    for (ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : configuration.getProxyConnectorRuleConfigurations()) {
        if (StringUtils.equals(proxyConnectorRuleConfiguration.getPattern(), proxyConnectorRule.getPattern()) && StringUtils.equals(proxyConnectorRuleConfiguration.getRuleType(), proxyConnectorRule.getProxyConnectorRuleType().getRuleType())) {
            toSave = true;
        } else {
            proxyConnectorRuleConfigurations.add(proxyConnectorRuleConfiguration);
        }
    }
    if (toSave) {
        configuration.setProxyConnectorRuleConfigurations(proxyConnectorRuleConfigurations);
        saveConfiguration(configuration);
    }
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ArrayList(java.util.ArrayList)

Example 13 with Configuration

use of org.apache.archiva.configuration.Configuration in project archiva by apache.

the class DefaultProxyConnectorRuleAdmin method addProxyConnectorRule.

@Override
public void addProxyConnectorRule(ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation) throws RepositoryAdminException {
    ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration = new ProxyConnectorRuleConfiguration();
    proxyConnectorRuleConfiguration.setPattern(proxyConnectorRule.getPattern());
    proxyConnectorRuleConfiguration.setRuleType(proxyConnectorRule.getProxyConnectorRuleType().getRuleType());
    for (ProxyConnector proxyConnector : proxyConnectorRule.getProxyConnectors()) {
        ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
        proxyConnectorConfiguration.setSourceRepoId(proxyConnector.getSourceRepoId());
        proxyConnectorConfiguration.setTargetRepoId(proxyConnector.getTargetRepoId());
        proxyConnectorRuleConfiguration.getProxyConnectors().add(proxyConnectorConfiguration);
    }
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    configuration.getProxyConnectorRuleConfigurations().add(proxyConnectorRuleConfiguration);
    saveConfiguration(configuration);
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 14 with Configuration

use of org.apache.archiva.configuration.Configuration in project archiva by apache.

the class DefaultProxyConnectorRuleAdmin method updateProxyConnectorRule.

@Override
public void updateProxyConnectorRule(ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    for (ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : configuration.getProxyConnectorRuleConfigurations()) {
        if (StringUtils.equals(proxyConnectorRuleConfiguration.getPattern(), proxyConnectorRule.getPattern()) && StringUtils.equals(proxyConnectorRuleConfiguration.getRuleType(), proxyConnectorRule.getProxyConnectorRuleType().getRuleType())) {
            List<ProxyConnectorConfiguration> proxyConnectors = new ArrayList<>(proxyConnectorRule.getProxyConnectors().size());
            for (ProxyConnector proxyConnector : proxyConnectorRule.getProxyConnectors()) {
                ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
                proxyConnectorConfiguration.setSourceRepoId(proxyConnector.getSourceRepoId());
                proxyConnectorConfiguration.setTargetRepoId(proxyConnector.getTargetRepoId());
                proxyConnectors.add(proxyConnectorConfiguration);
            }
            proxyConnectorRuleConfiguration.setProxyConnectors(proxyConnectors);
            saveConfiguration(configuration);
        }
    }
}
Also used : ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.ProxyConnectorRuleConfiguration) ArrayList(java.util.ArrayList) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector)

Example 15 with Configuration

use of org.apache.archiva.configuration.Configuration in project archiva by apache.

the class DefaultArchivaAdministration method removeFileType.

@Override
public void removeFileType(String fileTypeId, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    org.apache.archiva.configuration.FileType fileType = new org.apache.archiva.configuration.FileType();
    fileType.setId(fileTypeId);
    configuration.getRepositoryScanning().removeFileType(fileType);
    saveConfiguration(configuration);
}
Also used : UiConfiguration(org.apache.archiva.admin.model.beans.UiConfiguration) NetworkConfiguration(org.apache.archiva.admin.model.beans.NetworkConfiguration) Configuration(org.apache.archiva.configuration.Configuration) WebappConfiguration(org.apache.archiva.configuration.WebappConfiguration) FileType(org.apache.archiva.admin.model.beans.FileType)

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