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

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


         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;
               else if (value != null)
                  // can set (add or edit)
                  return canSetPropertyForType(pd.getRequiredType(), value, pd.getValueConstraints());
               else
                  // can remove
                  return !pd.isMandatory();
            }
         }
         return false;
      }
      catch (RepositoryException e)
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;
            else if (values != null)
            {
               // can set (add or edit)
               int res = 0;
               for (Value value : values)
               {
                  if (canSetPropertyForType(pd.getRequiredType(), value, pd.getValueConstraints()))
                     res++;
               }
               return res == values.length;
            }
            else
               // can remove
               return !pd.isMandatory();
         }
         else
            return false;
      }
      catch (RepositoryException e)
View Full Code Here

         if (propdefs == null)
         {
            throw new RepositoryException();
         }

         PropertyDefinitionData propertyDefinitionData = propdefs.getAnyDefinition();
         if (propertyDefinitionData == null)
         {
            throw new RepositoryException();
         }

         boolean isMultiValued = propertyDefinitionData.isMultiple();

         if (node.isNodeType(WebDavConst.NodeTypes.MIX_VERSIONABLE) && !node.isCheckedOut())
         {
            node.checkout();
            node.save();
View Full Code Here

         if (propdefs == null)
         {
            throw new RepositoryException();
         }

         PropertyDefinitionData propertyDefinitionData = propdefs.getAnyDefinition();
         if (propertyDefinitionData == null)
         {
            throw new RepositoryException();
         }

         boolean isMultiValued = propertyDefinitionData.isMultiple();

         if (node.isNodeType(WebDavConst.NodeTypes.MIX_VERSIONABLE) && !node.isCheckedOut())
         {
            node.checkout();
            node.save();
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
View Full Code Here

         PropertyDefinitionData[] props = new PropertyDefinitionData[pdlist.size()];
         for (int i = 0; i < pdlist.size(); i++)
         {
            PropertyDefinitionValue v = pdlist.get(i);

            PropertyDefinitionData pd;
            pd =
                     new PropertyDefinitionData(locationFactory.parseJCRName(v.getName()).getInternalName(), ntName, v
                              .isAutoCreate(), v.isMandatory(), v.getOnVersion(), v.isReadOnly(), v.getRequiredType(),
                              v.getValueConstraints() != null ? v.getValueConstraints().toArray(
                                       new String[v.getValueConstraints().size()]) : new String[0], v
                                       .getDefaultValueStrings() == null ? new String[0] : v.getDefaultValueStrings()
                                       .toArray(new String[v.getDefaultValueStrings().size()]), v.isMultiple());
View Full Code Here

   public PropertyDefinitionData getPropertyDefinition(InternalQName childName, boolean multiValued,
            InternalQName parentNodeType)
   {

      PropertyDefKey key = new PropertyDefKey(parentNodeType, childName, multiValued);
      PropertyDefinitionData def = propertyDefinitions.get(key);

      // try residual def
      if (def == null)
      {
         return propertyDefinitions.get(new PropertyDefKey(parentNodeType, Constants.JCR_ANY_NAME, multiValued));
View Full Code Here

      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

      }
View Full Code Here

                     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)),
View Full Code Here

            List<RelatedDefinition<PropertyDefinitionData>> changedDefinitionData, Set<String> nodes,
            PropertyDefinitionData[] allRecipientDefinition) throws RepositoryException
   {
      for (RelatedDefinition<PropertyDefinitionData> relatedDefinitions : changedDefinitionData)
      {
         PropertyDefinitionData ancestorDefinitionData = relatedDefinitions.getAncestorDefinition();
         PropertyDefinitionData recipientDefinitionData = relatedDefinitions.getRecepientDefinition();
         // change from mandatory=false to mandatory = true
         if (!ancestorDefinitionData.isMandatory() && recipientDefinitionData.isMandatory())
         {
            checkMandatory(registeredNodeType, nodes, recipientDefinitionData);

         }
         // change from Protected=false to Protected = true
         if (!ancestorDefinitionData.isProtected() && recipientDefinitionData.isProtected())
         {
            checkProtected(registeredNodeType, nodes, recipientDefinitionData);
         }
         // Required type change
         if (ancestorDefinitionData.getRequiredType() != recipientDefinitionData.getRequiredType()
                  && recipientDefinitionData.getRequiredType() != PropertyType.UNDEFINED)
         {
            checkRequiredType(registeredNodeType, recipientDefinitionData, allRecipientDefinition);
         }
         // ValueConstraints
         if (!Arrays.deepEquals(ancestorDefinitionData.getValueConstraints(), recipientDefinitionData
                  .getValueConstraints()))
         {
            checkValueConstraints(registeredNodeType, recipientDefinitionData, allRecipientDefinition);
         }
         // multiple change
         if (ancestorDefinitionData.isMultiple() && !recipientDefinitionData.isMultiple())
         {
            checkIsMultiple(registeredNodeType, recipientDefinitionData, allRecipientDefinition);
         }

      }
View Full Code Here

TOP

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

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.