Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B923E108F4 for ; Mon, 6 May 2013 18:35:05 +0000 (UTC) Received: (qmail 50443 invoked by uid 500); 6 May 2013 18:35:05 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 50390 invoked by uid 500); 6 May 2013 18:35:05 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 50383 invoked by uid 99); 6 May 2013 18:35:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 May 2013 18:35:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 May 2013 18:35:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4071F238896F; Mon, 6 May 2013 18:34:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1479667 - /sling/trunk/contrib/extensions/collection/src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionManagerImpl.java Date: Mon, 06 May 2013 18:34:44 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130506183444.4071F238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 ResourceCollectionManger 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 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(); } - // 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} */