sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r653411 - in /incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal: ContentLoaderService.java Loader.java
Date Mon, 05 May 2008 10:14:26 GMT
Author: cziegeler
Date: Mon May  5 03:14:26 2008
New Revision: 653411

URL: http://svn.apache.org/viewvc?rev=653411&view=rev
Log:
SLING-413: Handle bundle update and correctly handle overwrite flag.

Modified:
    incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
    incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java

Modified: incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java?rev=653411&r1=653410&r2=653411&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
(original)
+++ incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java
Mon May  5 03:14:26 2008
@@ -20,7 +20,9 @@
 
 import java.util.Calendar;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import java.util.StringTokenizer;
 
 import javax.jcr.Node;
@@ -90,6 +92,11 @@
      */
     private String slingId;
 
+    /**
+     * List of currently updated bundles.
+     */
+    private final Set<String> updatedBundles = new HashSet<String>();
+
     // ---------- BundleListener -----------------------------------------------
 
     /**
@@ -114,7 +121,8 @@
                 // we can safely add the content at this point.
                 try {
                     Session session = getAdminSession();
-                    initialContentLoader.registerBundle(session, event.getBundle(), false);
+                    final boolean isUpdate = this.updatedBundles.remove(event.getBundle().getSymbolicName());
+                    initialContentLoader.registerBundle(session, event.getBundle(), isUpdate);
                 } catch (Throwable t) {
                     log.error(
                         "bundleChanged: Problem loading initial content of bundle "
@@ -122,6 +130,11 @@
                             + event.getBundle().getBundleId() + ")", t);
                 }
                 break;
+            case BundleEvent.UPDATED:
+                // we just add the symbolic name to the list of updated bundles
+                // we will use this info when the new start event is triggered
+                this.updatedBundles.add(event.getBundle().getSymbolicName());
+                break;
             case BundleEvent.STOPPED:
                 try {
                     Session session = getAdminSession();

Modified: incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java?rev=653411&r1=653410&r2=653411&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
(original)
+++ incubator/sling/trunk/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
Mon May  5 03:14:26 2008
@@ -152,7 +152,7 @@
                 if ( !isUpdate && contentAlreadyLoaded ) {
                     log.info("Content of bundle already loaded {}.", bundle.getSymbolicName());
                 } else {
-                    this.installContent(session, bundle, pathIter);
+                    this.installContent(session, bundle, pathIter, contentAlreadyLoaded);
                     if (isRetry) {
                         // log success of retry
                         log.info(
@@ -197,20 +197,23 @@
 
     // ---------- internal -----------------------------------------------------
 
-    private void installContent(Session session, Bundle bundle, final Iterator<PathEntry>
pathIter)
+    private void installContent(final Session session,
+                                final Bundle bundle,
+                                final Iterator<PathEntry> pathIter,
+                                final boolean contentAlreadyLoaded)
     throws RepositoryException {
-        try {
-            log.debug("Installing initial content from bundle {}",
+        log.debug("Installing initial content from bundle {}",
                 bundle.getSymbolicName());
+        try {
             while (pathIter.hasNext() ) {
                 final PathEntry entry = pathIter.next();
-                this.installFromPath(bundle, entry.getPath(), entry.isOverwrite(), session.getRootNode());
+                if ( !contentAlreadyLoaded || entry.isOverwrite() ) {
+                    this.installFromPath(bundle, entry.getPath(), entry.isOverwrite(), session.getRootNode());
+                }
             }
 
             // persist modifications now
             session.save();
-            log.debug("Done installing initial content from bundle {}",
-                bundle.getSymbolicName());
         } finally {
             try {
                 if (session.hasPendingChanges()) {
@@ -222,6 +225,8 @@
                     bundle.getSymbolicName(), re);
             }
         }
+        log.debug("Done installing initial content from bundle {}",
+                bundle.getSymbolicName());
 
     }
 



Mime
View raw message