]> source.dussan.org Git - archiva.git/commitdiff
REST service to copy artifact from one repo to an other one use a field from parent...
authorOlivier Lamy <olamy@apache.org>
Fri, 23 Sep 2011 06:42:51 +0000 (06:42 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 23 Sep 2011 06:42:51 +0000 (06:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1174542 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java

index ca1059a77c1bf25f3547c450f85db9524382edc0..b78a1c9f6a21e2890eeffcd9f0adc62e50106560 100644 (file)
@@ -125,7 +125,7 @@ public class DefaultRepositoriesService
     {
         if ( repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId ) )
         {
-            log.info( "scanning of repository with id {} already scheduled" );
+            log.info( "scanning of repository with id {} already scheduled", repositoryId );
             return Boolean.FALSE;
         }
         RepositoryTask task = new RepositoryTask();
@@ -148,7 +148,7 @@ public class DefaultRepositoriesService
         return repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId );
     }
 
-    public Boolean removeScanningTaskFromQueue( @PathParam( "repositoryId" ) String repositoryId )
+    public Boolean removeScanningTaskFromQueue( String repositoryId )
     {
         RepositoryTask task = new RepositoryTask();
         task.setRepositoryId( repositoryId );
@@ -201,7 +201,7 @@ public class DefaultRepositoriesService
             throw new ArchivaRestServiceException( "copyArtifact call: userName not found" );
         }
 
-        if ( StringUtils.isBlank( artifactTransferRequest.getSourceRepositoryId() ) )
+        if ( StringUtils.isBlank( artifactTransferRequest.getRepositoryId() ) )
         {
             throw new ArchivaRestServiceException( "copyArtifact call: sourceRepositoryId cannot be null" );
         }
@@ -214,7 +214,7 @@ public class DefaultRepositoriesService
         ManagedRepository source = null;
         try
         {
-            source = managedRepositoryAdmin.getManagedRepository( artifactTransferRequest.getSourceRepositoryId() );
+            source = managedRepositoryAdmin.getManagedRepository( artifactTransferRequest.getRepositoryId() );
         }
         catch ( RepositoryAdminException e )
         {
@@ -224,7 +224,7 @@ public class DefaultRepositoriesService
         if ( source == null )
         {
             throw new ArchivaRestServiceException(
-                "cannot find repository with id " + artifactTransferRequest.getSourceRepositoryId() );
+                "cannot find repository with id " + artifactTransferRequest.getRepositoryId() );
         }
 
         ManagedRepository target = null;
@@ -282,11 +282,11 @@ public class DefaultRepositoriesService
         {
             boolean authz =
                 securitySystem.isAuthorized( securitySession, ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS,
-                                             artifactTransferRequest.getSourceRepositoryId() );
+                                             artifactTransferRequest.getRepositoryId() );
             if ( !authz )
             {
                 throw new ArchivaRestServiceException(
-                    "not authorized to access repo:" + artifactTransferRequest.getSourceRepositoryId() );
+                    "not authorized to access repo:" + artifactTransferRequest.getRepositoryId() );
             }
         }
         catch ( AuthorizationException e )
@@ -327,7 +327,7 @@ public class DefaultRepositoriesService
         {
 
             ManagedRepositoryContent sourceRepository =
-                repositoryFactory.getManagedRepositoryContent( artifactTransferRequest.getSourceRepositoryId() );
+                repositoryFactory.getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() );
 
             String artifactSourcePath = sourceRepository.toPath( artifactReference );
 
index 3181c800da1db0e3032bdd9e6c9a077ca069c4b9..2c4f6ab8a8ea90d058503c7652c677640e3c2758 100644 (file)
@@ -20,11 +20,11 @@ package org.apache.archiva.rest.services;
  */
 
 import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
 import org.apache.archiva.rest.api.services.RepositoriesService;
 import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
 import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.archiva.common.utils.FileUtil;
 import org.junit.Test;
 
 import java.io.File;
@@ -66,6 +66,13 @@ public class RepositoriesServiceTest
 
         String repoId = managedRepositoriesService.getManagedRepositories().get( 0 ).getId();
 
+        // take care if already in scan queue by startup phase
+        if ( service.alreadyScanning( repoId ) )
+        {
+            service.removeScanningTaskFromQueue( repoId );
+            assertFalse( service.alreadyScanning( repoId ) );
+        }
+
         assertTrue( service.scanRepository( repoId, true ) );
 
         log.info( "scanRepo call ok " );