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.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryRegistry;
@ -102,7 +103,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
sessionControl.replay();
repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), metadataTools,
applicationContext.getBean(
RepositoryRegistry.class ),
ArchivaRepositoryRegistry.class ),
repositorySession, listeners );
( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
@ -113,7 +114,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
public void testReleasedSnapshotsExistsInSameRepo()
throws Exception
{
RepositoryRegistry repositoryRegistry = applicationContext.getBean( RepositoryRegistry.class );
RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class );
repositoryRegistry.removeRepository( TEST_REPO_ID );
repositoryRegistry.putRepository(
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ));
@ -191,7 +192,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
throws Exception
{
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class);
RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID );
repositoryRegistry.removeRepository( managedRepository );
repositoryRegistry.putRepository(
@ -223,7 +224,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
throws Exception
{
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class);
RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID );
repositoryRegistry.removeRepository( TEST_REPO_ID );
repositoryRegistry.putRepository(
@ -304,7 +305,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
throws Exception
{
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class);
RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID );
repositoryRegistry.removeRepository( TEST_REPO_ID );
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.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.custommonkey.xmlunit.XMLAssert;
@ -260,14 +261,14 @@ public class RepositoryPurgeConsumerTest
private void addRepoToConfiguration( String configHint, org.apache.archiva.repository.ManagedRepository repoConfiguration )
throws Exception
{
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class);
RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
repositoryRegistry.putRepository( repoConfiguration );
}
private void removeRepoFromConfiguration( String configHint, org.apache.archiva.repository.ManagedRepository repoConfiguration )
throws Exception
{
RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class);
RepositoryRegistry repositoryRegistry = applicationContext.getBean( ArchivaRepositoryRegistry.class);
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.FileTypes;
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.ReleaseScheme;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
@ -94,7 +94,7 @@ public class NexusIndexerConsumerTest
private ApplicationContext applicationContext;
@Inject
RepositoryRegistry repositoryRegistry;
ArchivaRepositoryRegistry repositoryRegistry;
@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.ProxyConnector;
import org.apache.archiva.proxy.model.RepositoryProxyHandler;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.event.EventHandler;
import org.apache.archiva.repository.event.RepositoryRegistryEvent;
@ -65,7 +65,7 @@ public class ArchivaProxyRegistry implements ProxyRegistry, EventHandler<Reposit
List<Policy> policies;
@Inject
RepositoryRegistry repositoryRegistry;
ArchivaRepositoryRegistry repositoryRegistry;
private Map<String, NetworkProxy> networkProxyMap = 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
*/
@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);
@ -94,11 +96,12 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
private volatile boolean ignoreConfigEvents = false;
public RepositoryRegistry() {
public ArchivaRepositoryRegistry() {
this.eventManager = new EventManager(this);
}
public void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration) {
@Override
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) {
this.archivaConfiguration = archivaConfiguration;
}
@ -233,7 +236,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
repo.registerEventHandler(RepositoryEvent.ANY, this);
}
public ArchivaIndexManager getIndexManager(RepositoryType type) {
@Override
public ArchivaIndexManager getIndexManager( RepositoryType type ) {
return indexManagerFactory.getIndexManager(type);
}
@ -361,7 +365,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
*
* @return a list of managed and remote repositories
*/
public Collection<Repository> getRepositories() {
@Override
public Collection<Repository> getRepositories( ) {
rwLock.readLock().lock();
try {
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
*/
public Collection<ManagedRepository> getManagedRepositories() {
@Override
public Collection<ManagedRepository> getManagedRepositories( ) {
rwLock.readLock().lock();
try {
return uManagedRepository.values();
@ -389,7 +395,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
*
* @return a list of remote repositories
*/
public Collection<RemoteRepository> getRemoteRepositories() {
@Override
public Collection<RemoteRepository> getRemoteRepositories( ) {
rwLock.readLock().lock();
try {
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();
try {
return uRepositoryGroups.values();
@ -414,7 +422,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repoId the repository id
* @return the repository if found, otherwise null
*/
public Repository getRepository(String repoId) {
@Override
public Repository getRepository( String repoId ) {
rwLock.readLock().lock();
try {
log.debug("getRepository {}", repoId);
@ -441,7 +450,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repoId the repository id
* @return the managed repository if found, otherwise null
*/
public ManagedRepository getManagedRepository(String repoId) {
@Override
public ManagedRepository getManagedRepository( String repoId ) {
rwLock.readLock().lock();
try {
return managedRepositories.get(repoId);
@ -457,7 +467,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repoId the repository id
* @return the remote repository if found, otherwise null
*/
public RemoteRepository getRemoteRepository(String repoId) {
@Override
public RemoteRepository getRemoteRepository( String repoId ) {
rwLock.readLock().lock();
try {
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();
try {
return repositoryGroups.get(groupId);
@ -496,7 +508,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param managedRepository the new repository.
* @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();
try {
final String id = managedRepository.getId();
@ -547,7 +560,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the updated or created repository
* @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();
try {
final String id = managedRepositoryConfiguration.getId();
@ -581,7 +595,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the new or updated repository
* @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();
try {
final String id = managedRepositoryConfiguration.getId();
@ -622,7 +637,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repositoryGroup the new repository group.
* @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();
try {
final String id = repositoryGroup.getId();
@ -665,7 +681,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the updated or created repository
* @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();
try {
final String id = repositoryGroupConfiguration.getId();
@ -699,7 +716,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return The new or updated repository group
* @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();
try {
final String id = repositoryGroupConfiguration.getId();
@ -765,7 +783,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
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();
try {
final String id = remoteRepository.getId();
@ -822,7 +841,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param remoteRepository the remote repository to add
* @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();
try {
Configuration configuration = getArchivaConfiguration().getConfiguration();
@ -847,7 +867,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @return the updated or created repository
* @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();
try {
final String id = remoteRepositoryConfiguration.getId();
@ -881,8 +902,9 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @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 {
public RemoteRepository putRepository( RemoteRepositoryConfiguration remoteRepositoryConfiguration, Configuration configuration ) throws RepositoryException {
rwLock.writeLock().lock();
try {
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);
if (repo != null) {
removeRepository(repo);
}
}
public void removeRepository(Repository repo) throws RepositoryException {
@Override
public void removeRepository( Repository repo ) throws RepositoryException {
if (repo == null) {
log.warn("Trying to remove null repository");
return;
@ -946,7 +970,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param managedRepository the managed repository to remove
* @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) {
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) {
return;
}
@ -1019,7 +1045,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repositoryGroup the repository group to remove
* @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) {
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) {
return;
}
@ -1095,7 +1123,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param remoteRepository the remote repository to remove
* @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) {
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) {
return;
}
@ -1146,7 +1176,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
/**
* Reloads the registry from the configuration.
*/
public void reload() {
@Override
public void reload( ) {
initialize();
}
@ -1156,7 +1187,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repository The repository
* @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) {
EditableRepository eRepo = (EditableRepository) repository;
ArchivaIndexingContext newCtx = getIndexManager(repository.getType()).reset(repository.getIndexingContext());
@ -1172,7 +1204,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repo The origin 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)) {
throw new RepositoryException("The given id exists already " + newId);
}
@ -1184,7 +1217,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
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) {
return this.clone((RemoteRepository) repo, newId);
} else if (repo instanceof ManagedRepository) {
@ -1201,7 +1235,8 @@ public class RepositoryRegistry implements ConfigurationListener, EventSource, E
* @param repo The origin 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)) {
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.indexer.ArchivaIndexingContext;
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.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;
@ -59,7 +59,7 @@ import static org.junit.Assert.*;
public class MavenIndexManagerTest {
@Inject
RepositoryRegistry repositoryRegistry;
ArchivaRepositoryRegistry repositoryRegistry;
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.search.SearchResultHit;
import org.apache.archiva.indexer.search.SearchResults;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.lang3.SystemUtils;
@ -90,7 +90,7 @@ public abstract class AbstractMavenRepositorySearch
ArtifactContextProducer artifactContextProducer;
@Inject
RepositoryRegistry repositoryRegistry;
ArchivaRepositoryRegistry repositoryRegistry;
@Inject
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.SearchResultHit;
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.junit.After;
import org.junit.Test;
@ -32,7 +32,6 @@ import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
/**
* @author Olivier Lamy
@ -42,7 +41,7 @@ public class MavenRepositorySearchOSGITest
{
@Inject
RepositoryRegistry repositoryRegistry;
ArchivaRepositoryRegistry repositoryRegistry;
@After
@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.SearchResults;
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.junit.After;
import org.junit.Test;
@ -43,7 +43,7 @@ public class MavenRepositorySearchPaginateTest
{
@Autowired
RepositoryRegistry repositoryRegistry;
ArchivaRepositoryRegistry repositoryRegistry;
@After
public void endTests() {

View File

@ -22,7 +22,8 @@ package org.apache.archiva.repository;
import java.util.Map;
import java.util.TreeMap;
public class RepositoryRegistryMock extends RepositoryRegistry {
public class RepositoryRegistryMock extends ArchivaRepositoryRegistry
{
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 org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.indexer.UnsupportedBaseContextException;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.BasicManagedRepository;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
@ -71,7 +71,7 @@ public class ArchivaIndexingTaskExecutorTest
private ArchivaIndexingTaskExecutor indexingExecutor;
@Inject
RepositoryRegistry repositoryRegistry;
ArchivaRepositoryRegistry repositoryRegistry;
@Inject
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.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.BasicManagedRepository;
import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.RepositoryRegistry;
@ -42,7 +43,6 @@ import org.junit.runner.RunWith;
import java.nio.file.Paths;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAccessor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -106,7 +106,7 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
sessionControl.replay();
repositoryRegistryControl = EasyMock.createControl();
repositoryRegistry = repositoryRegistryControl.createMock( RepositoryRegistry.class );
repositoryRegistry = repositoryRegistryControl.createMock( ArchivaRepositoryRegistry.class );
List<Repository> reg = new ArrayList<>( );
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.ConfigurationListener;
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.RepositoryRegistry;
import org.apache.archiva.security.ServletAuthenticator;
@ -169,7 +170,7 @@ public class RepositoryServlet
configuration = wac.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
configuration.addListener(this);
repositoryRegistry = wac.getBean(RepositoryRegistry.class);
repositoryRegistry = wac.getBean( ArchivaRepositoryRegistry.class);
resourceFactory = wac.getBean("davResourceFactory#archiva", DavResourceFactory.class);
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.RemoteRepositoryConfiguration;
import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.repository.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest;
@ -100,7 +100,7 @@ public abstract class AbstractRepositoryServletTestCase
@Inject
RepositoryRegistry repositoryRegistry;
ArchivaRepositoryRegistry repositoryRegistry;
protected Logger log = LoggerFactory.getLogger( getClass() );