Search in sources :

Example 56 with RepositoryAdminException

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

the class DefaultNetworkProxyAdmin method deleteNetworkProxy.

@Override
public void deleteNetworkProxy(String networkProxyId, AuditInformation auditInformation) throws RepositoryAdminException {
    NetworkProxy networkProxy = getNetworkProxy(networkProxyId);
    if (networkProxy == null) {
        throw new RepositoryAdminException("cannot delete NetworkProxy with id " + networkProxyId + " as not exist");
    }
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration(networkProxy);
    configuration.removeNetworkProxy(networkProxyConfiguration);
    for (RemoteRepository repo : repositoryRegistry.getRemoteRepositories()) {
        if (repo.supportsFeature(RemoteIndexFeature.class)) {
            RemoteIndexFeature rif = repo.getFeature(RemoteIndexFeature.class).get();
            if (networkProxyId.equals(rif.getProxyId())) {
                rif.setProxyId(null);
                try {
                    repositoryRegistry.putRepository(repo, configuration);
                } catch (RepositoryException e) {
                    log.error("Could not update repository {}", repo.getId(), e);
                }
            }
        }
    }
    triggerAuditEvent(networkProxy.getId(), null, AuditEvent.DELETE_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) RemoteIndexFeature(org.apache.archiva.repository.features.RemoteIndexFeature) RemoteRepository(org.apache.archiva.repository.RemoteRepository) RepositoryException(org.apache.archiva.repository.RepositoryException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) NetworkProxy(org.apache.archiva.admin.model.beans.NetworkProxy)

Example 57 with RepositoryAdminException

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

the class DefaultRemoteRepositoryAdmin method deleteRemoteRepository.

@Override
public Boolean deleteRemoteRepository(String repositoryId, AuditInformation auditInformation) throws RepositoryAdminException {
    triggerAuditEvent(repositoryId, null, AuditEvent.DELETE_REMOTE_REPO, auditInformation);
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    RemoteRepository repo = repositoryRegistry.getRemoteRepository(repositoryId);
    if (repo == null) {
        throw new RepositoryAdminException("Could not delete repository " + repositoryId + ". The repository does not exist.");
    }
    try {
        repositoryRegistry.removeRepository(repo, configuration);
    } catch (RepositoryException e) {
        log.error("Deletion of remote repository failed {}: {}", repo.getId(), e.getMessage(), e);
        throw new RepositoryAdminException("Could not delete remote repository" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
    }
    saveConfiguration(configuration);
    return Boolean.TRUE;
}
Also used : RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) RemoteRepository(org.apache.archiva.repository.RemoteRepository) RepositoryException(org.apache.archiva.repository.RepositoryException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 58 with RepositoryAdminException

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

the class DefaultRedbackRuntimeConfigurationAdmin method getBoolean.

@Override
public boolean getBoolean(String key) {
    RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
    if (UserConfigurationKeys.LDAP_WRITABLE.equals(key)) {
        return conf.getLdapConfiguration().isWritable();
    }
    if (UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME.equals(key)) {
        return conf.getLdapConfiguration().isUseRoleNameAsGroup();
    }
    if (UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED.equals(key)) {
        return conf.getLdapConfiguration().isBindAuthenticatorEnabled();
    }
    if (conf.getConfigurationProperties().containsKey(key)) {
        return Boolean.valueOf(conf.getConfigurationProperties().get(key));
    }
    boolean value = userConfiguration.getBoolean(key);
    conf.getConfigurationProperties().put(key, Boolean.toString(value));
    try {
        updateRedbackRuntimeConfiguration(conf);
    } catch (RepositoryAdminException e) {
        log.error("fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
    return value;
}
Also used : RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 59 with RepositoryAdminException

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

the class DefaultRedbackRuntimeConfigurationAdmin method getList.

@Override
public List<String> getList(String key) {
    RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
    if (conf.getConfigurationProperties().containsKey(key)) {
        return Arrays.asList(conf.getConfigurationProperties().get(key).split(","));
    }
    List<String> value = userConfiguration.getList(key);
    conf.getConfigurationProperties().put(key, "");
    try {
        updateRedbackRuntimeConfiguration(conf);
    } catch (RepositoryAdminException e) {
        log.error("fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
    return value;
}
Also used : RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 60 with RepositoryAdminException

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

the class DefaultManagedRepositoryAdmin method deleteManagedRepository.

@Override
public Boolean deleteManagedRepository(String repositoryId, AuditInformation auditInformation, boolean deleteContent) throws RepositoryAdminException {
    Configuration config = getArchivaConfiguration().getConfiguration();
    ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById(repositoryId);
    if (repoConfig != null) {
        log.debug("Repo location " + repoConfig.getLocation());
        org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository(repositoryId);
        org.apache.archiva.repository.ManagedRepository stagingRepository = null;
        if (repo != null) {
            try {
                if (repo.supportsFeature(StagingRepositoryFeature.class)) {
                    stagingRepository = repo.getFeature(StagingRepositoryFeature.class).get().getStagingRepository();
                }
                repositoryRegistry.removeRepository(repo, config);
            } catch (RepositoryException e) {
                log.error("Removal of repository {} failed: {}", repositoryId, e.getMessage(), e);
                throw new RepositoryAdminException("Removal of repository " + repositoryId + " failed.");
            }
        } else {
            throw new RepositoryAdminException("A repository with that id does not exist");
        }
        triggerAuditEvent(repositoryId, null, AuditEvent.DELETE_MANAGED_REPO, auditInformation);
        if (repoConfig != null) {
            deleteManagedRepository(repoConfig, deleteContent, config, false);
        }
        // stage repo exists ?
        if (stagingRepository != null) {
            // do not trigger event when deleting the staged one
            ManagedRepositoryConfiguration stagingRepositoryConfig = config.findManagedRepositoryById(stagingRepository.getId());
            try {
                repositoryRegistry.removeRepository(stagingRepository);
                if (stagingRepositoryConfig != null) {
                    deleteManagedRepository(stagingRepositoryConfig, deleteContent, config, true);
                }
            } catch (RepositoryException e) {
                log.error("Removal of staging repository {} failed: {}", stagingRepository.getId(), e.getMessage(), e);
            }
        }
        try {
            saveConfiguration(config);
        } catch (Exception e) {
            throw new RepositoryAdminException("Error saving configuration for delete action" + e.getMessage(), e);
        }
        return Boolean.TRUE;
    } else {
        return Boolean.FALSE;
    }
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RepositoryException(org.apache.archiva.repository.RepositoryException) MetadataRepositoryException(org.apache.archiva.metadata.repository.MetadataRepositoryException) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) TaskQueueException(org.apache.archiva.redback.components.taskqueue.TaskQueueException) IndeterminateConfigurationException(org.apache.archiva.configuration.IndeterminateConfigurationException) RoleManagerException(org.apache.archiva.redback.role.RoleManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RepositoryException(org.apache.archiva.repository.RepositoryException) IndexUpdateFailedException(org.apache.archiva.indexer.IndexUpdateFailedException) MetadataRepositoryException(org.apache.archiva.metadata.repository.MetadataRepositoryException) RegistryException(org.apache.archiva.redback.components.registry.RegistryException) IOException(java.io.IOException)

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