From b67de4117e723519ca95277c77b983a9ca69b867 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 17 Dec 2013 07:28:27 +0000 Subject: [PATCH] refactoring to ease cron scheduling git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551472 13f79535-47bb-0310-9956-ffa450edef68 --- ...kJob.java => MergedRemoteIndexesTask.java} | 27 ++++++++++++++----- .../webdav/ArchivaDavResourceFactory.java | 13 ++++----- 2 files changed, 27 insertions(+), 13 deletions(-) rename archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/{MergedRemoteIndexesTaskJob.java => MergedRemoteIndexesTask.java} (84%) diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskJob.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java similarity index 84% rename from archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskJob.java rename to archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java index 5fe748871..2e19eb640 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskJob.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java @@ -32,20 +32,33 @@ import java.io.File; * @author Olivier Lamy * @since 2.0.0 */ -public class MergedRemoteIndexesTaskJob - extends AbstractJob +public class MergedRemoteIndexesTask + implements Runnable { private Logger logger = LoggerFactory.getLogger( getClass() ); - @Override - public void execute( JobExecutionContext context ) - throws JobExecutionException - { + private MergedRemoteIndexesTaskRequest mergedRemoteIndexesTaskRequest; + public MergedRemoteIndexesTask( MergedRemoteIndexesTaskRequest mergedRemoteIndexesTaskRequest ) + { + this.mergedRemoteIndexesTaskRequest = mergedRemoteIndexesTaskRequest; } - public MergedRemoteIndexesTaskResult execute( MergedRemoteIndexesTaskRequest mergedRemoteIndexesTaskRequest ) + @Override + public void run() + { + try + { + this.execute(); + } + catch ( IndexMergerException e ) + { + logger.error( e.getMessage(), e ); + } + } + + public MergedRemoteIndexesTaskResult execute( ) throws IndexMergerException { IndexMerger indexMerger = mergedRemoteIndexesTaskRequest.indexMerger; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index b6af5e3f9..cbe1172ba 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -38,7 +38,7 @@ import org.apache.archiva.configuration.RepositoryGroupConfiguration; import org.apache.archiva.indexer.merger.IndexMerger; import org.apache.archiva.indexer.merger.IndexMergerException; import org.apache.archiva.indexer.merger.IndexMergerRequest; -import org.apache.archiva.indexer.merger.MergedRemoteIndexesTaskJob; +import org.apache.archiva.indexer.merger.MergedRemoteIndexesTask; import org.apache.archiva.indexer.merger.TemporaryGroupIndex; import org.apache.archiva.indexer.search.RepositorySearch; import org.apache.archiva.maven2.metadata.MavenMetadataReader; @@ -72,7 +72,6 @@ import org.apache.archiva.repository.metadata.RepositoryMetadataWriter; import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler; import org.apache.archiva.security.ServletAuthenticator; import org.apache.archiva.webdav.util.MimeTypes; -import org.apache.archiva.webdav.util.RepositoryPathUtil; import org.apache.archiva.webdav.util.TemporaryGroupIndexSessionCleaner; import org.apache.archiva.webdav.util.WebdavMethodUtil; import org.apache.archiva.xml.XMLException; @@ -1317,12 +1316,14 @@ public class ArchivaDavResourceFactory repositoryGroupConfiguration.getMergedIndexTtl() ).mergedIndexDirectory( tempRepoFile ); - MergedRemoteIndexesTaskJob job = new MergedRemoteIndexesTaskJob(); - MergedRemoteIndexesTaskJob.MergedRemoteIndexesTaskRequest taskRequest = - new MergedRemoteIndexesTaskJob.MergedRemoteIndexesTaskRequest(indexMergerRequest, indexMerger); - IndexingContext indexingContext = job.execute( taskRequest ).getIndexingContext(); + MergedRemoteIndexesTask.MergedRemoteIndexesTaskRequest taskRequest = + new MergedRemoteIndexesTask.MergedRemoteIndexesTaskRequest(indexMergerRequest, indexMerger); + + MergedRemoteIndexesTask job = new MergedRemoteIndexesTask( taskRequest ); + + IndexingContext indexingContext = job.execute().getIndexingContext(); File mergedRepoDir = indexingContext.getIndexDirectoryFile(); TemporaryGroupIndex temporaryGroupIndex =