Skip to content
Permalink
Browse files
Migration to remote repository handler
  • Loading branch information
effrafax committed Aug 31, 2021
1 parent f40d750 commit 292dbe1bb4323dd299d36b78f37d9c1d55c889f8
Show file tree
Hide file tree
Showing 46 changed files with 1,969 additions and 734 deletions.
@@ -23,7 +23,7 @@
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.repository.base.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.base.managed.BasicManagedRepository;
import org.apache.archiva.repository.base.managed.ManagedRepositoryHandler;
import org.apache.archiva.repository.base.RepositoryHandlerDependencies;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry;
import org.junit.Before;
@@ -59,11 +59,7 @@

@SuppressWarnings( "unused" )
@Inject
private ManagedRepositoryHandler managedRepositoryHandler;

@SuppressWarnings( "unused" )
@Inject
private org.apache.archiva.repository.base.group.RepositoryGroupHandler repositoryGroupHandler;
private RepositoryHandlerDependencies repositoryHandlerDependencies;

@Inject
private RepositorySessionFactory repositorySessionFactory;
@@ -26,24 +26,21 @@
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.base.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.base.group.RepositoryGroupHandler;
import org.apache.archiva.repository.base.managed.ManagedRepositoryHandler;
import org.apache.archiva.repository.base.RepositoryHandlerDependencies;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;

import javax.inject.Inject;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
@@ -65,11 +62,7 @@

@SuppressWarnings( "unused" )
@Inject
RepositoryGroupHandler repositoryGroupHandler;

@SuppressWarnings( "unused" )
@Inject
ManagedRepositoryHandler managedRepositoryHandler;
RepositoryHandlerDependencies repositoryHandlerDependencies;


@Before
@@ -24,8 +24,7 @@
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.base.group.RepositoryGroupHandler;
import org.apache.archiva.repository.base.managed.ManagedRepositoryHandler;
import org.apache.archiva.repository.base.RepositoryHandlerDependencies;
import org.apache.archiva.repository.maven.metadata.storage.Maven2RepositoryPathTranslator;
import org.apache.archiva.repository.base.managed.BasicManagedRepository;
import org.apache.archiva.repository.ReleaseScheme;
@@ -114,11 +113,7 @@

@SuppressWarnings( "unused" )
@Inject
RepositoryGroupHandler repositoryGroupHandler;

@SuppressWarnings( "unused" )
@Inject
ManagedRepositoryHandler managedRepositoryHandler;
RepositoryHandlerDependencies repositoryHandlerDependencies;


@Before
@@ -21,14 +21,13 @@

import junit.framework.TestCase;
import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.components.taskqueue.TaskQueueException;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.components.taskqueue.TaskQueueException;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.base.ArchivaRepositoryRegistry;
import org.apache.archiva.repository.base.RepositoryHandlerDependencies;
import org.apache.archiva.repository.base.managed.BasicManagedRepository;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.base.group.RepositoryGroupHandler;
import org.apache.archiva.repository.base.managed.ManagedRepositoryHandler;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
@@ -45,7 +44,11 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* NexusIndexerConsumerTest
@@ -100,11 +103,7 @@ public void queueTask( ArtifactIndexingTask task )

@SuppressWarnings( "unused" )
@Inject
RepositoryGroupHandler repositoryGroupHandler;

@SuppressWarnings( "unused" )
@Inject
ManagedRepositoryHandler managedRepositoryHandler;
RepositoryHandlerDependencies repositoryHandlerDependencies;

@Override
@Before
@@ -51,12 +51,4 @@ Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformat
Map<String, RemoteRepository> getRemoteRepositoriesAsMap()
throws RepositoryAdminException;

/**
* @param repository
* @return
* @throws RepositoryAdminException
* @since 1.4-M2
*/
ArchivaIndexingContext createIndexContext( RemoteRepository repository )
throws RepositoryAdminException;
}
@@ -23,28 +23,27 @@
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.components.cache.Cache;
import org.apache.archiva.components.taskqueue.TaskQueueException;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.indexer.ArchivaIndexManager;
import org.apache.archiva.indexer.IndexManagerFactory;
import org.apache.archiva.indexer.IndexUpdateFailedException;
import org.apache.archiva.metadata.model.facets.AuditEvent;
import org.apache.archiva.metadata.repository.*;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.MetadataSessionException;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager;
import org.apache.archiva.components.cache.Cache;
import org.apache.archiva.components.registry.RegistryException;
import org.apache.archiva.components.taskqueue.TaskQueueException;
import org.apache.archiva.redback.role.RoleManager;
import org.apache.archiva.redback.role.RoleManagerException;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.base.group.RepositoryGroupHandler;
import org.apache.archiva.repository.base.managed.ManagedRepositoryHandler;
import org.apache.archiva.repository.base.RepositoryHandlerDependencies;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.StagingRepositoryFeature;
@@ -88,11 +87,9 @@
@Inject
private RepositoryRegistry repositoryRegistry;

@SuppressWarnings( "unused" )
@Inject
private ManagedRepositoryHandler managedRepositoryHandler;

@Inject
private RepositoryGroupHandler repositoryGroupHandler;
private RepositoryHandlerDependencies managedRepositoryHandler;

@Inject
@Named(value = "archivaTaskScheduler#repository")
@@ -133,18 +133,14 @@ public void deleteNetworkProxy( String networkProxyId, AuditInformation auditInf
throw new RepositoryAdminException(
"cannot delete NetworkProxy with id " + networkProxyId + " as not exist" );
}
Configuration configuration = getArchivaConfiguration().getConfiguration();
NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration( networkProxy );
configuration.removeNetworkProxy( networkProxyConfiguration );

for ( RemoteRepository repo : repositoryRegistry.getRemoteRepositories()) {
if (repo.supportsFeature( RemoteIndexFeature.class )) {
RemoteIndexFeature rif = repo.getFeature( RemoteIndexFeature.class ).get();
if (networkProxyId.equals(rif.getProxyId())) {
rif.setProxyId( null );
try
{
repositoryRegistry.putRepository( repo, configuration);
repositoryRegistry.putRepository( repo );
}
catch ( RepositoryException e )
{
@@ -154,9 +150,11 @@ public void deleteNetworkProxy( String networkProxyId, AuditInformation auditInf
}
}

triggerAuditEvent( networkProxy.getId(), null, AuditEvent.DELETE_NETWORK_PROXY, auditInformation );

Configuration configuration = getArchivaConfiguration().getConfiguration();
NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration( networkProxy );
configuration.removeNetworkProxy( networkProxyConfiguration );
saveConfiguration( configuration );
triggerAuditEvent( networkProxy.getId(), null, AuditEvent.DELETE_NETWORK_PROXY, auditInformation );
}

protected NetworkProxy getNetworkProxy( NetworkProxyConfiguration networkProxyConfiguration )

0 comments on commit 292dbe1

Please sign in to comment.