{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/product-iots/pulls/comments/71330308","id":71330308,"diff_hunk":"@@ -0,0 +1,259 @@\n+/*\n+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n+ *\n+ * WSO2 Inc. licenses this file to you under the Apache License,\n+ * Version 2.0 (the \"License\"); you may not use this file except\n+ * in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.homeautomation.firealarm.plugin.impl;\n+\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.homeautomation.firealarm.plugin.exception.FirealarmPluginException;\n+import org.homeautomation.firealarm.plugin.impl.dao.DeviceTypeDAO;\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.common.DeviceManagementException;\n+import org.wso2.carbon.device.mgt.common.DeviceManager;\n+import org.wso2.carbon.device.mgt.common.EnrolmentInfo;\n+import org.wso2.carbon.device.mgt.common.FeatureManager;\n+import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;\n+import org.wso2.carbon.device.mgt.common.license.mgt.License;\n+import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;\n+\n+import java.util.List;\n+\n+/**\n+ *\n+ */\n+public class DeviceTypeManager implements DeviceManager {\n+\n+    private static final Log log = LogFactory.getLog(DeviceTypeManager.class);\n+\n+    private static final DeviceTypeDAO connectedCupDAO = new DeviceTypeDAO();\n+\n+    @Override\n+    public FeatureManager getFeatureManager() {\n+        return null;\n+    }\n+\n+    @Override\n+    public boolean saveConfiguration(TenantConfiguration tenantConfiguration)\n+            throws DeviceManagementException {\n+        //TODO implement this\n+        return false;\n+    }\n+\n+    @Override\n+    public TenantConfiguration getConfiguration() throws DeviceManagementException {\n+        //TODO implement this\n+        return null;\n+    }\n+\n+    @Override\n+    public boolean enrollDevice(Device device) throws DeviceManagementException {\n+        boolean status;\n+        try {\n+            if (log.isDebugEnabled()) {\n+                log.debug(\"Enrolling a new Connected Cup device : \" + device.getDeviceIdentifier());\n+            }\n+            DeviceTypeDAO.beginTransaction();\n+            status = connectedCupDAO.getConnectedCupDeviceDAO().addDevice(device);\n+            DeviceTypeDAO.commitTransaction();\n+        } catch (FirealarmPluginException e) {\n+            try {\n+                DeviceTypeDAO.rollbackTransaction();\n+            } catch (FirealarmPluginException iotDAOEx) {\n+                String msg = \"Error occurred while roll back the device enrol transaction :\" + device.toString();\n+                log.warn(msg, iotDAOEx);\n+            }\n+            String msg = \"Error while enrolling the Connected Cup device : \" + device.getDeviceIdentifier();\n+            log.error(msg, e);\n+            throw new DeviceManagementException(msg, e);\n+        }\n+        return status;\n+    }\n+\n+    @Override\n+    public boolean modifyEnrollment(Device device) throws DeviceManagementException {\n+        boolean status;\n+        try {\n+            if (log.isDebugEnabled()) {\n+                log.debug(\"Modifying the Connected Cup device enrollment data\");\n+            }\n+            DeviceTypeDAO.beginTransaction();\n+            status = connectedCupDAO.getConnectedCupDeviceDAO().updateDevice(device);\n+            DeviceTypeDAO.commitTransaction();\n+        } catch (FirealarmPluginException e) {\n+            try {\n+                DeviceTypeDAO.rollbackTransaction();\n+            } catch (FirealarmPluginException iotDAOEx) {\n+                String msg = \"Error occurred while roll back the update device transaction :\" + device.toString();\n+                log.warn(msg, iotDAOEx);\n+            }\n+            String msg = \"Error while updating the enrollment of the Connected Cup device : \" +\n+                         device.getDeviceIdentifier();\n+            log.error(msg, e);\n+            throw new DeviceManagementException(msg, e);\n+        }\n+        return status;\n+    }\n+\n+    @Override\n+    public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {\n+        boolean status;\n+        try {\n+            if (log.isDebugEnabled()) {\n+                log.debug(\"Dis-enrolling Connected Cup device : \" + deviceId);\n+            }\n+            DeviceTypeDAO.beginTransaction();\n+            status = connectedCupDAO.getConnectedCupDeviceDAO().deleteDevice(deviceId.getId());\n+            DeviceTypeDAO.commitTransaction();\n+        } catch (FirealarmPluginException e) {","path":"modules/samples/firealarm/component/plugin/src/main/java/org/homeautomation/firealarm/plugin/impl/DeviceTypeManager.java","position":123,"original_position":123,"commit_id":"6c7041dcda5eacd2ce85a0e53057458c102d0cd9","original_commit_id":"6c7041dcda5eacd2ce85a0e53057458c102d0cd9","user":{"login":"DilanUA","id":8347682,"avatar_url":"https://avatars.githubusercontent.com/u/8347682?v=3","gravatar_id":"","url":"https://api.github.com/users/DilanUA","html_url":"https://github.com/DilanUA","followers_url":"https://api.github.com/users/DilanUA/followers","following_url":"https://api.github.com/users/DilanUA/following{/other_user}","gists_url":"https://api.github.com/users/DilanUA/gists{/gist_id}","starred_url":"https://api.github.com/users/DilanUA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DilanUA/subscriptions","organizations_url":"https://api.github.com/users/DilanUA/orgs","repos_url":"https://api.github.com/users/DilanUA/repos","events_url":"https://api.github.com/users/DilanUA/events{/privacy}","received_events_url":"https://api.github.com/users/DilanUA/received_events","type":"User","site_admin":false},"body":"same as above.","created_at":"2016-07-19T12:47:16Z","updated_at":"2016-07-19T12:47:16Z","html_url":"https://github.com/wso2/product-iots/pull/98#discussion_r71330308","pull_request_url":"https://api.github.com/repos/wso2/product-iots/pulls/98","_links":{"self":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/comments/71330308"},"html":{"href":"https://github.com/wso2/product-iots/pull/98#discussion_r71330308"},"pull_request":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/product-iots/pulls/98","id":61669604,"html_url":"https://github.com/wso2/product-iots/pull/98","diff_url":"https://github.com/wso2/product-iots/pull/98.diff","patch_url":"https://github.com/wso2/product-iots/pull/98.patch","issue_url":"https://api.github.com/repos/wso2/product-iots/issues/98","number":98,"state":"closed","locked":false,"title":"Add ESP8266 based fire alarm sample","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":"","created_at":"2016-03-04T05:39:51Z","updated_at":"2016-07-19T12:47:16Z","closed_at":"2016-03-04T05:40:01Z","merged_at":"2016-03-04T05:40:01Z","merge_commit_sha":"de4f8fe46b37c4f4c60c54d0ceb603b67132140e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2/product-iots/pulls/98/commits","review_comments_url":"https://api.github.com/repos/wso2/product-iots/pulls/98/comments","review_comment_url":"https://api.github.com/repos/wso2/product-iots/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/product-iots/issues/98/comments","statuses_url":"https://api.github.com/repos/wso2/product-iots/statuses/6c7041dcda5eacd2ce85a0e53057458c102d0cd9","head":{"label":"charithag:master","ref":"master","sha":"6c7041dcda5eacd2ce85a0e53057458c102d0cd9","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":43046444,"name":"product-iot-server","full_name":"charithag/product-iot-server","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/product-iot-server","description":"","fork":true,"url":"https://api.github.com/repos/charithag/product-iot-server","forks_url":"https://api.github.com/repos/charithag/product-iot-server/forks","keys_url":"https://api.github.com/repos/charithag/product-iot-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/charithag/product-iot-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/charithag/product-iot-server/teams","hooks_url":"https://api.github.com/repos/charithag/product-iot-server/hooks","issue_events_url":"https://api.github.com/repos/charithag/product-iot-server/issues/events{/number}","events_url":"https://api.github.com/repos/charithag/product-iot-server/events","assignees_url":"https://api.github.com/repos/charithag/product-iot-server/assignees{/user}","branches_url":"https://api.github.com/repos/charithag/product-iot-server/branches{/branch}","tags_url":"https://api.github.com/repos/charithag/product-iot-server/tags","blobs_url":"https://api.github.com/repos/charithag/product-iot-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/charithag/product-iot-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/charithag/product-iot-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/charithag/product-iot-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/charithag/product-iot-server/statuses/{sha}","languages_url":"https://api.github.com/repos/charithag/product-iot-server/languages","stargazers_url":"https://api.github.com/repos/charithag/product-iot-server/stargazers","contributors_url":"https://api.github.com/repos/charithag/product-iot-server/contributors","subscribers_url":"https://api.github.com/repos/charithag/product-iot-server/subscribers","subscription_url":"https://api.github.com/repos/charithag/product-iot-server/subscription","commits_url":"https://api.github.com/repos/charithag/product-iot-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/charithag/product-iot-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/charithag/product-iot-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/charithag/product-iot-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/charithag/product-iot-server/contents/{+path}","compare_url":"https://api.github.com/repos/charithag/product-iot-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/charithag/product-iot-server/merges","archive_url":"https://api.github.com/repos/charithag/product-iot-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/charithag/product-iot-server/downloads","issues_url":"https://api.github.com/repos/charithag/product-iot-server/issues{/number}","pulls_url":"https://api.github.com/repos/charithag/product-iot-server/pulls{/number}","milestones_url":"https://api.github.com/repos/charithag/product-iot-server/milestones{/number}","notifications_url":"https://api.github.com/repos/charithag/product-iot-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/charithag/product-iot-server/labels{/name}","releases_url":"https://api.github.com/repos/charithag/product-iot-server/releases{/id}","deployments_url":"https://api.github.com/repos/charithag/product-iot-server/deployments","created_at":"2015-09-24T05:19:19Z","updated_at":"2016-03-10T13:56:03Z","pushed_at":"2016-06-29T14:53:29Z","git_url":"git://github.com/charithag/product-iot-server.git","ssh_url":"git@github.com:charithag/product-iot-server.git","clone_url":"https://github.com/charithag/product-iot-server.git","svn_url":"https://github.com/charithag/product-iot-server","homepage":null,"size":102228,"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:master","ref":"master","sha":"77a2419bc40c9f569bcdfae4eb670c909c0b2202","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":42174888,"name":"product-iots","full_name":"wso2/product-iots","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/product-iots","description":"Welcome to the WSO2 IoT Server source code! For info on working with the WSO2 IoT Server repository and contributing code, click the link below.","fork":false,"url":"https://api.github.com/repos/wso2/product-iots","forks_url":"https://api.github.com/repos/wso2/product-iots/forks","keys_url":"https://api.github.com/repos/wso2/product-iots/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/product-iots/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/product-iots/teams","hooks_url":"https://api.github.com/repos/wso2/product-iots/hooks","issue_events_url":"https://api.github.com/repos/wso2/product-iots/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/product-iots/events","assignees_url":"https://api.github.com/repos/wso2/product-iots/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/product-iots/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/product-iots/tags","blobs_url":"https://api.github.com/repos/wso2/product-iots/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/product-iots/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/product-iots/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/product-iots/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/product-iots/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/product-iots/languages","stargazers_url":"https://api.github.com/repos/wso2/product-iots/stargazers","contributors_url":"https://api.github.com/repos/wso2/product-iots/contributors","subscribers_url":"https://api.github.com/repos/wso2/product-iots/subscribers","subscription_url":"https://api.github.com/repos/wso2/product-iots/subscription","commits_url":"https://api.github.com/repos/wso2/product-iots/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/product-iots/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/product-iots/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/product-iots/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/product-iots/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/product-iots/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/product-iots/merges","archive_url":"https://api.github.com/repos/wso2/product-iots/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/product-iots/downloads","issues_url":"https://api.github.com/repos/wso2/product-iots/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/product-iots/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/product-iots/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/product-iots/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/product-iots/labels{/name}","releases_url":"https://api.github.com/repos/wso2/product-iots/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/product-iots/deployments","created_at":"2015-09-09T11:39:56Z","updated_at":"2016-07-11T04:47:51Z","pushed_at":"2016-07-18T09:16:15Z","git_url":"git://github.com/wso2/product-iots.git","ssh_url":"git@github.com:wso2/product-iots.git","clone_url":"https://github.com/wso2/product-iots.git","svn_url":"https://github.com/wso2/product-iots","homepage":"http://wso2.github.io/","size":102201,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":0,"forks":23,"open_issues":0,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/98"},"html":{"href":"https://github.com/wso2/product-iots/pull/98"},"issue":{"href":"https://api.github.com/repos/wso2/product-iots/issues/98"},"comments":{"href":"https://api.github.com/repos/wso2/product-iots/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/product-iots/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/product-iots/statuses/6c7041dcda5eacd2ce85a0e53057458c102d0cd9"}}}}
{"actor":{"display_login":"DilanUA"}}