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

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


   public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException
   {

      checkValid();

      NodeTypeDataManager nodeTypeDataManager = session.getWorkspace().getNodeTypesHolder();

      // load nodeDatas
      List<NodeTypeData> nodeTypes = new ArrayList<NodeTypeData>();
      nodeTypes.add(nodeTypeDataManager.getNodeType(nodeData().getPrimaryTypeName()));
      InternalQName[] mixinNames = nodeData().getMixinTypeNames();
      for (int i = 0; i < mixinNames.length; i++)
      {
         nodeTypes.add(nodeTypeDataManager.getNodeType(mixinNames[i]));
      }

      // Searching default
      for (NodeTypeData ntData : nodeTypes)
      {
View Full Code Here


    */
   public NodeData getVersionableAncestor() throws RepositoryException
   {
      checkValid();
      NodeData node = nodeData();
      NodeTypeDataManager ntman = session.getWorkspace().getNodeTypesHolder();

      while (node.getParentIdentifier() != null)
      {
         if (ntman.isNodeType(Constants.MIX_VERSIONABLE, node.getPrimaryTypeName(), node.getMixinTypeNames()))
         {
            // mix:versionable has own jcr:isCheckedOut state
            return node;
         }
         else
View Full Code Here

      // create new property data with new values
      TransientPropertyData prop =
         new TransientPropertyData(propData.getQPath(), propData.getIdentifier(), propData.getPersistedVersion(),
            propData.getType(), propData.getParentIdentifier(), propData.isMultiValued(), values);

      NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();

      // remove mix:versionable stuff
      if (ntmanager.isNodeType(Constants.MIX_VERSIONABLE, removedName))
      {
         removeVersionable();
      }

      // remove mix:lockable stuff
      if (ntmanager.isNodeType(Constants.MIX_LOCKABLE, removedName))
      {
         removeLockable();
      }

      // Set mixin property and locally
      updateMixin(newMixin);

      // Remove mixin nt definition node/properties from this node
      QPath ancestorToSave = nodeData().getQPath();

      for (PropertyDefinitionData pd : ntmanager.getAllPropertyDefinitions(removedName))
      {
         // to skip remove propertyDefinition with existed another nodeType property definition
         PropertyDefinitionDatas propertyDefinitions =
            ntmanager.getPropertyDefinitions(pd.getName(), nodeData().getPrimaryTypeName(), newMixin
               .toArray(new InternalQName[]{}));
         if (propertyDefinitions == null || propertyDefinitions.getDefinition(pd.isMultiple()).isResidualSet())
         {
            ItemData p = dataManager.getItemData(nodeData(), new QPathEntry(pd.getName(), 1), ItemType.PROPERTY, false);
            if (p != null && !p.isNode())
            {
               // remove it
               dataManager.delete(p, ancestorToSave);
            }
         }
      }

      for (NodeDefinitionData nd : ntmanager.getAllChildNodeDefinitions(removedName))
      {
         ItemData n = dataManager.getItemData(nodeData(), new QPathEntry(nd.getName(), 1), ItemType.NODE);
         if (n != null && n.isNode())
         {
            // remove node with subtree
View Full Code Here

   public void validateChildNode(InternalQName name, InternalQName primaryTypeName) throws ItemExistsException,
      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

      if (!nodeTypeDataManager.isChildNodePrimaryTypeAllowed(primaryTypeName, nodeData().getPrimaryTypeName(),
         nodeData().getMixinTypeNames()))
      {
         throw new ConstraintViolationException("Can't add node " + sysLocFactory.createJCRName(name).getAsString()
            + " to " + getPath() + " node type " + sysLocFactory.createJCRName(primaryTypeName).getAsString()
            + " is not allowed as child's node type for parent node type ");
View Full Code Here

      // Create new Node
      ItemState state = ItemState.createAddedState(nodeData, false);
      NodeImpl node = (NodeImpl)dataManager.update(state, true);

      NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
      ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, valueFactory, dataManager, true);

      PlainChangesLog changes =
         itemAutocreator.makeAutoCreatedItems(node.nodeData(), primaryTypeName, dataManager, session.getUserID());
      for (ItemState autoCreatedState : changes.getAllStates())
View Full Code Here

    */
   private void init() throws RepositoryException, RepositoryConfigurationException
   {
      List<WorkspaceEntry> wsEntries = config.getWorkspaceEntries();

      NodeTypeDataManager typeManager = (NodeTypeDataManager)this.getComponentInstanceOfType(NodeTypeDataManager.class);
      NamespaceRegistryImpl namespaceRegistry =
         (NamespaceRegistryImpl)this.getComponentInstanceOfType(NamespaceRegistry.class);

      for (WorkspaceEntry ws : wsEntries)
      {
View Full Code Here

    */
   protected void removeVersionable() throws RepositoryException, ConstraintViolationException, VersionException
   {
      if (isNode())
      {
         NodeTypeDataManager ntManager = session.getWorkspace().getNodeTypesHolder();
         NodeData node = (NodeData)data;
         if (ntManager.isNodeType(Constants.MIX_VERSIONABLE, node.getPrimaryTypeName(), node.getMixinTypeNames()))
         {

            ItemData vhpd =
               dataManager.getItemData(node, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1), ItemType.PROPERTY);
            if (vhpd != null && !vhpd.isNode())
View Full Code Here

      PropertyDefinitionDatas defs;
      ItemImpl prevItem =
         dataManager.getItem(parentNode.nodeData(), new QPathEntry(propertyName, 0), true,
            dataManager.isNew(parentNode.getIdentifier()), ItemType.PROPERTY, false);

      NodeTypeDataManager ntm = session.getWorkspace().getNodeTypesHolder();
      NodeData parentData = (NodeData)parentNode.getData();
      boolean isMultiValue = multiValue;
      PropertyImpl prevProperty = null;
      if (prevItem == null || prevItem.isNode())
      { // new property
         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.getPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData.getMixinTypeNames());
         prevProp = null;
         state = ItemState.ADDED;
      }
      else
      {
         // update of the property
         prevProp = (PropertyImpl)prevItem;
         prevProperty = new AuditPropertyImpl(prevProp.getData(), prevProp.getSession());
         isMultiValue = prevProp.isMultiValued();
         defs =
            ntm.getPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData.getMixinTypeNames());

         identifier = prevProp.getInternalIdentifier();
         version = prevProp.getData().getPersistedVersion();
         if (propertyValues == null)
         {
View Full Code Here

      if (isNew())
      {
         throw new RepositoryException("It is impossible to call save() on the newly added item " + getPath());
      }

      NodeTypeDataManager ntManager = session.getWorkspace().getNodeTypesHolder();

      if (isNode())
      {
         // validate
         // 1. referenceable nodes - if a node is deleted and then added,
         // referential integrity is unchanged ('move' usecase)
         QPath path = getInternalPath();
         List<ItemState> changes = dataManager.getChangesLog().getDescendantsChanges(path);

         List<NodeData> refNodes = new ArrayList<NodeData>();

         for (int i = 0, length = changes.size(); i < length; i++)
         {
            ItemState changedItem = changes.get(i);
            if (changedItem.isNode())
            {
               NodeData refNode = (NodeData)changedItem.getData();

               // Check referential integrity (remove of mix:referenceable node)
               if (ntManager.isNodeType(Constants.MIX_REFERENCEABLE, refNode.getPrimaryTypeName(),
                  refNode.getMixinTypeNames()))
               {

                  // mix:referenceable
                  if (changedItem.isDeleted())
View Full Code Here

      InternalQName primaryTypeName = node.getPrimaryTypeName();
      InternalQName[] mixinNames = node.getMixinTypeNames();
      NodeTypeData[] nodeTypes = new NodeTypeData[mixinNames.length + 1];

      NodeTypeDataManager ntm = session.getWorkspace().getNodeTypesHolder();
      nodeTypes[0] = ntm.getNodeType(primaryTypeName);
      for (int i = 1; i <= mixinNames.length; i++)
      {
         nodeTypes[i] = ntm.getNodeType(mixinNames[i - 1]);
      }

      return nodeTypes;
   }
View Full Code Here

TOP

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

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.