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

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


      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,
               dataManager);
      }
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

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

      NodeTypeDataManager ntManager = 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.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

         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

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.