Search in sources :

Example 51 with RepositoryAdminException

use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.

the class DefaultArchivaAdministration method addFileTypePattern.

@Override
public void addFileTypePattern(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;
    }
    if (fileType.getPatterns().contains(pattern)) {
        throw new RepositoryAdminException("File type [" + fileTypeId + "] already contains pattern [" + pattern + "]");
    }
    fileType.addPattern(pattern);
    saveConfiguration(configuration);
    triggerAuditEvent("", "", AuditEvent.ADD_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) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 52 with RepositoryAdminException

use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.

the class DefaultRepositoryGroupAdmin method addRepositoryToGroup.

@Override
public Boolean addRepositoryToGroup(String repositoryGroupId, String repositoryId, AuditInformation auditInformation) throws RepositoryAdminException {
    RepositoryGroup repositoryGroup = getRepositoryGroup(repositoryGroupId);
    if (repositoryGroup == null) {
        throw new RepositoryAdminException("repositoryGroup with id " + repositoryGroupId + " doesn't not exists so cannot add repository to it");
    }
    if (repositoryGroup.getRepositories().contains(repositoryId)) {
        throw new RepositoryAdminException("repositoryGroup with id " + repositoryGroupId + " already contain repository with id" + repositoryId);
    }
    validateManagedRepositoriesExists(Arrays.asList(repositoryId));
    repositoryGroup.addRepository(repositoryId);
    updateRepositoryGroup(repositoryGroup, auditInformation, false);
    triggerAuditEvent(repositoryGroup.getId(), null, AuditEvent.ADD_REPO_TO_GROUP, auditInformation);
    return Boolean.TRUE;
}
Also used : RepositoryGroup(org.apache.archiva.admin.model.beans.RepositoryGroup) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 53 with RepositoryAdminException

use of org.apache.archiva.admin.model.RepositoryAdminException 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)

Example 54 with RepositoryAdminException

use of org.apache.archiva.admin.model.RepositoryAdminException 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 55 with RepositoryAdminException

use of org.apache.archiva.admin.model.RepositoryAdminException 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)

Aggregations

RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)67 Configuration (org.apache.archiva.configuration.Configuration)18 Path (java.nio.file.Path)15 RedbackRuntimeConfiguration (org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration)14 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)14 RepositoryException (org.apache.archiva.repository.RepositoryException)13 IOException (java.io.IOException)12 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)10 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)10 ArrayList (java.util.ArrayList)9 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)7 NetworkProxy (org.apache.archiva.admin.model.beans.NetworkProxy)6 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)6 IndexUpdateFailedException (org.apache.archiva.indexer.IndexUpdateFailedException)6 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)6 RemoteRepository (org.apache.archiva.repository.RemoteRepository)6 Date (java.util.Date)5 RemoteIndexFeature (org.apache.archiva.repository.features.RemoteIndexFeature)5 PostConstruct (javax.annotation.PostConstruct)4 LdapGroupMapping (org.apache.archiva.admin.model.beans.LdapGroupMapping)4