take advantage of generic type

This commit is contained in:
Brett Porter 2014-08-01 12:14:33 +10:00
parent 1e589ddd62
commit 2b8f78afe2
1 changed files with 9 additions and 11 deletions

View File

@ -53,7 +53,7 @@ import java.util.Date;
*/ */
@Service( "taskExecutor#repository-scanning" ) @Service( "taskExecutor#repository-scanning" )
public class ArchivaRepositoryScanningTaskExecutor public class ArchivaRepositoryScanningTaskExecutor
implements TaskExecutor implements TaskExecutor<RepositoryTask>
{ {
private Logger log = LoggerFactory.getLogger( ArchivaRepositoryScanningTaskExecutor.class ); private Logger log = LoggerFactory.getLogger( ArchivaRepositoryScanningTaskExecutor.class );
@ -86,7 +86,7 @@ public class ArchivaRepositoryScanningTaskExecutor
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
@Override @Override
public void executeTask( Task task ) public void executeTask( RepositoryTask task )
throws TaskExecutionException throws TaskExecutionException
{ {
try try
@ -101,9 +101,7 @@ public class ArchivaRepositoryScanningTaskExecutor
this.task = task; this.task = task;
RepositoryTask repoTask = (RepositoryTask) task; String repoId = task.getRepositoryId();
String repoId = repoTask.getRepositoryId();
if ( StringUtils.isBlank( repoId ) ) if ( StringUtils.isBlank( repoId ) )
{ {
throw new TaskExecutionException( "Unable to execute RepositoryTask with blank repository Id." ); throw new TaskExecutionException( "Unable to execute RepositoryTask with blank repository Id." );
@ -112,14 +110,14 @@ public class ArchivaRepositoryScanningTaskExecutor
ManagedRepository arepo = managedRepositoryAdmin.getManagedRepository( repoId ); ManagedRepository arepo = managedRepositoryAdmin.getManagedRepository( repoId );
// execute consumers on resource file if set // execute consumers on resource file if set
if ( repoTask.getResourceFile() != null ) if ( task.getResourceFile() != null )
{ {
log.debug( "Executing task from queue with job name: {}", repoTask ); log.debug( "Executing task from queue with job name: {}", task );
consumers.executeConsumers( arepo, repoTask.getResourceFile(), repoTask.isUpdateRelatedArtifacts() ); consumers.executeConsumers( arepo, task.getResourceFile(), task.isUpdateRelatedArtifacts() );
} }
else else
{ {
log.info( "Executing task from queue with job name: {}", repoTask ); log.info( "Executing task from queue with job name: {}", task );
// otherwise, execute consumers on whole repository // otherwise, execute consumers on whole repository
if ( arepo == null ) if ( arepo == null )
@ -135,7 +133,7 @@ public class ArchivaRepositoryScanningTaskExecutor
MetadataRepository metadataRepository = repositorySession.getRepository(); MetadataRepository metadataRepository = repositorySession.getRepository();
try try
{ {
if ( !repoTask.isScanAll() ) if ( !task.isScanAll() )
{ {
RepositoryStatistics previousStats = RepositoryStatistics previousStats =
repositoryStatisticsManager.getLastStatistics( metadataRepository, repoId ); repositoryStatisticsManager.getLastStatistics( metadataRepository, repoId );
@ -183,7 +181,7 @@ public class ArchivaRepositoryScanningTaskExecutor
// metadataRepository.findAllProjects(); // metadataRepository.findAllProjects();
// FIXME: do something // FIXME: do something
log.info( "Finished repository task: {}", repoTask ); log.info( "Finished repository task: {}", task );
this.task = null; this.task = null;
} }