refactoring to ease cron scheduling

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551472 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-12-17 07:28:27 +00:00
parent dcd4afcdb8
commit b67de4117e
2 changed files with 27 additions and 13 deletions

View File

@ -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;

View File

@ -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 =