Search in sources :

Example 36 with RepositoryAdminException

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);
    }
}
Also used : ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 37 with RepositoryAdminException

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);
    }
}
Also used : ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 38 with RepositoryAdminException

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;
}
Also used : ArrayList(java.util.ArrayList) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RepositoryScannerInstance(org.apache.archiva.repository.scanner.RepositoryScannerInstance) RepositoryScannerStatistics(org.apache.archiva.rest.api.model.RepositoryScannerStatistics)

Example 39 with RepositoryAdminException

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);
    }
}
Also used : ManagedRepository(org.apache.archiva.admin.model.beans.ManagedRepository) AuthorizationException(org.apache.archiva.redback.authorization.AuthorizationException) SecuritySession(org.apache.archiva.redback.system.SecuritySession) DefaultSecuritySession(org.apache.archiva.redback.system.DefaultSecuritySession) ArrayList(java.util.ArrayList) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 40 with RepositoryAdminException

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

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