Examples of QPathEntry


Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

         VersionHistoryDataHelper childHistory = null;
         try
         {

            String vhIdentifier =
               new String(((PropertyData)dataManager.getItemData(frozen, new QPathEntry(
                  Constants.JCR_CHILDVERSIONHISTORY, 0), ItemType.PROPERTY)).getValues().get(0).getAsByteArray());

            NodeData cHistory = null;
            if ((cHistory = (NodeData)dataManager.getItemData(vhIdentifier)) == null)
               throw new RepositoryException("Version history is not found with uuid " + vhIdentifier);

            childHistory = new VersionHistoryDataHelper(cHistory, dataManager, nodeTypeDataManager);
         }
         catch (IllegalStateException e)
         {
            throw new RepositoryException("jcr:childVersionHistory, error of data read "
               + userSession.getLocationFactory().createJCRPath(cvhpPropPath).getAsString(false), e);
         }
         catch (IOException e)
         {
            throw new RepositoryException("jcr:childVersionHistory, error of data read "
               + userSession.getLocationFactory().createJCRPath(cvhpPropPath).getAsString(false), e);
         }

         String versionableIdentifier = null;
         try
         {
            versionableIdentifier =
               new String(((PropertyData)dataManager.getItemData(childHistory, new QPathEntry(
                  Constants.JCR_VERSIONABLEUUID, 0), ItemType.PROPERTY)).getValues().get(0).getAsByteArray());

         }
         catch (IOException e)
         {
            throw new RepositoryException("jcr:childVersionHistory, error of data read "
               + userSession.getLocationFactory().createJCRPath(cvhpPropPath).getAsString(false), e);
         }

         NodeData versionable = (NodeData)dataManager.getItemData(versionableIdentifier);
         if (versionable != null)
         {
            // exists,
            // On restore of VN, if the workspace currently has an already
            // existing node corresponding to C’s version history and the
            // removeExisting flag of the restore is set to true, then that
            // instance of C becomes the child of the restored N.
            if (!removeExisting)
            {
               throw new ItemExistsException("Item with the same UUID " + versionableIdentifier
                  + " as versionable child node "
                  + userSession.getLocationFactory().createJCRPath(versionable.getQPath()).getAsString(false)
                  + " already exists and removeExisting=false");
            }
            // else - leaving existed unchanged
         }
         else
         {
            // not found, gets last version (by time of creation) and restore it
            NodeData lastVersionData = childHistory.getLastVersionData();
            NodeData cvFrozen =
               (NodeData)dataManager.getItemData(lastVersionData, new QPathEntry(Constants.JCR_FROZENNODE, 1),
                  ItemType.NODE);

            ItemDataRestoreVisitor restoreVisitor =
               new ItemDataRestoreVisitor(currentNode(), qname, childHistory, userSession, removeExisting, changes);
            cvFrozen.accept(restoreVisitor);
            changes.addAll(restoreVisitor.getRestoreChanges().getAllStates());
         }
         pushCurrent(null); // skip any childs of that node
      }
      else if (currentNode() != null)
      {
         // ordinary node for copy under nt:frozenNode
         // [PN] 10.04.06 In case of COPY - copy node, otherwise we don't
         // 8.2.11.3 INITIALIZE; 8.2.11.4 COMPUTE
         // On restore of VN, the C stored as its child will be ignored, and the
         // current C in the workspace will be left unchanged.

         int action =
            nodeTypeDataManager.getChildNodeDefinition(qname, frozen.getPrimaryTypeName(),
               currentNode().getPrimaryTypeName(),
               currentNode().getMixinTypeNames()).getOnParentVersion();

         if (log.isDebugEnabled())
         {
            log.debug("Stored node " + frozen.getQPath().getAsString() + ", "
               + OnParentVersionAction.nameFromValue(action));
         }

         if (action == OnParentVersionAction.COPY || action == OnParentVersionAction.VERSION)
         {
            // copy
            QPath restoredPath =
               QPath.makeChildPath(currentNode().getQPath(), frozen.getQPath().getName(), frozen.getQPath().getIndex());

            // jcr:uuid
            String jcrUuid = null;
            NodeData existing = null;
            if (nodeTypeDataManager.isNodeType(Constants.MIX_REFERENCEABLE, frozen.getPrimaryTypeName(), frozen
               .getMixinTypeNames()))
            {
               // copy uuid from frozen state of mix:referenceable,
               // NOTE: mix:referenceable stored in frozen state with genereted ID
               // (JCR_XITEM PK) as UUID must be unique,
               // but jcr:uuid property containts real UUID.
               QPath jcrUuidPath = QPath.makeChildPath(frozen.getQPath(), Constants.JCR_UUID);
               try
               {
                  jcrUuid =
                     new String(((PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_UUID, 0),
                        ItemType.PROPERTY)).getValues().get(0).getAsByteArray());

               }
               catch (IOException e)
               {
                  throw new RepositoryException("jcr:uuid, error of data read "
                     + userSession.getLocationFactory().createJCRPath(jcrUuidPath).getAsString(false), e);
               }
               existing = (NodeData)dataManager.getItemData(jcrUuid);
            }
            else
            {
               // try to use existing node uuid, otherwise to generate one new
               existing =
                  (NodeData)dataManager.getItemData(currentNode(), new QPathEntry(frozen.getQPath().getName(), frozen
                     .getQPath().getIndex()), ItemType.NODE);
               if (existing != null)
               {
                  jcrUuid = existing.getIdentifier();
               }
               else
               {
                  jcrUuid = IdGenerator.generate();
               }
            }

            if (existing != null && !existing.getQPath().isDescendantOf(restored.getQPath()))
            {
               NodeData existingDelegared = (NodeData)findDelegated(existing.getQPath());
               if (existingDelegared != null)
               {
                  // was restored by previous restore (Workspace.restore(...)), remove
                  // it from delegated log
                  deleteDelegated(existing.getQPath());
               }
               else
               {
                  // exists in workspace
                  if (removeExisting)
                  {
                     // remove existed node, with validation (same as for restored
                     // root)
                     ItemDataRemoveVisitor removeVisitor = new RemoveVisitor();
                     removeVisitor.visit(existing);

                     changes.addAll(removeVisitor.getRemovedStates());
                  }
                  else
                  {
                     throw new ItemExistsException("Node with the same UUID as restored child node "
                        + userSession.getLocationFactory().createJCRPath(restoredPath).getAsString(false)
                        + " already exists and removeExisting=false. Existed "
                        + userSession.getLocationFactory().createJCRPath(existing.getQPath()).getAsString(false) + " "
                        + existing.getIdentifier());
                  }
               }
            }

            AccessControlList acl = currentNode().getACL();

            boolean isPrivilegeable =
               nodeTypeDataManager.isNodeType(Constants.EXO_PRIVILEGEABLE, frozen.getPrimaryTypeName(),
                  frozen.getMixinTypeNames());

            boolean isOwneable =
               nodeTypeDataManager.isNodeType(Constants.EXO_OWNEABLE, frozen.getPrimaryTypeName(),
                  frozen.getMixinTypeNames());

            if (isPrivilegeable || isOwneable)
            {
               List<AccessControlEntry> permissionEntries = new ArrayList<AccessControlEntry>();
               permissionEntries.addAll((isPrivilegeable ? frozen.getACL() : currentNode().getACL())
                  .getPermissionEntries());

               String owner = isOwneable ? frozen.getACL().getOwner() : currentNode().getACL().getOwner();

               acl = new AccessControlList(owner, permissionEntries);
            }

            NodeData restoredData =
               new TransientNodeData(restoredPath, jcrUuid, frozen.getPersistedVersion(), frozen.getPrimaryTypeName(),
                  frozen.getMixinTypeNames(), frozen.getOrderNumber(), currentNode().getIdentifier(), acl);

            changes.add(ItemState.createAddedState(restoredData));
            pushCurrent(restoredData);
         }
         else if (action == OnParentVersionAction.INITIALIZE || action == OnParentVersionAction.COMPUTE)
         {
            // current C in the workspace will be left unchanged,
            NodeData existed =
               (NodeData)dataManager.getItemData(currentNode(), new QPathEntry(frozen.getQPath().getName(), 0),
                  ItemType.NODE);

            if (existed != null)
            {
               // copy existed - i.e. left unchanged
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

         final QPathEntry[] path = node.getQPath().getEntries();
         final QPathEntry[] siblingPath = new QPathEntry[path.length];
         final int li = path.length - 1;
         System.arraycopy(path, 0, siblingPath, 0, li);

         siblingPath[li] = new QPathEntry(path[li], path[li].getIndex() - 1);

         if (addedNodes.contains(new QPath(siblingPath)))
         {
            // current changes log has the older same-name sibling
            return;
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

    * Check if same-name sibling exists in persistence.
    */
   private void checkPersistedSNS(NodeData node, WorkspaceStorageConnection acon) throws RepositoryException
   {
      NodeData parent = (NodeData)acon.getItemData(node.getParentIdentifier());
      QPathEntry myName = node.getQPath().getEntries()[node.getQPath().getEntries().length - 1];
      ItemData sibling =
         acon.getItemData(parent, new QPathEntry(myName.getNamespace(), myName.getName(), myName.getIndex() - 1),
            ItemType.NODE);

      if (sibling == null || !sibling.isNode())
      {
         throw new InvalidItemStateException("Node can't be saved " + node.getQPath().getAsString()
            + ". No same-name sibling exists with index " + (myName.getIndex() - 1) + ".");
      }
   }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

      destParentNode.validateChildNode(destNodePath.getName().getInternalName(),
         ((NodeTypeImpl)srcNode.getPrimaryNodeType()).getQName());

      // Check for node with destAbsPath name in session
      NodeImpl destNode =
         (NodeImpl)dataManager.getItem((NodeData)destParentNode.getData(), new QPathEntry(destNodePath
            .getInternalPath().getName(), 0), false, ItemType.NODE);

      if (destNode != null)
      {
         if (!destNode.getDefinition().allowsSameNameSiblings())
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

            PropertyData pt =
               TransientPropertyData.createPropertyData(frozenNode, Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
                  false, new TransientValueData(Constants.NT_VERSIONEDCHILD));

            ValueData vh =
               ((PropertyData)dataManager.getItemData(node, new QPathEntry(Constants.JCR_VERSIONHISTORY, 0),
                  ItemType.PROPERTY)).getValues().get(0);

            PropertyData pd =
               TransientPropertyData.createPropertyData(frozenNode, Constants.JCR_CHILDVERSIONHISTORY,
                  PropertyType.REFERENCE, false, vh);
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

      List<ItemState> changes = new ArrayList<ItemState>();

      NodeData parentNodeData = (NodeData)dataManager.getItemData(cause.getParentIdentifier());

      NodeData nextSibling =
         (NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(cause.getQPath().getName(), cause.getQPath()
            .getIndex() + 1), ItemType.NODE);

      String reindexedId = null;
      // repeat till next sibling exists and it's not a caused Node (deleted or moved to) or just
      // reindexed
      while (nextSibling != null && !nextSibling.getIdentifier().equals(cause.getIdentifier())
         && !nextSibling.getIdentifier().equals(reindexedId))
      {
         // update with new index
         QPath siblingPath =
            QPath.makeChildPath(nextSibling.getQPath().makeParentPath(), nextSibling.getQPath().getName(), nextSibling
               .getQPath().getIndex() - 1);

         NodeData reindexed =
            new TransientNodeData(siblingPath, nextSibling.getIdentifier(), nextSibling.getPersistedVersion(),
               nextSibling.getPrimaryTypeName(), nextSibling.getMixinTypeNames(), nextSibling.getOrderNumber(),
               nextSibling.getParentIdentifier(), nextSibling.getACL());

         reindexedId = reindexed.getIdentifier();

         ItemState reindexedState = ItemState.createUpdatedState(reindexed);
         changes.add(reindexedState);

         // reload pooled implies... it's actual for session and workspace scope
         // operations
         // TODO this operation must respect all sub-tree of reindexed node
         // http://jira.exoplatform.org/browse/JCR-340
         itemsPool.reload(reindexed);

         // next...
         nextSibling =
            (NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(nextSibling.getQPath().getName(),
               nextSibling.getQPath().getIndex() + 1), ItemType.NODE);
      }

      return changes;
   }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

      Collection<ItemDefinitionData> mandatoryItemDefs =
         session.getWorkspace().getNodeTypesHolder()
            .getManadatoryItemDefs(nData.getPrimaryTypeName(), nData.getMixinTypeNames());
      for (ItemDefinitionData itemDefinitionData : mandatoryItemDefs)
      {
         if (getItemData(nData, new QPathEntry(itemDefinitionData.getName(), 0), ItemType.UNKNOWN) == null)
         {
            throw new ConstraintViolationException("Mandatory item " + itemDefinitionData.getName()
               + " not found. Node [" + nData.getQPath().getAsString() + " primary type: "
               + nData.getPrimaryTypeName().getAsString() + "]");
         }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

      NodeData vancestor = getVersionableAncestor();
      if (vancestor != null)
      {
         PropertyData isCheckedOut =
            (PropertyData)dataManager.getItemData(vancestor, new QPathEntry(Constants.JCR_ISCHECKEDOUT, 1),
               ItemType.PROPERTY);
         try
         {
            return ValueDataConvertor.readBoolean(isCheckedOut.getValues().get(0));
         }
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

      changesLog.add(ItemState.createUpdatedState(updatePropertyData(Constants.JCR_ISCHECKEDOUT,
         new TransientValueData(true))));

      ValueData baseVersion =
         ((PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_BASEVERSION, 0),
            ItemType.PROPERTY)).getValues().get(0);

      changesLog.add(ItemState.createUpdatedState(updatePropertyData(Constants.JCR_PREDECESSORS, baseVersion)));

      dataManager.getTransactManager().save(changesLog);
View Full Code Here

Examples of org.exoplatform.services.jcr.datamodel.QPathEntry

      }
      newMixin.add(type.getName());
      values.add(new TransientValueData(type.getName()));

      PropertyData prop =
         (PropertyData)dataManager.getItemData(((NodeData)getData()), new QPathEntry(Constants.JCR_MIXINTYPES, 0),
            ItemType.PROPERTY);
      ItemState state;

      if (prop != null)
      {// there was mixin prop
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.