Search in sources :

Example 41 with ArchivaRestServiceException

use of org.apache.archiva.rest.api.services.ArchivaRestServiceException in project archiva by apache.

the class DefaultArchivaAdministrationService method getKnownContentAdminRepositoryConsumers.

@Override
public List<AdminRepositoryConsumer> getKnownContentAdminRepositoryConsumers() throws ArchivaRestServiceException {
    try {
        AddAdminRepoConsumerClosure addAdminRepoConsumer = new AddAdminRepoConsumerClosure(archivaAdministration.getKnownContentConsumers());
        IterableUtils.forEach(repoConsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer);
        List<AdminRepositoryConsumer> knownContentConsumers = addAdminRepoConsumer.getList();
        knownContentConsumers.sort(AdminRepositoryConsumerComparator.getInstance());
        return knownContentConsumers;
    } catch (RepositoryAdminException e) {
        throw new ArchivaRestServiceException(e.getMessage(), e);
    }
}
Also used : AddAdminRepoConsumerClosure(org.apache.archiva.rest.services.utils.AddAdminRepoConsumerClosure) ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) AdminRepositoryConsumer(org.apache.archiva.rest.api.model.AdminRepositoryConsumer) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 42 with ArchivaRestServiceException

use of org.apache.archiva.rest.api.services.ArchivaRestServiceException in project archiva by apache.

the class DefaultArchivaRuntimeConfigurationService method updateArchivaRuntimeConfiguration.

@Override
public Boolean updateArchivaRuntimeConfiguration(ArchivaRuntimeConfiguration archivaRuntimeConfiguration) throws ArchivaRestServiceException {
    try {
        archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration(archivaRuntimeConfiguration);
        CacheConfiguration cacheConfiguration = archivaRuntimeConfiguration.getUrlFailureCacheConfiguration();
        if (cacheConfiguration != null) {
            usersCache.setTimeToLiveSeconds(cacheConfiguration.getTimeToLiveSeconds());
            usersCache.setTimeToIdleSeconds(cacheConfiguration.getTimeToIdleSeconds());
            usersCache.setMaxElementsOnDisk(cacheConfiguration.getMaxElementsOnDisk());
            usersCache.setMaxElementsInMemory(cacheConfiguration.getMaxElementsInMemory());
        }
        FileLockConfiguration fileLockConfiguration = archivaRuntimeConfiguration.getFileLockConfiguration();
        if (fileLockConfiguration != null) {
            fileLockManager.setTimeout(fileLockConfiguration.getLockingTimeout());
            fileLockManager.setSkipLocking(fileLockConfiguration.isSkipLocking());
        }
    } catch (RepositoryAdminException e) {
        throw new ArchivaRestServiceException(e.getMessage(), e);
    }
    return Boolean.TRUE;
}
Also used : ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) CacheConfiguration(org.apache.archiva.admin.model.beans.CacheConfiguration) FileLockConfiguration(org.apache.archiva.admin.model.beans.FileLockConfiguration)

Example 43 with ArchivaRestServiceException

use of org.apache.archiva.rest.api.services.ArchivaRestServiceException in project archiva by apache.

the class DefaultCommonServices method getAllI18nResources.

@Override
public String getAllI18nResources(String locale) throws ArchivaRestServiceException {
    String cachedi18n = cachei18n.get(StringUtils.isEmpty(locale) ? "en" : StringUtils.lowerCase(locale));
    if (cachedi18n != null) {
        return cachedi18n;
    }
    try {
        Properties all = utilServices.getI18nProperties(locale);
        StringBuilder resourceName = new StringBuilder(RESOURCE_NAME);
        loadResource(all, resourceName, locale);
        String i18n = fromProperties(all);
        cachei18n.put(StringUtils.isEmpty(locale) ? "en" : StringUtils.lowerCase(locale), i18n);
        return i18n;
    } catch (IOException e) {
        throw new ArchivaRestServiceException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
    } catch (RedbackServiceException e) {
        throw new ArchivaRestServiceException(e.getMessage(), e.getHttpErrorCode(), e);
    }
}
Also used : RedbackServiceException(org.apache.archiva.redback.rest.api.services.RedbackServiceException) ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) IOException(java.io.IOException) Properties(java.util.Properties)

Example 44 with ArchivaRestServiceException

use of org.apache.archiva.rest.api.services.ArchivaRestServiceException in project archiva by apache.

the class DefaultProxyConnectorRuleService method validateProxyConnectorRule.

private void validateProxyConnectorRule(ProxyConnectorRule proxyConnectorRule) throws ArchivaRestServiceException {
    if (StringUtils.isEmpty(proxyConnectorRule.getPattern())) {
        ArchivaRestServiceException e = new ArchivaRestServiceException("pattern cannot be empty", null);
        e.setErrorKey("proxy-connector-rule.pattern.empty");
        throw e;
    }
    if (proxyConnectorRule.getProxyConnectors() == null || proxyConnectorRule.getProxyConnectors().isEmpty()) {
        ArchivaRestServiceException e = new ArchivaRestServiceException("proxyConnector rule must have proxyConnectors.", null);
        e.setErrorKey("proxy-connector-rule.pattern.connectors.empty");
        throw e;
    }
    for (ProxyConnectorRule proxyConnectorRule1 : getProxyConnectorRules()) {
        if (StringUtils.equals(proxyConnectorRule.getPattern(), proxyConnectorRule1.getPattern()) && proxyConnectorRule.getProxyConnectorRuleType() == proxyConnectorRule1.getProxyConnectorRuleType()) {
            ArchivaRestServiceException e = new ArchivaRestServiceException("same ProxyConnector rule already exists.", null);
            e.setErrorKey("proxy-connector-rule.pattern.already.exists");
            throw e;
        }
    }
}
Also used : ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) ProxyConnectorRule(org.apache.archiva.admin.model.beans.ProxyConnectorRule)

Aggregations

ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)44 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)18 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)16 RepositorySession (org.apache.archiva.metadata.repository.RepositorySession)15 RepositoryException (org.apache.archiva.repository.RepositoryException)13 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)11 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)10 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)8 Path (java.nio.file.Path)8 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)8 MetadataResolutionException (org.apache.archiva.metadata.repository.MetadataResolutionException)8 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)7 Artifact (org.apache.archiva.maven2.model.Artifact)6 RepositorySearchException (org.apache.archiva.indexer.search.RepositorySearchException)5 MetadataResolver (org.apache.archiva.metadata.repository.MetadataResolver)5 ArtifactReference (org.apache.archiva.model.ArtifactReference)5 SearchResults (org.apache.archiva.indexer.search.SearchResults)4 ArchivaArtifact (org.apache.archiva.model.ArchivaArtifact)4 RepositoryNotFoundException (org.apache.archiva.repository.RepositoryNotFoundException)4