Package javax.jcr.version

Examples of javax.jcr.version.VersionException


         throw new InvalidItemStateException("Node has pending changes " + getPath());
      }

      if (hasProperty(Constants.JCR_MERGEFAILED))
      {
         throw new VersionException("Node has jcr:mergeFailed " + getPath());
      }

      if (!checkLocking())
      {
         throw new LockException("Node " + getPath() + " is locked ");
View Full Code Here


      // when this validation is done.

      // Check if versionable ancestor is not checked-in
      if (!checkedOut())
      {
         throw new VersionException("Node " + getPath() + " or its nearest ancestor is checked-in");
      }

      // Check locking
      if (!checkLocking())
      {
View Full Code Here

         throw new InvalidItemStateException("Session has pending changes ");
      }

      if (((VersionImpl)version).getInternalName().equals(Constants.JCR_ROOTVERSION))
      {
         throw new VersionException("It is illegal to call restore() on jcr:rootVersion");
      }

      if (!versionHistory(false).isVersionBelongToThis(version))
      {
         throw new VersionException("Bad version " + version.getPath());
      }

      // Check locking
      if (!checkLocking())
      {
View Full Code Here

            throw new InvalidItemStateException("Session has pending changes ");
         }

         if (((VersionImpl)version).getInternalName().equals(Constants.JCR_ROOTVERSION))
         {
            throw new VersionException("It is illegal to call restore() on jcr:rootVersion");
         }

         QPath destPath = locationFactory.parseRelPath(relPath).getInternalPath();
         NodeImpl destParent =
            (NodeImpl)dataManager.getItem(nodeData(), destPath.makeParentPath().getEntries(), false, ItemType.NODE);

         if (destParent == null)
         {
            throw new PathNotFoundException("Parent not found for " + relPath);
         }

         if (!destParent.isNode())
         {
            throw new ConstraintViolationException("Parent item is not a node. Rel path " + relPath);
         }

         NodeImpl destNode =
            (NodeImpl)dataManager.getItem(destParent.nodeData(),
               new QPathEntry(destPath.getName(), destPath.getIndex()), false, ItemType.NODE);

         if (destNode != null)
         {
            // Dest node exists

            if (!destNode.isNode())
            {
               throw new ConstraintViolationException("Item at relPath is not a node " + destNode.getPath());
            }

            if (!destNode.isNodeType(Constants.MIX_VERSIONABLE))
            {
               throw new UnsupportedRepositoryOperationException("Node at relPath is not versionable "
                  + destNode.getPath());
            }

            if (!destNode.versionHistory(false).isVersionBelongToThis(version))
            {
               throw new VersionException("Bad version " + version.getPath());
            }

            // Check locking
            if (!destNode.parent().checkLocking())
            {
               throw new LockException("Node " + destNode.getPath() + " is locked ");
            }
         }
         else
         {
            // Dest node not found
            if (!destParent.checkedOut())
            {
               throw new VersionException("Parent of a node at relPath is versionable and checked-in "
                  + destParent.getPath());
            }
         }

         ((VersionImpl)version).restore(session, destParent.nodeData(), destPath.getName(), removeExisting);
View Full Code Here

      }

      // Check if versionable ancestor is not checked-in
      if (!checkedOut())
      {
         throw new VersionException("Node " + getPath() + " or its nearest ancestor is checked-in");
      }

      if (!checkLocking())
      {
         // Check locking
View Full Code Here

         throw new ItemNotFoundException(getPath() + " has no child node with name " + destPath.getName().getAsString());
      }

      if (!checkedOut())
      {
         throw new VersionException(" cannot change child node ordering of a checked-in node ");
      }

      if (destPath != null && srcPath.getDepth() != destPath.getDepth())
      {
         throw new ItemNotFoundException("Source and destenation is not relative paths of depth one, "
View Full Code Here

      session.checkLive();
      NodeImpl node = (NodeImpl)session.getItem(parentAbsPath);
      // checked-in check
      if (!node.checkedOut())
      {
         throw new VersionException("Node " + node.getPath() + " or its nearest ancestor is checked-in");
      }

      // Check if node is not protected
      if (node.getDefinition().isProtected())
      {
View Full Code Here

      session.checkLive();

      NodeImpl node = (NodeImpl)session.getItem(parentAbsPath);
      if (!node.checkedOut())
      {
         throw new VersionException("Node " + node.getPath() + " or its nearest ancestor is checked-in");
      }

      // Check if node is not protected
      if (node.getDefinition().isProtected())
      {
View Full Code Here

         srcParentNode = srcNode.parent();
      }
      // Check if versionable ancestor is not checked-in
      if (!srcParentNode.checkedOut())
      {
         throw new VersionException("Source parent node " + srcNode.getPath()
            + " or its nearest ancestor is checked-in");
      }
      // Check locking
      if (!srcNode.checkLocking())
      {
View Full Code Here

                  notExistedVersions.add((VersionImpl)v);
                  continue;
               }
            }

            throw new VersionException(
               "No such node (for version, from the array of versions, "
                  + "that corresponds to a missing node in the workspace, there must also be a parent in the array). UUID: "
                  + versionableIdentifier);

         }
      }

      for (VersionImpl v : notExistedVersions)
      {
         String versionableIdentifier = v.getContainingHistory().getVersionableUUID();
         try
         {
            NodeData node = null;
            for (ItemState change : changesLog.getAllStates())
            {
               if (change.isNode() && change.isAdded()
                  && ((NodeData)change.getData()).getIdentifier().equals(versionableIdentifier))
               {
                  node = (NodeData)change.getData();
                  break;
               }
            }
            if (node != null)
            {
               NodeData destParent = (NodeData)dataManager.getItemData(node.getParentIdentifier());
               // version parent it's a VH
               NodeData vh = (NodeData)dataManager.getItemData(v.getParentIdentifier());
               VersionHistoryDataHelper historyHelper = new VersionHistoryDataHelper(vh, dataManager, nodeTypeManager);

               changesLog.addAll(v.restoreLog(destParent, node.getQPath().getName(), historyHelper, session,
                  removeExisting, changesLog).getAllStates());
            }
            else
            {
               throw new VersionException("No such node restored before (for version, from the array of versions, "
                  + "that corresponds to a missing node in the workspace, "
                  + "there must also be a parent in the array). UUID: " + versionableIdentifier);
            }
         }
         catch (ItemExistsException e)
View Full Code Here

TOP

Related Classes of javax.jcr.version.VersionException

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.