Package javax.jcr

Examples of javax.jcr.ItemExistsException


         throw new InvalidItemStateException(e);
      }
      catch (ItemExistsException e)
      {
         remainChangesBack(cLog);
         throw new ItemExistsException(e);
      }
      catch (ReferentialIntegrityException e)
      {
         remainChangesBack(cLog);
         throw new ReferentialIntegrityException(e);
View Full Code Here


      if (!nodedef.isAllowsSameNameSiblings() && ((sameNameNode != null) || (transientAddChilds.size() > 0)))
      {
         if ((sameNameNode != null) && (transientDeletedChilds.size() < 1))
         {
            throw new ItemExistsException("The node  already exists in " + sameNameNode.getQPath().getAsString()
               + " and same name sibling is not allowed ");
         }
         if (transientAddChilds.size() > 0)
         {
            throw new ItemExistsException("The node  already exists in add state "
               + "  and same name sibling is not allowed ");

         }
      }
View Full Code Here

         throw new InvalidItemStateException(e);
      }
      catch (ItemExistsException e)
      {
         remainChangesBack(cLog);
         throw new ItemExistsException(e);
      }
      catch (ReferentialIntegrityException e)
      {
         remainChangesBack(cLog);
         throw new ReferentialIntegrityException(e);
View Full Code Here

            sibling =
               (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind), ItemType.NODE, false);
         }
         else
         {
            throw new ItemExistsException("The node " + nameToAdd + " already exists in " + getPath()
               + " and same name sibling is not allowed ");
         }
      };

      return ind;
View Full Code Here

      if (destNode != null)
      {

         if (!destNode.getDefinition().allowsSameNameSiblings())
         {
            throw new ItemExistsException("A node with name (" + destAbsPath + ") is already exists.");
         }
      }

      ItemDataCopyVisitor initializer =
         new ItemDataCopyVisitor((NodeData)destParentNode.getData(), destNodePath.getName().getInternalName(),
View Full Code Here

      {
         if (!destNode.getDefinition().allowsSameNameSiblings())
         {
            // Throw exception
            String msg = "A node with name (" + destAbsPath + ") is already exists.";
            throw new ItemExistsException(msg);
         }
      }
      NodeImpl srcParentNode = null;
      if (destParentNode.getIdentifier().equals(srcNode.getParentIdentifier()))
      {
View Full Code Here

      {
         if (!destNode.getDefinition().allowsSameNameSiblings())
         {
            // Throw exception
            String msg = "A node with name (" + destAbsPath + ") is already exists.";
            throw new ItemExistsException(msg);
         }
      }

      ItemDataCloneVisitor initializer =
         new ItemDataCloneVisitor((NodeData)destParentNode.getData(), destNodePath.getName().getInternalName(),
View Full Code Here

               changesLog.addAll(((VersionImpl)v).restoreLog(destParent, node.getQPath().getName(), historyHelper,
                  session, removeExisting, changesLog).getAllStates());
            }
            catch (ItemExistsException e)
            {
               throw new ItemExistsException("Workspace restore. Can't restore a node. "
                  + v.getContainingHistory().getVersionableUUID() + ". " + e.getMessage(), e);
            }
            catch (RepositoryException e)
            {
               throw new RepositoryException("Workspace restore. Can't restore a node. "
                  + v.getContainingHistory().getVersionableUUID() + ". Repository error: " + e.getMessage(), e);
            }
         }
         else
         {
            // not found, looking for parent
            // SPEC: For every version V in S that corresponds to a missing node in
            // the workspace, there must also be a parent of V in S
            // =========================================
            // Trying search for corresponding node,
            // If we have a corr node and her parent in the existed list - all ok,
            // otherwise exception will be thrown.
            NodeData corrNode = null;
            String versionableParentIdentifier = null;
            if (!v.getSession().getWorkspace().getName().equals(session.getWorkspace().getName()))
            {
               TransactionableDataManager vDataManager =
                  ((SessionImpl)v.getSession()).getTransientNodesManager().getTransactManager();
               corrNode = (NodeData)vDataManager.getItemData(versionableIdentifier);
               if (corrNode != null)
               {
                  versionableParentIdentifier = corrNode.getParentIdentifier();
               }
               else
               {
                  log.warn("Workspace.restore(). Correspondent node is not found " + versionableIdentifier);
               }
            }
            if (versionableParentIdentifier != null && existedIdentifiers.contains(versionableParentIdentifier))
            {
               notExistedVersions.add((VersionImpl)v);
               continue;
            }

            if (versionableParentIdentifier == null)
            {
               //check in changes log
               ItemState itemState = changesLog.getItemState(versionableIdentifier);
               if (itemState != null && !itemState.isDeleted())
               {
                  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)
         {
            throw new ItemExistsException("Workspace restore. Can't restore a node not existed before. "
               + versionableIdentifier + ". " + e.getMessage(), e);
         }
         catch (RepositoryException e)
         {
            throw new RepositoryException("Workspace restore. Can't restore a node not existed before. "
View Full Code Here

                     changes.addAll(removeVisitor.getRemovedStates());
                  }
                  else
                  {
                     throw new ItemExistsException("Item with the same UUID as restored node " + nodePath.getAsString()
                        + " already exists and removeExisting=false. Existed "
                        + userSession.getLocationFactory().createJCRPath(sameIdentifierPath).getAsString(false) + " "
                        + sameIdentifierNode.getIdentifier());
                  }
               }
View Full Code Here

                        updatingPath.addAll(removeVisitor.getUpdatingPath());
                     }
                  }
                  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());
                  }
View Full Code Here

TOP

Related Classes of javax.jcr.ItemExistsException

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.