archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r722449 - in /archiva/trunk/archiva-modules: archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/ archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiv...
Date Tue, 02 Dec 2008 13:02:38 GMT
Author: brett
Date: Tue Dec  2 05:02:37 2008
New Revision: 722449

URL: http://svn.apache.org/viewvc?rev=722449&view=rev
Log:
[MRM-1027] Indices are not cleaned up when deleting artifact via web services
Merged from: r722439

Added:
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java
      - copied unchanged from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/events/RepositoryListenerFactoryBean.java
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml
      - copied unchanged from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.0/maven-metadata.xml
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.1/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/default-repo/org/apache/archiva/archiva-test/1.1/
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/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
      - copied unchanged from r722439, archiva/branches/MRM-1025/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
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar
      - copied unchanged from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar
      - copied unchanged from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar
      - copied unchanged from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/
      - copied from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom
      - copied unchanged from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom
      - copied unchanged from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom
      - copied unchanged from r722439, archiva/branches/MRM-1025/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/repositories/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom
Removed:
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/default-repo/
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/resources/legacy-repo/
Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java?rev=722449&r1=722448&r2=722449&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
Tue Dec  2 05:02:37 2008
@@ -174,6 +174,7 @@
                     versionRef.setVersion( version );
                     repository.deleteVersion( versionRef );
                     
+                    // TODO: looks incomplete, might not delete related artifacts?
                     for ( RepositoryListener listener : listeners )
                     {
                         listener.deleteArtifact( repository, artifact );

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml?rev=722449&r1=722448&r2=722449&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
Tue Dec  2 05:02:37 2008
@@ -57,9 +57,10 @@
     <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">

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml?rev=722449&r1=722448&r2=722449&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/pom.xml
Tue Dec  2 05:02:37 2008
@@ -45,12 +45,12 @@
           <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>

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java?rev=722449&r1=722448&r2=722449&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
Tue Dec  2 05:02:37 2008
@@ -20,6 +20,7 @@
  */
 
 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.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.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 @@
     
     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 @@
             ref.setGroupId( groupId );
             ref.setArtifactId( artifactId );
             ref.setVersion( version );
-                   
+            
             // delete from file system
             repoContent.deleteVersion( ref );
             
@@ -240,31 +238,23 @@
             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 @@
         {
             throw new Exception( "Error occurred while saving the configuration." );    
         }
-    }    
+    }
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java?rev=722449&r1=722448&r2=722449&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java
Tue Dec  2 05:02:37 2008
@@ -20,11 +20,15 @@
  */
 
 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.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 @@
     
     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 @@
     
     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 @@
         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 @@
         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 @@
         
         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 @@
         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 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 @@
         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 @@
         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 @@
         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() );
-        
-        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() );
+        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( 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 @@
         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



Mime
View raw message