{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/comments/60691873","id":60691873,"diff_hunk":"@@ -121,24 +122,356 @@\n  */\n public class AppMDAO {\n \n-\tprivate static final Log log = LogFactory.getLog(AppMDAO.class);\n+    private static final Log log = LogFactory.getLog(AppMDAO.class);\n \n-\tprivate static final String ENABLE_JWT_GENERATION =\n-\t                                                    \"AppConsumerAuthConfiguration.EnableTokenGeneration\";\n-\tprivate static final String ENABLE_JWT_CACHE = \"APIKeyManager.EnableJWTCache\";\n+    private static final String ENABLE_JWT_GENERATION =\n+            \"AppConsumerAuthConfiguration.EnableTokenGeneration\";\n+    private static final String ENABLE_JWT_CACHE = \"APIKeyManager.EnableJWTCache\";\n \n     private static final String GATEWAY_URL = \"APIGateway.Environments.Environment.GatewayEndpoint\";\n \n-\t// Primary/Secondary Login configuration\n-\tprivate static final String USERID_LOGIN = \"UserIdLogin\";\n-\tprivate static final String EMAIL_LOGIN = \"EmailLogin\";\n-\tprivate static final String PRIMARY_LOGIN = \"primary\";\n-\tprivate static final String CLAIM_URI = \"ClaimUri\";\n+    // Primary/Secondary Login configuration\n+    private static final String USERID_LOGIN = \"UserIdLogin\";\n+    private static final String EMAIL_LOGIN = \"EmailLogin\";\n+    private static final String PRIMARY_LOGIN = \"primary\";\n+    private static final String CLAIM_URI = \"ClaimUri\";\n \n-\tpublic AppMDAO() {\n-\t}\n+    public AppMDAO() {\n+    }\n \n-\t/**\n+    /**\n+     * This methode is to return a List of existing business owners with their properties.\n+     *\n+     * @return\n+     * @throws AppManagementException\n+     */\n+    public BusinessOwner getBusinessOwner(String appId) throws AppManagementException {\n+\n+        Connection connection = null;\n+        PreparedStatement statementToGetBusinessOwners = null;\n+        BusinessOwner businessOwner = new BusinessOwner();\n+        ResultSet rs1 = null;\n+\n+        String queryToGetBusinessOwner =\n+                \"SELECT BUSINESS_OWNERS.OWNER_ID, BUSINESS_OWNERS.OWNER_NAME, BUSINESS_OWNERS.OWNER_EMAIL, \" +\n+                        \"BUSINESS_OWNERS.OWNER_DESC, BUSINESS_OWNERS.OWNER_SITE FROM APM_APP INNER JOIN \" +\n+                        \"BUSINESS_OWNERS ON APM_APP.OWNER_ID = BUSINESS_OWNERS.OWNER_ID WHERE UUID = ? \";\n+\n+        try {\n+            connection = APIMgtDBUtil.getConnection();\n+            statementToGetBusinessOwners = connection.prepareStatement(queryToGetBusinessOwner);\n+            statementToGetBusinessOwners.setString(1, appId);\n+            rs1 = statementToGetBusinessOwners.executeQuery();\n+\n+            if (rs1.next()) {\n+                int businessOwnerId = rs1.getInt(\"OWNER_ID\");\n+                businessOwner.setBusinessOwnerId(businessOwnerId);\n+                businessOwner.setBusinessOwnerName(rs1.getString(\"OWNER_NAME\"));\n+                businessOwner.setBusinessOwnereDescription(rs1.getString(\"OWNER_DESC\"));\n+                businessOwner.setBusinessOwnerEmail(rs1.getString(\"OWNER_EMAIL\"));\n+                businessOwner.setBusinessOwnerSite(rs1.getString(\"OWNER_SITE\"));\n+                businessOwner.setBusinessOwnerDetails(getBusinessOwnerDetailsById(businessOwnerId));\n+            }\n+\n+        } catch (SQLException e) {\n+            handleException(\"Failed to retrieve business owners.\", e);\n+        } finally {\n+            APIMgtDBUtil.closeAllConnections(statementToGetBusinessOwners, connection, rs1);\n+\n+        }\n+        return businessOwner;\n+    }\n+\n+    /**\n+     * a\n+     *\n+     * @return Owner Name\n+     * @throws org.wso2.carbon.appmgt.api.AppManagementException if failed to get subscriber\n+     */\n+    public String getBusinessOwnerName(String appId)\n+            throws\n+            AppManagementException {\n+        PreparedStatement prepStmt = null;\n+        Connection connection = null;\n+        ResultSet rs = null;\n+\n+\n+        int ownerId;\n+        String ownerName = \"\";\n+        String sqlQuery =\n+                \"SELECT OWNER_ID FROM APM_APP WHERE UUID=?\";\n+\n+        try {\n+            connection = APIMgtDBUtil.getConnection();\n+            connection.setAutoCommit(false);\n+            prepStmt = connection.prepareStatement(sqlQuery);\n+            prepStmt.setString(1, appId);\n+            rs = prepStmt.executeQuery();\n+\n+            if (rs.next()) {\n+                ownerId = rs.getInt(\"OWNER_ID\");\n+\n+                if (ownerId > 0) {\n+                    PreparedStatement prepStmt2 = null;\n+                    Connection connection2 = null;\n+                    connection2 = APIMgtDBUtil.getConnection();\n+                    connection2.setAutoCommit(false);\n+                    ResultSet rs2 = null;\n+                    String sqlQuery2 = \"SELECT OWNER_NAME FROM BUSINESS_OWNERS WHERE OWNER_ID=?\";\n+                    prepStmt2 = connection2.prepareStatement(sqlQuery2);\n+                    prepStmt2.setInt(1, ownerId);\n+                    rs2 = prepStmt2.executeQuery();\n+                    if (rs2.next()) {\n+                        ownerName = rs2.getString(\"OWNER_NAME\");\n+                    }\n+\n+                }\n+\n+            }\n+\n+        } catch (SQLException e) {\n+            handleException(\"Error when reading the application information from\"\n+                                    + \" the persistence store.\", e);\n+        } finally {\n+            APIMgtDBUtil.closeAllConnections(prepStmt, null, rs);\n+        }\n+        return ownerName;\n+    }\n+\n+\n+    /**\n+     * Delete a given business owner.\n+     *\n+     * @param ownerId\n+     * @return\n+     */\n+    public void deleteBusinessOwner(String ownerId) throws AppManagementException {\n+\n+        Connection connection = null;\n+        PreparedStatement statementToDeleteRecord = null;\n+        PreparedStatement statementToDeleteRecordTwo = null;\n+        try {\n+            if (log.isDebugEnabled()) {\n+                log.debug(\"Deleting a Business Owner\");\n+            }\n+            connection = APIMgtDBUtil.getConnection();\n+\n+            String queryToDeleteRecordTwo = \"DELETE FROM BUSINESS_OWNERS_EXTRA WHERE OWNER_ID = ?\";","path":"components/org.wso2.carbon.appmgt.impl/src/main/java/org/wso2/carbon/appmgt/impl/dao/AppMDAO.java","position":158,"original_position":158,"commit_id":"55d35a927753936860c42163f21bf10bf7f6ae50","original_commit_id":"55d35a927753936860c42163f21bf10bf7f6ae50","user":{"login":"rushmin","id":1607954,"avatar_url":"https://avatars.githubusercontent.com/u/1607954?v=3","gravatar_id":"","url":"https://api.github.com/users/rushmin","html_url":"https://github.com/rushmin","followers_url":"https://api.github.com/users/rushmin/followers","following_url":"https://api.github.com/users/rushmin/following{/other_user}","gists_url":"https://api.github.com/users/rushmin/gists{/gist_id}","starred_url":"https://api.github.com/users/rushmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rushmin/subscriptions","organizations_url":"https://api.github.com/users/rushmin/orgs","repos_url":"https://api.github.com/users/rushmin/repos","events_url":"https://api.github.com/users/rushmin/events{/privacy}","received_events_url":"https://api.github.com/users/rushmin/received_events","type":"User","site_admin":false},"body":"variable name should be \"queryToDeleteRecordTwo\"","created_at":"2016-04-22T05:14:48Z","updated_at":"2016-04-22T05:14:48Z","html_url":"https://github.com/wso2/carbon-appmgt/pull/282#discussion_r60691873","pull_request_url":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/282","_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/comments/60691873"},"html":{"href":"https://github.com/wso2/carbon-appmgt/pull/282#discussion_r60691873"},"pull_request":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/282"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/282","id":67457342,"html_url":"https://github.com/wso2/carbon-appmgt/pull/282","diff_url":"https://github.com/wso2/carbon-appmgt/pull/282.diff","patch_url":"https://github.com/wso2/carbon-appmgt/pull/282.patch","issue_url":"https://api.github.com/repos/wso2/carbon-appmgt/issues/282","number":282,"state":"open","locked":false,"title":"Adding a business owner to published applications ","user":{"login":"visithamanujaya","id":8380771,"avatar_url":"https://avatars.githubusercontent.com/u/8380771?v=3","gravatar_id":"","url":"https://api.github.com/users/visithamanujaya","html_url":"https://github.com/visithamanujaya","followers_url":"https://api.github.com/users/visithamanujaya/followers","following_url":"https://api.github.com/users/visithamanujaya/following{/other_user}","gists_url":"https://api.github.com/users/visithamanujaya/gists{/gist_id}","starred_url":"https://api.github.com/users/visithamanujaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/visithamanujaya/subscriptions","organizations_url":"https://api.github.com/users/visithamanujaya/orgs","repos_url":"https://api.github.com/users/visithamanujaya/repos","events_url":"https://api.github.com/users/visithamanujaya/events{/privacy}","received_events_url":"https://api.github.com/users/visithamanujaya/received_events","type":"User","site_admin":false},"body":"Re-coded","created_at":"2016-04-22T04:16:55Z","updated_at":"2016-04-22T05:14:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f80e99d803fe19591a933f7f47062134f192982d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/282/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/282/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-appmgt/issues/282/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-appmgt/statuses/55d35a927753936860c42163f21bf10bf7f6ae50","head":{"label":"VisithaNew:master","ref":"master","sha":"55d35a927753936860c42163f21bf10bf7f6ae50","user":{"login":"VisithaNew","id":18572274,"avatar_url":"https://avatars.githubusercontent.com/u/18572274?v=3","gravatar_id":"","url":"https://api.github.com/users/VisithaNew","html_url":"https://github.com/VisithaNew","followers_url":"https://api.github.com/users/VisithaNew/followers","following_url":"https://api.github.com/users/VisithaNew/following{/other_user}","gists_url":"https://api.github.com/users/VisithaNew/gists{/gist_id}","starred_url":"https://api.github.com/users/VisithaNew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VisithaNew/subscriptions","organizations_url":"https://api.github.com/users/VisithaNew/orgs","repos_url":"https://api.github.com/users/VisithaNew/repos","events_url":"https://api.github.com/users/VisithaNew/events{/privacy}","received_events_url":"https://api.github.com/users/VisithaNew/received_events","type":"Organization","site_admin":false},"repo":{"id":56676846,"name":"carbon-appmgt","full_name":"VisithaNew/carbon-appmgt","owner":{"login":"VisithaNew","id":18572274,"avatar_url":"https://avatars.githubusercontent.com/u/18572274?v=3","gravatar_id":"","url":"https://api.github.com/users/VisithaNew","html_url":"https://github.com/VisithaNew","followers_url":"https://api.github.com/users/VisithaNew/followers","following_url":"https://api.github.com/users/VisithaNew/following{/other_user}","gists_url":"https://api.github.com/users/VisithaNew/gists{/gist_id}","starred_url":"https://api.github.com/users/VisithaNew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VisithaNew/subscriptions","organizations_url":"https://api.github.com/users/VisithaNew/orgs","repos_url":"https://api.github.com/users/VisithaNew/repos","events_url":"https://api.github.com/users/VisithaNew/events{/privacy}","received_events_url":"https://api.github.com/users/VisithaNew/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VisithaNew/carbon-appmgt","description":"","fork":true,"url":"https://api.github.com/repos/VisithaNew/carbon-appmgt","forks_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/forks","keys_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/teams","hooks_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/hooks","issue_events_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/issues/events{/number}","events_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/events","assignees_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/assignees{/user}","branches_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/branches{/branch}","tags_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/tags","blobs_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/git/refs{/sha}","trees_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/statuses/{sha}","languages_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/languages","stargazers_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/stargazers","contributors_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/contributors","subscribers_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/subscribers","subscription_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/subscription","commits_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/commits{/sha}","git_commits_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/git/commits{/sha}","comments_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/comments{/number}","issue_comment_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/issues/comments{/number}","contents_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/contents/{+path}","compare_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/merges","archive_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/downloads","issues_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/issues{/number}","pulls_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/pulls{/number}","milestones_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/milestones{/number}","notifications_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/labels{/name}","releases_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/releases{/id}","deployments_url":"https://api.github.com/repos/VisithaNew/carbon-appmgt/deployments","created_at":"2016-04-20T10:11:32Z","updated_at":"2016-04-20T10:11:40Z","pushed_at":"2016-04-22T04:15:29Z","git_url":"git://github.com/VisithaNew/carbon-appmgt.git","ssh_url":"git@github.com:VisithaNew/carbon-appmgt.git","clone_url":"https://github.com/VisithaNew/carbon-appmgt.git","svn_url":"https://github.com/VisithaNew/carbon-appmgt","homepage":null,"size":27040,"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":"0dda3abb9cfab773c72213b85736f771c8700cd8","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":17201753,"name":"carbon-appmgt","full_name":"wso2/carbon-appmgt","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/carbon-appmgt","description":"","fork":false,"url":"https://api.github.com/repos/wso2/carbon-appmgt","forks_url":"https://api.github.com/repos/wso2/carbon-appmgt/forks","keys_url":"https://api.github.com/repos/wso2/carbon-appmgt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-appmgt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-appmgt/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-appmgt/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-appmgt/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-appmgt/events","assignees_url":"https://api.github.com/repos/wso2/carbon-appmgt/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-appmgt/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-appmgt/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-appmgt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-appmgt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-appmgt/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-appmgt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-appmgt/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-appmgt/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-appmgt/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-appmgt/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-appmgt/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-appmgt/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-appmgt/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-appmgt/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-appmgt/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-appmgt/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-appmgt/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-appmgt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-appmgt/merges","archive_url":"https://api.github.com/repos/wso2/carbon-appmgt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-appmgt/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-appmgt/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-appmgt/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-appmgt/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-appmgt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-appmgt/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-appmgt/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/carbon-appmgt/deployments","created_at":"2014-02-26T06:47:05Z","updated_at":"2016-03-17T04:37:35Z","pushed_at":"2016-04-22T04:16:55Z","git_url":"git://github.com/wso2/carbon-appmgt.git","ssh_url":"git@github.com:wso2/carbon-appmgt.git","clone_url":"https://github.com/wso2/carbon-appmgt.git","svn_url":"https://github.com/wso2/carbon-appmgt","homepage":null,"size":28297,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":8,"forks":27,"open_issues":8,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/282"},"html":{"href":"https://github.com/wso2/carbon-appmgt/pull/282"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/issues/282"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/issues/282/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/282/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/pulls/282/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-appmgt/statuses/55d35a927753936860c42163f21bf10bf7f6ae50"}}}}