You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ie...@apache.org on 2009/07/16 14:21:30 UTC

svn commit: r794650 - in /sling/trunk: bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/ samples/simple-demo/src/main/resources/SLING-INF/content/sample/

Author: ieb
Date: Thu Jul 16 12:21:30 2009
New Revision: 794650

URL: http://svn.apache.org/viewvc?rev=794650&view=rev
Log:
SLING-971
    Patch applied (from myself)
    Corrects the Java doc and readme surrounding the contentloader, especially for the json format.

Modified:
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java
    sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/sample/sample_readme.txt

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java?rev=794650&r1=794649&r2=794650&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java (original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java Thu Jul 16 12:21:30 2009
@@ -37,9 +37,54 @@
 import org.apache.sling.jcr.contentloader.internal.ContentReader;
 import org.apache.sling.jcr.contentloader.internal.ImportProvider;
 
-
 /**
- * The <code>JsonReader</code> TODO
+ * The <code>JsonReader</code> Parses a Json document on content load and creates the
+ * corresponding node structure with properties. Will not update protected nodes and
+ * properties like rep:Policy and children.
+ * 
+ * <pre>
+ * Nodes, Properties and in fact complete subtrees may be described in JSON files
+ * using the following skeleton structure (see http://www.json.org for information
+ * on the syntax of JSON) :
+ * 
+ * # the name of the node is taken from the name of the file without the .json ext.
+ *   {
+ *   
+ *     # optional primary node type, default &quot;nt:unstructured&quot;
+ *     &quot;jcr:primaryType&quot;:&quot;sling:ScriptedComponent&quot;,
+ *     # optional mixin node types as array
+ *     &quot;jcr:mixinTypes&quot;: [ ],
+ *     
+ *       
+ *       # &quot;properties&quot; are added as key value pairs, the name of the key being the name
+ *       # of the property. The value is either the string property value, array for 
+ *       # multi-values or an object whose value[s] property denotes the property 
+ *       # value(s) and whose type property denotes the property type
+ *       &quot;sling:contentClass&quot;: &quot;com.day.sling.jcr.test.Test&quot;,
+ *       &quot;sampleMulti&quot;: [ &quot;v1&quot;, &quot;v2&quot; ],
+ *       &quot;sampleStruct&quot;: 1,
+ *       &quot;sampleStructMulti&quot;: [ 1, 2, 3 ],
+ *       
+ *       # reference properties start with jcr:reference
+ *       &quot;jcr:reference:sampleReference&quot;: &quot;/test/content&quot;,
+ *       
+ *       # path propertie start with jcr:path
+ *       &quot;jcr:path:sampleReference&quot;: &quot;/test/path&quot;,
+ *         
+ *       # nested nodes are added as nested maps. 
+ *     &quot;sling:scripts&quot;:  {
+ *               
+ *         &quot;jcr:primaryType&quot;: &quot;sling:ScriptList&quot;,
+ *         &quot;script1&quot; :{
+ *             &quot;primaryNodeType&quot;: &quot;sling:Script&quot;,
+ *               &quot;sling:name&quot;: &quot;/test/content/jsp/start.jsp&quot;,
+ *             &quot;sling:type&quot;: &quot;jsp&quot;,
+ *             &quot;sling:glob&quot;: &quot;*&quot;
+ *         }
+ *     }
+ *   }
+ * 
+ * </pre>
  */
 public class JsonReader implements ContentReader {
 

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java?rev=794650&r1=794649&r2=794650&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java (original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java Thu Jul 16 12:21:30 2009
@@ -50,34 +50,37 @@
 import org.xmlpull.v1.XmlPullParserException;
 
 /**
- * This reader reads an xml file defining the content.
- * The xml format should have this format:
- * <node>
- *   <name>the name of the node</name>
- *   <primaryNodeType>type</primaryNodeType>
- *   <mixinNodeTypes>
- *     <mixinNodeType>mixtype1</mixinNodeType>
- *     <mixinNodeType>mixtype2</mixinNodeType>
- *   </mixingNodeTypes>
- *   <properties>
- *     <property>
- *       <name>propName</name>
- *       <value>propValue</value>
+ * This reader reads an xml file defining the content. The xml format should have this
+ * format:
+ * 
+ * <pre>
+ * &lt;node&gt;
+ *   &lt;name&gt;the name of the node&lt;/name&gt;
+ *   &lt;primaryNodeType&gt;type&lt;/primaryNodeType&gt;
+ *   &lt;mixinNodeTypes&gt;
+ *     &lt;mixinNodeType&gt;mixtype1&lt;/mixinNodeType&gt;
+ *     &lt;mixinNodeType&gt;mixtype2&lt;/mixinNodeType&gt;
+ *   &lt;/mixingNodeTypes&gt;
+ *   &lt;properties&gt;
+ *     &lt;property&gt;
+ *       &lt;name&gt;propName&lt;/name&gt;
+ *       &lt;value&gt;propValue&lt;/value&gt;
  *           or
- *       <values>
- *         <value/> for multi value properties
- *       </values>
- *       <type>propType</type>
- *     </property>
- *     <!-- more properties -->
- *   </properties>
- *   <nodes>
- *     <!-- child nodes -->
- *     <node>
+ *       &lt;values&gt;
+ *         &lt;value/&gt; for multi value properties
+ *       &lt;/values&gt;
+ *       &lt;type&gt;propType&lt;/type&gt;
+ *     &lt;/property&gt;
+ *     &lt;!-- more properties --&gt;
+ *   &lt;/properties&gt;
+ *   &lt;nodes&gt;
+ *     &lt;!-- child nodes --&gt;
+ *     &lt;node&gt;
  *       ..
- *     </node>
- *   </nodes>
- * </node>
+ *     &lt;/node&gt;
+ *   &lt;/nodes&gt;
+ * &lt;/node&gt;
+ * </pre>
  */
 public class XmlReader implements ContentReader {
 

Modified: sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/sample/sample_readme.txt
URL: http://svn.apache.org/viewvc/sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/sample/sample_readme.txt?rev=794650&r1=794649&r2=794650&view=diff
==============================================================================
--- sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/sample/sample_readme.txt (original)
+++ sling/trunk/samples/simple-demo/src/main/resources/SLING-INF/content/sample/sample_readme.txt Thu Jul 16 12:21:30 2009
@@ -105,52 +105,39 @@
 using the following skeleton structure (see http://www.json.org for information
 on the syntax of JSON) :
 
+# the name of the node is taken from the name of the file without the .json ext.
 	{
-		// optional node name on top level, default is file name without .json ext.
-		"name": "nodename",
+	
+		# optional primary node type, default "nt:unstructured"
+		"jcr:primaryType":"sling:ScriptedComponent",
+		# optional mixin node types as array
+		"jcr:mixinTypes": [ ],
 		
-		// optional primary node type, default "nt:unstructured"
-		"primaryNodeType": "sling:ScriptedComponent",
-		
-		// optional mixin node types as array
-		"mixinNodeTypes": [ ],
 	    
-	    // the "properties" property is an object indexed by property name whose
-	    // value is either the string property value, array for multi-values or
-	    // an object whose value[s] property denotes the property value(s) and
-	    // whose type property denotes the property type
-	    "properties": {
-	    	"sling:contentClass": "com.day.sling.jcr.test.Test",
-	    	"sampleMulti": [ "v1", "v2" ],
-	    	"sampleStruct": {
-	    		"value": 1,
-	    		"type": "Long"
-	    	}
-	    	"sampleStructMulti": {
-	    		"value": [ 1, 2, 3 ],
-	    		"type": "Long"
-	    	}
-	    },
+	    # "properties" are added as key value pairs, the name of the key being the name
+	    # of the property. The value is either the string property value, array for 
+	    # multi-values or an object whose value[s] property denotes the property 
+	    # value(s) and whose type property denotes the property type
+	    "sling:contentClass": "com.day.sling.jcr.test.Test",
+	    "sampleMulti": [ "v1", "v2" ],
+	    "sampleStruct": 1,
+	    "sampleStructMulti": [ 1, 2, 3 ],
+	    
+	    # reference properties start with jcr:reference
+	    "jcr:reference:sampleReference": "/test/content",
 	    
-	    // the "nodes" property is an array of objects denoting child nodes. Nodes
-	    // may be further nested.
-		"nodes": [
-			{
-				// the name property is required on (nested) child nodes
-	            "name": "sling:scripts",
+	    # path propertie start with jcr:path
+	    "jcr:path:sampleReference": "/test/path",
+	    	
+	    # nested nodes are added as nested maps. 
+		"sling:scripts":	{
 	            
-				"primaryNodeType": "sling:ScriptList",
-				
-				"nodes": [
-					{
+				"jcr:primaryType": "sling:ScriptList",
+				"script1" :{
 						"primaryNodeType": "sling:Script",
-						"properties": {
-							"sling:name": "/test/content/jsp/start.jsp",
-							"sling:type": "jsp",
-							"sling:glob": "*"
-						}
-					}
-				]
-			}
-		]
+					    "sling:name": "/test/content/jsp/start.jsp",
+						"sling:type": "jsp",
+						"sling:glob": "*"
+				}
+		}
 	}