Package org.exoplatform.services.jcr.impl.storage

Examples of org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException


      {
         String cid = getInternalId(data.getIdentifier());
         // order numb update
         if (updateNodeByIdentifier(data.getPersistedVersion(), data.getQPath().getIndex(), data.getOrderNumber(), cid) <= 0)
         {
            throw new JCRInvalidItemStateException("(update) Node not found " + data.getQPath().getAsString() + " "
               + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
               ItemState.UPDATED);
         }

         if (LOG.isDebugEnabled())
View Full Code Here


      {
         String cid = getInternalId(data.getIdentifier());

         // update type
         if (updatePropertyByIdentifier(data.getPersistedVersion(), data.getType(), cid) <= 0)
            throw new JCRInvalidItemStateException("(update) Property not found " + data.getQPath().getAsString() + " "
               + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
               ItemState.UPDATED);

         // update reference
         try
View Full Code Here

      checkIfOpened();
      try
      {
         if (renameNode(data) <= 0)
         {
            throw new JCRInvalidItemStateException("(rename) Node not found " + data.getQPath().getAsString() + " "
               + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
               ItemState.RENAMED);
         }
      }
      catch (SQLException e)
View Full Code Here

      try
      {
         int nc = deleteItemByIdentifier(cid);
         if (nc <= 0)
         {
            throw new JCRInvalidItemStateException("(delete) Node not found " + data.getQPath().getAsString() + " "
               + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
               ItemState.DELETED);
         }

         if (LOG.isDebugEnabled())
View Full Code Here

         // delete item
         int nc = deleteItemByIdentifier(cid);
         if (nc <= 0)
         {
            throw new JCRInvalidItemStateException("(delete) Property not found " + data.getQPath().getAsString() + " "
               + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
               ItemState.DELETED);
         }

         if (LOG.isDebugEnabled())
View Full Code Here

      {
         String cid = getInternalId(data.getIdentifier());
         // order numb update
         if (updateNodeByIdentifier(data.getPersistedVersion(), data.getQPath().getIndex(), data.getOrderNumber(), cid) <= 0)
         {
            throw new JCRInvalidItemStateException("(update) Node not found " + data.getQPath().getAsString() + " "
               + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
               ItemState.UPDATED);
         }

         if (LOG.isDebugEnabled())
View Full Code Here

      {
         String cid = getInternalId(data.getIdentifier());

         // update type
         if (updatePropertyByIdentifier(data.getPersistedVersion(), data.getType(), cid) <= 0)
            throw new JCRInvalidItemStateException("(update) Property not found " + data.getQPath().getAsString() + " "
               + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
               ItemState.UPDATED);

         // update reference
         try
View Full Code Here

         // try detect error by foreign key names
         String umsg = errMessage.toLowerCase().toUpperCase();
         if (umsg.indexOf(conn.JCR_FK_ITEM_PARENT) >= 0)
         {
            message.append("Parent not found. Item ").append(itemInfo);
            throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
         }
         else if (umsg.indexOf(conn.JCR_PK_ITEM) >= 0)
         {
            message.append("Item already exists. Condition: ID. ").append(itemInfo);
            // InvalidItemStateException ! - because it's impossible add new item with existed UUID
            throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
         }
         else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_NAME) >= 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_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_IDX_ITEM_PARENT) >= 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_FK_VALUE_PROPERTY) >= 0)
         {
            message.append("Property is not exist but the value is being created. Condition: property ID. ").append(
               itemInfo);
            throw new RepositoryException(message.toString(), e);
         }
         else if (umsg.indexOf(conn.JCR_IDX_VALUE_PROPERTY) >= 0)
         {
            message.append("Property already exists. Condition: property ID, order number. ").append(itemInfo);
            throw new RepositoryException(message.toString(), e);
         }
         else if (umsg.indexOf(conn.JCR_PK_VALUE) >= 0)
         {
            message
               .append(
                  "[FATAL] Value already exists with the ValueID. Impossible state, check is ValueID is autoincremented. ")
               .append(itemInfo);
            throw new RepositoryException(message.toString(), e);
         }
         else if (umsg.indexOf(conn.JCR_PK_REF) >= 0)
         {
            message.append("Reference chain already exists. Condition: node ID, property ID, order number. ").append(
               itemInfo);
            throw new RepositoryException(message.toString(), e);
         }
         else if (umsg.indexOf(conn.JCR_IDX_REF_PROPERTY) >= 0)
         {
            message.append("Referenceable property value already exists. Condition: property ID, order number. ")
               .append(itemInfo);
            throw new RepositoryException(message.toString(), e);
         }
      }

      // try detect integrity violation
      RepositoryException ownException = null;
      try
      {
         NodeData parent = (NodeData)conn.getItemData(item.getParentIdentifier());
         if (parent != null)
         {
            // have a parent
            try
            {
               ItemData me = conn.getItemData(item.getIdentifier());
               if (me != null)
               {
                  // item already exists
                  message.append("Item already exists in storage: ").append(itemInfo);
                  ownException = new JCRItemExistsException(message.toString(), me.getIdentifier(), ItemState.ADDED, 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 JCRItemExistsException(message.toString(), me.getIdentifier(), ItemState.ADDED, e);
                  throw ownException;
               }

            }
            catch (Exception ep)
            {
               // item not found or other things but error of item reading
               if (ownException != null)
                  throw ownException;
            }

            // MySQL violation
            if (e.getClass().getName().indexOf("MySQLIntegrityConstraintViolationException") >= 0
               && errMessage.indexOf(item.getIdentifier()) >= 0)
            {
               // it's JCR_PK_ITEM violation
               message.append("Item already exists. Condition: ID. ").append(itemInfo);
               throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
            }

            // DB2 violation
            if (e.getClass().getName().indexOf("SqlIntegrityConstraintViolationException") >= 0
               && errMessage.indexOf("SQLCODE=-803") >= 0)
            {
               message.append("Item already exists.").append(itemInfo);
               throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
            }

            message.append("Error of item add. ").append(itemInfo);
            ownException = new RepositoryException(message.toString(), e);
            throw ownException;
         }
      }
      catch (Exception ep)
      {
         // no parent or error access it
         if (ownException != null)
            throw ownException;
      }
      message.append("Error of item add. ").append(itemInfo);
      throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
   }
View Full Code Here

         // no parent or error access it
         if (ownException != null)
            throw ownException;
      }
      message.append("Error of item add. ").append(itemInfo);
      throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.ADDED, e);
   }
View Full Code Here

         // try detect error by foreign key names
         String umsg = errMessage.toLowerCase().toUpperCase();
         if (umsg.indexOf(conn.JCR_FK_ITEM_PARENT) >= 0)
         {
            message.append("Can not delete parent till childs exists. Item ").append(itemInfo);
            throw new JCRInvalidItemStateException(message.toString(), item.getIdentifier(), ItemState.DELETED, e);
         }
         else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
         {
            message.append("[FATAL] Can not delete property item till it contains values. Condition: property ID. ")
               .append(itemInfo);
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException

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.