use of org.jowidgets.cap.common.api.exception.ForeignKeyConstraintViolationException in project jo-client-platform by jo-source.
the class HibernateOracleExceptionDecoratorImpl method decorate.
@Override
public Throwable decorate(final Throwable original) {
if (original instanceof PersistenceException) {
final PersistenceException persistenceException = (PersistenceException) original;
final Throwable cause = persistenceException.getCause();
if (cause instanceof ConstraintViolationException) {
final String constraintName = getConstraintName((ConstraintViolationException) cause);
if (!EmptyCheck.isEmpty(constraintName)) {
final ConstraintType constraintType = getConstraintType(constraintName);
if (constraintType == ConstraintType.FK) {
return new ForeignKeyConstraintViolationException();
} else if (constraintType != ConstraintType.UNSUPPORTED) {
final List<String> properties = getViolatedProperties(constraintName, constraintType);
if (!EmptyCheck.isEmpty(properties)) {
return new UniqueConstraintViolationException(properties);
}
}
}
}
}
return original;
}
Aggregations