* @param ex
* @return
*/
public static DataAccessException translateException(RepositoryException ex) {
if (ex instanceof AccessDeniedException) {
return new DataRetrievalFailureException("Access denied to this data", ex);
}
if (ex instanceof ConstraintViolationException) {
return new DataIntegrityViolationException("Constraint has been violated", ex);
}
if (ex instanceof InvalidItemStateException) {
return new ConcurrencyFailureException("Invalid item state", ex);
}
if (ex instanceof InvalidQueryException) {
return new DataRetrievalFailureException("Invalid query", ex);
}
if (ex instanceof InvalidSerializedDataException) {
return new DataRetrievalFailureException("Invalid serialized data", ex);
}
if (ex instanceof ItemExistsException) {
return new DataIntegrityViolationException("An item already exists", ex);
}
if (ex instanceof ItemNotFoundException) {
return new DataRetrievalFailureException("Item not found", ex);
}
if (ex instanceof LoginException) {
return new DataAccessResourceFailureException("Bad login", ex);
}
if (ex instanceof LockException) {
return new ConcurrencyFailureException("Item is locked", ex);
}
if (ex instanceof MergeException) {
return new DataIntegrityViolationException("Merge failed", ex);
}
if (ex instanceof NamespaceException) {
return new InvalidDataAccessApiUsageException("Namespace not registred", ex);
}
if (ex instanceof NoSuchNodeTypeException) {
return new InvalidDataAccessApiUsageException("No such node type", ex);
}
if (ex instanceof NoSuchWorkspaceException) {
return new DataAccessResourceFailureException("Workspace not found", ex);
}
if (ex instanceof PathNotFoundException) {
return new DataRetrievalFailureException("Path not found", ex);
}
if (ex instanceof ReferentialIntegrityException) {
return new DataIntegrityViolationException("Referential integrity violated", ex);
}
if (ex instanceof UnsupportedRepositoryOperationException) {