aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java14
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java11
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java32
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java104
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java2
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java35
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java28
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java156
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java35
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java2
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutor.java9
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java4
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java67
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTaskNameSelectionPredicate.java47
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArtifactIndexingTask.java108
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java40
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java87
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTaskSelectionPredicate.java53
-rw-r--r--archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java39
-rw-r--r--archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java3
-rw-r--r--archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutorTest.java14
-rw-r--r--archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java3
-rw-r--r--archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java36
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java10
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java57
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java4
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java18
-rw-r--r--archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java2
28 files changed, 328 insertions, 692 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java
index 4ad4c2f7d..ef310b04f 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumer.java
@@ -19,6 +19,9 @@ package org.apache.archiva.consumers.lucene;
* under the License.
*/
+import java.io.File;
+import java.util.List;
+
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
@@ -34,9 +37,6 @@ import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.util.List;
-
/**
* LuceneCleanupRemoveIndexedConsumer
*
@@ -97,16 +97,16 @@ public class LuceneCleanupRemoveIndexedConsumer
if ( !artifactFile.exists() )
{
ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repository.getId(), artifactFile, ArtifactIndexingTask.DELETE );
+ TaskCreator.createIndexingTask( repository.getId(), artifactFile, ArtifactIndexingTask.Action.DELETE );
- log.debug( "Queueing indexing task '" + task.getName() + "' to remove the artifact from the index." );
+ log.debug( "Queueing indexing task '" + task + "' to remove the artifact from the index." );
scheduler.queueIndexingTask( task );
// note we finish immediately here since it isn't done repo-by-repo. It might be nice to ensure that is
// the case for optimisation though
task =
- TaskCreator.createIndexingTask( repository.getId(), artifactFile, ArtifactIndexingTask.FINISH );
- log.debug( "Queueing indexing task + '" + task.getName() + "' to finish indexing." );
+ TaskCreator.createIndexingTask( repository.getId(), artifactFile, ArtifactIndexingTask.Action.FINISH );
+ log.debug( "Queueing indexing task + '" + task + "' to finish indexing." );
scheduler.queueIndexingTask( task );
}
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 69ce89f48..94a22996f 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
@@ -33,6 +33,7 @@ import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryConte
import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask;
import org.apache.maven.archiva.scheduled.tasks.TaskCreator;
+import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask.Action;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,10 +91,10 @@ public class NexusIndexerConsumer
File artifactFile = new File( managedRepository, path );
ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryContent.getId(), artifactFile, ArtifactIndexingTask.ADD );
+ TaskCreator.createIndexingTask( repositoryContent.getId(), artifactFile, ArtifactIndexingTask.Action.ADD );
try
{
- log.debug( "Queueing indexing task + '" + task.getName() + "' to add or update the artifact in the index." );
+ log.debug( "Queueing indexing task + '" + task + "' to add or update the artifact in the index." );
scheduler.queueIndexingTask( task );
}
catch ( TaskQueueException e )
@@ -105,15 +106,15 @@ public class NexusIndexerConsumer
public void completeScan()
{
ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryContent.getId(), null, ArtifactIndexingTask.FINISH );
+ TaskCreator.createIndexingTask( repositoryContent.getId(), null, ArtifactIndexingTask.Action.FINISH );
try
{
- log.debug( "Queueing indexing task + '" + task.getName() + "' to finish indexing." );
+ log.debug( "Queueing indexing task + '" + task + "' to finish indexing." );
scheduler.queueIndexingTask( task );
}
catch ( TaskQueueException e )
{
- log.error( "Error queueing task: " + task.getName() + ": " + e.getMessage(), e );
+ log.error( "Error queueing task: " + task + ": " + e.getMessage(), e );
}
}
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java
index 188735981..4f005dff2 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/LuceneCleanupRemoveIndexedConsumerTest.java
@@ -20,6 +20,7 @@ package org.apache.archiva.consumers.lucene;
*/
import java.io.File;
+import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@@ -31,6 +32,7 @@ import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask;
import org.apache.maven.archiva.scheduled.tasks.TaskCreator;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.codehaus.plexus.taskqueue.TaskQueue;
import org.easymock.MockControl;
import org.easymock.classextension.MockClassControl;
@@ -48,7 +50,7 @@ public class LuceneCleanupRemoveIndexedConsumerTest
private ManagedRepositoryConfiguration repositoryConfig;
- private ArchivaTaskScheduler scheduler;
+ private TaskQueue indexingQueue;
public void setUp()
throws Exception
@@ -58,7 +60,9 @@ public class LuceneCleanupRemoveIndexedConsumerTest
repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
repoFactory = (RepositoryContentFactory) repoFactoryControl.getMock();
- scheduler = ( ArchivaTaskScheduler ) lookup( ArchivaTaskScheduler.class );
+ ArchivaTaskScheduler scheduler = ( ArchivaTaskScheduler ) lookup( ArchivaTaskScheduler.class );
+
+ indexingQueue = (TaskQueue) lookup( TaskQueue.ROLE, "indexing" );
consumer = new LuceneCleanupRemoveIndexedConsumer( repoFactory, scheduler );
@@ -81,9 +85,12 @@ public class LuceneCleanupRemoveIndexedConsumerTest
super.tearDown();
}
+ @SuppressWarnings( "unchecked" )
public void testProcessArtifactArtifactDoesNotExist()
throws Exception
{
+ assertTrue( indexingQueue.getQueueSnapshot().isEmpty() );
+
ArchivaArtifact artifact =
new ArchivaArtifact( "org.apache.archiva", "archiva-lucene-consumers", "1.2", null, "jar", "test-repo" );
@@ -92,9 +99,6 @@ public class LuceneCleanupRemoveIndexedConsumerTest
File artifactFile = new File( repoContent.getRepoRoot(), repoContent.toPath( artifact ) );
- ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.DELETE );
-
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( repositoryConfig.getId() ),
repoContent );
@@ -104,22 +108,26 @@ public class LuceneCleanupRemoveIndexedConsumerTest
repoFactoryControl.verify();
- assertTrue( scheduler.isProcessingIndexingTaskWithName( task.getName() ) );
+ List<ArtifactIndexingTask> queue = indexingQueue.getQueueSnapshot();
+ assertEquals( 2, queue.size() );
+ ArtifactIndexingTask task =
+ TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.DELETE );
+ assertEquals( task, queue.get( 0 ) );
+ task =
+ TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.FINISH );
+ assertEquals( task, queue.get( 1 ) );
}
public void testProcessArtifactArtifactExists()
throws Exception
{
+ assertTrue( indexingQueue.getQueueSnapshot().isEmpty() );
+
ArchivaArtifact artifact =
new ArchivaArtifact( "org.apache.maven.archiva", "archiva-lucene-cleanup", "1.0", null, "jar", "test-repo" );
ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
repoContent.setRepository( repositoryConfig );
- File artifactFile = new File( repoContent.getRepoRoot(), repoContent.toPath( artifact ) );
-
- ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.DELETE );
-
repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( repositoryConfig.getId() ),
repoContent );
@@ -129,7 +137,7 @@ public class LuceneCleanupRemoveIndexedConsumerTest
repoFactoryControl.verify();
- assertFalse( scheduler.isProcessingIndexingTaskWithName( task.getName() ) );
+ assertTrue( indexingQueue.getQueueSnapshot().isEmpty() );
}
@Override
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 2bb33524d..918442493 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
@@ -22,6 +22,7 @@ package org.apache.archiva.consumers.lucene;
import java.io.File;
import java.util.Calendar;
import java.util.Date;
+import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@@ -30,6 +31,8 @@ import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask;
import org.apache.maven.archiva.scheduled.tasks.TaskCreator;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
/**
* NexusIndexerConsumerTest
@@ -38,21 +41,23 @@ public class NexusIndexerConsumerTest
extends PlexusInSpringTestCase
{
private KnownRepositoryContentConsumer nexusIndexerConsumer;
-
+
private ManagedRepositoryConfiguration repositoryConfig;
-
- private ArchivaTaskScheduler scheduler;
-
+
+ private TaskQueue indexingQueue;
+
@Override
- protected void setUp()
+ protected void setUp()
throws Exception
{
super.setUp();
-
- scheduler = ( ArchivaTaskScheduler ) lookup( ArchivaTaskScheduler.class );
-
+
+ ArchivaTaskScheduler scheduler = (ArchivaTaskScheduler) lookup( ArchivaTaskScheduler.class );
+
+ indexingQueue = (TaskQueue) lookup( TaskQueue.ROLE, "indexing" );
+
nexusIndexerConsumer = new NexusIndexerConsumer( scheduler );
-
+
repositoryConfig = new ManagedRepositoryConfiguration();
repositoryConfig.setId( "test-repo" );
repositoryConfig.setLocation( getBasedir() + "/target/test-classes/test-repo" );
@@ -62,7 +67,7 @@ public class NexusIndexerConsumerTest
repositoryConfig.setSnapshots( false );
repositoryConfig.setReleases( true );
}
-
+
@Override
protected void tearDown()
throws Exception
@@ -71,33 +76,44 @@ public class NexusIndexerConsumerTest
File indexDir = new File( repositoryConfig.getLocation(), ".indexer" );
FileUtils.deleteDirectory( indexDir );
assertFalse( indexDir.exists() );
-
+
indexDir = new File( repositoryConfig.getLocation(), ".index" );
FileUtils.deleteDirectory( indexDir );
assertFalse( indexDir.exists() );
-
+
super.tearDown();
}
-
+
public void testIndexerIndexArtifact()
throws Exception
- {
+ {
File artifactFile =
new File( repositoryConfig.getLocation(),
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
- ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
-
// begin scan
Date now = Calendar.getInstance().getTime();
nexusIndexerConsumer.beginScan( repositoryConfig, now );
nexusIndexerConsumer.processFile( "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
nexusIndexerConsumer.completeScan();
-
- assertTrue( scheduler.isProcessingIndexingTaskWithName( task.getName() ) );
+
+ assertTaskQueued( artifactFile );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private void assertTaskQueued( File artifactFile )
+ throws TaskQueueException
+ {
+ List<ArtifactIndexingTask> queue = indexingQueue.getQueueSnapshot();
+ assertEquals( 2, queue.size() );
+ ArtifactIndexingTask task =
+ TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.ADD );
+ assertEquals( task, queue.get( 0 ) );
+
+ task = TaskCreator.createIndexingTask( repositoryConfig.getId(), null, ArtifactIndexingTask.Action.FINISH );
+ assertEquals( task, queue.get( 1 ) );
}
-
+
public void testIndexerArtifactAlreadyIndexed()
throws Exception
{
@@ -105,60 +121,54 @@ public class NexusIndexerConsumerTest
new File( repositoryConfig.getLocation(),
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
- ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
-
// begin scan
Date now = Calendar.getInstance().getTime();
nexusIndexerConsumer.beginScan( repositoryConfig, now );
nexusIndexerConsumer.processFile( "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
nexusIndexerConsumer.completeScan();
-
- assertTrue( scheduler.isProcessingIndexingTaskWithName( task.getName() ) );
-
+
+ assertTaskQueued( artifactFile );
+ indexingQueue.take();
+ indexingQueue.take();
+
// scan and index again
now = Calendar.getInstance().getTime();
nexusIndexerConsumer.beginScan( repositoryConfig, now );
- nexusIndexerConsumer.processFile( "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
+ nexusIndexerConsumer.processFile( "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
nexusIndexerConsumer.completeScan();
-
- assertTrue( scheduler.isProcessingIndexingTaskWithName( task.getName() ) );
+
+ assertTaskQueued( artifactFile );
}
-
+
public void testIndexerIndexArtifactThenPom()
throws Exception
- {
+ {
File artifactFile =
new File( repositoryConfig.getLocation(),
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
- ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
-
// begin scan
Date now = Calendar.getInstance().getTime();
nexusIndexerConsumer.beginScan( repositoryConfig, now );
nexusIndexerConsumer.processFile( "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
nexusIndexerConsumer.completeScan();
-
- assertTrue( scheduler.isProcessingIndexingTaskWithName( task.getName() ) );
-
+
+ assertTaskQueued( artifactFile );
+ indexingQueue.take();
+ indexingQueue.take();
+
artifactFile =
- new File( repositoryConfig.getLocation(),
- "org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml" );
+ new File( repositoryConfig.getLocation(), "org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml" );
- task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
-
// scan and index again
now = Calendar.getInstance().getTime();
nexusIndexerConsumer.beginScan( repositoryConfig, now );
- nexusIndexerConsumer.processFile( "org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml" );
+ nexusIndexerConsumer.processFile( "org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml" );
nexusIndexerConsumer.completeScan();
-
- assertTrue( scheduler.isProcessingIndexingTaskWithName( task.getName() ) );
- }
-
+
+ assertTaskQueued( artifactFile );
+ }
+
@Override
protected String getPlexusConfigLocation()
{
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
index 5bd96d269..06ab597cd 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
@@ -585,7 +585,7 @@ public class DefaultRepositoryProxyConnectors
private void queueRepositoryTask( String repositoryId, File localFile )
{
- RepositoryTask task = TaskCreator.createRepositoryTask( repositoryId, localFile.getName(), localFile, true, true );
+ RepositoryTask task = TaskCreator.createRepositoryTask( repositoryId, localFile, true, true );
try
{
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java
index d3e9592ad..444a7b1d2 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java
@@ -38,22 +38,12 @@ public interface ArchivaTaskScheduler
public final static String ROLE = ArchivaTaskScheduler.class.getName();
/**
- * Checks if there is any repository scanning task queued.
- *
- * @return
- * @throws ArchivaException
- */
- public boolean isProcessingAnyRepositoryTask()
- throws ArchivaException;
-
- /**
* Checks if there is any database scanning task queued.
*
* @return
* @throws ArchivaException
*/
- public boolean isProcessingDatabaseTask()
- throws ArchivaException;
+ public boolean isProcessingDatabaseTask();
/**
* Checks if a repository scanning task for the specified repository is queuedd.
@@ -62,30 +52,9 @@ public interface ArchivaTaskScheduler
* @return
* @throws ArchivaException
*/
- public boolean isProcessingRepositoryTask( String repositoryId )
- throws ArchivaException;
+ public boolean isProcessingRepositoryTask( String repositoryId );
/**
- * Checks if a repository scanning task with the specified name is queued.
- *
- * @param taskName
- * @return
- * @throws ArchivaException
- */
- public boolean isProcessingRepositoryTaskWithName( String taskName )
- throws ArchivaException;
-
- /**
- * Checks is an indexing task with the specified name is queued.
- *
- * @param taskName
- * @return
- * @throws ArchivaException
- */
- public boolean isProcessingIndexingTaskWithName( String taskName )
- throws ArchivaException;
-
- /**
* Adds the database task to the database scanning queue.
*
* @param task
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java
index ede35a8f6..e00829be1 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java
@@ -19,9 +19,9 @@ package org.apache.maven.archiva.scheduled;
* under the License.
*/
-import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
import org.codehaus.plexus.scheduler.AbstractJob;
+import org.codehaus.plexus.taskqueue.Task;
import org.codehaus.plexus.taskqueue.TaskQueue;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.quartz.JobDataMap;
@@ -34,12 +34,6 @@ import org.quartz.JobExecutionException;
public class DatabaseTaskJob
extends AbstractJob
{
- static final String TASK_KEY = "EXECUTION";
-
- static final String TASK_QUEUE = "TASK_QUEUE";
-
- static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY";
-
/**
* Execute the discoverer and the indexer.
*
@@ -53,29 +47,17 @@ public class DatabaseTaskJob
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
setJobDataMap( dataMap );
- TaskQueue taskQueue = (TaskQueue) dataMap.get( TASK_QUEUE );
- String queuePolicy = (String) dataMap.get( TASK_QUEUE_POLICY );
+ TaskQueue taskQueue = (TaskQueue) dataMap.get( DefaultArchivaTaskScheduler.TASK_QUEUE );
- ArchivaTask task = new DatabaseTask();
- task.setName( context.getJobDetail().getName() );
+ Task task = new DatabaseTask();
try
{
- if ( taskQueue.getQueueSnapshot().size() == 0 )
+ // The database job only needs to run one at a time
+ if ( taskQueue.getQueueSnapshot().isEmpty() )
{
taskQueue.put( task );
}
- else
- {
- if ( ArchivaTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) )
- {
- taskQueue.put( task );
- }
- else if ( ArchivaTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) )
- {
- // do not queue anymore, policy is to skip
- }
- }
}
catch ( TaskQueueException e )
{
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java
index 229a3025e..ee04d3f0d 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java
@@ -19,7 +19,12 @@ package org.apache.maven.archiva.scheduled;
* under the License.
*/
-import org.apache.commons.collections.CollectionUtils;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.maven.archiva.common.ArchivaException;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationEvent;
@@ -28,12 +33,9 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
import org.apache.maven.archiva.repository.scanner.RepositoryScanStatistics;
-import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask;
import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
-import org.apache.maven.archiva.scheduled.tasks.ArchivaTaskNameSelectionPredicate;
-import org.apache.maven.archiva.scheduled.tasks.RepositoryTaskSelectionPredicate;
import org.apache.maven.archiva.scheduled.tasks.TaskCreator;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
@@ -51,12 +53,6 @@ import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
* Default implementation of a scheduling component for archiva.
*
@@ -97,19 +93,21 @@ public class DefaultArchivaTaskScheduler
*/
private ArchivaDAO dao;
- public static final String DATABASE_SCAN_GROUP = "dbg";
+ private static final String DATABASE_SCAN_GROUP = "dbg";
- public static final String DATABASE_JOB = "dbj";
+ private static final String DATABASE_JOB = "dbj";
- public static final String DATABASE_JOB_TRIGGER = "dbt";
+ private static final String DATABASE_JOB_TRIGGER = "dbt";
- public static final String REPOSITORY_SCAN_GROUP = "rg";
+ private static final String REPOSITORY_SCAN_GROUP = "rg";
- public static final String REPOSITORY_JOB = "rj";
+ private static final String REPOSITORY_JOB = "rj";
- public static final String REPOSITORY_JOB_TRIGGER = "rjt";
-
- public static final String INDEXING_JOB = "ij";
+ private static final String REPOSITORY_JOB_TRIGGER = "rjt";
+
+ static final String TASK_QUEUE = "TASK_QUEUE";
+
+ static final String TASK_REPOSITORY = "TASK_REPOSITORY";
public static final String CRON_HOURLY = "0 0 * * * ?";
@@ -199,39 +197,14 @@ public class DefaultArchivaTaskScheduler
}
/**
- * @see ArchivaTaskScheduler#isProcessingAnyRepositoryTask()
- */
- @SuppressWarnings("unchecked")
- public boolean isProcessingAnyRepositoryTask()
- throws ArchivaException
- {
- synchronized( repositoryScanningQueue )
- {
- List<? extends Task> queue = null;
-
- try
- {
- queue = repositoryScanningQueue.getQueueSnapshot();
- }
- catch ( TaskQueueException e )
- {
- throw new ArchivaException( "Unable to get repository scanning queue:" + e.getMessage(), e );
- }
-
- return !queue.isEmpty();
- }
- }
-
- /**
* @see ArchivaTaskScheduler#isProcessingRepositoryTask(String)
*/
@SuppressWarnings("unchecked")
public boolean isProcessingRepositoryTask( String repositoryId )
- throws ArchivaException
{
synchronized( repositoryScanningQueue )
{
- List<? extends Task> queue = null;
+ List<RepositoryTask> queue = null;
try
{
@@ -239,10 +212,17 @@ public class DefaultArchivaTaskScheduler
}
catch ( TaskQueueException e )
{
- throw new ArchivaException( "Unable to get repository scanning queue:" + e.getMessage(), e );
+ // not possible with plexus-taskqueue implementation, ignore
}
- return CollectionUtils.exists( queue, new RepositoryTaskSelectionPredicate( repositoryId ) );
+ for ( RepositoryTask queuedTask : queue )
+ {
+ if ( queuedTask.getRepositoryId().equals( repositoryId ) )
+ {
+ return true;
+ }
+ }
+ return false;
}
}
@@ -250,12 +230,11 @@ public class DefaultArchivaTaskScheduler
* @see ArchivaTaskScheduler#isProcessingIndexingTaskWithName(String)
*/
@SuppressWarnings("unchecked")
- public boolean isProcessingRepositoryTaskWithName( String taskName )
- throws ArchivaException
+ private boolean isProcessingRepositoryTask( RepositoryTask task )
{
synchronized( repositoryScanningQueue )
{
- List<? extends Task> queue = null;
+ List<RepositoryTask> queue = null;
try
{
@@ -263,43 +242,25 @@ public class DefaultArchivaTaskScheduler
}
catch ( TaskQueueException e )
{
- throw new ArchivaException( "Unable to get repository scanning queue:" + e.getMessage(), e );
+ // not possible with plexus-taskqueue implementation, ignore
}
- return CollectionUtils.exists( queue, new ArchivaTaskNameSelectionPredicate( taskName ) );
- }
- }
-
- /**
- * @see ArchivaTaskScheduler#isProcessingIndexingTaskWithName(String)
- */
- @SuppressWarnings("unchecked")
- public boolean isProcessingIndexingTaskWithName( String taskName )
- throws ArchivaException
- {
- synchronized( indexingQueue )
- {
- List<? extends Task> queue = null;
-
- try
+ for ( RepositoryTask queuedTask : queue )
{
- queue = indexingQueue.getQueueSnapshot();
- }
- catch ( TaskQueueException e )
- {
- throw new ArchivaException( "Unable to get indexing scanning queue:" + e.getMessage(), e );
+ if ( task.equals( queuedTask ) )
+ {
+ return true;
+ }
}
-
- return CollectionUtils.exists( queue, new ArchivaTaskNameSelectionPredicate( taskName ) );
+ return false;
}
}
-
+
/**
* @see ArchivaTaskScheduler#isProcessingDatabaseTask()
*/
@SuppressWarnings("unchecked")
public boolean isProcessingDatabaseTask()
- throws ArchivaException
{
List<? extends Task> queue = null;
@@ -309,7 +270,7 @@ public class DefaultArchivaTaskScheduler
}
catch ( TaskQueueException e )
{
- throw new ArchivaException( "Unable to get database update queue:" + e.getMessage(), e );
+ // not possible with plexus-taskqueue implementation, ignore
}
return !queue.isEmpty();
@@ -321,27 +282,17 @@ public class DefaultArchivaTaskScheduler
public void queueRepositoryTask( RepositoryTask task )
throws TaskQueueException
{
- synchronized( repositoryScanningQueue )
+ synchronized ( repositoryScanningQueue )
{
- if( task.getResourceFile() != null )
+ if ( isProcessingRepositoryTask( task ) )
{
- try
- {
- if( isProcessingRepositoryTaskWithName( task.getName() ) )
- {
- log.debug( "Repository task '" + task.getName() + "' is already queued. Skipping task.." );
- return;
- }
- }
- catch ( ArchivaException e )
- {
- log.warn( "Error occurred while checking if repository task '" + task.getName() +
- "' is already queued." );
- }
+ log.debug( "Repository task '" + task + "' is already queued. Skipping task." );
+ }
+ else
+ {
+ // add check if the task is already queued if it is a file scan
+ repositoryScanningQueue.put( task );
}
-
- // add check if the task is already queued if it is a file scan
- repositoryScanningQueue.put( task );
}
}
@@ -428,14 +379,12 @@ public class DefaultArchivaTaskScheduler
private synchronized void queueInitialRepoScan( ManagedRepositoryConfiguration repoConfig )
{
String repoId = repoConfig.getId();
- RepositoryTask task = TaskCreator.createRepositoryTask( repoId, "initial-scan" );
+ RepositoryTask task = TaskCreator.createRepositoryTask( repoId );
- if ( queuedRepos.contains( repoId ) )
- {
- log.error( "Repository [" + repoId + "] is currently being processed or is already queued." );
- }
- else
+ if ( !queuedRepos.contains( repoId ) )
{
+ log.info( "Repository [" + repoId + "] is queued to be scanned as it hasn't been previously." );
+
try
{
queuedRepos.add( repoConfig.getId() );
@@ -479,9 +428,8 @@ public class DefaultArchivaTaskScheduler
new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP, RepositoryTaskJob.class );
JobDataMap dataMap = new JobDataMap();
- dataMap.put( RepositoryTaskJob.TASK_QUEUE, repositoryScanningQueue );
- dataMap.put( RepositoryTaskJob.TASK_QUEUE_POLICY, ArchivaTask.QUEUE_POLICY_WAIT );
- dataMap.put( RepositoryTaskJob.TASK_REPOSITORY, repoConfig.getId() );
+ dataMap.put( DefaultArchivaTaskScheduler.TASK_QUEUE, repositoryScanningQueue );
+ dataMap.put( DefaultArchivaTaskScheduler.TASK_REPOSITORY, repoConfig.getId() );
repositoryJob.setJobDataMap( dataMap );
try
@@ -510,7 +458,7 @@ public class DefaultArchivaTaskScheduler
JobDetail databaseJob = new JobDetail( DATABASE_JOB, DATABASE_SCAN_GROUP, DatabaseTaskJob.class );
JobDataMap dataMap = new JobDataMap();
- dataMap.put( DatabaseTaskJob.TASK_QUEUE, databaseUpdateQueue );
+ dataMap.put( TASK_QUEUE, databaseUpdateQueue );
databaseJob.setJobDataMap( dataMap );
CronExpressionValidator cronValidator = new CronExpressionValidator();
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java
index 9088847df..e0c34ae2c 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java
@@ -19,7 +19,6 @@ package org.apache.maven.archiva.scheduled;
* under the License.
*/
-import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
import org.apache.maven.archiva.scheduled.tasks.TaskCreator;
import org.codehaus.plexus.scheduler.AbstractJob;
@@ -35,20 +34,11 @@ import org.quartz.JobExecutionException;
public class RepositoryTaskJob
extends AbstractJob
{
- static final String TASK_KEY = "EXECUTION";
-
- static final String TASK_QUEUE = "TASK_QUEUE";
-
- static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY";
-
- static final String TASK_REPOSITORY = "TASK_REPOSITORY";
-
/**
* Execute the discoverer and the indexer.
- *
+ *
* @param context
* @throws org.quartz.JobExecutionException
- *
*/
public void execute( JobExecutionContext context )
throws JobExecutionException
@@ -56,29 +46,14 @@ public class RepositoryTaskJob
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
setJobDataMap( dataMap );
- TaskQueue taskQueue = (TaskQueue) dataMap.get( TASK_QUEUE );
- String queuePolicy = dataMap.get( TASK_QUEUE_POLICY ).toString();
+ TaskQueue taskQueue = (TaskQueue) dataMap.get( DefaultArchivaTaskScheduler.TASK_QUEUE );
- RepositoryTask task = TaskCreator.createRepositoryTask( (String) dataMap.get( TASK_REPOSITORY ), "" );
- task.setName( context.getJobDetail().getName() );
+ String repositoryId = (String) dataMap.get( DefaultArchivaTaskScheduler.TASK_REPOSITORY );
+ RepositoryTask task = TaskCreator.createRepositoryTask( repositoryId );
try
{
- if ( taskQueue.getQueueSnapshot().size() == 0 )
- {
- taskQueue.put( task );
- }
- else
- {
- if ( ArchivaTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) )
- {
- taskQueue.put( task );
- }
- else if ( ArchivaTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) )
- {
- // do not queue anymore, policy is to skip
- }
- }
+ taskQueue.put( task );
}
catch ( TaskQueueException e )
{
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java
index e8a88e8c8..a4dbb9d8b 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java
@@ -60,7 +60,7 @@ public class ArchivaDatabaseUpdateTaskExecutor
{
DatabaseTask dbtask = (DatabaseTask) task;
- log.info( "Executing task from queue with job name: " + dbtask.getName() );
+ log.info( "Executing task from queue with job name: " + dbtask );
long time = System.currentTimeMillis();
try
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutor.java
index 4576eae0a..a0f620c49 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutor.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutor.java
@@ -107,7 +107,7 @@ public class ArchivaIndexingTaskExecutor
indexDirectory, null, null, NexusIndexer.FULL_INDEX, false );
context.setSearchable( repository.isScanned() );
- if ( ArtifactIndexingTask.FINISH.equals( indexingTask.getAction() ) )
+ if ( ArtifactIndexingTask.Action.FINISH.equals( indexingTask.getAction() ) )
{
final File indexLocation = new File( managedRepository, ".index" );
IndexPackingRequest request = new IndexPackingRequest( context, indexLocation );
@@ -122,7 +122,7 @@ public class ArchivaIndexingTaskExecutor
if ( ac != null )
{
- if ( indexingTask.getAction().equals( ArtifactIndexingTask.ADD ) )
+ if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
{
boolean add = true;
IndexReader r = context.getIndexReader();
@@ -164,9 +164,8 @@ public class ArchivaIndexingTaskExecutor
}
catch ( IOException e )
{
- log.error( "Error occurred while executing indexing task '" + indexingTask.getName() + "'" );
- throw new TaskExecutionException( "Error occurred while executing indexing task '"
- + indexingTask.getName() + "'" );
+ log.error( "Error occurred while executing indexing task '" + indexingTask + "'" );
+ throw new TaskExecutionException( "Error occurred while executing indexing task '" + indexingTask + "'" );
}
catch ( UnsupportedExistingLuceneIndexException e )
{
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
index 916ff4a44..631e6a03f 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
@@ -112,12 +112,12 @@ public class ArchivaRepositoryScanningTaskExecutor
// execute consumers on resource file if set
if( repoTask.getResourceFile() != null )
{
- log.debug( "Executing task from queue with job name: " + repoTask.getName() );
+ log.debug( "Executing task from queue with job name: " + repoTask );
consumers.executeConsumers( arepo, repoTask.getResourceFile(), repoTask.isUpdateRelatedArtifacts() );
}
else
{
- log.info( "Executing task from queue with job name: " + repoTask.getName() );
+ log.info( "Executing task from queue with job name: " + repoTask );
// otherwise, execute consumers on whole repository
try
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java
deleted file mode 100644
index 2d08265d5..000000000
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.apache.maven.archiva.scheduled.tasks;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.taskqueue.Task;
-
-/**
- * A repository task.
- *
- */
-public interface ArchivaTask
- extends Task
-{
- public static final String QUEUE_POLICY_WAIT = "wait";
-
- public static final String QUEUE_POLICY_SKIP = "skip";
-
- /**
- * Gets the queue policy for this task.
- *
- * @return Queue policy for this task
- */
- public String getQueuePolicy();
-
- /**
- * Sets the queue policy for this task.
- *
- * @param policy
- */
- public void setQueuePolicy( String policy );
-
- /**
- * Sets the job name to represent a group of similar / identical job tasks. Can be used to check the
- * task queue for similar / identical job tasks.
- */
- public void setName( String name );
-
- /**
- * obtains the name of the task
- * @return
- */
- public String getName();
-
- public long getMaxExecutionTime();
-
- public void setMaxExecutionTime( long maxExecutionTime );
-
-
-
-}
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTaskNameSelectionPredicate.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTaskNameSelectionPredicate.java
deleted file mode 100644
index a2b47c1d7..000000000
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTaskNameSelectionPredicate.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.apache.maven.archiva.scheduled.tasks;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.collections.Predicate;
-import org.apache.commons.lang.StringUtils;
-
-public class ArchivaTaskNameSelectionPredicate
- implements Predicate
-{
- private String taskName;
-
- public ArchivaTaskNameSelectionPredicate( String taskName )
- {
- this.taskName = taskName;
- }
-
- public boolean evaluate( Object object )
- {
- boolean satisfies = false;
-
- if ( object instanceof ArchivaTask )
- {
- ArchivaTask task = (ArchivaTask) object;
- return StringUtils.equals( taskName, task.getName() );
- }
-
- return satisfies;
- }
-}
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArtifactIndexingTask.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArtifactIndexingTask.java
index f0b23cba8..91823c8b4 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArtifactIndexingTask.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArtifactIndexingTask.java
@@ -21,30 +21,18 @@ package org.apache.maven.archiva.scheduled.tasks;
import java.io.File;
-import org.sonatype.nexus.index.ArtifactContext;
+import org.codehaus.plexus.taskqueue.Task;
public class ArtifactIndexingTask
- implements ArchivaTask
+ implements Task
{
- public static final String ADD = "add";
-
- public static final String DELETE = "delete";
-
- public static final String FINISH = "finish";
-
- String repositoryId;
-
- String name;
-
- String queuePolicy;
+ public enum Action { ADD, DELETE, FINISH }
- long maxExecutionTime;
-
- File resourceFile;
+ private String repositoryId;
- ArtifactContext artifactContext;
+ private File resourceFile;
- String action;
+ private Action action;
public String getRepositoryId()
{
@@ -58,32 +46,7 @@ public class ArtifactIndexingTask
public long getMaxExecutionTime()
{
- return maxExecutionTime;
- }
-
- public void setMaxExecutionTime( long maxExecutionTime )
- {
- this.maxExecutionTime = maxExecutionTime;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getQueuePolicy()
- {
- return queuePolicy;
- }
-
- public void setQueuePolicy( String queuePolicy )
- {
- this.queuePolicy = queuePolicy;
+ return 0;
}
public File getResourceFile()
@@ -96,24 +59,65 @@ public class ArtifactIndexingTask
this.resourceFile = resourceFile;
}
- public ArtifactContext getArtifactContext()
+ public Action getAction()
{
- return artifactContext;
+ return action;
}
- public void setArtifactContext( ArtifactContext artifactContext )
+ public void setAction( Action action )
{
- this.artifactContext = artifactContext;
+ this.action = action;
}
- public String getAction()
+ @Override
+ public String toString()
{
- return action;
+ return "ArtifactIndexingTask [action=" + action + ", repositoryId=" + repositoryId + ", resourceFile="
+ + resourceFile + "]";
}
- public void setAction( String action )
+ @Override
+ public int hashCode()
{
- this.action = action;
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( action == null ) ? 0 : action.hashCode() );
+ result = prime * result + ( ( repositoryId == null ) ? 0 : repositoryId.hashCode() );
+ result = prime * result + ( ( resourceFile == null ) ? 0 : resourceFile.hashCode() );
+ return result;
}
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ ArtifactIndexingTask other = (ArtifactIndexingTask) obj;
+ if ( action == null )
+ {
+ if ( other.action != null )
+ return false;
+ }
+ else if ( !action.equals( other.action ) )
+ return false;
+ if ( repositoryId == null )
+ {
+ if ( other.repositoryId != null )
+ return false;
+ }
+ else if ( !repositoryId.equals( other.repositoryId ) )
+ return false;
+ if ( resourceFile == null )
+ {
+ if ( other.resourceFile != null )
+ return false;
+ }
+ else if ( !resourceFile.equals( other.resourceFile ) )
+ return false;
+ return true;
+ }
}
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java
index 816e9d193..c2db624de 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java
@@ -19,6 +19,8 @@ package org.apache.maven.archiva.scheduled.tasks;
* under the License.
*/
+import org.codehaus.plexus.taskqueue.Task;
+
/**
* DataRefreshTask - task for discovering changes in the repository
* and updating all associated data.
@@ -26,42 +28,16 @@ package org.apache.maven.archiva.scheduled.tasks;
* @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $
*/
public class DatabaseTask
- implements ArchivaTask
+ implements Task
{
-
- String name;
-
- String queuePolicy;
-
- long maxExecutionTime;
-
- public long getMaxExecutionTime()
+ @Override
+ public String toString()
{
- return maxExecutionTime;
+ return "DatabaseTask";
}
- public void setMaxExecutionTime( long maxExecutionTime )
- {
- this.maxExecutionTime = maxExecutionTime;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getQueuePolicy()
- {
- return queuePolicy;
- }
-
- public void setQueuePolicy( String queuePolicy )
+ public long getMaxExecutionTime()
{
- this.queuePolicy = queuePolicy;
+ return 0;
}
}
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java
index 5fc58067d..27dd5e787 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java
@@ -2,6 +2,8 @@ package org.apache.maven.archiva.scheduled.tasks;
import java.io.File;
+import org.codehaus.plexus.taskqueue.Task;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,21 +30,52 @@ import java.io.File;
* @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $
*/
public class RepositoryTask
- implements ArchivaTask
+ implements Task
{
- String repositoryId;
-
- String name;
-
- String queuePolicy;
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( repositoryId == null ) ? 0 : repositoryId.hashCode() );
+ result = prime * result + ( ( resourceFile == null ) ? 0 : resourceFile.hashCode() );
+ return result;
+ }
- long maxExecutionTime;
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ RepositoryTask other = (RepositoryTask) obj;
+ if ( repositoryId == null )
+ {
+ if ( other.repositoryId != null )
+ return false;
+ }
+ else if ( !repositoryId.equals( other.repositoryId ) )
+ return false;
+ if ( resourceFile == null )
+ {
+ if ( other.resourceFile != null )
+ return false;
+ }
+ else if ( !resourceFile.equals( other.resourceFile ) )
+ return false;
+ return true;
+ }
+
+ private String repositoryId;
- File resourceFile;
+ private File resourceFile;
- boolean updateRelatedArtifacts;
+ private boolean updateRelatedArtifacts;
- boolean scanAll;
+ private boolean scanAll;
public boolean isScanAll()
{
@@ -66,32 +99,7 @@ public class RepositoryTask
public long getMaxExecutionTime()
{
- return maxExecutionTime;
- }
-
- public void setMaxExecutionTime( long maxExecutionTime )
- {
- this.maxExecutionTime = maxExecutionTime;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getQueuePolicy()
- {
- return queuePolicy;
- }
-
- public void setQueuePolicy( String queuePolicy )
- {
- this.queuePolicy = queuePolicy;
+ return 0;
}
public File getResourceFile()
@@ -113,4 +121,11 @@ public class RepositoryTask
{
this.updateRelatedArtifacts = updateRelatedArtifacts;
}
+
+ @Override
+ public String toString()
+ {
+ return "RepositoryTask [repositoryId=" + repositoryId + ", resourceFile=" + resourceFile + ", scanAll="
+ + scanAll + ", updateRelatedArtifacts=" + updateRelatedArtifacts + "]";
+ }
}
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTaskSelectionPredicate.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTaskSelectionPredicate.java
deleted file mode 100644
index 8c76f873e..000000000
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTaskSelectionPredicate.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.apache.maven.archiva.scheduled.tasks;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.collections.Predicate;
-import org.apache.commons.lang.StringUtils;
-
-/**
- * RepositoryTaskSelectionPredicate
- *
- * @version $Id$
- */
-public class RepositoryTaskSelectionPredicate
- implements Predicate
-{
- private String repoid;
-
- public RepositoryTaskSelectionPredicate( String repositoryId )
- {
- this.repoid = repositoryId;
- }
-
- public boolean evaluate( Object object )
- {
- boolean satisfies = false;
-
- if ( object instanceof RepositoryTask )
- {
- RepositoryTask task = (RepositoryTask) object;
- return StringUtils.equals( repoid, task.getRepositoryId() );
- }
-
- return satisfies;
- }
-
-}
diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java
index 227e8c46b..8230deea4 100644
--- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java
+++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java
@@ -21,72 +21,51 @@ package org.apache.maven.archiva.scheduled.tasks;
import java.io.File;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler;
-
/**
* TaskCreator Convenience class for creating Archiva tasks.
*/
public class TaskCreator
{
- public static RepositoryTask createRepositoryTask( String repositoryId, String taskNameSuffix )
+ public static RepositoryTask createRepositoryTask( String repositoryId )
{
- String suffix = "";
- if ( !StringUtils.isEmpty( taskNameSuffix ) )
- {
- suffix = ":" + taskNameSuffix;
- }
-
RepositoryTask task = new RepositoryTask();
task.setRepositoryId( repositoryId );
- task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repositoryId + suffix );
- task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );
-
return task;
}
- public static RepositoryTask createRepositoryTask( String repositoryId, String taskNameSuffix, boolean scanAll )
+ public static RepositoryTask createRepositoryTask( String repositoryId, boolean scanAll )
{
- RepositoryTask task = createRepositoryTask( repositoryId, taskNameSuffix );
+ RepositoryTask task = createRepositoryTask( repositoryId );
task.setScanAll( scanAll );
return task;
}
- public static RepositoryTask createRepositoryTask( String repositoryId, String taskNameSuffix, File resourceFile,
+ public static RepositoryTask createRepositoryTask( String repositoryId, File resourceFile,
boolean updateRelatedArtifacts )
{
- RepositoryTask task = createRepositoryTask( repositoryId, taskNameSuffix );
+ RepositoryTask task = createRepositoryTask( repositoryId );
task.setResourceFile( resourceFile );
task.setUpdateRelatedArtifacts( updateRelatedArtifacts );
return task;
}
- public static RepositoryTask createRepositoryTask( String repositoryId, String taskNameSuffix, File resourceFile,
+ public static RepositoryTask createRepositoryTask( String repositoryId, File resourceFile,
boolean updateRelatedArtifacts, boolean scanAll )
{
- RepositoryTask task = createRepositoryTask( repositoryId, taskNameSuffix, resourceFile, updateRelatedArtifacts );
+ RepositoryTask task = createRepositoryTask( repositoryId, resourceFile, updateRelatedArtifacts );
task.setScanAll( scanAll );
return task;
}
- public static ArtifactIndexingTask createIndexingTask( String repositoryId, File resource, String action )
+ public static ArtifactIndexingTask createIndexingTask( String repositoryId, File resource,
+ ArtifactIndexingTask.Action action )
{
ArtifactIndexingTask task = new ArtifactIndexingTask();
task.setRepositoryId( repositoryId );
-
- String name = DefaultArchivaTaskScheduler.INDEXING_JOB + ":" + repositoryId;
- if ( resource != null )
- {
- name = name + ":" + resource.getName();
- }
- name = name + ":" + action;
-
- task.setName( name );
task.setAction( action );
- task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );
task.setResourceFile( resource );
return task;
diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java
index 677c95062..84a8235a8 100644
--- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java
+++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java
@@ -168,9 +168,6 @@ public class ArchivaDatabaseUpdateTaskExecutorTest
// Execute the database task.
DatabaseTask dataTask = new DatabaseTask();
-
- dataTask.setName( "testDataTask" );
-
taskExecutor.executeTask( dataTask );
// Test for artifact existance.
diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutorTest.java
index 5c23800c7..0d0de4d11 100644
--- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutorTest.java
+++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutorTest.java
@@ -127,7 +127,7 @@ public class ArchivaIndexingTaskExecutorTest
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
+ TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.ADD );
archivaConfigControl.expectAndReturn( archivaConfiguration.getConfiguration(), configuration );
@@ -171,7 +171,7 @@ public class ArchivaIndexingTaskExecutorTest
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
+ TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.ADD );
archivaConfigControl.expectAndReturn( archivaConfiguration.getConfiguration(), configuration, 2 );
@@ -204,7 +204,7 @@ public class ArchivaIndexingTaskExecutorTest
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
+ TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.ADD );
archivaConfigControl.expectAndReturn( archivaConfiguration.getConfiguration(), configuration, 3 );
@@ -213,7 +213,7 @@ public class ArchivaIndexingTaskExecutorTest
// add artifact to index
indexingExecutor.executeTask( task );
- task = TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.FINISH );
+ task = TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.FINISH );
// add artifact to index
indexingExecutor.executeTask( task );
@@ -232,7 +232,7 @@ public class ArchivaIndexingTaskExecutorTest
assertEquals( 1, topDocs.totalHits );
// remove added artifact from index
- task = TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.DELETE );
+ task = TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.DELETE );
indexingExecutor.executeTask( task );
archivaConfigControl.verify();
@@ -261,7 +261,7 @@ public class ArchivaIndexingTaskExecutorTest
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
ArtifactIndexingTask task =
- TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.ADD );
+ TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.ADD );
archivaConfigControl.expectAndReturn( archivaConfiguration.getConfiguration(), configuration );
@@ -273,7 +273,7 @@ public class ArchivaIndexingTaskExecutorTest
archivaConfigControl.reset();
- task = TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.FINISH );
+ task = TaskCreator.createIndexingTask( repositoryConfig.getId(), artifactFile, ArtifactIndexingTask.Action.FINISH );
archivaConfigControl.expectAndReturn( archivaConfiguration.getConfiguration(), configuration );
diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
index 7313bbf22..103d53dd9 100644
--- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
+++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
@@ -171,7 +171,6 @@ public class ArchivaRepositoryScanningTaskExecutorTest
RepositoryTask repoTask = new RepositoryTask();
- repoTask.setName( "testRepoTask" );
repoTask.setRepositoryId( "testRepo" );
taskExecutor.executeTask( repoTask );
@@ -199,7 +198,6 @@ public class ArchivaRepositoryScanningTaskExecutorTest
RepositoryTask repoTask = new RepositoryTask();
- repoTask.setName( "testRepoTask" );
repoTask.setRepositoryId( "testRepo" );
repoTask.setScanAll( false );
@@ -257,7 +255,6 @@ public class ArchivaRepositoryScanningTaskExecutorTest
RepositoryTask repoTask = new RepositoryTask();
- repoTask.setName( "testRepoTask" );
repoTask.setRepositoryId( "testRepo" );
repoTask.setScanAll( true );
diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java
index 271221aa9..baab0ab65 100644
--- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java
+++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java
@@ -21,7 +21,6 @@ package org.apache.maven.archiva.scheduled.tasks;
import java.io.File;
-import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
public class TaskCreatorTest
@@ -29,23 +28,18 @@ public class TaskCreatorTest
{
private static final String REPO_ID = "test-repo";
- private static final String TASKNAME_SUFFIX = "test-task";
-
public void testCreateRepositoryTask()
throws Exception
{
- RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, "" );
+ RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID );
assertEquals( "Incorrect repository id set.", REPO_ID, task.getRepositoryId() );
- assertEquals( "Incorrect queue policy set.", ArchivaTask.QUEUE_POLICY_WAIT, task.getQueuePolicy() );
- assertEquals( "Incorrect task name set.", DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + REPO_ID,
- task.getName() );
}
public void testCreateRepositoryTaskWithTaskNameSuffix()
throws Exception
{
- RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, TASKNAME_SUFFIX );
+ RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID );
assertBasicTaskDetails( task );
}
@@ -53,63 +47,57 @@ public class TaskCreatorTest
public void testCreateRepositoryTaskScanAllArtifacts()
throws Exception
{
- RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, TASKNAME_SUFFIX, true );
+ RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, true );
assertBasicTaskDetails( task );
- assertTrue( task.scanAll );
+ assertTrue( task.isScanAll() );
}
public void testCreateRepositoryTaskDoNotScanAllArtifacts()
throws Exception
{
- RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, TASKNAME_SUFFIX, false );
+ RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, false );
assertBasicTaskDetails( task );
- assertFalse( task.scanAll );
+ assertFalse( task.isScanAll() );
}
public void testCreateRepositoryTaskForArtifactUpdateAllRelated()
throws Exception
{
File resource = new File( getBasedir(), "target/test-classes/test.jar" );
- RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, TASKNAME_SUFFIX, resource, true );
+ RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, resource, true );
assertBasicTaskDetails( task );
assertEquals( "Incorrect resource file set.", resource, task.getResourceFile() );
- assertTrue( task.updateRelatedArtifacts );
+ assertTrue( task.isUpdateRelatedArtifacts() );
}
public void testCreateRepositoryTaskForArtifactDoNotUpdateAllRelated()
throws Exception
{
File resource = new File( getBasedir(), "target/test-classes/test.jar" );
- RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, TASKNAME_SUFFIX, resource, false );
+ RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, resource, false );
assertBasicTaskDetails( task );
assertEquals( "Incorrect resource file set.", resource, task.getResourceFile() );
- assertFalse( task.updateRelatedArtifacts );
+ assertFalse( task.isUpdateRelatedArtifacts() );
}
public void testCreateIndexingTask()
throws Exception
{
File resource = new File( getBasedir(), "target/test-classes/test.jar" );
- ArtifactIndexingTask task = TaskCreator.createIndexingTask( REPO_ID, resource, ArtifactIndexingTask.ADD );
+ ArtifactIndexingTask task = TaskCreator.createIndexingTask( REPO_ID, resource, ArtifactIndexingTask.Action.ADD );
assertEquals( "Incorrect repository id set.", REPO_ID, task.getRepositoryId() );
- assertEquals( "Incorrect queue policy set.", ArchivaTask.QUEUE_POLICY_WAIT, task.getQueuePolicy() );
- assertEquals( "Incorrect task name set.", DefaultArchivaTaskScheduler.INDEXING_JOB + ":" + REPO_ID + ":" +
- resource.getName() + ":" + ArtifactIndexingTask.ADD, task.getName() );
- assertEquals( "Incorrect action set.", ArtifactIndexingTask.ADD, task.getAction() );
+ assertEquals( "Incorrect action set.", ArtifactIndexingTask.Action.ADD, task.getAction() );
assertEquals( "Incorrect resource file set.", resource, task.getResourceFile() );
}
private void assertBasicTaskDetails( RepositoryTask task )
{
assertEquals( "Incorrect repository id set.", REPO_ID, task.getRepositoryId() );
- assertEquals( "Incorrect task name set.", DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + REPO_ID + ":" +
- TASKNAME_SUFFIX, task.getName() );
- assertEquals( "Incorrect queue policy set.", ArchivaTask.QUEUE_POLICY_WAIT, task.getQueuePolicy() );
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
index 9c538c837..3bab1372b 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
@@ -19,9 +19,6 @@ package org.apache.maven.archiva.web.action;
* under the License.
*/
-import com.opensymphony.xwork2.Preparable;
-import com.opensymphony.xwork2.Validateable;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -35,7 +32,7 @@ import java.util.Date;
import java.util.List;
import java.util.TimeZone;
-import org.apache.archiva.checksum.ChecksumAlgorithm;
+import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
@@ -70,6 +67,9 @@ import org.apache.maven.archiva.security.PrincipalNotFoundException;
import org.apache.maven.archiva.security.UserRepositories;
import org.codehaus.plexus.taskqueue.TaskQueueException;
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.Validateable;
+
/**
* Upload an artifact using Jakarta file upload in webwork. If set by the user a pom will also be generated. Metadata
* will also be updated if one exists, otherwise it would be created.
@@ -617,7 +617,7 @@ public class UploadAction
private void queueRepositoryTask( String repositoryId, File localFile )
{
- RepositoryTask task = TaskCreator.createRepositoryTask( repositoryId, localFile.getName(), localFile, true, true );
+ RepositoryTask task = TaskCreator.createRepositoryTask( repositoryId, localFile, true, true );
try
{
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java
index 711a553cf..c6eb4cb7b 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java
@@ -20,10 +20,7 @@ package org.apache.maven.archiva.web.action.admin;
*/
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.common.ArchivaException;
import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
-import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler;
-import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
import org.apache.maven.archiva.scheduled.tasks.TaskCreator;
@@ -61,35 +58,13 @@ public class SchedulerAction
return SUCCESS;
}
- RepositoryTask task = TaskCreator.createRepositoryTask( repoid, "", scanAll );
+ RepositoryTask task = TaskCreator.createRepositoryTask( repoid, scanAll );
- boolean scheduleTask = false;
-
- try
- {
- if ( taskScheduler.isProcessingAnyRepositoryTask() )
- {
- if ( taskScheduler.isProcessingRepositoryTask( repoid ) )
- {
- addActionError( "Repository [" + repoid + "] task was already queued." );
- }
- else
- {
- scheduleTask = true;
- }
- }
- else
- {
- scheduleTask = true;
- }
- }
- catch ( ArchivaException e )
+ if ( taskScheduler.isProcessingRepositoryTask( repoid ) )
{
- scheduleTask = false;
- addActionError( e.getMessage() );
+ addActionError( "Repository [" + repoid + "] task was already queued." );
}
-
- if ( scheduleTask )
+ else
{
try
{
@@ -109,30 +84,14 @@ public class SchedulerAction
public String updateDatabase()
{
+ log.info( "Queueing database task on request from user interface" );
DatabaseTask task = new DatabaseTask();
- task.setName( DefaultArchivaTaskScheduler.DATABASE_JOB + ":user-requested" );
- task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );
- boolean scheduleTask = false;
-
- try
- {
- if ( taskScheduler.isProcessingDatabaseTask() )
- {
- addActionError( "Database task was already queued." );
- }
- else
- {
- scheduleTask = true;
- }
- }
- catch ( ArchivaException e )
+ if ( taskScheduler.isProcessingDatabaseTask() )
{
- scheduleTask = false;
- addActionError( e.getMessage() );
+ addActionError( "Database task was already queued." );
}
-
- if ( scheduleTask )
+ else
{
try
{
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
index 493d17d71..113aba0e5 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java
@@ -643,9 +643,9 @@ public class ArchivaDavResource
}
}
- private void queueRepositoryTask( File localFile )
+ private void queueRepositoryTask( File localFile )
{
- RepositoryTask task = TaskCreator.createRepositoryTask( repository.getId(), localFile.getName(), localFile, false, true );
+ RepositoryTask task = TaskCreator.createRepositoryTask( repository.getId(), localFile, false, true );
try
{
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
index 623b32475..385db320a 100644
--- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
+++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
@@ -51,12 +51,12 @@ import org.apache.maven.archiva.repository.RepositoryNotFoundException;
import org.apache.maven.archiva.repository.events.RepositoryListener;
import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers;
import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
-import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler;
-import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
import org.apache.maven.archiva.scheduled.tasks.TaskCreator;
import org.codehaus.plexus.registry.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* AdministrationServiceImpl
@@ -66,6 +66,8 @@ import org.codehaus.plexus.registry.RegistryException;
public class AdministrationServiceImpl
implements AdministrationService
{
+ protected Logger log = LoggerFactory.getLogger( getClass() );
+
private ArchivaConfiguration archivaConfiguration;
private RepositoryContentConsumers repoConsumersUtil;
@@ -285,9 +287,8 @@ public class AdministrationServiceImpl
return false;
}
+ log.info( "Queueing database task on request from administration service" );
DatabaseTask task = new DatabaseTask();
- task.setName( DefaultArchivaTaskScheduler.DATABASE_JOB + ":user-requested-via-web-service" );
- task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT );
taskScheduler.queueDatabaseTask( task );
@@ -305,15 +306,12 @@ public class AdministrationServiceImpl
throw new Exception( "Repository does not exist." );
}
- if ( taskScheduler.isProcessingAnyRepositoryTask() )
+ if ( taskScheduler.isProcessingRepositoryTask( repoId ) )
{
- if ( taskScheduler.isProcessingRepositoryTask( repoId ) )
- {
- return false;
- }
+ return false;
}
- RepositoryTask task = TaskCreator.createRepositoryTask( repoId, "" );
+ RepositoryTask task = TaskCreator.createRepositoryTask( repoId );
taskScheduler.queueRepositoryTask( task );
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java
index 71ccb87d1..5089b289b 100644
--- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java
+++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java
@@ -642,7 +642,6 @@ public class AdministrationServiceImplTest
RepositoryTask task = new RepositoryTask();
- taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingAnyRepositoryTask(), true );
taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingRepositoryTask( "internal" ), false );
taskScheduler.queueRepositoryTask( task );
@@ -675,7 +674,6 @@ public class AdministrationServiceImplTest
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ),
createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
- taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingAnyRepositoryTask(), true );
taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingRepositoryTask( "internal" ), true);
archivaConfigControl.replay();