From: Olivier Lamy Date: Tue, 27 Sep 2011 07:18:30 +0000 (+0000) Subject: add a rest service to schedule a download remote index X-Git-Tag: archiva-1.4-M1~188 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=066197cdd2f89fa0910bf9e05a60fbf466b60945;p=archiva.git 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 --- diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java index d0397fb17..a961a0a90 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java @@ -83,4 +83,13 @@ public interface RepositoriesService Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest ) 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; + } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java index b78a1c9f6..e1ff84c88 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java @@ -44,6 +44,8 @@ import org.apache.archiva.rest.api.services.RepositoriesService; import org.apache.archiva.scheduler.ArchivaTaskScheduler; import org.apache.archiva.scheduler.indexing.ArchivaIndexingTaskExecutor; 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.RepositoryTask; import org.apache.archiva.security.common.ArchivaRoleConstants; @@ -67,7 +69,6 @@ import org.springframework.stereotype.Service; import javax.inject.Inject; import javax.inject.Named; -import javax.ws.rs.PathParam; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -119,6 +120,9 @@ public class DefaultRepositoriesService @Named( value = "archivaTaskScheduler#repository" ) private ArchivaTaskScheduler scheduler; + @Inject + private DownloadRemoteIndexScheduler downloadRemoteIndexScheduler; + private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 }; 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 ) throws ArchivaRestServiceException {