org.apache.sling.resource.collection

## Interface ResourceCollectionManager

    @ProviderType
    public interface ResourceCollectionManager

The `ResourceCollectionManager` defines the API to get, create and delete resource collections `ResourceCollection`. The ResourceCollectionManager service can be retrieved by looking it up from the service registry or by adapting a `ResourceResolver`.

### Method Summary

All Methods Instance Methods Abstract Methods
`ResourceCollection` `createCollection(org.apache.sling.api.resource.Resource parentResource, String name)` This method creates a resource collection with a given name under the `parentResource`.
`ResourceCollection` `createCollection(org.apache.sling.api.resource.Resource parentResource, String name, Map<String,Object> properties)` This method creates a resource collection with a given name under the `parentResource`.
`boolean` `deleteCollection(org.apache.sling.api.resource.Resource resource)` Removes the `ResourceCollection` corresponding to the collection represented by `resource`.
`ResourceCollection` `getCollection(org.apache.sling.api.resource.Resource resource)` This method returns a resource collection for the given `resource` that represents a `ResourceCollection`.

### Method Detail

#### getCollection

    ResourceCollection getCollection(org.apache.sling.api.resource.Resource resource)

This method returns a resource collection for the given `resource` that represents a `ResourceCollection`. It returns null if given resource is not a collection

Parameters:
  `resource` - resource that represents a collection
Returns:
  The `ResourceCollection` representing the collection.

#### createCollection

    ResourceCollection createCollection(org.apache.sling.api.resource.Resource parentResource,
                                        String name)
                                 throws org.apache.sling.api.resource.PersistenceException

This method creates a resource collection with a given name under the `parentResource`. The changes are transient and have to be saved by resourceResolver.commit()

Parameters:
  `parentResource` - parent resource where collection needs to be created.
  `name` - The name for collection.
Returns:
  The `ResourceCollection` representing the created collection.
Throws:
  `org.apache.sling.api.resource.PersistenceException` - if the operation fails

#### createCollection

    ResourceCollection createCollection(org.apache.sling.api.resource.Resource parentResource,
                                        String name,
                                        Map<String,Object> properties)
                                 throws org.apache.sling.api.resource.PersistenceException

This method creates a resource collection with a given name under the `parentResource`. The changes are transient and have to be saved by resourceResolver.commit()

Parameters:
  `parentResource` - parent resource where collection needs to be created.
  `name` - The name for collection.
  `properties` - The additional data for resource collection
Returns:
  The `ResourceCollection` representing the created collection.
Throws:
  `org.apache.sling.api.resource.PersistenceException` - if the operation fails

#### deleteCollection

    boolean deleteCollection(org.apache.sling.api.resource.Resource resource)
                      throws org.apache.sling.api.resource.PersistenceException

Removes the `ResourceCollection` corresponding to the collection represented by `resource`. The changes are transient and have to be saved by resourceResolver.commit()

Parameters:
  `resource` - resource representing a collection to be deleted.
Returns:
  `true` if the collection was successfully removed.
Throws:
  `org.apache.sling.api.resource.PersistenceException` - if the operation fails