use of org.apache.archiva.configuration.provider.IndeterminateConfigurationException in project archiva by apache.
the class RemoteRepositoryHandler method put.
@Override
public RemoteRepository put(RemoteRepositoryConfiguration repositoryConfiguration) throws RepositoryException {
final String id = repositoryConfiguration.getId();
final RepositoryType repositoryType = RepositoryType.valueOf(repositoryConfiguration.getType());
final RepositoryProvider provider = getProvider(repositoryType);
ReentrantReadWriteLock.WriteLock configLock = this.getConfigurationHandler().getLock().writeLock();
configLock.lock();
RemoteRepository repo = null;
RemoteRepository oldRepository = null;
Configuration configuration = null;
try {
boolean updated = false;
configuration = getConfigurationHandler().getBaseConfiguration();
repo = getRepositories().get(id);
oldRepository = repo == null ? null : clone(repo, id);
if (repo == null) {
repo = put(repositoryConfiguration, configuration);
} else {
setRepositoryDefaults(repositoryConfiguration);
provider.updateRemoteInstance((EditableRemoteRepository) repo, repositoryConfiguration);
updated = true;
pushEvent(LifecycleEvent.UPDATED, repo);
}
registerNewRepository(repositoryConfiguration, repo, configuration, updated);
} catch (IndeterminateConfigurationException | RegistryException e) {
if (oldRepository != null) {
RemoteRepositoryConfiguration oldCfg = provider.getRemoteConfiguration(oldRepository);
provider.updateRemoteInstance((EditableRemoteRepository) repo, oldCfg);
rollback(configuration, oldRepository, e, oldCfg);
} else {
getRepositories().remove(id);
}
log.error("Could not save the configuration for repository {}: {}", id, e.getMessage(), e);
throw new RepositoryException("Could not save the configuration for repository " + id + ": " + e.getMessage());
} finally {
configLock.unlock();
}
return repo;
}
Aggregations