Add exception handler

This commit is contained in:
Martin Stockhammer 2016-10-25 15:53:59 +02:00
parent 45b429e778
commit b6a3d01360
1 changed files with 12 additions and 4 deletions

View File

@ -373,10 +373,18 @@ public class JpaRbacManager extends AbstractRBACManager {
@Override
public List<UserAssignment> getUserAssignmentsForRoles(Collection<String> roleNames) throws RbacManagerException {
final EntityManager em = getEm();
Query q = em.createQuery("SELECT ua FROM JpaUserAssignment ua, ua.roleNames rn WHERE rn IN :rolenames");
q.setParameter("rolenames",roleNames);
return q.getResultList();
try {
final EntityManager em = getEm();
Query q = em.createQuery("SELECT ua FROM JpaUserAssignment ua WHERE ua.roleNames IN :roles");
q.setParameter("roles", roleNames);
return q.getResultList();
} catch (Exception ex) {
log.error("Query failed: {}",ex.getMessage(),ex);
if (log.isDebugEnabled()) {
ex.printStackTrace();
}
throw new RbacManagerException(ex.getMessage(),ex);
}
}
@Transactional