Search in sources :

Example 1 with TagManager

use of com.day.cq.tagging.TagManager in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ListImpl method populateTagListItems.

private void populateTagListItems() {
    listItems = new ArrayList<>();
    String[] tags = properties.get(PN_TAGS, new String[0]);
    boolean matchAny = properties.get(PN_TAGS_MATCH, TAGS_MATCH_ANY_VALUE).equals(TAGS_MATCH_ANY_VALUE);
    if (ArrayUtils.isNotEmpty(tags)) {
        Page rootPage = getRootPage(PN_TAGS_PARENT_PAGE);
        if (rootPage != null) {
            TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
            if (tagManager != null) {
                RangeIterator<Resource> resourceRangeIterator = tagManager.find(rootPage.getPath(), tags, matchAny);
                if (resourceRangeIterator != null) {
                    while (resourceRangeIterator.hasNext()) {
                        Page containingPage = pageManager.getContainingPage(resourceRangeIterator.next());
                        if (containingPage != null) {
                            listItems.add(containingPage);
                        }
                    }
                }
            }
        }
    }
}
Also used : TagManager(com.day.cq.tagging.TagManager) Resource(org.apache.sling.api.resource.Resource) Page(com.day.cq.wcm.api.Page)

Aggregations

TagManager (com.day.cq.tagging.TagManager)1 Page (com.day.cq.wcm.api.Page)1 Resource (org.apache.sling.api.resource.Resource)1