Expand my Community achievements bar.

SOLVED

Assets in collections

Avatar

Level 2

I am trying to get all assets inside a  collection how to do that .

1 Accepted Solution

Avatar

Correct answer by
Level 5

Resource Collection API will be used to retrieve the assets in a Collection. For reference

Resource resource = resourceResolver

            .getResource("yourpath");

    if (null != resource) {

        log.debug("resource path is {}", resource.getPath());

        ResourceCollection resourceCollection = resource.adaptTo(ResourceCollection.class);

        if (null != resourceCollection) {

            Iterator<Resource> resourceIterator = resourceCollection.getResources();

            while (resourceIterator.hasNext()) {

                Resource damResource = resourceIterator.next();

                log.debug("damResource path is {}", damResource.getPath());

                imagePaths.add(damResource.getPath());

            }

        }

    }

View solution in original post

2 Replies

Avatar

Level 3

Hi Scott!

Please go through adobe helpx documentations.

Here is the link which expalins adding assets to a collection.

https://helpx.adobe.com/in/experience-manager/6-5/assets/using/managing-collections-touch-ui.html#Ad...

Best,

Cal

Avatar

Correct answer by
Level 5

Resource Collection API will be used to retrieve the assets in a Collection. For reference

Resource resource = resourceResolver

            .getResource("yourpath");

    if (null != resource) {

        log.debug("resource path is {}", resource.getPath());

        ResourceCollection resourceCollection = resource.adaptTo(ResourceCollection.class);

        if (null != resourceCollection) {

            Iterator<Resource> resourceIterator = resourceCollection.getResources();

            while (resourceIterator.hasNext()) {

                Resource damResource = resourceIterator.next();

                log.debug("damResource path is {}", damResource.getPath());

                imagePaths.add(damResource.getPath());

            }

        }

    }