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);
}
}
}
}
}
}
}
Aggregations