{"action":"created","comment":{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/comments/61597348","id":61597348,"diff_hunk":"@@ -1,33 +1,64 @@\n package com.stormpath.sdk.servlet.mvc;\n \n import com.stormpath.sdk.account.Account;\n+import com.stormpath.sdk.impl.resource.AbstractResource;\n import com.stormpath.sdk.servlet.account.AccountResolver;\n+import com.stormpath.sdk.servlet.http.UserAgents;\n \n import javax.servlet.http.HttpServletRequest;\n import javax.servlet.http.HttpServletResponse;\n-import java.util.HashMap;\n-import java.util.Map;\n+import java.util.*;\n \n /**\n  * 1.0.RC8\n  */\n public class MeController extends AbstractController {\n \n+    private boolean expandGroups;\n+    private Set<String> accountProperties = new HashSet<String>(Arrays.asList(\"href\", \"username\", \"email\", \"givenName\",\n+            \"middleName\", \"surname\", \"fullName\", \"status\", \"createdAt\", \"modifiedAt\", \"emailVerificationToken\"));\n+\n     @Override\n     public boolean isNotAllowIfAuthenticated() {\n         return false;\n     }\n \n+    public boolean isExpandGroups() {\n+        return expandGroups;\n+    }\n+\n+    public void setExpandGroups(boolean expandGroups) {\n+        this.expandGroups = expandGroups;\n+    }\n+\n     @Override\n     protected ViewModel doGet(HttpServletRequest request, HttpServletResponse response) throws Exception {\n \n         Map<String,Object> model = new HashMap<String, Object>();\n \n         if (AccountResolver.INSTANCE.hasAccount(request)) {\n             Account account = AccountResolver.INSTANCE.getAccount(request);\n-            model.put(\"account\", account);\n+            AbstractResource abstractAccount = (AbstractResource)account;\n+            if (isExpandGroups()){\n+                accountProperties.add(\"groups\");\n+            }\n+            model.put(\"account\", getModel(abstractAccount, accountProperties));\n         }\n \n-        return new DefaultViewModel(\"stormpathJsonView\", model);\n+        if (UserAgents.get(request).isJsonPreferred()) {\n+            return new DefaultViewModel(\"stormpath/me\", model).setRedirect(false);\n+        }\n+\n+        //otherwise HTML view:\n+        return new DefaultViewModel(getNextUri()).setRedirect(true);\n+    }\n+\n+    private Map<String, Object> getModel(AbstractResource abstractResource, Set<String> resourceProperties) {","path":"extensions/servlet/src/main/java/com/stormpath/sdk/servlet/mvc/MeController.java","position":60,"original_position":60,"commit_id":"e7660b9025a7fbcc0a855a41aff0c3580dbfc49b","original_commit_id":"e7660b9025a7fbcc0a855a41aff0c3580dbfc49b","user":{"login":"lhazlewood","id":121180,"avatar_url":"https://avatars.githubusercontent.com/u/121180?v=3","gravatar_id":"","url":"https://api.github.com/users/lhazlewood","html_url":"https://github.com/lhazlewood","followers_url":"https://api.github.com/users/lhazlewood/followers","following_url":"https://api.github.com/users/lhazlewood/following{/other_user}","gists_url":"https://api.github.com/users/lhazlewood/gists{/gist_id}","starred_url":"https://api.github.com/users/lhazlewood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhazlewood/subscriptions","organizations_url":"https://api.github.com/users/lhazlewood/orgs","repos_url":"https://api.github.com/users/lhazlewood/repos","events_url":"https://api.github.com/users/lhazlewood/events{/privacy}","received_events_url":"https://api.github.com/users/lhazlewood/received_events","type":"User","site_admin":false},"body":"Based on the comments above, this should be something like:\r\n\r\n```java\r\nprivate Map<String, Object> getModel(AbstractResource abstractResource) {\r\n    Map<String, Object> result = new HashMap<String, Object>();\r\n    for(String propertyName: abstractResource.getPropertyNames()) {\r\n    Object value = abstractResource.getProperty(propertyName);\r\n    if (!(value instanceof Map.class || value instanceof Collection.class)) {\r\n        result.put(propertyName, value);\r\n    }\r\n    return result;\r\n}\r\n```","created_at":"2016-04-29T15:37:43Z","updated_at":"2016-04-29T15:37:43Z","html_url":"https://github.com/stormpath/stormpath-sdk-java/pull/608#discussion_r61597348","pull_request_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/608","_links":{"self":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/comments/61597348"},"html":{"href":"https://github.com/stormpath/stormpath-sdk-java/pull/608#discussion_r61597348"},"pull_request":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/608"}}},"pull_request":{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/608","id":67971454,"html_url":"https://github.com/stormpath/stormpath-sdk-java/pull/608","diff_url":"https://github.com/stormpath/stormpath-sdk-java/pull/608.diff","patch_url":"https://github.com/stormpath/stormpath-sdk-java/pull/608.patch","issue_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues/608","number":608,"state":"open","locked":false,"title":"585 /me endpoint","user":{"login":"mzumbadoate","id":17259590,"avatar_url":"https://avatars.githubusercontent.com/u/17259590?v=3","gravatar_id":"","url":"https://api.github.com/users/mzumbadoate","html_url":"https://github.com/mzumbadoate","followers_url":"https://api.github.com/users/mzumbadoate/followers","following_url":"https://api.github.com/users/mzumbadoate/following{/other_user}","gists_url":"https://api.github.com/users/mzumbadoate/gists{/gist_id}","starred_url":"https://api.github.com/users/mzumbadoate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzumbadoate/subscriptions","organizations_url":"https://api.github.com/users/mzumbadoate/orgs","repos_url":"https://api.github.com/users/mzumbadoate/repos","events_url":"https://api.github.com/users/mzumbadoate/events{/privacy}","received_events_url":"https://api.github.com/users/mzumbadoate/received_events","type":"User","site_admin":false},"body":"resolves #585","created_at":"2016-04-26T22:55:17Z","updated_at":"2016-04-29T15:37:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca239880242ce1f1474dda71a67f891ea7720b02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/608/commits","review_comments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/608/comments","review_comment_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues/608/comments","statuses_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/statuses/e7660b9025a7fbcc0a855a41aff0c3580dbfc49b","head":{"label":"stormpath:585-with-364-as-base-branch","ref":"585-with-364-as-base-branch","sha":"e7660b9025a7fbcc0a855a41aff0c3580dbfc49b","user":{"login":"stormpath","id":1377453,"avatar_url":"https://avatars.githubusercontent.com/u/1377453?v=3","gravatar_id":"","url":"https://api.github.com/users/stormpath","html_url":"https://github.com/stormpath","followers_url":"https://api.github.com/users/stormpath/followers","following_url":"https://api.github.com/users/stormpath/following{/other_user}","gists_url":"https://api.github.com/users/stormpath/gists{/gist_id}","starred_url":"https://api.github.com/users/stormpath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stormpath/subscriptions","organizations_url":"https://api.github.com/users/stormpath/orgs","repos_url":"https://api.github.com/users/stormpath/repos","events_url":"https://api.github.com/users/stormpath/events{/privacy}","received_events_url":"https://api.github.com/users/stormpath/received_events","type":"Organization","site_admin":false},"repo":{"id":3913468,"name":"stormpath-sdk-java","full_name":"stormpath/stormpath-sdk-java","owner":{"login":"stormpath","id":1377453,"avatar_url":"https://avatars.githubusercontent.com/u/1377453?v=3","gravatar_id":"","url":"https://api.github.com/users/stormpath","html_url":"https://github.com/stormpath","followers_url":"https://api.github.com/users/stormpath/followers","following_url":"https://api.github.com/users/stormpath/following{/other_user}","gists_url":"https://api.github.com/users/stormpath/gists{/gist_id}","starred_url":"https://api.github.com/users/stormpath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stormpath/subscriptions","organizations_url":"https://api.github.com/users/stormpath/orgs","repos_url":"https://api.github.com/users/stormpath/repos","events_url":"https://api.github.com/users/stormpath/events{/privacy}","received_events_url":"https://api.github.com/users/stormpath/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stormpath/stormpath-sdk-java","description":"Official Java SDK for the Stormpath User Management REST API","fork":false,"url":"https://api.github.com/repos/stormpath/stormpath-sdk-java","forks_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/forks","keys_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/teams","hooks_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/hooks","issue_events_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues/events{/number}","events_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/events","assignees_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/assignees{/user}","branches_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/branches{/branch}","tags_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/tags","blobs_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/statuses/{sha}","languages_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/languages","stargazers_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/stargazers","contributors_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/contributors","subscribers_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/subscribers","subscription_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/subscription","commits_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/contents/{+path}","compare_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/merges","archive_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/downloads","issues_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues{/number}","pulls_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls{/number}","milestones_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/milestones{/number}","notifications_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/labels{/name}","releases_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/releases{/id}","deployments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/deployments","created_at":"2012-04-03T01:22:09Z","updated_at":"2016-04-21T10:52:18Z","pushed_at":"2016-04-29T14:29:54Z","git_url":"git://github.com/stormpath/stormpath-sdk-java.git","ssh_url":"git@github.com:stormpath/stormpath-sdk-java.git","clone_url":"https://github.com/stormpath/stormpath-sdk-java.git","svn_url":"https://github.com/stormpath/stormpath-sdk-java","homepage":"","size":14149,"stargazers_count":81,"watchers_count":81,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":70,"mirror_url":null,"open_issues_count":115,"forks":70,"open_issues":115,"watchers":81,"default_branch":"master"}},"base":{"label":"stormpath:364-spa-support","ref":"364-spa-support","sha":"439bc15c8cd9843d932c4801b04e372af7193388","user":{"login":"stormpath","id":1377453,"avatar_url":"https://avatars.githubusercontent.com/u/1377453?v=3","gravatar_id":"","url":"https://api.github.com/users/stormpath","html_url":"https://github.com/stormpath","followers_url":"https://api.github.com/users/stormpath/followers","following_url":"https://api.github.com/users/stormpath/following{/other_user}","gists_url":"https://api.github.com/users/stormpath/gists{/gist_id}","starred_url":"https://api.github.com/users/stormpath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stormpath/subscriptions","organizations_url":"https://api.github.com/users/stormpath/orgs","repos_url":"https://api.github.com/users/stormpath/repos","events_url":"https://api.github.com/users/stormpath/events{/privacy}","received_events_url":"https://api.github.com/users/stormpath/received_events","type":"Organization","site_admin":false},"repo":{"id":3913468,"name":"stormpath-sdk-java","full_name":"stormpath/stormpath-sdk-java","owner":{"login":"stormpath","id":1377453,"avatar_url":"https://avatars.githubusercontent.com/u/1377453?v=3","gravatar_id":"","url":"https://api.github.com/users/stormpath","html_url":"https://github.com/stormpath","followers_url":"https://api.github.com/users/stormpath/followers","following_url":"https://api.github.com/users/stormpath/following{/other_user}","gists_url":"https://api.github.com/users/stormpath/gists{/gist_id}","starred_url":"https://api.github.com/users/stormpath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stormpath/subscriptions","organizations_url":"https://api.github.com/users/stormpath/orgs","repos_url":"https://api.github.com/users/stormpath/repos","events_url":"https://api.github.com/users/stormpath/events{/privacy}","received_events_url":"https://api.github.com/users/stormpath/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stormpath/stormpath-sdk-java","description":"Official Java SDK for the Stormpath User Management REST API","fork":false,"url":"https://api.github.com/repos/stormpath/stormpath-sdk-java","forks_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/forks","keys_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/teams","hooks_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/hooks","issue_events_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues/events{/number}","events_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/events","assignees_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/assignees{/user}","branches_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/branches{/branch}","tags_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/tags","blobs_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/statuses/{sha}","languages_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/languages","stargazers_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/stargazers","contributors_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/contributors","subscribers_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/subscribers","subscription_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/subscription","commits_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/contents/{+path}","compare_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/merges","archive_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/downloads","issues_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues{/number}","pulls_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls{/number}","milestones_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/milestones{/number}","notifications_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/labels{/name}","releases_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/releases{/id}","deployments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-java/deployments","created_at":"2012-04-03T01:22:09Z","updated_at":"2016-04-21T10:52:18Z","pushed_at":"2016-04-29T14:29:54Z","git_url":"git://github.com/stormpath/stormpath-sdk-java.git","ssh_url":"git@github.com:stormpath/stormpath-sdk-java.git","clone_url":"https://github.com/stormpath/stormpath-sdk-java.git","svn_url":"https://github.com/stormpath/stormpath-sdk-java","homepage":"","size":14149,"stargazers_count":81,"watchers_count":81,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":70,"mirror_url":null,"open_issues_count":115,"forks":70,"open_issues":115,"watchers":81,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/608"},"html":{"href":"https://github.com/stormpath/stormpath-sdk-java/pull/608"},"issue":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues/608"},"comments":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/issues/608/comments"},"review_comments":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/608/comments"},"review_comment":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/pulls/608/commits"},"statuses":{"href":"https://api.github.com/repos/stormpath/stormpath-sdk-java/statuses/e7660b9025a7fbcc0a855a41aff0c3580dbfc49b"}}}}