Package org.exoplatform.services.jcr.impl.core

Examples of org.exoplatform.services.jcr.impl.core.SessionDataManager$ItemReferencePool


   /**
    * Is a successor of the merge version
    */
   protected boolean isSuccessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException
   {
      SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();

      PropertyData successorsProperty =
         (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_SUCCESSORS, 0),
            ItemType.PROPERTY);

      if (successorsProperty != null)
      {
         for (ValueData sv : successorsProperty.getValues())
         {
            String sidentifier = ValueDataUtil.getString(sv);

            if (sidentifier.equals(corrVersion.getIdentifier()))
            {
               return true; // got it
            }

            // search in successors of the successor
            NodeData successor = (NodeData)mergeDataManager.getItemData(sidentifier);
            if (successor != null)
            {
               if (isSuccessor(successor, corrVersion))
               {
                  return true;
View Full Code Here


    * @throws RepositoryException
    * @throws IOException
    */
   private void updateVersionedChildNodes(List<String> versionUuids) throws RepositoryException, IOException
   {
      SessionDataManager dataManager = userSession.getTransientNodesManager();

      NodeData versionStorage = (NodeData)dataManager.getItemData(Constants.VERSIONSTORAGE_UUID);

      for (String versionUuid : versionUuids)
      {
         NodeData versionHistoryData =
            (NodeData)dataManager.getItemData(versionStorage, new QPathEntry("", versionUuid, 1), ItemType.NODE);

         PropertyData versionableUuidProp =
            (PropertyData)dataManager.getItemData(versionHistoryData, new QPathEntry(Constants.JCR_VERSIONABLEUUID, 1),
               ItemType.PROPERTY);

         String versionableUuid = ValueDataUtil.getString(versionableUuidProp.getValues().get(0));

         // fetch child versionable node

         NodeData versionedChild = (NodeData)dataManager.getItemData(versionableUuid);

         if (versionedChild != null && versionedChild.getQPath().isDescendantOf(versionableNode.getData().getQPath()))
         {
            // find latest version
            String latestVersionUuid = null;
            for (int versionNumber = 1;; versionNumber++)
            {
               NodeData nodeData =
                  (NodeData)dataManager.getItemData(versionHistoryData, new QPathEntry("", Integer
                     .toString(versionNumber), 1), ItemType.NODE);

               if (nodeData == null)
               {
                  break;
               }
               else
               {
                  latestVersionUuid = nodeData.getIdentifier();
               }
            }

            if (latestVersionUuid == null)
            {
               // fetch root version
               NodeData rootVersion =
                  (NodeData)dataManager.getItemData(versionHistoryData, new QPathEntry(Constants.JCR_ROOTVERSION, 1),
                     ItemType.NODE);
               latestVersionUuid = rootVersion.getIdentifier();
            }

            PropertyData propVersionHistory =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1),
                  ItemType.PROPERTY);
            String prevVerHistoryId = ValueDataUtil.getString(propVersionHistory.getValues().get(0));

            PropertyData propBaseVersion =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_BASEVERSION, 1),
                  ItemType.PROPERTY);

            PropertyData propPredecessors =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_PREDECESSORS, 1),
                  ItemType.PROPERTY);

            TransientPropertyData newVersionHistoryProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_VERSIONHISTORY,
                  PropertyType.REFERENCE, false, new TransientValueData(new Identifier(versionUuid)));

            // jcr:baseVersion
            TransientPropertyData newBaseVersionProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_BASEVERSION,
                  PropertyType.REFERENCE, false, new TransientValueData(new Identifier(latestVersionUuid)));

            // jcr:predecessors
            List<ValueData> predecessorValues = new ArrayList<ValueData>();
            predecessorValues.add(new TransientValueData(new Identifier(latestVersionUuid)));
            TransientPropertyData newPredecessorsProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_PREDECESSORS,
                  PropertyType.REFERENCE, true, predecessorValues);

            //remove previous version of childnode nad update properties
            NodeData prevVersionHistory = (NodeData)dataManager.getItemData(prevVerHistoryId);

            PlainChangesLogImpl changesLog = new PlainChangesLogImpl();
            if (!prevVerHistoryId.equals(versionUuid))
            {
               RemoveVisitor rv = new RemoveVisitor();
View Full Code Here

    * @throws RepositoryException
    * @throws IOException
    */
   private void updateVersionedChildNodes(List<String> versionUuids) throws RepositoryException, IOException
   {
      SessionDataManager dataManager = userSession.getTransientNodesManager();

      NodeData versionStorage = (NodeData)dataManager.getItemData(Constants.VERSIONSTORAGE_UUID);

      for (String versionUuid : versionUuids)
      {
         NodeData versionHistoryData =
            (NodeData)dataManager.getItemData(versionStorage, new QPathEntry("", versionUuid, 1), ItemType.NODE);

         PropertyData versionableUuidProp =
            (PropertyData)dataManager.getItemData(versionHistoryData, new QPathEntry(Constants.JCR_VERSIONABLEUUID, 1),
               ItemType.PROPERTY);

         String versionableUuid = ValueDataConvertor.readString(versionableUuidProp.getValues().get(0));

         // fetch child versionable node

         NodeData versionedChild = (NodeData)dataManager.getItemData(versionableUuid);

         if (versionedChild != null && versionedChild.getQPath().isDescendantOf(versionableNode.getData().getQPath()))
         {
            // find latest version
            String latestVersionUuid = null;
            for (int versionNumber = 1;; versionNumber++)
            {
               NodeData nodeData =
                  (NodeData)dataManager.getItemData(versionHistoryData, new QPathEntry("", Integer
                     .toString(versionNumber), 1), ItemType.NODE);

               if (nodeData == null)
               {
                  break;
               }
               else
               {
                  latestVersionUuid = nodeData.getIdentifier();
               }
            }

            if (latestVersionUuid == null)
            {
               // fetch root version
               NodeData rootVersion =
                  (NodeData)dataManager.getItemData(versionHistoryData, new QPathEntry(Constants.JCR_ROOTVERSION, 1),
                     ItemType.NODE);
               latestVersionUuid = rootVersion.getIdentifier();
            }

            PropertyData propVersionHistory =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1),
                  ItemType.PROPERTY);
            String prevVerHistoryId = ValueDataConvertor.readString(propVersionHistory.getValues().get(0));

            PropertyData propBaseVersion =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_BASEVERSION, 1),
                  ItemType.PROPERTY);

            PropertyData propPredecessors =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_PREDECESSORS, 1),
                  ItemType.PROPERTY);

            TransientPropertyData newVersionHistoryProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_VERSIONHISTORY,
                  PropertyType.REFERENCE, false, new TransientValueData(new Identifier(versionUuid)));

            // jcr:baseVersion
            TransientPropertyData newBaseVersionProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_BASEVERSION,
                  PropertyType.REFERENCE, false, new TransientValueData(new Identifier(latestVersionUuid)));

            // jcr:predecessors
            List<ValueData> predecessorValues = new ArrayList<ValueData>();
            predecessorValues.add(new TransientValueData(new Identifier(latestVersionUuid)));
            TransientPropertyData newPredecessorsProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_PREDECESSORS,
                  PropertyType.REFERENCE, true, predecessorValues);

            //remove previous version of childnode nad update properties
            NodeData prevVersionHistory = (NodeData)dataManager.getItemData(prevVerHistoryId);

            PlainChangesLogImpl changesLog = new PlainChangesLogImpl();
            if (!prevVerHistoryId.equals(versionUuid))
            {
               RemoveVisitor rv = new RemoveVisitor();
View Full Code Here

         {
            // for each child node of n' in D' copy it (and its subtree) to n
            // as a new child node (if an incoming node has the same
            // UUID as a node already existing in this workspace,
            // the already existing node is removed).
            SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
            for (NodeData corrNode : context.getCorrChildNodes())
            {
               NodeData existedSameIdentifier = (NodeData)mergeDataManager.getItemData(corrNode.getIdentifier());
               if (existedSameIdentifier != null)
               {
                  // if an incoming node has the same
                  // UUID as a node already existing in this workspace,
                  // the already existing node is removed
View Full Code Here

            if (corrVersion != null)
            {
               // let v be base version of n.
               // let v' be base version of n'.

               SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();

               PropertyData isCheckedOutProperty =
                  (PropertyData)mergeDataManager.getItemData(mergeNode, new QPathEntry(Constants.JCR_ISCHECKEDOUT, 0),
                     ItemType.PROPERTY);

               try
               {
                  if (!Boolean.valueOf(new String(isCheckedOutProperty.getValues().get(0).getAsByteArray()))
View Full Code Here

      NodeTypeDataManager ntManager = session.getWorkspace().getNodeTypesHolder();
      if (ntManager.isNodeType(Constants.MIX_VERSIONABLE, node.getPrimaryTypeName(), node.getMixinTypeNames()))
      {

         SessionDataManager dmanager = session.getTransientNodesManager();

         PropertyData bvProperty =
            (PropertyData)dmanager.getItemData(node, new QPathEntry(Constants.JCR_BASEVERSION, 0), ItemType.PROPERTY);

         try
         {
            return (NodeData)dmanager.getItemData(new String(bvProperty.getValues().get(0).getAsByteArray()));
         }
         catch (IOException e)
         {
            throw new RepositoryException("Merge. Get base version error " + e.getMessage(), e);
         }
View Full Code Here

   protected NodeData getCorrNodeData(final NodeData mergeNode) throws RepositoryException
   {

      final QPath mergePath = mergeNode.getQPath();

      SessionDataManager corrDataManager = corrSession.getTransientNodesManager();
      SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
      NodeTypeDataManager mergeNtManager = mergeSession.getWorkspace().getNodeTypesHolder();

      if (mergeNtManager.isNodeType(Constants.MIX_REFERENCEABLE, mergeNode.getPrimaryTypeName(),
         mergeNode.getMixinTypeNames()))
      {
         // by UUID
         return (NodeData)corrDataManager.getItemData(mergeNode.getIdentifier());
      }

      // by location
      for (int i = 1; i <= mergePath.getDepth(); i++)
      {
         final QPath ancesstorPath = mergePath.makeAncestorPath(i);
         NodeData mergeAncestor = (NodeData)mergeDataManager.getItemData(ancesstorPath);
         if (mergeAncestor != null
            && mergeNtManager.isNodeType(Constants.MIX_REFERENCEABLE, mergeAncestor.getPrimaryTypeName(),
               mergeAncestor.getMixinTypeNames()))
         {
View Full Code Here

   /**
    * Is a predecessor of the merge version
    */
   protected boolean isPredecessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException
   {
      SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();

      PropertyData predecessorsProperty =
         (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_PREDECESSORS, 0),
            ItemType.PROPERTY);

      if (predecessorsProperty != null)
         for (ValueData pv : predecessorsProperty.getValues())
         {
            try
            {
               String pidentifier = new String(pv.getAsByteArray());

               if (pidentifier.equals(corrVersion.getIdentifier()))
                  return true; // got it

               // search in predecessors of the predecessor
               NodeData predecessor = (NodeData)mergeDataManager.getItemData(pidentifier);
               if (predecessor != null)
               {
                  if (isPredecessor(predecessor, corrVersion))
                  {
                     return true;
View Full Code Here

   /**
    * Is a successor of the merge version
    */
   protected boolean isSuccessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException
   {
      SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();

      PropertyData successorsProperty =
         (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_SUCCESSORS, 0),
            ItemType.PROPERTY);

      if (successorsProperty != null)
         for (ValueData sv : successorsProperty.getValues())
         {
            try
            {
               String sidentifier = new String(sv.getAsByteArray());

               if (sidentifier.equals(corrVersion.getIdentifier()))
                  return true; // got it

               // search in successors of the successor
               NodeData successor = (NodeData)mergeDataManager.getItemData(sidentifier);
               if (successor != null)
               {
                  if (isSuccessor(successor, corrVersion))
                  {
                     return true;
View Full Code Here

         {
            // for each child node of n' in D' copy it (and its subtree) to n
            // as a new child node (if an incoming node has the same
            // UUID as a node already existing in this workspace,
            // the already existing node is removed).
            SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
            for (NodeData corrNode : context.getCorrChildNodes())
            {
               NodeData existedSameIdentifier = (NodeData)mergeDataManager.getItemData(corrNode.getIdentifier());
               if (existedSameIdentifier != null)
               {
                  // if an incoming node has the same
                  // UUID as a node already existing in this workspace,
                  // the already existing node is removed
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.core.SessionDataManager$ItemReferencePool

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.