Extracting interface from RepositoryRegistry

This commit is contained in:
Martin Stockhammer 2019-10-03 20:55:40 +02:00
parent e7bbbc0e46
commit 6766beb8ac
15 changed files with 210 additions and 63 deletions

View File

@ -24,6 +24,7 @@ import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin
import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryContentFactory; import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.RepositoryRegistry;
@ -102,7 +103,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
sessionControl.replay(); sessionControl.replay();
repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), metadataTools, repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), metadataTools,
applicationContext.getBean( applicationContext.getBean(
RepositoryRegistry.class ), ArchivaRepositoryRegistry.class ),
repositorySession, listeners ); repositorySession, listeners );
( (DefaultManagedRepositoryAdmin) applicationContext.getBean( ( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
@ -113,7 +114,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
public void testReleasedSnapshotsExistsInSameRepo() public void testReleasedSnapshotsExistsInSameRepo()
throws Exception throws Exception
{ {
RepositoryRegistry repositoryRegistry = applicationContext.getBean( RepositoryRegistry.class ); RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class );
repositoryRegistry.removeRepository( TEST_REPO_ID ); repositoryRegistry.removeRepository( TEST_REPO_ID );
repositoryRegistry.putRepository( repositoryRegistry.putRepository(
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME )); getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ));
@ -191,7 +192,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
throws Exception throws Exception
{ {
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class); RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID ); ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID );
repositoryRegistry.removeRepository( managedRepository ); repositoryRegistry.removeRepository( managedRepository );
repositoryRegistry.putRepository( repositoryRegistry.putRepository(
@ -223,7 +224,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
throws Exception throws Exception
{ {
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class); RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID ); ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID );
repositoryRegistry.removeRepository( TEST_REPO_ID ); repositoryRegistry.removeRepository( TEST_REPO_ID );
repositoryRegistry.putRepository( repositoryRegistry.putRepository(
@ -304,7 +305,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
throws Exception throws Exception
{ {
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class); RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID ); ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID );
repositoryRegistry.removeRepository( TEST_REPO_ID ); repositoryRegistry.removeRepository( TEST_REPO_ID );
repositoryRegistry.putRepository( repositoryRegistry.putRepository(

View File

@ -27,6 +27,7 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate; import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.features.ArtifactCleanupFeature; import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.custommonkey.xmlunit.XMLAssert; import org.custommonkey.xmlunit.XMLAssert;
@ -260,14 +261,14 @@ public class RepositoryPurgeConsumerTest
private void addRepoToConfiguration( String configHint, org.apache.archiva.repository.ManagedRepository repoConfiguration ) private void addRepoToConfiguration( String configHint, org.apache.archiva.repository.ManagedRepository repoConfiguration )
throws Exception throws Exception
{ {
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class); RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
repositoryRegistry.putRepository( repoConfiguration ); repositoryRegistry.putRepository( repoConfiguration );
} }
private void removeRepoFromConfiguration( String configHint, org.apache.archiva.repository.ManagedRepository repoConfiguration ) private void removeRepoFromConfiguration( String configHint, org.apache.archiva.repository.ManagedRepository repoConfiguration )
throws Exception throws Exception
{ {
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class); RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
repositoryRegistry.removeRepository( repoConfiguration ); repositoryRegistry.removeRepository( repoConfiguration );
} }

View File

@ -24,9 +24,9 @@ import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.redback.components.taskqueue.TaskQueueException; import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.BasicManagedRepository; import org.apache.archiva.repository.BasicManagedRepository;
import org.apache.archiva.repository.ReleaseScheme; import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.scheduler.ArchivaTaskScheduler; import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask; import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
@ -94,7 +94,7 @@ public class NexusIndexerConsumerTest
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@Inject @Inject
RepositoryRegistry repositoryRegistry; ArchivaRepositoryRegistry repositoryRegistry;
@Override @Override

View File

@ -28,9 +28,9 @@ import org.apache.archiva.policies.PolicyUtil;
import org.apache.archiva.proxy.model.NetworkProxy; import org.apache.archiva.proxy.model.NetworkProxy;
import org.apache.archiva.proxy.model.ProxyConnector; import org.apache.archiva.proxy.model.ProxyConnector;
import org.apache.archiva.proxy.model.RepositoryProxyHandler; import org.apache.archiva.proxy.model.RepositoryProxyHandler;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RemoteRepository; import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryType; import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.event.EventHandler; import org.apache.archiva.event.EventHandler;
import org.apache.archiva.repository.event.RepositoryRegistryEvent; import org.apache.archiva.repository.event.RepositoryRegistryEvent;
@ -65,7 +65,7 @@ public class ArchivaProxyRegistry implements ProxyRegistry, EventHandler<Reposit
List<Policy> policies; List<Policy> policies;
@Inject @Inject
RepositoryRegistry repositoryRegistry; ArchivaRepositoryRegistry repositoryRegistry;
private Map<String, NetworkProxy> networkProxyMap = new HashMap<>(); private Map<String, NetworkProxy> networkProxyMap = new HashMap<>();
private Map<RepositoryType, List<RepositoryProxyHandler>> handlerMap = new HashMap<>(); private Map<RepositoryType, List<RepositoryProxyHandler>> handlerMap = new HashMap<>();

View File

@ -0,0 +1,109 @@
package org.apache.archiva.repository;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.event.EventSource;
import org.apache.archiva.indexer.ArchivaIndexManager;
import org.apache.archiva.indexer.IndexUpdateFailedException;
import java.util.Collection;
/**
* Registry for repositories. This is the central entry point for repositories. It provides methods for
* retrieving, adding and removing repositories.
* <p>
* The modification methods addXX and removeXX persist the changes immediately to the configuration. If the
* configuration save fails the changes are rolled back.
* <p>
* @author Martin Stockhammer <martin_s@apache.org>
*/
public interface RepositoryRegistry extends EventSource
{
void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration );
ArchivaIndexManager getIndexManager( RepositoryType type );
Collection<Repository> getRepositories( );
Collection<ManagedRepository> getManagedRepositories( );
Collection<RemoteRepository> getRemoteRepositories( );
Collection<RepositoryGroup> getRepositoryGroups( );
Repository getRepository( String repoId );
ManagedRepository getManagedRepository( String repoId );
RemoteRepository getRemoteRepository( String repoId );
RepositoryGroup getRepositoryGroup( String groupId );
ManagedRepository putRepository( ManagedRepository managedRepository ) throws RepositoryException;
ManagedRepository putRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration ) throws RepositoryException;
ManagedRepository putRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration, Configuration configuration ) throws RepositoryException;
RepositoryGroup putRepositoryGroup( RepositoryGroup repositoryGroup ) throws RepositoryException;
RepositoryGroup putRepositoryGroup( RepositoryGroupConfiguration repositoryGroupConfiguration ) throws RepositoryException;
RepositoryGroup putRepositoryGroup( RepositoryGroupConfiguration repositoryGroupConfiguration, Configuration configuration ) throws RepositoryException;
RemoteRepository putRepository( RemoteRepository remoteRepository, Configuration configuration ) throws RepositoryException;
RemoteRepository putRepository( RemoteRepository remoteRepository ) throws RepositoryException;
RemoteRepository putRepository( RemoteRepositoryConfiguration remoteRepositoryConfiguration ) throws RepositoryException;
RemoteRepository putRepository( RemoteRepositoryConfiguration remoteRepositoryConfiguration, Configuration configuration ) throws RepositoryException;
void removeRepository( String repoId ) throws RepositoryException;
void removeRepository( Repository repo ) throws RepositoryException;
void removeRepository( ManagedRepository managedRepository ) throws RepositoryException;
void removeRepository( ManagedRepository managedRepository, Configuration configuration ) throws RepositoryException;
void removeRepositoryGroup( RepositoryGroup repositoryGroup ) throws RepositoryException;
void removeRepositoryGroup( RepositoryGroup repositoryGroup, Configuration configuration ) throws RepositoryException;
void removeRepository( RemoteRepository remoteRepository ) throws RepositoryException;
void removeRepository( RemoteRepository remoteRepository, Configuration configuration ) throws RepositoryException;
void reload( );
void resetIndexingContext( Repository repository ) throws IndexUpdateFailedException;
ManagedRepository clone( ManagedRepository repo, String newId ) throws RepositoryException;
<T extends Repository> Repository clone( T repo, String newId ) throws RepositoryException;
RemoteRepository clone( RemoteRepository repo, String newId ) throws RepositoryException;
}

View File

@ -58,7 +58,9 @@ import static org.apache.archiva.indexer.ArchivaIndexManager.DEFAULT_INDEX_PATH;
* @since 3.0 * @since 3.0
*/ */
@Service("repositoryRegistry") @Service("repositoryRegistry")
public class RepositoryRegistry implements ConfigurationListener, EventSource, EventHandler<Event> { public class ArchivaRepositoryRegistry implements ConfigurationListener, EventHandler<Event>,
RepositoryRegistry
{
private static final Logger log = LoggerFactory.getLogger(RepositoryRegistry.class); private static final Logger log = LoggerFactory.getLogger(RepositoryRegistry.class);
@ -94,11 +96,12 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
private volatile boolean ignoreConfigEvents = false; private volatile boolean ignoreConfigEvents = false;
public RepositoryRegistry() { public ArchivaRepositoryRegistry() {
this.eventManager = new EventManager(this); this.eventManager = new EventManager(this);
} }
public void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration) { @Override
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) {
this.archivaConfiguration = archivaConfiguration; this.archivaConfiguration = archivaConfiguration;
} }
@ -233,7 +236,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
repo.registerEventHandler(RepositoryEvent.ANY, this); repo.registerEventHandler(RepositoryEvent.ANY, this);
} }
public ArchivaIndexManager getIndexManager(RepositoryType type) { @Override
public ArchivaIndexManager getIndexManager( RepositoryType type ) {
return indexManagerFactory.getIndexManager(type); return indexManagerFactory.getIndexManager(type);
} }
@ -361,7 +365,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* *
* @return a list of managed and remote repositories * @return a list of managed and remote repositories
*/ */
public Collection<Repository> getRepositories() { @Override
public Collection<Repository> getRepositories( ) {
rwLock.readLock().lock(); rwLock.readLock().lock();
try { try {
return Stream.concat(managedRepositories.values().stream(), remoteRepositories.values().stream()).collect(Collectors.toList()); return Stream.concat(managedRepositories.values().stream(), remoteRepositories.values().stream()).collect(Collectors.toList());
@ -375,7 +380,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* *
* @return a list of managed repositories * @return a list of managed repositories
*/ */
public Collection<ManagedRepository> getManagedRepositories() { @Override
public Collection<ManagedRepository> getManagedRepositories( ) {
rwLock.readLock().lock(); rwLock.readLock().lock();
try { try {
return uManagedRepository.values(); return uManagedRepository.values();
@ -389,7 +395,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* *
* @return a list of remote repositories * @return a list of remote repositories
*/ */
public Collection<RemoteRepository> getRemoteRepositories() { @Override
public Collection<RemoteRepository> getRemoteRepositories( ) {
rwLock.readLock().lock(); rwLock.readLock().lock();
try { try {
return uRemoteRepositories.values(); return uRemoteRepositories.values();
@ -398,7 +405,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
} }
} }
public Collection<RepositoryGroup> getRepositoryGroups() { @Override
public Collection<RepositoryGroup> getRepositoryGroups( ) {
rwLock.readLock().lock(); rwLock.readLock().lock();
try { try {
return uRepositoryGroups.values(); return uRepositoryGroups.values();
@ -414,7 +422,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repoId the repository id * @param repoId the repository id
* @return the repository if found, otherwise null * @return the repository if found, otherwise null
*/ */
public Repository getRepository(String repoId) { @Override
public Repository getRepository( String repoId ) {
rwLock.readLock().lock(); rwLock.readLock().lock();
try { try {
log.debug("getRepository {}", repoId); log.debug("getRepository {}", repoId);
@ -441,7 +450,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repoId the repository id * @param repoId the repository id
* @return the managed repository if found, otherwise null * @return the managed repository if found, otherwise null
*/ */
public ManagedRepository getManagedRepository(String repoId) { @Override
public ManagedRepository getManagedRepository( String repoId ) {
rwLock.readLock().lock(); rwLock.readLock().lock();
try { try {
return managedRepositories.get(repoId); return managedRepositories.get(repoId);
@ -457,7 +467,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repoId the repository id * @param repoId the repository id
* @return the remote repository if found, otherwise null * @return the remote repository if found, otherwise null
*/ */
public RemoteRepository getRemoteRepository(String repoId) { @Override
public RemoteRepository getRemoteRepository( String repoId ) {
rwLock.readLock().lock(); rwLock.readLock().lock();
try { try {
return remoteRepositories.get(repoId); return remoteRepositories.get(repoId);
@ -466,7 +477,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
} }
} }
public RepositoryGroup getRepositoryGroup(String groupId) { @Override
public RepositoryGroup getRepositoryGroup( String groupId ) {
rwLock.readLock().lock(); rwLock.readLock().lock();
try { try {
return repositoryGroups.get(groupId); return repositoryGroups.get(groupId);
@ -496,7 +508,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param managedRepository the new repository. * @param managedRepository the new repository.
* @throws RepositoryException if the new repository could not be saved to the configuration. * @throws RepositoryException if the new repository could not be saved to the configuration.
*/ */
public ManagedRepository putRepository(ManagedRepository managedRepository) throws RepositoryException { @Override
public ManagedRepository putRepository( ManagedRepository managedRepository ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = managedRepository.getId(); final String id = managedRepository.getId();
@ -547,7 +560,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the updated or created repository * @return the updated or created repository
* @throws RepositoryException if an error occurs, or the configuration is not valid. * @throws RepositoryException if an error occurs, or the configuration is not valid.
*/ */
public ManagedRepository putRepository(ManagedRepositoryConfiguration managedRepositoryConfiguration) throws RepositoryException { @Override
public ManagedRepository putRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = managedRepositoryConfiguration.getId(); final String id = managedRepositoryConfiguration.getId();
@ -581,7 +595,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the new or updated repository * @return the new or updated repository
* @throws RepositoryException if the configuration cannot be saved or updated * @throws RepositoryException if the configuration cannot be saved or updated
*/ */
public ManagedRepository putRepository(ManagedRepositoryConfiguration managedRepositoryConfiguration, Configuration configuration) throws RepositoryException { @Override
public ManagedRepository putRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration, Configuration configuration ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = managedRepositoryConfiguration.getId(); final String id = managedRepositoryConfiguration.getId();
@ -622,7 +637,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repositoryGroup the new repository group. * @param repositoryGroup the new repository group.
* @throws RepositoryException if the new repository group could not be saved to the configuration. * @throws RepositoryException if the new repository group could not be saved to the configuration.
*/ */
public RepositoryGroup putRepositoryGroup(RepositoryGroup repositoryGroup) throws RepositoryException { @Override
public RepositoryGroup putRepositoryGroup( RepositoryGroup repositoryGroup ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = repositoryGroup.getId(); final String id = repositoryGroup.getId();
@ -665,7 +681,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the updated or created repository * @return the updated or created repository
* @throws RepositoryException if an error occurs, or the configuration is not valid. * @throws RepositoryException if an error occurs, or the configuration is not valid.
*/ */
public RepositoryGroup putRepositoryGroup(RepositoryGroupConfiguration repositoryGroupConfiguration) throws RepositoryException { @Override
public RepositoryGroup putRepositoryGroup( RepositoryGroupConfiguration repositoryGroupConfiguration ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = repositoryGroupConfiguration.getId(); final String id = repositoryGroupConfiguration.getId();
@ -699,7 +716,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return The new or updated repository group * @return The new or updated repository group
* @throws RepositoryException if the configuration cannot be saved or updated * @throws RepositoryException if the configuration cannot be saved or updated
*/ */
public RepositoryGroup putRepositoryGroup(RepositoryGroupConfiguration repositoryGroupConfiguration, Configuration configuration) throws RepositoryException { @Override
public RepositoryGroup putRepositoryGroup( RepositoryGroupConfiguration repositoryGroupConfiguration, Configuration configuration ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = repositoryGroupConfiguration.getId(); final String id = repositoryGroupConfiguration.getId();
@ -765,7 +783,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
configuration.addRepositoryGroup(repositoryGroupConfiguration); configuration.addRepositoryGroup(repositoryGroupConfiguration);
} }
public RemoteRepository putRepository(RemoteRepository remoteRepository, Configuration configuration) throws RepositoryException { @Override
public RemoteRepository putRepository( RemoteRepository remoteRepository, Configuration configuration ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = remoteRepository.getId(); final String id = remoteRepository.getId();
@ -822,7 +841,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param remoteRepository the remote repository to add * @param remoteRepository the remote repository to add
* @throws RepositoryException if an error occurs during configuration save * @throws RepositoryException if an error occurs during configuration save
*/ */
public RemoteRepository putRepository(RemoteRepository remoteRepository) throws RepositoryException { @Override
public RemoteRepository putRepository( RemoteRepository remoteRepository ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
Configuration configuration = getArchivaConfiguration().getConfiguration(); Configuration configuration = getArchivaConfiguration().getConfiguration();
@ -847,7 +867,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the updated or created repository * @return the updated or created repository
* @throws RepositoryException if an error occurs, or the configuration is not valid. * @throws RepositoryException if an error occurs, or the configuration is not valid.
*/ */
public RemoteRepository putRepository(RemoteRepositoryConfiguration remoteRepositoryConfiguration) throws RepositoryException { @Override
public RemoteRepository putRepository( RemoteRepositoryConfiguration remoteRepositoryConfiguration ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = remoteRepositoryConfiguration.getId(); final String id = remoteRepositoryConfiguration.getId();
@ -881,8 +902,9 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the new or updated repository * @return the new or updated repository
* @throws RepositoryException if the configuration cannot be saved or updated * @throws RepositoryException if the configuration cannot be saved or updated
*/ */
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public RemoteRepository putRepository(RemoteRepositoryConfiguration remoteRepositoryConfiguration, Configuration configuration) throws RepositoryException { public RemoteRepository putRepository( RemoteRepositoryConfiguration remoteRepositoryConfiguration, Configuration configuration ) throws RepositoryException {
rwLock.writeLock().lock(); rwLock.writeLock().lock();
try { try {
final String id = remoteRepositoryConfiguration.getId(); final String id = remoteRepositoryConfiguration.getId();
@ -916,14 +938,16 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
} }
public void removeRepository(String repoId) throws RepositoryException { @Override
public void removeRepository( String repoId ) throws RepositoryException {
Repository repo = getRepository(repoId); Repository repo = getRepository(repoId);
if (repo != null) { if (repo != null) {
removeRepository(repo); removeRepository(repo);
} }
} }
public void removeRepository(Repository repo) throws RepositoryException { @Override
public void removeRepository( Repository repo ) throws RepositoryException {
if (repo == null) { if (repo == null) {
log.warn("Trying to remove null repository"); log.warn("Trying to remove null repository");
return; return;
@ -946,7 +970,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param managedRepository the managed repository to remove * @param managedRepository the managed repository to remove
* @throws RepositoryException if a error occurs during configuration save * @throws RepositoryException if a error occurs during configuration save
*/ */
public void removeRepository(ManagedRepository managedRepository) throws RepositoryException { @Override
public void removeRepository( ManagedRepository managedRepository ) throws RepositoryException {
if (managedRepository == null) { if (managedRepository == null) {
return; return;
} }
@ -985,7 +1010,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
} }
} }
public void removeRepository(ManagedRepository managedRepository, Configuration configuration) throws RepositoryException { @Override
public void removeRepository( ManagedRepository managedRepository, Configuration configuration ) throws RepositoryException {
if (managedRepository == null) { if (managedRepository == null) {
return; return;
} }
@ -1019,7 +1045,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repositoryGroup the repository group to remove * @param repositoryGroup the repository group to remove
* @throws RepositoryException if a error occurs during configuration save * @throws RepositoryException if a error occurs during configuration save
*/ */
public void removeRepositoryGroup(RepositoryGroup repositoryGroup) throws RepositoryException { @Override
public void removeRepositoryGroup( RepositoryGroup repositoryGroup ) throws RepositoryException {
if (repositoryGroup == null) { if (repositoryGroup == null) {
return; return;
} }
@ -1050,7 +1077,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
} }
} }
public void removeRepositoryGroup(RepositoryGroup repositoryGroup, Configuration configuration) throws RepositoryException { @Override
public void removeRepositoryGroup( RepositoryGroup repositoryGroup, Configuration configuration ) throws RepositoryException {
if (repositoryGroup == null) { if (repositoryGroup == null) {
return; return;
} }
@ -1095,7 +1123,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param remoteRepository the remote repository to remove * @param remoteRepository the remote repository to remove
* @throws RepositoryException if a error occurs during configuration save * @throws RepositoryException if a error occurs during configuration save
*/ */
public void removeRepository(RemoteRepository remoteRepository) throws RepositoryException { @Override
public void removeRepository( RemoteRepository remoteRepository ) throws RepositoryException {
if (remoteRepository == null) { if (remoteRepository == null) {
return; return;
} }
@ -1122,7 +1151,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
} }
} }
public void removeRepository(RemoteRepository remoteRepository, Configuration configuration) throws RepositoryException { @Override
public void removeRepository( RemoteRepository remoteRepository, Configuration configuration ) throws RepositoryException {
if (remoteRepository == null) { if (remoteRepository == null) {
return; return;
} }
@ -1146,7 +1176,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
/** /**
* Reloads the registry from the configuration. * Reloads the registry from the configuration.
*/ */
public void reload() { @Override
public void reload( ) {
initialize(); initialize();
} }
@ -1156,7 +1187,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repository The repository * @param repository The repository
* @throws IndexUpdateFailedException If the index could not be resetted. * @throws IndexUpdateFailedException If the index could not be resetted.
*/ */
public void resetIndexingContext(Repository repository) throws IndexUpdateFailedException { @Override
public void resetIndexingContext( Repository repository ) throws IndexUpdateFailedException {
if (repository.hasIndex() && repository instanceof EditableRepository) { if (repository.hasIndex() && repository instanceof EditableRepository) {
EditableRepository eRepo = (EditableRepository) repository; EditableRepository eRepo = (EditableRepository) repository;
ArchivaIndexingContext newCtx = getIndexManager(repository.getType()).reset(repository.getIndexingContext()); ArchivaIndexingContext newCtx = getIndexManager(repository.getType()).reset(repository.getIndexingContext());
@ -1172,7 +1204,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repo The origin repository * @param repo The origin repository
* @return The cloned repository. * @return The cloned repository.
*/ */
public ManagedRepository clone(ManagedRepository repo, String newId) throws RepositoryException { @Override
public ManagedRepository clone( ManagedRepository repo, String newId ) throws RepositoryException {
if (managedRepositories.containsKey(newId) || remoteRepositories.containsKey(newId)) { if (managedRepositories.containsKey(newId) || remoteRepositories.containsKey(newId)) {
throw new RepositoryException("The given id exists already " + newId); throw new RepositoryException("The given id exists already " + newId);
} }
@ -1184,7 +1217,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
return cloned; return cloned;
} }
public <T extends Repository> Repository clone(T repo, String newId) throws RepositoryException { @Override
public <T extends Repository> Repository clone( T repo, String newId ) throws RepositoryException {
if (repo instanceof RemoteRepository) { if (repo instanceof RemoteRepository) {
return this.clone((RemoteRepository) repo, newId); return this.clone((RemoteRepository) repo, newId);
} else if (repo instanceof ManagedRepository) { } else if (repo instanceof ManagedRepository) {
@ -1201,7 +1235,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repo The origin repository * @param repo The origin repository
* @return The cloned repository. * @return The cloned repository.
*/ */
public RemoteRepository clone(RemoteRepository repo, String newId) throws RepositoryException { @Override
public RemoteRepository clone( RemoteRepository repo, String newId ) throws RepositoryException {
if (managedRepositories.containsKey(newId) || remoteRepositories.containsKey(newId)) { if (managedRepositories.containsKey(newId) || remoteRepositories.containsKey(newId)) {
throw new RepositoryException("The given id exists already " + newId); throw new RepositoryException("The given id exists already " + newId);
} }

View File

@ -22,7 +22,7 @@ package org.apache.archiva.indexer.maven;
import org.apache.archiva.common.utils.FileUtils; import org.apache.archiva.common.utils.FileUtils;
import org.apache.archiva.indexer.ArchivaIndexingContext; import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.indexer.IndexCreationFailedException; import org.apache.archiva.indexer.IndexCreationFailedException;
import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.RepositoryType; import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.repository.features.IndexCreationFeature; import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature; import org.apache.archiva.repository.features.RemoteIndexFeature;
@ -59,7 +59,7 @@ import static org.junit.Assert.*;
public class MavenIndexManagerTest { public class MavenIndexManagerTest {
@Inject @Inject
RepositoryRegistry repositoryRegistry; ArchivaRepositoryRegistry repositoryRegistry;
private Path indexPath; private Path indexPath;

View File

@ -29,8 +29,8 @@ import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.indexer.ArchivaIndexingContext; import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.indexer.search.SearchResultHit; import org.apache.archiva.indexer.search.SearchResultHit;
import org.apache.archiva.indexer.search.SearchResults; import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.Repository; import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.features.IndexCreationFeature; import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
@ -90,7 +90,7 @@ public abstract class AbstractMavenRepositorySearch
ArtifactContextProducer artifactContextProducer; ArtifactContextProducer artifactContextProducer;
@Inject @Inject
RepositoryRegistry repositoryRegistry; ArchivaRepositoryRegistry repositoryRegistry;
@Inject @Inject
private IndexerEngine indexerEngine; private IndexerEngine indexerEngine;

View File

@ -22,7 +22,7 @@ package org.apache.archiva.indexer.maven.search;
import org.apache.archiva.indexer.search.SearchFields; import org.apache.archiva.indexer.search.SearchFields;
import org.apache.archiva.indexer.search.SearchResultHit; import org.apache.archiva.indexer.search.SearchResultHit;
import org.apache.archiva.indexer.search.SearchResults; import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
@ -32,7 +32,6 @@ import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* @author Olivier Lamy * @author Olivier Lamy
@ -42,7 +41,7 @@ public class MavenRepositorySearchOSGITest
{ {
@Inject @Inject
RepositoryRegistry repositoryRegistry; ArchivaRepositoryRegistry repositoryRegistry;
@After @After
@Override @Override

View File

@ -23,7 +23,7 @@ import org.apache.archiva.indexer.search.SearchResultHit;
import org.apache.archiva.indexer.search.SearchResultLimits; import org.apache.archiva.indexer.search.SearchResultLimits;
import org.apache.archiva.indexer.search.SearchResults; import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.indexer.util.SearchUtil; import org.apache.archiva.indexer.util.SearchUtil;
import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
@ -43,7 +43,7 @@ public class MavenRepositorySearchPaginateTest
{ {
@Autowired @Autowired
RepositoryRegistry repositoryRegistry; ArchivaRepositoryRegistry repositoryRegistry;
@After @After
public void endTests() { public void endTests() {

View File

@ -22,7 +22,8 @@ package org.apache.archiva.repository;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
public class RepositoryRegistryMock extends RepositoryRegistry { public class RepositoryRegistryMock extends ArchivaRepositoryRegistry
{
private Map<String, ManagedRepository> managedRepositories = new TreeMap<>(); private Map<String, ManagedRepository> managedRepositories = new TreeMap<>();

View File

@ -22,10 +22,10 @@ package org.apache.archiva.scheduler.indexing.maven;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.archiva.indexer.ArchivaIndexingContext; import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.indexer.UnsupportedBaseContextException; import org.apache.archiva.indexer.UnsupportedBaseContextException;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.BasicManagedRepository; import org.apache.archiva.repository.BasicManagedRepository;
import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ReleaseScheme; import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.storage.StorageAsset; import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.features.IndexCreationFeature; import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask; import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
@ -71,7 +71,7 @@ public class ArchivaIndexingTaskExecutorTest
private ArchivaIndexingTaskExecutor indexingExecutor; private ArchivaIndexingTaskExecutor indexingExecutor;
@Inject @Inject
RepositoryRegistry repositoryRegistry; ArchivaRepositoryRegistry repositoryRegistry;
@Inject @Inject
private IndexUpdater indexUpdater; private IndexUpdater indexUpdater;

View File

@ -27,6 +27,7 @@ import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.BasicManagedRepository; import org.apache.archiva.repository.BasicManagedRepository;
import org.apache.archiva.repository.Repository; import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.RepositoryRegistry;
@ -42,7 +43,6 @@ import org.junit.runner.RunWith;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.temporal.TemporalAccessor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -106,7 +106,7 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
sessionControl.replay(); sessionControl.replay();
repositoryRegistryControl = EasyMock.createControl(); repositoryRegistryControl = EasyMock.createControl();
repositoryRegistry = repositoryRegistryControl.createMock( RepositoryRegistry.class ); repositoryRegistry = repositoryRegistryControl.createMock( ArchivaRepositoryRegistry.class );
List<Repository> reg = new ArrayList<>( ); List<Repository> reg = new ArrayList<>( );
reg.add( new BasicManagedRepository( TEST_REPO, TEST_REPO, new FilesystemStorage( Paths.get("target/test-storage"), new DefaultFileLockManager() ) ) ); reg.add( new BasicManagedRepository( TEST_REPO, TEST_REPO, new FilesystemStorage( Paths.get("target/test-storage"), new DefaultFileLockManager() ) ) );

View File

@ -24,6 +24,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.ConfigurationEvent; import org.apache.archiva.configuration.ConfigurationEvent;
import org.apache.archiva.configuration.ConfigurationListener; import org.apache.archiva.configuration.ConfigurationListener;
import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator; import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.security.ServletAuthenticator; import org.apache.archiva.security.ServletAuthenticator;
@ -169,7 +170,7 @@ public class RepositoryServlet
configuration = wac.getBean("archivaConfiguration#default", ArchivaConfiguration.class); configuration = wac.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
configuration.addListener(this); configuration.addListener(this);
repositoryRegistry = wac.getBean(RepositoryRegistry.class); repositoryRegistry = wac.getBean( ArchivaRepositoryRegistry.class);
resourceFactory = wac.getBean("davResourceFactory#archiva", DavResourceFactory.class); resourceFactory = wac.getBean("davResourceFactory#archiva", DavResourceFactory.class);
locatorFactory = new ArchivaDavLocatorFactory(); locatorFactory = new ArchivaDavLocatorFactory();

View File

@ -27,8 +27,8 @@ import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.indexer.ArchivaIndexingContext; import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryType; import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest; import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest;
@ -100,7 +100,7 @@ public abstract class AbstractRepositoryServletTestCase
@Inject @Inject
RepositoryRegistry repositoryRegistry; ArchivaRepositoryRegistry repositoryRegistry;
protected Logger log = LoggerFactory.getLogger( getClass() ); protected Logger log = LoggerFactory.getLogger( getClass() );