public void executeTask( Task task )
throws TaskExecutionException
{
this.task = task;
RepositoryTask repoTask = (RepositoryTask) task;
if ( StringUtils.isBlank( repoTask.getRepositoryId() ) )
{
throw new TaskExecutionException( "Unable to execute RepositoryTask with blank repository Id." );
}
ManagedRepositoryConfiguration arepo =
archivaConfiguration.getConfiguration().findManagedRepositoryById( repoTask.getRepositoryId() );
// execute consumers on resource file if set
if ( repoTask.getResourceFile() != null )
{
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 );
// otherwise, execute consumers on whole repository
try
{
if ( arepo == null )
{
throw new TaskExecutionException(
"Unable to execute RepositoryTask with invalid repository id: " + repoTask.getRepositoryId() );
}
long sinceWhen = RepositoryScanner.FRESH_SCAN;
List<RepositoryContentStatistics> results = (List<RepositoryContentStatistics>) dao.query(
new MostRecentRepositoryScanStatistics( arepo.getId() ) );
if ( CollectionUtils.isNotEmpty( results ) )
{
RepositoryContentStatistics lastStats = results.get( 0 );
if ( !repoTask.isScanAll() )
{
sinceWhen = lastStats.getWhenGathered().getTime() - lastStats.getDuration();
}
}