]> source.dussan.org Git - archiva.git/commitdiff
add a rest service to schedule a download remote index
authorOlivier Lamy <olamy@apache.org>
Tue, 27 Sep 2011 07:18:30 +0000 (07:18 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 27 Sep 2011 07:18:30 +0000 (07:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1176245 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java

index d0397fb1750522a3b26a008e578e1b2824b377eb..a961a0a904acd504d7ae1ec067d3fc48b1b33865 100644 (file)
@@ -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;
+
 }
index b78a1c9f6a21e2890eeffcd9f0adc62e50106560..e1ff84c885ee0d3381a59e21e76ae6794a129f9d 100644 (file)
@@ -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
     {