You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/05/06 20:34:44 UTC

svn commit: r1479667 - /sling/trunk/contrib/extensions/collection/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java

Author: cziegeler
Date: Mon May  6 18:34:43 2013
New Revision: 1479667

URL: http://svn.apache.org/r1479667
Log:
Revert wrong change from revision 1479549

Modified:
    sling/trunk/contrib/extensions/collection/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java

Modified: sling/trunk/contrib/extensions/collection/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/collection/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java?rev=1479667&r1=1479666&r2=1479667&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/collection/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java (original)
+++ sling/trunk/contrib/extensions/collection/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java Mon May  6 18:34:43 2013
@@ -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 ResourceCollectionManagerIm
     	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 ResourceCollectionManagerIm
      */
     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 ResourceCollectionManagerIm
                 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 ResourceCollectionManagerIm
 
     /**
      * {@inheritDoc}
-     *
+     * 
      * @throws PersistenceException
      */
     public boolean deleteCollection(Resource resource)
@@ -121,7 +127,7 @@ public class ResourceCollectionManagerIm
     		throw new IllegalArgumentException("resource can not be null");
     	}
     }
-
+    
     /**
      * {@inheritDoc}
      */