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

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


      RepositoryException, ConstraintViolationException, VersionException, LockException
   {

      // Check if nodeType exists and not mixin
      NodeTypeDataManager nodeTypeDataManager = session.getWorkspace().getNodeTypesHolder();
      NodeTypeData nodeType = nodeTypeDataManager.getNodeType(primaryTypeName);
      if (nodeType == null)
      {
         throw new NoSuchNodeTypeException("Nodetype not found "
            + sysLocFactory.createJCRName(primaryTypeName).getAsString());
      }

      if (nodeType.isMixin())
      {
         throw new ConstraintViolationException("Add Node failed, "
            + sysLocFactory.createJCRName(primaryTypeName).getAsString() + " is MIXIN type!");
      }
View Full Code Here


         else
         {
            name = mixinTypes[i];
         }

         final NodeTypeData nt = this.nodeTypeRepository.getNodeType(name);

         if (nt != null)
         {
            if (nt.hasOrderableChildNodes())
            {
               return true;
            }

            final Set<InternalQName> supers = this.nodeTypeRepository.getSupertypes(nt.getName());
            for (final InternalQName suName : supers)
            {
               final NodeTypeData su = this.nodeTypeRepository.getNodeType(suName);
               if (su != null && su.hasOrderableChildNodes())
               {
                  return true;
               }
            }
         }
View Full Code Here

   public PlainChangesLog setPrimaryType(final NodeData nodeData, final InternalQName nodeTypeName)
      throws RepositoryException
   {
      final PlainChangesLog changesLog = new PlainChangesLogImpl();

      final NodeTypeData ancestorDefinition = getNodeType(nodeData.getPrimaryTypeName());
      final NodeTypeData recipientDefinition = getNodeType(nodeTypeName);

      InternalQName[] ancestorAllNodeTypeNames = null;
      if (nodeData.getMixinTypeNames() == null || nodeData.getMixinTypeNames().length == 0)
      {
         ancestorAllNodeTypeNames = new InternalQName[]{nodeData.getPrimaryTypeName()};
      }
      else
      {
         ancestorAllNodeTypeNames = new InternalQName[nodeData.getMixinTypeNames().length + 1];
         ancestorAllNodeTypeNames[0] = nodeData.getPrimaryTypeName();
         System.arraycopy(nodeData.getMixinTypeNames(), 0, ancestorAllNodeTypeNames, 1,
            nodeData.getMixinTypeNames().length);
      }
      InternalQName[] recipienAllNodeTypeNames = null;
      if (nodeData.getMixinTypeNames() == null || nodeData.getMixinTypeNames().length == 0)
      {
         recipienAllNodeTypeNames = new InternalQName[]{nodeTypeName};
      }
      else
      {
         recipienAllNodeTypeNames = new InternalQName[nodeData.getMixinTypeNames().length + 1];
         recipienAllNodeTypeNames[0] = nodeTypeName;
         System.arraycopy(nodeData.getMixinTypeNames(), 0, recipienAllNodeTypeNames, 1,
            nodeData.getMixinTypeNames().length);
      }

      final boolean recipientsMixVersionable = isNodeType(Constants.MIX_VERSIONABLE, recipienAllNodeTypeNames);
      final boolean ancestorIsMixVersionable = isNodeType(Constants.MIX_VERSIONABLE, ancestorAllNodeTypeNames);

      ItemAutocreator itemAutocreator = new ItemAutocreator(this, valueFactory, dataManager, false);
      if (recipientsMixVersionable && !ancestorIsMixVersionable)
      {

         changesLog.addAll(itemAutocreator.makeMixVesionableChanges(nodeData).getAllStates());
      }
      else if (!recipientsMixVersionable && ancestorIsMixVersionable)
      {

         final StringBuffer buffer = new StringBuffer();
         buffer.append("Fail to change  node type from ");
         buffer.append(ancestorDefinition.getName().getAsString());
         buffer.append(" to ");
         buffer.append(recipientDefinition.getName().getAsString());
         buffer.append(" because change from  mix:versionable = true ");
         buffer.append(" to mix:versionable = false is not alowed");

         throw new ConstraintViolationException(buffer.toString());
      }
View Full Code Here

    * @see #unregisterNodeTypes(Collection)
    */
   public void unregisterNodeType(final InternalQName nodeTypeName) throws RepositoryException
   {

      final NodeTypeData nodeType = this.nodeTypeRepository.getNodeType(nodeTypeName);
      if (nodeType == null)
      {
         throw new NoSuchNodeTypeException(nodeTypeName.getAsString());
      }
      // check build in
View Full Code Here

         NodeData parent = getParent();

         NodeDefinitionData nodeNt =
            nodeTypeDataManager.getChildNodeDefinition(nodeName, parent.getPrimaryTypeName(), parent
               .getMixinTypeNames());
         NodeTypeData nodeType;
         if (nodeNt.getName().equals(Constants.JCR_ANY_NAME) && nodeNt.getDefaultPrimaryType() != null)
         {
            nodeType = nodeTypeDataManager.getNodeType(nodeNt.getDefaultPrimaryType());
         }
         else
         {
            nodeType = nodeTypeDataManager.getNodeType(nodeNt.getName());
         }

         if (nodeType == null)
            throw new ConstraintViolationException("Can not define node-type for node " + nodeName.getAsString()
               + ", parent node type " + parent.getPrimaryTypeName().getAsString());

         nodeTypes.add(nodeType);
         props.put(Constants.JCR_PRIMARYTYPE, locationFactory.createJCRName(nodeType.getName()).getAsString());
      }

      if (atts != null)
      {
         for (String key : atts.keySet())
         {

            String attValue = atts.get(key);

            String propName = ISO9075.decode(key);
            if (log.isDebugEnabled())
            {
               log.debug(propName + ":" + attValue);
            }
            InternalQName propInternalQName = locationFactory.parseJCRName(propName).getInternalName();

            if (Constants.JCR_PRIMARYTYPE.equals(propInternalQName))
            {
               String primaryNodeType = StringConverter.denormalizeString(attValue);
               InternalQName ntName = locationFactory.parseJCRName(primaryNodeType).getInternalName();
               NodeTypeData nodeType = nodeTypeDataManager.getNodeType(ntName);
               if (nodeType == null)
                  throw new ConstraintViolationException("Can not find node type " + primaryNodeType);
               nodeTypes.add(nodeType);
               props.put(propInternalQName, primaryNodeType);
            }
            else if (Constants.JCR_MIXINTYPES.equals(propInternalQName))
            {
               String[] amTypes = attValue.split(" ");
               for (int mi = 0; mi < amTypes.length; mi++)
               {
                  amTypes[mi] = StringConverter.denormalizeString(amTypes[mi]);
                  InternalQName name = locationFactory.parseJCRName(amTypes[mi]).getInternalName();
                  mixinNodeTypes.add(name);
                  NodeTypeData nodeType = nodeTypeDataManager.getNodeType(name);
                  if (nodeType == null)
                     throw new ConstraintViolationException("Can not find node type " + amTypes[mi]);

                  nodeTypes.add(nodeType);
               }
View Full Code Here

    * @param volatileNodeTypes
    * @return
    */
   public NodeTypeData getNodeType(final InternalQName nodeTypeName, Map<InternalQName, NodeTypeData> volatileNodeTypes)
   {
      NodeTypeData nt = volatileNodeTypes.get(nodeTypeName);
      if (nt == null)
      {
         final NodeTypeHolder nth = nodeTypes.get(nodeTypeName);
         nt = nth != null ? nth.nodeType : null;
      }
View Full Code Here

         {
            if (list.contains(su))
               continue;
            list.add(su);

            NodeTypeData volatileSuper = volatileNodeTypes.get(su);
            NodeTypeHolder ntSuper = nodeTypes.get(su);
            if (volatileSuper == null && ntSuper == null)
            {
               throw new RepositoryException("Node type " + su.getAsString() + " not found");
            }
            if (volatileSuper != null)
            {

               mergeAllSupertypes(list, volatileSuper.getDeclaredSupertypeNames(), volatileNodeTypes);

            }
            else
            {
               mergeAllSupertypes(list, ntSuper.superTypes.toArray(new InternalQName[ntSuper.superTypes.size()]),
View Full Code Here

   // JSR-170 stuff ================================

   public NodeType findNodeType(InternalQName nodeTypeName) throws NoSuchNodeTypeException, RepositoryException
   {

      NodeTypeData ntdata = typesManager.getNodeType(nodeTypeName);
      if (ntdata != null)
         return new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory);

      throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName.getAsString());
   }
View Full Code Here

   /**
    * {@inheritDoc}
    */
   public NodeType getNodeType(final String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException
   {
      NodeTypeData ntdata = typesManager.getNodeType(locationFactory.parseJCRName(nodeTypeName).getInternalName());
      if (ntdata != null)
         return new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory);

      throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName);
   }
View Full Code Here

   /**
    * {@inheritDoc}
    */
   public NodeTypeValue getNodeTypeValue(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException
   {
      NodeTypeData ntdata = typesManager.getNodeType(locationFactory.parseJCRName(nodeTypeName).getInternalName());
      if (ntdata != null)
      {
         NodeTypeValue nodeTypeValue = new NodeTypeValue();
         nodeTypeValue.setMixin(ntdata.isMixin());
         nodeTypeValue.setName(locationFactory.createJCRName(ntdata.getName()).getAsString());
         nodeTypeValue.setOrderableChild(ntdata.hasOrderableChildNodes());
         if (ntdata.getPrimaryItemName() == null)
         {
            nodeTypeValue.setPrimaryItemName("");
         }
         else
         {
            nodeTypeValue.setPrimaryItemName(locationFactory.createJCRName(ntdata.getPrimaryItemName()).getAsString());
         }
         List<String> declaredSupertypeNames = new ArrayList<String>();
         for (int i = 0; i < ntdata.getDeclaredSupertypeNames().length; i++)
         {
            declaredSupertypeNames.add(locationFactory.createJCRName(ntdata.getDeclaredSupertypeNames()[i])
               .getAsString());
         }
         List<PropertyDefinitionValue> declaredPropertyDefinitionValues = new ArrayList<PropertyDefinitionValue>();

         for (int i = 0; i < ntdata.getDeclaredPropertyDefinitions().length; i++)
         {
            declaredPropertyDefinitionValues.add(convert(ntdata.getDeclaredPropertyDefinitions()[i]));
         }

         List<NodeDefinitionValue> declaredChildNodeDefinitionValues = new ArrayList<NodeDefinitionValue>();

         for (int i = 0; i < ntdata.getDeclaredChildNodeDefinitions().length; i++)
         {
            declaredChildNodeDefinitionValues.add(convert(ntdata.getDeclaredChildNodeDefinitions()[i]));
         }

         nodeTypeValue.setDeclaredSupertypeNames(declaredSupertypeNames);
         nodeTypeValue.setDeclaredPropertyDefinitionValues(declaredPropertyDefinitionValues);
         nodeTypeValue.setDeclaredChildNodeDefinitionValues(declaredChildNodeDefinitionValues);
View Full Code Here

TOP

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

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.