Assets in collections | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Umesh_Sondhi

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());

            }

        }

    }

2 replies

cal-netsolution
Level 2
September 23, 2019

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#Addingassetstoacollection

Best,

Cal

Umesh_Sondhi
Umesh_SondhiAccepted solution
Level 4
September 23, 2019

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());

            }

        }

    }