aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-base/archiva-maven2-indexer/pom.xml6
-rw-r--r--archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexContext.java5
-rw-r--r--archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java11
-rw-r--r--archiva-modules/archiva-base/archiva-maven2-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java35
-rw-r--r--archiva-modules/archiva-base/archiva-maven2-indexer/src/test/resources/spring-context.xml3
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java3
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexingContext.java7
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java2
8 files changed, 65 insertions, 7 deletions
diff --git a/archiva-modules/archiva-base/archiva-maven2-indexer/pom.xml b/archiva-modules/archiva-base/archiva-maven2-indexer/pom.xml
index 2712e3a51..e51f82443 100644
--- a/archiva-modules/archiva-base/archiva-maven2-indexer/pom.xml
+++ b/archiva-modules/archiva-base/archiva-maven2-indexer/pom.xml
@@ -175,6 +175,12 @@
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-file</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<scope>provided</scope>
</dependency>
diff --git a/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexContext.java b/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexContext.java
index 30cc72795..4ee80794d 100644
--- a/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexContext.java
+++ b/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexContext.java
@@ -85,6 +85,11 @@ public class MavenIndexContext implements ArchivaIndexingContext {
}
@Override
+ public void close() throws IOException {
+ delegate.close(false);
+ }
+
+ @Override
public void purge() throws IOException {
delegate.purge();
}
diff --git a/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java b/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java
index d54f868a0..00e67e42f 100644
--- a/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java
+++ b/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java
@@ -242,13 +242,16 @@ public class MavenIndexManager implements ArchivaIndexManager
}
@Override
- public void update( final ArchivaIndexingContext context, final URI remoteUpdateUri, final boolean fullUpdate ) throws IndexUpdateFailedException
+ public void update(final ArchivaIndexingContext context, final boolean fullUpdate) throws IndexUpdateFailedException
{
log.info( "start download remote index for remote repository {}", context.getRepository( ).getId( ) );
-
- if ( !( context.getRepository( ) instanceof RemoteRepository ) )
+ URI remoteUpdateUri;
+ if ( !( context.getRepository( ) instanceof RemoteRepository ) || !(context.getRepository().supportsFeature(RemoteIndexFeature.class)) )
{
- throw new IndexUpdateFailedException( "The context is not associated to a remote repository " + context.getId( ) );
+ throw new IndexUpdateFailedException( "The context is not associated to a remote repository with remote index " + context.getId( ) );
+ } else {
+ RemoteIndexFeature rif = context.getRepository().getFeature(RemoteIndexFeature.class).get();
+ remoteUpdateUri = context.getRepository().getLocation().resolve(rif.getIndexUri());
}
final RemoteRepository remoteRepository = (RemoteRepository) context.getRepository( );
diff --git a/archiva-modules/archiva-base/archiva-maven2-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java b/archiva-modules/archiva-base/archiva-maven2-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java
index 96876ad95..53cdaad81 100644
--- a/archiva-modules/archiva-base/archiva-maven2-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java
+++ b/archiva-modules/archiva-base/archiva-maven2-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java
@@ -24,7 +24,9 @@ import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.indexer.IndexCreationFailedException;
import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.repository.features.IndexCreationFeature;
+import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.archiva.repository.maven2.MavenManagedRepository;
+import org.apache.archiva.repository.maven2.MavenRemoteRepository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.maven.index.MAVEN;
import org.apache.maven.index.QueryCreator;
@@ -59,6 +61,7 @@ public class MavenIndexManagerTest {
private Path indexPath;
private MavenManagedRepository repository;
private ArchivaIndexingContext ctx;
+ private MavenRemoteRepository repositoryRemote;
@Inject
MavenIndexManager mavenIndexManager;
@@ -84,6 +87,19 @@ public class MavenIndexManagerTest {
@Test
public void pack() throws Exception {
+ createTestContext();
+ Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-webapp/1.0");
+ Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-webapp/1.0");
+ org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(),destDir.toFile());
+ mavenIndexManager.scan(ctx);
+ mavenIndexManager.pack(ctx);
+ assertTrue(Files.list(indexPath).filter(path -> {
+ try {
+ return path.getFileName().toString().endsWith(".gz") && Files.size(path) > 0;
+ } catch (IOException e) {
+ return false;
+ }
+ }).findAny().isPresent());
}
@Test
@@ -101,8 +117,16 @@ public class MavenIndexManagerTest {
assertEquals(4, mvnCtx.acquireIndexSearcher().count(q));
}
+ /*
+ * Does only a index update via file uri, no HTTP uri
+ */
@Test
public void update() throws Exception {
+ createTestContext();
+ mavenIndexManager.pack(ctx);
+ ctx.close(false);
+ createTestContextForRemote();
+ mavenIndexManager.update(ctx, true);
}
@Test
@@ -162,6 +186,17 @@ public class MavenIndexManagerTest {
return ctx;
}
+ private ArchivaIndexingContext createTestContextForRemote() throws URISyntaxException, IndexCreationFailedException, IOException {
+ indexPath = Paths.get("target/repositories/test-repo/.index-test");
+ Path repoPath = Paths.get("target/repositories").toAbsolutePath();
+ repositoryRemote = new MavenRemoteRepository("test-repo", "Test Repo", repoPath);
+ repositoryRemote.setLocation(repoPath.resolve("test-repo").toUri());
+ RemoteIndexFeature icf = repositoryRemote.getFeature(RemoteIndexFeature.class).get();
+ icf.setIndexUri(new URI(".index-test"));
+ ctx = mavenIndexManager.createContext(repositoryRemote);
+ return ctx;
+ }
+
@Test
public void createContext() throws Exception {
ArchivaIndexingContext ctx = createTestContext();
diff --git a/archiva-modules/archiva-base/archiva-maven2-indexer/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-maven2-indexer/src/test/resources/spring-context.xml
index 13ef95f3c..fbf53be07 100644
--- a/archiva-modules/archiva-base/archiva-maven2-indexer/src/test/resources/spring-context.xml
+++ b/archiva-modules/archiva-base/archiva-maven2-indexer/src/test/resources/spring-context.xml
@@ -30,6 +30,9 @@
<context:annotation-config/>
<context:component-scan base-package="org.apache.archiva.indexer.maven" />
+
+ <bean name="wagon#file" scope="prototype" class="org.apache.maven.wagon.providers.file.FileWagon"/>
+
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
<props>
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java
index 5e870d04f..fb34eb2ff 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java
@@ -43,10 +43,9 @@ public interface ArchivaIndexManager {
/**
* Updates the index from the remote url.
* @param context
- * @param remoteUpdateUri
* @param fullUpdate
*/
- void update(ArchivaIndexingContext context, URI remoteUpdateUri, boolean fullUpdate) throws IndexUpdateFailedException;
+ void update(ArchivaIndexingContext context, boolean fullUpdate) throws IndexUpdateFailedException;
/**
* Adds a list of artifacts to the index.
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexingContext.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexingContext.java
index 7f31b0450..95555a3c3 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexingContext.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexingContext.java
@@ -84,6 +84,13 @@ public interface ArchivaIndexingContext {
void close(boolean deleteFiles) throws IOException;
/**
+ * Closes the context without deleting the files.
+ * Is identical to <code>close(false)</code>
+ * @throws IOException
+ */
+ void close() throws IOException;
+
+ /**
* Removes all entries from the index. After this method finished,
* isEmpty() should return true.
* @throws IOException
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java
index 02069773f..d0f803416 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/GenericIndexManager.java
@@ -40,7 +40,7 @@ public class GenericIndexManager implements ArchivaIndexManager {
}
@Override
- public void update(ArchivaIndexingContext context, URI remoteUpdateUri, boolean fullUpdate) {
+ public void update(ArchivaIndexingContext context, boolean fullUpdate) {
}