{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/che/pulls/comments/85088504","pull_request_review_id":5823319,"id":85088504,"diff_hunk":"@@ -887,47 +889,86 @@ Instance startMachine(LineConsumer machineLogger,\n                                                                   NotFoundException;\n     }\n \n-    private CheServiceImpl getServiceWithCorrectSource(CheServiceImpl service,\n-                                                       MachineSource machineSource)\n+    private CheServiceImpl normalizeServiceSource(CheServiceImpl service,\n+                                                  MachineSource machineSource)\n             throws ServerException {\n-        CheServiceImpl serviceWithCorrectSource = service;\n+        CheServiceImpl serviceWithNormalizedSource = service;\n         if (machineSource != null) {\n-            serviceWithCorrectSource = new CheServiceImpl(service);\n+            serviceWithNormalizedSource = new CheServiceImpl(service);\n             if (\"image\".equals(machineSource.getType())) {\n-                serviceWithCorrectSource.setBuild(null);\n-                serviceWithCorrectSource.setImage(machineSource.getLocation());\n+                serviceWithNormalizedSource.setBuild(null);\n+                serviceWithNormalizedSource.setImage(machineSource.getLocation());\n             } else {\n                 // dockerfile\n-                serviceWithCorrectSource.setImage(null);\n+                serviceWithNormalizedSource.setImage(null);\n                 if (machineSource.getContent() != null) {\n-                    serviceWithCorrectSource.setBuild(new CheServiceBuildContextImpl(null,\n-                                                                                     null,\n-                                                                                     machineSource.getContent(),\n-                                                                                     null));\n+                    serviceWithNormalizedSource.setBuild(new CheServiceBuildContextImpl(null,\n+                                                                                        null,\n+                                                                                        machineSource.getContent(),\n+                                                                                        null));\n                 } else {\n-                    serviceWithCorrectSource.setBuild(new CheServiceBuildContextImpl(machineSource.getLocation(),\n-                                                                                     null,\n-                                                                                     null,\n-                                                                                     null));\n+                    serviceWithNormalizedSource.setBuild(new CheServiceBuildContextImpl(machineSource.getLocation(),\n+                                                                                        null,\n+                                                                                        null,\n+                                                                                        null));\n                 }\n             }\n         }\n-        return serviceWithCorrectSource;\n+        return serviceWithNormalizedSource;\n     }\n \n-    private Machine getMachineWithCorrectSource(MachineImpl machine, MachineSource machineSource) {\n-        Machine machineWithCorrectSource = machine;\n+    private Machine getMachineWithNormalizedSource(MachineImpl machine, MachineSource machineSource) {\n+        Machine machineWithNormalizedSource = machine;\n         if (machineSource != null) {\n-            machineWithCorrectSource = MachineImpl.builder()\n-                                                  .fromMachine(machine)\n-                                                  .setConfig(MachineConfigImpl.builder()\n-                                                                              .fromConfig(machine.getConfig())\n-                                                                              .setSource(machineSource)\n-                                                                              .build())\n-                                                  .build();\n+            machineWithNormalizedSource = MachineImpl.builder()\n+                                                     .fromMachine(machine)\n+                                                     .setConfig(MachineConfigImpl.builder()\n+                                                                                 .fromConfig(machine.getConfig())\n+                                                                                 .setSource(machineSource)\n+                                                                                 .build())\n+                                                     .build();\n+\n+        }\n+        return machineWithNormalizedSource;\n+    }\n+\n+    /**\n+     * Replaces linked to this service's name with container name which represents the service in links section.\n+     * The problem is that a user writes names of other services in links section in compose file.\n+     * But actually links are constraints and they values should be names of containers (not services) to be linked.\n+     * <br/>\n+     * For example: serviceDB:serviceDbAlias -> container_1234:serviceDbAlias <br/>\n+     * If alias is omitted then service name will be used.\n+     *\n+     * @param serviceToStart\n+     *         service which is starting now\n+     * @param services\n+     *         all services in environment\n+     */\n+    @VisibleForTesting\n+    void replaceServiceToContainerNameInLinks(CheServiceImpl serviceToStart, Map<String, CheServiceImpl> services) {\n+        final List<String> containerLinks = serviceToStart.getLinks();\n+        for (int i = 0;  i < containerLinks.size(); i++) {\n+            String link = containerLinks.get(i);\n+            String serviceName;\n+            String serviceAlias;\n+            int colonIndex = link.indexOf(':');\n+            if (colonIndex != -1) {\n+                serviceName = link.substring(0, colonIndex);\n+                serviceAlias = link.substring(colonIndex + 1);\n+            } else {\n+                serviceName = link;\n+                serviceAlias = null;\n+            }\n \n+            CheServiceImpl serviceLinkedTo = services.get(serviceName);\n+            if (serviceLinkedTo != null) {\n+                String containerNameLinkedTo = serviceLinkedTo.getContainerName();\n+                containerLinks.set(i, (serviceAlias == null) ?","path":"wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/environment/server/CheEnvironmentEngine.java","position":194,"original_position":194,"commit_id":"709147ae0c8dab876e384e8176e859836ca5fea7","original_commit_id":"709147ae0c8dab876e384e8176e859836ca5fea7","user":{"login":"mmorhun","id":15607393,"avatar_url":"https://avatars.githubusercontent.com/u/15607393?v=3","gravatar_id":"","url":"https://api.github.com/users/mmorhun","html_url":"https://github.com/mmorhun","followers_url":"https://api.github.com/users/mmorhun/followers","following_url":"https://api.github.com/users/mmorhun/following{/other_user}","gists_url":"https://api.github.com/users/mmorhun/gists{/gist_id}","starred_url":"https://api.github.com/users/mmorhun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmorhun/subscriptions","organizations_url":"https://api.github.com/users/mmorhun/orgs","repos_url":"https://api.github.com/users/mmorhun/repos","events_url":"https://api.github.com/users/mmorhun/events{/privacy}","received_events_url":"https://api.github.com/users/mmorhun/received_events","type":"User","site_admin":false},"body":"But in case of no links we need additional logic which made code a bit complicated or return new empty list when it can be untouched, which is a bit weird to me.","created_at":"2016-10-26T10:01:20Z","updated_at":"2016-10-26T10:01:20Z","html_url":"https://github.com/eclipse/che/pull/2850#discussion_r85088504","pull_request_url":"https://api.github.com/repos/eclipse/che/pulls/2850","_links":{"self":{"href":"https://api.github.com/repos/eclipse/che/pulls/comments/85088504"},"html":{"href":"https://github.com/eclipse/che/pull/2850#discussion_r85088504"},"pull_request":{"href":"https://api.github.com/repos/eclipse/che/pulls/2850"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/che/pulls/2850","id":90234760,"html_url":"https://github.com/eclipse/che/pull/2850","diff_url":"https://github.com/eclipse/che/pull/2850.diff","patch_url":"https://github.com/eclipse/che/pull/2850.patch","issue_url":"https://api.github.com/repos/eclipse/che/issues/2850","number":2850,"state":"open","locked":false,"title":"Fix broken links section in docker-compose recipe","user":{"login":"mmorhun","id":15607393,"avatar_url":"https://avatars.githubusercontent.com/u/15607393?v=3","gravatar_id":"","url":"https://api.github.com/users/mmorhun","html_url":"https://github.com/mmorhun","followers_url":"https://api.github.com/users/mmorhun/followers","following_url":"https://api.github.com/users/mmorhun/following{/other_user}","gists_url":"https://api.github.com/users/mmorhun/gists{/gist_id}","starred_url":"https://api.github.com/users/mmorhun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmorhun/subscriptions","organizations_url":"https://api.github.com/users/mmorhun/orgs","repos_url":"https://api.github.com/users/mmorhun/repos","events_url":"https://api.github.com/users/mmorhun/events{/privacy}","received_events_url":"https://api.github.com/users/mmorhun/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\nFix broken links section in docker-compose recipe.\r\n\r\n### What issues does this PR fix or reference?\r\n#2687 \r\n\r\n### Previous behavior\r\nIf links section is present in recipe than workspace will fail to start.\r\n\r\n### New behavior\r\nLinks and aliases works now.\r\n","created_at":"2016-10-20T16:23:28Z","updated_at":"2016-10-26T10:01:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"476e070ba8345a571b2450aaa67f341d38baa7be","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/che/pulls/2850/commits","review_comments_url":"https://api.github.com/repos/eclipse/che/pulls/2850/comments","review_comment_url":"https://api.github.com/repos/eclipse/che/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/che/issues/2850/comments","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/709147ae0c8dab876e384e8176e859836ca5fea7","head":{"label":"eclipse:CHE-2687","ref":"CHE-2687","sha":"709147ae0c8dab876e384e8176e859836ca5fea7","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-26T07:07:16Z","pushed_at":"2016-10-26T09:54:12Z","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":54409,"stargazers_count":3272,"watchers_count":3272,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":538,"mirror_url":null,"open_issues_count":358,"forks":538,"open_issues":358,"watchers":3272,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"f2a0b3ef02e01b79922b449c940e8f58773deb8f","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-26T07:07:16Z","pushed_at":"2016-10-26T09:54:12Z","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":54409,"stargazers_count":3272,"watchers_count":3272,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":538,"mirror_url":null,"open_issues_count":358,"forks":538,"open_issues":358,"watchers":3272,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/che/pulls/2850"},"html":{"href":"https://github.com/eclipse/che/pull/2850"},"issue":{"href":"https://api.github.com/repos/eclipse/che/issues/2850"},"comments":{"href":"https://api.github.com/repos/eclipse/che/issues/2850/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/che/pulls/2850/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/che/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/che/pulls/2850/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/che/statuses/709147ae0c8dab876e384e8176e859836ca5fea7"}}}}
{"actor":{"display_login":"mmorhun"}}