String[] emails = (String[]) parameters.get("email");
String email = emails[0];
if (email == null || email.length() == 0) {
UserReportableException error = new UserReportableException(
"Must provide an email in the request URL", PersonDetailPage.class);
setResponsePage(new ErrorReportPage(error));
}
person = SimalRepositoryFactory.getPersonService().findBySha1Sum(RDFUtils.getSHA1(email));
} else {
UserReportableException error = new UserReportableException(
"URL does not have sufficient parameters for finding a unique person", PersonDetailPage.class);
setResponsePage(new ErrorReportPage(error));
}
if (person == null) {
setResponsePage(new PersonListPage());
} else {
populatePage(person);
}
} catch (SimalRepositoryException e) {
UserReportableException error = new UserReportableException(
"Unable to get person from the repository", PersonDetailPage.class,
e);
setResponsePage(new ErrorReportPage(error));
} catch (NoSuchAlgorithmException e) {
UserReportableException error = new UserReportableException(
"Unable to calculate SHA1 has for email", PersonDetailPage.class,
e);
setResponsePage(new ErrorReportPage(error));
}
}