You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:45:57 UTC

[sling-org-apache-sling-jcr-contentloader] 04/32: SLING-400: Move content loading to own bundle.

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.contentloader-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git

commit 6adfd33834caa041231d1c1b802eff7a9bc403e7
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Apr 30 11:31:40 2008 +0000

    SLING-400: Move content loading to own bundle.
    
    git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/contentloader@652339 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/jcr/contentloader/internal/Loader.java   |  2 +-
 .../jcr/contentloader/internal/PathEntry.java      | 28 ++++++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
index 300b2f8..7a3355c 100644
--- a/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
+++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
@@ -658,7 +658,7 @@ public class Loader {
                 bundle.getSymbolicName());
             while (pathIter.hasNext() ) {
                 final PathEntry entry = pathIter.next();
-                if ( entry.isOverwrite() ) {
+                if ( entry.isUninstall() ) {
                     this.uninstallFromPath(bundle, entry.getPath(), session.getRootNode());
                 } else {
                     log.debug("Ignoring to uninstall content at {}, overwrite flag is not set.", entry.getPath());
diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/PathEntry.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/PathEntry.java
index b9a0633..e70b561 100644
--- a/src/main/java/org/apache/sling/jcr/contentloader/internal/PathEntry.java
+++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/PathEntry.java
@@ -36,12 +36,18 @@ public class PathEntry {
     /** The overwrite flag specifying if content should be overwritten or just initially added. */
     public static final String OVERWRITE_FLAG = "overwrite";
 
+    /** The uninstall flag specifying if content should be uninstalled. */
+    public static final String UNINSTALL_FLAG = "uninstall";
+
     /** The path for the initial content. */
     private final String path;
 
     /** Should existing content be overwritten? */
     private final boolean overwrite;
 
+    /** Should existing content be uninstalled? */
+    private final boolean uninstall;
+
     public static Iterator<PathEntry> getContentPaths(final Bundle bundle) {
         final List<PathEntry> entries = new ArrayList<PathEntry>();
 
@@ -62,7 +68,8 @@ public class PathEntry {
 
     public PathEntry(String path) {
         // check for overwrite flag
-        boolean overwrite = false;
+        boolean overwriteFlag = false;
+        Boolean uninstallFlag = null;
         int flagPos = path.indexOf(";");
         if ( flagPos != -1 ) {
             final StringTokenizer flagTokenizer = new StringTokenizer(path.substring(flagPos+1), ";");
@@ -70,15 +77,24 @@ public class PathEntry {
                 final String token = flagTokenizer.nextToken();
                 int pos = token.indexOf(":=");
                 if ( pos != -1 ) {
-                    if ( token.substring(0, pos).equals(OVERWRITE_FLAG) ) {
-                        overwrite = Boolean.valueOf(token.substring(pos+2));
+                    final String name = token.substring(0, pos);
+                    final String value = token.substring(pos+2);
+                    if ( name.equals(OVERWRITE_FLAG) ) {
+                        overwriteFlag = Boolean.valueOf(value).booleanValue();
+                    } else if (name.equals(UNINSTALL_FLAG) ) {
+                        uninstallFlag = Boolean.valueOf(value);
                     }
                 }
             }
             path = path.substring(0, flagPos);
         }
         this.path = path;
-        this.overwrite = overwrite;
+        this.overwrite = overwriteFlag;
+        if ( uninstallFlag != null ) {
+            this.uninstall = uninstallFlag;
+        } else {
+            this.uninstall = this.overwrite;
+        }
     }
 
     public String getPath() {
@@ -88,4 +104,8 @@ public class PathEntry {
     public boolean isOverwrite() {
         return this.overwrite;
     }
+
+    public boolean isUninstall() {
+        return this.uninstall;
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.