From b79bd84a0cded52fd0b8e44c8b7dbab6616c6093 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 23 Sep 2011 06:42:51 +0000 Subject: [PATCH] REST service to copy artifact from one repo to an other one use a field from parent class git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1174542 13f79535-47bb-0310-9956-ffa450edef68 --- .../services/DefaultRepositoriesService.java | 16 ++++++++-------- .../rest/services/RepositoriesServiceTest.java | 9 ++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) 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 ca1059a77..b78a1c9f6 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 @@ -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 ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java index 3181c800d..2c4f6ab8a 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java @@ -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 " );