Package org.exoplatform.services.jcr.impl.xml.importing.dataflow

Examples of org.exoplatform.services.jcr.impl.xml.importing.dataflow.ImportPropertyData


    * @throws ValueFormatException
    */
   private ImportPropertyData endProperty() throws PathNotFoundException, RepositoryException, NoSuchNodeTypeException,
            IllegalPathException, ValueFormatException
   {
      ImportPropertyData propertyData = null;
      if (Constants.JCR_PRIMARYTYPE.equals(propertyInfo.getName()))
      {

         propertyData = endPrimaryType();

      }
      else if (Constants.JCR_MIXINTYPES.equals(propertyInfo.getName()))
      {
         propertyData = endMixinTypes();

      }
      else if (Constants.JCR_UUID.equals(propertyInfo.getName()))
      {
         propertyData = endUuid();

         // skip verionable properties
      }
      else if (!getParent().getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH)
               && (Constants.JCR_VERSIONHISTORY.equals(propertyInfo.getName())
                        || Constants.JCR_BASEVERSION.equals(propertyInfo.getName()) || Constants.JCR_PREDECESSORS
                        .equals(propertyInfo.getName())))
      {

         propertyData = null;

         endVersionable((ImportNodeData) getParent(), parseValues());
      }
      else
      {

         ImportNodeData currentNodeInfo = (ImportNodeData) getParent();
         List<ValueData> values = parseValues();

         // determinating is property multivalue;
         boolean isMultivalue = true;

         PropertyDefinitionDatas defs =
                  nodeTypeDataManager.findPropertyDefinitions(propertyInfo.getName(), currentNodeInfo
                           .getPrimaryTypeName(), currentNodeInfo.getMixinTypeNames());

         if (defs == null)
         {
            if (!((Boolean) context.get(ContentImporter.RESPECT_PROPERTY_DEFINITIONS_CONSTRAINTS)))
            {
               log.warn("Property definition not found for " + propertyInfo.getName());
               return null;
            }
            else
               throw new RepositoryException("Property definition not found for " + propertyInfo.getName());

         }

         if (values.size() == 1)
         {
            // there is single-value defeniton
            if (defs.getDefinition(false) != null)
            {
               isMultivalue = false;
            }
         }
         else
         {
            if ((defs.getDefinition(true) == null) && (defs.getDefinition(false) != null))
            {
               throw new ValueFormatException("Can not assign multiple-values " + "Value to a single-valued property "
                        + propertyInfo.getName().getName());
            }
         }
         log.debug("Import " + propertyInfo.getName().getName() + " size=" + propertyInfo.getValuesSize()
                  + " isMultivalue=" + isMultivalue);

         propertyData =
                  new ImportPropertyData(QPath.makeChildPath(currentNodeInfo.getQPath(), propertyInfo.getName()),
                           propertyInfo.getIndentifer(), 0, propertyInfo.getType(), currentNodeInfo.getIdentifier(),
                           isMultivalue);
         propertyData.setValues(values);

      }
      return propertyData;
   }
View Full Code Here


    * @throws PathNotFoundException
    * @throws IllegalPathException
    */
   private ImportPropertyData endUuid() throws RepositoryException, PathNotFoundException, IllegalPathException
   {
      ImportPropertyData propertyData;
      ImportNodeData currentNodeInfo = (ImportNodeData) tree.pop();

      currentNodeInfo.setMixReferenceable(nodeTypeDataManager.isNodeType(Constants.MIX_REFERENCEABLE, currentNodeInfo
               .getPrimaryTypeName(), currentNodeInfo.getMixinTypeNames()));

      if (currentNodeInfo.isMixReferenceable())
      {
         currentNodeInfo.setMixVersionable(nodeTypeDataManager.isNodeType(Constants.MIX_VERSIONABLE, currentNodeInfo
                  .getPrimaryTypeName(), currentNodeInfo.getMixinTypeNames()));
         checkReferenceable(currentNodeInfo, propertyInfo.getValues().get(0).toString());
      }

      propertyData =
               new ImportPropertyData(QPath.makeChildPath(currentNodeInfo.getQPath(), propertyInfo.getName()),
                        propertyInfo.getIndentifer(), 0, propertyInfo.getType(), currentNodeInfo.getIdentifier(), false);
      propertyData.setValue(new TransientValueData(currentNodeInfo.getIdentifier()));

      tree.push(currentNodeInfo);
      return propertyData;
   }
View Full Code Here

      }
      else if (Constants.SV_PROPERTY_NAME.equals(elementName))
      {
         // sv:property element

         ImportPropertyData propertyData = endProperty();
         if (propertyData != null)
            changesLog.add(new ItemState(propertyData, ItemState.ADDED, true, getAncestorToSave()));
      }
      else if (Constants.SV_VALUE_NAME.equals(elementName))
      {
View Full Code Here

    * @throws NoSuchNodeTypeException
    */
   private ImportPropertyData endMixinTypes() throws PathNotFoundException, RepositoryException,
      NoSuchNodeTypeException
   {
      ImportPropertyData propertyData;
      InternalQName[] mixinNames = new InternalQName[propertyInfo.getValuesSize()];
      List<ValueData> values = new ArrayList<ValueData>(propertyInfo.getValuesSize());
      ImportNodeData currentNodeInfo = (ImportNodeData)getParent();
      for (int i = 0; i < propertyInfo.getValuesSize(); i++)
      {

         String value = propertyInfo.getValues().get(i).toString();

         mixinNames[i] = locationFactory.parseJCRName(value).getInternalName();
         currentNodeInfo.addNodeType((nodeTypeDataManager.getNodeType(mixinNames[i])));
         values.add(new TransientValueData(value.toString()));
      }

      currentNodeInfo.setMixinTypeNames(mixinNames);

      propertyData =
         new ImportPropertyData(QPath.makeChildPath(currentNodeInfo.getQPath(), propertyInfo.getName()), propertyInfo
            .getIndentifer(), 0, propertyInfo.getType(), currentNodeInfo.getIdentifier(), true);
      propertyData.setValues(parseValues());
      return propertyData;
   }
View Full Code Here

    * @throws NoSuchNodeTypeException
    */
   private ImportPropertyData endPrimaryType() throws PathNotFoundException, RepositoryException,
      NoSuchNodeTypeException
   {
      ImportPropertyData propertyData;
      String sName = propertyInfo.getValues().get(0).toString();
      InternalQName primaryTypeName = locationFactory.parseJCRName(sName).getInternalName();

      ImportNodeData nodeData = (ImportNodeData)tree.pop();
      if (!Constants.ROOT_UUID.equals(nodeData.getIdentifier()))
      {
         NodeData parentNodeData = getParent();
         // nodeTypeDataManager.findChildNodeDefinition(primaryTypeName,)
         if (!nodeTypeDataManager.isChildNodePrimaryTypeAllowed(primaryTypeName, parentNodeData.getPrimaryTypeName(),
            parentNodeData.getMixinTypeNames()))
         {
            throw new ConstraintViolationException("Can't add node " + nodeData.getQName().getAsString() + " to "
               + parentNodeData.getQPath().getAsString() + " node type " + sName
               + " is not allowed as child's node type for parent node type "
               + parentNodeData.getPrimaryTypeName().getAsString());
         }
      }
      //
      nodeData.addNodeType((nodeTypeDataManager.getNodeType(primaryTypeName)));
      nodeData.setPrimaryTypeName(primaryTypeName);

      propertyData =
         new ImportPropertyData(QPath.makeChildPath(nodeData.getQPath(), propertyInfo.getName()), propertyInfo
            .getIndentifer(), 0, propertyInfo.getType(), nodeData.getIdentifier(), false);
      propertyData.setValues(parseValues());
      tree.push(nodeData);
      return propertyData;
   }
View Full Code Here

    * @throws ValueFormatException
    */
   private ImportPropertyData endProperty() throws PathNotFoundException, RepositoryException, NoSuchNodeTypeException,
      IllegalPathException, ValueFormatException
   {
      ImportPropertyData propertyData = null;
      if (Constants.JCR_PRIMARYTYPE.equals(propertyInfo.getName()))
      {

         propertyData = endPrimaryType();

      }
      else if (Constants.JCR_MIXINTYPES.equals(propertyInfo.getName()))
      {
         propertyData = endMixinTypes();

      }
      else if (Constants.JCR_UUID.equals(propertyInfo.getName()))
      {
         propertyData = endUuid();

         // skip verionable properties
      }
      else if (!getParent().getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH)
         && (Constants.JCR_VERSIONHISTORY.equals(propertyInfo.getName())
            || Constants.JCR_BASEVERSION.equals(propertyInfo.getName()) || Constants.JCR_PREDECESSORS
            .equals(propertyInfo.getName())))
      {

         propertyData = null;

         endVersionable((ImportNodeData)getParent(), parseValues());
      }
      else
      {

         ImportNodeData currentNodeInfo = (ImportNodeData)getParent();
         List<ValueData> values = parseValues();

         // determinating is property multivalue;
         boolean isMultivalue = true;

         PropertyDefinitionDatas defs =
            nodeTypeDataManager.getPropertyDefinitions(propertyInfo.getName(), currentNodeInfo.getPrimaryTypeName(),
               currentNodeInfo.getMixinTypeNames());

         if (defs == null)
         {
            if (!((Boolean)context.get(ContentImporter.RESPECT_PROPERTY_DEFINITIONS_CONSTRAINTS)))
            {
               log.warn("Property definition not found for " + propertyInfo.getName());
               return null;
            }
            else
               throw new RepositoryException("Property definition not found for " + propertyInfo.getName());

         }

         if (values.size() == 1)
         {
            // there is single-value defeniton
            if (defs.getDefinition(false) != null)
            {
               isMultivalue = false;
            }
         }
         else
         {
            if ((defs.getDefinition(true) == null) && (defs.getDefinition(false) != null))
            {
               throw new ValueFormatException("Can not assign multiple-values " + "Value to a single-valued property "
                  + propertyInfo.getName().getName());
            }
         }
         log.debug("Import " + propertyInfo.getName().getName() + " size=" + propertyInfo.getValuesSize()
            + " isMultivalue=" + isMultivalue);

         propertyData =
            new ImportPropertyData(QPath.makeChildPath(currentNodeInfo.getQPath(), propertyInfo.getName()),
               propertyInfo.getIndentifer(), 0, propertyInfo.getType(), currentNodeInfo.getIdentifier(), isMultivalue);
         propertyData.setValues(values);

      }
      return propertyData;
   }
View Full Code Here

    * @throws PathNotFoundException
    * @throws IllegalPathException
    */
   private ImportPropertyData endUuid() throws RepositoryException, PathNotFoundException, IllegalPathException
   {
      ImportPropertyData propertyData;
      ImportNodeData currentNodeInfo = (ImportNodeData)tree.pop();

      currentNodeInfo.setMixReferenceable(nodeTypeDataManager.isNodeType(Constants.MIX_REFERENCEABLE, currentNodeInfo
         .getPrimaryTypeName(), currentNodeInfo.getMixinTypeNames()));

      if (currentNodeInfo.isMixReferenceable())
      {
         currentNodeInfo.setMixVersionable(nodeTypeDataManager.isNodeType(Constants.MIX_VERSIONABLE, currentNodeInfo
            .getPrimaryTypeName(), currentNodeInfo.getMixinTypeNames()));
         checkReferenceable(currentNodeInfo, propertyInfo.getValues().get(0).toString());
      }

      propertyData =
         new ImportPropertyData(QPath.makeChildPath(currentNodeInfo.getQPath(), propertyInfo.getName()), propertyInfo
            .getIndentifer(), 0, propertyInfo.getType(), currentNodeInfo.getIdentifier(), false);
      propertyData.setValue(new TransientValueData(currentNodeInfo.getIdentifier()));

      tree.push(currentNodeInfo);
      return propertyData;
   }
View Full Code Here

         if (log.isDebugEnabled())
         {
            log.debug("New node " + nodeData.getQPath().getAsString());
         }

         ImportPropertyData newProperty =
            new ImportPropertyData(QPath.makeChildPath(nodeData.getQPath(), Constants.JCR_PRIMARYTYPE), IdGenerator
               .generate(), 0, PropertyType.NAME, nodeData.getIdentifier(), false);

         newProperty.setValue(new TransientValueData(Constants.NT_UNSTRUCTURED));
         changesLog.add(new ItemState(newProperty, ItemState.ADDED, true, getAncestorToSave()));
         newProperty =
            new ImportPropertyData(QPath.makeChildPath(nodeData.getQPath(), Constants.JCR_XMLCHARACTERS), IdGenerator
               .generate(), 0, PropertyType.STRING, nodeData.getIdentifier(), false);
         newProperty.setValue(new TransientValueData(text.toString()));

         changesLog.add(new ItemState(newProperty, ItemState.ADDED, true, getAncestorToSave()));
         xmlCharactersProperty = newProperty;
         xmlCharactersPropertyValue = text.toString();
      }
View Full Code Here

      }
      else if (Constants.SV_PROPERTY_NAME.equals(elementName))
      {
         // sv:property element

         ImportPropertyData propertyData = endProperty();
         if (propertyData != null)
         {
            changesLog.add(new ItemState(propertyData, ItemState.ADDED, true, getAncestorToSave()));
           
            ImportNodeData currentNodeInfo = (ImportNodeData)getParent();
View Full Code Here

    * @throws NoSuchNodeTypeException
    */
   private ImportPropertyData endMixinTypes() throws PathNotFoundException, RepositoryException,
      NoSuchNodeTypeException
   {
      ImportPropertyData propertyData;
      InternalQName[] mixinNames = new InternalQName[propertyInfo.getValuesSize()];
      List<ValueData> values = new ArrayList<ValueData>(propertyInfo.getValuesSize());
      ImportNodeData currentNodeInfo = (ImportNodeData)getParent();
      for (int i = 0; i < propertyInfo.getValuesSize(); i++)
      {

         String value = propertyInfo.getValues().get(i).toString();

         mixinNames[i] = locationFactory.parseJCRName(value).getInternalName();
         currentNodeInfo.addNodeType((nodeTypeDataManager.getNodeType(mixinNames[i])));
         values.add(new TransientValueData(value.toString()));
      }

      currentNodeInfo.setMixinTypeNames(mixinNames);

      propertyData =
         new ImportPropertyData(QPath.makeChildPath(currentNodeInfo.getQPath(), propertyInfo.getName()), propertyInfo
            .getIndentifer(), 0, propertyInfo.getType(), currentNodeInfo.getIdentifier(), true);
      propertyData.setValues(parseValues());
      return propertyData;
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.xml.importing.dataflow.ImportPropertyData

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.