aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2017-11-01 15:33:06 +0100
committerMartin Stockhammer <martin_s@apache.org>2017-11-01 15:33:06 +0100
commit4bcf4c0cd05220156cbba00be5408985f182805c (patch)
tree4cd6300464adc33b1441092032a1a7e39e03dbc1 /archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src
parentfd51964c13cdeb633aad1944c0b95b1a571681e2 (diff)
downloadarchiva-4bcf4c0cd05220156cbba00be5408985f182805c.tar.gz
archiva-4bcf4c0cd05220156cbba00be5408985f182805c.zip
Adapting consumers to new repository api interfaces.
Using the repository api where necessary.
Diffstat (limited to 'archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src')
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java10
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/conf/repository-manager.xml2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java37
3 files changed, 32 insertions, 17 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
index 434f864e6..50dd8c1c4 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
@@ -20,8 +20,8 @@ package org.apache.archiva.consumers.lucene;
*/
import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.ConfigurationNames;
import org.apache.archiva.configuration.FileTypes;
@@ -31,6 +31,8 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.redback.components.registry.Registry;
import org.apache.archiva.redback.components.registry.RegistryListener;
import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
+import org.apache.archiva.repository.ManagedRepository;
+import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.maven.index.NexusIndexer;
@@ -60,6 +62,10 @@ public class NexusIndexerConsumer
extends AbstractMonitoredConsumer
implements KnownRepositoryContentConsumer, RegistryListener
{
+
+ @Inject
+ private RepositoryRegistry repositoryRegistry;
+
private Logger log = LoggerFactory.getLogger( getClass() );
private ArchivaConfiguration configuration;
@@ -113,7 +119,7 @@ public class NexusIndexerConsumer
throws ConsumerException
{
this.repository = repository;
- managedRepository = Paths.get( repository.getLocation() );
+ managedRepository = PathUtil.getPathFromUri( repository.getLocation() );
try
{
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/conf/repository-manager.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/conf/repository-manager.xml
index 6c836b81c..106fcea10 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/conf/repository-manager.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/conf/repository-manager.xml
@@ -30,7 +30,7 @@
<snapshots>true</snapshots>
<indexed>true</indexed>
<refreshCronExpression>0 0 * * * ?</refreshCronExpression>
- <retentionTime>0</retentionTime>
+ <retentionPeriod>0</retentionPeriod>
<retentionCount>2</retentionCount>
</repository>
</repositories>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
index 2b76279a0..2a8546a72 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
@@ -20,16 +20,20 @@ package org.apache.archiva.consumers.lucene;
*/
import junit.framework.TestCase;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+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.BasicManagedRepository;
+import org.apache.archiva.repository.ManagedRepository;
+import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.context.IndexCreator;
+import org.apache.regexp.RE;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -39,6 +43,7 @@ import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import java.io.IOException;
+import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -46,6 +51,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
/**
@@ -89,7 +95,7 @@ public class NexusIndexerConsumerTest
private NexusIndexerConsumer nexusIndexerConsumer;
- private ManagedRepository repositoryConfig;
+ private BasicManagedRepository repositoryConfig;
private ArchivaTaskSchedulerStub scheduler;
@@ -126,27 +132,27 @@ public class NexusIndexerConsumerTest
// initialize to set the file types to be processed
nexusIndexerConsumer.initialize();
- repositoryConfig = new ManagedRepository();
- repositoryConfig.setId( "test-repo" );
- repositoryConfig.setLocation( "target/test-classes/test-repo" );
+ repositoryConfig = new BasicManagedRepository( "test-repo", "Test Repository" );
+ repositoryConfig.setLocation( new URI("target/test-classes/test-repo") );
repositoryConfig.setLayout( "default" );
- repositoryConfig.setName( "Test Repository" );
repositoryConfig.setScanned( true );
- repositoryConfig.setSnapshots( false );
- repositoryConfig.setReleases( true );
+ repositoryConfig.addActiveReleaseScheme( ReleaseScheme.RELEASE );
+ repositoryConfig.removeActiveReleaseScheme( ReleaseScheme.SNAPSHOT );
}
+
@Override
@After
public void tearDown()
throws Exception
{
// delete created index in the repository
- Path indexDir = Paths.get( repositoryConfig.getLocation(), ".indexer" );
+ Path basePath = PathUtil.getPathFromUri( repositoryConfig.getLocation() );
+ Path indexDir = basePath.resolve( ".indexer" );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDir );
assertFalse( Files.exists(indexDir) );
- indexDir = Paths.get( repositoryConfig.getLocation(), ".index" );
+ indexDir = basePath.resolve( ".index" );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDir );
assertFalse( Files.exists(indexDir) );
@@ -157,7 +163,8 @@ public class NexusIndexerConsumerTest
public void testIndexerIndexArtifact()
throws Exception
{
- Path artifactFile = Paths.get( repositoryConfig.getLocation(),
+ Path basePath = PathUtil.getPathFromUri( repositoryConfig.getLocation() );
+ Path artifactFile = basePath.resolve(
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
// begin scan
@@ -174,7 +181,8 @@ public class NexusIndexerConsumerTest
public void testIndexerArtifactAlreadyIndexed()
throws Exception
{
- Path artifactFile = Paths.get( repositoryConfig.getLocation(),
+ Path basePath = PathUtil.getPathFromUri( repositoryConfig.getLocation() );
+ Path artifactFile = basePath.resolve(
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
// begin scan
@@ -200,7 +208,8 @@ public class NexusIndexerConsumerTest
public void testIndexerIndexArtifactThenPom()
throws Exception
{
- Path artifactFile = Paths.get( repositoryConfig.getLocation(),
+ Path basePath = PathUtil.getPathFromUri( repositoryConfig.getLocation( ) );
+ Path artifactFile = basePath.resolve(
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
// begin scan
@@ -213,7 +222,7 @@ public class NexusIndexerConsumerTest
assertTrue( scheduler.indexed.contains( artifactFile ) );
artifactFile =
- Paths.get( repositoryConfig.getLocation(), "org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml" );
+ basePath.resolve( "org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml" );
// scan and index again
now = Calendar.getInstance().getTime();