@Path("/permissions/{username}/{typename}/{id}") @GET @RunAsAdmin public NameValueList hasPermission( @PathParam("username") String username, @PathParam("typename") String typename, @PathParam("id") long id) { List<FxRole> roles = new ArrayList<>(1); FxRole user = FxRole.loadByName(username, em); roles.add(user); NameValueList mList = new NameValueList(); FleximsDynamicEntityImpl entity = null; if (id != 0) { entity = dao.loadEntity(typename, id); } for (Action action : ACLHelper.getAvailableActions()) { if (permissionChecker.hasPermission(action, roles, typename, entity)) { mList.addPair(action.getName(), "true"); } else { mList.addPair(action.getName(), "false"); } } return mList; }
@Path("/allactions") @GET public NameValueList allActions() { NameValueList mList = new NameValueList(); for (Action action : ACLHelper.getAvailableActions()) { mList.addPair(action.getName(), action.getDescription()); } return mList; }