@PreAuthorize("hasRole('" + StandardEntitlement.ROLE_UPDATE + "')") public RoleTO update(final RoleTO roleTO) { Role role = roleDAO.find(roleTO.getKey()); if (role == null) { LOG.error("Could not find role '" + roleTO.getKey() + "'"); throw new NotFoundException(roleTO.getKey()); } return binder.getRoleTO(binder.update(role, roleTO)); }
@PreAuthorize("hasRole('" + StandardEntitlement.ROLE_READ + "')") @Transactional(readOnly = true) public RoleTO read(final String key) { Role role = roleDAO.find(key); if (role == null) { LOG.error("Could not find role '" + key + "'"); throw new NotFoundException(key); } return binder.getRoleTO(role); }
@PreAuthorize("hasRole('" + StandardEntitlement.ROLE_DELETE + "')") public RoleTO delete(final String key) { Role role = roleDAO.find(key); if (role == null) { LOG.error("Could not find role '" + key + "'"); throw new NotFoundException(key); } RoleTO deleted = binder.getRoleTO(role); roleDAO.delete(key); return deleted; }
@Override protected RoleTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException { String key = null; if (ArrayUtils.isNotEmpty(args)) { for (int i = 0; key == null && i < args.length; i++) { if (args[i] instanceof String) { key = (String) args[i]; } else if (args[i] instanceof RoleTO) { key = ((RoleTO) args[i]).getKey(); } } } if (key != null) { try { return binder.getRoleTO(roleDAO.find(key)); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); } }