summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-scheduler
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-11-02 22:32:15 +0000
committerOlivier Lamy <olamy@apache.org>2011-11-02 22:32:15 +0000
commitbaaa23f0928f73966b7101c62db9cadfc845a9b6 (patch)
tree74f6d4fdc93cc46020fe1e6eb8c219b7fc141a95 /archiva-modules/archiva-scheduler
parent0262091faaaed893c6c43d2a7090d5d92cbba4aa (diff)
downloadarchiva-baaa23f0928f73966b7101c62db9cadfc845a9b6.tar.gz
archiva-baaa23f0928f73966b7101c62db9cadfc845a9b6.zip
remove this ugly static method
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1196841 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-scheduler')
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java17
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java44
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java6
3 files changed, 12 insertions, 55 deletions
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
index 3d9a0b199..059898732 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
@@ -20,7 +20,9 @@ package org.apache.archiva.scheduler.indexing;
* under the License.
*/
+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.plexusbridge.MavenIndexerUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
@@ -29,7 +31,6 @@ import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.maven.index.ArtifactContext;
import org.apache.maven.index.ArtifactContextProducer;
-import org.apache.maven.index.DefaultArtifactContextProducer;
import org.apache.maven.index.FlatSearchRequest;
import org.apache.maven.index.FlatSearchResponse;
import org.apache.maven.index.MAVEN;
@@ -37,7 +38,6 @@ import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.artifact.IllegalArtifactCoordinateException;
import org.apache.maven.index.context.IndexCreator;
import org.apache.maven.index.context.IndexingContext;
-import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
import org.apache.maven.index.expr.SourcedSearchExpression;
import org.apache.maven.index.packer.IndexPacker;
import org.apache.maven.index.packer.IndexPackingRequest;
@@ -78,6 +78,9 @@ public class ArchivaIndexingTaskExecutor
@Inject
private MavenIndexerUtils mavenIndexerUtils;
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
private NexusIndexer nexusIndexer;
private List<? extends IndexCreator> allIndexCreators;
@@ -130,15 +133,9 @@ public class ArchivaIndexingTaskExecutor
{
log.debug( "Creating indexing context on resource: {}",
indexingTask.getResourceFile().getPath() );
- context = ArtifactIndexingTask.createContext( repository, nexusIndexer, allIndexCreators );
- }
- catch ( IOException e )
- {
- log.error( "Error occurred while creating context: " + e.getMessage() );
- throw new TaskExecutionException( "Error occurred while creating context: " + e.getMessage(),
- e );
+ context = managedRepositoryAdmin.createIndexContext( repository );
}
- catch ( UnsupportedExistingLuceneIndexException e )
+ catch ( RepositoryAdminException e )
{
log.error( "Error occurred while creating context: " + e.getMessage() );
throw new TaskExecutionException( "Error occurred while creating context: " + e.getMessage(),
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
index 5ab9efd08..560105366 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
@@ -181,48 +181,4 @@ public class ArtifactIndexingTask
+ resourceFile + "]";
}
- /**
- * FIXME remove this static somewhere else !
- * @param repository
- * @param indexer
- * @param indexCreators
- * @return
- * @throws IOException
- * @throws UnsupportedExistingLuceneIndexException
- */
- public static IndexingContext createContext( ManagedRepository repository, NexusIndexer indexer,
- List<? extends IndexCreator> indexCreators )
- throws IOException, UnsupportedExistingLuceneIndexException
- {
- IndexingContext context = indexer.getIndexingContexts().get( repository.getId() );
-
- if ( context != null )
- {
- LoggerFactory.getLogger( ArtifactIndexingTask.class ).debug(
- "skip adding repository with id {} as already exists", repository.getId() );
- return context;
- }
-
-
- String indexDir = repository.getIndexDirectory();
- File managedRepository = new File( repository.getLocation() );
-
- File indexDirectory = null;
- if ( indexDir != null && !"".equals( indexDir ) )
- {
- indexDirectory = new File( repository.getIndexDirectory() );
- }
- else
- {
- indexDirectory = new File( managedRepository, ".indexer" );
- }
-
-
- context = indexer.addIndexingContext( repository.getId(), repository.getId(), managedRepository, indexDirectory,
- managedRepository.toURI().toURL().toExternalForm(),
- indexDirectory.toURI().toURL().toString(), indexCreators );
-
- context.setSearchable( repository.isScanned() );
- return context;
- }
}
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
index e0fbdeb65..aff511520 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
@@ -21,6 +21,7 @@ package org.apache.archiva.scheduler.indexing;
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.plexusbridge.MavenIndexerUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.commons.io.FileUtils;
@@ -76,6 +77,9 @@ public class ArchivaIndexingTaskExecutorTest
@Inject
MavenIndexerUtils mavenIndexerUtils;
+ @Inject
+ ManagedRepositoryAdmin managedRepositoryAdmin;
+
@Before
public void setUp()
throws Exception
@@ -93,7 +97,7 @@ public class ArchivaIndexingTaskExecutorTest
indexer = plexusSisuBridge.lookup( NexusIndexer.class );
- ArtifactIndexingTask.createContext( repositoryConfig, indexer, mavenIndexerUtils.getAllIndexCreators() );
+ managedRepositoryAdmin.createIndexContext( repositoryConfig );
}
@After