{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/che/pulls/comments/85709024","pull_request_review_id":6408098,"id":85709024,"diff_hunk":"@@ -0,0 +1,103 @@\n+/*******************************************************************************\n+ * Copyright (c) 2012-2016 Codenvy, S.A.\n+ * All rights reserved. This program and the accompanying materials\n+ * are made available under the terms of the Eclipse Public License v1.0\n+ * which accompanies this distribution, and is available at\n+ * http://www.eclipse.org/legal/epl-v10.html\n+ *\n+ * Contributors:\n+ *   Codenvy, S.A. - initial API and implementation\n+ *******************************************************************************/\n+package org.eclipse.che.api.environment.server.compose.deserializer;\n+\n+import com.fasterxml.jackson.core.JsonParser;\n+import com.fasterxml.jackson.core.JsonProcessingException;\n+import com.fasterxml.jackson.databind.DeserializationContext;\n+import com.fasterxml.jackson.databind.JsonDeserializer;\n+import com.google.common.collect.ImmutableMap;\n+\n+import java.io.IOException;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+\n+import static java.lang.String.format;\n+\n+/**\n+ * Deserializer of environment section of Docker compose file.\n+ *\n+ * @author Dmytro Nochevnov\n+ */\n+public class EnvironmentDeserializer extends JsonDeserializer<Map<String, String>> {\n+\n+    public static final String ARRAY_ITEM_DIVIDER        = \"=\";\n+    public static final String UNSUPPORTED_VALUE_MESSAGE = \"Unsupported value '%s'.\";\n+\n+    @Override\n+    public Map<String, String> deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException {\n+        Object environment = jsonParser.readValueAs(Object.class);\n+\n+        /* Parse dictionary in view of:\n+           \"environment:\n+             key1: value1\n+             key2: value2\"\n+        */\n+        if (environment instanceof Map) {\n+            return (Map<String, String>) environment;\n+        }\n+\n+        /* Parse array in view of:\n+           \"environment:\n+             - key1=value1\n+             - key2=value2\"\n+        */\n+        try {\n+            if (environment instanceof List) {\n+                // convert array to Map<String, String>{ key1: value1, key2: value2 }\n+                Map<String, String> map = new HashMap<>();\n+                for (String item : (List<String>) environment) {\n+                    map.putAll(parseEnvironmentItem(item));\n+                }\n+\n+                return map;\n+            }\n+        } catch (IllegalArgumentException ie) {\n+            throw ctxt.mappingException(ie.getMessage());\n+\n+        } catch (Exception e) {\n+            throw ctxt.mappingException(format(UNSUPPORTED_VALUE_MESSAGE, environment));\n+        }\n+\n+        // work around empty environment\n+        if (environment instanceof String) {\n+            if (((String) environment).isEmpty()) {\n+                return new HashMap<>();\n+            }\n+\n+            throw ctxt.mappingException(format(UNSUPPORTED_VALUE_MESSAGE, environment));\n+        }\n+\n+        /* Work around unsupported type of environment content, for example, 'Boolean' in case of content:\n+           \"environment:\n+             true\"\n+        */\n+        throw ctxt.mappingException(format(\"Unsupported type '%s'.\", environment.getClass()));\n+    }\n+\n+    /**\n+     * Parse \"key=value\" item.\n+     * @param item - environment array item to parse","path":"wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/environment/server/compose/deserializer/EnvironmentDeserializer.java","position":89,"original_position":89,"commit_id":"d93ab8dc043491c495c30e8efb9ce539e015e239","original_commit_id":"d93ab8dc043491c495c30e8efb9ce539e015e239","user":{"login":"sleshchenko","id":5887312,"avatar_url":"https://avatars.githubusercontent.com/u/5887312?v=3","gravatar_id":"","url":"https://api.github.com/users/sleshchenko","html_url":"https://github.com/sleshchenko","followers_url":"https://api.github.com/users/sleshchenko/followers","following_url":"https://api.github.com/users/sleshchenko/following{/other_user}","gists_url":"https://api.github.com/users/sleshchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/sleshchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleshchenko/subscriptions","organizations_url":"https://api.github.com/users/sleshchenko/orgs","repos_url":"https://api.github.com/users/sleshchenko/repos","events_url":"https://api.github.com/users/sleshchenko/events{/privacy}","received_events_url":"https://api.github.com/users/sleshchenko/received_events","type":"User","site_admin":false},"body":"Java doc is still unformatted correctly","created_at":"2016-10-31T09:53:43Z","updated_at":"2016-10-31T09:56:17Z","html_url":"https://github.com/eclipse/che/pull/2865#discussion_r85709024","pull_request_url":"https://api.github.com/repos/eclipse/che/pulls/2865","_links":{"self":{"href":"https://api.github.com/repos/eclipse/che/pulls/comments/85709024"},"html":{"href":"https://github.com/eclipse/che/pull/2865#discussion_r85709024"},"pull_request":{"href":"https://api.github.com/repos/eclipse/che/pulls/2865"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/che/pulls/2865","id":90532758,"html_url":"https://github.com/eclipse/che/pull/2865","diff_url":"https://github.com/eclipse/che/pull/2865.diff","patch_url":"https://github.com/eclipse/che/pull/2865.patch","issue_url":"https://api.github.com/repos/eclipse/che/issues/2865","number":2865,"state":"open","locked":false,"title":"Support array format for environment in compose file","user":{"login":"dmytro-ndp","id":1197777,"avatar_url":"https://avatars.githubusercontent.com/u/1197777?v=3","gravatar_id":"","url":"https://api.github.com/users/dmytro-ndp","html_url":"https://github.com/dmytro-ndp","followers_url":"https://api.github.com/users/dmytro-ndp/followers","following_url":"https://api.github.com/users/dmytro-ndp/following{/other_user}","gists_url":"https://api.github.com/users/dmytro-ndp/gists{/gist_id}","starred_url":"https://api.github.com/users/dmytro-ndp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmytro-ndp/subscriptions","organizations_url":"https://api.github.com/users/dmytro-ndp/orgs","repos_url":"https://api.github.com/users/dmytro-ndp/repos","events_url":"https://api.github.com/users/dmytro-ndp/events{/privacy}","received_events_url":"https://api.github.com/users/dmytro-ndp/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\n\nFor issue #2624 it adds support of array format of environment variables of _docker compose file_ into the **ComposeServiceImpl** class.\n### Note:\n\nnext variant of class [ComposeServiceImpl](https://github.com/eclipse/che/blob/af4de272e06ec8213eab5a7c4f69ad72088b3d2e/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/environment/server/compose/ComposeServiceImpl.java#L29):\n\n```\n    /** Parse dictionary in view of:\n       \"environment:\n         key1: value1\n         key2: value2\"\n    */\n    public void setEnvironment(Map<String, String> environment) {\n        this.environment = environment;\n    }\n\n    /** Parse array in view of:\n       \"listEnvironment:\n         - key1=value1\n         - key2=value2\"\n    */\n    public void setEnvironment(List<String> listEnvironment) {\n        // convert array to Map<String, String>{ key1: value1, key2: value2 }\n        try {\n            this.environment = listEnvironment.stream()\n                                              .collect(Collectors.toMap(item -> item.split(\"=\")[0],\n                                                                        item -> item.split(\"=\")[1]));\n        } catch (Exception e) {\n            throw new RuntimeException(format(\"Unsupported value '%s'.\", listEnvironment.toString()));\n        }\n    }\n```\n\nleads to parsing error:\n\n> java.lang.IllegalArgumentException: Parsing of environment configuration failed. Conflicting setter definitions for property \"environment\": org.eclipse.che.api.environment.server.compose.ComposeServiceImpl#setEnvironment(1 params) vs org.eclipse.che.api.environment.server.compose.ComposeServiceImpl#setEnvironment(1 params)\n>     at org.eclipse.che.api.environment.server.compose.ComposeFileParser.parse(ComposeFileParser.java:51)\n\n@garagatyi: please, review this request.\n\nSigned-off-by: Dmytro Nochevnov dnochevnov@codenvy.com\n","created_at":"2016-10-23T22:38:39Z","updated_at":"2016-10-31T09:56:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf370527f72a9d282903d8c47b7dbba2d0ca4a6f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/che/pulls/2865/commits","review_comments_url":"https://api.github.com/repos/eclipse/che/pulls/2865/comments","review_comment_url":"https://api.github.com/repos/eclipse/che/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/che/issues/2865/comments","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/d93ab8dc043491c495c30e8efb9ce539e015e239","head":{"label":"eclipse:che-2624","ref":"che-2624","sha":"d93ab8dc043491c495c30e8efb9ce539e015e239","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":32935745,"name":"che","full_name":"eclipse/che","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/che","description":"Eclipse Che: Next-generation Eclipse IDE.  Open source workspace server and cloud IDE.","fork":false,"url":"https://api.github.com/repos/eclipse/che","forks_url":"https://api.github.com/repos/eclipse/che/forks","keys_url":"https://api.github.com/repos/eclipse/che/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/che/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/che/teams","hooks_url":"https://api.github.com/repos/eclipse/che/hooks","issue_events_url":"https://api.github.com/repos/eclipse/che/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/che/events","assignees_url":"https://api.github.com/repos/eclipse/che/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/che/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/che/tags","blobs_url":"https://api.github.com/repos/eclipse/che/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/che/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/che/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/che/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/che/languages","stargazers_url":"https://api.github.com/repos/eclipse/che/stargazers","contributors_url":"https://api.github.com/repos/eclipse/che/contributors","subscribers_url":"https://api.github.com/repos/eclipse/che/subscribers","subscription_url":"https://api.github.com/repos/eclipse/che/subscription","commits_url":"https://api.github.com/repos/eclipse/che/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/che/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/che/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/che/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/che/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/che/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/che/merges","archive_url":"https://api.github.com/repos/eclipse/che/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/che/downloads","issues_url":"https://api.github.com/repos/eclipse/che/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/che/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/che/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/che/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/che/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/che/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/che/deployments","created_at":"2015-03-26T15:31:01Z","updated_at":"2016-10-28T19:37:27Z","pushed_at":"2016-10-31T09:35:16Z","git_url":"git://github.com/eclipse/che.git","ssh_url":"git@github.com:eclipse/che.git","clone_url":"https://github.com/eclipse/che.git","svn_url":"https://github.com/eclipse/che","homepage":"http://eclipse.org/che","size":54987,"stargazers_count":3277,"watchers_count":3277,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":539,"mirror_url":null,"open_issues_count":366,"forks":539,"open_issues":366,"watchers":3277,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"10bae415603ce27b91e022c77791fc4c4e8af016","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":32935745,"name":"che","full_name":"eclipse/che","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/che","description":"Eclipse Che: Next-generation Eclipse IDE.  Open source workspace server and cloud IDE.","fork":false,"url":"https://api.github.com/repos/eclipse/che","forks_url":"https://api.github.com/repos/eclipse/che/forks","keys_url":"https://api.github.com/repos/eclipse/che/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/che/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/che/teams","hooks_url":"https://api.github.com/repos/eclipse/che/hooks","issue_events_url":"https://api.github.com/repos/eclipse/che/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/che/events","assignees_url":"https://api.github.com/repos/eclipse/che/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/che/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/che/tags","blobs_url":"https://api.github.com/repos/eclipse/che/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/che/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/che/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/che/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/che/languages","stargazers_url":"https://api.github.com/repos/eclipse/che/stargazers","contributors_url":"https://api.github.com/repos/eclipse/che/contributors","subscribers_url":"https://api.github.com/repos/eclipse/che/subscribers","subscription_url":"https://api.github.com/repos/eclipse/che/subscription","commits_url":"https://api.github.com/repos/eclipse/che/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/che/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/che/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/che/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/che/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/che/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/che/merges","archive_url":"https://api.github.com/repos/eclipse/che/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/che/downloads","issues_url":"https://api.github.com/repos/eclipse/che/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/che/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/che/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/che/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/che/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/che/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/che/deployments","created_at":"2015-03-26T15:31:01Z","updated_at":"2016-10-28T19:37:27Z","pushed_at":"2016-10-31T09:35:16Z","git_url":"git://github.com/eclipse/che.git","ssh_url":"git@github.com:eclipse/che.git","clone_url":"https://github.com/eclipse/che.git","svn_url":"https://github.com/eclipse/che","homepage":"http://eclipse.org/che","size":54987,"stargazers_count":3277,"watchers_count":3277,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":539,"mirror_url":null,"open_issues_count":366,"forks":539,"open_issues":366,"watchers":3277,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/che/pulls/2865"},"html":{"href":"https://github.com/eclipse/che/pull/2865"},"issue":{"href":"https://api.github.com/repos/eclipse/che/issues/2865"},"comments":{"href":"https://api.github.com/repos/eclipse/che/issues/2865/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/che/pulls/2865/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/che/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/che/pulls/2865/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/che/statuses/d93ab8dc043491c495c30e8efb9ce539e015e239"}}}}
{"actor":{"display_login":"sleshchenko"}}