incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1076242 - /sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java
Date Wed, 02 Mar 2011 15:11:50 GMT
Author: cziegeler
Date: Wed Mar  2 15:11:50 2011
New Revision: 1076242

URL: http://svn.apache.org/viewvc?rev=1076242&view=rev
Log:
SLING-2010 : Support deep folder structure for installation

Modified:
    sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java

Modified: sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java?rev=1076242&r1=1076241&r2=1076242&view=diff
==============================================================================
--- sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java
(original)
+++ sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/WatchedFolder.java
Wed Mar  2 15:11:50 2011
@@ -141,44 +141,54 @@ class WatchedFolder implements EventList
         // Return an InstallableResource for all child nodes for which we have a NodeConverter
         final ScanResult result = new ScanResult();
         final Set<String> resourcesSeen = new HashSet<String>();
-        if(folder != null) {
-            final NodeIterator it = folder.getNodes();
-            while(it.hasNext()) {
-            	final Node n = it.nextNode();
-            	for(JcrInstaller.NodeConverter nc : converters) {
-            		final InstallableResource r = nc.convertNode(n, priority);
-            		if(r != null) {
-            			resourcesSeen.add(r.getId());
-            		    final String oldDigest = digests.get(r.getId());
-            		    if(r.getDigest().equals(oldDigest)) {
-            		    	log.debug("Digest didn't change, ignoring " + r);
-            		    } else {
-                            result.toAdd.add(r);
-            		    }
-            			break;
-            		}
-            	}
-            }
+        if (folder != null) {
+            scanNode(folder, result, resourcesSeen);
         }
 
         // Resources that existed but are not in resourcesSeen need to be
         // unregistered from OsgiInstaller
-        for(String url : existingResourceUrls) {
+        for(final String url : existingResourceUrls) {
         	if(!resourcesSeen.contains(url)) {
                 result.toRemove.add(url);
         	}
         }
-        for(String u : result.toRemove) {
+        for(final String u : result.toRemove) {
         	existingResourceUrls.remove(u);
         	digests.remove(u);
         }
 
         // Update saved digests of the resources that we're returning
-        for(InstallableResource r : result.toAdd) {
+        for(final InstallableResource r : result.toAdd) {
             existingResourceUrls.add(r.getId());
             digests.put(r.getId(), r.getDigest());
         }
 
         return result;
     }
+
+    private void scanNode(final Node folder, final ScanResult result, final Set<String>
resourcesSeen)
+    throws RepositoryException {
+        final NodeIterator it = folder.getNodes();
+        while(it.hasNext()) {
+            final Node n = it.nextNode();
+            boolean processed = false;
+            for (JcrInstaller.NodeConverter nc : converters) {
+                final InstallableResource r = nc.convertNode(n, priority);
+                if(r != null) {
+                    processed = true;
+                    resourcesSeen.add(r.getId());
+                    final String oldDigest = digests.get(r.getId());
+                    if(r.getDigest().equals(oldDigest)) {
+                        log.debug("Digest didn't change, ignoring " + r);
+                    } else {
+                        result.toAdd.add(r);
+                    }
+                    break;
+                }
+            }
+            if ( !processed ) {
+                this.scanNode(n, result, resourcesSeen);
+            }
+        }
+    }
 }



Mime
View raw message