use of com.day.cq.wcm.api.PageFilter in project acs-aem-commons by Adobe-Consulting-Services.
the class SiteMapServlet method doGet.
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
response.setContentType(request.getResponseContentType());
if (StringUtils.isNotEmpty(this.characterEncoding)) {
response.setCharacterEncoding(characterEncoding);
}
ResourceResolver resourceResolver = request.getResourceResolver();
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Page page = pageManager.getContainingPage(request.getResource());
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
try {
XMLStreamWriter stream = outputFactory.createXMLStreamWriter(response.getWriter());
stream.writeStartDocument("1.0");
stream.writeStartElement("", "urlset", NS);
stream.writeNamespace("", NS);
// first do the current page
write(page, stream, resourceResolver);
for (Iterator<Page> children = page.listChildren(new PageFilter(false, true), true); children.hasNext(); ) {
write(children.next(), stream, resourceResolver);
}
if (damAssetTypes.size() > 0 && damAssetProperty.length() > 0) {
for (Resource assetFolder : getAssetFolders(page, resourceResolver)) {
writeAssets(stream, assetFolder, resourceResolver);
}
}
stream.writeEndElement();
stream.writeEndDocument();
} catch (XMLStreamException e) {
throw new IOException(e);
}
}
use of com.day.cq.wcm.api.PageFilter in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class LanguageNavigationImpl method getItems.
private List<NavigationItem> getItems(Page root) {
List<NavigationItem> pages = new ArrayList<>();
if (root.getDepth() < structureDepth) {
Iterator<Page> it = root.listChildren(new PageFilter());
while (it.hasNext()) {
Page page = it.next();
boolean active = currentPage.getPath().equals(page.getPath()) || currentPage.getPath().startsWith(page.getPath() + "/");
String title = page.getNavigationTitle();
if (title == null) {
title = page.getTitle();
}
List<NavigationItem> children = getItems(page);
int level = page.getDepth() - startLevel;
Page localizedPage = getLocalizedPage(currentPage, page);
if (localizedPage != null) {
page = localizedPage;
}
boolean current = currentPage.getPath().equals(page.getPath());
pages.add(newLanguageNavigationItem(page, active, current, linkHandler, level, children, title, getId(), component));
}
}
return pages;
}
Aggregations