]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1027] Indices are not cleaned up when deleting artifact via web services
authorBrett Porter <brett@apache.org>
Tue, 2 Dec 2008 13:02:37 +0000 (13:02 +0000)
committerBrett Porter <brett@apache.org>
Tue, 2 Dec 2008 13:02:37 +0000 (13:02 +0000)
Merged from: r722439

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@722449 13f79535-47bb-0310-9956-ffa450edef68

40 files changed:
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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 [new file with mode: 0644]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar [new file with mode: 0644]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar [new file with mode: 0644]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar [new file with mode: 0644]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom [new file with mode: 0644]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom [new file with mode: 0644]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom [new file with mode: 0644]
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 [deleted file]
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 [deleted file]
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 [deleted file]
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 [deleted file]
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 [deleted file]
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 [deleted file]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml [deleted file]
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 [deleted file]
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 [deleted file]
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 [deleted file]
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 [deleted file]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar [deleted file]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar [deleted file]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar [deleted file]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom [deleted file]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom [deleted file]
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom [deleted file]

index ae4524d06dac1547b5c61793416a212fdb7658f3..7d358c5fea144626ece15e72e7c81fde43dbab4e 100644 (file)
@@ -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 (file)
index 0000000..b4d16b1
--- /dev/null
@@ -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;
+    }
+
+    
+}
index 1df527c0508fed3860793cb931ca10420c290d79..58c3b69b794f6635f44119420b24593017a03b4a 100644 (file)
     <constructor-arg ref="databaseConsumers"/>
     <constructor-arg ref="repositoryContentFactory"/>
     <constructor-arg ref="artifactDAO#jdo"/>
-    <constructor-arg ref="databaseCleanupConsumer#not-present-remove-db-artifact"/>
-    <constructor-arg ref="databaseCleanupConsumer#not-present-remove-db-project"/> 
-    <constructor-arg ref="archivaTaskScheduler"/>       
+    <constructor-arg ref="archivaTaskScheduler"/>
+    <constructor-arg>
+      <bean class="org.apache.maven.archiva.repository.events.RepositoryListenerFactoryBean" />
+    </constructor-arg>       
   </bean> 
 
   <bean name="xmlrpcServicesList" lazy-init="true" scope="singleton" class="java.util.ArrayList">
index 604c8a4fd0c5ab6a50c691066fca0ca36ab717a7..07c668a9910c95352126fd2f962b8490707a652c 100644 (file)
           <mainClass>org.apache.archiva.web.xmlrpc.client.SampleClient</mainClass>
           <arguments>
             <!-- 
-                 URL: ex. http://127.0.0.1:8080/archiva/xmlrpc 
+                 URL: ex. http://127.0.0.1:9091/xmlrpc 
                  USERNAME & PASSWORD: Archiva credentials  
             --> 
-            <argument>http://127.0.0.1:8080/archiva/xmlrpc</argument>
-            <argument>username</argument>
-            <argument>password</argument>
+            <argument>http://127.0.0.1:9091/xmlrpc</argument>
+            <argument>admin</argument>
+            <argument>${password}</argument>
           </arguments>
         </configuration>
       </plugin>
index 61204b891f4cbb671bf32ff2ebf0e80329fd1499..e7437701c0e1dfebbaa67fc93034ddf96dacc983 100644 (file)
@@ -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<RepositoryListener> listeners;
+
     public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil,
                                       DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory,
-                                      ArtifactDAO artifactDAO, DatabaseCleanupConsumer cleanupArtifacts,
-                                      DatabaseCleanupConsumer cleanupProjects, ArchivaTaskScheduler taskScheduler )
-    {   
+                                      ArtifactDAO artifactDAO, ArchivaTaskScheduler taskScheduler,
+                                      Collection<RepositoryListener> 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." );    
         }
-    }    
+    }
 }
index 9817a9945f616974b10666544ad543a25ef37939..71ccb87d103169b6afc5d232f9e54720e99034d7 100644 (file)
@@ -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/repositories/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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/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 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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/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 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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/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 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
new file mode 100644 (file)
index 0000000..f80e1de
--- /dev/null
@@ -0,0 +1,18 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+  <modelVersion>4.0.0</modelVersion>\r
+  <groupId>org.apache.archiva</groupId>\r
+  <artifactId>archiva-test</artifactId>\r
+  <packaging>jar</packaging>\r
+  <version>1.0</version>\r
+  <name>Maven Quick Start Archetype</name>\r
+  <url>http://maven.apache.org</url>\r
+  <dependencies>\r
+    <dependency>\r
+      <groupId>junit</groupId>\r
+      <artifactId>junit</artifactId>\r
+      <version>3.8.1</version>\r
+      <scope>test</scope>\r
+    </dependency>\r
+  </dependencies>\r
+</project>\r
diff --git a/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 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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/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 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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/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 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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/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 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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/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 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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/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 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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/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
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/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
new file mode 100644 (file)
index 0000000..e69de29
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.md5
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar.sha1
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom
deleted file mode 100644 (file)
index f80e1de..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
-  <modelVersion>4.0.0</modelVersion>\r
-  <groupId>org.apache.archiva</groupId>\r
-  <artifactId>archiva-test</artifactId>\r
-  <packaging>jar</packaging>\r
-  <version>1.0</version>\r
-  <name>Maven Quick Start Archetype</name>\r
-  <url>http://maven.apache.org</url>\r
-  <dependencies>\r
-    <dependency>\r
-      <groupId>junit</groupId>\r
-      <artifactId>junit</artifactId>\r
-      <version>3.8.1</version>\r
-      <scope>test</scope>\r
-    </dependency>\r
-  </dependencies>\r
-</project>\r
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.md5
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom.sha1
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.md5
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml.sha1
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.jar
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/default-repo/org/apache/archiva/archiva-test/1.1/archiva-test-1.1.pom
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom
deleted file mode 100644 (file)
index e69de29..0000000
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/resources/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom
deleted file mode 100644 (file)
index e69de29..0000000