Package javax.jcr

Examples of javax.jcr.ItemExistsException


            throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
         }
         else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT) >= 0 || umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_NAME) >= 0)
         {
            message.append("Item already exists. Condition: parent ID, name, index. ").append(itemInfo);
            throw new ItemExistsException(message.toString(), e);
         }
         else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_ID) >= 0)
         {
            message.append("Item already exists. Condition: parent ID and ID. ").append(itemInfo);
            throw new ItemExistsException(message.toString(), e);
         }
         else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
         {
            message.append("Property is not exist but the value is being created. Condition: property ID. ").append(
               itemInfo);
View Full Code Here


               ItemData me = conn.getItemData(item.getIdentifier());
               if (me != null)
               {
                  // item already exists
                  message.append("Item already exists in storage: ").append(itemInfo);
                  ownException = new ItemExistsException(message.toString(), e);
                  throw ownException;
               }

               me =
                  conn.getItemData(parent, new QPathEntry(item.getQPath().getName(), item.getQPath().getIndex()),
                     ItemType.getItemType(item));
               if (me != null)
               {
                  message.append("Item already exists in storage: ").append(itemInfo);
                  ownException = new ItemExistsException(message.toString(), e);
                  throw ownException;
               }

            }
            catch (Exception ep)
View Full Code Here

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

   public void add(NodeData item) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
      IllegalStateException
   {

      if (items.get(new MapKey(item.getQPath(), ItemType.getItemType(item))) != null)
         throw new ItemExistsException("WorkspaceContainerImpl.add(Item) item '" + item.getQPath().getAsString()
            + "' already exists!");

      items.put(new MapKey(item.getQPath(), ItemType.getItemType(item)), item);
      log.debug("InmemoryContainer added node " + item.getQPath().getAsString());
      Iterator props = getChildProperties(item).iterator();
View Full Code Here

      if (destNode != null)
      {
         if (!destNode.getDefinition().allowsSameNameSiblings())
         {
            throw new ItemExistsException("A node with this name (" + destAbsPath + ") is already exists. ");
         }
      }
      NodeImpl srcParentNode = null;
      if (destParentNode.getIdentifier().equals(srcNode.getParentIdentifier()))
      {
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

      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

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.