use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultRedbackRuntimeConfigurationService method getRedbackRuntimeConfiguration.
@Override
public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration() throws ArchivaRestServiceException {
try {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
log.debug("getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration);
return redbackRuntimeConfiguration;
} catch (RepositoryAdminException e) {
throw new ArchivaRestServiceException(e.getMessage(), e);
}
}
use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultManagedRepositoriesService method createSnippet.
private String createSnippet(ManagedRepository repo) throws ArchivaRestServiceException {
try {
StringBuilder snippet = new StringBuilder();
snippet.append("<project>\n");
snippet.append(" ...\n");
snippet.append(" <distributionManagement>\n");
String distRepoName = "repository";
if (repo.isSnapshots()) {
distRepoName = "snapshotRepository";
}
snippet.append(" <").append(distRepoName).append(">\n");
snippet.append(" <id>").append(repo.getId()).append("</id>\n");
snippet.append(" <url>");
snippet.append(getBaseUrl() + "/repository");
snippet.append("/").append(repo.getId()).append("/").append("</url>\n");
if (!"default".equals(repo.getLayout())) {
snippet.append(" <layout>").append(repo.getLayout()).append("</layout>");
}
snippet.append(" </").append(distRepoName).append(">\n");
snippet.append(" </distributionManagement>\n");
snippet.append("\n");
snippet.append(" <repositories>\n");
snippet.append(" <repository>\n");
snippet.append(" <id>").append(repo.getId()).append("</id>\n");
snippet.append(" <name>").append(repo.getName()).append("</name>\n");
snippet.append(" <url>");
snippet.append(getBaseUrl() + "/repository");
snippet.append("/").append(repo.getId()).append("/");
snippet.append("</url>\n");
if (!"default".equals(repo.getLayout())) {
snippet.append(" <layout>").append(repo.getLayout()).append("</layout>\n");
}
snippet.append(" <releases>\n");
snippet.append(" <enabled>").append(Boolean.valueOf(repo.isReleases())).append("</enabled>\n");
snippet.append(" </releases>\n");
snippet.append(" <snapshots>\n");
snippet.append(" <enabled>").append(Boolean.valueOf(repo.isSnapshots())).append("</enabled>\n");
snippet.append(" </snapshots>\n");
snippet.append(" </repository>\n");
snippet.append(" </repositories>\n");
snippet.append(" <pluginRepositories>\n");
snippet.append(" <pluginRepository>\n");
snippet.append(" <id>").append(repo.getId()).append("</id>\n");
snippet.append(" <name>").append(repo.getName()).append("</name>\n");
snippet.append(" <url>");
snippet.append(getBaseUrl() + "/repository");
snippet.append("/").append(repo.getId()).append("/");
snippet.append("</url>\n");
if (!"default".equals(repo.getLayout())) {
snippet.append(" <layout>").append(repo.getLayout()).append("</layout>\n");
}
snippet.append(" <releases>\n");
snippet.append(" <enabled>").append(Boolean.valueOf(repo.isReleases())).append("</enabled>\n");
snippet.append(" </releases>\n");
snippet.append(" <snapshots>\n");
snippet.append(" <enabled>").append(Boolean.valueOf(repo.isSnapshots())).append("</enabled>\n");
snippet.append(" </snapshots>\n");
snippet.append(" </pluginRepository>\n");
snippet.append(" </pluginRepositories>\n");
snippet.append(" ...\n");
snippet.append("</project>\n");
return StringEscapeUtils.escapeXml(snippet.toString());
} catch (RepositoryAdminException e) {
throw new ArchivaRestServiceException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
}
}
use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultSystemStatusService method getRepositoryScannerStatistics.
@Override
public List<RepositoryScannerStatistics> getRepositoryScannerStatistics() throws ArchivaRestServiceException {
Set<RepositoryScannerInstance> repositoryScannerInstances = scanner.getInProgressScans();
if (repositoryScannerInstances.isEmpty()) {
return Collections.emptyList();
}
List<RepositoryScannerStatistics> repositoryScannerStatisticsList = new ArrayList<RepositoryScannerStatistics>(repositoryScannerInstances.size());
for (RepositoryScannerInstance instance : repositoryScannerInstances) {
RepositoryScannerStatistics repositoryScannerStatistics = new RepositoryScannerStatistics();
repositoryScannerStatisticsList.add(repositoryScannerStatistics);
try {
repositoryScannerStatistics.setManagedRepository(managedRepositoryAdmin.getManagedRepository(instance.getRepository().getId()));
} catch (RepositoryAdminException e) {
log.error("Could not retrieve repository '{}'", instance.getRepository().getId());
}
repositoryScannerStatistics.setNewFileCount(instance.getStats().getNewFileCount());
repositoryScannerStatistics.setTotalFileCount(instance.getStats().getTotalFileCount());
repositoryScannerStatistics.setConsumerScanningStatistics(mapConsumerScanningStatistics(instance));
}
return repositoryScannerStatisticsList;
}
use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultUserRepositories method getAccessibleRepositories.
private List<ManagedRepository> getAccessibleRepositories(String principal, String operation) throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException {
SecuritySession securitySession = createSession(principal);
List<ManagedRepository> managedRepositories = new ArrayList<>();
try {
List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
for (ManagedRepository repo : repos) {
try {
String repoId = repo.getId();
if (securitySystem.isAuthorized(securitySession, operation, repoId)) {
managedRepositories.add(repo);
}
} catch (AuthorizationException e) {
// swallow.
log.debug("Not authorizing '{}' for repository '{}': {}", principal, repo.getId(), e.getMessage());
}
}
return managedRepositories;
} catch (RepositoryAdminException e) {
throw new ArchivaSecurityException(e.getMessage(), e);
}
}
use of org.apache.archiva.admin.model.RepositoryAdminException in project archiva by apache.
the class DefaultArchivaAdministrationService method getInvalidContentAdminRepositoryConsumers.
@Override
public List<AdminRepositoryConsumer> getInvalidContentAdminRepositoryConsumers() throws ArchivaRestServiceException {
try {
AddAdminRepoConsumerClosure addAdminRepoConsumer = new AddAdminRepoConsumerClosure(archivaAdministration.getInvalidContentConsumers());
IterableUtils.forEach(repoConsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer);
List<AdminRepositoryConsumer> invalidContentConsumers = addAdminRepoConsumer.getList();
invalidContentConsumers.sort(AdminRepositoryConsumerComparator.getInstance());
return invalidContentConsumers;
} catch (RepositoryAdminException e) {
throw new ArchivaRestServiceException(e.getMessage(), e);
}
}
Aggregations