private void init(Node siteMapNode) throws RepositoryException { for(NodeIterator nodeIt = siteMapNode.getNodes(); nodeIt.hasNext();) { Node child = nodeIt.nextNode(); if(child == null) { log.warn("skipping null node"); continue; } if(child.isNodeType(HstNodeTypes.NODETYPE_HST_SITEMAPITEM)) { try { HstSiteMapItemService siteMapItemService = new HstSiteMapItemService(child, siteMapRootNodePath, siteMapItemHandlersConfiguration , null, this, 1); rootSiteMapItems.put(siteMapItemService.getValue(), siteMapItemService); } catch (ServiceException e) { if (log.isDebugEnabled()) { log.warn("Skipping root sitemap '{}'", child.getPath(), e); } else if (log.isWarnEnabled()) { log.warn("Skipping root sitemap '{}'", child.getPath()); } } } else { if (log.isWarnEnabled()) { log.warn("Skipping node '{}' because is not of type {}", child.getPath(), HstNodeTypes.NODETYPE_HST_SITEMAPITEM); } } } }
HstSiteMapItemService matchedAncestorOrSelf = matchedHstSiteMapItem; while(matchedAncestorOrSelf != null) { if(matchedAncestorOrSelf.isWildCard() || matchedAncestorOrSelf.containsWildCard() || matchedAncestorOrSelf.isAny() || matchedAncestorOrSelf.containsAny()) { matchedAncestorOrSelfWildcardList.add(0,matchedAncestorOrSelf); matchedAncestorOrSelf = (HstSiteMapItemService)matchedAncestorOrSelf.getParentItem(); HstSiteMapItemService currentAncestorOrSelf = (HstSiteMapItemService)resolvedSiteMapItem.getHstSiteMapItem(); while(currentAncestorOrSelf != null) { if(currentAncestorOrSelf.isWildCard() || currentAncestorOrSelf.containsWildCard() || currentAncestorOrSelf.isAny() || currentAncestorOrSelf.containsAny()) { currentCtxAncestorOrSeldWildcardList.add(0,currentAncestorOrSelf); currentAncestorOrSelf = (HstSiteMapItemService)currentAncestorOrSelf.getParentItem(); if(matchedHstSiteMapItem.getWildCardAnyOccurences() <= (propertiesToMerge.size() + propertyPlaceHolderMap.size())) { propertyPlaceHolderMap.putAll(propertiesToMerge); return true;
if( (s = hstSiteMapItemService.getChild(elements[position])) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(s, params, ++position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getWildCardPatternChild(elements[position], checkedSiteMapItems)) != null ) { String parameter = getStrippedParameter((HstSiteMapItemService)s, elements[position]); params.put(String.valueOf(params.size()+1), parameter); return traverseInToSiteMapItem(s, params, ++position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getChild(WILDCARD)) != null && !checkedSiteMapItems.contains(s)) { params.put(String.valueOf(params.size()+1), elements[position]); return traverseInToSiteMapItem(s, params, ++position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getAnyPatternChild(elements, position, checkedSiteMapItems)) != null ) { StringBuffer remainder = new StringBuffer(elements[position]); while(++position < elements.length) { return s; else if(hstSiteMapItemService.getChild(ANY) != null ) { StringBuffer remainder = new StringBuffer(elements[position]); while(++position < elements.length) {
@Override public int compare(final HstSiteMapItemService item1, final HstSiteMapItemService item2) { if (item1.getDepth() == item2.getDepth()) { // order lexically to force consistent result return item1.getId().compareTo(item2.getId()); } else { // item with lowest depth is best return item1.getDepth() - item2.getDepth(); } } }
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; }
while (index-- != 0) { final HstSiteMapItemService s = (HstSiteMapItemService) ancestorItems.get(index); if (s.isWildCard()) { params.put(String.valueOf(params.size() + 1), HstNodeTypes.WILDCARD); propertyOrderList.add(PropertyParser.DEFAULT_PLACEHOLDER_PREFIX + params.size() + PropertyParser.DEFAULT_PLACEHOLDER_SUFFIX); } else if (s.isAny()) { params.put(String.valueOf(params.size() + 1), HstNodeTypes.ANY); propertyOrderList.add(PropertyParser.DEFAULT_PLACEHOLDER_PREFIX + params.size() + PropertyParser.DEFAULT_PLACEHOLDER_SUFFIX); } else if (s.containsWildCard()) { String paramVal = s.getPrefix() + HstNodeTypes.WILDCARD; if (s.getPostfix().indexOf(".") > -1) { final String post = s.getPostfix().substring(0, s.getPostfix().indexOf(".")); if (!"".equals(post)) { paramVal += post; paramVal += s.getPostfix(); } else if (s.containsAny()) { String paramVal = s.getPrefix() + HstNodeTypes.ANY; if (s.getPostfix().indexOf(".") > -1) { String post = s.getPostfix().substring(0, s.getPostfix().indexOf(".")); if (!"".equals(post)) { paramVal += post; paramVal += s.getPostfix(); ((HstSiteMapItemService)siteMapItem).setKeyToPropertyPlaceHolderMap(keyToPropertyPlaceHolderMap);
this.siteMapItemHandlersConfiguration = siteMapItemHandlersConfiguration; this.depth = depth; String nodePath = getValueProvider().getPath(); if(!getValueProvider().getPath().startsWith(siteMapRootNodePath)) { this.closeValueProvider(false); throw new ServiceException("Node path of the sitemap cannot start without the global sitemap root path. Skip SiteMapItem"); this.value = getValueProvider().getName(); this.statusCode = getValueProvider().getLong(HstNodeTypes.SITEMAPITEM_PROPERTY_STATUSCODE).intValue(); this.errorCode = getValueProvider().getLong(HstNodeTypes.SITEMAPITEM_PROPERTY_ERRORCODE).intValue(); this.closeValueProvider(false); throw new ServiceException("The 'value' of a SiteMapItem is not allowed to be null. It is so for '"+nodePath+"'"); this.parameterizedPath = this.parentItem.getParameterizedPath()+"/"; this.occurences = this.parentItem.getWildCardAnyOccurences(); } else { parameterizedPath = ""; ((HstSiteMapItemService)parentItem).addWildCardPrefixedChildSiteMapItems(this); ((HstSiteMapItemService)parentItem).addAnyPrefixedChildSiteMapItems(this); String[] parameterNames = getValueProvider().getStrings(HstNodeTypes.GENERAL_PROPERTY_PARAMETER_NAMES); String[] parameterValues = getValueProvider().getStrings(HstNodeTypes.GENERAL_PROPERTY_PARAMETER_VALUES); for(Entry<String, String> parentParam : this.parentItem.getParameters().entrySet()) { if(!this.parameters.containsKey(parentParam.getKey())) {
parameterizedPath = this.parentItem.getParameterizedPath()+"/"; occurences = this.parentItem.getWildCardAnyOccurences(); } else { parameterizedPath = ""; ((HstSiteMapItemService)parentItem).addWildCardPrefixedChildSiteMapItems(this); ((HstSiteMapItemService)parentItem).addAnyPrefixedChildSiteMapItems(this); if (clonedParameterValues[i] != null && clonedParameterValues[i].contains("${")) { String resolved = (String) mountParameterParser.resolveProperty(clonedParameterNames[i], clonedParameterValues[i]); if (containsInvalidOrNonIntegerPlaceholders(resolved)) { log.warn("Invalid irreplaceable property placeholder found for parameter name '{}' with value '{}' for " + "sitemap item '{}'. Setting value for '{}' to null", new String[]{clonedParameterNames[i], clonedParameterValues[i], for(Entry<String, String> parentParam : this.parentItem.getParameters().entrySet()) { if(!parameters.containsKey(parentParam.getKey())) { parameters.put(StringPool.get(parentParam.getKey()), StringPool.get(parentParam.getValue())); if (containsInvalidOrNonIntegerPlaceholders(resolved)) { log.warn("Invalid irreplaceable property placeholder found for hst:relativecontentpath '{}' for sitemap item '{}'." + "Setting relativeContentPath to null", new String[]{relativeContentPath, canonicalPath}); if (componentConfigurationId != null && componentConfigurationId.contains("${")) { String resolved = (String) mountParameterParser.resolveProperty("componentConfigurationId", componentConfigurationId); if (containsInvalidOrNonIntegerPlaceholders(resolved)) { log.warn("Invalid irreplaceable property placeholder found for {} '{}' for sitemap item '{}'. " + "Setting relativeContentPath to null", new String[]{SITEMAPITEM_PROPERTY_COMPONENTCONFIGURATIONID,
if(service.containsWildCard() && service.patternMatch(elements[0], service.getPrefix(), service.getPostfix())) { String parameter = getStrippedParameter((HstSiteMapItemService)service, elements[0]); params.put(String.valueOf(params.size()+1), parameter); if(service.containsAny() && service.patternMatch(pathInfo, service.getPrefix(), service.getPostfix())) { String parameter = getStrippedParameter((HstSiteMapItemService)service, pathInfo); params.put(String.valueOf(params.size()+1), parameter);
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; } }
if( (s = hstSiteMapItem.getChild(WILDCARD)) != null && !checkedSiteMapItems.contains(s)){ return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getWildCardPatternChild(elements[position], checkedSiteMapItems)) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); }else if(hstSiteMapItem.getChild(ANY) != null) { return traverseInToSiteMapItem(hstSiteMapItem, params,position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getAnyPatternChild(elements, position, checkedSiteMapItems)) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItem.getChild(WILDCARD)) != null && !checkedSiteMapItems.contains(s)){ return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getWildCardPatternChild(elements[position], checkedSiteMapItems)) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else if(hstSiteMapItem.getChild(ANY) != null ){ return traverseInToSiteMapItem(hstSiteMapItem, params,position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getAnyPatternChild(elements, position, checkedSiteMapItems)) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else {
if(HstNodeTypes.NODETYPE_HST_SITEMAPITEM.equals(child.getNodeTypeName())) { try { HstSiteMapItemService siteMapItemService = new HstSiteMapItemService(child, mountSiteMapConfiguration, siteMapItemHandlersConfiguration , null, this, 1); rootSiteMapItems.put(siteMapItemService.getValue(), siteMapItemService); } catch (ModelLoadingException e) { if (log.isDebugEnabled()) { ((HstSiteMapItemService)child).optimize();
HstSiteMapItemService serv = (HstSiteMapItemService)item; if(representsDocument) { if(serv.getExtension() != null) { if(serv.getExtension() == null) {
while(index-- != 0) { HstSiteMapItemService s = (HstSiteMapItemService)ancestorItems.get(index); if(s.isWildCard()) { params.put(String.valueOf(params.size()+1), HstNodeTypes.WILDCARD); propertyOrderList.add(PropertyParser.DEFAULT_PLACEHOLDER_PREFIX + params.size() + PropertyParser.DEFAULT_PLACEHOLDER_SUFFIX); } else if(s.isAny()) { params.put(String.valueOf(params.size()+1), HstNodeTypes.ANY); propertyOrderList.add(PropertyParser.DEFAULT_PLACEHOLDER_PREFIX + params.size() + PropertyParser.DEFAULT_PLACEHOLDER_SUFFIX); } else if( s.containsWildCard() ) { String paramVal = s.getPrefix()+HstNodeTypes.WILDCARD; if(s.getPostfix().indexOf(".") > -1) { String post = s.getPostfix().substring(0,s.getPostfix().indexOf(".")); if(!"".equals(post)) { paramVal += post; paramVal += s.getPostfix(); } else if( s.containsAny() ) { String paramVal = s.getPrefix()+HstNodeTypes.ANY; if(s.getPostfix().indexOf(".") > -1) { String post = s.getPostfix().substring(0,s.getPostfix().indexOf(".")); if(!"".equals(post)) { paramVal += post; paramVal += s.getPostfix(); ((HstSiteMapItemService)hstSiteMapItem).setKeyToPropertyPlaceHolderMap(keyToPropertyPlaceHolderMap);
if(service.containsWildCard() && service.patternMatch(elements[0], service.getPrefix(), service.getPostfix())) { String parameter = getStrippedParameter(service, elements[0]); params.put(String.valueOf(params.size()+1), parameter); if(service.containsAny() && service.patternMatch(pathInfo, service.getPrefix(), service.getPostfix())) { String parameter = getStrippedParameter(service, pathInfo); params.put(String.valueOf(params.size()+1), parameter);
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; } }
if( (s = hstSiteMapItem.getChild(WILDCARD)) != null && !checkedSiteMapItems.contains(s)){ return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getWildCardPatternChild(elements[position], checkedSiteMapItems)) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); }else if(hstSiteMapItem.getChild(ANY) != null) { return traverseInToSiteMapItem(hstSiteMapItem, params,position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getAnyPatternChild(elements, position, checkedSiteMapItems)) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItem.getChild(WILDCARD)) != null && !checkedSiteMapItems.contains(s)){ return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getWildCardPatternChild(elements[position], checkedSiteMapItems)) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else if(hstSiteMapItem.getChild(ANY) != null ){ return traverseInToSiteMapItem(hstSiteMapItem, params,position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getAnyPatternChild(elements, position, checkedSiteMapItems)) != null && !checkedSiteMapItems.contains(s)) { return traverseInToSiteMapItem(hstSiteMapItem, params, position, elements, checkedSiteMapItems); } else {
HstSiteMapItemService serv = (HstSiteMapItemService)item; if(representsDocument) { if(serv.getExtension() != null) { if(serv.getExtension() == null) {
HstSiteMapItemService matchedAncestorOrSelf = (HstSiteMapItemService)matchedHstSiteMapItem; while(matchedAncestorOrSelf != null) { if(matchedAncestorOrSelf.isWildCard() || matchedAncestorOrSelf.containsWildCard() || matchedAncestorOrSelf.isAny() || matchedAncestorOrSelf.containsAny()) { matchedAncestorOrSelfWildcardList.add(0,matchedAncestorOrSelf); matchedAncestorOrSelf = (HstSiteMapItemService)matchedAncestorOrSelf.getParentItem(); HstSiteMapItemService currentAncestorOrSelf = (HstSiteMapItemService)this.resolvedSiteMapItem.getHstSiteMapItem(); while(currentAncestorOrSelf != null) { if(currentAncestorOrSelf.isWildCard() || currentAncestorOrSelf.containsWildCard() || currentAncestorOrSelf.isAny() || currentAncestorOrSelf.containsAny()) { currentCtxAncestorOrSeldWildcardList.add(0,currentAncestorOrSelf); currentAncestorOrSelf = (HstSiteMapItemService)currentAncestorOrSelf.getParentItem(); if(matchedHstSiteMapItem.getWildCardAnyOccurences() <= (propertiesToMerge.size() + propertyPlaceHolderMap.size())) { log.debug("Succeful contextualized matched sitemap item"); propertyPlaceHolderMap.putAll(propertiesToMerge);
if( (s = hstSiteMapItemService.getChild(elements[position])) != null && !checkedSiteMapItems.contains(s) && !s.isMarkedDeleted()) { if (s.isAny() || s.isWildCard()) { } else if( (s = hstSiteMapItemService.getWildCardPatternChild(elements[position], checkedSiteMapItems)) != null && !s.isMarkedDeleted()) { String parameter = getStrippedParameter((HstSiteMapItemService)s, elements[position]); params.put(String.valueOf(params.size()+1), parameter); return traverseInToSiteMapItem(s, params, ++position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getChild(WILDCARD)) != null && !checkedSiteMapItems.contains(s) && !s.isMarkedDeleted()) { params.put(String.valueOf(params.size()+1), elements[position]); return traverseInToSiteMapItem(s, params, ++position, elements, checkedSiteMapItems); } else if( (s = hstSiteMapItemService.getAnyPatternChild(elements, position, checkedSiteMapItems)) != null && !s.isMarkedDeleted()) { StringBuffer remainder = new StringBuffer(elements[position]); while(++position < elements.length) { return s; else if(hstSiteMapItemService.getChild(ANY) != null && !hstSiteMapItemService.getChild(ANY).isMarkedDeleted()) { StringBuffer remainder = new StringBuffer(elements[position]); while(++position < elements.length) {