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);
}
}
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;
}
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);
}
}
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;
}
}
}
Aggregations