//logger.info("key:" + key);
String componentXPath = "component[@name='" + slotName + "']";
//logger.info("componentXPath:" + componentXPath);
Xb1XPath xpathObject = (Xb1XPath)cachedXPathObjects.get(componentXPath);
if(xpathObject == null)
{
xpathObject = new Xb1XPath( componentXPath );
cachedXPathObjects.put(componentXPath, xpathObject);
}
List anl = xpathObject.selectNodes( element );
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("XPP3 selectNodes size:" + anl.size(), t.getElapsedTime());
//logger.info("anl:" + anl.size());
//logger.info("componentElements:" + componentElements.size());
Iterator componentIterator = anl.iterator();
int slotPosition = 0;
while(componentIterator.hasNext())
{
XmlElement componentElement = (XmlElement)componentIterator.next();
Integer id = new Integer(componentElement.getAttributeValue(componentElement.getNamespaceName(), "id"));
Integer contentId = new Integer(componentElement.getAttributeValue(componentElement.getNamespaceName(), "contentId"));
String name = componentElement.getAttributeValue(componentElement.getNamespaceName(), "name");
String isInherited = componentElement.getAttributeValue(componentElement.getNamespaceName(), "isInherited");
String pagePartTemplateContentId = componentElement.getAttributeValue(componentElement.getNamespaceName(), "pagePartTemplateContentId");
String isPagePartRef = componentElement.getAttributeValue(componentElement.getNamespaceName(), "isPagePartReference");
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("XPP 1 took", t.getElapsedTime());
try
{
ContentVO contentVO = ContentDeliveryController.getContentDeliveryController().getContentVO(db, contentId, templateController.getDeliveryContext());
//logger.info("slotName:" + slotName + " should get connected with content_" + contentVO.getId());
groups = new String[]{CacheController.getPooledString(1, contentVO.getId())};
InfoGlueComponent component = new InfoGlueComponent();
component.setPositionInSlot(new Integer(slotPosition));
component.setId(id);
component.setContentId(contentId);
component.setName(contentVO.getName());
component.setSlotName(name);
component.setParentComponent(parentComponent);
if(isInherited != null && isInherited.equals("true"))
component.setIsInherited(true);
else if(parentComponent != null)
component.setIsInherited(parentComponent.getIsInherited());
if(pagePartTemplateContentId != null && !pagePartTemplateContentId.equals("") && !pagePartTemplateContentId.equals("-1"))
{
Integer pptContentId = new Integer(pagePartTemplateContentId);
ContentVO pptContentIdContentVO = ContentDeliveryController.getContentDeliveryController().getContentVO(db, pptContentId, templateController.getDeliveryContext());
InfoGlueComponent partTemplateReferenceComponent = new InfoGlueComponent();
partTemplateReferenceComponent.setPositionInSlot(new Integer(slotPosition));
partTemplateReferenceComponent.setId(id);
partTemplateReferenceComponent.setContentId(pptContentId);
partTemplateReferenceComponent.setName(pptContentIdContentVO.getName());
partTemplateReferenceComponent.setSlotName(name);
partTemplateReferenceComponent.setParentComponent(parentComponent);
partTemplateReferenceComponent.setIsInherited(true);
component.setPagePartTemplateContentId(pptContentId);
component.setPagePartTemplateComponent(partTemplateReferenceComponent);
}
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("3 took", t.getElapsedTime());
Xb1XPath xpathObject3 = (Xb1XPath)cachedXPathObjects.get("properties");
if(xpathObject3 == null)
{
xpathObject3 = new Xb1XPath("properties");
cachedXPathObjects.put("properties", xpathObject3);
}
List propertiesNodeList = xpathObject3.selectNodes( componentElement );
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("XPP3 propertiesNodeList:" + propertiesNodeList.size(), t.getElapsedTime());
//logger.info("XPP3 componentElement:" + componentElement);
if(propertiesNodeList.size() > 0)
{
XmlElement propertiesElement = (XmlElement)propertiesNodeList.get(0);
Xb1XPath xpathObject4 = (Xb1XPath)cachedXPathObjects.get("property");
if(xpathObject4 == null)
{
xpathObject4 = new Xb1XPath("property");
cachedXPathObjects.put("property", xpathObject4);
}
List propertyNodeList = xpathObject4.selectNodes( propertiesElement );
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("XPP3 propertyNodeList:" + propertyNodeList.size(), t.getElapsedTime());
Iterator propertyNodeListIterator = propertyNodeList.iterator();
while(propertyNodeListIterator.hasNext())
{
XmlElement propertyElement = (XmlElement)propertyNodeListIterator.next();
String propertyName = propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "name");
String type = propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "type");
String path = propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path");
if(path == null)
{
LanguageVO langaugeVO = LanguageDeliveryController.getLanguageDeliveryController().getMasterLanguageForSiteNode(getDatabase(), templateController.getSiteNodeId());
if(propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path_" + langaugeVO.getLanguageCode()) != null)
path = propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path_" + langaugeVO.getLanguageCode());
}
if(propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path_" + locale.getLanguage()) != null)
path = propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path_" + locale.getLanguage());
if(path == null || path.equals(""))
{
logger.info("Falling back to content master language 1 for property:" + propertyName);
LanguageVO contentMasterLangaugeVO = LanguageDeliveryController.getLanguageDeliveryController().getMasterLanguageForRepository(getDatabase(), contentVO.getRepositoryId());
if(propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path_" + contentMasterLangaugeVO.getLanguageCode()) != null)
path = propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path_" + contentMasterLangaugeVO.getLanguageCode());
}
Map property = new HashMap();
property.put("name", propertyName);
property.put("path", path);
property.put("type", type);
property.put("isPagePartReference", (isPagePartRef == null ? "false" : isPagePartRef));
Iterator attributesIterator = propertyElement.attributes();
while(attributesIterator.hasNext())
{
XmlAttribute attribute = (XmlAttribute)attributesIterator.next();
if(attribute.getName().startsWith("path_"))
property.put(attribute.getName(), attribute.getValue());
}
if(path != null)
{
if(propertyName.equals(InfoGlueComponent.CACHE_RESULT_PROPERTYNAME) && (path.equalsIgnoreCase("true") || path.equalsIgnoreCase("yes")))
{
component.setCacheResult(true);
}
if(propertyName.equals(InfoGlueComponent.UPDATE_INTERVAL_PROPERTYNAME) && !path.equals(""))
{
try { component.setUpdateInterval(Integer.parseInt(path)); } catch (Exception e) { logger.warn("The component " + component.getName() + " " + InfoGlueComponent.UPDATE_INTERVAL_PROPERTYNAME + " with a faulty value on page " + this.getTemplateController().getOriginalFullURL() + ":" + e.getMessage()); }
}
if(propertyName.equals(InfoGlueComponent.CACHE_KEY_PROPERTYNAME) && !path.equals(""))
{
component.setCacheKey(path);
}
if(propertyName.equals(InfoGlueComponent.PREPROCESSING_ORDER_PROPERTYNAME) && !path.equals(""))
{
component.setPreProcessingOrder(path);
}
}
List<ComponentBinding> bindings = new ArrayList<ComponentBinding>();
Xb1XPath xpathObject5 = (Xb1XPath)cachedXPathObjects.get("binding");
if(xpathObject5 == null)
{
xpathObject5 = new Xb1XPath("binding");
cachedXPathObjects.put("binding", xpathObject5);
}
List bindingNodeList = xpathObject5.selectNodes( propertyElement );
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("XPP3 bindingNodeList:" + bindingNodeList.size(), t.getElapsedTime());
Iterator bindingNodeListIterator = bindingNodeList.iterator();
while(bindingNodeListIterator.hasNext())
{
XmlElement bindingElement = (XmlElement)bindingNodeListIterator.next();
String entity = bindingElement.getAttributeValue(bindingElement.getNamespaceName(), "entity");
String entityId = bindingElement.getAttributeValue(bindingElement.getNamespaceName(), "entityId");
String assetKey = bindingElement.getAttributeValue(bindingElement.getNamespaceName(), "assetKey");
XmlElement supplementingBindingElement = bindingElement.element(bindingElement.getNamespace(), "supplementing-binding");
ComponentBinding componentBinding;
if (supplementingBindingElement == null)
{
componentBinding = new ComponentBinding();
}
else
{
String supplementingEntityIdString = null;
try
{
supplementingEntityIdString = supplementingBindingElement.getAttributeValue(supplementingBindingElement.getNamespaceName(), "entityId");
Integer supplementingEntityId = null;
if (supplementingEntityIdString != null && !supplementingEntityIdString.equals(""))
{
supplementingEntityId = new Integer(supplementingEntityIdString);
}
String supplementingAssetKey = supplementingBindingElement.getAttributeValue(supplementingBindingElement.getNamespaceName(), "assetKey");
supplementingAssetKey = StringEscapeUtils.unescapeXml(supplementingAssetKey);
componentBinding = new SupplementedComponentBinding(supplementingEntityId, supplementingAssetKey);
}
catch (NumberFormatException ex)
{
logger.error("Could not make Integer from supplementing entity id [id: " + supplementingEntityIdString + "]. Will ignore it!. Property name: " + propertyName);
componentBinding = new ComponentBinding();
}
}
//componentBinding.setId(new Integer(id));
//componentBinding.setComponentId(componentId);
componentBinding.setEntityClass(entity);
componentBinding.setEntityId(new Integer(entityId));
componentBinding.setAssetKey(assetKey);
componentBinding.setBindingPath(path);
bindings.add(componentBinding);
}
property.put("bindings", bindings);
component.getProperties().put(propertyName, property);
}
}
getComponentRestrictionsWithXPP3(componentElement, component, locale, templateController);
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getComponentRestrictions", t.getElapsedTime());
//Getting slots for the component
try
{
String componentString = this.getComponentString(templateController, contentId, component);
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getComponentString", t.getElapsedTime());
int offset = 0;
int slotStartIndex = componentString.indexOf("<ig:slot", offset);
while(slotStartIndex > -1)
{
int slotStopIndex = componentString.indexOf("</ig:slot>", slotStartIndex);
String slotString = componentString.substring(slotStartIndex, slotStopIndex + 10);
String slotId = slotString.substring(slotString.indexOf("id") + 4, slotString.indexOf("\"", slotString.indexOf("id") + 4));
boolean inherit = true;
int inheritIndex = slotString.indexOf("inherit");
if(inheritIndex > -1)
{
String inheritString = slotString.substring(inheritIndex + 9, slotString.indexOf("\"", inheritIndex + 9));
inherit = Boolean.parseBoolean(inheritString);
}
boolean disableAccessControl = false;
int disableAccessControlIndex = slotString.indexOf("disableAccessControl");
if(disableAccessControlIndex > -1)
{
String disableAccessControlString = slotString.substring(disableAccessControlIndex + "disableAccessControl".length() + 2, slotString.indexOf("\"", disableAccessControlIndex + "disableAccessControl".length() + 2));
disableAccessControl = Boolean.parseBoolean(disableAccessControlString);
}
String[] allowedComponentNamesArray = null;
int allowedComponentNamesIndex = slotString.indexOf(" allowedComponentNames");
if(allowedComponentNamesIndex > -1)
{
String allowedComponentNames = slotString.substring(allowedComponentNamesIndex + 24, slotString.indexOf("\"", allowedComponentNamesIndex + 24));
allowedComponentNamesArray = allowedComponentNames.split(",");
}
String[] disallowedComponentNamesArray = null;
int disallowedComponentNamesIndex = slotString.indexOf(" disallowedComponentNames");
if(disallowedComponentNamesIndex > -1)
{
String disallowedComponentNames = slotString.substring(disallowedComponentNamesIndex + 27, slotString.indexOf("\"", disallowedComponentNamesIndex + 27));
disallowedComponentNamesArray = disallowedComponentNames.split(",");
}
String[] allowedComponentGroupNamesArray = null;
int allowedComponentGroupNamesIndex = slotString.indexOf(" allowedComponentGroupNames");
if(allowedComponentGroupNamesIndex > -1)
{
String allowedComponentGroupNames = slotString.substring(allowedComponentGroupNamesIndex + 29, slotString.indexOf("\"", allowedComponentGroupNamesIndex + 29));
allowedComponentGroupNamesArray = allowedComponentGroupNames.split(",");
}
String addComponentText = null;
int addComponentTextIndex = slotString.indexOf("addComponentText");
if(addComponentTextIndex > -1)
{
addComponentText = slotString.substring(addComponentTextIndex + "addComponentText".length() + 2, slotString.indexOf("\"", addComponentTextIndex + "addComponentText".length() + 2));
}
String addComponentLinkHTML = null;
int addComponentLinkHTMLIndex = slotString.indexOf("addComponentLinkHTML");
if(addComponentLinkHTMLIndex > -1)
{
addComponentLinkHTML = slotString.substring(addComponentLinkHTMLIndex + "addComponentLinkHTML".length() + 2, slotString.indexOf("\"", addComponentLinkHTMLIndex + "addComponentLinkHTML".length() + 2));
}
int allowedNumberOfComponentsInt = -1;
int allowedNumberOfComponentsIndex = slotString.indexOf("allowedNumberOfComponents");
if(allowedNumberOfComponentsIndex > -1)
{
String allowedNumberOfComponents = slotString.substring(allowedNumberOfComponentsIndex + "allowedNumberOfComponents".length() + 2, slotString.indexOf("\"", allowedNumberOfComponentsIndex + "allowedNumberOfComponents".length() + 2));
try
{
allowedNumberOfComponentsInt = new Integer(allowedNumberOfComponents);
}
catch (Exception e)
{
allowedNumberOfComponentsInt = -1;
}
}
Slot slot = new Slot();
slot.setId(slotId);
slot.setInherit(inherit);
slot.setDisableAccessControl(disableAccessControl);
slot.setAllowedComponentsArray(allowedComponentNamesArray);
slot.setDisallowedComponentsArray(disallowedComponentNamesArray);
slot.setAllowedComponentGroupsArray(allowedComponentGroupNamesArray);
slot.setAddComponentLinkHTML(addComponentLinkHTML);
slot.setAddComponentText(addComponentText);
slot.setAllowedNumberOfComponents(new Integer(allowedNumberOfComponentsInt));
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Parsing slots", t.getElapsedTime());
Xb1XPath xpathObject2 = (Xb1XPath)cachedXPathObjects.get("components");
if(xpathObject2 == null)
{
xpathObject2 = new Xb1XPath("components");
cachedXPathObjects.put("components", xpathObject2);
}
XmlElement componentsElement = (XmlElement)xpathObject2.selectSingleNode( componentElement );
//RequestAnalyser.getRequestAnalyser().registerComponentStatistics("XPP3 componentsElement:" + componentsElement, t.getElapsedTime());
//logger.info("componentsElement:" + componentsElement);
//groups = new String[]{CacheController.getPooledString(1, contentVO.getId())};