/** * @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; }