@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("/typepermissions/{username}/{action}") @GET @RunAsAdmin public NameValueList hasTypePermission( @PathParam("username") String username, @PathParam("action") String actionName) { List<FxRole> roles = new ArrayList<>(1); FxRole user = FxRole.loadByName(username, em); roles.add(user); NameValueList mList = new NameValueList(); Action action = ACLHelper.getActionByName(actionName); for (ManagedType<?> t : JpaMetamodelHelper.getMetamodel().getManagedTypes()) { if (permissionChecker.hasPermission(action, roles, t.getJavaType().getSimpleName(), null)) { mList.addPair(t.getJavaType().getSimpleName(), "true"); } else { mList.addPair(t.getJavaType().getSimpleName(), "false"); } } return mList; }