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 7e66f243ea2c2e78798383eb939dfb48399a6d5d
Author: Justin Edelson <[email protected]>
AuthorDate: Tue Feb 9 01:29:19 2010 +0000

    SLING-1359 - updating contentloader bundle to use Undefined instead of 
String as the default property type
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentloader@907872 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../internal/DefaultContentCreator.java            |  6 ++-
 .../contentloader/internal/readers/JsonReader.java | 54 +++++++++++-----------
 .../jcr/contentloader/internal/JsonReaderTest.java | 20 ++++----
 3 files changed, 42 insertions(+), 38 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
 
b/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
index 2cf70aa..d9efe3a 100644
--- 
a/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
+++ 
b/src/main/java/org/apache/sling/jcr/contentloader/internal/DefaultContentCreator.java
@@ -333,7 +333,11 @@ public class DefaultContentCreator implements 
ContentCreator {
               node.setProperty(name, value, propertyType);
             }
         } else {
-            node.setProperty(name, value, propertyType);
+            if (propertyType == PropertyType.UNDEFINED) {
+                node.setProperty(name, value);
+            } else {
+                node.setProperty(name, value, propertyType);
+            }
         }
     }
 
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 a357d42..1e65518 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
@@ -42,39 +42,39 @@ import 
org.apache.sling.jcr.contentloader.internal.ImportProvider;
  * 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 
+ *       # 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. 
+ *
+ *       # 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;,
@@ -84,7 +84,7 @@ import 
org.apache.sling.jcr.contentloader.internal.ImportProvider;
  *         }
  *     }
  *   }
- * 
+ *
  * </pre>
  */
 public class JsonReader implements ContentReader {
@@ -104,7 +104,7 @@ public class JsonReader implements ContentReader {
         ignoredNames.add("jcr:checkedOut");
         ignoredNames.add("jcr:created");
     }
-    
+
     private static final Set<String> ignoredPrincipalPropertyNames = new 
HashSet<String>();
     static {
        ignoredPrincipalPropertyNames.add("name");
@@ -239,7 +239,7 @@ public class JsonReader implements ContentReader {
         }
 
         // fall back to default
-        return PropertyType.STRING;
+        return PropertyType.UNDEFINED;
     }
 
     protected String getName(String name) {
@@ -278,8 +278,8 @@ public class JsonReader implements ContentReader {
 
         return new String(bos.toByteArray(), encoding);
     }
-    
-    
+
+
     /**
      * Create or update one or more user and/or groups
      * <code>
@@ -313,7 +313,7 @@ public class JsonReader implements ContentReader {
                }
        }
     }
-    
+
     /**
      * Create or update a user or group
      */
@@ -349,11 +349,11 @@ public class JsonReader implements ContentReader {
                contentCreator.createUser(name, password, extraProps);
        }
     }
-    
+
     /**
      * Create or update one or more access control entries for the current
      * node.
-     * 
+     *
      *  <code>
      *  {
      *   "security:acl" : [
@@ -372,8 +372,8 @@ public class JsonReader implements ContentReader {
      *                 "jcr:read",
      *                 "jcr:write"
      *                 ]
-     *         }   
-     *   ]   
+     *         }
+     *   ]
      *  }
      *  </code>
      */
@@ -395,14 +395,14 @@ public class JsonReader implements ContentReader {
                }
        }
     }
-   
+
     /**
      * Create or update an access control entry
      */
     protected void createAce(JSONObject ace, ContentCreator contentCreator)
     throws JSONException, RepositoryException {
                String principalID = ace.getString("principal");
-               
+
                String [] grantedPrivileges = null;
                JSONArray granted = ace.optJSONArray("granted");
                if (granted != null) {
@@ -420,9 +420,9 @@ public class JsonReader implements ContentReader {
                                deniedPrivileges[a] = denied.getString(a);
                        }
                }
-               
+
                //do the work.
                contentCreator.createAce(principalID, grantedPrivileges, 
deniedPrivileges);
-    }   
-   
+    }
+
 }
diff --git 
a/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java 
b/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java
index e7916d1..ad90a46 100644
--- 
a/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java
+++ 
b/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java
@@ -127,7 +127,7 @@ public class JsonReaderTest {
 
         this.mockery.checking(new Expectations() {{
             allowing(creator).createNode(null, null, null); 
inSequence(mySequence);
-            allowing(creator).createProperty("property", PropertyType.STRING, 
""); inSequence(mySequence);
+            allowing(creator).createProperty("property", 
PropertyType.UNDEFINED, ""); inSequence(mySequence);
             allowing(creator).finishNode(); inSequence(mySequence);
         }});
         this.parse(json);
@@ -138,7 +138,7 @@ public class JsonReaderTest {
 
         this.mockery.checking(new Expectations() {{
             allowing(creator).createNode(null, null, null); 
inSequence(mySequence);
-            allowing(creator).createProperty("p1", PropertyType.STRING, "v1"); 
inSequence(mySequence);
+            allowing(creator).createProperty("p1", PropertyType.UNDEFINED, 
"v1"); inSequence(mySequence);
             allowing(creator).finishNode(); inSequence(mySequence);
         }});
         this.parse(json);
@@ -160,8 +160,8 @@ public class JsonReaderTest {
 
         this.mockery.checking(new Expectations() {{
             allowing(creator).createNode(null, null, null); 
inSequence(mySequence);
-            allowing(creator).createProperty("p1", PropertyType.STRING, "v1"); 
inSequence(mySequence);
-            allowing(creator).createProperty("p2", PropertyType.STRING, "v2"); 
inSequence(mySequence);
+            allowing(creator).createProperty("p1", PropertyType.UNDEFINED, 
"v1"); inSequence(mySequence);
+            allowing(creator).createProperty("p2", PropertyType.UNDEFINED, 
"v2"); inSequence(mySequence);
             allowing(creator).finishNode(); inSequence(mySequence);
         }});
         this.parse(json);
@@ -172,7 +172,7 @@ public class JsonReaderTest {
 
         this.mockery.checking(new Expectations() {{
             allowing(creator).createNode(null, null, null); 
inSequence(mySequence);
-            allowing(creator).createProperty("p1", PropertyType.STRING, new 
String[] {"v1"}); inSequence(mySequence);
+            allowing(creator).createProperty("p1", PropertyType.UNDEFINED, new 
String[] {"v1"}); inSequence(mySequence);
             allowing(creator).finishNode(); inSequence(mySequence);
         }});
         this.parse(json);
@@ -253,14 +253,14 @@ public class JsonReaderTest {
         this.mockery.checking(new Expectations() {{
             allowing(creator).createNode(null, null, null); 
inSequence(mySequence);
             allowing(creator).createNode("c1", null, null); 
inSequence(mySequence);
-            allowing(creator).createProperty("c1p1", PropertyType.STRING, 
"v1");
+            allowing(creator).createProperty("c1p1", PropertyType.UNDEFINED, 
"v1");
             allowing(creator).finishNode(); inSequence(mySequence);
             allowing(creator).finishNode(); inSequence(mySequence);
         }});
         this.parse(json);
     }
-    
-    
+
+
     @org.junit.Test public void testCreateAcl() throws Exception {
        String json = " { " +
                        "\"security:acl\" : [ " +
@@ -279,10 +279,10 @@ public class JsonReaderTest {
                        "    \"denied\" : [\"jcr:write\"]" +
                        "  }" +
                        "]" +
-                       "}";    
+                       "}";
         this.mockery.checking(new Expectations() {{
                allowing(creator).createNode(null, null, null); 
inSequence(mySequence);
-            
+
             allowing(creator).createAce("username1",new 
String[]{"jcr:read","jcr:write"},new String[]{}); inSequence(mySequence);
             allowing(creator).createAce("groupname1",new 
String[]{"jcr:read","jcr:write"},null); inSequence(mySequence);
             allowing(creator).createAce("groupname2",new 
String[]{"jcr:read"},new String[]{"jcr:write"}); inSequence(mySequence);

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to