{"action":"created","comment":{"url":"https://api.github.com/repos/cloudogu/cas/pulls/comments/84766841","pull_request_review_id":5523590,"id":84766841,"diff_hunk":"@@ -0,0 +1,112 @@\n+/*\n+ * To change this license header, choose License Headers in Project Properties.\n+ * To change this template file, choose Tools | Templates\n+ * and open the template in the editor.\n+ */\n+package de.triology.cas.services;\n+\n+import java.io.BufferedReader;\n+import java.io.FileReader;\n+import java.io.IOException;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.concurrent.ConcurrentHashMap;\n+import mousio.etcd4j.responses.EtcdKeysResponse;\n+import org.apache.commons.lang.StringUtils;\n+import org.jasig.cas.services.RegisteredService;\n+import org.json.simple.JSONArray;\n+import org.json.simple.JSONObject;\n+import org.json.simple.parser.JSONParser;\n+import org.json.simple.parser.ParseException;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+/**\n+ *\n+ * @author mbehlendorf\n+ */\n+public final class EtcdRegistryUtils {\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(EtcdRegistryUtils.class);\n+\n+    private static final JSONParser PARSER = new JSONParser();\n+\n+    public static List<String> convertNodesToStringList(List<EtcdKeysResponse.EtcdNode> nodesFromEtcd) {\n+        List<String> stringList = new ArrayList<>();\n+        for (EtcdKeysResponse.EtcdNode entry : nodesFromEtcd) {\n+            JSONObject json;\n+            try {\n+                json = getCurrentDoguNode(entry);\n+                if (hasCasDependency(json)) {\n+                    stringList.add(json.get(\"Name\").toString());\n+                }\n+            } catch (ParseException ex) {\n+                LOGGER.warn(\"failed to parse EtcdNode to json\", ex);\n+            }\n+\n+        }\n+        return stringList;\n+    }\n+\n+    private static boolean hasCasDependency(JSONObject json) {\n+        return json != null && json.get(\"Dependencies\") != null && ((JSONArray) json.get(\"Dependencies\")).contains(\"cas\");\n+    }\n+\n+    private static JSONObject getCurrentDoguNode(EtcdKeysResponse.EtcdNode doguNode) throws ParseException {\n+        String version = \"\";\n+        JSONObject json = null;\n+        // get used dogu version\n+        for (EtcdKeysResponse.EtcdNode leaf : doguNode.getNodes()) {\n+            if (leaf.getKey().equals(doguNode.getKey() + \"/current\")) {\n+                version = leaf.getValue();\n+            }\n+\n+        }\n+        // empty if dogu isnt used\n+        if (!version.isEmpty()) {\n+            for (EtcdKeysResponse.EtcdNode leaf : doguNode.getNodes()) {\n+                if (leaf.getKey().equals(doguNode.getKey() + \"/\" + version)) {\n+\n+                    json = (JSONObject) PARSER.parse(leaf.getValue());\n+                }\n+            }\n+        }\n+\n+        return json;\n+\n+    }\n+\n+    public static int containsService(List<String> list, RegisteredService registeredService) {","path":"src/main/java/de/triology/cas/services/EtcdRegistryUtils.java","position":80,"original_position":80,"commit_id":"ccf372b50b09ed66e65235b83aec99e467d4f1aa","original_commit_id":"ccf372b50b09ed66e65235b83aec99e467d4f1aa","user":{"login":"sdorra","id":493333,"avatar_url":"https://avatars.githubusercontent.com/u/493333?v=3","gravatar_id":"","url":"https://api.github.com/users/sdorra","html_url":"https://github.com/sdorra","followers_url":"https://api.github.com/users/sdorra/followers","following_url":"https://api.github.com/users/sdorra/following{/other_user}","gists_url":"https://api.github.com/users/sdorra/gists{/gist_id}","starred_url":"https://api.github.com/users/sdorra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdorra/subscriptions","organizations_url":"https://api.github.com/users/sdorra/orgs","repos_url":"https://api.github.com/users/sdorra/repos","events_url":"https://api.github.com/users/sdorra/events{/privacy}","received_events_url":"https://api.github.com/users/sdorra/received_events","type":"User","site_admin":false},"body":"Missing javadoc, each public api should be documented.","created_at":"2016-10-24T19:41:23Z","updated_at":"2016-10-24T19:41:23Z","html_url":"https://github.com/cloudogu/cas/pull/14#discussion_r84766841","pull_request_url":"https://api.github.com/repos/cloudogu/cas/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/cloudogu/cas/pulls/comments/84766841"},"html":{"href":"https://github.com/cloudogu/cas/pull/14#discussion_r84766841"},"pull_request":{"href":"https://api.github.com/repos/cloudogu/cas/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/cloudogu/cas/pulls/14","id":90610165,"html_url":"https://github.com/cloudogu/cas/pull/14","diff_url":"https://github.com/cloudogu/cas/pull/14.diff","patch_url":"https://github.com/cloudogu/cas/pull/14.patch","issue_url":"https://api.github.com/repos/cloudogu/cas/issues/14","number":14,"state":"open","locked":false,"title":"improved EtcdServicesManager #13","user":{"login":"mbehlendorf","id":13451512,"avatar_url":"https://avatars.githubusercontent.com/u/13451512?v=3","gravatar_id":"","url":"https://api.github.com/users/mbehlendorf","html_url":"https://github.com/mbehlendorf","followers_url":"https://api.github.com/users/mbehlendorf/followers","following_url":"https://api.github.com/users/mbehlendorf/following{/other_user}","gists_url":"https://api.github.com/users/mbehlendorf/gists{/gist_id}","starred_url":"https://api.github.com/users/mbehlendorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbehlendorf/subscriptions","organizations_url":"https://api.github.com/users/mbehlendorf/orgs","repos_url":"https://api.github.com/users/mbehlendorf/repos","events_url":"https://api.github.com/users/mbehlendorf/events{/privacy}","received_events_url":"https://api.github.com/users/mbehlendorf/received_events","type":"User","site_admin":false},"body":"resolves #13 ","created_at":"2016-10-24T13:19:12Z","updated_at":"2016-10-24T19:48:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"336232526ea79a9031db37f01c9f2161b9c8a127","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cloudogu/cas/pulls/14/commits","review_comments_url":"https://api.github.com/repos/cloudogu/cas/pulls/14/comments","review_comment_url":"https://api.github.com/repos/cloudogu/cas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudogu/cas/issues/14/comments","statuses_url":"https://api.github.com/repos/cloudogu/cas/statuses/ccf372b50b09ed66e65235b83aec99e467d4f1aa","head":{"label":"cloudogu:feature/13-RefactoringESM","ref":"feature/13-RefactoringESM","sha":"ccf372b50b09ed66e65235b83aec99e467d4f1aa","user":{"login":"cloudogu","id":13451207,"avatar_url":"https://avatars.githubusercontent.com/u/13451207?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudogu","html_url":"https://github.com/cloudogu","followers_url":"https://api.github.com/users/cloudogu/followers","following_url":"https://api.github.com/users/cloudogu/following{/other_user}","gists_url":"https://api.github.com/users/cloudogu/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudogu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudogu/subscriptions","organizations_url":"https://api.github.com/users/cloudogu/orgs","repos_url":"https://api.github.com/users/cloudogu/repos","events_url":"https://api.github.com/users/cloudogu/events{/privacy}","received_events_url":"https://api.github.com/users/cloudogu/received_events","type":"Organization","site_admin":false},"repo":{"id":39615554,"name":"cas","full_name":"cloudogu/cas","owner":{"login":"cloudogu","id":13451207,"avatar_url":"https://avatars.githubusercontent.com/u/13451207?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudogu","html_url":"https://github.com/cloudogu","followers_url":"https://api.github.com/users/cloudogu/followers","following_url":"https://api.github.com/users/cloudogu/following{/other_user}","gists_url":"https://api.github.com/users/cloudogu/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudogu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudogu/subscriptions","organizations_url":"https://api.github.com/users/cloudogu/orgs","repos_url":"https://api.github.com/users/cloudogu/repos","events_url":"https://api.github.com/users/cloudogu/events{/privacy}","received_events_url":"https://api.github.com/users/cloudogu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudogu/cas","description":"CAS Server","fork":false,"url":"https://api.github.com/repos/cloudogu/cas","forks_url":"https://api.github.com/repos/cloudogu/cas/forks","keys_url":"https://api.github.com/repos/cloudogu/cas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudogu/cas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudogu/cas/teams","hooks_url":"https://api.github.com/repos/cloudogu/cas/hooks","issue_events_url":"https://api.github.com/repos/cloudogu/cas/issues/events{/number}","events_url":"https://api.github.com/repos/cloudogu/cas/events","assignees_url":"https://api.github.com/repos/cloudogu/cas/assignees{/user}","branches_url":"https://api.github.com/repos/cloudogu/cas/branches{/branch}","tags_url":"https://api.github.com/repos/cloudogu/cas/tags","blobs_url":"https://api.github.com/repos/cloudogu/cas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudogu/cas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudogu/cas/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudogu/cas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudogu/cas/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudogu/cas/languages","stargazers_url":"https://api.github.com/repos/cloudogu/cas/stargazers","contributors_url":"https://api.github.com/repos/cloudogu/cas/contributors","subscribers_url":"https://api.github.com/repos/cloudogu/cas/subscribers","subscription_url":"https://api.github.com/repos/cloudogu/cas/subscription","commits_url":"https://api.github.com/repos/cloudogu/cas/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudogu/cas/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudogu/cas/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudogu/cas/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudogu/cas/contents/{+path}","compare_url":"https://api.github.com/repos/cloudogu/cas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudogu/cas/merges","archive_url":"https://api.github.com/repos/cloudogu/cas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudogu/cas/downloads","issues_url":"https://api.github.com/repos/cloudogu/cas/issues{/number}","pulls_url":"https://api.github.com/repos/cloudogu/cas/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudogu/cas/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudogu/cas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudogu/cas/labels{/name}","releases_url":"https://api.github.com/repos/cloudogu/cas/releases{/id}","deployments_url":"https://api.github.com/repos/cloudogu/cas/deployments","created_at":"2015-07-24T06:26:57Z","updated_at":"2016-07-19T08:02:46Z","pushed_at":"2016-10-24T13:19:13Z","git_url":"git://github.com/cloudogu/cas.git","ssh_url":"git@github.com:cloudogu/cas.git","clone_url":"https://github.com/cloudogu/cas.git","svn_url":"https://github.com/cloudogu/cas","homepage":null,"size":1270,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"develop"}},"base":{"label":"cloudogu:develop","ref":"develop","sha":"27c3ed0040f78ad73a913743a66ca66dd4100177","user":{"login":"cloudogu","id":13451207,"avatar_url":"https://avatars.githubusercontent.com/u/13451207?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudogu","html_url":"https://github.com/cloudogu","followers_url":"https://api.github.com/users/cloudogu/followers","following_url":"https://api.github.com/users/cloudogu/following{/other_user}","gists_url":"https://api.github.com/users/cloudogu/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudogu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudogu/subscriptions","organizations_url":"https://api.github.com/users/cloudogu/orgs","repos_url":"https://api.github.com/users/cloudogu/repos","events_url":"https://api.github.com/users/cloudogu/events{/privacy}","received_events_url":"https://api.github.com/users/cloudogu/received_events","type":"Organization","site_admin":false},"repo":{"id":39615554,"name":"cas","full_name":"cloudogu/cas","owner":{"login":"cloudogu","id":13451207,"avatar_url":"https://avatars.githubusercontent.com/u/13451207?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudogu","html_url":"https://github.com/cloudogu","followers_url":"https://api.github.com/users/cloudogu/followers","following_url":"https://api.github.com/users/cloudogu/following{/other_user}","gists_url":"https://api.github.com/users/cloudogu/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudogu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudogu/subscriptions","organizations_url":"https://api.github.com/users/cloudogu/orgs","repos_url":"https://api.github.com/users/cloudogu/repos","events_url":"https://api.github.com/users/cloudogu/events{/privacy}","received_events_url":"https://api.github.com/users/cloudogu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudogu/cas","description":"CAS Server","fork":false,"url":"https://api.github.com/repos/cloudogu/cas","forks_url":"https://api.github.com/repos/cloudogu/cas/forks","keys_url":"https://api.github.com/repos/cloudogu/cas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudogu/cas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudogu/cas/teams","hooks_url":"https://api.github.com/repos/cloudogu/cas/hooks","issue_events_url":"https://api.github.com/repos/cloudogu/cas/issues/events{/number}","events_url":"https://api.github.com/repos/cloudogu/cas/events","assignees_url":"https://api.github.com/repos/cloudogu/cas/assignees{/user}","branches_url":"https://api.github.com/repos/cloudogu/cas/branches{/branch}","tags_url":"https://api.github.com/repos/cloudogu/cas/tags","blobs_url":"https://api.github.com/repos/cloudogu/cas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudogu/cas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudogu/cas/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudogu/cas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudogu/cas/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudogu/cas/languages","stargazers_url":"https://api.github.com/repos/cloudogu/cas/stargazers","contributors_url":"https://api.github.com/repos/cloudogu/cas/contributors","subscribers_url":"https://api.github.com/repos/cloudogu/cas/subscribers","subscription_url":"https://api.github.com/repos/cloudogu/cas/subscription","commits_url":"https://api.github.com/repos/cloudogu/cas/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudogu/cas/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudogu/cas/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudogu/cas/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudogu/cas/contents/{+path}","compare_url":"https://api.github.com/repos/cloudogu/cas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudogu/cas/merges","archive_url":"https://api.github.com/repos/cloudogu/cas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudogu/cas/downloads","issues_url":"https://api.github.com/repos/cloudogu/cas/issues{/number}","pulls_url":"https://api.github.com/repos/cloudogu/cas/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudogu/cas/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudogu/cas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudogu/cas/labels{/name}","releases_url":"https://api.github.com/repos/cloudogu/cas/releases{/id}","deployments_url":"https://api.github.com/repos/cloudogu/cas/deployments","created_at":"2015-07-24T06:26:57Z","updated_at":"2016-07-19T08:02:46Z","pushed_at":"2016-10-24T13:19:13Z","git_url":"git://github.com/cloudogu/cas.git","ssh_url":"git@github.com:cloudogu/cas.git","clone_url":"https://github.com/cloudogu/cas.git","svn_url":"https://github.com/cloudogu/cas","homepage":null,"size":1270,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudogu/cas/pulls/14"},"html":{"href":"https://github.com/cloudogu/cas/pull/14"},"issue":{"href":"https://api.github.com/repos/cloudogu/cas/issues/14"},"comments":{"href":"https://api.github.com/repos/cloudogu/cas/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudogu/cas/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudogu/cas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudogu/cas/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/cloudogu/cas/statuses/ccf372b50b09ed66e65235b83aec99e467d4f1aa"}}}}
{"actor":{"display_login":"sdorra"}}