Updating indexing path
import org.apache.archiva.proxy.common.WagonFactoryException;
import org.apache.archiva.proxy.common.WagonFactoryRequest;
import org.apache.archiva.repository.*;
+import org.apache.archiva.repository.features.IndexCreationEvent;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.commons.lang.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
+import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.FileNotFoundException;
import java.io.IOException;
* time of retries a IndexUpdateFailedException is thrown.
*/
@Service( "archivaIndexManager#maven" )
-public class MavenIndexManager implements ArchivaIndexManager
-{
+public class MavenIndexManager implements ArchivaIndexManager {
private static final Logger log = LoggerFactory.getLogger( MavenIndexManager.class );
@Inject
private ArtifactContextProducer artifactContextProducer;
+ @Inject
+ RepositoryRegistry repositoryRegistry;
+
+ public static final String DEFAULT_INDEXER_DIR = ".indexer";
+
private ConcurrentSkipListSet<Path> activeContexts = new ConcurrentSkipListSet<>( );
private static final int WAIT_TIME = 100;
@@ -511,6 +517,18 @@ public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository re
}
}
+ @Override
+ public void updateLocalIndexPath(Repository repo) {
+ if (repo.supportsFeature(IndexCreationFeature.class)) {
+ IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
+ try {
+ icf.setLocalIndexPath(getIndexPath(repo));
+ } catch (IOException e) {
+ log.error("Could not set local index path for {}. New URI: {}", repo.getId(), icf.getIndexPath());
+ }
+ }
+ }
+
private Path getIndexPath(Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
Path repoDir = repo.getLocalPath();
@@ -528,7 +546,7 @@ private Path getIndexPath(Repository repo) throws IOException {
}
else
{
- indexDirectory = repoDir.resolve( ".index" );
+ indexDirectory = repoDir.resolve( DEFAULT_INDEXER_DIR );
}
if ( !Files.exists( indexDirectory ) )
@@ -644,7 +662,7 @@ private String calculateIndexRemoteUrl( URI baseUri, RemoteIndexFeature rif )
{
if ( rif.getIndexUri( ) == null )
{
- return baseUri.resolve( ".index" ).toString( );
+ return baseUri.resolve( DEFAULT_INDEXER_DIR ).toString( );
}
else
{
