GitHub PullRequestReviewCommentEvent at 2014-11-24 20:36:08
Repository: coopr
Actor: jwang47
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/caskdata/coopr/pulls/comments/20819987","id":20819987,"diff_hunk":"@@ -229,6 +236,91 @@ public void getProviderTypeResource(HttpRequest request, HttpResponder responder\n     sendResourceInChunks(responder, account, resourceTypeObj, name, version);\n   }\n \n+  /**\n+   * Writes a {@link co.cask.coopr.spec.plugin.ProviderType}. User must be admin or a 403 is returned.\n+   * If the name in the path does not match the name in the put body, a 400 is returned.\n+   *\n+   * @param request Request to write provider type.\n+   * @param responder Responder to send response.\n+   * @param providertypeId Id of the provider type to write.\n+   */\n+  @PUT\n+  @Path(\"/plugins/providertypes/{providertype-id}\")\n+  public void putProviderType(HttpRequest request, HttpResponder responder,\n+                              @PathParam(\"providertype-id\") String providertypeId) {\n+    ProviderType providerType = getEntityFromRequest(request, responder, ProviderType.class);\n+    if (providerType == null) {\n+      // getEntityFromRequest writes to the responder if there was an issue.\n+      return;\n+    } else if (!providerType.getName().equals(providertypeId)) {\n+      responder.sendError(HttpResponseStatus.BAD_REQUEST, \"mismatch between provider type name and name in path.\");\n+      return;\n+    }\n+\n+    try {\n+      entityStoreService.getView(Account.SUPERADMIN).writeProviderType(providerType);\n+      responder.sendStatus(HttpResponseStatus.OK);\n+    } catch (IOException e) {\n+      responder.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR,\n+                          \"Exception writing provider type \" + providertypeId);\n+    } catch (IllegalAccessException e) {\n+      responder.sendError(HttpResponseStatus.FORBIDDEN, \"user unauthorized to write provider type.\");\n+    }\n+  }\n+\n+  /**\n+   * Writes a {@link co.cask.coopr.spec.plugin.AutomatorType}. User must be admin or a 403 is returned.\n+   * If the name in the path does not match the name in the put body, a 400 is returned.\n+   *\n+   * @param request Request to write provider type.\n+   * @param responder Responder to send response.\n+   * @param automatortypeId Id of the provider type to write.\n+   */\n+  @PUT\n+  @Path(\"/plugins/automatortypes/{automatortype-id}\")\n+  public void putAutomatorType(HttpRequest request, HttpResponder responder,\n+                               @PathParam(\"automatortype-id\") String automatortypeId) {\n+    AutomatorType automatorType = getEntityFromRequest(request, responder, AutomatorType.class);\n+    if (automatorType == null) {\n+      // getEntityFromRequest writes to the responder if there was an issue.\n+      return;\n+    } else if (!automatorType.getName().equals(automatortypeId)) {\n+      responder.sendError(HttpResponseStatus.BAD_REQUEST, \"mismatch between automator type name and name in path.\");\n+      return;\n+    }\n+\n+    try {\n+      entityStoreService.getView(Account.SUPERADMIN).writeAutomatorType(automatorType);\n+      responder.sendStatus(HttpResponseStatus.OK);\n+    } catch (IOException e) {\n+      responder.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR,\n+                          \"Exception writing automator type \" + automatortypeId);\n+    } catch (IllegalAccessException e) {\n+      responder.sendError(HttpResponseStatus.FORBIDDEN, \"user unauthorized to write automator type.\");\n+    }\n+  }\n+\n+  private <T> T getEntityFromRequest(HttpRequest request, HttpResponder responder, Type tClass) {\n+    T result = null;\n+    try {\n+      Reader reader = new InputStreamReader(new ChannelBufferInputStream(request.getContent()), Charsets.UTF_8);\n+      try {\n+        result = gson.fromJson(reader, tClass);\n+      } finally {\n+        try {\n+          reader.close();\n+        } catch (IOException e) {\n+          LOG.warn(\"Exception while closing request reader\", e);\n+        }\n+      }\n+    } catch (IllegalArgumentException e) {\n+      responder.sendError(HttpResponseStatus.BAD_REQUEST, \"invalid input: \" + e.getMessage());\n+    } catch (Exception e) {\n+      responder.sendError(HttpResponseStatus.BAD_REQUEST, \"invalid input\");\n+    }\n+    return result;\n+  }","path":"coopr-server/src/main/java/co/cask/coopr/http/handler/ProvisionerHandler.java","position":125,"original_position":125,"commit_id":"f2a88c9d0135f724f809406113b3ae681970fd7e","original_commit_id":"f2a88c9d0135f724f809406113b3ae681970fd7e","user":{"login":"jwang47","id":1084704,"avatar_url":"https://avatars.githubusercontent.com/u/1084704?v=3","gravatar_id":"","url":"https://api.github.com/users/jwang47","html_url":"https://github.com/jwang47","followers_url":"https://api.github.com/users/jwang47/followers","following_url":"https://api.github.com/users/jwang47/following{/other_user}","gists_url":"https://api.github.com/users/jwang47/gists{/gist_id}","starred_url":"https://api.github.com/users/jwang47/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwang47/subscriptions","organizations_url":"https://api.github.com/users/jwang47/orgs","repos_url":"https://api.github.com/users/jwang47/repos","events_url":"https://api.github.com/users/jwang47/events{/privacy}","received_events_url":"https://api.github.com/users/jwang47/received_events","type":"User","site_admin":false},"body":"Isn't this external now, so we'll need user check?","created_at":"2014-11-24T20:36:08Z","updated_at":"2014-11-24T20:36:08Z","html_url":"https://github.com/caskdata/coopr/pull/787#discussion_r20819987","pull_request_url":"https://api.github.com/repos/caskdata/coopr/pulls/787","_links":{"self":{"href":"https://api.github.com/repos/caskdata/coopr/pulls/comments/20819987"},"html":{"href":"https://github.com/caskdata/coopr/pull/787#discussion_r20819987"},"pull_request":{"href":"https://api.github.com/repos/caskdata/coopr/pulls/787"}}},"pull_request":{"url":"https://api.github.com/repos/caskdata/coopr/pulls/787","id":24854067,"html_url":"https://github.com/caskdata/coopr/pull/787","diff_url":"https://github.com/caskdata/coopr/pull/787.diff","patch_url":"https://github.com/caskdata/coopr/pull/787.patch","issue_url":"https://api.github.com/repos/caskdata/coopr/issues/787","number":787,"state":"open","locked":false,"title":"Coopr 567: Split server APIs to separate ports.","user":{"login":"ytalashkocv","id":8393633,"avatar_url":"https://avatars.githubusercontent.com/u/8393633?v=3","gravatar_id":"","url":"https://api.github.com/users/ytalashkocv","html_url":"https://github.com/ytalashkocv","followers_url":"https://api.github.com/users/ytalashkocv/followers","following_url":"https://api.github.com/users/ytalashkocv/following{/other_user}","gists_url":"https://api.github.com/users/ytalashkocv/gists{/gist_id}","starred_url":"https://api.github.com/users/ytalashkocv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ytalashkocv/subscriptions","organizations_url":"https://api.github.com/users/ytalashkocv/orgs","repos_url":"https://api.github.com/users/ytalashkocv/repos","events_url":"https://api.github.com/users/ytalashkocv/events{/privacy}","received_events_url":"https://api.github.com/users/ytalashkocv/received_events","type":"User","site_admin":false},"body":"I have removed ProvisionerHandler from External API and add this handler to Internal API. Also added \r\n\"PUT /v2/plugins/providertypes/{providertype-id}\"\r\n\"PUT /v2/plugins/automatortypes/{automatortype-id}\"\r\nrequests to ProvisionerHandler and removed this requests from SuperadminHandler. For now Internal API handles TaskHandler and ProvisionerHandler. I have done some basic tests with coopr standalone - real cluster provisioning via UI.","created_at":"2014-11-21T17:12:21Z","updated_at":"2014-11-24T20:36:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7560b3bc3e5ce497b9fe4e6f3aa58f116847a84","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/caskdata/coopr/pulls/787/commits","review_comments_url":"https://api.github.com/repos/caskdata/coopr/pulls/787/comments","review_comment_url":"https://api.github.com/repos/caskdata/coopr/pulls/comments/{number}","comments_url":"https://api.github.com/repos/caskdata/coopr/issues/787/comments","statuses_url":"https://api.github.com/repos/caskdata/coopr/statuses/f2a88c9d0135f724f809406113b3ae681970fd7e","head":{"label":"cybervisiontech:coopr_567","ref":"coopr_567","sha":"f2a88c9d0135f724f809406113b3ae681970fd7e","user":{"login":"cybervisiontech","id":8482357,"avatar_url":"https://avatars.githubusercontent.com/u/8482357?v=3","gravatar_id":"","url":"https://api.github.com/users/cybervisiontech","html_url":"https://github.com/cybervisiontech","followers_url":"https://api.github.com/users/cybervisiontech/followers","following_url":"https://api.github.com/users/cybervisiontech/following{/other_user}","gists_url":"https://api.github.com/users/cybervisiontech/gists{/gist_id}","starred_url":"https://api.github.com/users/cybervisiontech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cybervisiontech/subscriptions","organizations_url":"https://api.github.com/users/cybervisiontech/orgs","repos_url":"https://api.github.com/users/cybervisiontech/repos","events_url":"https://api.github.com/users/cybervisiontech/events{/privacy}","received_events_url":"https://api.github.com/users/cybervisiontech/received_events","type":"Organization","site_admin":false},"repo":{"id":24725151,"name":"coopr","full_name":"cybervisiontech/coopr","owner":{"login":"cybervisiontech","id":8482357,"avatar_url":"https://avatars.githubusercontent.com/u/8482357?v=3","gravatar_id":"","url":"https://api.github.com/users/cybervisiontech","html_url":"https://github.com/cybervisiontech","followers_url":"https://api.github.com/users/cybervisiontech/followers","following_url":"https://api.github.com/users/cybervisiontech/following{/other_user}","gists_url":"https://api.github.com/users/cybervisiontech/gists{/gist_id}","starred_url":"https://api.github.com/users/cybervisiontech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cybervisiontech/subscriptions","organizations_url":"https://api.github.com/users/cybervisiontech/orgs","repos_url":"https://api.github.com/users/cybervisiontech/repos","events_url":"https://api.github.com/users/cybervisiontech/events{/privacy}","received_events_url":"https://api.github.com/users/cybervisiontech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cybervisiontech/coopr","description":"A template-based cluster provisioning system.","fork":true,"url":"https://api.github.com/repos/cybervisiontech/coopr","forks_url":"https://api.github.com/repos/cybervisiontech/coopr/forks","keys_url":"https://api.github.com/repos/cybervisiontech/coopr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cybervisiontech/coopr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cybervisiontech/coopr/teams","hooks_url":"https://api.github.com/repos/cybervisiontech/coopr/hooks","issue_events_url":"https://api.github.com/repos/cybervisiontech/coopr/issues/events{/number}","events_url":"https://api.github.com/repos/cybervisiontech/coopr/events","assignees_url":"https://api.github.com/repos/cybervisiontech/coopr/assignees{/user}","branches_url":"https://api.github.com/repos/cybervisiontech/coopr/branches{/branch}","tags_url":"https://api.github.com/repos/cybervisiontech/coopr/tags","blobs_url":"https://api.github.com/repos/cybervisiontech/coopr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cybervisiontech/coopr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cybervisiontech/coopr/git/refs{/sha}","trees_url":"https://api.github.com/repos/cybervisiontech/coopr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cybervisiontech/coopr/statuses/{sha}","languages_url":"https://api.github.com/repos/cybervisiontech/coopr/languages","stargazers_url":"https://api.github.com/repos/cybervisiontech/coopr/stargazers","contributors_url":"https://api.github.com/repos/cybervisiontech/coopr/contributors","subscribers_url":"https://api.github.com/repos/cybervisiontech/coopr/subscribers","subscription_url":"https://api.github.com/repos/cybervisiontech/coopr/subscription","commits_url":"https://api.github.com/repos/cybervisiontech/coopr/commits{/sha}","git_commits_url":"https://api.github.com/repos/cybervisiontech/coopr/git/commits{/sha}","comments_url":"https://api.github.com/repos/cybervisiontech/coopr/comments{/number}","issue_comment_url":"https://api.github.com/repos/cybervisiontech/coopr/issues/comments/{number}","contents_url":"https://api.github.com/repos/cybervisiontech/coopr/contents/{+path}","compare_url":"https://api.github.com/repos/cybervisiontech/coopr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cybervisiontech/coopr/merges","archive_url":"https://api.github.com/repos/cybervisiontech/coopr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cybervisiontech/coopr/downloads","issues_url":"https://api.github.com/repos/cybervisiontech/coopr/issues{/number}","pulls_url":"https://api.github.com/repos/cybervisiontech/coopr/pulls{/number}","milestones_url":"https://api.github.com/repos/cybervisiontech/coopr/milestones{/number}","notifications_url":"https://api.github.com/repos/cybervisiontech/coopr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cybervisiontech/coopr/labels{/name}","releases_url":"https://api.github.com/repos/cybervisiontech/coopr/releases{/id}","created_at":"2014-10-02T15:41:26Z","updated_at":"2014-10-07T14:23:05Z","pushed_at":"2014-11-24T15:10:24Z","git_url":"git://github.com/cybervisiontech/coopr.git","ssh_url":"git@github.com:cybervisiontech/coopr.git","clone_url":"https://github.com/cybervisiontech/coopr.git","svn_url":"https://github.com/cybervisiontech/coopr","homepage":"","size":129635,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"caskdata:develop","ref":"develop","sha":"ee42aa2aee9b0eb5ca0f7b9142dc84791ffb6f5a","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":17919097,"name":"coopr","full_name":"caskdata/coopr","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/coopr","description":"A template-based cluster provisioning system.","fork":false,"url":"https://api.github.com/repos/caskdata/coopr","forks_url":"https://api.github.com/repos/caskdata/coopr/forks","keys_url":"https://api.github.com/repos/caskdata/coopr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/coopr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/coopr/teams","hooks_url":"https://api.github.com/repos/caskdata/coopr/hooks","issue_events_url":"https://api.github.com/repos/caskdata/coopr/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/coopr/events","assignees_url":"https://api.github.com/repos/caskdata/coopr/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/coopr/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/coopr/tags","blobs_url":"https://api.github.com/repos/caskdata/coopr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/coopr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/coopr/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/coopr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/coopr/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/coopr/languages","stargazers_url":"https://api.github.com/repos/caskdata/coopr/stargazers","contributors_url":"https://api.github.com/repos/caskdata/coopr/contributors","subscribers_url":"https://api.github.com/repos/caskdata/coopr/subscribers","subscription_url":"https://api.github.com/repos/caskdata/coopr/subscription","commits_url":"https://api.github.com/repos/caskdata/coopr/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/coopr/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/coopr/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/coopr/issues/comments/{number}","contents_url":"https://api.github.com/repos/caskdata/coopr/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/coopr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/coopr/merges","archive_url":"https://api.github.com/repos/caskdata/coopr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/coopr/downloads","issues_url":"https://api.github.com/repos/caskdata/coopr/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/coopr/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/coopr/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/coopr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/coopr/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/coopr/releases{/id}","created_at":"2014-03-19T20:25:45Z","updated_at":"2014-11-24T19:25:41Z","pushed_at":"2014-11-24T19:25:40Z","git_url":"git://github.com/caskdata/coopr.git","ssh_url":"git@github.com:caskdata/coopr.git","clone_url":"https://github.com/caskdata/coopr.git","svn_url":"https://github.com/caskdata/coopr","homepage":"http://coopr.io","size":168087,"stargazers_count":48,"watchers_count":48,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":96,"forks":8,"open_issues":96,"watchers":48,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/caskdata/coopr/pulls/787"},"html":{"href":"https://github.com/caskdata/coopr/pull/787"},"issue":{"href":"https://api.github.com/repos/caskdata/coopr/issues/787"},"comments":{"href":"https://api.github.com/repos/caskdata/coopr/issues/787/comments"},"review_comments":{"href":"https://api.github.com/repos/caskdata/coopr/pulls/787/comments"},"review_comment":{"href":"https://api.github.com/repos/caskdata/coopr/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/caskdata/coopr/pulls/787/commits"},"statuses":{"href":"https://api.github.com/repos/caskdata/coopr/statuses/f2a88c9d0135f724f809406113b3ae681970fd7e"}}}}