@RequestMapping(method = RequestMethod.GET, produces = MimeTypeUtils.APPLICATION_JSON_VALUE) public String listResourceSets(Model m, Authentication auth) { ensureOAuthScope(auth, SystemScopeService.UMA_PROTECTION_SCOPE); String owner = auth.getName(); Collection<ResourceSet> resourceSets = Collections.emptySet(); if (auth instanceof OAuth2Authentication) { // if it's an OAuth mediated call, it's on behalf of a client, so look that up too OAuth2Authentication o2a = (OAuth2Authentication) auth; resourceSets = resourceSetService.getAllForOwnerAndClient(owner, o2a.getOAuth2Request().getClientId()); } else { // otherwise get everything for the current user resourceSets = resourceSetService.getAllForOwner(owner); } // build the entity here and send to the display Set<String> ids = new HashSet<>(); for (ResourceSet resourceSet : resourceSets) { ids.add( resourceSet .getId() .toString()); // add them all as strings so that gson renders them properly } m.addAttribute(JsonEntityView.ENTITY, ids); return JsonEntityView.VIEWNAME; }