incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r695929 - /incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
Date Tue, 16 Sep 2008 14:53:24 GMT
Author: bdelacretaz
Date: Tue Sep 16 07:53:24 2008
New Revision: 695929

URL: http://svn.apache.org/viewvc?rev=695929&view=rev
Log:
SLING-658 - only uninstall resources from folders which don't match current regexp

Modified:
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java?rev=695929&r1=695928&r2=695929&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
Tue Sep 16 07:53:24 2008
@@ -30,6 +30,7 @@
 import java.util.Properties;
 import java.util.Set;
 
+import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
@@ -240,18 +241,29 @@
     
     /** Uninstall resources as needed when starting up */
     void handleInitialUninstalls() {
-        // If regexp has changed, uninstall everything - it's a bit hard
-        // to know what might have changed otherwise
-        // (null context happens during testing only)
+        // If regexp has changed, uninstall resources left in folders 
+        // that don't match the new regexp
+        // TODO this happens right after activate() is called on this service,
+        // might conflict with ongoing SCR activities?
         final Properties props = loadProperties(serviceDataFile);
         final String oldRegexp = props.getProperty(DATA_LAST_FOLDER_REGEXP);
         if(oldRegexp != null && !oldRegexp.equals(folderNameFilter.getRegexp()))
{
-            log.info("Folder name regexp has changed, uninstalling all resources ( {} ->
{} )", 
+            log.info("Folder name regexp has changed uninstalling non-applicable resources
( {} -> {} )", 
                     oldRegexp, folderNameFilter.getRegexp());
             for(String uri : osgiController.getInstalledUris()) {
                 try {
-                    osgiController.uninstall(uri);
-                } catch (JcrInstallException e) {
+                    if(session.itemExists(uri)) {
+                        final Item i = session.getItem(uri);
+                        if(i.isNode()) {
+                            final Node n = (Node)i;
+                            final Node parent = n.getParent();
+                            if(!folderNameFilter.accept(parent.getPath())) {
+                                log.info("Uninstalling resource {}, folder name not accepted
by current filter", uri);
+                                osgiController.uninstall(uri);
+                            }
+                        }
+                    }
+                } catch (Exception e) {
                     log.warn("Exception during 'uninstall all'", e);
                 }
             }



Mime
View raw message