From ec236f0bdf8d97b5d8fb735785123470b82c9d6e Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Thu, 16 Oct 2008 10:38:50 +0000 Subject: [PATCH] - added the ArchivaTaskScheduler in AdministrationServiceImpl - uncommented methods for executing db and repo scanners git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@705202 13f79535-47bb-0310-9956-ffa450edef68 --- .../webapp/WEB-INF/applicationContext.xml | 7 +++---- .../web/xmlrpc/api/AdministrationService.java | 11 ++++++++++- .../services/AdministrationServiceImpl.java | 19 +++++++++---------- .../AdministrationServiceImplTest.java | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/MRM-124/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/MRM-124/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index 5b1b38131..d8604065c 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/MRM-124/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -40,13 +40,12 @@ - + + - - - + diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java index 45c83fb1d..814933446 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java @@ -69,7 +69,16 @@ public interface AdministrationService */ public List getAllRepositoryConsumers(); - // TODO should we already implement config of consumers per repository? + // TODO should we already implement config of consumers per repository? + /** + * Configures (enable or disable) repository consumer. + * + * @param repoId + * @param consumerId + * @param enable + * @return + * @throws Exception + */ public Boolean configureRepositoryConsumer( String repoId, String consumerId, boolean enable ) throws Exception; /** diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java index ca3c1a7ea..7bb2882b2 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java @@ -69,9 +69,7 @@ public class AdministrationServiceImpl private RepositoryContentConsumers repoConsumersUtil; private DatabaseConsumers dbConsumersUtil; - - //private ArchivaTaskScheduler taskScheduler; - + private RepositoryContentFactory repoFactory; private ArtifactDAO artifactDAO; @@ -80,10 +78,12 @@ public class AdministrationServiceImpl private DatabaseCleanupConsumer cleanupProjects; + private ArchivaTaskScheduler taskScheduler; + public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory, ArtifactDAO artifactDAO, DatabaseCleanupConsumer cleanupArtifacts, - DatabaseCleanupConsumer cleanupProjects ) + DatabaseCleanupConsumer cleanupProjects, ArchivaTaskScheduler taskScheduler ) { this.archivaConfiguration = archivaConfig; this.repoConsumersUtil = repoConsumersUtil; @@ -92,6 +92,7 @@ public class AdministrationServiceImpl this.artifactDAO = artifactDAO; this.cleanupArtifacts = cleanupArtifacts; this.cleanupProjects = cleanupProjects; + this.taskScheduler = taskScheduler; } /** @@ -288,7 +289,7 @@ public class AdministrationServiceImpl */ public Boolean executeDatabaseScanner() throws Exception { - /*if ( taskScheduler.isProcessingDatabaseTask() ) + if ( taskScheduler.isProcessingDatabaseTask() ) { return false; } @@ -297,7 +298,7 @@ public class AdministrationServiceImpl task.setName( DefaultArchivaTaskScheduler.DATABASE_JOB + ":user-requested-via-web-service" ); task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT ); - taskScheduler.queueDatabaseTask( task ); */ + taskScheduler.queueDatabaseTask( task ); return new Boolean( true ); } @@ -307,7 +308,7 @@ public class AdministrationServiceImpl */ public Boolean executeRepositoryScanner( String repoId ) throws Exception { - /* Configuration config = archivaConfiguration.getConfiguration(); + Configuration config = archivaConfiguration.getConfiguration(); if( config.findManagedRepositoryById( repoId ) == null ) { throw new Exception( "Repository does not exist." ); @@ -326,7 +327,7 @@ public class AdministrationServiceImpl task.setName( DefaultArchivaTaskScheduler.REPOSITORY_JOB + ":" + repoId ); task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT ); - taskScheduler.queueRepositoryTask( task ); */ + taskScheduler.queueRepositoryTask( task ); return new Boolean( true ); } @@ -396,8 +397,6 @@ public class AdministrationServiceImpl managedRepos.add( repo ); } - System.out.println( "\n++++++MANAGED REPOS --> " + managedRepos ); - return managedRepos; } diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java index 770acbc5f..2c544577d 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -172,7 +172,7 @@ public class AdministrationServiceImplTest cleanupConsumer = ( DatabaseCleanupConsumer ) cleanupControl.getMock(); service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, dbConsumersUtil, - repositoryFactory, artifactDao, cleanupConsumer, cleanupConsumer ); + repositoryFactory, artifactDao, cleanupConsumer, cleanupConsumer, taskScheduler ); } /* Tests for database consumers */ -- 2.39.5