use of org.apache.archiva.repository.RepositoryProvider in project archiva by apache.
the class ArchivaRepositoryRegistry method initialize.
@PostConstruct
private void initialize() {
rwLock.writeLock().lock();
try {
log.debug("Initializing repository registry");
initializeManagedRepositories();
initializeRemoteRepositories();
initializeRepositoryGroups();
for (RepositoryProvider provider : repositoryProviders) {
provider.addRepositoryEventHandler(this);
}
this.configurationHandler.addListener(this);
registerEventHandler(EventType.ROOT, centralEventManager);
} finally {
rwLock.writeLock().unlock();
}
pushEvent(new RepositoryRegistryEvent(RepositoryRegistryEvent.RELOADED, this));
if (managed_initialized.get() && remote_initialized.get() && groups_initalized.get()) {
pushEvent(new RepositoryRegistryEvent(RepositoryRegistryEvent.INITIALIZED, this));
}
}
use of org.apache.archiva.repository.RepositoryProvider in project archiva by apache.
the class RepositoryGroupHandler method newInstance.
@Override
public RepositoryGroup newInstance(final RepositoryGroupConfiguration repositoryConfiguration) throws RepositoryException {
RepositoryType type = RepositoryType.valueOf(repositoryConfiguration.getType());
RepositoryProvider provider = getProvider(type);
return createNewRepositoryGroup(provider, repositoryConfiguration);
}
use of org.apache.archiva.repository.RepositoryProvider in project archiva by apache.
the class RepositoryGroupHandler method clone.
@Override
public RepositoryGroup clone(RepositoryGroup repo, String newId) throws RepositoryException {
RepositoryProvider provider = getProvider(repo.getType());
RepositoryGroupConfiguration cfg = provider.getRepositoryGroupConfiguration(repo);
cfg.setId(newId);
RepositoryGroup cloned = provider.createRepositoryGroup(cfg);
cloned.registerEventHandler(RepositoryEvent.ANY, repositoryRegistry);
setLastState(cloned, RepositoryState.CREATED);
return cloned;
}
use of org.apache.archiva.repository.RepositoryProvider in project archiva by apache.
the class RepositoryGroupHandler method put.
/**
* Adds a new repository group or updates the repository with the same id, if it exists already.
* The configuration is saved immediately.
*
* @param repositoryGroupConfiguration the repository configuration
* @return the updated or created repository
* @throws RepositoryException if an error occurs, or the configuration is not valid.
*/
@Override
public RepositoryGroup put(RepositoryGroupConfiguration repositoryGroupConfiguration) throws RepositoryException {
final String id = repositoryGroupConfiguration.getId();
final RepositoryType repositoryType = RepositoryType.valueOf(repositoryGroupConfiguration.getType());
final RepositoryProvider provider = getProvider(repositoryType);
RepositoryGroup currentRepository;
ReentrantReadWriteLock.WriteLock configLock = this.getConfigurationHandler().getLock().writeLock();
configLock.lock();
try {
Configuration configuration = this.getConfigurationHandler().getBaseConfiguration();
currentRepository = getRepositories().get(id);
RepositoryGroup oldRepository = currentRepository == null ? null : clone(currentRepository, id);
try {
boolean updated = false;
if (currentRepository == null) {
currentRepository = put(repositoryGroupConfiguration, configuration);
} else {
setRepositoryGroupDefaults(repositoryGroupConfiguration);
provider.updateRepositoryGroupInstance((EditableRepositoryGroup) currentRepository, repositoryGroupConfiguration);
updated = true;
pushEvent(LifecycleEvent.UPDATED, currentRepository);
}
registerNewRepository(repositoryGroupConfiguration, currentRepository, configuration, updated);
} catch (IndeterminateConfigurationException | RegistryException | RepositoryException e) {
// Trying a rollback
if (oldRepository != null) {
RepositoryGroupConfiguration oldCfg = provider.getRepositoryGroupConfiguration(oldRepository);
provider.updateRepositoryGroupInstance((EditableRepositoryGroup) currentRepository, oldCfg);
rollback(configuration, oldRepository, e, oldCfg);
} else {
getRepositories().remove(id);
}
log.error("Could not save the configuration for repository group {}: {}", id, e.getMessage(), e);
if (e instanceof RepositoryException) {
throw (RepositoryException) e;
} else {
throw new RepositoryException("Could not save the configuration for repository group " + id + ": " + e.getMessage());
}
}
} finally {
configLock.unlock();
}
return currentRepository;
}
use of org.apache.archiva.repository.RepositoryProvider in project archiva by apache.
the class ManagedRepositoryHandler method clone.
@Override
public ManagedRepository clone(ManagedRepository repo, String id) throws RepositoryException {
RepositoryProvider provider = getProvider(repo.getType());
ManagedRepositoryConfiguration cfg = provider.getManagedConfiguration(repo);
cfg.setId(id);
ManagedRepository cloned = provider.createManagedInstance(cfg);
cloned.registerEventHandler(RepositoryEvent.ANY, repositoryHandlerManager);
setLastState(cloned, RepositoryState.CREATED);
return cloned;
}
Aggregations