{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/comments/37524674","id":37524674,"diff_hunk":"@@ -0,0 +1,85 @@\n+package com.wikia.services.dcfilesync.service;\n+\n+import com.wikia.model.asset.rabbit.Dc;\n+import com.wikia.pandora.gateway.ceph.CephS3Gateway;\n+import com.wikia.pandora.gateway.exceptions.CephObjectNotFoundException;\n+import com.wikia.services.dcfilesync.DcFileSyncApplication;\n+\n+import java.io.FileNotFoundException;\n+import java.io.IOException;\n+\n+import javax.inject.Inject;\n+import javax.inject.Named;\n+\n+public class CephS3FileService implements FileService {\n+\n+  private final CephS3Gateway sjcGateway;\n+\n+  private final CephS3Gateway restonGateway;\n+\n+  @Inject\n+  public CephS3FileService(\n+      @Named(\"sjc-ceph-s3-gateway\") CephS3Gateway sjcGateway,\n+      @Named(\"reston-ceph-s3-gateway\") CephS3Gateway restonGateway) {\n+    this.sjcGateway = sjcGateway;\n+    this.restonGateway = restonGateway;\n+  }\n+\n+  CephS3Gateway getGatewayForDc(Dc dc) {\n+    if (dc == Dc.SJC) {\n+      return sjcGateway;\n+    } else if (dc == Dc.Reston) {\n+      return restonGateway;\n+    } else {\n+      throw new RuntimeException(String.format(\"Invalid DC: %s\", dc.toValue()));\n+    }\n+  }\n+\n+  private CephS3Gateway.GetFileResult getFile(\n+      CephS3Gateway gateway, String bucketName, String fileName) throws IOException {\n+\n+    try {\n+      return gateway.getFile(bucketName, fileName);\n+    } catch (CephObjectNotFoundException e) {\n+      String message = String.format(\n+          \"Could not find requested file - bucket: %s, file name: %s\",\n+          bucketName,\n+          fileName);\n+      DcFileSyncApplication.LOGGER.error(message, e);\n+      throw new FileNotFoundException(message);\n+    }\n+  }\n+\n+  public void copyFile(\n+      Dc sourceDc,\n+      String bucketName,\n+      String fileName,\n+      Dc destDc\n+  ) throws IOException {\n+\n+    CephS3Gateway sourceGateway = getGatewayForDc(sourceDc);\n+    CephS3Gateway destGateway = getGatewayForDc(destDc);\n+\n+    CephS3Gateway.GetFileResult file = getFile(sourceGateway, bucketName, fileName);\n+\n+    try {\n+      destGateway.putFile(bucketName, fileName, file.getInputStream(), file.getLength());\n+    } finally {\n+      file.getInputStream().close();\n+    }\n+  }\n+\n+  public void deleteFile(","path":"service/dc-file-sync/src/main/java/com/wikia/services/dcfilesync/service/CephS3FileService.java","position":72,"original_position":72,"commit_id":"e5c1c16dd71b43ef13c63393a3f65b899cc47b07","original_commit_id":"634e8796a4d024339482d309f1b897fdbc348ace","user":{"login":"jcellary","id":7473307,"avatar_url":"https://avatars.githubusercontent.com/u/7473307?v=3","gravatar_id":"","url":"https://api.github.com/users/jcellary","html_url":"https://github.com/jcellary","followers_url":"https://api.github.com/users/jcellary/followers","following_url":"https://api.github.com/users/jcellary/following{/other_user}","gists_url":"https://api.github.com/users/jcellary/gists{/gist_id}","starred_url":"https://api.github.com/users/jcellary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcellary/subscriptions","organizations_url":"https://api.github.com/users/jcellary/orgs","repos_url":"https://api.github.com/users/jcellary/repos","events_url":"https://api.github.com/users/jcellary/events{/privacy}","received_events_url":"https://api.github.com/users/jcellary/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2015-08-20T12:50:21Z","updated_at":"2015-08-20T12:50:21Z","html_url":"https://github.com/Wikia/pandora/pull/399#discussion_r37524674","pull_request_url":"https://api.github.com/repos/Wikia/pandora/pulls/399","_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments/37524674"},"html":{"href":"https://github.com/Wikia/pandora/pull/399#discussion_r37524674"},"pull_request":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/399"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/399","id":42810071,"html_url":"https://github.com/Wikia/pandora/pull/399","diff_url":"https://github.com/Wikia/pandora/pull/399.diff","patch_url":"https://github.com/Wikia/pandora/pull/399.patch","issue_url":"https://api.github.com/repos/Wikia/pandora/issues/399","number":399,"state":"open","locked":false,"title":"[Platform-1371] Added Dc file sync worker for Sjc - Reston image synchronization","user":{"login":"jcellary","id":7473307,"avatar_url":"https://avatars.githubusercontent.com/u/7473307?v=3","gravatar_id":"","url":"https://api.github.com/users/jcellary","html_url":"https://github.com/jcellary","followers_url":"https://api.github.com/users/jcellary/followers","following_url":"https://api.github.com/users/jcellary/following{/other_user}","gists_url":"https://api.github.com/users/jcellary/gists{/gist_id}","starred_url":"https://api.github.com/users/jcellary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcellary/subscriptions","organizations_url":"https://api.github.com/users/jcellary/orgs","repos_url":"https://api.github.com/users/jcellary/repos","events_url":"https://api.github.com/users/jcellary/events{/privacy}","received_events_url":"https://api.github.com/users/jcellary/received_events","type":"User","site_admin":false},"body":"A few additions:\r\n- Dc file sync worker for Sjc - Reston image synchronization. Also made changes to the Rabbit Abstract Worker to enable greater customization. \r\n- Extended Static Assets Service to push events to the rabbit queue and store information about images in the assets_in_dc table","created_at":"2015-08-19T12:49:17Z","updated_at":"2015-08-20T12:50:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4b21f9b5bf5b757b348d4899a687805a6e5ecf00","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/pandora/pulls/399/commits","review_comments_url":"https://api.github.com/repos/Wikia/pandora/pulls/399/comments","review_comment_url":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/pandora/issues/399/comments","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/e5c1c16dd71b43ef13c63393a3f65b899cc47b07","head":{"label":"Wikia:dc-file-sync","ref":"dc-file-sync","sha":"e5c1c16dd71b43ef13c63393a3f65b899cc47b07","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-08-18T21:15:19Z","pushed_at":"2015-08-20T10:59:49Z","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":25497,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":3,"default_branch":"master"}},"base":{"label":"Wikia:master","ref":"master","sha":"81f1320901db859349ffadf8f4b28cfdc66c3445","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-08-18T21:15:19Z","pushed_at":"2015-08-20T10:59:49Z","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":25497,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/399"},"html":{"href":"https://github.com/Wikia/pandora/pull/399"},"issue":{"href":"https://api.github.com/repos/Wikia/pandora/issues/399"},"comments":{"href":"https://api.github.com/repos/Wikia/pandora/issues/399/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/399/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/399/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/pandora/statuses/e5c1c16dd71b43ef13c63393a3f65b899cc47b07"}}}}