{"action":"created","comment":{"url":"https://api.github.com/repos/codenvy/platform-api/pulls/comments/22791250","id":22791250,"diff_hunk":"@@ -350,6 +350,78 @@ public void removeFactory(@ApiParam(value = \"Factory ID\", required = true)\n         factoryStore.removeFactory(id);\n     }\n \n+\n+    /**\n+     * Updates factory with a new factory content\n+     *\n+     * @param id\n+     *         id of factory\n+     * @param newFactory\n+     *         the new data for the factory\n+     * @throws NotFoundException\n+     *         when factory with given id doesn't exist\n+     */\n+    @ApiOperation(value = \"Updates factory information by its ID\",\n+            notes = \"Updates factory based on the Factory ID which is passed in a path parameter\")\n+    @ApiResponses(value = {\n+            @ApiResponse(code = 200, message = \"OK\"),\n+            @ApiResponse(code = 403, message = \"User not authorized to call this operation\"),\n+            @ApiResponse(code = 404, message = \"Factory not found\"),\n+            @ApiResponse(code = 500, message = \"Internal Server Error\")})\n+    @POST\n+    @Path(\"/{id}\")\n+    @RolesAllowed(\"user\")\n+    @Consumes({MediaType.APPLICATION_JSON})\n+    @Produces({MediaType.APPLICATION_JSON})\n+    public Factory updateFactory(@ApiParam(value = \"Factory ID\", required = true)\n+                                 @PathParam(\"id\") String id,\n+                                 Factory newFactory) throws ForbiddenException, NotFoundException, ApiException {\n+\n+        // Check we've a user\n+        final User user = EnvironmentContext.getCurrent().getUser();\n+        if (user == null) {\n+            // well this shouldn't happen if only user is authorized to call the method\n+            throw new ForbiddenException(\"No authenticated user\");\n+        }\n+\n+        // Do we have a factory for this id ?\n+        Factory existingFactory = factoryStore.getFactory(id);\n+        if (existingFactory == null) {\n+            throw new NotFoundException(\"Factory with id \" + id + \" does not exist.\");\n+        }\n+\n+        // Gets the User id\n+        String userId = user.getId();\n+\n+        // Validate the factory against the current user\n+        factoryEditValidator.validate(existingFactory, userId);\n+\n+        // Check author is set and copy created date from old factory\n+        Author newAuthor = newFactory.getCreator();\n+        if (newAuthor == null) {\n+            newAuthor = DtoFactory.getInstance().createDto(Author.class);\n+            newFactory.setCreator(newAuthor);\n+        }\n+        if (newAuthor.getUserId() == null) {\n+            newAuthor.setUserId(user.getId());\n+        }\n+        newFactory.getCreator().withCreated(existingFactory.getCreator().getCreated());\n+        newFactory.setId(existingFactory.getId());\n+\n+        // validate the new content\n+        createValidator.validateOnCreate(newFactory);\n+        try {\n+            newFactory.setLinks(linksHelper.createLinks(newFactory, factoryStore.getFactoryImages(id, null), uriInfo));\n+        } catch (UnsupportedEncodingException e) {\n+            throw new ConflictException(e.getLocalizedMessage());\n+        }\n+        // access granted, user can update the factory\n+        factoryStore.updateFactory(id, newFactory);\n+\n+        return newFactory;","path":"codenvy-api-factory/src/main/java/com/codenvy/api/factory/FactoryService.java","position":72,"original_position":72,"commit_id":"05385f71e817885fa4a67fa3c3e61eaca3f3de3c","original_commit_id":"05385f71e817885fa4a67fa3c3e61eaca3f3de3c","user":{"login":"garagatyi","id":1851863,"avatar_url":"https://avatars.githubusercontent.com/u/1851863?v=3","gravatar_id":"","url":"https://api.github.com/users/garagatyi","html_url":"https://github.com/garagatyi","followers_url":"https://api.github.com/users/garagatyi/followers","following_url":"https://api.github.com/users/garagatyi/following{/other_user}","gists_url":"https://api.github.com/users/garagatyi/gists{/gist_id}","starred_url":"https://api.github.com/users/garagatyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garagatyi/subscriptions","organizations_url":"https://api.github.com/users/garagatyi/orgs","repos_url":"https://api.github.com/users/garagatyi/repos","events_url":"https://api.github.com/users/garagatyi/events{/privacy}","received_events_url":"https://api.github.com/users/garagatyi/received_events","type":"User","site_admin":false},"body":"Insert links here instead","created_at":"2015-01-12T14:07:40Z","updated_at":"2015-01-12T14:07:40Z","html_url":"https://github.com/codenvy/platform-api/pull/124#discussion_r22791250","pull_request_url":"https://api.github.com/repos/codenvy/platform-api/pulls/124","_links":{"self":{"href":"https://api.github.com/repos/codenvy/platform-api/pulls/comments/22791250"},"html":{"href":"https://github.com/codenvy/platform-api/pull/124#discussion_r22791250"},"pull_request":{"href":"https://api.github.com/repos/codenvy/platform-api/pulls/124"}}},"pull_request":{"url":"https://api.github.com/repos/codenvy/platform-api/pulls/124","id":27195395,"html_url":"https://github.com/codenvy/platform-api/pull/124","diff_url":"https://github.com/codenvy/platform-api/pull/124.diff","patch_url":"https://github.com/codenvy/platform-api/pull/124.patch","issue_url":"https://api.github.com/repos/codenvy/platform-api/issues/124","number":124,"state":"open","locked":false,"title":"IDEX-1881 Allow to update a factory","user":{"login":"benoitf","id":436777,"avatar_url":"https://avatars.githubusercontent.com/u/436777?v=3","gravatar_id":"","url":"https://api.github.com/users/benoitf","html_url":"https://github.com/benoitf","followers_url":"https://api.github.com/users/benoitf/followers","following_url":"https://api.github.com/users/benoitf/following{/other_user}","gists_url":"https://api.github.com/users/benoitf/gists{/gist_id}","starred_url":"https://api.github.com/users/benoitf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benoitf/subscriptions","organizations_url":"https://api.github.com/users/benoitf/orgs","repos_url":"https://api.github.com/users/benoitf/repos","events_url":"https://api.github.com/users/benoitf/events{/privacy}","received_events_url":"https://api.github.com/users/benoitf/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-12T13:58:49Z","updated_at":"2015-01-12T14:07:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d8cb5faed2054c8b4f94254a3b9147f421520f3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codenvy/platform-api/pulls/124/commits","review_comments_url":"https://api.github.com/repos/codenvy/platform-api/pulls/124/comments","review_comment_url":"https://api.github.com/repos/codenvy/platform-api/pulls/comments/{number}","comments_url":"https://api.github.com/repos/codenvy/platform-api/issues/124/comments","statuses_url":"https://api.github.com/repos/codenvy/platform-api/statuses/05385f71e817885fa4a67fa3c3e61eaca3f3de3c","head":{"label":"codenvy:IDEX-1881","ref":"IDEX-1881","sha":"05385f71e817885fa4a67fa3c3e61eaca3f3de3c","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":12398755,"name":"platform-api","full_name":"codenvy/platform-api","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/platform-api","description":"Codenvy API","fork":false,"url":"https://api.github.com/repos/codenvy/platform-api","forks_url":"https://api.github.com/repos/codenvy/platform-api/forks","keys_url":"https://api.github.com/repos/codenvy/platform-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/platform-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/platform-api/teams","hooks_url":"https://api.github.com/repos/codenvy/platform-api/hooks","issue_events_url":"https://api.github.com/repos/codenvy/platform-api/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/platform-api/events","assignees_url":"https://api.github.com/repos/codenvy/platform-api/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/platform-api/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/platform-api/tags","blobs_url":"https://api.github.com/repos/codenvy/platform-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/platform-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/platform-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/platform-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/platform-api/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/platform-api/languages","stargazers_url":"https://api.github.com/repos/codenvy/platform-api/stargazers","contributors_url":"https://api.github.com/repos/codenvy/platform-api/contributors","subscribers_url":"https://api.github.com/repos/codenvy/platform-api/subscribers","subscription_url":"https://api.github.com/repos/codenvy/platform-api/subscription","commits_url":"https://api.github.com/repos/codenvy/platform-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/platform-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/platform-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/platform-api/issues/comments/{number}","contents_url":"https://api.github.com/repos/codenvy/platform-api/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/platform-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/platform-api/merges","archive_url":"https://api.github.com/repos/codenvy/platform-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/platform-api/downloads","issues_url":"https://api.github.com/repos/codenvy/platform-api/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/platform-api/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/platform-api/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/platform-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/platform-api/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/platform-api/releases{/id}","created_at":"2013-08-27T06:27:49Z","updated_at":"2015-01-09T17:24:47Z","pushed_at":"2015-01-12T13:58:41Z","git_url":"git://github.com/codenvy/platform-api.git","ssh_url":"git@github.com:codenvy/platform-api.git","clone_url":"https://github.com/codenvy/platform-api.git","svn_url":"https://github.com/codenvy/platform-api","homepage":null,"size":14606,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"codenvy:master","ref":"master","sha":"0340d3a405b4c14e9e0f65ae496b2fc5dce64bf1","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":12398755,"name":"platform-api","full_name":"codenvy/platform-api","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/platform-api","description":"Codenvy API","fork":false,"url":"https://api.github.com/repos/codenvy/platform-api","forks_url":"https://api.github.com/repos/codenvy/platform-api/forks","keys_url":"https://api.github.com/repos/codenvy/platform-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/platform-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/platform-api/teams","hooks_url":"https://api.github.com/repos/codenvy/platform-api/hooks","issue_events_url":"https://api.github.com/repos/codenvy/platform-api/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/platform-api/events","assignees_url":"https://api.github.com/repos/codenvy/platform-api/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/platform-api/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/platform-api/tags","blobs_url":"https://api.github.com/repos/codenvy/platform-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/platform-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/platform-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/platform-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/platform-api/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/platform-api/languages","stargazers_url":"https://api.github.com/repos/codenvy/platform-api/stargazers","contributors_url":"https://api.github.com/repos/codenvy/platform-api/contributors","subscribers_url":"https://api.github.com/repos/codenvy/platform-api/subscribers","subscription_url":"https://api.github.com/repos/codenvy/platform-api/subscription","commits_url":"https://api.github.com/repos/codenvy/platform-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/platform-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/platform-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/platform-api/issues/comments/{number}","contents_url":"https://api.github.com/repos/codenvy/platform-api/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/platform-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/platform-api/merges","archive_url":"https://api.github.com/repos/codenvy/platform-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/platform-api/downloads","issues_url":"https://api.github.com/repos/codenvy/platform-api/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/platform-api/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/platform-api/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/platform-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/platform-api/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/platform-api/releases{/id}","created_at":"2013-08-27T06:27:49Z","updated_at":"2015-01-09T17:24:47Z","pushed_at":"2015-01-12T13:58:41Z","git_url":"git://github.com/codenvy/platform-api.git","ssh_url":"git@github.com:codenvy/platform-api.git","clone_url":"https://github.com/codenvy/platform-api.git","svn_url":"https://github.com/codenvy/platform-api","homepage":null,"size":14606,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codenvy/platform-api/pulls/124"},"html":{"href":"https://github.com/codenvy/platform-api/pull/124"},"issue":{"href":"https://api.github.com/repos/codenvy/platform-api/issues/124"},"comments":{"href":"https://api.github.com/repos/codenvy/platform-api/issues/124/comments"},"review_comments":{"href":"https://api.github.com/repos/codenvy/platform-api/pulls/124/comments"},"review_comment":{"href":"https://api.github.com/repos/codenvy/platform-api/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/codenvy/platform-api/pulls/124/commits"},"statuses":{"href":"https://api.github.com/repos/codenvy/platform-api/statuses/05385f71e817885fa4a67fa3c3e61eaca3f3de3c"}}}}