This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag 
org.apache.sling.resourcecollection-1.0.0
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcecollection.git

commit 0b5a4e2b9b47a2b99c11c1077ff43cfdc48fbea1
Author: Carsten Ziegeler <cziege...@apache.org>
AuthorDate: Mon May 6 18:34:43 2013 +0000

    Revert wrong change from revision 1479549
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/collection@1479667
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../impl/ResourceCollectionManagerImpl.java        | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java
 
b/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java
index 66acdb7..450bc7c 100755
--- 
a/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java
+++ 
b/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java
@@ -25,13 +25,14 @@ import java.util.Map;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.jcr.resource.JcrResourceConstants;
 import org.apache.sling.resource.collection.ResourceCollection;
 import org.apache.sling.resource.collection.ResourceCollectionManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- *
+ * 
  * Implements <code>ResourceCollectionManger</code> interface. And provides
  * create, delete, get apis for ResourceCollection.
  *
@@ -54,11 +55,11 @@ public class ResourceCollectionManagerImpl implements 
ResourceCollectionManager
        if (resource != null) {
                if (resource.isResourceType(ResourceCollection.RESOURCE_TYPE)) {
                 return new ResourceCollectionImpl(resource);
-            }
+            } 
        } else {
                throw new IllegalArgumentException("resource can not be null");
        }
-
+       
        return null;
     }
 
@@ -75,7 +76,7 @@ public class ResourceCollectionManagerImpl implements 
ResourceCollectionManager
      */
     public ResourceCollection createCollection(Resource parentResource, String 
name,
             Map<String, Object> properties) throws PersistenceException {
-
+        
         if (parentResource != null) {
                String fullPath = parentResource.getPath() + name;
 
@@ -83,16 +84,21 @@ public class ResourceCollectionManagerImpl implements 
ResourceCollectionManager
                 throw new IllegalArgumentException("invalid path, " + fullPath
                     + "resource already exists");
             }
-
+            
             if (properties == null) {
                 properties = new HashMap<String, Object>();
             }
 
-            // make sure correct resource type is used
-            properties.put(
-                    ResourceResolver.PROPERTY_RESOURCE_TYPE,
+            if 
(properties.get(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY) != null
+                && 
!ResourceCollection.RESOURCE_TYPE.equals(properties.get(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY)))
 {
+                properties.put(
+                    JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY,
                     ResourceCollection.RESOURCE_TYPE);
-
+            } else {
+                properties.put(
+                    JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY,
+                    ResourceCollection.RESOURCE_TYPE);
+            }
             Resource collectionRes = resolver.create(parentResource, name, 
properties);
             resolver.create(collectionRes, "members", null);
             log.debug("collection  {} created", fullPath);
@@ -108,7 +114,7 @@ public class ResourceCollectionManagerImpl implements 
ResourceCollectionManager
 
     /**
      * {@inheritDoc}
-     *
+     * 
      * @throws PersistenceException
      */
     public boolean deleteCollection(Resource resource)
@@ -121,7 +127,7 @@ public class ResourceCollectionManagerImpl implements 
ResourceCollectionManager
                throw new IllegalArgumentException("resource can not be null");
        }
     }
-
+    
     /**
      * {@inheritDoc}
      */

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

Reply via email to