}
}
//helper method for requestAccess
private boolean createDbRequest(Long requestedHealthrecordId) {
HealthrecordRequest request = null;
try {
request = new HealthrecordRequest(requestedHealthrecordId.intValue(), getLocalUser().getUserId().intValue());
}
catch (Exception ex){
throw new WebApplicationException(Response.Status.PRECONDITION_FAILED);
}
//persist request here via EM
PersistenceService persistenceSvc = PersistenceService.getInstance();
try {
persistenceSvc.beginTx();
EntityManager em = persistenceSvc.getEntityManager();
request = em.merge(request);
persistenceSvc.commitTx();
} catch (Exception ex) {
//ignored
} finally {
persistenceSvc.close();
}
return (request.getRequestId() > 0);
}