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:47:16 UTC

[sling-org-apache-sling-jcr-contentloader] 13/36: SLING-971 Patch applied (from myself) Corrects the Java doc and readme surrounding the contentloader, especially for the json format.

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.6
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git

commit d003a8a5e834a5ceedf46c00e65b8367df356f62
Author: Ian Boston <ie...@apache.org>
AuthorDate: Thu Jul 16 12:21:30 2009 +0000

    SLING-971
        Patch applied (from myself)
        Corrects the Java doc and readme surrounding the contentloader, especially for the json format.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentloader@794650 13f79535-47bb-0310-9956-ffa450edef68
---
 .../contentloader/internal/readers/JsonReader.java | 49 ++++++++++++++++++-
 .../contentloader/internal/readers/XmlReader.java  | 55 ++++++++++++----------
 2 files changed, 76 insertions(+), 28 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java
index 75a9802..8a2ee2e 100644
--- a/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java
+++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java
@@ -37,9 +37,54 @@ import org.apache.sling.jcr.contentloader.internal.ContentCreator;
 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 {
 
diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java
index 6b6fcaf..39a69a8 100644
--- a/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java
+++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/XmlReader.java
@@ -50,34 +50,37 @@ import org.xmlpull.v1.XmlPullParser;
 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 {
 

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