Examples of Xb1XPath


Examples of org.xmlpull.v1.builder.xpath.Xb1XPath

    String propertyXPath = "//component[@id=" + componentId + "]/properties/property[@name='" + propertyName + "']";
   
    if(propertyName.equals("GUFlashImages") || propertyName.equals("MiniArticleShortcuts"))
      this.templateController.getDeliveryContext().addDebugInformation("DEBUG INFO propertyXPath: " + propertyXPath + " (Thread" + Thread.currentThread().getId() + ").\n");

    Xb1XPath xpathObject = (Xb1XPath)cachedXPathObjects.get(propertyXPath);
        if(xpathObject == null)
        {
          xpathObject = new Xb1XPath( propertyXPath );
          cachedXPathObjects.put(propertyXPath, xpathObject);
        }

        List anl = xpathObject.selectNodes( doc );

    //If not found on the same component id - let's check them all and use the first we find.
    if(anl == null || anl.size() == 0)
    {
      String globalPropertyXPath = "(//component/properties/property[@name='" + propertyName + "'])[1]";
      if(propertyName.equals("GUFlashImages") || propertyName.equals("MiniArticleShortcuts"))
        this.templateController.getDeliveryContext().addDebugInformation("DEBUG INFO globalPropertyXPath: " + globalPropertyXPath + " (Thread" + Thread.currentThread().getId() + ").\n");
     
      Xb1XPath globalXpathObject = new Xb1XPath( globalPropertyXPath );
          anl = globalXpathObject.selectNodes( doc );
    }     

    Iterator anlIterator = anl.iterator();
    while(anlIterator.hasNext())
    {
      XmlElement infosetItem = (XmlElement)anlIterator.next();

      String name    = infosetItem.getAttributeValue(infosetItem.getNamespaceName(), "name");
      String type    = infosetItem.getAttributeValue(infosetItem.getNamespaceName(), "type");
      String entity   = infosetItem.getAttributeValue(infosetItem.getNamespaceName(), "entity");
      String componentContentId = null;
      boolean isMultipleBinding = new Boolean(infosetItem.getAttributeValue(infosetItem.getNamespaceName(), "multiple")).booleanValue();

      XmlElement parent = (XmlElement)infosetItem.getParent();
      if(parent != null)
      {
        XmlElement component = (XmlElement)parent.getParent();
        if(component != null)
        {
          componentContentId = component.getAttributeValue(infosetItem.getNamespaceName(), "contentId");
        }
      }
     
      String value = null;
     
      if(type.equalsIgnoreCase("textfield") || type.equalsIgnoreCase("textarea") || type.equalsIgnoreCase("select"))
      {
          value = infosetItem.getAttributeValue(infosetItem.getNamespaceName(), "path");

          Locale locale = LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithId(templateController.getDatabase(), languageId);
        Locale masterLocale = LanguageDeliveryController.getLanguageDeliveryController().getMasterLanguageForSiteNode(templateController.getDatabase(), siteNodeId).getLocale();
       
          if(infosetItem.attribute("path_" + locale.getLanguage()) != null)
            value = infosetItem.getAttributeValue(infosetItem.getNamespaceName(), "path_" + locale.getLanguage());

          if((value == null || value.equals("")) && infosetItem.attribute("path_" + masterLocale.getLanguage()) != null)
              value = infosetItem.getAttributeValue(infosetItem.getNamespaceName(), "path_" + masterLocale.getLanguage());
         
        if(value != null)
          value = value.replaceAll("igbr", separator);
      }
      else
      {
        Locale locale = LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithId(templateController.getDatabase(), languageId);

        String componentXPath = "//component[@id=" + componentId + "]/properties/property[@name='" + name + "']";

        Xb1XPath globalXpathObject = new Xb1XPath( componentXPath );
        List propertyNL = globalXpathObject.selectNodes( doc );

        Iterator propertyNLIterator = propertyNL.iterator();
        while(propertyNLIterator.hasNext())
        {
          XmlElement propertyElement2 = (XmlElement)propertyNLIterator.next();
View Full Code Here

Examples of org.xmlpull.v1.builder.xpath.Xb1XPath

        XmlInfosetBuilder builder = XmlInfosetBuilder.newInstance();
        XmlDocument doc = builder.parseReader(new StringReader( inheritedPageComponentsXML ) );
       
    String propertyXPath = "//component[@id=" + componentId + "]/properties/property[@name='" + propertyName + "']";
   
    Xb1XPath xpathObject = (Xb1XPath)cachedXPathObjects.get(propertyXPath);
        if(xpathObject == null)
        {
          xpathObject = new Xb1XPath( propertyXPath );
          cachedXPathObjects.put(propertyXPath, xpathObject);
        }

        List anl = xpathObject.selectNodes( doc );

    //If not found on the same component id - let's check them all and use the first we find.
    if(anl == null || anl.size() == 0)
    {
      String globalPropertyXPath = "(//component/properties/property[@name='" + propertyName + "'])[1]";
     
      Xb1XPath globalXpathObject = new Xb1XPath( globalPropertyXPath );
          anl = globalXpathObject.selectNodes( doc );
    }     

    StringBuilder sb = new StringBuilder();
   
    Iterator anlIterator = anl.iterator();
View Full Code Here

Examples of org.xmlpull.v1.builder.xpath.Xb1XPath

        XmlInfosetBuilder builder = XmlInfosetBuilder.newInstance();
        XmlDocument doc = builder.parseReader(new StringReader( inheritedPageComponentsXML ) );
       
    String propertyXPath = "//component[@id=" + componentId + "]/properties/property[@name='" + propertyName + "']";
   
    Xb1XPath xpathObject = new Xb1XPath( propertyXPath );

        List anl = xpathObject.selectNodes( doc );

    //If not found on the same component id - let's check them all and use the first we find.
    if(anl == null || anl.size() == 0)
    {
      String globalPropertyXPath = "(//component/properties/property[@name='" + propertyName + "'])[1]";
     
      Xb1XPath globalXpathObject = new Xb1XPath( globalPropertyXPath );
          anl = globalXpathObject.selectNodes( doc );
    }     

    StringBuilder sb = new StringBuilder();
   
    Iterator anlIterator = anl.iterator();
View Full Code Here

Examples of org.xmlpull.v1.builder.xpath.Xb1XPath

  public static int getComponentsAsStringHashCode(String inheritedPageComponentsXML, String componentXPath) throws Exception
  {
        XmlInfosetBuilder builder = XmlInfosetBuilder.newInstance();
        XmlDocument doc = builder.parseReader(new StringReader( inheritedPageComponentsXML ) );

    Xb1XPath xpathObject = new Xb1XPath( componentXPath );

        //This keeps track of the cached inherited components.
        StringBuilder sb = new StringBuilder();
       
        List componentNodeList = xpathObject.selectNodes( doc.getDocumentElement() );
    Iterator componentNodeListIterator = componentNodeList.iterator();
    while(componentNodeListIterator.hasNext())
    {
      XmlElement child   = (XmlElement)componentNodeListIterator.next();
     
View Full Code Here

Examples of org.xmlpull.v1.builder.xpath.Xb1XPath

   
    Map components = new HashMap();
   
    String componentXPath = "component";

    Xb1XPath xpathObject = (Xb1XPath)cachedXPathObjects.get(componentXPath);
        if(xpathObject == null)
        {
          xpathObject = new Xb1XPath(componentXPath);
          cachedXPathObjects.put(componentXPath, xpathObject);
        }

        List componentNodeList = xpathObject.selectNodes( element );
    Iterator componentNodeListIterator = componentNodeList.iterator();
    while(componentNodeListIterator.hasNext())
    {
      XmlElement child   = (XmlElement)componentNodeListIterator.next();
      Integer id       = new Integer(child.getAttributeValue(child.getNamespaceName(), "id"));
      Integer contentId   = new Integer(child.getAttributeValue(child.getNamespaceName(), "contentId"));
      String name       = child.getAttributeValue(child.getNamespaceName(), "name");
      String isPagePartRef  = child.getAttributeValue(child.getNamespaceName(), "isPagePartReference");
     
      //logger.info("id 2:" + id);
      //logger.info("contentId 2:" + contentId);
      //logger.info("name 2:" + name);
     
      ContentVO contentVO = ContentDeliveryController.getContentDeliveryController().getContentVO(db, contentId, templateController.getDeliveryContext());
     
      component = new InfoGlueComponent();
      component.setId(id);
      component.setContentId(contentId);
      component.setName(contentVO.getName());
      //component.setName(name);
      component.setSlotName(name);
      component.setParentComponent(parentComponent);
      if(parentComponent != null)
        component.setIsInherited(parentComponent.getIsInherited());
       
      Xb1XPath xpathObject2 = (Xb1XPath)cachedXPathObjects.get("properties");
          if(xpathObject2 == null)
          {
            xpathObject2 = new Xb1XPath("properties");
            cachedXPathObjects.put("properties", xpathObject2);
          }

          List propertiesNodeList = xpathObject2.selectNodes( child );
      if(propertiesNodeList.size() > 0)
      {
        XmlElement propertiesElement = (XmlElement)propertiesNodeList.get(0);
       
        Xb1XPath xpathObject3 = (Xb1XPath)cachedXPathObjects.get("property");
            if(xpathObject3 == null)
            {
              xpathObject3 = new Xb1XPath("property");
              cachedXPathObjects.put("property", xpathObject3);
            }

            List propertyNodeList = xpathObject3.selectNodes(propertiesElement);
        //logger.info("propertyNodeList:" + propertyNodeList.getLength());
        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());
          }

          //logger.info("path:" + "path_" + locale.getLanguage() + ":" + propertyElement.attributeValue("path_" + locale.getLanguage()));
          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 bindings = new ArrayList();
         
          Xb1XPath xpathObject4 = (Xb1XPath)cachedXPathObjects.get("binding");
              if(xpathObject4 == null)
              {
                xpathObject4 = new Xb1XPath("binding");
                cachedXPathObjects.put("binding", xpathObject4);
              }

              List bindingNodeList = xpathObject4.selectNodes(propertyElement);
          //logger.info("bindingNodeList:" + bindingNodeList.getLength());
          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");
            //logger.info("Binding found:" + entity + ":" + entityId);

            ComponentBinding 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);

          //TEST
          //component.getProperties().put(propertyName, property);

        }
      }
     
     
      getComponentRestrictionsWithXPP3(child, component, locale, templateController);

     
      //Getting slots for the component
      String componentString = this.getComponentString(templateController, contentId, component);
      //logger.info("Getting the slots for component.......");
      //logger.info("componentString:" + componentString);
      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));
         
          List subComponents = getComponentsWithXPP3(db, templateController, component, templateController.getSiteNodeId(), slotId);
          slot.setComponents(subComponents);
         
          component.getSlotList().add(slot);

          offset = slotStopIndex; // + 10;
        slotStartIndex = componentString.indexOf("<ig:slot", offset);
      }
     
     
      Xb1XPath xpathObject5 = (Xb1XPath)cachedXPathObjects.get("components");
          if(xpathObject5 == null)
          {
            xpathObject5 = new Xb1XPath("components");
            cachedXPathObjects.put("components", xpathObject5);
          }

      List anl = xpathObject5.selectNodes(child);
      if(anl.size() > 0)
      {
        XmlElement componentsElement = (XmlElement)anl.get(0);
        component.setComponents(getComponentsWithXPP3(db, componentsElement, templateController, component));
      }
View Full Code Here

Examples of org.xmlpull.v1.builder.xpath.Xb1XPath

    Map components = new HashMap();
   
    String componentXPath = getComponentXPath(parentComponent) + "/components/component[@name='" + componentName + "']";
    //logger.info("componentXPath:" + componentXPath);
   
    Xb1XPath xpathObject = (Xb1XPath)cachedXPathObjects.get(componentXPath);
        if(xpathObject == null)
        {
          xpathObject = new Xb1XPath( componentXPath );
          cachedXPathObjects.put(componentXPath, xpathObject);
        }

        //This keeps track of the cached inherited components.
        StringBuilder sb = new StringBuilder();
       
        List componentNodeList = xpathObject.selectNodes( element );
    Iterator componentNodeListIterator = componentNodeList.iterator();
    while(componentNodeListIterator.hasNext())
    {
      XmlElement child   = (XmlElement)componentNodeListIterator.next();
     
      String componentString = builder.serializeToString(child).trim();
      sb.append(componentString);
      //System.out.println("AAAAAAAAA" + componentString);
     
      Integer id       = new Integer(child.getAttributeValue(child.getNamespaceName(), "id"));
      Integer contentId   = new Integer(child.getAttributeValue(child.getNamespaceName(), "contentId"));
      String name       = child.getAttributeValue(child.getNamespaceName(), "name");
      String isPagePartRef  = child.getAttributeValue(child.getNamespaceName(), "isPagePartReference");
 
      ContentVO contentVO = ContentDeliveryController.getContentDeliveryController().getContentVO(db, contentId, templateController.getDeliveryContext());
     
      component = new InfoGlueComponent();
      component.setId(id);
      component.setContentId(contentId);
      component.setName(contentVO.getName());
      //component.setName(name);
      component.setSlotName(name);
      component.setParentComponent(parentComponent);
      if(parentComponent != null)
        component.setIsInherited(parentComponent.getIsInherited());

      Xb1XPath xpathObject2 = (Xb1XPath)cachedXPathObjects.get("properties");
          if(xpathObject2 == null)
          {
            xpathObject2 = new Xb1XPath( "properties" );
            cachedXPathObjects.put("properties", xpathObject2);
          }

      List propertiesNodeList = xpathObject2.selectNodes(child);
      ////logger.info("propertiesNodeList:" + propertiesNodeList.getLength());
      if(propertiesNodeList.size() > 0)
      {
        XmlElement propertiesElement = (XmlElement)propertiesNodeList.get(0);

        Xb1XPath xpathObject3 = (Xb1XPath)cachedXPathObjects.get("property");
            if(xpathObject3 == null)
            {
              xpathObject3 = new Xb1XPath( "property" );
              cachedXPathObjects.put("property", xpathObject3);
            }

        List propertyNodeList = xpathObject3.selectNodes(propertiesElement);
        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());
          }

          //logger.info("path:" + "path_" + locale.getLanguage() + ":" + propertyElement.attributeValue("path_" + locale.getLanguage()));
          if(propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path_" + locale.getLanguage()) != null)
            path = propertyElement.getAttributeValue(propertyElement.getNamespaceName(), "path_" + locale.getLanguage());
          //logger.info("path:" + path);

          if(path == null || path.equals(""))
          {
            logger.info("Falling back to content master language 2 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 bindings = new ArrayList();

          Xb1XPath xpathObject4 = (Xb1XPath)cachedXPathObjects.get("binding");
              if(xpathObject4 == null)
              {
                xpathObject4 = new Xb1XPath( "binding" );
                cachedXPathObjects.put("binding", xpathObject4);
              }

          List bindingNodeList = xpathObject4.selectNodes(propertyElement);
          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");
            ////logger.info("Binding found:" + entity + ":" + entityId);
           
            ComponentBinding 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(child, component, locale, templateController);
     
      Xb1XPath xpathObject5 = (Xb1XPath)cachedXPathObjects.get("components");
          if(xpathObject5 == null)
          {
            xpathObject5 = new Xb1XPath( "components" );
            cachedXPathObjects.put("components", xpathObject5);
          }

      List anl = xpathObject5.selectNodes(child);
      if(anl.size() > 0)
      {
        XmlElement componentsElement = (XmlElement)anl.get(0);
        component.setComponents(getComponentsWithXPP3(db, componentsElement, templateController, component));
      }
View Full Code Here

Examples of org.xmlpull.v1.builder.xpath.Xb1XPath

     
      //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())};
             
View Full Code Here

Examples of org.xmlpull.v1.builder.xpath.Xb1XPath

  /**
   * This method gets the restrictions for this component
   */
  private void getComponentRestrictionsWithXPP3(XmlElement child, InfoGlueComponent component, Locale locale, TemplateController templateController) throws Exception
  {
    Xb1XPath xpathObject = (Xb1XPath)cachedXPathObjects.get("restrictions");
        if(xpathObject == null)
        {
          xpathObject = new Xb1XPath("restrictions");
          cachedXPathObjects.put("restrictions", xpathObject);
        }

        List restrictionsNodeList = xpathObject.selectNodes( child );
    //logger.info("restrictionsNodeList:" + restrictionsNodeList.getLength());
    if(restrictionsNodeList.size() > 0)
    {
      XmlElement restrictionsElement = (XmlElement)restrictionsNodeList.get(0);

      Xb1XPath xpathObject2 = (Xb1XPath)cachedXPathObjects.get("restriction");
          if(xpathObject2 == null)
          {
            xpathObject2 = new Xb1XPath("restriction");
            cachedXPathObjects.put("restriction", xpathObject2);
          }

          List restrictionNodeList = xpathObject2.selectNodes( restrictionsElement );
      //logger.info("restrictionNodeList:" + restrictionNodeList.getLength());
      Iterator restrictionNodeListIterator = restrictionNodeList.iterator();
      while(restrictionNodeListIterator.hasNext())
      {
        XmlElement restrictionElement = (XmlElement)restrictionNodeListIterator.next();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.