incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r956170 - in /sling/trunk: bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/ launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ launchpad/test-services/src/main/re...
Date Sat, 19 Jun 2010 01:32:16 GMT
Author: justin
Date: Sat Jun 19 01:32:15 2010
New Revision: 956170

URL: http://svn.apache.org/viewvc?rev=956170&view=rev
Log:
SLING-1561 - changing destination of ROOT descriptor if path is specified in manifest entry

Added:
    sling/trunk/launchpad/test-services/src/main/resources/SLING-INF/content/ROOT.json
Modified:
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/InitialContentTest.java

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java?rev=956170&r1=956169&r2=956170&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
Sat Jun 19 01:32:15 2010
@@ -73,11 +73,11 @@ public class DefaultContentCreator imple
     private final Map<String, List<String>> delayedReferences = new HashMap<String,
List<String>>();
     private final Map<String, String[]> delayedMultipleReferences = new HashMap<String,
String[]>();
 
-    private String defaultRootName;
+    private String defaultName;
 
-    private Node rootNode;
+    private Node createdRootNode;
 
-    private boolean isRootNodeImport;
+    private boolean isParentNodeImport;
 
     private boolean ignoreOverwriteFlag = false;
 
@@ -135,17 +135,17 @@ public class DefaultContentCreator imple
 
     /**
      *
-     * If the defaultRootName is null, we are in ROOT_NODE import mode.
+     * If the defaultName is null, we are in PARENT_NODE import mode.
      * @param parentNode
-     * @param defaultRootName
+     * @param defaultName
      */
     public void prepareParsing(final Node parentNode,
-                               final String defaultRootName) {
+                               final String defaultName) {
         this.parentNodeStack.clear();
         this.parentNodeStack.push(parentNode);
-        this.defaultRootName = defaultRootName;
-        this.rootNode = null;
-        isRootNodeImport = defaultRootName == null;
+        this.defaultName = defaultName;
+        isParentNodeImport = defaultName == null;
+        this.createdRootNode = null;
     }
 
     /**
@@ -173,8 +173,8 @@ public class DefaultContentCreator imple
     /**
      * Get the created root node.
      */
-    public Node getRootNode() {
-        return this.rootNode;
+    public Node getCreatedRootNode() {
+        return this.createdRootNode;
     }
 
     /**
@@ -231,11 +231,11 @@ public class DefaultContentCreator imple
             if ( this.parentNodeStack.size() > 1 ) {
                 throw new RepositoryException("Node needs to have a name.");
             }
-            name = this.defaultRootName;
+            name = this.defaultName;
         }
 
-        // if we are in root node import mode, we don't create the root top level node!
-        if ( !isRootNodeImport || this.parentNodeStack.size() > 1 ) {
+        // if we are in parent node import mode, we don't create the root top level node!
+        if ( !isParentNodeImport || this.parentNodeStack.size() > 1 ) {
             // if node already exists but should be overwritten, delete it
             if (!this.ignoreOverwriteFlag && this.configuration.isOverwrite() &&
parentNode.hasNode(name)) {
                 parentNode.getNode(name).remove();
@@ -281,8 +281,8 @@ public class DefaultContentCreator imple
             }
 
             this.parentNodeStack.push(node);
-            if ( this.rootNode == null ) {
-                this.rootNode = node;
+            if ( this.createdRootNode == null ) {
+                this.createdRootNode = node;
             }
         }
     }

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java?rev=956170&r1=956169&r2=956170&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
(original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/Loader.java
Sat Jun 19 01:32:15 2010
@@ -392,11 +392,10 @@ public class Loader {
             return;
         }
 
-        // potential root node import/extension
-        URL rootNodeDescriptor = importRootNode(parent.getSession(), bundle, path);
-        if (rootNodeDescriptor != null) {
-            processedEntries.put(rootNodeDescriptor,
-                parent.getSession().getRootNode());
+        // potential parent node import/extension
+        URL parentNodeDescriptor = importParentNode(parent.getSession(), bundle, path, parent);
+        if (parentNodeDescriptor != null) {
+            processedEntries.put(parentNodeDescriptor, parent);
         }
 
         while (entries.hasMoreElements()) {
@@ -549,7 +548,7 @@ public class Loader {
             this.contentCreator.prepareParsing(parent, toPlainName(name));
             nodeReader.parse(resourceUrl, this.contentCreator);
 
-            return this.contentCreator.getRootNode();
+            return this.contentCreator.getCreatedRootNode();
         } catch (RepositoryException re) {
             throw re;
         } catch (Throwable t) {
@@ -807,9 +806,9 @@ public class Loader {
 
     /**
      * Imports mixin nodes and properties (and optionally child nodes) of the
-     * root node.
+     * parent node.
      */
-    private URL importRootNode(Session session, Bundle bundle, String path)
+    private URL importParentNode(Session session, Bundle bundle, String path, Node parent)
     throws RepositoryException {
         final Descriptor descriptor = getRootNodeDescriptor(bundle, path);
         // no root descriptor found
@@ -818,7 +817,7 @@ public class Loader {
         }
 
         try {
-            this.contentCreator.prepareParsing(session.getRootNode(), null);
+            this.contentCreator.prepareParsing(parent, null);
             descriptor.nodeReader.parse(descriptor.rootNodeDescriptor, this.contentCreator);
 
             return descriptor.rootNodeDescriptor;

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/InitialContentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/InitialContentTest.java?rev=956170&r1=956169&r2=956170&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/InitialContentTest.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/InitialContentTest.java
Sat Jun 19 01:32:15 2010
@@ -26,24 +26,31 @@ public class InitialContentTest extends 
         final String content = getContent(HTTP_BASE_URL + "/index.html", CONTENT_TYPE_HTML);
         assertTrue("Content contains expected marker (" + content + ")",content.contains(expected));
     }
-    
+
     public void testRootRedirectProperty() throws IOException {
     	final String expected = "\"sling:resourceType\":\"sling:redirect\"";
     	final String content = getContent(HTTP_BASE_URL + "/.json", CONTENT_TYPE_JSON);
     	assertTrue("Content contains " + expected + " (" + content + ")", content.contains(expected));
     }
-    
+
     public void testInitialContentA() throws IOException {
     	final String expected = "42";
     	final String content = getContent(
     			HTTP_BASE_URL + "/sling-test/sling/initial-content-test/marker.txt", CONTENT_TYPE_PLAIN);
     	assertTrue("Content contains " + expected + " (" + content + ")", content.contains(expected));
     }
-    
+
     public void testInitialContentB() throws IOException {
     	final String expected = "46";
     	final String content = getContent(
     			HTTP_BASE_URL + "/sling-test/initial-content-folder/folder-content-test/marker.txt",
CONTENT_TYPE_PLAIN);
     	assertTrue("Content contains " + expected + " (" + content + ")", content.contains(expected));
     }
+
+    public void testInitialContentInSubNodeRoot() throws IOException {
+        final String expected = "\"testProperty\":\"value\"";
+        final String content = getContent(
+                HTTP_BASE_URL + "/sling-test.json", CONTENT_TYPE_JSON);
+        assertTrue("Content contains " + expected + " (" + content + ")", content.contains(expected));
+    }
 }

Added: sling/trunk/launchpad/test-services/src/main/resources/SLING-INF/content/ROOT.json
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/resources/SLING-INF/content/ROOT.json?rev=956170&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/resources/SLING-INF/content/ROOT.json (added)
+++ sling/trunk/launchpad/test-services/src/main/resources/SLING-INF/content/ROOT.json Sat
Jun 19 01:32:15 2010
@@ -0,0 +1,3 @@
+{
+	"testProperty" : "value"
+}
\ No newline at end of file



Mime
View raw message