Author: cziegeler
Date: Fri Jan 21 09:41:42 2011
New Revision: 1061707

URL: http://svn.apache.org/viewvc?rev=1061707&view=rev
Log:
SLING-1945 : Remove resource from untransformed resources if resource is 
removed by provider

Modified:
    
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
    
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java

Modified: 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java?rev=1061707&r1=1061706&r2=1061707&view=diff
==============================================================================
--- 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
 (original)
+++ 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
 Fri Jan 21 09:41:42 2011
@@ -191,6 +191,10 @@ public class PersistentResourceList {
 
             t.addOrUpdate(input);
         } else {
+            // check if there is an old resource and remove it first
+            if ( this.untransformedResources.contains(input) ) {
+                this.untransformedResources.remove(input);
+            }
             this.untransformedResources.add(input);
         }
     }
@@ -203,13 +207,25 @@ public class PersistentResourceList {
     }
 
     /**
-     * Remove a resource by url
+     * Remove a resource by url.
+     * Check all resource groups and the list of untransformed resources.
      * @param url The url to remove
      */
     public void remove(final String url) {
+        // iterate over all resource groups and remove resources
+        // with the given url
         for(final EntityResourceList group : this.data.values()) {
             group.remove(url);
         }
+        // iterate over untransformed resources and remove
+        // the resource with that url
+        for(final RegisteredResource rr : this.untransformedResources) {
+            if ( rr.getURL().equals(url) ) {
+                ((RegisteredResourceImpl)rr).cleanup();
+                this.untransformedResources.remove(rr);
+                break;
+            }
+        }
     }
 
     /**

Modified: 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java?rev=1061707&r1=1061706&r2=1061707&view=diff
==============================================================================
--- 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java
 (original)
+++ 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/RegisteredResourceImpl.java
 Fri Jan 21 09:41:42 2011
@@ -293,7 +293,7 @@ public class RegisteredResourceImpl
             return false;
         }
         if ( this.entity == null ) {
-            return super.equals(obj);
+            return 
this.getURL().equals(((RegisteredResourceImpl)obj).getURL());
         }
         return compareTo((RegisteredResourceImpl)obj) == 0;
     }


Reply via email to