You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2008/02/08 09:14:59 UTC

svn commit: r619800 - /incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java

Author: fmeschbe
Date: Fri Feb  8 00:14:59 2008
New Revision: 619800

URL: http://svn.apache.org/viewvc?rev=619800&view=rev
Log:
Prevent reinstallation of system/document view imports if already existsing

Modified:
    incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java

Modified: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java?rev=619800&r1=619799&r2=619800&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java Fri Feb  8 00:14:59 2008
@@ -214,7 +214,10 @@
                 String name = this.getName(base);
 
                 Node node = null;
-                URL nodeDescriptor = bundle.getEntry(base + EXT_XML);
+                URL nodeDescriptor = bundle.getEntry(base + EXT_JCR_XML);
+                if (nodeDescriptor == null) {
+                    nodeDescriptor = bundle.getEntry(base + EXT_XML);
+                }
                 if (nodeDescriptor == null) {
                     nodeDescriptor = bundle.getEntry(base + EXT_JSON);
                 }
@@ -280,18 +283,18 @@
         InputStream ins = null;
         try {
             NodeReader nodeReader;
-            if (nodeXML.getPath().toLowerCase().endsWith(EXT_XML)) {
-                // return immediately if system/document view import succeeds
-                Node childNode = importSystemView(parent, name, nodeXML);
-                if (childNode != null) {
-                    return childNode;
-                }
+            if (nodeXML.getPath().toLowerCase().endsWith(EXT_JCR_XML)) {
+                return importSystemView(parent, name, nodeXML);
                 
+            } else if (nodeXML.getPath().toLowerCase().endsWith(EXT_XML)) {
                 nodeReader = this.getXmlReader();
+                
             } else if (nodeXML.getPath().toLowerCase().endsWith(EXT_JSON)) {
                 nodeReader = this.getJsonReader();
+                
             } else if (nodeXML.getPath().toLowerCase().endsWith(EXT_XJSON)) {
                 nodeReader = this.getXJsonReader();
+                
             } else {
                 // cannot find out the type
                 return null;
@@ -575,20 +578,23 @@
     private Node importSystemView(Node parent, String name, URL nodeXML)
             throws IOException {
 
-        // only consider ".jcr.xml" files here
-        if (!nodeXML.getPath().toLowerCase().endsWith(EXT_JCR_XML)) {
-            return null;
-        }
-
         InputStream ins = null;
         try {
 
+            // check whether we have the content already, nothing to do then
+            name = toPlainName(name);
+            if (parent.hasNode(name)) {
+                log.debug(
+                    "importSystemView: Node {} for XML {} already exists, nothing to to",
+                    name, nodeXML);
+                return parent.getNode(name);
+            }
+            
             ins = nodeXML.openStream();
             Session session = parent.getSession();
             session.importXML(parent.getPath(), ins, IMPORT_UUID_CREATE_NEW);
 
             // additionally check whether the expected child node exists
-            name = toPlainName(name);
             return (parent.hasNode(name)) ? parent.getNode(name) : null;
 
         } catch (InvalidSerializedDataException isde) {