{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/comments/52157155","id":52157155,"diff_hunk":"@@ -0,0 +1,217 @@\n+/*\n+* Copyright (c) 2015, 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.wso2.carbon.apimgt.usage.client;\n+\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.wso2.carbon.apimgt.api.APIManagementException;\n+import org.wso2.carbon.apimgt.api.APIProvider;\n+import org.wso2.carbon.apimgt.api.model.API;\n+import org.wso2.carbon.apimgt.api.model.APIStatus;\n+import org.wso2.carbon.apimgt.impl.APIManagerAnalyticsConfiguration;\n+import org.wso2.carbon.apimgt.impl.APIManagerConfiguration;\n+import org.wso2.carbon.apimgt.impl.APIManagerFactory;\n+import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder;\n+import org.wso2.carbon.apimgt.impl.utils.APIUtil;\n+import org.wso2.carbon.apimgt.usage.client.exception.APIMgtUsageQueryServiceClientException;\n+import org.wso2.carbon.apimgt.usage.client.pojo.APIFirstAccess;\n+import org.wso2.carbon.apimgt.usage.client.pojo.SubscriberCountByAPIs;\n+import org.wso2.carbon.context.PrivilegedCarbonContext;\n+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;\n+import org.wso2.carbon.utils.multitenancy.MultitenantUtils;\n+\n+import java.lang.reflect.InvocationTargetException;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+/**\n+ * usageClient class it use to expose the Statistic class instance. it responsible to make instance of the class that is provided by the api-manager.xml\n+ */\n+public class UsageClient {\n+    private static final Log log = LogFactory.getLog(UsageClient.class);\n+    private static APIUsageStatisticsClient usageStatisticsClient;\n+\n+    /**\n+     * central point to initialise datasources or related configuration done by the admin-dashboard analytics section\n+     *\n+     * @throws APIMgtUsageQueryServiceClientException\n+     */\n+    public static void initializeDataSource() throws APIMgtUsageQueryServiceClientException {\n+\n+        try {\n+            APIUsageStatisticsClient client = UsageClient.getStatisticClient(\"\");\n+            client.initializeDataSource();\n+        } catch (APIMgtUsageQueryServiceClientException e) {\n+            throw new APIMgtUsageQueryServiceClientException(\"Error in initializing data sources\", e);\n+        }\n+\n+    }\n+\n+    /**\n+     * central public method used to get the instance if the statistic client\n+     *\n+     * @return return the APIUsageStatisticsClient implementation\n+     * @throws APIMgtUsageQueryServiceClientException if error in creating instance\n+     */\n+    public static APIUsageStatisticsClient getClient(String user) throws APIMgtUsageQueryServiceClientException {\n+        if (isDataPublishingEnabled()) {\n+            try {\n+                return UsageClient.getStatisticClient(user);\n+            } catch (APIMgtUsageQueryServiceClientException e) {\n+                throw new APIMgtUsageQueryServiceClientException(\"Error getting Statistics usage client instance\", e);","path":"components/apimgt/org.wso2.carbon.apimgt.usage/org.wso2.carbon.apimgt.usage.client/src/main/java/org/wso2/carbon/apimgt/usage/client/UsageClient.java","position":77,"original_position":77,"commit_id":"f8b46a38385dde25e501a43bd16ac69cbdd085d9","original_commit_id":"f8b46a38385dde25e501a43bd16ac69cbdd085d9","user":{"login":"ruks","id":1345278,"avatar_url":"https://avatars.githubusercontent.com/u/1345278?v=3","gravatar_id":"","url":"https://api.github.com/users/ruks","html_url":"https://github.com/ruks","followers_url":"https://api.github.com/users/ruks/followers","following_url":"https://api.github.com/users/ruks/following{/other_user}","gists_url":"https://api.github.com/users/ruks/gists{/gist_id}","starred_url":"https://api.github.com/users/ruks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruks/subscriptions","organizations_url":"https://api.github.com/users/ruks/orgs","repos_url":"https://api.github.com/users/ruks/repos","events_url":"https://api.github.com/users/ruks/events{/privacy}","received_events_url":"https://api.github.com/users/ruks/received_events","type":"User","site_admin":false},"body":"fixed in commit: https://github.com/wso2/carbon-apimgt/commit/c5071cbc7f3c39fed2489c288179e0fe93507544","created_at":"2016-02-08T11:17:56Z","updated_at":"2016-02-08T11:17:56Z","html_url":"https://github.com/wso2/carbon-apimgt/pull/1179#discussion_r52157155","pull_request_url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1179","_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/comments/52157155"},"html":{"href":"https://github.com/wso2/carbon-apimgt/pull/1179#discussion_r52157155"},"pull_request":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1179"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1179","id":48648767,"html_url":"https://github.com/wso2/carbon-apimgt/pull/1179","diff_url":"https://github.com/wso2/carbon-apimgt/pull/1179.diff","patch_url":"https://github.com/wso2/carbon-apimgt/pull/1179.patch","issue_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1179","number":1179,"state":"closed","locked":false,"title":"Analytics REST Client implementation","user":{"login":"ruks","id":1345278,"avatar_url":"https://avatars.githubusercontent.com/u/1345278?v=3","gravatar_id":"","url":"https://api.github.com/users/ruks","html_url":"https://github.com/ruks","followers_url":"https://api.github.com/users/ruks/followers","following_url":"https://api.github.com/users/ruks/following{/other_user}","gists_url":"https://api.github.com/users/ruks/gists{/gist_id}","starred_url":"https://api.github.com/users/ruks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruks/subscriptions","organizations_url":"https://api.github.com/users/ruks/orgs","repos_url":"https://api.github.com/users/ruks/repos","events_url":"https://api.github.com/users/ruks/events{/privacy}","received_events_url":"https://api.github.com/users/ruks/received_events","type":"User","site_admin":false},"body":"Added Statistic REST Client for DAS\r\nMoved old APIUsageStatisticsClient.java to impl/APIUsageStatisticsRdbmsClientImpl.java\r\nupgrade Carbon-deployment to 4.5.4-SNAPSHOT\r\nRemoved Stat Client access via Hostobjects\r\nUpgraded commons version to 4.4.8 from 4.4.7\r\nset carbon deployment version to 4.6.0","created_at":"2015-10-24T04:42:46Z","updated_at":"2016-02-08T11:17:56Z","closed_at":"2015-10-30T04:34:50Z","merged_at":"2015-10-30T04:34:50Z","merge_commit_sha":"487811fbdec6a6c4d81e3a1bffb5bdd2551545f8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1179/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1179/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1179/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-apimgt/statuses/f8b46a38385dde25e501a43bd16ac69cbdd085d9","head":{"label":"ruks:1.10.x.3","ref":"1.10.x.3","sha":"f8b46a38385dde25e501a43bd16ac69cbdd085d9","user":{"login":"ruks","id":1345278,"avatar_url":"https://avatars.githubusercontent.com/u/1345278?v=3","gravatar_id":"","url":"https://api.github.com/users/ruks","html_url":"https://github.com/ruks","followers_url":"https://api.github.com/users/ruks/followers","following_url":"https://api.github.com/users/ruks/following{/other_user}","gists_url":"https://api.github.com/users/ruks/gists{/gist_id}","starred_url":"https://api.github.com/users/ruks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruks/subscriptions","organizations_url":"https://api.github.com/users/ruks/orgs","repos_url":"https://api.github.com/users/ruks/repos","events_url":"https://api.github.com/users/ruks/events{/privacy}","received_events_url":"https://api.github.com/users/ruks/received_events","type":"User","site_admin":false},"repo":{"id":38859499,"name":"carbon-apimgt","full_name":"ruks/carbon-apimgt","owner":{"login":"ruks","id":1345278,"avatar_url":"https://avatars.githubusercontent.com/u/1345278?v=3","gravatar_id":"","url":"https://api.github.com/users/ruks","html_url":"https://github.com/ruks","followers_url":"https://api.github.com/users/ruks/followers","following_url":"https://api.github.com/users/ruks/following{/other_user}","gists_url":"https://api.github.com/users/ruks/gists{/gist_id}","starred_url":"https://api.github.com/users/ruks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruks/subscriptions","organizations_url":"https://api.github.com/users/ruks/orgs","repos_url":"https://api.github.com/users/ruks/repos","events_url":"https://api.github.com/users/ruks/events{/privacy}","received_events_url":"https://api.github.com/users/ruks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ruks/carbon-apimgt","description":"","fork":true,"url":"https://api.github.com/repos/ruks/carbon-apimgt","forks_url":"https://api.github.com/repos/ruks/carbon-apimgt/forks","keys_url":"https://api.github.com/repos/ruks/carbon-apimgt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ruks/carbon-apimgt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ruks/carbon-apimgt/teams","hooks_url":"https://api.github.com/repos/ruks/carbon-apimgt/hooks","issue_events_url":"https://api.github.com/repos/ruks/carbon-apimgt/issues/events{/number}","events_url":"https://api.github.com/repos/ruks/carbon-apimgt/events","assignees_url":"https://api.github.com/repos/ruks/carbon-apimgt/assignees{/user}","branches_url":"https://api.github.com/repos/ruks/carbon-apimgt/branches{/branch}","tags_url":"https://api.github.com/repos/ruks/carbon-apimgt/tags","blobs_url":"https://api.github.com/repos/ruks/carbon-apimgt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ruks/carbon-apimgt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ruks/carbon-apimgt/git/refs{/sha}","trees_url":"https://api.github.com/repos/ruks/carbon-apimgt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ruks/carbon-apimgt/statuses/{sha}","languages_url":"https://api.github.com/repos/ruks/carbon-apimgt/languages","stargazers_url":"https://api.github.com/repos/ruks/carbon-apimgt/stargazers","contributors_url":"https://api.github.com/repos/ruks/carbon-apimgt/contributors","subscribers_url":"https://api.github.com/repos/ruks/carbon-apimgt/subscribers","subscription_url":"https://api.github.com/repos/ruks/carbon-apimgt/subscription","commits_url":"https://api.github.com/repos/ruks/carbon-apimgt/commits{/sha}","git_commits_url":"https://api.github.com/repos/ruks/carbon-apimgt/git/commits{/sha}","comments_url":"https://api.github.com/repos/ruks/carbon-apimgt/comments{/number}","issue_comment_url":"https://api.github.com/repos/ruks/carbon-apimgt/issues/comments{/number}","contents_url":"https://api.github.com/repos/ruks/carbon-apimgt/contents/{+path}","compare_url":"https://api.github.com/repos/ruks/carbon-apimgt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ruks/carbon-apimgt/merges","archive_url":"https://api.github.com/repos/ruks/carbon-apimgt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ruks/carbon-apimgt/downloads","issues_url":"https://api.github.com/repos/ruks/carbon-apimgt/issues{/number}","pulls_url":"https://api.github.com/repos/ruks/carbon-apimgt/pulls{/number}","milestones_url":"https://api.github.com/repos/ruks/carbon-apimgt/milestones{/number}","notifications_url":"https://api.github.com/repos/ruks/carbon-apimgt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ruks/carbon-apimgt/labels{/name}","releases_url":"https://api.github.com/repos/ruks/carbon-apimgt/releases{/id}","deployments_url":"https://api.github.com/repos/ruks/carbon-apimgt/deployments","created_at":"2015-07-10T03:43:50Z","updated_at":"2015-07-10T03:44:01Z","pushed_at":"2016-02-08T08:59:12Z","git_url":"git://github.com/ruks/carbon-apimgt.git","ssh_url":"git@github.com:ruks/carbon-apimgt.git","clone_url":"https://github.com/ruks/carbon-apimgt.git","svn_url":"https://github.com/ruks/carbon-apimgt","homepage":null,"size":61421,"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":"1.10.x.11"}},"base":{"label":"wso2:release-1.10.x","ref":"release-1.10.x","sha":"1ad1ad411b0a8bc51ff062592b8cf5d069364e87","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":17201744,"name":"carbon-apimgt","full_name":"wso2/carbon-apimgt","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-apimgt","description":"","fork":false,"url":"https://api.github.com/repos/wso2/carbon-apimgt","forks_url":"https://api.github.com/repos/wso2/carbon-apimgt/forks","keys_url":"https://api.github.com/repos/wso2/carbon-apimgt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-apimgt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-apimgt/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-apimgt/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-apimgt/events","assignees_url":"https://api.github.com/repos/wso2/carbon-apimgt/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-apimgt/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-apimgt/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-apimgt/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-apimgt/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-apimgt/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-apimgt/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-apimgt/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-apimgt/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-apimgt/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-apimgt/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-apimgt/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-apimgt/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-apimgt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-apimgt/merges","archive_url":"https://api.github.com/repos/wso2/carbon-apimgt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-apimgt/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-apimgt/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-apimgt/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-apimgt/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-apimgt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-apimgt/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-apimgt/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/carbon-apimgt/deployments","created_at":"2014-02-26T06:46:48Z","updated_at":"2016-01-11T04:46:27Z","pushed_at":"2016-02-08T11:08:58Z","git_url":"git://github.com/wso2/carbon-apimgt.git","ssh_url":"git@github.com:wso2/carbon-apimgt.git","clone_url":"https://github.com/wso2/carbon-apimgt.git","svn_url":"https://github.com/wso2/carbon-apimgt","homepage":null,"size":65633,"stargazers_count":14,"watchers_count":14,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":121,"mirror_url":null,"open_issues_count":5,"forks":121,"open_issues":5,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1179"},"html":{"href":"https://github.com/wso2/carbon-apimgt/pull/1179"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1179"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/issues/1179/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1179/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/pulls/1179/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-apimgt/statuses/f8b46a38385dde25e501a43bd16ac69cbdd085d9"}}}}