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