use of com.adobe.cq.wcm.core.components.config.HtmlPageItemConfig in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class PageImpl method getHtmlPageItems.
@Override
@NotNull
public List<HtmlPageItem> getHtmlPageItems() {
if (htmlPageItems == null) {
htmlPageItems = new LinkedList<>();
ConfigurationBuilder configurationBuilder = configurationResolver.get(resource);
HtmlPageItemsConfig config = configurationBuilder.as(HtmlPageItemsConfig.class);
for (HtmlPageItemConfig itemConfig : config.items()) {
HtmlPageItem item = new HtmlPageItemImpl(StringUtils.defaultString(config.prefixPath()), itemConfig);
if (item.getElement() != null) {
htmlPageItems.add(item);
}
}
// Support the former node structure: see com.adobe.cq.wcm.core.components.config.HtmlPageItemsConfig
if (htmlPageItems.isEmpty()) {
Resource configResource = configurationResourceResolver.getResource(resource, "sling:configs", HtmlPageItemsConfig.class.getName());
if (configResource != null) {
ValueMap properties = configResource.getValueMap();
for (Resource child : configResource.getChildren()) {
HtmlPageItem item = new HtmlPageItemImpl(properties.get(HtmlPageItemsConfig.PN_PREFIX_PATH, StringUtils.EMPTY), child);
if (item.getElement() != null) {
htmlPageItems.add(item);
}
}
}
}
}
return htmlPageItems;
}
Aggregations