Search in sources :

Example 41 with Configuration

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

the class DefaultArchivaAdministration method addLegacyArtifactPath.

@Override
public void addLegacyArtifactPath(LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    configuration.addLegacyArtifactPath(getModelMapper().map(legacyArtifactPath, org.apache.archiva.configuration.LegacyArtifactPath.class));
    saveConfiguration(configuration);
    triggerAuditEvent("", "", AuditEvent.ADD_LEGACY_PATH, auditInformation);
}
Also used : LegacyArtifactPath(org.apache.archiva.admin.model.beans.LegacyArtifactPath) 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)

Example 42 with Configuration

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

the class DefaultArchivaAdministration method addInvalidContentConsumer.

@Override
public void addInvalidContentConsumer(String invalidContentConsumer, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    if (configuration.getRepositoryScanning().getInvalidContentConsumers().contains(invalidContentConsumer)) {
        log.warn("skip adding invalidContentConsumer {} as already here", invalidContentConsumer);
        return;
    }
    configuration.getRepositoryScanning().addInvalidContentConsumer(invalidContentConsumer);
    saveConfiguration(configuration);
    triggerAuditEvent("", "", AuditEvent.ENABLE_REPO_CONSUMER, auditInformation);
}
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)

Example 43 with Configuration

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

the class DefaultArchivaAdministration method removeFileTypePattern.

@Override
public void removeFileTypePattern(String fileTypeId, String pattern, AuditInformation auditInformation) throws RepositoryAdminException {
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    org.apache.archiva.configuration.FileType fileType = getFileTypeById(fileTypeId, configuration);
    if (fileType == null) {
        return;
    }
    fileType.removePattern(pattern);
    saveConfiguration(configuration);
    triggerAuditEvent("", "", AuditEvent.REMOVE_PATTERN, auditInformation);
}
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)

Example 44 with Configuration

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

the class DefaultRepositoryGroupAdmin method addRepositoryGroup.

@Override
public Boolean addRepositoryGroup(RepositoryGroup repositoryGroup, AuditInformation auditInformation) throws RepositoryAdminException {
    validateRepositoryGroup(repositoryGroup, false);
    validateManagedRepositoriesExists(repositoryGroup.getRepositories());
    RepositoryGroupConfiguration repositoryGroupConfiguration = new RepositoryGroupConfiguration();
    repositoryGroupConfiguration.setId(repositoryGroup.getId());
    repositoryGroupConfiguration.setRepositories(repositoryGroup.getRepositories());
    repositoryGroupConfiguration.setMergedIndexPath(repositoryGroup.getMergedIndexPath());
    repositoryGroupConfiguration.setMergedIndexTtl(repositoryGroup.getMergedIndexTtl());
    repositoryGroupConfiguration.setCronExpression(repositoryGroup.getCronExpression());
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    configuration.addRepositoryGroup(repositoryGroupConfiguration);
    saveConfiguration(configuration);
    triggerAuditEvent(repositoryGroup.getId(), null, AuditEvent.ADD_REPO_GROUP, auditInformation);
    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 45 with Configuration

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

the class DefaultRepositoryGroupAdmin method validateRepositoryGroup.

public Boolean validateRepositoryGroup(RepositoryGroup repositoryGroup, boolean updateMode) throws RepositoryAdminException {
    String repoGroupId = repositoryGroup.getId();
    if (StringUtils.isBlank(repoGroupId)) {
        throw new RepositoryAdminException("repositoryGroup id cannot be empty");
    }
    if (repoGroupId.length() > 100) {
        throw new RepositoryAdminException("Identifier [" + repoGroupId + "] is over the maximum limit of 100 characters");
    }
    Matcher matcher = REPO_GROUP_ID_PATTERN.matcher(repoGroupId);
    if (!matcher.matches()) {
        throw new RepositoryAdminException("Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'");
    }
    if (repositoryGroup.getMergedIndexTtl() <= 0) {
        throw new RepositoryAdminException("Merged Index TTL must be greater than 0.");
    }
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    if (configuration.getRepositoryGroupsAsMap().containsKey(repoGroupId)) {
        if (!updateMode) {
            throw new RepositoryAdminException("Unable to add new repository group with id [" + repoGroupId + "], that id already exists as a repository group.");
        }
    } else if (configuration.getManagedRepositoriesAsMap().containsKey(repoGroupId)) {
        throw new RepositoryAdminException("Unable to add new repository group with id [" + repoGroupId + "], that id already exists as a managed repository.");
    } else if (configuration.getRemoteRepositoriesAsMap().containsKey(repoGroupId)) {
        throw new RepositoryAdminException("Unable to add new repository group with id [" + repoGroupId + "], that id already exists as a remote repository.");
    }
    return Boolean.TRUE;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.Configuration) Matcher(java.util.regex.Matcher) 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