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

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


            LOG.warn("Node already of mixin type " + mixinName + " " + getPath());
            return;
         }
      }

      NodeTypeData type = session.getWorkspace().getNodeTypesHolder().getNodeType(name);

      // Mixin or not
      if (type == null || !type.isMixin())
         throw new NoSuchNodeTypeException("Nodetype " + mixinName + " not found or not mixin type.");

      // Validate
      if (session.getWorkspace().getNodeTypesHolder().isNodeType(type.getName(), nodeData().getPrimaryTypeName(),
         nodeData().getMixinTypeNames()))
         throw new ConstraintViolationException("Can not add mixin type " + mixinName + " to " + getPath());

      if (definition.isProtected())
         throw new ConstraintViolationException("Can not add mixin type. Node is protected " + getPath());
View Full Code Here


   public boolean canAddMixin(String mixinName) throws RepositoryException
   {

      checkValid();

      NodeTypeData type =
         session.getWorkspace().getNodeTypesHolder().getNodeType(
            locationFactory.parseJCRName(mixinName).getInternalName());

      if (type == null)
         throw new NoSuchNodeTypeException("Nodetype not found (mixin) " + mixinName);

      if (session.getWorkspace().getNodeTypesHolder().isNodeType(type.getName(), nodeData().getPrimaryTypeName(),
         nodeData().getMixinTypeNames()))
         return false;

      if (definition.isProtected())
         return false;
View Full Code Here

      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!");

      // Check if new node's node type is allowed by its parent definition
View Full Code Here

      NodeType[] supers = new NodeType[snames.length];

      for (int i = 0; i < snames.length; i++)
      {
         NodeTypeData superNodeTypeData = nodeTypeDataManager.getNodeType(snames[i]);
         supers[i] =
            new NodeTypeImpl(superNodeTypeData, nodeTypeDataManager, nodeTypeManager, locationFactory, valueFactory);
      }

      return supers;
View Full Code Here

   public PlainChangesLog makeAutoCreatedItems(final NodeData parent, final InternalQName nodeTypeName,
      final ItemDataConsumer targetDataManager, final String owner) throws RepositoryException
   {
      final PlainChangesLogImpl changes = new PlainChangesLogImpl();
      final NodeTypeData type = nodeTypeDataManager.getNodeType(nodeTypeName);

      changes.addAll(makeAutoCreatedProperties(parent, nodeTypeName,
         nodeTypeDataManager.getAllPropertyDefinitions(nodeTypeName), targetDataManager, owner).getAllStates());
      // Add autocreated child nodes
      changes.addAll(makeAutoCreatedNodes(parent, nodeTypeName,
         nodeTypeDataManager.getAllChildNodeDefinitions(nodeTypeName), targetDataManager, owner).getAllStates());

      // versionable
      if (nodeTypeDataManager.isNodeType(Constants.MIX_VERSIONABLE, new InternalQName[]{type.getName()}))
      {

         // using VH helper as for one new VH, all changes in changes log
         changes.addAll(makeMixVesionableChanges(parent).getAllStates());
      }
View Full Code Here

         NodeData parent = getParent();

         NodeDefinitionData nodeNt =
                  nodeTypeDataManager.findChildNodeDefinition(nodeName, parent.getPrimaryTypeName(), parent
                           .getMixinTypeNames());
         NodeTypeData nodeType;
         if (nodeNt.getName().equals(Constants.JCR_ANY_NAME) && nodeNt.getDefaultPrimaryType() != null)
         {
            nodeType = nodeTypeDataManager.findNodeType(nodeNt.getDefaultPrimaryType());
         }
         else
         {
            nodeType = nodeTypeDataManager.findNodeType(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.findNodeType(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.findNodeType(name);
                  if (nodeType == null)
                     throw new ConstraintViolationException("Can not find node type " + amTypes[mi]);

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

      NodeTypeDataManager ntManager = ((ExtendedWorkspace)userSession.getWorkspace()).getNodeTypesHolder();
      LocationFactory locationFactory = userSession.getLocationFactory();
      for (int i = 0; i < criteria.getNodeTypeName().length; i++)
      {
         InternalQName name = locationFactory.parseJCRName(criteria.getNodeTypeName()[i]).getInternalName();
         NodeTypeData criteriaNT = ntManager.getNodeType(name);
         InternalQName[] testQNames;
         if (criteriaNT == null)
         {
            LOG.warn("The nodetype '{}' defined in the criteria of the listener is unknown.", criteria.getNodeTypeName()[i]);
            continue;
         }
         else if (criteriaNT.isMixin())
         {
            testQNames = node.getMixinTypeNames();
         }
         else
         {
            testQNames = new InternalQName[1];
            testQNames[0] = node.getPrimaryTypeName();
         }
         if (ntManager.isNodeType(criteriaNT.getName(), testQNames))
         {
            return true;
         }
      }
      return false;
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

   public PlainChangesLog makeAutoCreatedItems(NodeData parent, InternalQName nodeTypeName,
            ItemDataConsumer dataManager, String owner) throws RepositoryException
   {
      PlainChangesLogImpl changes = new PlainChangesLogImpl();
      NodeTypeData type = findNodeType(nodeTypeName);

      changes.addAll(makeAutoCreatedProperties(parent, nodeTypeName, getAllPropertyDefinitions(nodeTypeName),
               dataManager, owner).getAllStates());
      changes.addAll(makeAutoCreatedNodes(parent, nodeTypeName, getAllChildNodeDefinitions(nodeTypeName), dataManager,
               owner).getAllStates());

      // Add autocreated child nodes

      // versionable
      if (isNodeType(Constants.MIX_VERSIONABLE, new InternalQName[]
      {type.getName()}))
      {

         // using VH helper as for one new VH, all changes in changes log
         makeMixVesionableChanges(parent, dataManager, changes);
      }
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.