archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/ArchivaRepositoryRegistry.java
/**
     * Adds a new repository group to the current list, or replaces the repository group definition with
     * the same id, if it exists already.
     * The change is saved to the configuration immediately.
     *
     * @param repositoryGroup the new repository group.
     * @throws RepositoryException if the new repository group could not be saved to the configuration.
     */
Adds a new repository group to the current list, or replaces the repository group definition with
the same id, if it exists already.
The change is saved to the configuration immediately.

@param repositoryGroup the new repository group.
@throws RepositoryException if the new repository group could not be saved to the configuration.
Adds a new repository group to the current list or replaces the repository group definition with the same id if it exists already . The change is saved to the configuration immediately . @param repositoryGroup the new repository group . @throws RepositoryException if the new repository group could not be saved to the configuration .
@Override
    public RepositoryGroup putRepositoryGroup( RepositoryGroup repositoryGroup ) throws RepositoryException {
        rwLock.writeLock().lock();
        try {
            final String id = repositoryGroup.getId();
            RepositoryGroup originRepoGroup = repositoryGroups.put(id, repositoryGroup);
            try {
                if (originRepoGroup != null && originRepoGroup != repositoryGroup) {
                    originRepoGroup.close();
                }
                RepositoryProvider provider = getProvider(repositoryGroup.getType());
                RepositoryGroupConfiguration newCfg = provider.getRepositoryGroupConfiguration(repositoryGroup);
                Configuration configuration = getArchivaConfiguration().getConfiguration();
                updateRepositoryReferences(provider, repositoryGroup, newCfg);
                RepositoryGroupConfiguration oldCfg = configuration.findRepositoryGroupById(id);
                if (oldCfg != null) {
                    configuration.removeRepositoryGroup(oldCfg);
                }
                configuration.addRepositoryGroup(newCfg);
                saveConfiguration(configuration);
                return repositoryGroup;
            } catch (Exception e) {
                if (originRepoGroup != null) {
                    repositoryGroups.put(id, originRepoGroup);
                } else {
                    repositoryGroups.remove(id);
                }
                log.error("Exception during configuration update {}", e.getMessage(), e);
                throw new RepositoryException("Could not save the configuration" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
            }
        } finally {
            rwLock.writeLock().unlock();
        }
    }
@ Override public RepositoryGroup putRepositoryGroup ( RepositoryGroup repositoryGroup ) throws RepositoryException { rwLock . writeLock ( ) . lock ( ) ; try { final String id = repositoryGroup . getId ( ) ; RepositoryGroup originRepoGroup = repositoryGroups . put ( id , repositoryGroup ) ; try { if ( originRepoGroup != null && originRepoGroup != repositoryGroup ) { originRepoGroup . close ( ) ; } RepositoryProvider provider = getProvider ( repositoryGroup . getType ( ) ) ; RepositoryGroupConfiguration newCfg = provider . getRepositoryGroupConfiguration ( repositoryGroup ) ; Configuration configuration = getArchivaConfiguration ( ) . getConfiguration ( ) ; updateRepositoryReferences ( provider , repositoryGroup , newCfg ) ; RepositoryGroupConfiguration oldCfg = configuration . findRepositoryGroupById ( id ) ; if ( oldCfg != null ) { configuration . removeRepositoryGroup ( oldCfg ) ; } configuration . addRepositoryGroup ( newCfg ) ; saveConfiguration ( configuration ) ; return repositoryGroup ; } catch ( Exception e ) { if ( originRepoGroup != null ) { repositoryGroups . put ( id , originRepoGroup ) ; } else { repositoryGroups . remove ( id ) ; } log . error ( "Exception during configuration update {}" , e . getMessage ( ) , e ) ; throw new RepositoryException ( "Could not save the configuration" + ( e . getMessage ( ) == null ? "" : ": " + e . getMessage ( ) ) ) ; } } finally { rwLock . writeLock ( ) . unlock ( ) ; } }
Adds a new repository group to the current list, or replaces the repository group definition with
 the same id, if it exists already.
Adds a new repository group to the current list or replaces the repository group definition with the same id if it exists already .
// Rollback