java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.utils.DuplicateKeyDetector

public final class DuplicateKeyDetector extends Object
Recognizes the failure of a commit refused by a unique index: a record carrying a key that another record already holds, reported by the backend with an ORecordDuplicatedException, which the layers above may have wrapped.
Author:
Luca Frosini (ISTI - CNR)
  • Method Details

    • isDuplicateKey

      public static boolean isDuplicateKey(Throwable throwable)
      Returns whether the given failure, or one of its causes, is a duplicate key.
      Parameters:
      throwable - the failure
      Returns:
      true if a unique index refused the write
    • duplicatedKey

      public static Object duplicatedKey(Throwable throwable)
      Returns the key the unique index refused.
      Parameters:
      throwable - the failure
      Returns:
      the duplicated key, or null if the failure is not a duplicate key