//logger.info("slotId:" + id);
//logger.info("component:" + component);
//logger.info("getInheritedComponents with " + component.getName() + ":" + component.getSlotName() + ":" + component.getId());
List inheritedComponents = new ArrayList();
NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(templateController.getSiteNodeId(), templateController.getLanguageId(), templateController.getContentId());
Iterator slotIterator = component.getSlotList().iterator();
while(slotIterator.hasNext())
{
Slot slot = (Slot)slotIterator.next();
//logger.info("Slot for component " + component.getName() + ":" + slot.getId());
//logger.info("Slot for component " + id + ":" + slot.getId() + ":" + slot.getName());
if(slot.getId().equalsIgnoreCase(id))
{
Iterator subComponentIterator = slot.getComponents().iterator();
while(subComponentIterator.hasNext())
{
InfoGlueComponent infoGlueComponent = (InfoGlueComponent)subComponentIterator.next();
//logger.info("Adding not inherited component " + infoGlueComponent.getName() + " to list...");
inheritedComponents.add(infoGlueComponent);
}
}
}
SiteNodeVO parentSiteNodeVO = nodeDeliveryController.getParentSiteNode(db, siteNodeId);
boolean restrictAll = false;
Iterator restrictionsIterator = component.getRestrictions().iterator();
while(restrictionsIterator.hasNext())
{
ComponentRestriction restriction = (ComponentRestriction)restrictionsIterator.next();
if(restriction.getType().equalsIgnoreCase("blockComponents"))
{
if(restriction.getSlotId().equalsIgnoreCase(id) && restriction.getArguments().equalsIgnoreCase("*"))
{
restrictAll = true;
}
}
}
while(inheritedComponents.size() == 0 && parentSiteNodeVO != null && inherit && !restrictAll)
{
//logger.info("INHERITING COMPONENTS");
String componentXML = this.getPageComponentsString(db, templateController, parentSiteNodeVO.getId(), templateController.getLanguageId(), component.getContentId());
//logger.info("componentXML:" + componentXML);
//logger.info("id:" + id);
String key = "" + parentSiteNodeVO.getId() + "_" + componentXML.hashCode();
//String mapKey = "" + parentSiteNodeVO.getId() + "_" + componentXML.hashCode() + "_" + id + "_components"; //
String mapKey = "" + parentSiteNodeVO.getId() + "_" + componentXML.hashCode() + "_" + id + "_" + siteNodeId + "_" + component.getId() + "_components";
Map components = (Map)CacheController.getCachedObjectFromAdvancedCache("componentPropertyCache", mapKey);
if(components == null)
{
Timer t = new Timer();
//DOM4j
/*
Document document = domBuilder.getDocument(componentXML);
components = getComponentWithDOM4j(db, document.getRootElement(), id, templateController, component);
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("INHERITING COMPONENTS WITH DOM4J", t.getElapsedTime());
*/
//XPP3
XmlInfosetBuilder builder = XmlInfosetBuilder.newInstance();
XmlDocument doc = builder.parseReader(new StringReader( componentXML ) );
components = getComponentWithXPP3(db, builder, doc.getDocumentElement(), id, templateController, component);
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("INHERITING COMPONENTS WITH XPP3", t.getElapsedTime());
//System.out.println("components:" + components);
String hashCode = "" + components.get(id + "_hashCode");
String path = "" + components.get(id + "_xpath");
templateController.getDeliveryContext().addUsedContent("content_" + parentSiteNodeVO.getMetaInfoContentId() + "_ComponentStructureDependency");
templateController.getDeliveryContext().addUsedContent("content_" + parentSiteNodeVO.getMetaInfoContentId() + "_ComponentStructure:" + path + "=" + hashCode);
//logger.info("components:" + components);
if(components != null)
CacheController.cacheObjectInAdvancedCache("componentPropertyCache", mapKey, components, null, false);
}
//logger.info("components:" + components.size());
//logger.info("id:" + id);
if(components.containsKey(id))
{
inheritedComponents = (List)components.get(id);
//logger.info("inheritedComponents:" + inheritedComponents);
Iterator inheritedComponentIterator = inheritedComponents.iterator();
while(inheritedComponentIterator.hasNext())
{
InfoGlueComponent infoGlueComponent = (InfoGlueComponent)inheritedComponentIterator.next();
infoGlueComponent.setIsInherited(true);
}
}
parentSiteNodeVO = nodeDeliveryController.getParentSiteNode(db, parentSiteNodeVO.getId());
}
return inheritedComponents;
}