add a rest service to schedule a download remote index

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1176245 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-27 07:18:30 +00:00
parent 489d8bfaf0
commit 066197cdd2
2 changed files with 29 additions and 1 deletions

View File

@ -83,4 +83,13 @@ public interface RepositoriesService
Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest ) Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path( "scheduleDownloadRemoteIndex" )
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
Boolean scheduleDownloadRemoteIndex( @QueryParam( "repositoryId" ) String repositoryId,
@QueryParam( "now" ) boolean now,
@QueryParam( "fullDownload" ) boolean fullDownload )
throws ArchivaRestServiceException;
} }

View File

@ -44,6 +44,8 @@ import org.apache.archiva.rest.api.services.RepositoriesService;
import org.apache.archiva.scheduler.ArchivaTaskScheduler; import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArchivaIndexingTaskExecutor; import org.apache.archiva.scheduler.indexing.ArchivaIndexingTaskExecutor;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask; import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.archiva.scheduler.indexing.DownloadRemoteIndexException;
import org.apache.archiva.scheduler.indexing.DownloadRemoteIndexScheduler;
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.archiva.scheduler.repository.RepositoryTask;
import org.apache.archiva.security.common.ArchivaRoleConstants; import org.apache.archiva.security.common.ArchivaRoleConstants;
@ -67,7 +69,6 @@ import org.springframework.stereotype.Service;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.ws.rs.PathParam;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -119,6 +120,9 @@ public class DefaultRepositoriesService
@Named( value = "archivaTaskScheduler#repository" ) @Named( value = "archivaTaskScheduler#repository" )
private ArchivaTaskScheduler scheduler; private ArchivaTaskScheduler scheduler;
@Inject
private DownloadRemoteIndexScheduler downloadRemoteIndexScheduler;
private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 }; private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 };
public Boolean scanRepository( String repositoryId, boolean fullScan ) public Boolean scanRepository( String repositoryId, boolean fullScan )
@ -191,6 +195,21 @@ public class DefaultRepositoriesService
} }
} }
public Boolean scheduleDownloadRemoteIndex( String repositoryId, boolean now, boolean fullDownload )
throws ArchivaRestServiceException
{
try
{
downloadRemoteIndexScheduler.scheduleDownloadRemote( repositoryId, now, fullDownload );
}
catch ( DownloadRemoteIndexException e )
{
log.error( e.getMessage(), e );
throw new ArchivaRestServiceException( e.getMessage() );
}
return Boolean.TRUE;
}
public Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest ) public Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest )
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {