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 "nt:unstructured"
+ * "jcr:primaryType":"sling:ScriptedComponent",
+ * # optional mixin node types as array
+ * "jcr:mixinTypes": [ ],
+ *
+ *
+ * # "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",
+ *
+ * # path propertie start with jcr:path
+ * "jcr:path:sampleReference": "/test/path",
+ *
+ * # nested nodes are added as nested maps.
+ * "sling:scripts": {
+ *
+ * "jcr:primaryType": "sling:ScriptList",
+ * "script1" :{
+ * "primaryNodeType": "sling:Script",
+ * "sling:name": "/test/content/jsp/start.jsp",
+ * "sling:type": "jsp",
+ * "sling:glob": "*"
+ * }
+ * }
+ * }
+ *
+ * </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>
+ * <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>
* or
- * <values>
- * <value/> for multi value properties
- * </values>
- * <type>propType</type>
- * </property>
- * <!-- more properties -->
- * </properties>
- * <nodes>
- * <!-- child nodes -->
- * <node>
+ * <values>
+ * <value/> for multi value properties
+ * </values>
+ * <type>propType</type>
+ * </property>
+ * <!-- more properties -->
+ * </properties>
+ * <nodes>
+ * <!-- child nodes -->
+ * <node>
* ..
- * </node>
- * </nodes>
- * </node>
+ * </node>
+ * </nodes>
+ * </node>
+ * </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": "*"
+ }
+ }
}