From 8946eb16818609f9b23d52b3a5ab8c3e861b2f22 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 2 Dec 2008 13:02:37 +0000 Subject: [PATCH] [MRM-1027] Indices are not cleaned up when deleting artifact via web services Merged from: r722439 git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@722449 13f79535-47bb-0310-9956-ffa450edef68 --- ...eanupReleasedSnapshotsRepositoryPurge.java | 1 + .../events/RepositoryListenerFactoryBean.java | 63 ++++++++ .../webapp/WEB-INF/applicationContext.xml | 7 +- .../archiva-xmlrpc-client/pom.xml | 8 +- .../services/AdministrationServiceImpl.java | 44 +++--- .../AdministrationServiceImplTest.java | 134 +++++++++--------- .../archiva-test/1.0/archiva-test-1.0.jar | 0 .../archiva-test/1.0/archiva-test-1.0.jar.md5 | 0 .../1.0/archiva-test-1.0.jar.sha1 | 0 .../archiva-test/1.0/archiva-test-1.0.pom | 0 .../archiva-test/1.0/archiva-test-1.0.pom.md5 | 0 .../1.0/archiva-test-1.0.pom.sha1 | 0 .../archiva-test/1.0/maven-metadata.xml | 0 .../archiva-test/1.0/maven-metadata.xml.md5 | 0 .../archiva-test/1.0/maven-metadata.xml.sha1 | 0 .../archiva-test/1.1/archiva-test-1.1.jar | 0 .../archiva-test/1.1/archiva-test-1.1.pom | 0 .../jars/archiva-diff-1.0.jar | 0 .../jars/archiva-test-1.0.jar | 0 .../jars/archiva-test-1.1.jar | 0 .../poms/archiva-diff-1.0.pom | 0 .../poms/archiva-test-1.0.pom | 0 .../poms/archiva-test-1.1.pom | 0 23 files changed, 155 insertions(+), 102 deletions(-) create mode 100644 archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5 (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1 (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5 (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1 (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5 (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1 (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom (100%) rename archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/{resources => repositories}/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom (100%) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java index ae4524d06..7d358c5fe 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java @@ -174,6 +174,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge versionRef.setVersion( version ); repository.deleteVersion( versionRef ); + // TODO: looks incomplete, might not delete related artifacts? for ( RepositoryListener listener : listeners ) { listener.deleteArtifact( repository, artifact ); diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java new file mode 100644 index 000000000..b4d16b16d --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java @@ -0,0 +1,63 @@ +package org.apache.maven.archiva.repository.events; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +/** + * @todo though we will eventually remove this altogether, an interim cleanup would be to genericise this + * and replace the calls in RepositoryContentConsumers with calls to the same thing + */ +public class RepositoryListenerFactoryBean + implements FactoryBean, ApplicationContextAware +{ + + private ApplicationContext applicationContext; + + public void setApplicationContext( ApplicationContext applicationContext ) + throws BeansException + { + this.applicationContext = applicationContext; + } + + public Object getObject() + throws Exception + { + return applicationContext.getBeansOfType( RepositoryListener.class ).values(); + } + + public Class getObjectType() + { + return List.class; + } + + public boolean isSingleton() + { + return true; + } + + +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index 1df527c05..58c3b69b7 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -57,9 +57,10 @@ - - - + + + + diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml index 604c8a4fd..07c668a99 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml @@ -45,12 +45,12 @@ org.apache.archiva.web.xmlrpc.client.SampleClient - http://127.0.0.1:8080/archiva/xmlrpc - username - password + http://127.0.0.1:9091/xmlrpc + admin + ${password} diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java index 61204b891..e7437701c 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java @@ -20,6 +20,7 @@ package org.apache.archiva.web.xmlrpc.services; */ import java.util.ArrayList; +import java.util.Collection; import java.util.List; import org.apache.archiva.web.xmlrpc.api.AdministrationService; @@ -32,7 +33,6 @@ import org.apache.maven.archiva.configuration.IndeterminateConfigurationExceptio import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; -import org.apache.maven.archiva.consumers.ConsumerException; import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer; import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.maven.archiva.database.ArchivaDatabaseException; @@ -48,6 +48,7 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.RepositoryException; import org.apache.maven.archiva.repository.RepositoryNotFoundException; +import org.apache.maven.archiva.repository.events.RepositoryListener; import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers; import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler; @@ -74,25 +75,22 @@ public class AdministrationServiceImpl private ArtifactDAO artifactDAO; - private DatabaseCleanupConsumer cleanupArtifacts; - - private DatabaseCleanupConsumer cleanupProjects; - private ArchivaTaskScheduler taskScheduler; + private Collection listeners; + public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory, - ArtifactDAO artifactDAO, DatabaseCleanupConsumer cleanupArtifacts, - DatabaseCleanupConsumer cleanupProjects, ArchivaTaskScheduler taskScheduler ) - { + ArtifactDAO artifactDAO, ArchivaTaskScheduler taskScheduler, + Collection listeners ) + { this.archivaConfiguration = archivaConfig; this.repoConsumersUtil = repoConsumersUtil; this.dbConsumersUtil = dbConsumersUtil; this.repoFactory = repoFactory; this.artifactDAO = artifactDAO; - this.cleanupArtifacts = cleanupArtifacts; - this.cleanupProjects = cleanupProjects; this.taskScheduler = taskScheduler; + this.listeners = listeners; } /** @@ -230,7 +228,7 @@ public class AdministrationServiceImpl ref.setGroupId( groupId ); ref.setArtifactId( artifactId ); ref.setVersion( version ); - + // delete from file system repoContent.deleteVersion( ref ); @@ -240,31 +238,23 @@ public class AdministrationServiceImpl try { artifacts = artifactDAO.queryArtifacts( constraint ); - if( artifacts == null ) - { - return true; - } } catch ( ArchivaDatabaseException e ) { throw new Exception( "Error occurred while cleaning up database." ); } - // cleanup db manually? or use the cleanup consumers as what is done now? - for( ArchivaArtifact artifact : artifacts ) + if ( artifacts != null ) { - if( artifact.getVersion().equals( version ) ) + for ( ArchivaArtifact artifact : artifacts ) { - try + if ( artifact.getVersion().equals( version ) ) { - cleanupArtifacts.processArchivaArtifact( artifact ); - cleanupProjects.processArchivaArtifact( artifact ); + for ( RepositoryListener listener : listeners ) + { + listener.deleteArtifact( repoContent, artifact ); + } } - catch ( ConsumerException ce ) - { - // log error - continue; - } } } } @@ -436,5 +426,5 @@ public class AdministrationServiceImpl { throw new Exception( "Error occurred while saving the configuration." ); } - } + } } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java index 9817a9945..71ccb87d1 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -20,11 +20,15 @@ package org.apache.archiva.web.xmlrpc.services; */ import java.io.File; +import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.FileFilterUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; @@ -45,6 +49,7 @@ import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent; import org.apache.maven.archiva.repository.content.PathParser; +import org.apache.maven.archiva.repository.events.RepositoryListener; import org.apache.maven.archiva.repository.layout.LayoutException; import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers; import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; @@ -100,16 +105,10 @@ public class AdministrationServiceImplTest private MockControl unprocessedConsumersControl; - private MockControl cleanupConsumersControl; - private DatabaseUnprocessedArtifactConsumer processArtifactConsumer; private DatabaseUnprocessedArtifactConsumer processPomConsumer; - private DatabaseCleanupConsumer cleanupIndexConsumer; - - private DatabaseCleanupConsumer cleanupDbConsumer; - // delete artifact private MockControl repoFactoryControl; @@ -119,9 +118,15 @@ public class AdministrationServiceImplTest private ArtifactDAO artifactDao; - private MockControl cleanupControl; - - private DatabaseCleanupConsumer cleanupConsumer; + private MockControl listenerControl; + + private RepositoryListener listener; + + private DatabaseCleanupConsumer cleanupIndexConsumer; + + private DatabaseCleanupConsumer cleanupDbConsumer; + + private MockControl cleanupConsumersControl; protected void setUp() throws Exception @@ -154,9 +159,9 @@ public class AdministrationServiceImplTest dbConsumersUtil = ( DatabaseConsumers ) dbConsumersUtilControl.getMock(); cleanupConsumersControl = MockControl.createControl( DatabaseCleanupConsumer.class ); - cleanupIndexConsumer = ( DatabaseCleanupConsumer ) cleanupConsumersControl.getMock(); - cleanupDbConsumer = ( DatabaseCleanupConsumer ) cleanupConsumersControl.getMock(); - + cleanupIndexConsumer = (DatabaseCleanupConsumer) cleanupConsumersControl.getMock(); + cleanupDbConsumer = (DatabaseCleanupConsumer) cleanupConsumersControl.getMock(); + unprocessedConsumersControl = MockControl.createControl( DatabaseUnprocessedArtifactConsumer.class ); processArtifactConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock(); processPomConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock(); @@ -168,11 +173,12 @@ public class AdministrationServiceImplTest artifactDaoControl = MockControl.createControl( ArtifactDAO.class ); artifactDao = ( ArtifactDAO ) artifactDaoControl.getMock(); - cleanupControl = MockClassControl.createControl( DatabaseCleanupConsumer.class ); - cleanupConsumer = ( DatabaseCleanupConsumer ) cleanupControl.getMock(); - - service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, dbConsumersUtil, - repositoryFactory, artifactDao, cleanupConsumer, cleanupConsumer, taskScheduler ); + listenerControl = MockControl.createControl( RepositoryListener.class ); + listener = (RepositoryListener) listenerControl.getMock(); + + service = + new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, dbConsumersUtil, repositoryFactory, + artifactDao, taskScheduler, Collections.singletonList( listener ) ); } /* Tests for database consumers */ @@ -210,7 +216,7 @@ public class AdministrationServiceImplTest recordDbConsumers(); - // test enable "process-pom" db consumer + // test enable "process-pom" db consumer archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning ); @@ -243,7 +249,7 @@ public class AdministrationServiceImplTest archivaConfigControl.verify(); configControl.verify(); - // test disable "process-pom" db consumer + // test disable "process-pom" db consumer dbConsumersUtilControl.reset(); cleanupConsumersControl.reset(); unprocessedConsumersControl.reset(); @@ -454,11 +460,7 @@ public class AdministrationServiceImplTest public void testDeleteM2ArtifactArtifactExists() throws Exception { - File file = new File( getBasedir(), "/target/test-classes/default-repo/" ); - assertTrue( file.exists() ); - - ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "default", "Internal Repository", true, false ); - managedRepo.setLocation( file.getAbsolutePath() ); + ManagedRepositoryConfiguration managedRepo = createManagedRepo("default", "default-repo"); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); @@ -474,33 +476,26 @@ public class AdministrationServiceImplTest artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER ); artifactDaoControl.setReturnValue( artifacts ); - cleanupConsumer.processArchivaArtifact( artifacts.get( 0 ) ); - cleanupControl.setVoidCallable( 2 ); + listener.deleteArtifact( repoContent, artifacts.get( 0 ) ); + listenerControl.setVoidCallable( 1 ); archivaConfigControl.replay(); configControl.replay(); repoFactoryControl.replay(); artifactDaoControl.replay(); - cleanupControl.replay(); + listenerControl.replay(); - try - { - boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" ); - assertTrue( success ); - } - catch ( Exception e ) - { - fail( "An exception should not have been thrown." ); - } + boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" ); + assertTrue( success ); archivaConfigControl.verify(); configControl.verify(); repoFactoryControl.verify(); artifactDaoControl.verify(); - cleanupControl.verify(); + listenerControl.verify(); - assertFalse( new File( getBasedir(), "/target/test-classes/default-repo/org/apache/archiva/archiva-test/1.0" ).exists() ); - assertTrue( new File( getBasedir(), "/target/test-classes/default-repo/org/apache/archiva/archiva-test/1.1" ).exists() ); + assertFalse( new File( managedRepo.getLocation(), "org/apache/archiva/archiva-test/1.0" ).exists() ); + assertTrue( new File( managedRepo.getLocation(), "org/apache/archiva/archiva-test/1.1" ).exists() ); } public void testDeleteM1ArtifactArtifactExists() @@ -512,11 +507,7 @@ public class AdministrationServiceImplTest MockControl pathParserControl = MockClassControl.createControl( PathParser.class ); PathParser parser = ( PathParser ) pathParserControl.getMock(); - File file = new File( getBasedir(), "/target/test-classes/legacy-repo/" ); - assertTrue( file.exists() ); - - ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "legacy", "Internal Repository", true, false ); - managedRepo.setLocation( file.getAbsolutePath() ); + ManagedRepositoryConfiguration managedRepo = createManagedRepo( "legacy", "legacy-repo" ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); @@ -536,52 +527,42 @@ public class AdministrationServiceImplTest artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER ); artifactDaoControl.setReturnValue( artifacts ); - cleanupConsumer.processArchivaArtifact( artifacts.get( 0 ) ); - cleanupControl.setVoidCallable( 2 ); + listener.deleteArtifact( repoContent, artifacts.get( 0 ) ); + listenerControl.setVoidCallable( 1 ); archivaConfigControl.replay(); configControl.replay(); repoFactoryControl.replay(); artifactDaoControl.replay(); - cleanupControl.replay(); + listenerControl.replay(); fileTypesControl.replay(); pathParserControl.replay(); - try - { - boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" ); - assertTrue( success ); - } - catch ( Exception e ) - { - fail( "An exception should not have been thrown." ); - } + boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" ); + assertTrue( success ); archivaConfigControl.verify(); configControl.verify(); repoFactoryControl.verify(); artifactDaoControl.verify(); - cleanupControl.verify(); + listenerControl.verify(); fileTypesControl.verify(); pathParserControl.verify(); - assertFalse( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar" ).exists() ); - assertFalse( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom" ).exists() ); + File repo = new File( managedRepo.getLocation() ); + assertFalse( new File( repo, "org.apache.archiva/jars/archiva-test-1.0.jar" ).exists() ); + assertFalse( new File( repo, "org.apache.archiva/poms/archiva-test-1.0.pom" ).exists() ); - assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar" ).exists() ); - assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar" ).exists() ); - assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom" ).exists() ); - assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom" ).exists() ); + assertTrue( new File( repo, "org.apache.archiva/jars/archiva-test-1.1.jar" ).exists() ); + assertTrue( new File( repo, "org.apache.archiva/jars/archiva-diff-1.0.jar" ).exists() ); + assertTrue( new File( repo, "org.apache.archiva/poms/archiva-test-1.1.pom" ).exists() ); + assertTrue( new File( repo, "org.apache.archiva/poms/archiva-diff-1.0.pom" ).exists() ); } public void testDeleteArtifactArtifactDoesNotExist() throws Exception { - File file = new File( getBasedir(), "/target/test-classes/default-repo/" ); - assertTrue( file.exists() ); - - ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "default", "Internal Repository", true, false ); - managedRepo.setLocation( file.getAbsolutePath() ); + ManagedRepositoryConfiguration managedRepo = createManagedRepo("default", "default-repo"); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); @@ -609,6 +590,23 @@ public class AdministrationServiceImplTest configControl.verify(); repoFactoryControl.verify(); } + + private ManagedRepositoryConfiguration createManagedRepo(String layout, String directory) + throws IOException + { + File srcDir = new File( getBasedir(), "src/test/repositories/"+ directory ); + + File repoDir = getTestFile( "target/test-repos/" + directory ); + + FileUtils.deleteDirectory( repoDir ); + + FileUtils.copyDirectory( srcDir, repoDir, FileFilterUtils.makeSVNAware( null ) ); + + ManagedRepositoryConfiguration managedRepo = + createManagedRepo( "internal", layout, "Internal Repository", true, false ); + managedRepo.setLocation( repoDir.getAbsolutePath() ); + return managedRepo; + } public void testDeleteArtifacRepositoryDoesNotExist() throws Exception diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5 similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5 rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5 diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1 similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1 rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1 diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5 similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5 rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5 diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1 similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1 rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1 diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5 similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5 rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5 diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1 b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1 similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1 rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1 diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom similarity index 100% rename from archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom rename to archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom -- 2.39.5