{"action":"created","comment":{"url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/comments/68620203","id":68620203,"diff_hunk":"@@ -0,0 +1,252 @@\n+package org.wso2.carbon.device.mgt.iot.common.api;\n+\n+import org.wso2.carbon.device.mgt.common.Device;\n+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;\n+import org.wso2.carbon.device.mgt.group.common.Group;\n+import org.wso2.carbon.device.mgt.group.common.GroupManagementException;\n+import org.wso2.carbon.device.mgt.iot.common.GroupManagement;\n+import org.wso2.carbon.user.core.Permission;\n+\n+import javax.ws.rs.*;\n+import java.util.Date;\n+import java.util.List;\n+\n+public class GroupManagerService {\n+\n+    @Path(\"/group\")\n+    @POST\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public boolean addGroup(@FormParam(\"name\") String name, @FormParam(\"username\") String username, @FormParam(\"description\") String description) {\n+        Group group = new Group();\n+        group.setName(name);\n+        group.setDescription(description);\n+        group.setOwnerId(username);\n+        group.setDateOfCreation(new Date().getTime());\n+        group.setDateOfLastUpdate(new Date().getTime());\n+        try {\n+            return new GroupManagement().getGroupManagementService().createGroup(group);\n+        } catch (GroupManagementException e) {\n+            e.printStackTrace();\n+            return false;\n+        }\n+    }\n+\n+    @Path(\"/group/id/{groupId}\")\n+    @PUT\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public boolean updateGroup(@PathParam(\"groupId\") int groupId, @FormParam(\"name\") String name, @FormParam(\"username\") String username, @FormParam(\"description\") String description) {\n+        Group group = new Group();\n+        group.setId(groupId);\n+        group.setName(name);\n+        group.setDescription(description);\n+        group.setOwnerId(username);\n+        group.setDateOfLastUpdate(new Date().getTime());\n+        try {\n+            new GroupManagement().getGroupManagementService().updateGroup(group);\n+            return true;\n+        } catch (GroupManagementException e) {\n+            e.printStackTrace();\n+            return false;\n+        }\n+    }\n+\n+    @Path(\"/group/id/{groupId}\")\n+    @DELETE\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public boolean deleteGroup(@PathParam(\"groupId\") int groupId, @FormParam(\"username\") String username) {\n+        try {\n+            return new GroupManagement().getGroupManagementService().deleteGroup(groupId);\n+        } catch (GroupManagementException e) {\n+            e.printStackTrace();\n+            return false;\n+        }\n+    }\n+\n+    @Path(\"/group/id/{groupId}\")\n+    @GET\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public Group getGroup(@PathParam(\"groupId\") int groupId, @FormParam(\"username\") String username) {\n+        try {\n+            return new GroupManagement().getGroupManagementService().getGroupById(groupId);\n+        } catch (GroupManagementException e) {\n+            e.printStackTrace();\n+            return null;\n+        }\n+    }\n+\n+    @Path(\"/group/name/{groupName}\")\n+    @GET\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public Group getGroupByName(@PathParam(\"groupName\") String groupName, @FormParam(\"username\") String username) {\n+        try {\n+            return new GroupManagement().getGroupManagementService().getGroupByName(groupName);\n+        } catch (GroupManagementException e) {\n+            e.printStackTrace();\n+            return null;\n+        }\n+    }\n+\n+    @Path(\"/group/all\")\n+    @GET\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public Group[] getGroupsOfUser(@FormParam(\"username\") String username) {\n+        try {\n+            List<Group> groups = new GroupManagement().getGroupManagementService().getGroupListOfUser(username);\n+            Group[] groupArray = new Group[groups.size()];\n+            return groups.toArray(groupArray);\n+        } catch (GroupManagementException e) {\n+            e.printStackTrace();\n+            return null;\n+        }\n+    }\n+\n+    @Path(\"/group/all/count\")\n+    @GET\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public int getGroupCountOfUser(@FormParam(\"username\") String username) {\n+        try {\n+            return new GroupManagement().getGroupManagementService().getGroupCountOfUser(username);\n+        } catch (GroupManagementException e) {\n+            e.printStackTrace();\n+            return 0;\n+        }\n+    }\n+\n+    @Path(\"/group/id/{groupId}/share\")\n+    @POST\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public boolean shareGroup(@FormParam(\"username\") String username, @FormParam(\"shareUser\") String shareUser, @PathParam(\"groupId\") int groupId, @FormParam(\"role\") String sharingRole) {\n+        try {\n+            return new GroupManagement().getGroupManagementService().shareGroup(shareUser, groupId, sharingRole);\n+        } catch (GroupManagementException e) {\n+            e.printStackTrace();\n+            return false;\n+        }\n+    }\n+\n+    @Path(\"/group/id/{groupId}/unshare\")\n+    @POST\n+    @Consumes(\"application/json\")\n+    @Produces(\"application/json\")\n+    public boolean unShareGroup(@FormParam(\"username\") String username, @FormParam(\"unShareUser\") String unShareUser, @PathParam(\"groupId\") int groupId, @FormParam(\"role\") String sharingRole) {","path":"components/devicecloud-api/org.wso2.carbon.device.mgt.iot.common.api/src/main/java/org/wso2/carbon/device/mgt/iot/common/api/GroupManagerService.java","position":139,"original_position":139,"commit_id":"281582d160020003ae654489af8dffc1990bfe25","original_commit_id":"281582d160020003ae654489af8dffc1990bfe25","user":{"login":"charithag","id":3184302,"avatar_url":"https://avatars.githubusercontent.com/u/3184302?v=3","gravatar_id":"","url":"https://api.github.com/users/charithag","html_url":"https://github.com/charithag","followers_url":"https://api.github.com/users/charithag/followers","following_url":"https://api.github.com/users/charithag/following{/other_user}","gists_url":"https://api.github.com/users/charithag/gists{/gist_id}","starred_url":"https://api.github.com/users/charithag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charithag/subscriptions","organizations_url":"https://api.github.com/users/charithag/orgs","repos_url":"https://api.github.com/users/charithag/repos","events_url":"https://api.github.com/users/charithag/events{/privacy}","received_events_url":"https://api.github.com/users/charithag/received_events","type":"User","site_admin":false},"body":"Ack, Already done in latest repository. Code moved to https://github.com/wso2/carbon-device-mgt","created_at":"2016-06-27T17:33:46Z","updated_at":"2016-06-27T17:33:46Z","html_url":"https://github.com/wso2-incubator/iot-server-extensions/pull/2#discussion_r68620203","pull_request_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/comments/68620203"},"html":{"href":"https://github.com/wso2-incubator/iot-server-extensions/pull/2#discussion_r68620203"},"pull_request":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/2","id":40848410,"html_url":"https://github.com/wso2-incubator/iot-server-extensions/pull/2","diff_url":"https://github.com/wso2-incubator/iot-server-extensions/pull/2.diff","patch_url":"https://github.com/wso2-incubator/iot-server-extensions/pull/2.patch","issue_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/issues/2","number":2,"state":"closed","locked":false,"title":"Add Grouping","user":{"login":"charithag","id":3184302,"avatar_url":"https://avatars.githubusercontent.com/u/3184302?v=3","gravatar_id":"","url":"https://api.github.com/users/charithag","html_url":"https://github.com/charithag","followers_url":"https://api.github.com/users/charithag/followers","following_url":"https://api.github.com/users/charithag/following{/other_user}","gists_url":"https://api.github.com/users/charithag/gists{/gist_id}","starred_url":"https://api.github.com/users/charithag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charithag/subscriptions","organizations_url":"https://api.github.com/users/charithag/orgs","repos_url":"https://api.github.com/users/charithag/repos","events_url":"https://api.github.com/users/charithag/events{/privacy}","received_events_url":"https://api.github.com/users/charithag/received_events","type":"User","site_admin":false},"body":"Add functionalities for grouping","created_at":"2015-07-26T05:42:20Z","updated_at":"2016-06-27T17:33:46Z","closed_at":"2015-07-26T06:46:32Z","merged_at":"2015-07-26T06:46:32Z","merge_commit_sha":"fca05e1aeb18461da99334200515430904888a69","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/2/commits","review_comments_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/2/comments","review_comment_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/issues/2/comments","statuses_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/statuses/281582d160020003ae654489af8dffc1990bfe25","head":{"label":"charithag:master","ref":"master","sha":"281582d160020003ae654489af8dffc1990bfe25","user":{"login":"charithag","id":3184302,"avatar_url":"https://avatars.githubusercontent.com/u/3184302?v=3","gravatar_id":"","url":"https://api.github.com/users/charithag","html_url":"https://github.com/charithag","followers_url":"https://api.github.com/users/charithag/followers","following_url":"https://api.github.com/users/charithag/following{/other_user}","gists_url":"https://api.github.com/users/charithag/gists{/gist_id}","starred_url":"https://api.github.com/users/charithag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charithag/subscriptions","organizations_url":"https://api.github.com/users/charithag/orgs","repos_url":"https://api.github.com/users/charithag/repos","events_url":"https://api.github.com/users/charithag/events{/privacy}","received_events_url":"https://api.github.com/users/charithag/received_events","type":"User","site_admin":false},"repo":{"id":38413787,"name":"iot-server-extensions","full_name":"charithag/iot-server-extensions","owner":{"login":"charithag","id":3184302,"avatar_url":"https://avatars.githubusercontent.com/u/3184302?v=3","gravatar_id":"","url":"https://api.github.com/users/charithag","html_url":"https://github.com/charithag","followers_url":"https://api.github.com/users/charithag/followers","following_url":"https://api.github.com/users/charithag/following{/other_user}","gists_url":"https://api.github.com/users/charithag/gists{/gist_id}","starred_url":"https://api.github.com/users/charithag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charithag/subscriptions","organizations_url":"https://api.github.com/users/charithag/orgs","repos_url":"https://api.github.com/users/charithag/repos","events_url":"https://api.github.com/users/charithag/events{/privacy}","received_events_url":"https://api.github.com/users/charithag/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/charithag/iot-server-extensions","description":"","fork":true,"url":"https://api.github.com/repos/charithag/iot-server-extensions","forks_url":"https://api.github.com/repos/charithag/iot-server-extensions/forks","keys_url":"https://api.github.com/repos/charithag/iot-server-extensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/charithag/iot-server-extensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/charithag/iot-server-extensions/teams","hooks_url":"https://api.github.com/repos/charithag/iot-server-extensions/hooks","issue_events_url":"https://api.github.com/repos/charithag/iot-server-extensions/issues/events{/number}","events_url":"https://api.github.com/repos/charithag/iot-server-extensions/events","assignees_url":"https://api.github.com/repos/charithag/iot-server-extensions/assignees{/user}","branches_url":"https://api.github.com/repos/charithag/iot-server-extensions/branches{/branch}","tags_url":"https://api.github.com/repos/charithag/iot-server-extensions/tags","blobs_url":"https://api.github.com/repos/charithag/iot-server-extensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/charithag/iot-server-extensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/charithag/iot-server-extensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/charithag/iot-server-extensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/charithag/iot-server-extensions/statuses/{sha}","languages_url":"https://api.github.com/repos/charithag/iot-server-extensions/languages","stargazers_url":"https://api.github.com/repos/charithag/iot-server-extensions/stargazers","contributors_url":"https://api.github.com/repos/charithag/iot-server-extensions/contributors","subscribers_url":"https://api.github.com/repos/charithag/iot-server-extensions/subscribers","subscription_url":"https://api.github.com/repos/charithag/iot-server-extensions/subscription","commits_url":"https://api.github.com/repos/charithag/iot-server-extensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/charithag/iot-server-extensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/charithag/iot-server-extensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/charithag/iot-server-extensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/charithag/iot-server-extensions/contents/{+path}","compare_url":"https://api.github.com/repos/charithag/iot-server-extensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/charithag/iot-server-extensions/merges","archive_url":"https://api.github.com/repos/charithag/iot-server-extensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/charithag/iot-server-extensions/downloads","issues_url":"https://api.github.com/repos/charithag/iot-server-extensions/issues{/number}","pulls_url":"https://api.github.com/repos/charithag/iot-server-extensions/pulls{/number}","milestones_url":"https://api.github.com/repos/charithag/iot-server-extensions/milestones{/number}","notifications_url":"https://api.github.com/repos/charithag/iot-server-extensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/charithag/iot-server-extensions/labels{/name}","releases_url":"https://api.github.com/repos/charithag/iot-server-extensions/releases{/id}","deployments_url":"https://api.github.com/repos/charithag/iot-server-extensions/deployments","created_at":"2015-07-02T05:46:22Z","updated_at":"2015-10-10T02:18:53Z","pushed_at":"2015-11-06T06:43:26Z","git_url":"git://github.com/charithag/iot-server-extensions.git","ssh_url":"git@github.com:charithag/iot-server-extensions.git","clone_url":"https://github.com/charithag/iot-server-extensions.git","svn_url":"https://github.com/charithag/iot-server-extensions","homepage":null,"size":3778,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wso2-incubator:master","ref":"master","sha":"1bc0b8d1eb41e272a84f60edb59549e1c43a4b5e","user":{"login":"wso2-incubator","id":6744733,"avatar_url":"https://avatars.githubusercontent.com/u/6744733?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2-incubator","html_url":"https://github.com/wso2-incubator","followers_url":"https://api.github.com/users/wso2-incubator/followers","following_url":"https://api.github.com/users/wso2-incubator/following{/other_user}","gists_url":"https://api.github.com/users/wso2-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2-incubator/subscriptions","organizations_url":"https://api.github.com/users/wso2-incubator/orgs","repos_url":"https://api.github.com/users/wso2-incubator/repos","events_url":"https://api.github.com/users/wso2-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/wso2-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":33305761,"name":"iot-server-extensions","full_name":"wso2-incubator/iot-server-extensions","owner":{"login":"wso2-incubator","id":6744733,"avatar_url":"https://avatars.githubusercontent.com/u/6744733?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2-incubator","html_url":"https://github.com/wso2-incubator","followers_url":"https://api.github.com/users/wso2-incubator/followers","following_url":"https://api.github.com/users/wso2-incubator/following{/other_user}","gists_url":"https://api.github.com/users/wso2-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2-incubator/subscriptions","organizations_url":"https://api.github.com/users/wso2-incubator/orgs","repos_url":"https://api.github.com/users/wso2-incubator/repos","events_url":"https://api.github.com/users/wso2-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/wso2-incubator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2-incubator/iot-server-extensions","description":"","fork":false,"url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions","forks_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/forks","keys_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/teams","hooks_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/hooks","issue_events_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/issues/events{/number}","events_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/events","assignees_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/assignees{/user}","branches_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/branches{/branch}","tags_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/tags","blobs_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/languages","stargazers_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/stargazers","contributors_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/contributors","subscribers_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/subscribers","subscription_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/subscription","commits_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/contents/{+path}","compare_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/merges","archive_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/downloads","issues_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/issues{/number}","pulls_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/labels{/name}","releases_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/releases{/id}","deployments_url":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/deployments","created_at":"2015-04-02T11:40:34Z","updated_at":"2016-06-26T18:33:40Z","pushed_at":"2016-06-26T19:01:19Z","git_url":"git://github.com/wso2-incubator/iot-server-extensions.git","ssh_url":"git@github.com:wso2-incubator/iot-server-extensions.git","clone_url":"https://github.com/wso2-incubator/iot-server-extensions.git","svn_url":"https://github.com/wso2-incubator/iot-server-extensions","homepage":null,"size":3696,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":0,"forks":9,"open_issues":0,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/2"},"html":{"href":"https://github.com/wso2-incubator/iot-server-extensions/pull/2"},"issue":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/issues/2"},"comments":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/wso2-incubator/iot-server-extensions/statuses/281582d160020003ae654489af8dffc1990bfe25"}}}}
{"actor":{"display_login":"charithag"}}