Package org.exoplatform.services.jcr.core.nodetype

Examples of org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas


    * {@inheritDoc}
    */
   public PropertyDefinitionDatas getPropertyDefinitions(InternalQName propertyName, InternalQName... nodeTypeNames)
   {

      PropertyDefinitionDatas propertyDefinitions = defsHolder.getPropertyDefinitions(propertyName, nodeTypeNames);
      // Try super
      if (propertyDefinitions == null)
      {
         for (int i = 0; i < nodeTypeNames.length && propertyDefinitions == null; i++)
         {
View Full Code Here


    */
   public PropertyDefinitionDatas getPropertyDefinitions(final InternalQName propertyName,
            final InternalQName... nodeTypes)
   {

      PropertyDefinitionDatas pdefs = new PropertyDefinitionDatas();

      for (InternalQName nt : nodeTypes)
      {
         // single-valued
         PropertyDefinitionData def = propertyDefinitions.get(new PropertyDefKey(nt, propertyName, false));
         if (def != null && pdefs.getDefinition(def.isMultiple()) == null)
            pdefs.setDefinition(def); // set if same is not exists

         // multi-valued
         def = propertyDefinitions.get(new PropertyDefKey(nt, propertyName, true));
         if (def != null && pdefs.getDefinition(def.isMultiple()) == null)
            pdefs.setDefinition(def); // set if same is not exists

         // try residual

      }

      return pdefs.getAnyDefinition() != null ? pdefs : null;
   }
View Full Code Here

   {
      try
      {
         InternalQName iname = locationFactory.parseJCRName(itemName).getInternalName();

         PropertyDefinitionDatas pdefs = nodeTypeDataManager.getPropertyDefinitions(iname, nodeTypeData.getName());
         if (pdefs != null)
         {
            PropertyDefinitionData pd = pdefs.getAnyDefinition();
            if (pd != null)
               return !(pd.isMandatory() || pd.isProtected());
         }
         NodeDefinitionData cndef = nodeTypeDataManager.findChildNodeDefinition(iname, nodeTypeData.getName());
         if (cndef != null)
View Full Code Here

   {
      try
      {
         InternalQName pname = locationFactory.parseJCRName(propertyName).getInternalName();

         PropertyDefinitionDatas pdefs = nodeTypeDataManager.getPropertyDefinitions(pname, nodeTypeData.getName());
         if (pdefs != null)
         {
            PropertyDefinitionData pd = pdefs.getDefinition(false);
            if (pd != null)
            {
               if (pd.isProtected())
                  // can set (edit)
                  return false;
View Full Code Here

   {
      try
      {
         InternalQName pname = locationFactory.parseJCRName(propertyName).getInternalName();

         PropertyDefinitionDatas pdefs = nodeTypeDataManager.getPropertyDefinitions(pname, nodeTypeData.getName());
         PropertyDefinitionData pd = pdefs.getDefinition(true);
         if (pd != null)
         {
            if (pd.isProtected())
               // can set (edit)
               return false;
View Full Code Here

   private void initDefinitions(boolean multiple) throws RepositoryException, ConstraintViolationException
   {

      NodeData parent = parentData();
      InternalQName pname = getData().getQPath().getName();
      PropertyDefinitionDatas definitions =
               session.getWorkspace().getNodeTypesHolder().findPropertyDefinitions(pname, parent.getPrimaryTypeName(),
                        parent.getMixinTypeNames());
      if (definitions == null)
         throw new ConstraintViolationException("Definition for property " + getPath() + " not found.");

      propertyDef = definitions.getDefinition(multiple);
   }
View Full Code Here

      String identifier;
      int version;
      PropertyImpl oldProp = null;
      ItemImpl oldItem = dataManager.getItem(parentNode.nodeData(), new QPathEntry(propertyName, 0), true);
      PropertyDefinitionDatas defs = null;

      NodeTypeDataManager ntm = session.getWorkspace().getNodeTypesHolder();
      NodeData parentData = (NodeData) parentNode.getData();
      boolean isMultiValue = multiValue;
      if (oldItem == null || oldItem.isNode())
      { // new prop
         identifier = IdGenerator.generate();
         version = -1;
         if (propertyValues == null)
         {
            // new property null values;
            TransientPropertyData nullData =
                     new TransientPropertyData(qpath, identifier, version, PropertyType.UNDEFINED, parentNode
                              .getInternalIdentifier(), isMultiValue);
            PropertyImpl nullProperty = new PropertyImpl(nullData, session);
            nullProperty.invalidate();
            return nullProperty;
         }
         defs =
                  ntm.findPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData
                           .getMixinTypeNames());

         state = ItemState.ADDED;
      }
      else
      {
         oldProp = (PropertyImpl) oldItem;
         isMultiValue = oldProp.isMultiValued();
         defs =
                  ntm.findPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData
                           .getMixinTypeNames());

         identifier = oldProp.getInternalIdentifier();
         version = oldProp.getData().getPersistedVersion();
         if (propertyValues == null)
            state = ItemState.DELETED;
         else
         {
            state = ItemState.UPDATED;
         }
      }
      if (defs == null || defs.getAnyDefinition() == null)
         throw new RepositoryException("Property definition '" + propertyName.getAsString() + "' is not found.");

      PropertyDefinitionData def = defs.getDefinition(isMultiValue);
      if (def != null && def.isProtected())
         throw new ConstraintViolationException("Can not set protected property "
                  + locationFactory.createJCRPath(qpath).getAsString(false));

      if (multiValue && (def == null || (oldProp != null && !oldProp.isMultiValued())))
View Full Code Here

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

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

            newProperty = endUuid(nodeData, propName);
         }
         else
         {
            PropertyDefinitionData pDef;
            PropertyDefinitionDatas defs;
            InternalQName[] nTypes = mixinNodeTypes.toArray(new InternalQName[mixinNodeTypes.size() + 1]);
            nTypes[nTypes.length - 1] = nodeData.getPrimaryTypeName();
            defs = nodeTypeDataManager.getPropertyDefinitions(propName, nTypes);
            if (defs == null || defs.getAnyDefinition() == null)
            {
               if (!((Boolean)context.get(ContentImporter.RESPECT_PROPERTY_DEFINITIONS_CONSTRAINTS)))
               {
                  log.warn("Property definition not found for " + propName.getAsString());
                  continue;
               }
               throw new RepositoryException("Property definition not found for " + propName.getAsString());
            }

            pDef = defs.getAnyDefinition();

            if ((pDef == null) || (defs == null))
            {
               throw new RepositoryException("no propertyDefinition found");
            }

            if (pDef.getRequiredType() == PropertyType.BINARY)
            {
               newProperty = endBinary(propertiesMap, newProperty, propName);
            }
            else
            {
               StringTokenizer spaceTokenizer = new StringTokenizer(propertiesMap.get(propName));

               List<ValueData> values = new ArrayList<ValueData>();
               int pType = pDef.getRequiredType() > 0 ? pDef.getRequiredType() : PropertyType.STRING;

               if ("".equals(propertiesMap.get(propName)))
               {
                  // Skip empty non string values
                  if (pType != PropertyType.STRING)
                  {
                     continue;
                  }

                  String denormalizeString = StringConverter.denormalizeString(propertiesMap.get(propName));
                  Value value = valueFactory.createValue(denormalizeString, pType);
                  values.add(((BaseValue)value).getInternalData());
                  if (Constants.EXO_OWNER.equals(propName))
                  {
                     nodeData.setExoOwner(denormalizeString);
                  }
               }
               else
               {
                  List<String> denormalizeStrings = new ArrayList<String>();

                  while (spaceTokenizer.hasMoreTokens())
                  {
                     String elem = spaceTokenizer.nextToken();
                     String denormalizeString = StringConverter.denormalizeString(elem);
                     denormalizeStrings.add(denormalizeString);
                     Value value = valueFactory.createValue(denormalizeString, pType);
                     if (log.isDebugEnabled())
                     {
                        String valueAsString = null;
                        try
                        {
                           valueAsString = value.getString();
                        }
                        catch (Exception e)
                        {
                           log.error("Can't present value as string. " + e.getMessage());
                           valueAsString = "[Can't present value as string]";
                        }
                        log.debug("Property " + ExtendedPropertyType.nameFromValue(pType) + ": " + propName + "="
                           + valueAsString);
                     }
                     values.add(((BaseValue)value).getInternalData());

                  }
                  if (pType == ExtendedPropertyType.PERMISSION)
                  {
                     nodeData.setExoPrivileges(denormalizeStrings);
                  }
                  else if (Constants.EXO_OWNER.equals(propName))
                  {
                     nodeData.setExoOwner(denormalizeStrings.get(0));
                  }
               }

               boolean isMultivalue = true;

               // determinating is property multivalue;
               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 " + propName.getAsString() + " node " + jcrName.getName());
                  }
               }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas

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.