private AuthResult byPreferredEmail(final HttpServletResponse rsp, final String email) { try { final ReviewDb db = schema.open(); try { List<Account> matches = db.accounts().byPreferredEmail(email).toList(); return matches.size() == 1 ? auth(matches.get(0)) : null; } finally { db.close(); } } catch (OrmException e) { getServletContext().log("cannot query database", e); return null; } }
private AuthResult byAccountId(final HttpServletResponse rsp, final String idStr) { final Account.Id id; try { id = Account.Id.parse(idStr); } catch (NumberFormatException nfe) { return null; } try { final ReviewDb db = schema.open(); try { return auth(db.accounts().get(id)); } finally { db.close(); } } catch (OrmException e) { getServletContext().log("cannot query database", e); return null; } }