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

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


      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())
            LOG.debug("Node deleted " + data.getQPath().getAsString() + ", " + data.getIdentifier() + ", "
View Full Code Here


         deleteReference(cid);

         // 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())
            LOG.debug("Property deleted "
View Full Code Here

      try
      {
         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())
            LOG.debug("Node updated " + data.getQPath().getAsString() + ", " + data.getIdentifier() + ", "
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 += "Parent not found. Item " + itemInfo;
            throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.ADDED, e);
         }
         else if (umsg.indexOf(conn.JCR_PK_ITEM) >= 0)
         {
            message += "Item already exists. Condition: ID. " + itemInfo;
            // InvalidItemStateException ! - because it's impossible add new item with existed UUID
            throw new JCRInvalidItemStateException(message, 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 += "Item already exists. Condition: parent ID, name, index. " + itemInfo;
            throw new ItemExistsException(message, e);
         }
         else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_ID) >= 0)
         {
            message += "Item already exists. Condition: parent ID and ID. " + itemInfo;
            throw new ItemExistsException(message, e);
         }
         else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
         {
            message += "Property is not exist but the value is being created. Condition: property ID. " + itemInfo;
            throw new RepositoryException(message, e);
         }
         else if (umsg.indexOf(conn.JCR_IDX_VALUE_PROPERTY) >= 0)
         {
            message += "Property already exists. Condition: property ID, order number. " + itemInfo;
            throw new RepositoryException(message, e);
         }
         else if (umsg.indexOf(conn.JCR_PK_VALUE) >= 0)
         {
            message +=
                     "[FATAL] Value already exists with the ValueID. Impossible state, check is ValueID is autoincremented. "
                              + itemInfo;
            throw new RepositoryException(message, e);
         }
         else if (umsg.indexOf(conn.JCR_PK_REF) >= 0)
         {
            message += "Reference chain already exists. Condition: node ID, property ID, order number. " + itemInfo;
            throw new RepositoryException(message, e);
         }
         else if (umsg.indexOf(conn.JCR_IDX_REF_PROPERTY) >= 0)
         {
            message += "Referenceable property value already exists. Condition: property ID, order number. " + itemInfo;
            throw new RepositoryException(message, 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 += "Item already exists in storage: " + itemInfo;
                  ownException = new ItemExistsException(message, e);
                  throw ownException;
               }

               me = conn.getItemData(parent, new QPathEntry(item.getQPath().getName(), item.getQPath().getIndex()));
               if (me != null)
               {
                  message += "Item already exists in storage: " + itemInfo;
                  ownException = new ItemExistsException(message, 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 += "Item already exists. Condition: ID. " + itemInfo;
               throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.ADDED, e);
            }

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

         // no parent or error access it
         if (ownException != null)
            throw ownException;
      }
      message += "Error of item add. " + itemInfo;
      throw new JCRInvalidItemStateException(message, 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 += "Can not delete parent till childs exists. Item " + itemInfo;
            throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.DELETED, e);
         }
         else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
         {
            message +=
                     "[FATAL] Can not delete property item till it contains values. Condition: property ID. "
View Full Code Here

            throw new RepositoryException(message, e);
         }
         else if (errMessage.toLowerCase().toUpperCase().indexOf(conn.JCR_PK_ITEM) >= 0)
         {
            message += "Item already exists. Condition: ID. " + itemInfo;
            throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.UPDATED, e);
         }

      // try detect integrity violation
      RepositoryException ownException = null;
      try
      {
         ItemData me = conn.getItemData(item.getIdentifier());
         if (me != null)
         {
            // item already exists
            message += "Item already exists. But update errors. " + itemInfo;
            ownException = new RepositoryException(message, e);
            throw ownException;
         }
      }
      catch (Exception ep)
      {
         // item not found or other things but error of item reading
         if (ownException != null)
            throw ownException;
      }
      message += "Error of item update. " + itemInfo;
      throw new JCRInvalidItemStateException(message, item.getIdentifier(), ItemState.UPDATED, e);
   }
View Full Code Here

         }
        
         // then 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
View Full Code Here

                     ItemData data = getCurrentItem(currentChange, i, FAKE_NODE);
                     if (data == FAKE_NODE) //NOSONAR
                     {
                        throw new RepositoryException("Current item cannot be found");                          
                     }
                     throw new JCRInvalidItemStateException("(delete) " + (data.isNode() ? "Node" : "Property")+ " not found "
                        + data.getQPath().getAsString() + " " + data.getIdentifier()
                        + ". Probably was deleted by another session ", data.getIdentifier(), ItemState.DELETED);
                  }
               }
            }
            // Update commands
            if ((currentChangeStatus & TYPE_UPDATE_REFERENCE) > 0)
            {
               currentChange = TYPE_UPDATE_REFERENCE;
               updateReference.executeBatch();
            }
            if ((currentChangeStatus & TYPE_UPDATE_VALUE) > 0)
            {
               currentChange = TYPE_UPDATE_VALUE;
               updateValue.executeBatch();
            }
            if ((currentChangeStatus & TYPE_UPDATE_PROPERTY) > 0)
            {
               currentChange = TYPE_UPDATE_PROPERTY;
               int[] results = updateProperty.executeBatch();
               for (int i = 0; i < results.length; i++)
               {
                  if (results[i] == 0)
                  {
                     ItemData data = getCurrentItem(currentChange, i, FAKE_PROPERTY);
                     if (data == FAKE_PROPERTY) //NOSONAR
                     {
                        throw new RepositoryException("Current item cannot be found");                          
                     }
                     throw new JCRInvalidItemStateException("(update) Property not found " + data.getQPath().getAsString() + " "
                              + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
                              ItemState.UPDATED);
                  }
               }
            }
            if ((currentChangeStatus & TYPE_UPDATE_NODE) > 0)
            {
               currentChange = TYPE_UPDATE_NODE;
               int[] results = updateNode.executeBatch();
               for (int i = 0; i < results.length; i++)
               {
                  if (results[i] == 0)
                  {
                     ItemData data = getCurrentItem(currentChange, i, FAKE_NODE);
                     if (data == FAKE_NODE) //NOSONAR
                     {
                        throw new RepositoryException("Current item cannot be found");                          
                     }
                     throw new JCRInvalidItemStateException("(update) Node not found " + data.getQPath().getAsString() + " "
                              + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
                              ItemState.UPDATED);
                  }
               }
            }
            // Rename commands
            if ((currentChangeStatus & TYPE_RENAME_NODE) > 0)
            {
               currentChange = TYPE_RENAME_NODE;
               int[] results = renameNode.executeBatch();
               for (int i = 0; i < results.length; i++)
               {
                  if (results[i] == 0)
                  {
                     ItemData data = getCurrentItem(currentChange, i, FAKE_NODE);
                     if (data == FAKE_NODE) //NOSONAR
                     {
                        throw new RepositoryException("Current item cannot be found");                          
                     }
                     throw new JCRInvalidItemStateException("(rename) Node not found " + data.getQPath().getAsString() + " "
                              + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
                              ItemState.RENAMED);
                  }
               }
            }
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.