Package org.exoplatform.services.jcr.impl.util

Examples of org.exoplatform.services.jcr.impl.util.NodeDataReader


               "/jcr:system is not found. Possible the workspace is not initialized properly");
      }

      if (isInialized())
      {
         NodeDataReader nsReader = new NodeDataReader(nsRoot, dataManager);
         nsReader.setRememberSkiped(true);
         nsReader.forNodesByType(Constants.EXO_NAMESPACE);
         nsReader.read();

         List<NodeDataReader> nsData = nsReader.getNodesByType(Constants.EXO_NAMESPACE);
         for (NodeDataReader nsr : nsData)
         {
            nsr.forProperty(Constants.EXO_URI_NAME, PropertyType.STRING).forProperty(Constants.EXO_PREFIX,
               PropertyType.STRING);
            nsr.read();

            try
            {
               String exoUri = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_URI_NAME));
               String exoPrefix = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_PREFIX));
               namespacesMap.put(exoPrefix, exoUri);
               urisMap.put(exoUri, exoPrefix);

               if (log.isDebugEnabled())
                  log.debug("Namespace " + exoPrefix + " is loaded");
            }
            catch (IOException e)
            {
               throw new RepositoryException("Namespace load error " + e, e);
            }
         }

         for (NodeData skipedNs : nsReader.getSkiped())
         {
            log.warn("Namespace node " + skipedNs.getQPath().getName().getAsString() + " (primary type '"
               + skipedNs.getPrimaryTypeName().getAsString()
               + "') is not supported for loading. Nodes with 'exo:namespace' node type is supported only now.");
         }
View Full Code Here


               "/jcr:system is not found. Possible the workspace is not initialized properly");
      }

      if (isInialized())
      {
         NodeDataReader nsReader = new NodeDataReader(nsRoot, dataManager);
         nsReader.setRememberSkiped(true);
         nsReader.forNodesByType(Constants.EXO_NAMESPACE);
         nsReader.read();

         List<NodeDataReader> nsData = nsReader.getNodesByType(Constants.EXO_NAMESPACE);
         for (NodeDataReader nsr : nsData)
         {
            nsr.forProperty(Constants.EXO_URI_NAME, PropertyType.STRING).forProperty(Constants.EXO_PREFIX,
               PropertyType.STRING);
            nsr.read();

            try
            {
               String exoUri = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_URI_NAME));
               String exoPrefix = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_PREFIX));
               namespacesMap.put(exoPrefix, exoUri);
               urisMap.put(exoUri, exoPrefix);

               if (log.isDebugEnabled())
                  log.debug("Namespace " + exoPrefix + " is loaded");
            }
            catch (IOException e)
            {
               throw new RepositoryException("Namespace load error " + e, e);
            }
         }

         for (NodeData skipedNs : nsReader.getSkiped())
         {
            log.warn("Namespace node " + skipedNs.getQPath().getName().getAsString() + " (primary type '"
               + skipedNs.getPrimaryTypeName().getAsString()
               + "') is not supported for loading. Nodes with 'exo:namespace' node type is supported only now.");
         }
View Full Code Here

         long cycleStart = System.currentTimeMillis();
         if (LOG.isDebugEnabled())
            LOG.debug(">>> Node types registration cycle started");

         NodeDataReader ntReader = new NodeDataReader(ntRoot, dataManager);
         ntReader.forNodesByType(Constants.NT_NODETYPE); // for nt:nodeType
         ntReader.read();

         nextNodeType : for (NodeDataReader ntr : ntReader.getNodesByType(Constants.NT_NODETYPE))
         {

            long ntStart = System.currentTimeMillis();

            InternalQName ntName = null;
            try
            {

               ntr.forProperty(Constants.JCR_NODETYPENAME, PropertyType.NAME);
               ntr.read();

               try
               {
                  ntName = ValueDataConvertor.readQName(ntr.getPropertyValue(Constants.JCR_NODETYPENAME));
               }
               catch (IllegalNameException e)
               {
                  LOG.error("NodeType name is not valid. " + e + ". NodeType skipped.");
                  continue nextNodeType;
               }

               if (LOG.isDebugEnabled())
                  LOG.debug("Reading from storage " + ntName.getAsString() + " "
                           + (System.currentTimeMillis() - ntStart));

               ntr.forProperty(Constants.JCR_PRIMARYTYPE, PropertyType.NAME).forProperty(Constants.JCR_ISMIXIN,
                        PropertyType.BOOLEAN).forProperty(Constants.JCR_HASORDERABLECHILDNODES, PropertyType.BOOLEAN)
                        .forProperty(Constants.JCR_PRIMARYITEMNAME, PropertyType.NAME).forProperty(
                                 Constants.JCR_SUPERTYPES, PropertyType.NAME);
               ntr.forNodesByType(Constants.NT_PROPERTYDEFINITION).forNodesByType(Constants.NT_CHILDNODEDEFINITION);
               ntr.read();

               boolean mixin = ValueDataConvertor.readBoolean(ntr.getPropertyValue(Constants.JCR_ISMIXIN));
               boolean hasOrderableChilds =
                        ValueDataConvertor.readBoolean(ntr.getPropertyValue(Constants.JCR_HASORDERABLECHILDNODES));
               InternalQName primaryItemName;
               try
               {
                  primaryItemName = ValueDataConvertor.readQName(ntr.getPropertyValue(Constants.JCR_PRIMARYITEMNAME));
               }
               catch (PathNotFoundException e)
               {
                  primaryItemName = null;
               }
               catch (IllegalNameException e)
               {
                  LOG.error("NodeType primary item name is not valid. " + e + ". NodeType " + ntName.getAsString()
                           + " skipped.");
                  continue nextNodeType;
               }

               // -------- Super types --------
               InternalQName[] declaredSupertypes;
               try
               {
                  List<ValueData> dst = ntr.getPropertyValues(Constants.JCR_SUPERTYPES);
                  InternalQName[] supertypes = new InternalQName[dst.size()];
                  for (int i = 0; i < dst.size(); i++)
                     supertypes[i] = ValueDataConvertor.readQName(dst.get(i));

                  declaredSupertypes = supertypes;
               }
               catch (PathNotFoundException e)
               {
                  declaredSupertypes = new InternalQName[0];
               }
               catch (IllegalNameException e)
               {
                  LOG.error("NodeType supertype name is not valid. " + e + ". NodeType " + ntName.getAsString()
                           + " skipped.");
                  continue nextNodeType;
               }

               // -------- Property definitions --------
               if (LOG.isDebugEnabled())
                  LOG.debug("Reading Property definitions for " + ntName.getAsString() + " "
                           + (System.currentTimeMillis() - ntStart));

               PropertyDefinitionData[] declaredProperties;
               try
               {
                  List<NodeDataReader> pdNodes = ntr.getNodesByType(Constants.NT_PROPERTYDEFINITION);
                  PropertyDefinitionData[] declaredPropertyDefs = new PropertyDefinitionData[pdNodes.size()];
                  for (int pdi = 0; pdi < pdNodes.size(); pdi++)
                  {
                     NodeDataReader pdr = pdNodes.get(pdi);

                     pdr.forProperty(Constants.JCR_NAME, PropertyType.NAME) // jcr:name
                              .forProperty(Constants.JCR_AUTOCREATED, PropertyType.BOOLEAN)
                              // jcr:autoCreated
                              .forProperty(Constants.JCR_MANDATORY, PropertyType.BOOLEAN)
                              // jcr:mandatory
                              .forProperty(Constants.JCR_PROTECTED, PropertyType.BOOLEAN)
                              // jcr:protected
                              .forProperty(Constants.JCR_MULTIPLE, PropertyType.BOOLEAN)
                              // jcr:multiple
                              .forProperty(Constants.JCR_ONPARENTVERSION, PropertyType.STRING)
                              // jcr:onParentVersion
                              .forProperty(Constants.JCR_REQUIREDTYPE, PropertyType.STRING)
                              // jcr:requiredType
                              .forProperty(Constants.JCR_VALUECONSTRAINTS, PropertyType.STRING)
                              // jcr:valueConstraints
                              .forProperty(Constants.JCR_DEFAULTVALUES, PropertyType.STRING);
                     // jcr:defaultValues
                     pdr.read();

                     InternalQName pname;
                     try
                     {
                        pname = ValueDataConvertor.readQName(pdr.getPropertyValue(Constants.JCR_NAME));
                     }
                     catch (PathNotFoundException e)
                     {
                        pname = null; // residual property definition
                     }
                     catch (IllegalNameException e)
                     {
                        LOG.error("Property definition name is not valid. " + e + ". NodeType " + ntName.getAsString()
                                 + " skipped.");
                        continue nextNodeType;
                     }

                     String[] valueConstraints;
                     try
                     {
                        List<ValueData> valueConstraintValues = pdr.getPropertyValues(Constants.JCR_VALUECONSTRAINTS);
                        valueConstraints = new String[valueConstraintValues.size()];
                        for (int j = 0; j < valueConstraintValues.size(); j++)
                           valueConstraints[j] = ValueDataConvertor.readString(valueConstraintValues.get(j));
                     }
                     catch (PathNotFoundException e)
                     {
                        valueConstraints = new String[0];
                     }

                     String[] defaultValues;
                     try
                     {
                        List<ValueData> dvl = pdr.getPropertyValues(Constants.JCR_DEFAULTVALUES);
                        defaultValues = new String[dvl.size()];
                        for (int i = 0; i < dvl.size(); i++)
                           defaultValues[i] = ValueDataConvertor.readString(dvl.get(i));
                     }
                     catch (PathNotFoundException e)
                     {
                        defaultValues = new String[0];
                     }

                     PropertyDefinitionData pDef =
                              new PropertyDefinitionData(pname, ntName, ValueDataConvertor.readBoolean(pdr
                                       .getPropertyValue(Constants.JCR_AUTOCREATED)), ValueDataConvertor
                                       .readBoolean(pdr.getPropertyValue(Constants.JCR_MANDATORY)),
                                       OnParentVersionAction.valueFromName(ValueDataConvertor.readString(pdr
                                                .getPropertyValue(Constants.JCR_ONPARENTVERSION))), ValueDataConvertor
                                                .readBoolean(pdr.getPropertyValue(Constants.JCR_PROTECTED)),
                                       ExtendedPropertyType.valueFromName(ValueDataConvertor.readString(pdr
                                                .getPropertyValue(Constants.JCR_REQUIREDTYPE))), valueConstraints,
                                       defaultValues, ValueDataConvertor.readBoolean(pdr
                                                .getPropertyValue(Constants.JCR_MULTIPLE)));
                     if (LOG.isDebugEnabled())
                        LOG.debug("Property definitions readed "
                                 + (pname != null ? pname.getAsString() : Constants.JCR_ANY_NAME.getAsString()) + " "
                                 + (System.currentTimeMillis() - ntStart));

                     declaredPropertyDefs[pdi] = pDef;
                  }

                  declaredProperties = declaredPropertyDefs;
               }
               catch (PathNotFoundException e)
               {
                  if (LOG.isDebugEnabled())
                     LOG.debug("Property definitions is not found. " + e + ". NodeType " + ntName.getAsString());
                  declaredProperties = new PropertyDefinitionData[]
                  {};
               }

               // --------- Child nodes definitions ----------
               if (LOG.isDebugEnabled())
                  LOG.debug("Reading Child nodes definitions for " + ntName.getAsString() + " "
                           + (System.currentTimeMillis() - ntStart));

               NodeDefinitionData[] declaredChildNodes;
               try
               {
                  List<NodeDataReader> cdNodes = ntr.getNodesByType(Constants.NT_CHILDNODEDEFINITION);
                  NodeDefinitionData[] declaredChildNodesDefs = new NodeDefinitionData[cdNodes.size()];
                  for (int cdi = 0; cdi < cdNodes.size(); cdi++)
                  {
                     NodeDataReader cdr = cdNodes.get(cdi);

                     cdr.forProperty(Constants.JCR_NAME, PropertyType.NAME) // jcr:name
                              .forProperty(Constants.JCR_REQUIREDPRIMARYTYPES, PropertyType.NAME)
                              // jcr:requiredPrimaryTypes
                              .forProperty(Constants.JCR_AUTOCREATED, PropertyType.BOOLEAN)
                              // jcr:autoCreated
                              .forProperty(Constants.JCR_MANDATORY, PropertyType.BOOLEAN)
                              // jcr:mandatory
                              .forProperty(Constants.JCR_PROTECTED, PropertyType.BOOLEAN)
                              // jcr:protected
                              .forProperty(Constants.JCR_ONPARENTVERSION, PropertyType.STRING)
                              // jcr:onParentVersion
                              .forProperty(Constants.JCR_SAMENAMESIBLINGS, PropertyType.STRING)
                              // jcr:sameNameSiblings
                              .forProperty(Constants.JCR_DEFAULTPRIMNARYTYPE, PropertyType.NAME); // jcr
                     // :
                     // defaultPrimaryType
                     cdr.read();

                     InternalQName nname;
                     try
                     {
                        nname = ValueDataConvertor.readQName(cdr.getPropertyValue(Constants.JCR_NAME));
                     }
                     catch (PathNotFoundException e)
                     {
                        nname = null; // residual
                     }
                     catch (IllegalNameException e)
                     {
                        LOG.error("Child node definition name is not valid. " + e + ". NodeType "
                                 + ntName.getAsString() + " skipped.");
                        continue nextNodeType;
                     }

                     InternalQName defaultNodeTypeName;
                     try
                     {
                        try
                        {
                           defaultNodeTypeName =
                                    ValueDataConvertor.readQName(cdr
                                             .getPropertyValue(Constants.JCR_DEFAULTPRIMNARYTYPE));
                        }
                        catch (IllegalNameException e)
                        {
                           LOG.error("Child node default nodetype name is not valid. " + e + ". NodeType "
                                    + ntName.getAsString() + " skipped.");
                           continue nextNodeType;
                        }
                     }
                     catch (PathNotFoundException e)
                     {
                        defaultNodeTypeName = null;
                     }

                     List<ValueData> requiredNodeTypesValues =
                              cdr.getPropertyValues(Constants.JCR_REQUIREDPRIMARYTYPES);
                     InternalQName[] requiredNodeTypes = new InternalQName[requiredNodeTypesValues.size()];
                     try
                     {
                        for (int j = 0; j < requiredNodeTypesValues.size(); j++)
                           requiredNodeTypes[j] = ValueDataConvertor.readQName(requiredNodeTypesValues.get(j));
                     }
                     catch (IllegalNameException e)
                     {
                        LOG.error("Child node required nodetype name is not valid. " + e + ". NodeType "
                                 + ntName.getAsString() + " skipped.");
                        continue nextNodeType;
                     }

                     NodeDefinitionData nDef =
                              new NodeDefinitionData(nname, ntName, ValueDataConvertor.readBoolean(cdr
                                       .getPropertyValue(Constants.JCR_AUTOCREATED)), ValueDataConvertor
                                       .readBoolean(cdr.getPropertyValue(Constants.JCR_MANDATORY)),
                                       OnParentVersionAction.valueFromName(ValueDataConvertor.readString(cdr
                                                .getPropertyValue(Constants.JCR_ONPARENTVERSION))), ValueDataConvertor
                                                .readBoolean(cdr.getPropertyValue(Constants.JCR_PROTECTED)),
                                       requiredNodeTypes, defaultNodeTypeName, ValueDataConvertor.readBoolean(cdr
                                                .getPropertyValue(Constants.JCR_SAMENAMESIBLINGS)));

                     declaredChildNodesDefs[cdi] = nDef;

                     if (LOG.isDebugEnabled())
View Full Code Here

   }

   private List<NodeDataReader> getNodeTypesData(InternalQName nodeTypeName) throws RepositoryException
   {

      NodeDataReader ntReader = new NodeDataReader(ntRoot, dataManager);
      ntReader.forNode(nodeTypeName);
      ntReader.read();

      ntReader.getNodes(nodeTypeName);

      return ntReader.getNodes(nodeTypeName);
   }
View Full Code Here

                     "/jcr:system is not found. Possible the workspace is not initialized properly");
      }

      if (isInialized())
      {
         NodeDataReader nsReader = new NodeDataReader(nsRoot, dataManager);
         nsReader.setRememberSkiped(true);
         nsReader.forNodesByType(Constants.EXO_NAMESPACE);
         nsReader.read();

         List<NodeDataReader> nsData = nsReader.getNodesByType(Constants.EXO_NAMESPACE);
         for (NodeDataReader nsr : nsData)
         {
            nsr.forProperty(Constants.EXO_URI_NAME, PropertyType.STRING).forProperty(Constants.EXO_PREFIX,
                     PropertyType.STRING);
            nsr.read();

            try
            {
               String exoUri = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_URI_NAME));
               String exoPrefix = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_PREFIX));
               namespacesMap.put(exoPrefix, exoUri);
               urisMap.put(exoUri, exoPrefix);

               if (log.isDebugEnabled())
                  log.debug("Namespace " + exoPrefix + " is loaded");
            }
            catch (IOException e)
            {
               throw new RepositoryException("Namespace load error " + e, e);
            }
         }

         for (NodeData skipedNs : nsReader.getSkiped())
         {
            log.warn("Namespace node " + skipedNs.getQPath().getName().getAsString() + " (primary type '"
                     + skipedNs.getPrimaryTypeName().getAsString()
                     + "') is not supported for loading. Nodes with 'exo:namespace' node type is supported only now.");
         }
View Full Code Here

               "/jcr:system is not found. Possible the workspace is not initialized properly");
      }

      if (isInialized())
      {
         NodeDataReader nsReader = new NodeDataReader(nsRoot, dataManager);
         nsReader.setRememberSkiped(true);
         nsReader.forNodesByType(Constants.EXO_NAMESPACE);
         nsReader.read();

         List<NodeDataReader> nsData = nsReader.getNodesByType(Constants.EXO_NAMESPACE);
         for (NodeDataReader nsr : nsData)
         {
            nsr.forProperty(Constants.EXO_URI_NAME, PropertyType.STRING).forProperty(Constants.EXO_PREFIX,
               PropertyType.STRING);
            nsr.read();

            try
            {
               String exoUri = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_URI_NAME));
               String exoPrefix = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_PREFIX));
               namespacesMap.put(exoPrefix, exoUri);
               urisMap.put(exoUri, exoPrefix);

               if (log.isDebugEnabled())
                  log.debug("Namespace " + exoPrefix + " is loaded");
            }
            catch (IOException e)
            {
               throw new RepositoryException("Namespace load error " + e, e);
            }
         }

         for (NodeData skipedNs : nsReader.getSkiped())
         {
            log.warn("Namespace node " + skipedNs.getQPath().getName().getAsString() + " (primary type '"
               + skipedNs.getPrimaryTypeName().getAsString()
               + "') is not supported for loading. Nodes with 'exo:namespace' node type is supported only now.");
         }
View Full Code Here

               "/jcr:system is not found. Possible the workspace is not initialized properly");
      }

      if (isInialized())
      {
         NodeDataReader nsReader = new NodeDataReader(nsRoot, dataManager);
         nsReader.setRememberSkiped(true);
         nsReader.forNodesByType(Constants.EXO_NAMESPACE);
         nsReader.read();

         List<NodeDataReader> nsData = nsReader.getNodesByType(Constants.EXO_NAMESPACE);
         for (NodeDataReader nsr : nsData)
         {
            nsr.forProperty(Constants.EXO_URI_NAME, PropertyType.STRING).forProperty(Constants.EXO_PREFIX,
               PropertyType.STRING);
            nsr.read();

            String exoUri = ValueDataUtil.getString(nsr.getPropertyValue(Constants.EXO_URI_NAME));
            String exoPrefix = ValueDataUtil.getString(nsr.getPropertyValue(Constants.EXO_PREFIX));
            namespacesMap.put(exoPrefix, exoUri);
            urisMap.put(exoUri, exoPrefix);

            if (log.isDebugEnabled())
               log.debug("Namespace " + exoPrefix + " is loaded");
         }

         for (NodeData skipedNs : nsReader.getSkiped())
         {
            log.warn("Namespace node " + skipedNs.getQPath().getName().getAsString() + " (primary type '"
               + skipedNs.getPrimaryTypeName().getAsString()
               + "') is not supported for loading. Nodes with 'exo:namespace' node type is supported only now.");
         }
View Full Code Here

               "/jcr:system is not found. Possible the workspace is not initialized properly");
      }

      if (isInialized())
      {
         NodeDataReader nsReader = new NodeDataReader(nsRoot, dataManager);
         nsReader.setRememberSkiped(true);
         nsReader.forNodesByType(Constants.EXO_NAMESPACE);
         nsReader.read();

         List<NodeDataReader> nsData = nsReader.getNodesByType(Constants.EXO_NAMESPACE);
         for (NodeDataReader nsr : nsData)
         {
            nsr.forProperty(Constants.EXO_URI_NAME, PropertyType.STRING).forProperty(Constants.EXO_PREFIX,
               PropertyType.STRING);
            nsr.read();

            try
            {
               String exoUri = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_URI_NAME));
               String exoPrefix = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_PREFIX));
               namespacesMap.put(exoPrefix, exoUri);
               urisMap.put(exoUri, exoPrefix);

               if (log.isDebugEnabled())
                  log.debug("Namespace " + exoPrefix + " is loaded");
            }
            catch (IOException e)
            {
               throw new RepositoryException("Namespace load error " + e, e);
            }
         }

         for (NodeData skipedNs : nsReader.getSkiped())
         {
            log.warn("Namespace node " + skipedNs.getQPath().getName().getAsString() + " (primary type '"
               + skipedNs.getPrimaryTypeName().getAsString()
               + "') is not supported for loading. Nodes with 'exo:namespace' node type is supported only now.");
         }
View Full Code Here

               "/jcr:system is not found. Possible the workspace is not initialized properly");
      }

      if (isInialized())
      {
         NodeDataReader nsReader = new NodeDataReader(nsRoot, dataManager);
         nsReader.setRememberSkiped(true);
         nsReader.forNodesByType(Constants.EXO_NAMESPACE);
         nsReader.read();

         List<NodeDataReader> nsData = nsReader.getNodesByType(Constants.EXO_NAMESPACE);
         for (NodeDataReader nsr : nsData)
         {
            nsr.forProperty(Constants.EXO_URI_NAME, PropertyType.STRING).forProperty(Constants.EXO_PREFIX,
               PropertyType.STRING);
            nsr.read();

            try
            {
               String exoUri = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_URI_NAME));
               String exoPrefix = ValueDataConvertor.readString(nsr.getPropertyValue(Constants.EXO_PREFIX));
               namespacesMap.put(exoPrefix, exoUri);
               urisMap.put(exoUri, exoPrefix);

               if (log.isDebugEnabled())
                  log.debug("Namespace " + exoPrefix + " is loaded");
            }
            catch (IOException e)
            {
               throw new RepositoryException("Namespace load error " + e, e);
            }
         }

         for (NodeData skipedNs : nsReader.getSkiped())
         {
            log.warn("Namespace node " + skipedNs.getQPath().getName().getAsString() + " (primary type '"
               + skipedNs.getPrimaryTypeName().getAsString()
               + "') is not supported for loading. Nodes with 'exo:namespace' node type is supported only now.");
         }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.util.NodeDataReader

Copyright © 2018 www.massapicom. 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.