{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/65061196","id":65061196,"diff_hunk":"@@ -0,0 +1,159 @@\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.mailbox.cassandra.mail;\n+\n+import static com.datastax.driver.core.querybuilder.QueryBuilder.delete;\n+import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;\n+import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;\n+import static com.datastax.driver.core.querybuilder.QueryBuilder.select;\n+import static com.datastax.driver.core.querybuilder.QueryBuilder.set;\n+import static com.datastax.driver.core.querybuilder.QueryBuilder.update;\n+\n+import java.util.AbstractMap;\n+import java.util.Map;\n+import java.util.Optional;\n+import java.util.stream.Collectors;\n+\n+import org.apache.james.backends.cassandra.utils.CassandraConstants;\n+import org.apache.james.backends.cassandra.utils.CassandraUtils;\n+import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;\n+import org.apache.james.backends.cassandra.utils.LightweightTransactionException;\n+import org.apache.james.mailbox.cassandra.CassandraId;\n+import org.apache.james.mailbox.cassandra.table.CassandraAnnotationTable;\n+import org.apache.james.mailbox.exception.MailboxException;\n+import org.apache.james.mailbox.model.MailboxAnnotation;\n+import org.apache.james.mailbox.model.MailboxAnnotation.AnnotationValue;\n+import org.apache.james.mailbox.model.MailboxAnnotation.MailboxAnnotationCommand;\n+import org.apache.james.mailbox.model.MailboxAnnotation.MailboxAnnotationEntryKey;\n+import org.apache.james.mailbox.model.MailboxAnnotation.MailboxAnnotationEntryValue;\n+import org.apache.james.mailbox.model.SimpleMailboxAnnotation;\n+import org.apache.james.mailbox.model.SimpleMailboxAnnotation.SimpleMailboxAnnotationEntryKey;\n+import org.apache.james.mailbox.model.SimpleMailboxAnnotation.SimpleMailboxAnnotationEntryValue;\n+import org.apache.james.mailbox.store.mail.model.Mailbox;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import com.datastax.driver.core.ResultSet;\n+import com.datastax.driver.core.Row;\n+import com.datastax.driver.core.Session;\n+import com.google.common.base.Preconditions;\n+\n+public class CassandraAnnotationMapper {\n+\n+    @FunctionalInterface\n+    public interface CodeInjector {\n+        void inject();\n+    }\n+\n+    private final Mailbox<CassandraId> mailbox;\n+    private final Session session;\n+    private final int maxRetry;\n+    private final CodeInjector codeInjector;\n+\n+    private static final Logger LOG = LoggerFactory.getLogger(CassandraAnnotationMapper.class);\n+\n+    public CassandraAnnotationMapper(Mailbox<CassandraId> mailbox, Session session, int maxRetry) {\n+        this(mailbox, session, maxRetry, () -> {\n+        });\n+    }\n+\n+    public CassandraAnnotationMapper(Mailbox<CassandraId> mailbox, Session session, int maxRetry,\n+            CodeInjector codeInjector) {\n+        Preconditions.checkArgument(maxRetry > 0);\n+        this.mailbox = mailbox;\n+        this.session = session;\n+        this.maxRetry = maxRetry;\n+        this.codeInjector = codeInjector;\n+    }\n+\n+    public MailboxAnnotation getAnnotation() {\n+        ResultSet resultSet = getStoredAnnotationRow();\n+        if (resultSet.isExhausted()) {","path":"mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java","position":88,"original_position":88,"commit_id":"72b0fd0850dfbdfb0b154974b373e84b6cee50db","original_commit_id":"72b0fd0850dfbdfb0b154974b373e84b6cee50db","user":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"body":"You can avoid this if, I guess","created_at":"2016-05-30T11:49:47Z","updated_at":"2016-05-30T11:49:47Z","html_url":"https://github.com/linagora/james-project/pull/253#discussion_r65061196","pull_request_url":"https://api.github.com/repos/linagora/james-project/pulls/253","_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments/65061196"},"html":{"href":"https://github.com/linagora/james-project/pull/253#discussion_r65061196"},"pull_request":{"href":"https://api.github.com/repos/linagora/james-project/pulls/253"}}},"pull_request":{"url":"https://api.github.com/repos/linagora/james-project/pulls/253","id":71882087,"html_url":"https://github.com/linagora/james-project/pull/253","diff_url":"https://github.com/linagora/james-project/pull/253.diff","patch_url":"https://github.com/linagora/james-project/pull/253.patch","issue_url":"https://api.github.com/repos/linagora/james-project/issues/253","number":253,"state":"open","locked":false,"title":"RFC-5464: Store metadata","user":{"login":"quynhn","id":296170,"avatar_url":"https://avatars.githubusercontent.com/u/296170?v=3","gravatar_id":"","url":"https://api.github.com/users/quynhn","html_url":"https://github.com/quynhn","followers_url":"https://api.github.com/users/quynhn/followers","following_url":"https://api.github.com/users/quynhn/following{/other_user}","gists_url":"https://api.github.com/users/quynhn/gists{/gist_id}","starred_url":"https://api.github.com/users/quynhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quynhn/subscriptions","organizations_url":"https://api.github.com/users/quynhn/orgs","repos_url":"https://api.github.com/users/quynhn/repos","events_url":"https://api.github.com/users/quynhn/events{/privacy}","received_events_url":"https://api.github.com/users/quynhn/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-30T10:23:16Z","updated_at":"2016-05-30T11:49:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linagora/james-project/pulls/253/commits","review_comments_url":"https://api.github.com/repos/linagora/james-project/pulls/253/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/253/comments","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/72b0fd0850dfbdfb0b154974b373e84b6cee50db","head":{"label":"quynhn:RFC-5464","ref":"RFC-5464","sha":"72b0fd0850dfbdfb0b154974b373e84b6cee50db","user":{"login":"quynhn","id":296170,"avatar_url":"https://avatars.githubusercontent.com/u/296170?v=3","gravatar_id":"","url":"https://api.github.com/users/quynhn","html_url":"https://github.com/quynhn","followers_url":"https://api.github.com/users/quynhn/followers","following_url":"https://api.github.com/users/quynhn/following{/other_user}","gists_url":"https://api.github.com/users/quynhn/gists{/gist_id}","starred_url":"https://api.github.com/users/quynhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quynhn/subscriptions","organizations_url":"https://api.github.com/users/quynhn/orgs","repos_url":"https://api.github.com/users/quynhn/repos","events_url":"https://api.github.com/users/quynhn/events{/privacy}","received_events_url":"https://api.github.com/users/quynhn/received_events","type":"User","site_admin":false},"repo":{"id":58912828,"name":"james-project","full_name":"quynhn/james-project","owner":{"login":"quynhn","id":296170,"avatar_url":"https://avatars.githubusercontent.com/u/296170?v=3","gravatar_id":"","url":"https://api.github.com/users/quynhn","html_url":"https://github.com/quynhn","followers_url":"https://api.github.com/users/quynhn/followers","following_url":"https://api.github.com/users/quynhn/following{/other_user}","gists_url":"https://api.github.com/users/quynhn/gists{/gist_id}","starred_url":"https://api.github.com/users/quynhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quynhn/subscriptions","organizations_url":"https://api.github.com/users/quynhn/orgs","repos_url":"https://api.github.com/users/quynhn/repos","events_url":"https://api.github.com/users/quynhn/events{/privacy}","received_events_url":"https://api.github.com/users/quynhn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/quynhn/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/quynhn/james-project","forks_url":"https://api.github.com/repos/quynhn/james-project/forks","keys_url":"https://api.github.com/repos/quynhn/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quynhn/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quynhn/james-project/teams","hooks_url":"https://api.github.com/repos/quynhn/james-project/hooks","issue_events_url":"https://api.github.com/repos/quynhn/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/quynhn/james-project/events","assignees_url":"https://api.github.com/repos/quynhn/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/quynhn/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/quynhn/james-project/tags","blobs_url":"https://api.github.com/repos/quynhn/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quynhn/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quynhn/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/quynhn/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quynhn/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/quynhn/james-project/languages","stargazers_url":"https://api.github.com/repos/quynhn/james-project/stargazers","contributors_url":"https://api.github.com/repos/quynhn/james-project/contributors","subscribers_url":"https://api.github.com/repos/quynhn/james-project/subscribers","subscription_url":"https://api.github.com/repos/quynhn/james-project/subscription","commits_url":"https://api.github.com/repos/quynhn/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/quynhn/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/quynhn/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/quynhn/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/quynhn/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/quynhn/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quynhn/james-project/merges","archive_url":"https://api.github.com/repos/quynhn/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quynhn/james-project/downloads","issues_url":"https://api.github.com/repos/quynhn/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/quynhn/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/quynhn/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/quynhn/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quynhn/james-project/labels{/name}","releases_url":"https://api.github.com/repos/quynhn/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/quynhn/james-project/deployments","created_at":"2016-05-16T07:35:33Z","updated_at":"2016-05-16T07:35:44Z","pushed_at":"2016-05-30T10:21:27Z","git_url":"git://github.com/quynhn/james-project.git","ssh_url":"git@github.com:quynhn/james-project.git","clone_url":"https://github.com/quynhn/james-project.git","svn_url":"https://github.com/quynhn/james-project","homepage":null,"size":11129,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"linagora:master","ref":"master","sha":"f53d0eb93045212d778b211384dde48ef1cefc99","user":{"login":"linagora","id":1230365,"avatar_url":"https://avatars.githubusercontent.com/u/1230365?v=3","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,"name":"james-project","full_name":"linagora/james-project","owner":{"login":"linagora","id":1230365,"avatar_url":"https://avatars.githubusercontent.com/u/1230365?v=3","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":"2016-05-24T08:51:49Z","pushed_at":"2016-05-30T10:23:16Z","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":13542,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":14,"forks":8,"open_issues":14,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/253"},"html":{"href":"https://github.com/linagora/james-project/pull/253"},"issue":{"href":"https://api.github.com/repos/linagora/james-project/issues/253"},"comments":{"href":"https://api.github.com/repos/linagora/james-project/issues/253/comments"},"review_comments":{"href":"https://api.github.com/repos/linagora/james-project/pulls/253/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/253/commits"},"statuses":{"href":"https://api.github.com/repos/linagora/james-project/statuses/72b0fd0850dfbdfb0b154974b373e84b6cee50db"}}}}
{"actor":{"display_login":"chibenwa"}}