archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/ArchivaRepositoryRegistry.java
/**
     * 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.
     */
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.
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 putRepositoryGroup( RepositoryGroupConfiguration repositoryGroupConfiguration ) throws RepositoryException {
        rwLock.writeLock().lock();
        try {
            final String id = repositoryGroupConfiguration.getId();
            final RepositoryType repositoryType = RepositoryType.valueOf(repositoryGroupConfiguration.getType());
            Configuration configuration = getArchivaConfiguration().getConfiguration();
            RepositoryGroup repo = repositoryGroups.get(id);
            RepositoryGroupConfiguration oldCfg = repo != null ? getProvider(repositoryType).getRepositoryGroupConfiguration(repo) : null;
            repo = putRepositoryGroup(repositoryGroupConfiguration, configuration);
            try {
                saveConfiguration(configuration);
            } catch (IndeterminateConfigurationException | RegistryException e) {
                if (oldCfg != null) {
                    getProvider(repositoryType).updateRepositoryGroupInstance((EditableRepositoryGroup) repo, oldCfg);
                }
                log.error("Could not save the configuration for repository group {}: {}", id, e.getMessage(), e);
                throw new RepositoryException("Could not save the configuration for repository group " + id + ": " + e.getMessage());
            }
            return repo;
        } finally {
            rwLock.writeLock().unlock();
        }
    }
@ Override public RepositoryGroup putRepositoryGroup ( RepositoryGroupConfiguration repositoryGroupConfiguration ) throws RepositoryException { rwLock . writeLock ( ) . lock ( ) ; try { final String id = repositoryGroupConfiguration . getId ( ) ; final RepositoryType repositoryType = RepositoryType . valueOf ( repositoryGroupConfiguration . getType ( ) ) ; Configuration configuration = getArchivaConfiguration ( ) . getConfiguration ( ) ; RepositoryGroup repo = repositoryGroups . get ( id ) ; RepositoryGroupConfiguration oldCfg = repo != null ? getProvider ( repositoryType ) . getRepositoryGroupConfiguration ( repo ) : null ; repo = putRepositoryGroup ( repositoryGroupConfiguration , configuration ) ; try { saveConfiguration ( configuration ) ; } catch ( IndeterminateConfigurationException | RegistryException e ) { if ( oldCfg != null ) { getProvider ( repositoryType ) . updateRepositoryGroupInstance ( ( EditableRepositoryGroup ) repo , oldCfg ) ; } log . error ( "Could not save the configuration for repository group {}: {}" , id , e . getMessage ( ) , e ) ; throw new RepositoryException ( "Could not save the configuration for repository group " + id + ": " + e . getMessage ( ) ) ; } return repo ; } finally { rwLock . writeLock ( ) . unlock ( ) ; } }
Adds a new repository group or updates the repository with the same id, if it exists already.
Adds a new repository group or updates the repository with the same id if it exists already .