{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/comments/26956785","id":26956785,"diff_hunk":"@@ -0,0 +1,91 @@\n+package com.wikia.communitydata.resources;\n+\n+import static net.logstash.logback.marker.Markers.appendEntries;\n+\n+import com.wikia.communitydata.core.CommunityData;\n+import com.wikia.communitydata.core.CommunityDataProvider;\n+import com.wikia.communitydata.exception.ErrorResponse;\n+\n+import com.codahale.metrics.annotation.Timed;\n+import com.google.common.collect.ImmutableMap;\n+import com.google.inject.Inject;\n+import com.wordnik.swagger.annotations.Api;\n+import com.wordnik.swagger.annotations.ApiOperation;\n+import com.wordnik.swagger.annotations.ApiResponse;\n+import com.wordnik.swagger.annotations.ApiResponses;\n+import io.dropwizard.jersey.caching.CacheControl;\n+import org.jooq.DSLContext;\n+import org.slf4j.LoggerFactory;\n+\n+import java.util.concurrent.TimeUnit;\n+\n+import javax.ws.rs.GET;\n+import javax.ws.rs.NotFoundException;\n+import javax.ws.rs.Path;\n+import javax.ws.rs.PathParam;\n+import javax.ws.rs.Produces;\n+import javax.ws.rs.WebApplicationException;\n+import javax.ws.rs.core.Context;\n+import javax.ws.rs.core.MediaType;\n+import javax.ws.rs.core.Response;\n+\n+@Path(\"/{domain}\")\n+@Api(\"/CommunityData\")\n+@Produces(MediaType.APPLICATION_JSON)\n+public class CommunityDataResource {\n+  private CommunityDataProvider provider;\n+\n+  @Inject\n+  public CommunityDataResource(CommunityDataProvider provider) {\n+    this.provider = provider;\n+  }\n+\n+  @GET\n+  @Produces(MediaType.APPLICATION_JSON)\n+  @ApiOperation(\n+      value=\"get information about a community\",\n+      notes=\"get information about a community\",\n+      produces=MediaType.APPLICATION_JSON\n+  )\n+  @ApiResponses(value={\n+      @ApiResponse(code=200, response=CommunityData.class, message=\"community data\"),\n+      @ApiResponse(code=404, response=ErrorResponse.class, message=\"community does not exist\"),\n+      @ApiResponse(code=500, response=ErrorResponse.class, message=\"error while fetching data\")\n+  })\n+  @Timed\n+  @CacheControl(maxAge = 24, maxAgeUnit = TimeUnit.HOURS)\n+  public CommunityData getData(@PathParam(\"domain\") String domain, @Context DSLContext db) {\n+    CommunityData data;\n+\n+    try {\n+      data = provider.getCommunityData(db, domain);\n+    } catch (Exception e) {\n+      LoggerFactory.getLogger(this.getClass()).error(\n+          appendEntries(\n+              new ImmutableMap.Builder<String, String>()\n+                  .put(\"domain\", domain)\n+                  .build()\n+          ),\n+          \"error fetching community data\",\n+          e\n+      );\n+      Response response = Response\n+          .status(Response.Status.INTERNAL_SERVER_ERROR)\n+          .entity(new ErrorResponse(String.format(\"error fetching data for %s\", domain),\n+                                    Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()))\n+          .build();\n+      throw new WebApplicationException(response);\n+    }","path":"service/community-data/src/main/java/com/wikia/communitydata/resources/CommunityDataResource.java","position":78,"original_position":78,"commit_id":"9e13eced4b3c75b0f7826097b7fd401b0cd49d96","original_commit_id":"9e13eced4b3c75b0f7826097b7fd401b0cd49d96","user":{"login":"drsnyder","id":21621,"avatar_url":"https://avatars.githubusercontent.com/u/21621?v=3","gravatar_id":"","url":"https://api.github.com/users/drsnyder","html_url":"https://github.com/drsnyder","followers_url":"https://api.github.com/users/drsnyder/followers","following_url":"https://api.github.com/users/drsnyder/following{/other_user}","gists_url":"https://api.github.com/users/drsnyder/gists{/gist_id}","starred_url":"https://api.github.com/users/drsnyder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drsnyder/subscriptions","organizations_url":"https://api.github.com/users/drsnyder/orgs","repos_url":"https://api.github.com/users/drsnyder/repos","events_url":"https://api.github.com/users/drsnyder/events{/privacy}","received_events_url":"https://api.github.com/users/drsnyder/received_events","type":"User","site_admin":false},"body":"I think it would be nice to move the exception handling logic elsewhere so it doesn't clutter the controller. There is a mechanism in [jersey for doing this](https://jersey.java.net/documentation/latest/representations.html#d0e6559).","created_at":"2015-03-23T17:09:26Z","updated_at":"2015-03-23T17:09:26Z","html_url":"https://github.com/Wikia/pandora/pull/100#discussion_r26956785","pull_request_url":"https://api.github.com/repos/Wikia/pandora/pulls/100","_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments/26956785"},"html":{"href":"https://github.com/Wikia/pandora/pull/100#discussion_r26956785"},"pull_request":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/100"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/100","id":31566722,"html_url":"https://github.com/Wikia/pandora/pull/100","diff_url":"https://github.com/Wikia/pandora/pull/100.diff","patch_url":"https://github.com/Wikia/pandora/pull/100.patch","issue_url":"https://api.github.com/repos/Wikia/pandora/issues/100","number":100,"state":"closed","locked":false,"title":"Community Data Service","user":{"login":"nmonterroso","id":325800,"avatar_url":"https://avatars.githubusercontent.com/u/325800?v=3","gravatar_id":"","url":"https://api.github.com/users/nmonterroso","html_url":"https://github.com/nmonterroso","followers_url":"https://api.github.com/users/nmonterroso/followers","following_url":"https://api.github.com/users/nmonterroso/following{/other_user}","gists_url":"https://api.github.com/users/nmonterroso/gists{/gist_id}","starred_url":"https://api.github.com/users/nmonterroso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmonterroso/subscriptions","organizations_url":"https://api.github.com/users/nmonterroso/orgs","repos_url":"https://api.github.com/users/nmonterroso/repos","events_url":"https://api.github.com/users/nmonterroso/events{/privacy}","received_events_url":"https://api.github.com/users/nmonterroso/received_events","type":"User","site_admin":false},"body":"@drsnyder @sqreek @pchojnacki \r\nhttps://wikia-inc.atlassian.net/browse/SERVICES-139\r\n\r\nProvides a service to get data about a community. Only resource is `/{domain}` ex: `/leagueoflegends.wikia.com`. Spoke with @kenkouot and this is their preferred method for fetching information for a specific wikia. Also piggybacking in some changes that were required to make this work:\r\n\r\n* [jooq](jooq.org) code generation task\r\n* udpating to latest swagger-codegen version which allows accessing the Nirvana API asynchronously, though this didn't actually end up being used","created_at":"2015-03-19T21:12:18Z","updated_at":"2015-03-23T17:09:26Z","closed_at":"2015-03-20T18:45:26Z","merged_at":"2015-03-20T18:45:26Z","merge_commit_sha":"c3a3857c637a8a547966022f7b120cfba166b6d0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/pandora/pulls/100/commits","review_comments_url":"https://api.github.com/repos/Wikia/pandora/pulls/100/comments","review_comment_url":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/pandora/issues/100/comments","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/9e13eced4b3c75b0f7826097b7fd401b0cd49d96","head":{"label":"Wikia:SERVICES-139","ref":"SERVICES-139","sha":"9e13eced4b3c75b0f7826097b7fd401b0cd49d96","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":26663749,"name":"pandora","full_name":"Wikia/pandora","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/pandora","description":"API Service","fork":false,"url":"https://api.github.com/repos/Wikia/pandora","forks_url":"https://api.github.com/repos/Wikia/pandora/forks","keys_url":"https://api.github.com/repos/Wikia/pandora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/pandora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/pandora/teams","hooks_url":"https://api.github.com/repos/Wikia/pandora/hooks","issue_events_url":"https://api.github.com/repos/Wikia/pandora/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/pandora/events","assignees_url":"https://api.github.com/repos/Wikia/pandora/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/pandora/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/pandora/tags","blobs_url":"https://api.github.com/repos/Wikia/pandora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/pandora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/pandora/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/pandora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/pandora/languages","stargazers_url":"https://api.github.com/repos/Wikia/pandora/stargazers","contributors_url":"https://api.github.com/repos/Wikia/pandora/contributors","subscribers_url":"https://api.github.com/repos/Wikia/pandora/subscribers","subscription_url":"https://api.github.com/repos/Wikia/pandora/subscription","commits_url":"https://api.github.com/repos/Wikia/pandora/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/pandora/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/pandora/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/pandora/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/pandora/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/pandora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/pandora/merges","archive_url":"https://api.github.com/repos/Wikia/pandora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/pandora/downloads","issues_url":"https://api.github.com/repos/Wikia/pandora/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/pandora/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/pandora/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/pandora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/pandora/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/pandora/releases{/id}","created_at":"2014-11-15T00:29:06Z","updated_at":"2015-03-23T15:37:34Z","pushed_at":"2015-03-23T16:50:15Z","git_url":"git://github.com/Wikia/pandora.git","ssh_url":"git@github.com:Wikia/pandora.git","clone_url":"https://github.com/Wikia/pandora.git","svn_url":"https://github.com/Wikia/pandora","homepage":null,"size":5486,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":3,"default_branch":"master"}},"base":{"label":"Wikia:master","ref":"master","sha":"98a7694eb9c258e191d24a64a200ddb8732bd501","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":26663749,"name":"pandora","full_name":"Wikia/pandora","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/pandora","description":"API Service","fork":false,"url":"https://api.github.com/repos/Wikia/pandora","forks_url":"https://api.github.com/repos/Wikia/pandora/forks","keys_url":"https://api.github.com/repos/Wikia/pandora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/pandora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/pandora/teams","hooks_url":"https://api.github.com/repos/Wikia/pandora/hooks","issue_events_url":"https://api.github.com/repos/Wikia/pandora/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/pandora/events","assignees_url":"https://api.github.com/repos/Wikia/pandora/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/pandora/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/pandora/tags","blobs_url":"https://api.github.com/repos/Wikia/pandora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/pandora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/pandora/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/pandora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/pandora/languages","stargazers_url":"https://api.github.com/repos/Wikia/pandora/stargazers","contributors_url":"https://api.github.com/repos/Wikia/pandora/contributors","subscribers_url":"https://api.github.com/repos/Wikia/pandora/subscribers","subscription_url":"https://api.github.com/repos/Wikia/pandora/subscription","commits_url":"https://api.github.com/repos/Wikia/pandora/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/pandora/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/pandora/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/pandora/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/pandora/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/pandora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/pandora/merges","archive_url":"https://api.github.com/repos/Wikia/pandora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/pandora/downloads","issues_url":"https://api.github.com/repos/Wikia/pandora/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/pandora/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/pandora/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/pandora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/pandora/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/pandora/releases{/id}","created_at":"2014-11-15T00:29:06Z","updated_at":"2015-03-23T15:37:34Z","pushed_at":"2015-03-23T16:50:15Z","git_url":"git://github.com/Wikia/pandora.git","ssh_url":"git@github.com:Wikia/pandora.git","clone_url":"https://github.com/Wikia/pandora.git","svn_url":"https://github.com/Wikia/pandora","homepage":null,"size":5486,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/100"},"html":{"href":"https://github.com/Wikia/pandora/pull/100"},"issue":{"href":"https://api.github.com/repos/Wikia/pandora/issues/100"},"comments":{"href":"https://api.github.com/repos/Wikia/pandora/issues/100/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/100/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/100/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/pandora/statuses/9e13eced4b3c75b0f7826097b7fd401b0cd49d96"}}}}