archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/base/ArchivaRepositoryRegistry.java
/**
     * Adds a new repository or updates the repository with the same id. The given configuration object is updated, but
     * the configuration is not saved.
     *
     * @param remoteRepositoryConfiguration the new or changed repository configuration
     * @param configuration                 the configuration object
     * @return the new or updated repository
     * @throws RepositoryException if the configuration cannot be saved or updated
     */
Adds a new repository or updates the repository with the same id. The given configuration object is updated, but
the configuration is not saved.

@param remoteRepositoryConfiguration the new or changed repository configuration
@param configuration                 the configuration object
@return the new or updated repository
@throws RepositoryException if the configuration cannot be saved or updated
Adds a new repository or updates the repository with the same id . The given configuration object is updated but the configuration is not saved . @param remoteRepositoryConfiguration the new or changed repository configuration @param configuration the configuration object @return the new or updated repository @throws RepositoryException if the configuration cannot be saved or updated
@Override
    @SuppressWarnings("unchecked")
    public RemoteRepository putRepository( RemoteRepositoryConfiguration remoteRepositoryConfiguration, Configuration configuration ) throws RepositoryException {
        rwLock.writeLock().lock();
        try {
            final String id = remoteRepositoryConfiguration.getId();
            final RepositoryType repoType = RepositoryType.valueOf(remoteRepositoryConfiguration.getType());
            RemoteRepository repo;
            boolean registeredNew = false;
            repo = remoteRepositories.get(id);
            if (repo != null && repo.isOpen()) {
                if (repo instanceof EditableRemoteRepository) {
                    getProvider(repoType).updateRemoteInstance((EditableRemoteRepository) repo, remoteRepositoryConfiguration);
                } else {
                    throw new RepositoryException("The repository is not editable " + id);
                }
            } else {
                repo = getProvider(repoType).createRemoteInstance(remoteRepositoryConfiguration);
                remoteRepositories.put(id, repo);
                registeredNew = true;
            }
            updateRepositoryReferences(getProvider(repoType), repo, remoteRepositoryConfiguration, configuration);
            replaceOrAddRepositoryConfig(remoteRepositoryConfiguration, configuration);
            if (registeredNew) {
                pushEvent(new LifecycleEvent(LifecycleEvent.REGISTERED, this, repo));
            } else {
                pushEvent(new LifecycleEvent(LifecycleEvent.UPDATED, this, repo));
            }
            return repo;
        } finally {
            rwLock.writeLock().unlock();
        }
    }
@ Override @ SuppressWarnings ( "unchecked" ) public RemoteRepository putRepository ( RemoteRepositoryConfiguration remoteRepositoryConfiguration , Configuration configuration ) throws RepositoryException { rwLock . writeLock ( ) . lock ( ) ; try { final String id = remoteRepositoryConfiguration . getId ( ) ; final RepositoryType repoType = RepositoryType . valueOf ( remoteRepositoryConfiguration . getType ( ) ) ; RemoteRepository repo ; boolean registeredNew = false ; repo = remoteRepositories . get ( id ) ; if ( repo != null && repo . isOpen ( ) ) { if ( repo instanceof EditableRemoteRepository ) { getProvider ( repoType ) . updateRemoteInstance ( ( EditableRemoteRepository ) repo , remoteRepositoryConfiguration ) ; } else { throw new RepositoryException ( "The repository is not editable " + id ) ; } } else { repo = getProvider ( repoType ) . createRemoteInstance ( remoteRepositoryConfiguration ) ; remoteRepositories . put ( id , repo ) ; registeredNew = true ; } updateRepositoryReferences ( getProvider ( repoType ) , repo , remoteRepositoryConfiguration , configuration ) ; replaceOrAddRepositoryConfig ( remoteRepositoryConfiguration , configuration ) ; if ( registeredNew ) { pushEvent ( new LifecycleEvent ( LifecycleEvent . REGISTERED , this , repo ) ) ; } else { pushEvent ( new LifecycleEvent ( LifecycleEvent . UPDATED , this , repo ) ) ; } return repo ; } finally { rwLock . writeLock ( ) . unlock ( ) ; } }
Adds a new repository or updates the repository with the same id.
Adds a new repository or updates the repository with the same id .