{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/product-as/pulls/comments/28663310","id":28663310,"diff_hunk":"@@ -0,0 +1,176 @@\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.appserver.integration.common.artifacts.lazyloading;\n+\n+\n+import org.apache.axis2.context.ConfigurationContext;\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.wso2.carbon.context.PrivilegedCarbonContext;\n+import org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils;\n+import org.wso2.carbon.utils.ConfigurationContextService;\n+import org.wso2.carbon.webapp.mgt.WebApplication;\n+import org.wso2.carbon.webapp.mgt.WebApplicationsHolder;\n+\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+/**\n+ * Util class that contains the service implementation of LazyLoadingInfoService and supportive methods.\n+ */\n+public class LazyLoadingInfoUtil {\n+    private static final Log log = LogFactory.getLog(LazyLoadingInfoUtil.class);\n+\n+\n+    /**\n+     * Get the server configuration context.\n+     *\n+     * @return configuration context of the server.\n+     */\n+    private static ConfigurationContext getServerConfigurationContext() {\n+        ConfigurationContextService configurationContext = (ConfigurationContextService)\n+                PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(ConfigurationContextService.class,\n+                        null);\n+        return configurationContext.getServerConfigContext();\n+    }\n+\n+\n+    /**\n+     * Get the configuration contexts of all loaded tenants\n+     *\n+     * @return Map that contains the  configuration contexts\n+     */\n+    private static Map<String, ConfigurationContext> getTenantConfigContexts() {\n+        return TenantAxisUtils.getTenantConfigurationContexts(getServerConfigurationContext());\n+    }\n+\n+\n+    /**\n+     * Get the configuration context of given tenant.\n+     *\n+     * @param tenantDomain tenant domain name.\n+     * @return ConfigurationContext of given tenant\n+     */\n+    private static ConfigurationContext getTenantConfigurationContext(String tenantDomain) {\n+        return getTenantConfigContexts().get(tenantDomain);\n+    }\n+\n+    /**\n+     * Check  the given tenant is loaded.\n+     *\n+     * @param tenantDomain Domain name of the tenant\n+     * @return TenantStatus with current status  information about the tenant.\n+     */\n+    protected static TenantStatus getTenantStatus(String tenantDomain) {\n+        boolean isTenantContextLoaded = false;\n+\n+        Map<String, ConfigurationContext> tenantConfigContextsServer = getTenantConfigContexts();\n+        if (tenantConfigContextsServer != null) {\n+            isTenantContextLoaded = tenantConfigContextsServer.containsKey(tenantDomain);\n+            log.info(\"Tenant \" + tenantDomain + \" loaded :\" + isTenantContextLoaded);\n+        }\n+\n+        return new TenantStatus(isTenantContextLoaded);\n+    }\n+\n+    /**\n+     * Check  the given web-app of given tenant is loaded.\n+     *\n+     * @param tenantDomain Tenant name\n+     * @param webAppName   Web-app Name\n+     * @return WebAppStatus  with current status  information about the Web app.\n+     */\n+    protected static WebAppStatus getWebAppStatus(String tenantDomain, String webAppName) {\n+        WebAppStatus webAppStatus = new WebAppStatus();\n+        ConfigurationContext tenantConfigurationContext = getTenantConfigurationContext(tenantDomain);\n+        if (tenantConfigurationContext != null) {\n+            webAppStatus.setTenantStatus(new TenantStatus(true));\n+            log.info(\"Tenant \" + tenantDomain + \" configuration context is loaded.\");\n+            WebApplicationsHolder webApplicationsHolder = (WebApplicationsHolder) ((HashMap)\n+                    tenantConfigurationContext.getLocalProperty(\"carbon.webapps.holderlist\")).get(\"webapps\");\n+            Map<String, WebApplication> startedWebAppMap = webApplicationsHolder.getStartedWebapps();\n+            if (startedWebAppMap != null) {\n+\n+                WebApplication webApplication = startedWebAppMap.get(webAppName);\n+                if (webApplication != null) {\n+                    webAppStatus.setWebAppStarted(true);\n+                    log.info(\"Tenant \" + tenantDomain + \" Web-app: \" + webAppName +\n+                            \" is available in configuration context.\");\n+                    boolean isWebAppGhost = Boolean.parseBoolean((String) webApplication.getProperty(\"GhostWebApp\"));\n+                    log.info(\"Tenant \" + tenantDomain + \" Web-app: \" + webAppName + \" is in Ghost deployment status :\" +\n+                            isWebAppGhost);\n+                    webAppStatus.setWebAppGhost(isWebAppGhost);\n+                } else {\n+                    log.info(\"Given web-app:\" + webAppName + \" for tenant:\" + tenantDomain + \" not found in started state\");\n+                    webAppStatus.setWebAppStarted(false);\n+                }\n+\n+            } else {\n+                log.info(\"Tenant \" + tenantDomain + \" has no started web-apps.\");\n+                webAppStatus.setWebAppStarted(false);\n+            }\n+\n+        } else {\n+            log.info(\"Tenant \" + tenantDomain + \" configuration context is not loaded.\");\n+            webAppStatus.setTenantStatus(new TenantStatus(false));\n+        }\n+\n+        return webAppStatus;\n+\n+    }\n+\n+\n+    /**\n+     * Check  the given web-app of super tenant is loaded.\n+     *\n+     * @param webAppName Web-app Name\n+     * @return WebAppStatus  with current status  information about the Web app.\n+     */\n+\n+    protected static WebAppStatus getSuperTenantWebAppStatus(String webAppName) {\n+\n+        WebAppStatus webAppStatus = new WebAppStatus();\n+        webAppStatus.setTenantStatus(new TenantStatus(true)); // Super tenant always loaded;\n+        ConfigurationContext serverConfigurationContext = getServerConfigurationContext();\n+\n+        WebApplicationsHolder webApplicationsHolder = (WebApplicationsHolder) ((HashMap)\n+                serverConfigurationContext.getLocalProperty(\"carbon.webapps.holderlist\")).get(\"webapps\");\n+        Map<String, WebApplication> startedWebAppMap = webApplicationsHolder.getStartedWebapps();\n+        if (startedWebAppMap != null) {\n+            WebApplication webApplication = startedWebAppMap.get(webAppName);\n+            if (webApplication != null) {\n+                webAppStatus.setWebAppStarted(true);\n+                log.info(\"Super Tenant  Web-app: \" + webAppName +\n+                        \" is available in configuration context.\");\n+                boolean isWebAppGhost = Boolean.parseBoolean((String) webApplication.getProperty(\"GhostWebApp\"));\n+                log.info(\"Super Tenant Web-app: \" + webAppName + \" is in Ghost deployment status :\" +\n+                        isWebAppGhost);\n+                webAppStatus.setWebAppGhost(isWebAppGhost);\n+            } else {\n+                log.info(\"Given web-app:\" + webAppName + \" for super tenant  not found in started state\");\n+            }\n+\n+        } else {\n+            log.info(\"Super Tenant has no started web-apps.\");\n+        }\n+        return webAppStatus;\n+    }\n+\n+\n+}","path":"modules/integration/tests-common/common-artifacts/lazy-loading-info/src/main/java/org/wso2/appserver/integration/common/artifacts/lazyloading/LazyLoadingInfoUtil.java","position":176,"original_position":176,"commit_id":"413fec4cfdd48be3529ef7b59a984535ea489f8c","original_commit_id":"413fec4cfdd48be3529ef7b59a984535ea489f8c","user":{"login":"warunap","id":7383632,"avatar_url":"https://avatars.githubusercontent.com/u/7383632?v=3","gravatar_id":"","url":"https://api.github.com/users/warunap","html_url":"https://github.com/warunap","followers_url":"https://api.github.com/users/warunap/followers","following_url":"https://api.github.com/users/warunap/following{/other_user}","gists_url":"https://api.github.com/users/warunap/gists{/gist_id}","starred_url":"https://api.github.com/users/warunap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/warunap/subscriptions","organizations_url":"https://api.github.com/users/warunap/orgs","repos_url":"https://api.github.com/users/warunap/repos","events_url":"https://api.github.com/users/warunap/events{/privacy}","received_events_url":"https://api.github.com/users/warunap/received_events","type":"User","site_admin":false},"body":"why do we need two methods here? Cant we get the status with previous method by passing \"carbon.super\"?","created_at":"2015-04-20T04:16:29Z","updated_at":"2015-04-20T04:16:29Z","html_url":"https://github.com/wso2/product-as/pull/48#discussion_r28663310","pull_request_url":"https://api.github.com/repos/wso2/product-as/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/wso2/product-as/pulls/comments/28663310"},"html":{"href":"https://github.com/wso2/product-as/pull/48#discussion_r28663310"},"pull_request":{"href":"https://api.github.com/repos/wso2/product-as/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/product-as/pulls/48","id":30141258,"html_url":"https://github.com/wso2/product-as/pull/48","diff_url":"https://github.com/wso2/product-as/pull/48.diff","patch_url":"https://github.com/wso2/product-as/pull/48.patch","issue_url":"https://api.github.com/repos/wso2/product-as/issues/48","number":48,"state":"open","locked":false,"title":"Implementation of  Ghost deployment(Lazy Loading) test cases for WSO2 AS (JIRI TA-591)","user":{"login":"sanethd","id":9712144,"avatar_url":"https://avatars.githubusercontent.com/u/9712144?v=3","gravatar_id":"","url":"https://api.github.com/users/sanethd","html_url":"https://github.com/sanethd","followers_url":"https://api.github.com/users/sanethd/followers","following_url":"https://api.github.com/users/sanethd/following{/other_user}","gists_url":"https://api.github.com/users/sanethd/gists{/gist_id}","starred_url":"https://api.github.com/users/sanethd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanethd/subscriptions","organizations_url":"https://api.github.com/users/sanethd/orgs","repos_url":"https://api.github.com/users/sanethd/repos","events_url":"https://api.github.com/users/sanethd/events{/privacy}","received_events_url":"https://api.github.com/users/sanethd/received_events","type":"User","site_admin":false},"body":"Implementation of  Ghost deployment(Lazy Loading) test cases for WSO2 AS (JIRI TA-591)\r\nthis includes\r\n1) Ghost deployment (Lazy Loading) test caes for WSO2 AS.\r\n2) Rest web service artefact  to retrieve the web-app/tenant lazy loading information.\r\n3) add new  \"tests-common\" module in between  \"modules/integration\" and  other common sub modules like \"tests-common/admin-client\",\"tests-common/ui-pages\",\"tests-common/integration-test-utils\". \r\n ","created_at":"2015-02-27T04:34:54Z","updated_at":"2015-04-20T04:16:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7406aa8f7535d2daff089ede4b9bbe3d5b8276c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2/product-as/pulls/48/commits","review_comments_url":"https://api.github.com/repos/wso2/product-as/pulls/48/comments","review_comment_url":"https://api.github.com/repos/wso2/product-as/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/product-as/issues/48/comments","statuses_url":"https://api.github.com/repos/wso2/product-as/statuses/413fec4cfdd48be3529ef7b59a984535ea489f8c","head":{"label":"sanethd:master","ref":"master","sha":"413fec4cfdd48be3529ef7b59a984535ea489f8c","user":{"login":"sanethd","id":9712144,"avatar_url":"https://avatars.githubusercontent.com/u/9712144?v=3","gravatar_id":"","url":"https://api.github.com/users/sanethd","html_url":"https://github.com/sanethd","followers_url":"https://api.github.com/users/sanethd/followers","following_url":"https://api.github.com/users/sanethd/following{/other_user}","gists_url":"https://api.github.com/users/sanethd/gists{/gist_id}","starred_url":"https://api.github.com/users/sanethd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanethd/subscriptions","organizations_url":"https://api.github.com/users/sanethd/orgs","repos_url":"https://api.github.com/users/sanethd/repos","events_url":"https://api.github.com/users/sanethd/events{/privacy}","received_events_url":"https://api.github.com/users/sanethd/received_events","type":"User","site_admin":false},"repo":{"id":30750976,"name":"product-as","full_name":"sanethd/product-as","owner":{"login":"sanethd","id":9712144,"avatar_url":"https://avatars.githubusercontent.com/u/9712144?v=3","gravatar_id":"","url":"https://api.github.com/users/sanethd","html_url":"https://github.com/sanethd","followers_url":"https://api.github.com/users/sanethd/followers","following_url":"https://api.github.com/users/sanethd/following{/other_user}","gists_url":"https://api.github.com/users/sanethd/gists{/gist_id}","starred_url":"https://api.github.com/users/sanethd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanethd/subscriptions","organizations_url":"https://api.github.com/users/sanethd/orgs","repos_url":"https://api.github.com/users/sanethd/repos","events_url":"https://api.github.com/users/sanethd/events{/privacy}","received_events_url":"https://api.github.com/users/sanethd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sanethd/product-as","description":"","fork":true,"url":"https://api.github.com/repos/sanethd/product-as","forks_url":"https://api.github.com/repos/sanethd/product-as/forks","keys_url":"https://api.github.com/repos/sanethd/product-as/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sanethd/product-as/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sanethd/product-as/teams","hooks_url":"https://api.github.com/repos/sanethd/product-as/hooks","issue_events_url":"https://api.github.com/repos/sanethd/product-as/issues/events{/number}","events_url":"https://api.github.com/repos/sanethd/product-as/events","assignees_url":"https://api.github.com/repos/sanethd/product-as/assignees{/user}","branches_url":"https://api.github.com/repos/sanethd/product-as/branches{/branch}","tags_url":"https://api.github.com/repos/sanethd/product-as/tags","blobs_url":"https://api.github.com/repos/sanethd/product-as/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sanethd/product-as/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sanethd/product-as/git/refs{/sha}","trees_url":"https://api.github.com/repos/sanethd/product-as/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sanethd/product-as/statuses/{sha}","languages_url":"https://api.github.com/repos/sanethd/product-as/languages","stargazers_url":"https://api.github.com/repos/sanethd/product-as/stargazers","contributors_url":"https://api.github.com/repos/sanethd/product-as/contributors","subscribers_url":"https://api.github.com/repos/sanethd/product-as/subscribers","subscription_url":"https://api.github.com/repos/sanethd/product-as/subscription","commits_url":"https://api.github.com/repos/sanethd/product-as/commits{/sha}","git_commits_url":"https://api.github.com/repos/sanethd/product-as/git/commits{/sha}","comments_url":"https://api.github.com/repos/sanethd/product-as/comments{/number}","issue_comment_url":"https://api.github.com/repos/sanethd/product-as/issues/comments{/number}","contents_url":"https://api.github.com/repos/sanethd/product-as/contents/{+path}","compare_url":"https://api.github.com/repos/sanethd/product-as/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sanethd/product-as/merges","archive_url":"https://api.github.com/repos/sanethd/product-as/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sanethd/product-as/downloads","issues_url":"https://api.github.com/repos/sanethd/product-as/issues{/number}","pulls_url":"https://api.github.com/repos/sanethd/product-as/pulls{/number}","milestones_url":"https://api.github.com/repos/sanethd/product-as/milestones{/number}","notifications_url":"https://api.github.com/repos/sanethd/product-as/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sanethd/product-as/labels{/name}","releases_url":"https://api.github.com/repos/sanethd/product-as/releases{/id}","created_at":"2015-02-13T10:06:11Z","updated_at":"2015-03-14T04:48:40Z","pushed_at":"2015-03-14T04:48:38Z","git_url":"git://github.com/sanethd/product-as.git","ssh_url":"git@github.com:sanethd/product-as.git","clone_url":"https://github.com/sanethd/product-as.git","svn_url":"https://github.com/sanethd/product-as","homepage":null,"size":42079,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"fa3b7e20eecdc754549a4b4211e84ac76ae93385","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":16947368,"name":"product-as","full_name":"wso2/product-as","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-as","description":"","fork":false,"url":"https://api.github.com/repos/wso2/product-as","forks_url":"https://api.github.com/repos/wso2/product-as/forks","keys_url":"https://api.github.com/repos/wso2/product-as/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/product-as/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/product-as/teams","hooks_url":"https://api.github.com/repos/wso2/product-as/hooks","issue_events_url":"https://api.github.com/repos/wso2/product-as/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/product-as/events","assignees_url":"https://api.github.com/repos/wso2/product-as/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/product-as/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/product-as/tags","blobs_url":"https://api.github.com/repos/wso2/product-as/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/product-as/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/product-as/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/product-as/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/product-as/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/product-as/languages","stargazers_url":"https://api.github.com/repos/wso2/product-as/stargazers","contributors_url":"https://api.github.com/repos/wso2/product-as/contributors","subscribers_url":"https://api.github.com/repos/wso2/product-as/subscribers","subscription_url":"https://api.github.com/repos/wso2/product-as/subscription","commits_url":"https://api.github.com/repos/wso2/product-as/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/product-as/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/product-as/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/product-as/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/product-as/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/product-as/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/product-as/merges","archive_url":"https://api.github.com/repos/wso2/product-as/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/product-as/downloads","issues_url":"https://api.github.com/repos/wso2/product-as/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/product-as/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/product-as/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/product-as/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/product-as/labels{/name}","releases_url":"https://api.github.com/repos/wso2/product-as/releases{/id}","created_at":"2014-02-18T11:57:09Z","updated_at":"2015-03-05T11:09:15Z","pushed_at":"2015-04-10T16:25:11Z","git_url":"git://github.com/wso2/product-as.git","ssh_url":"git@github.com:wso2/product-as.git","clone_url":"https://github.com/wso2/product-as.git","svn_url":"https://github.com/wso2/product-as","homepage":null,"size":45474,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":16,"forks":36,"open_issues":16,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/product-as/pulls/48"},"html":{"href":"https://github.com/wso2/product-as/pull/48"},"issue":{"href":"https://api.github.com/repos/wso2/product-as/issues/48"},"comments":{"href":"https://api.github.com/repos/wso2/product-as/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/product-as/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/product-as/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/product-as/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/product-as/statuses/413fec4cfdd48be3529ef7b59a984535ea489f8c"}}}}