/** * If any cause in the given exception chain is an APIAuthenticationException, rethrow that * * @param thrown */ public static void rethrowAPIAuthenticationException(Throwable thrown) { rethrowIfCause(thrown, APIAuthenticationException.class); }
/** * @see SerializedObjectDAO#convertSerializedObject(Class, SerializedObject) */ @Override @SuppressWarnings("unchecked") public <T extends OpenmrsObject> T convertSerializedObject(Class<T> clazz, SerializedObject serializedObject) throws DAOException { if (serializedObject == null) { return null; } OpenmrsSerializer serializer = getSerializer(serializedObject); T obj; try { Class<?> subtype = Context.loadClass(serializedObject.getSubtype()); obj = (T) serializer.deserialize(serializedObject.getSerializedData(), subtype); } catch (Exception e) { ExceptionUtil.rethrowAPIAuthenticationException(e); throw new DAOException("Unable to deserialize object: " + serializedObject, e); } if (obj == null) { // it's probably impossible to reach this code branch throw new DAOException("Unable to deserialize object: " + serializedObject); } obj.setId(serializedObject.getId()); obj.setUuid(serializedObject.getUuid()); return obj; }
ExceptionUtil.rethrowIfCause(ex, NullPointerException.class); ExceptionUtil.rethrowIfCause(ex, IllegalArgumentException.class); ExceptionUtil.rethrowIfCause(ex, IllegalStateException.class);