try {
context = new Context();
refreshParams(context);
if (entityExists(ref.getId())) {
return new BitstreamEntity(ref.getId(), context);
}
} catch (SQLException ex) {
throw new EntityException("Internal server error", "SQL error", 500);
} finally {
removeConn(context);