{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/212572550","pull_request_review_id":149235411,"id":212572550,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjU3MjU1MA==","diff_hunk":"@@ -0,0 +1,120 @@\n+/****************************************************************\n+ * Licensed to the Apache Software Foundation (ASF) under one   *\n+ * or more contributor license agreements.  See the NOTICE file *\n+ * distributed with this work for additional information        *\n+ * regarding copyright ownership.  The ASF licenses this file   *\n+ * to you under the Apache License, Version 2.0 (the            *\n+ * \"License\"); you may not use this file except in compliance   *\n+ * with the License.  You may obtain a copy of the License at   *\n+ *                                                              *\n+ *   http://www.apache.org/licenses/LICENSE-2.0                 *\n+ *                                                              *\n+ * Unless required by applicable law or agreed to in writing,   *\n+ * software distributed under the License is distributed on an  *\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *\n+ * KIND, either express or implied.  See the License for the    *\n+ * specific language governing permissions and limitations      *\n+ * under the License.                                           *\n+ ****************************************************************/\n+\n+package org.apache.james.blob.cloud;\n+\n+import java.io.ByteArrayInputStream;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.util.UUID;\n+import java.util.concurrent.CompletableFuture;\n+\n+import org.apache.commons.io.IOUtils;\n+import org.apache.james.blob.api.BlobId;\n+import org.apache.james.blob.api.HashBlobId;\n+import org.apache.james.blob.api.ObjectStore;\n+import org.apache.james.blob.api.ObjectStoreException;\n+import org.jclouds.ContextBuilder;\n+import org.jclouds.blobstore.BlobStore;\n+import org.jclouds.blobstore.domain.Blob;\n+import org.jclouds.blobstore.options.CopyOptions;\n+import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;\n+import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext;\n+\n+import com.github.fge.lambdas.Throwing;\n+import com.google.common.base.Preconditions;\n+import com.google.common.collect.ImmutableSet;\n+import com.google.common.hash.Hashing;\n+import com.google.common.hash.HashingInputStream;\n+import com.google.inject.Inject;\n+import com.google.inject.Module;\n+\n+class CloudBlobsDAO implements ObjectStore {\n+    private static final InputStream EMPTY_STREAM = new ByteArrayInputStream(new byte[0]);\n+    private static final Iterable<Module> JCLOUDS_MODULES = ImmutableSet.of(new SLF4JLoggingModule());\n+\n+    private final BlobId.Factory blobIdFactory;\n+    private final BlobStore blobStore;\n+    private final ContainerName containerName;\n+\n+    @Inject\n+    public CloudBlobsDAO(ContainerName containerName, HashBlobId.Factory blobIdFactory,\n+                         CloudsBlobsConfiguration cloudsBlobsConfiguration) {\n+        this.blobIdFactory = blobIdFactory;\n+        this.containerName = containerName;\n+\n+        RegionScopedBlobStoreContext blobStoreContext = ContextBuilder.newBuilder(\"openstack-swift\")\n+            .endpoint(cloudsBlobsConfiguration.getEndpoint().toString())\n+            .credentials(\n+                cloudsBlobsConfiguration.getIdentity().getValue(),\n+                cloudsBlobsConfiguration.getCredentials().getValue())\n+            .overrides(cloudsBlobsConfiguration.getOverrides())\n+            .modules(JCLOUDS_MODULES)\n+            .buildView(RegionScopedBlobStoreContext.class);\n+\n+        blobStore = cloudsBlobsConfiguration\n+            .getRegion()\n+            .map(region -> blobStoreContext.getBlobStore(region.getValue()))\n+            .orElse(blobStoreContext.getBlobStore());\n+    }\n+\n+    @Override\n+    public CompletableFuture<BlobId> save(byte[] data) {\n+        return save(new ByteArrayInputStream(data));\n+    }\n+\n+    @Override\n+    public CompletableFuture<BlobId> save(InputStream data) {","path":"server/blob/blob-cloud/src/main/java/org/apache/james/blob/cloud/CloudBlobsDAO.java","position":83,"original_position":83,"commit_id":"33a15e10baeefd1deb1ccf085ba3b3a2e27f0b18","original_commit_id":"33a15e10baeefd1deb1ccf085ba3b3a2e27f0b18","user":{"login":"mbaechler","id":708318,"node_id":"MDQ6VXNlcjcwODMxOA==","avatar_url":"https://avatars2.githubusercontent.com/u/708318?v=4","gravatar_id":"","url":"https://api.github.com/users/mbaechler","html_url":"https://github.com/mbaechler","followers_url":"https://api.github.com/users/mbaechler/followers","following_url":"https://api.github.com/users/mbaechler/following{/other_user}","gists_url":"https://api.github.com/users/mbaechler/gists{/gist_id}","starred_url":"https://api.github.com/users/mbaechler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbaechler/subscriptions","organizations_url":"https://api.github.com/users/mbaechler/orgs","repos_url":"https://api.github.com/users/mbaechler/repos","events_url":"https://api.github.com/users/mbaechler/events{/privacy}","received_events_url":"https://api.github.com/users/mbaechler/received_events","type":"User","site_admin":false},"body":"that's pseudo-code of course, you can rely on Pair class","created_at":"2018-08-24T09:32:25Z","updated_at":"2018-08-24T09:32:25Z","html_url":"https://github.com/linagora/james-project/pull/1681#discussion_r212572550","pull_request_url":"https://api.github.com/repos/linagora/james-project/pulls/1681","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments/212572550"},"html":{"href":"https://github.com/linagora/james-project/pull/1681#discussion_r212572550"},"pull_request":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1681"}},"in_reply_to_id":212546000},"pull_request":{"url":"https://api.github.com/repos/linagora/james-project/pulls/1681","id":210508692,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwNTA4Njky","html_url":"https://github.com/linagora/james-project/pull/1681","diff_url":"https://github.com/linagora/james-project/pull/1681.diff","patch_url":"https://github.com/linagora/james-project/pull/1681.patch","issue_url":"https://api.github.com/repos/linagora/james-project/issues/1681","number":1681,"state":"open","locked":false,"title":"JAMES-2525 CloudBlob store (swift+tempAuth)","user":{"login":"jeantil","id":22979,"node_id":"MDQ6VXNlcjIyOTc5","avatar_url":"https://avatars3.githubusercontent.com/u/22979?v=4","gravatar_id":"","url":"https://api.github.com/users/jeantil","html_url":"https://github.com/jeantil","followers_url":"https://api.github.com/users/jeantil/followers","following_url":"https://api.github.com/users/jeantil/following{/other_user}","gists_url":"https://api.github.com/users/jeantil/gists{/gist_id}","starred_url":"https://api.github.com/users/jeantil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeantil/subscriptions","organizations_url":"https://api.github.com/users/jeantil/orgs","repos_url":"https://api.github.com/users/jeantil/repos","events_url":"https://api.github.com/users/jeantil/events{/privacy}","received_events_url":"https://api.github.com/users/jeantil/received_events","type":"User","site_admin":false},"body":"This implementation is currently hard coded on swift with tempAuthCredentials. This will be improved in further pull requests.","created_at":"2018-08-23T16:39:06Z","updated_at":"2018-08-24T09:32:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e6dc95ad009aa0c932e8f4206de46954d33a79fd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/linagora/james-project/pulls/1681/commits","review_comments_url":"https://api.github.com/repos/linagora/james-project/pulls/1681/comments","review_comment_url":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linagora/james-project/issues/1681/comments","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/33a15e10baeefd1deb1ccf085ba3b3a2e27f0b18","head":{"label":"jeantil:JAMES-2525-blob-store-swift-tempauth","ref":"JAMES-2525-blob-store-swift-tempauth","sha":"33a15e10baeefd1deb1ccf085ba3b3a2e27f0b18","user":{"login":"jeantil","id":22979,"node_id":"MDQ6VXNlcjIyOTc5","avatar_url":"https://avatars3.githubusercontent.com/u/22979?v=4","gravatar_id":"","url":"https://api.github.com/users/jeantil","html_url":"https://github.com/jeantil","followers_url":"https://api.github.com/users/jeantil/followers","following_url":"https://api.github.com/users/jeantil/following{/other_user}","gists_url":"https://api.github.com/users/jeantil/gists{/gist_id}","starred_url":"https://api.github.com/users/jeantil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeantil/subscriptions","organizations_url":"https://api.github.com/users/jeantil/orgs","repos_url":"https://api.github.com/users/jeantil/repos","events_url":"https://api.github.com/users/jeantil/events{/privacy}","received_events_url":"https://api.github.com/users/jeantil/received_events","type":"User","site_admin":false},"repo":{"id":51064074,"node_id":"MDEwOlJlcG9zaXRvcnk1MTA2NDA3NA==","name":"james-project","full_name":"jeantil/james-project","owner":{"login":"jeantil","id":22979,"node_id":"MDQ6VXNlcjIyOTc5","avatar_url":"https://avatars3.githubusercontent.com/u/22979?v=4","gravatar_id":"","url":"https://api.github.com/users/jeantil","html_url":"https://github.com/jeantil","followers_url":"https://api.github.com/users/jeantil/followers","following_url":"https://api.github.com/users/jeantil/following{/other_user}","gists_url":"https://api.github.com/users/jeantil/gists{/gist_id}","starred_url":"https://api.github.com/users/jeantil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeantil/subscriptions","organizations_url":"https://api.github.com/users/jeantil/orgs","repos_url":"https://api.github.com/users/jeantil/repos","events_url":"https://api.github.com/users/jeantil/events{/privacy}","received_events_url":"https://api.github.com/users/jeantil/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeantil/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/jeantil/james-project","forks_url":"https://api.github.com/repos/jeantil/james-project/forks","keys_url":"https://api.github.com/repos/jeantil/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeantil/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeantil/james-project/teams","hooks_url":"https://api.github.com/repos/jeantil/james-project/hooks","issue_events_url":"https://api.github.com/repos/jeantil/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/jeantil/james-project/events","assignees_url":"https://api.github.com/repos/jeantil/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/jeantil/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/jeantil/james-project/tags","blobs_url":"https://api.github.com/repos/jeantil/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeantil/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeantil/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeantil/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeantil/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/jeantil/james-project/languages","stargazers_url":"https://api.github.com/repos/jeantil/james-project/stargazers","contributors_url":"https://api.github.com/repos/jeantil/james-project/contributors","subscribers_url":"https://api.github.com/repos/jeantil/james-project/subscribers","subscription_url":"https://api.github.com/repos/jeantil/james-project/subscription","commits_url":"https://api.github.com/repos/jeantil/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeantil/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeantil/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeantil/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeantil/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/jeantil/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeantil/james-project/merges","archive_url":"https://api.github.com/repos/jeantil/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeantil/james-project/downloads","issues_url":"https://api.github.com/repos/jeantil/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/jeantil/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/jeantil/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/jeantil/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeantil/james-project/labels{/name}","releases_url":"https://api.github.com/repos/jeantil/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/jeantil/james-project/deployments","created_at":"2016-02-04T09:02:49Z","updated_at":"2016-02-04T09:02:58Z","pushed_at":"2018-08-23T16:37:21Z","git_url":"git://github.com/jeantil/james-project.git","ssh_url":"git@github.com:jeantil/james-project.git","clone_url":"https://github.com/jeantil/james-project.git","svn_url":"https://github.com/jeantil/james-project","homepage":null,"size":34555,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"linagora:master","ref":"master","sha":"8bfefda83f1ccf0db8bdecc5dc60d6f5764f747f","user":{"login":"linagora","id":1230365,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyMzAzNjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1230365?v=4","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"repo":{"id":39182136,"node_id":"MDEwOlJlcG9zaXRvcnkzOTE4MjEzNg==","name":"james-project","full_name":"linagora/james-project","owner":{"login":"linagora","id":1230365,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyMzAzNjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1230365?v=4","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linagora/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/linagora/james-project","forks_url":"https://api.github.com/repos/linagora/james-project/forks","keys_url":"https://api.github.com/repos/linagora/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linagora/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linagora/james-project/teams","hooks_url":"https://api.github.com/repos/linagora/james-project/hooks","issue_events_url":"https://api.github.com/repos/linagora/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/linagora/james-project/events","assignees_url":"https://api.github.com/repos/linagora/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/linagora/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/linagora/james-project/tags","blobs_url":"https://api.github.com/repos/linagora/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linagora/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linagora/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/linagora/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/linagora/james-project/languages","stargazers_url":"https://api.github.com/repos/linagora/james-project/stargazers","contributors_url":"https://api.github.com/repos/linagora/james-project/contributors","subscribers_url":"https://api.github.com/repos/linagora/james-project/subscribers","subscription_url":"https://api.github.com/repos/linagora/james-project/subscription","commits_url":"https://api.github.com/repos/linagora/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/linagora/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/linagora/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/linagora/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/linagora/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/linagora/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linagora/james-project/merges","archive_url":"https://api.github.com/repos/linagora/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linagora/james-project/downloads","issues_url":"https://api.github.com/repos/linagora/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/linagora/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/linagora/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/linagora/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linagora/james-project/labels{/name}","releases_url":"https://api.github.com/repos/linagora/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/linagora/james-project/deployments","created_at":"2015-07-16T07:04:59Z","updated_at":"2018-08-23T12:50:19Z","pushed_at":"2018-08-24T09:23:31Z","git_url":"git://github.com/linagora/james-project.git","ssh_url":"git@github.com:linagora/james-project.git","clone_url":"https://github.com/linagora/james-project.git","svn_url":"https://github.com/linagora/james-project","homepage":null,"size":35652,"stargazers_count":21,"watchers_count":21,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":26,"mirror_url":null,"archived":false,"open_issues_count":73,"license":null,"forks":26,"open_issues":73,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1681"},"html":{"href":"https://github.com/linagora/james-project/pull/1681"},"issue":{"href":"https://api.github.com/repos/linagora/james-project/issues/1681"},"comments":{"href":"https://api.github.com/repos/linagora/james-project/issues/1681/comments"},"review_comments":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1681/comments"},"review_comment":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1681/commits"},"statuses":{"href":"https://api.github.com/repos/linagora/james-project/statuses/33a15e10baeefd1deb1ccf085ba3b3a2e27f0b18"}},"author_association":"NONE"}}
{"actor":{"display_login":"mbaechler"}}