{"action":"created","comment":{"url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/comments/30785505","id":30785505,"diff_hunk":"@@ -101,22 +142,55 @@ public void initialize() {\n                     continue;\n                 } // if\n                 \n-                String[] tokens = line.split(\"\\\\|\");\n-                \n-                if (tokens.length < 5 || tokens[0].length() == 0 || tokens[1].length() == 0 || tokens[2].length() == 0\n-                        || tokens[3].length() == 0 || tokens[4].length() == 0) {\n-                    LOGGER.warn(\"Malformed matching rule, it will be discarded. Details=\" + line);\n-                    continue;\n-                } // if\n-                \n-                int id = new Integer(tokens[0]);\n-                ArrayList<String> fields = new ArrayList<String>(Arrays.asList(tokens[1].split(\",\")));\n-                matchingTable.add(new MatchingRule(id, fields, tokens[2], tokens[3], tokens[4]));\n+                jsonStr += line;\n             } // while\n+            \n+            return jsonStr;\n         } catch (IOException e) {\n-            LOGGER.error(\"Runtime error (I/O exception. Details=\" + e.getMessage() + \")\");\n-        } // try catch // try catch\n-    } // initialize\n+            LOGGER.error(\"Error while reading the Json-based grouping rules file. Details=\" + e.getMessage() + \")\");\n+            return null;\n+        } // try catch\n+    } // readGroupingRulesFile\n+    \n+    private JSONArray parseGroupingRules(String jsonStr) {\n+        if (jsonStr == null) {\n+            return null;\n+        } // if\n+        \n+        JSONParser jsonParser = new JSONParser();\n+        \n+        try {\n+            return (JSONArray) ((JSONObject) jsonParser.parse(jsonStr)).get(\"grouping_rules\");\n+        } catch (ParseException e) {\n+            LOGGER.error(\"Error while parsing the Json-based grouping rules file. Details=\" + e.getMessage());\n+            return null;\n+        } // try catch\n+    } // parseGroupingRules\n+    \n+    private LinkedList<GroupingRule> createGroupingRules(JSONArray jsonGroupingRules) {\n+        if (jsonGroupingRules == null) {\n+            return null;\n+        } // if\n+        \n+        groupingRules = new LinkedList<GroupingRule>();\n+        \n+        for (Object jsonGroupingRule : jsonGroupingRules) {\n+            JSONObject jsonRule = (JSONObject) jsonGroupingRule;\n+            \n+            if (isValid(jsonRule)) {","path":"src/main/java/com/telefonica/iot/cygnus/interceptors/GroupingInterceptor.java","position":177,"original_position":177,"commit_id":"d4a6b5e3306f51db68062929c0e196e73346bd42","original_commit_id":"9faf852e518a22f5a6dcbdeb3dcfdad0d246aaaa","user":{"login":"frbattid","id":3865056,"avatar_url":"https://avatars.githubusercontent.com/u/3865056?v=3","gravatar_id":"","url":"https://api.github.com/users/frbattid","html_url":"https://github.com/frbattid","followers_url":"https://api.github.com/users/frbattid/followers","following_url":"https://api.github.com/users/frbattid/following{/other_user}","gists_url":"https://api.github.com/users/frbattid/gists{/gist_id}","starred_url":"https://api.github.com/users/frbattid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbattid/subscriptions","organizations_url":"https://api.github.com/users/frbattid/orgs","repos_url":"https://api.github.com/users/frbattid/repos","events_url":"https://api.github.com/users/frbattid/events{/privacy}","received_events_url":"https://api.github.com/users/frbattid/received_events","type":"User","site_admin":false},"body":"Fixed in https://github.com/telefonicaid/fiware-cygnus/commit/d4a6b5e3306f51db68062929c0e196e73346bd42","created_at":"2015-05-21T09:20:27Z","updated_at":"2015-05-21T09:20:27Z","html_url":"https://github.com/telefonicaid/fiware-cygnus/pull/409#discussion_r30785505","pull_request_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/409","_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/comments/30785505"},"html":{"href":"https://github.com/telefonicaid/fiware-cygnus/pull/409#discussion_r30785505"},"pull_request":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/409"}}},"pull_request":{"url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/409","id":35628678,"html_url":"https://github.com/telefonicaid/fiware-cygnus/pull/409","diff_url":"https://github.com/telefonicaid/fiware-cygnus/pull/409.diff","patch_url":"https://github.com/telefonicaid/fiware-cygnus/pull/409.patch","issue_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues/409","number":409,"state":"open","locked":false,"title":"hardening/387_json_pattern_grouping","user":{"login":"frbattid","id":3865056,"avatar_url":"https://avatars.githubusercontent.com/u/3865056?v=3","gravatar_id":"","url":"https://api.github.com/users/frbattid","html_url":"https://github.com/frbattid","followers_url":"https://api.github.com/users/frbattid/followers","following_url":"https://api.github.com/users/frbattid/following{/other_user}","gists_url":"https://api.github.com/users/frbattid/gists{/gist_id}","starred_url":"https://api.github.com/users/frbattid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbattid/subscriptions","organizations_url":"https://api.github.com/users/frbattid/orgs","repos_url":"https://api.github.com/users/frbattid/repos","events_url":"https://api.github.com/users/frbattid/events{/privacy}","received_events_url":"https://api.github.com/users/frbattid/received_events","type":"User","site_admin":false},"body":"* Fixed issue #387 \r\n* 100% unit tests passed:\r\n```\r\nResults :\r\nTests run: 49, Failures: 0, Errors: 0, Skipped: 0\r\n```\r\n* (unofficial) e2e tests passed:\r\n```\r\n$ cat /Applications/apache-flume-1.4.0-bin/conf/grouping_rules.conf\r\n{\r\n    \"grouping_rules\": [\r\n        {\r\n            \"id\": 1,\r\n            \"fields\": [\r\n                \"entityType\"\r\n            ],\r\n            \"regex\": \"Room\",\r\n            \"destination\": \"test_rooms\",\r\n            \"fiware_service_path\": \"rooms\"\r\n        }\r\n    ]\r\n}\r\n...\r\n$ curl -X GET \"http://130.206.80.46:14000/webhdfs/v1/user/frb/zzz_serv/rooms/test_rooms/test_rooms.txt?op=open&user.name=frb\"\r\n{\"recvTimeTs\":\"1431951901\",\"recvTime\":\"2015-05-18T12:25:01.273Z\",\"entityId\":\"Room1\",\"entityType\":\"Room\",\"attrName\":\"temperature\",\"attrType\":\"centigrade\",\"attrValue\":\"26.5\",\"attrMd\":[]}\r\n```\r\n* Assignee @gtorodelvalle but LGTM from @fgalan is also required. Comments from @iariasleon are welcome as well.","created_at":"2015-05-18T12:32:32Z","updated_at":"2015-05-21T09:20:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"65cff111563d47203d64ed1f1f02a5db901791ec","assignee":{"login":"gtorodelvalle","id":667284,"avatar_url":"https://avatars.githubusercontent.com/u/667284?v=3","gravatar_id":"","url":"https://api.github.com/users/gtorodelvalle","html_url":"https://github.com/gtorodelvalle","followers_url":"https://api.github.com/users/gtorodelvalle/followers","following_url":"https://api.github.com/users/gtorodelvalle/following{/other_user}","gists_url":"https://api.github.com/users/gtorodelvalle/gists{/gist_id}","starred_url":"https://api.github.com/users/gtorodelvalle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtorodelvalle/subscriptions","organizations_url":"https://api.github.com/users/gtorodelvalle/orgs","repos_url":"https://api.github.com/users/gtorodelvalle/repos","events_url":"https://api.github.com/users/gtorodelvalle/events{/privacy}","received_events_url":"https://api.github.com/users/gtorodelvalle/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/409/commits","review_comments_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/409/comments","review_comment_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues/409/comments","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/statuses/d4a6b5e3306f51db68062929c0e196e73346bd42","head":{"label":"telefonicaid:hardening/387_json_patter_grouping","ref":"hardening/387_json_patter_grouping","sha":"d4a6b5e3306f51db68062929c0e196e73346bd42","user":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"repo":{"id":16607947,"name":"fiware-cygnus","full_name":"telefonicaid/fiware-cygnus","owner":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/telefonicaid/fiware-cygnus","description":"FI-WARE connectors","fork":false,"url":"https://api.github.com/repos/telefonicaid/fiware-cygnus","forks_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/forks","keys_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/teams","hooks_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/hooks","issue_events_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues/events{/number}","events_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/events","assignees_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/assignees{/user}","branches_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/branches{/branch}","tags_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/tags","blobs_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/refs{/sha}","trees_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/statuses/{sha}","languages_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/languages","stargazers_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/stargazers","contributors_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/contributors","subscribers_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/subscribers","subscription_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/subscription","commits_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/commits{/sha}","git_commits_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/commits{/sha}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/comments{/number}","issue_comment_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues/comments{/number}","contents_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/contents/{+path}","compare_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/merges","archive_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/downloads","issues_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues{/number}","pulls_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls{/number}","milestones_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/milestones{/number}","notifications_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/labels{/name}","releases_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/releases{/id}","created_at":"2014-02-07T07:57:41Z","updated_at":"2015-05-08T09:59:00Z","pushed_at":"2015-05-21T09:20:16Z","git_url":"git://github.com/telefonicaid/fiware-cygnus.git","ssh_url":"git@github.com:telefonicaid/fiware-cygnus.git","clone_url":"https://github.com/telefonicaid/fiware-cygnus.git","svn_url":"https://github.com/telefonicaid/fiware-cygnus","homepage":"","size":95414,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":46,"forks":9,"open_issues":46,"watchers":13,"default_branch":"master"}},"base":{"label":"telefonicaid:develop","ref":"develop","sha":"06235027b222d421147256f382cd4a76026c1291","user":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"repo":{"id":16607947,"name":"fiware-cygnus","full_name":"telefonicaid/fiware-cygnus","owner":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/telefonicaid/fiware-cygnus","description":"FI-WARE connectors","fork":false,"url":"https://api.github.com/repos/telefonicaid/fiware-cygnus","forks_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/forks","keys_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/teams","hooks_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/hooks","issue_events_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues/events{/number}","events_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/events","assignees_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/assignees{/user}","branches_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/branches{/branch}","tags_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/tags","blobs_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/refs{/sha}","trees_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/statuses/{sha}","languages_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/languages","stargazers_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/stargazers","contributors_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/contributors","subscribers_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/subscribers","subscription_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/subscription","commits_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/commits{/sha}","git_commits_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/git/commits{/sha}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/comments{/number}","issue_comment_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues/comments{/number}","contents_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/contents/{+path}","compare_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/merges","archive_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/downloads","issues_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues{/number}","pulls_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls{/number}","milestones_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/milestones{/number}","notifications_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/labels{/name}","releases_url":"https://api.github.com/repos/telefonicaid/fiware-cygnus/releases{/id}","created_at":"2014-02-07T07:57:41Z","updated_at":"2015-05-08T09:59:00Z","pushed_at":"2015-05-21T09:20:16Z","git_url":"git://github.com/telefonicaid/fiware-cygnus.git","ssh_url":"git@github.com:telefonicaid/fiware-cygnus.git","clone_url":"https://github.com/telefonicaid/fiware-cygnus.git","svn_url":"https://github.com/telefonicaid/fiware-cygnus","homepage":"","size":95414,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":46,"forks":9,"open_issues":46,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/409"},"html":{"href":"https://github.com/telefonicaid/fiware-cygnus/pull/409"},"issue":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues/409"},"comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/issues/409/comments"},"review_comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/409/comments"},"review_comment":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/pulls/409/commits"},"statuses":{"href":"https://api.github.com/repos/telefonicaid/fiware-cygnus/statuses/d4a6b5e3306f51db68062929c0e196e73346bd42"}}}}