{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/carbon-uuf/pulls/comments/40765363","id":40765363,"diff_hunk":"@@ -0,0 +1,115 @@\n+function getConfigurations(isCachingEnabled) {\n+    // TODO: implement a proper caching mechanism\n+    var configs = require(\"configs.json\");\n+    configs.isCachingEnabled = isCachingEnabled;\n+    return configs;\n+}\n+\n+function getLookUpTable(configs) {\n+    // TODO: implement a proper caching mechanism\n+    var log = new Log(\"utils-app-context\");\n+\n+    function getLayoutsData(layoutsDir) {\n+        var layoutsData = {};\n+        var layoutsFiles = new File(layoutsDir).listFiles();\n+        for (var i = 0; i < layoutsFiles.length; i++) {\n+            var layoutFile = layoutsFiles[i];\n+            if (layoutFile.isDirectory()) {\n+                // this is not a layout, ignore\n+                continue;\n+            }\n+\n+            layoutsData[layoutFile.getName()] = {\n+                path: layoutFile.getPath()\n+            }\n+        }\n+        return layoutsData;\n+    }\n+\n+    /**\n+     * Returns unit's data.\n+     * @param unitsDir {string} path to the units directory e.g. \"/app/units\"\n+     * @return {{\n+     *          units: Object<string, {name: string, path: string, definition: Object}>,\n+     *          pushedUnits: Object<string, string[]>,\n+     *          extendedUnits: Object.<string, string[]>}} unit data\n+     */\n+    function getUnitsData(unitsDir) {\n+        /**\n+         * @type {Object<string, {shortName: string, path: string, definition: Object}>}\n+         */\n+        var units = {};\n+        /**\n+         * @type {Object<string, string[]>}\n+         */\n+        var pushedUnits = {};\n+        /**\n+         * @type {Object<string, string[]>}\n+         */\n+        var extendedUnits = {};\n+        var unitDirs = new File(unitsDir).listFiles();\n+        for (var i = 0; i < unitDirs.length; i++) {\n+            var unitDir = unitDirs[i];\n+            if (!unitDir.isDirectory()) {\n+                // this is not an unit, ignore\n+                continue;\n+            }\n+\n+            var unitFullName = unitDir.getName();\n+            var unitShortName = unitFullName.split(\".\").pop();\n+            var unitPath = unitsDir + \"/\" + unitFullName;\n+            // Unit's definition is read form the <unit_short_name>.json file.\n+            // If doesn't exits it will be an empty JSON.\n+            var unitDefinition = {};\n+            var definitionFile = new File(unitPath + \"/\" + unitShortName + \".json\");\n+            if (definitionFile.isExists() && !definitionFile.isDirectory()) {\n+                unitDefinition = require(definitionFile.getPath());\n+            } else {\n+                log.warn(\"Unable to find a definition file for unit '\" + unitFullName + \"'\");\n+            }\n+            units[unitFullName] = {\n+                shortName: unitShortName,\n+                path: unitPath,\n+                definition: unitDefinition\n+            };\n+\n+            var uriPatterns = unitDefinition.scope;\n+            if (uriPatterns && Array.isArray(uriPatterns)) {\n+                for (var j = 0; j < uriPatterns.length; j++) {\n+                    var uriPattern = uriPatterns[j];\n+                    if (!pushedUnits[uriPattern]) {\n+                        pushedUnits[uriPattern] = [];\n+                    }\n+                    pushedUnits[uriPattern].push(unitFullName);\n+                }\n+            }\n+\n+            var parentUnitName = unitDefinition.extends;\n+            if (parentUnitName) {\n+                if (!extendedUnits[parentUnitName]) {\n+                    extendedUnits[parentUnitName] = [];\n+                }\n+                extendedUnits[parentUnitName].push(unitFullName);","path":"lib/utils.js","position":null,"original_position":92,"commit_id":"9b94361246d2c1e315ab9c1fd76773fd1e7e7e61","original_commit_id":"21f22e5d6cca764456ae506aefa96ca3cb8520b4","user":{"login":"sajithar","id":11549922,"avatar_url":"https://avatars.githubusercontent.com/u/11549922?v=3","gravatar_id":"","url":"https://api.github.com/users/sajithar","html_url":"https://github.com/sajithar","followers_url":"https://api.github.com/users/sajithar/followers","following_url":"https://api.github.com/users/sajithar/following{/other_user}","gists_url":"https://api.github.com/users/sajithar/gists{/gist_id}","starred_url":"https://api.github.com/users/sajithar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sajithar/subscriptions","organizations_url":"https://api.github.com/users/sajithar/orgs","repos_url":"https://api.github.com/users/sajithar/repos","events_url":"https://api.github.com/users/sajithar/events{/privacy}","received_events_url":"https://api.github.com/users/sajithar/received_events","type":"User","site_admin":false},"body":"fixed in commit 9b94361246d2c1e315ab9c1fd76773fd1e7e7e61","created_at":"2015-09-30T07:31:56Z","updated_at":"2015-09-30T07:31:56Z","html_url":"https://github.com/wso2/carbon-uuf/pull/1#discussion_r40765363","pull_request_url":"https://api.github.com/repos/wso2/carbon-uuf/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-uuf/pulls/comments/40765363"},"html":{"href":"https://github.com/wso2/carbon-uuf/pull/1#discussion_r40765363"},"pull_request":{"href":"https://api.github.com/repos/wso2/carbon-uuf/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/carbon-uuf/pulls/1","id":45650087,"html_url":"https://github.com/wso2/carbon-uuf/pull/1","diff_url":"https://github.com/wso2/carbon-uuf/pull/1.diff","patch_url":"https://github.com/wso2/carbon-uuf/pull/1.patch","issue_url":"https://api.github.com/repos/wso2/carbon-uuf/issues/1","number":1,"state":"open","locked":false,"title":"UUF Re-write","user":{"login":"sajithar","id":11549922,"avatar_url":"https://avatars.githubusercontent.com/u/11549922?v=3","gravatar_id":"","url":"https://api.github.com/users/sajithar","html_url":"https://github.com/sajithar","followers_url":"https://api.github.com/users/sajithar/followers","following_url":"https://api.github.com/users/sajithar/following{/other_user}","gists_url":"https://api.github.com/users/sajithar/gists{/gist_id}","starred_url":"https://api.github.com/users/sajithar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sajithar/subscriptions","organizations_url":"https://api.github.com/users/sajithar/orgs","repos_url":"https://api.github.com/users/sajithar/repos","events_url":"https://api.github.com/users/sajithar/events{/privacy}","received_events_url":"https://api.github.com/users/sajithar/received_events","type":"User","site_admin":false},"body":"Removed files & folders (layouts, pages, units) that belong to the deployed app.\r\nRemoved 'fuse'.\r\nAdded new static file router, dynamic file router and debugging handler.\r\nAdded new rendering Handlebars helpers.\r\nAdded clean `less-rhino-1.7.5.js` library.\r\nUpdated the `jaggery.conf`.\r\nUpdated the readme.\r\nAdded Git ignores.","created_at":"2015-09-22T11:00:21Z","updated_at":"2015-09-30T07:31:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d6ec8fcd9b683b25a47d16f388aeb3eebcd93ae","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-uuf/pulls/1/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-uuf/pulls/1/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-uuf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-uuf/issues/1/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-uuf/statuses/9b94361246d2c1e315ab9c1fd76773fd1e7e7e61","head":{"label":"sajithar:master","ref":"master","sha":"9b94361246d2c1e315ab9c1fd76773fd1e7e7e61","user":{"login":"sajithar","id":11549922,"avatar_url":"https://avatars.githubusercontent.com/u/11549922?v=3","gravatar_id":"","url":"https://api.github.com/users/sajithar","html_url":"https://github.com/sajithar","followers_url":"https://api.github.com/users/sajithar/followers","following_url":"https://api.github.com/users/sajithar/following{/other_user}","gists_url":"https://api.github.com/users/sajithar/gists{/gist_id}","starred_url":"https://api.github.com/users/sajithar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sajithar/subscriptions","organizations_url":"https://api.github.com/users/sajithar/orgs","repos_url":"https://api.github.com/users/sajithar/repos","events_url":"https://api.github.com/users/sajithar/events{/privacy}","received_events_url":"https://api.github.com/users/sajithar/received_events","type":"User","site_admin":false},"repo":{"id":41596111,"name":"carbon-uuf","full_name":"sajithar/carbon-uuf","owner":{"login":"sajithar","id":11549922,"avatar_url":"https://avatars.githubusercontent.com/u/11549922?v=3","gravatar_id":"","url":"https://api.github.com/users/sajithar","html_url":"https://github.com/sajithar","followers_url":"https://api.github.com/users/sajithar/followers","following_url":"https://api.github.com/users/sajithar/following{/other_user}","gists_url":"https://api.github.com/users/sajithar/gists{/gist_id}","starred_url":"https://api.github.com/users/sajithar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sajithar/subscriptions","organizations_url":"https://api.github.com/users/sajithar/orgs","repos_url":"https://api.github.com/users/sajithar/repos","events_url":"https://api.github.com/users/sajithar/events{/privacy}","received_events_url":"https://api.github.com/users/sajithar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sajithar/carbon-uuf","description":"","fork":true,"url":"https://api.github.com/repos/sajithar/carbon-uuf","forks_url":"https://api.github.com/repos/sajithar/carbon-uuf/forks","keys_url":"https://api.github.com/repos/sajithar/carbon-uuf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sajithar/carbon-uuf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sajithar/carbon-uuf/teams","hooks_url":"https://api.github.com/repos/sajithar/carbon-uuf/hooks","issue_events_url":"https://api.github.com/repos/sajithar/carbon-uuf/issues/events{/number}","events_url":"https://api.github.com/repos/sajithar/carbon-uuf/events","assignees_url":"https://api.github.com/repos/sajithar/carbon-uuf/assignees{/user}","branches_url":"https://api.github.com/repos/sajithar/carbon-uuf/branches{/branch}","tags_url":"https://api.github.com/repos/sajithar/carbon-uuf/tags","blobs_url":"https://api.github.com/repos/sajithar/carbon-uuf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sajithar/carbon-uuf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sajithar/carbon-uuf/git/refs{/sha}","trees_url":"https://api.github.com/repos/sajithar/carbon-uuf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sajithar/carbon-uuf/statuses/{sha}","languages_url":"https://api.github.com/repos/sajithar/carbon-uuf/languages","stargazers_url":"https://api.github.com/repos/sajithar/carbon-uuf/stargazers","contributors_url":"https://api.github.com/repos/sajithar/carbon-uuf/contributors","subscribers_url":"https://api.github.com/repos/sajithar/carbon-uuf/subscribers","subscription_url":"https://api.github.com/repos/sajithar/carbon-uuf/subscription","commits_url":"https://api.github.com/repos/sajithar/carbon-uuf/commits{/sha}","git_commits_url":"https://api.github.com/repos/sajithar/carbon-uuf/git/commits{/sha}","comments_url":"https://api.github.com/repos/sajithar/carbon-uuf/comments{/number}","issue_comment_url":"https://api.github.com/repos/sajithar/carbon-uuf/issues/comments{/number}","contents_url":"https://api.github.com/repos/sajithar/carbon-uuf/contents/{+path}","compare_url":"https://api.github.com/repos/sajithar/carbon-uuf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sajithar/carbon-uuf/merges","archive_url":"https://api.github.com/repos/sajithar/carbon-uuf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sajithar/carbon-uuf/downloads","issues_url":"https://api.github.com/repos/sajithar/carbon-uuf/issues{/number}","pulls_url":"https://api.github.com/repos/sajithar/carbon-uuf/pulls{/number}","milestones_url":"https://api.github.com/repos/sajithar/carbon-uuf/milestones{/number}","notifications_url":"https://api.github.com/repos/sajithar/carbon-uuf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sajithar/carbon-uuf/labels{/name}","releases_url":"https://api.github.com/repos/sajithar/carbon-uuf/releases{/id}","created_at":"2015-08-29T14:30:07Z","updated_at":"2015-08-29T14:30:07Z","pushed_at":"2015-09-30T07:30:32Z","git_url":"git://github.com/sajithar/carbon-uuf.git","ssh_url":"git@github.com:sajithar/carbon-uuf.git","clone_url":"https://github.com/sajithar/carbon-uuf.git","svn_url":"https://github.com/sajithar/carbon-uuf","homepage":null,"size":563,"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":"2015ef0cd0205147bdf25a8c4ecf7055c0295c47","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":32568128,"name":"carbon-uuf","full_name":"wso2/carbon-uuf","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-uuf","description":"","fork":false,"url":"https://api.github.com/repos/wso2/carbon-uuf","forks_url":"https://api.github.com/repos/wso2/carbon-uuf/forks","keys_url":"https://api.github.com/repos/wso2/carbon-uuf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-uuf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-uuf/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-uuf/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-uuf/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-uuf/events","assignees_url":"https://api.github.com/repos/wso2/carbon-uuf/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-uuf/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-uuf/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-uuf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-uuf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-uuf/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-uuf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-uuf/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-uuf/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-uuf/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-uuf/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-uuf/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-uuf/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-uuf/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-uuf/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-uuf/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-uuf/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-uuf/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-uuf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-uuf/merges","archive_url":"https://api.github.com/repos/wso2/carbon-uuf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-uuf/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-uuf/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-uuf/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-uuf/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-uuf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-uuf/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-uuf/releases{/id}","created_at":"2015-03-20T06:59:30Z","updated_at":"2015-06-18T12:47:01Z","pushed_at":"2015-09-30T07:30:32Z","git_url":"git://github.com/wso2/carbon-uuf.git","ssh_url":"git@github.com:wso2/carbon-uuf.git","clone_url":"https://github.com/wso2/carbon-uuf.git","svn_url":"https://github.com/wso2/carbon-uuf","homepage":null,"size":586,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-uuf/pulls/1"},"html":{"href":"https://github.com/wso2/carbon-uuf/pull/1"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-uuf/issues/1"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-uuf/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-uuf/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-uuf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-uuf/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-uuf/statuses/9b94361246d2c1e315ab9c1fd76773fd1e7e7e61"}}}}