public ServiceResults executeServiceRequest( UriInfo ui, ApiResponse response, ServiceAction action, ServicePayload payload) throws Exception { logger.debug("ServiceResource.executeServiceRequest"); boolean tree = "true".equalsIgnoreCase(ui.getQueryParameters().getFirst("tree")); boolean collectionGet = false; if (action == ServiceAction.GET) { collectionGet = (getServiceParameters().size() == 1 && InflectionUtils.isPlural(getServiceParameters().get(0))) ? true : false; } addQueryParams(getServiceParameters(), ui); ServiceRequest r = services.newRequest(action, tree, getServiceParameters(), payload); response.setServiceRequest(r); ServiceResults results = r.execute(); if (results != null) { if (results.hasData()) { response.setData(results.getData()); } if (results.getServiceMetadata() != null) { response.setMetadata(results.getServiceMetadata()); } Query query = r.getLastQuery(); if (query != null) { query = new Query(query); query.setIdsOnly(false); if (query.hasSelectSubjects()) { response.setList(query.getSelectionResults(results)); response.setCount(response.getList().size()); response.setNext(results.getNextResult()); response.setPath(results.getPath()); return results; } } if (collectionGet) { response.setCount(results.size()); } response.setResults(results); } httpServletRequest.setAttribute("applicationId", services.getApplicationId()); return results; }
@RequireAdminUserAccess @GET public JSONWithPadding getUserData( @Context UriInfo ui, @QueryParam("ttl") long ttl, @QueryParam("callback") @DefaultValue("callback") String callback) throws Exception { ApiResponse response = createApiResponse(); response.setAction("get admin user"); String token = management.getAccessTokenForAdminUser(SubjectUtils.getUser().getUuid(), ttl); Map<String, Object> userOrganizationData = management.getAdminUserOrganizationData(user.getUuid()); userOrganizationData.put("token", token); response.setData(userOrganizationData); response.setSuccess(); return new JSONWithPadding(response, callback); }