private HstSiteMapItem getCanonicalItem(List<HstSiteMapItem> matchedHstSiteMapItema) { List<HstSiteMapItemService> canonicals = new ArrayList<>(); for(HstSiteMapItem item : matchedHstSiteMapItema) { HstSiteMapItemService serviceItem = (HstSiteMapItemService)item; if(serviceItem.isUseableInRightContextOnly()) { // unusable for canonical continue; } canonicals.add(serviceItem); } if(!canonicals.isEmpty()) { // even if multiple canonicals are equally suited, we cannot do better then pick the first Collections.sort(canonicals, new LowestDepthFirstAndThenLexicalComparator()); return canonicals.get(0); } return null; }
private HstSiteMapItem getCanonicalItem(List<HstSiteMapItem> matchedHstSiteMapItema) { List<HstSiteMapItem> canonicals = new ArrayList<HstSiteMapItem>(); int lowestDepth = Integer.MAX_VALUE; for(HstSiteMapItem item : matchedHstSiteMapItema) { HstSiteMapItemService serviceItem = (HstSiteMapItemService)item; if(serviceItem.isUseableInRightContextOnly()) { // unuseable for canonical continue; } if(serviceItem.getDepth() < lowestDepth) { lowestDepth = serviceItem.getDepth(); canonicals.clear(); canonicals.add(serviceItem); } else if (serviceItem.getDepth() == lowestDepth) { canonicals.add(serviceItem); } } if(!canonicals.isEmpty()) { // even if multiple canonicals are equally suited, we cannot do better then pick the first return canonicals.get(0); } return null; }
private HstSiteMapItem contextualize(HstSiteMapItemService matchedHstSiteMapItem) { if(matchedHstSiteMapItem.isUseableInRightContextOnly()) { boolean mergeable = mergeMatchedItemWithCurrentCtx(matchedHstSiteMapItem); // if not succeeded, return null if(!mergeable) { log.debug("Cannot contextualize hstSiteMapItem '{}' for current sitemap item '{}'", matchedHstSiteMapItem.getId(), this.resolvedSiteMapItem.getHstSiteMapItem().getId()); return null; } return matchedHstSiteMapItem; } else { return matchedHstSiteMapItem; } }
private HstSiteMapItem contextualize(final HstSiteMapItemService matchedHstSiteMapItem, final Map<String,String> propertyPlaceHolderMap) { if (matchedHstSiteMapItem.isUseableInRightContextOnly()) { boolean mergeable = mergeMatchedItemWithCurrentCtx(matchedHstSiteMapItem, propertyPlaceHolderMap); // if not succeeded, return null if(!mergeable) { log.debug("Cannot contextualize hstSiteMapItem '{}' for current sitemap item '{}'", matchedHstSiteMapItem.getId(), this.resolvedSiteMapItem.getHstSiteMapItem().getId()); return null; } return matchedHstSiteMapItem; } else { return matchedHstSiteMapItem; } }