{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/65324630","id":65324630,"diff_hunk":"@@ -0,0 +1,328 @@\n+package org.apache.james.mailbox.model;\n+\n+import java.util.Collections;\n+import java.util.HashMap;\n+import java.util.Iterator;\n+import java.util.Map;\n+import java.util.Map.Entry;\n+import java.util.regex.Pattern;\n+\n+import org.apache.james.mailbox.exception.UnsupportedAnnotationException;\n+import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;\n+\n+import com.google.common.base.Preconditions;\n+\n+public class SimpleMailboxAnnotation implements MailboxAnnotation {\n+\n+    private static final Pattern NAME_ANNOTATION_PATTERN = Pattern.compile(\"[^\\\\x1a-\\\\x7f]\");\n+\n+    public static final MailboxAnnotation EMPTY;\n+\n+    private final Map<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue> entries;\n+\n+    static {\n+        EMPTY = new SimpleMailboxAnnotation();\n+    }\n+\n+    /**\n+     * Creates a new instance of SimpleMailboxAnnotation containing no entries.\n+     * \n+     */\n+    public SimpleMailboxAnnotation() {\n+        this.entries = Collections.emptyMap();\n+    }\n+\n+    /**\n+     * Creates a new instance of SimpleMailboxAnnotation from the given array of\n+     * entries.\n+     * \n+     * @param entries\n+     */\n+    public SimpleMailboxAnnotation(Map.Entry<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue>[] entries) {\n+        if (entries != null) {\n+            Map<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue> m = \n+                    new HashMap<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue>(entries.length + entries.length / 2 + 1);\n+            for (Entry<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue> en : entries) {\n+                m.put(en.getKey(), en.getValue());\n+            }\n+            this.entries = Collections.unmodifiableMap(m);\n+        } else {\n+            this.entries = Collections.emptyMap();\n+        }\n+    }\n+\n+    /**\n+     * Creates a new instance of SimpleMailboxAnnotation from the given {@link Map} of\n+     * entries.\n+     * \n+     * @param entries\n+     */\n+    public SimpleMailboxAnnotation(Map<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue> entries) {\n+        if (entries != null && entries.size() > 0) {\n+            Map<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue> m = \n+                    new HashMap<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue>(entries.size() + entries.size() / 2 + 1);\n+            for (Entry<MailboxAnnotationEntryKey, MailboxAnnotationEntryValue> en : entries.entrySet()) {\n+                m.put(en.getKey(), en.getValue());\n+            }\n+            this.entries = Collections.unmodifiableMap(m);\n+        } else {\n+            this.entries = Collections.emptyMap();\n+        }\n+    }\n+\n+    /**\n+     * Default implementation of {@link MailboxACLEntryKey}.\n+     */\n+    public static class SimpleMailboxAnnotationEntryKey implements MailboxAnnotationEntryKey {\n+        private final String name;\n+\n+        /**\n+         * Creates a new instance of SimpleMailboxAnnotationEntryKey from the given\n+         * serialized {@link String}.\n+         * \n+         * @param serialized\n+         */\n+        public SimpleMailboxAnnotationEntryKey(String serialized) {\n+\n+            if (serialized == null) {\n+                throw new IllegalStateException(\"Cannot parse null to a \" + getClass().getName());\n+            }\n+            serialized = serialized.trim();\n+            if (serialized.length() == 0) {\n+                throw new IllegalStateException(\"Cannot parse an empty string to a \" + getClass().getName());\n+            }\n+            if (serialized.charAt(0) != SLASH_CHARACTER) {\n+                throw new IllegalStateException(\"The annotation does not start with a slash \" + getClass().getName());\n+            }\n+            if (serialized.contains(\"\" + ASTERISK_CHARACTER)) {\n+                throw new IllegalStateException(\"The annotation contains at least a '*' character \" + getClass().getName());\n+            }\n+            if (serialized.contains(\"\" + PERCENT_CHARACTER)) {\n+                throw new IllegalStateException(\"The annotation contains at least a '%' character \" + getClass().getName());\n+            }\n+            if (serialized.contains(\"\" + SLASH_CHARACTER + SLASH_CHARACTER)) {\n+                throw new IllegalStateException(\"The annotation contains 2 consecutive '/' character \" + getClass().getName());\n+            }\n+            if (serialized.endsWith(\"\" + SLASH_CHARACTER)) {\n+                throw new IllegalStateException(\"The annotation ends with '/' character \" + getClass().getName());\n+            }\n+            if (NAME_ANNOTATION_PATTERN.matcher(serialized).find()) {\n+                throw new IllegalStateException(\"The annotation contains non-ASCII character except some special characters \" + getClass().getName());\n+            }\n+            this.name = serialized;\n+        }\n+\n+        @Override\n+        public boolean equals(Object o) {\n+            if (o instanceof MailboxAnnotationEntryKey) {\n+                MailboxAnnotationEntryKey other = (MailboxAnnotationEntryKey) o;\n+                return this.name.equals(other.getName());\n+            } else {\n+                return false;\n+            }\n+        }\n+\n+        /*\n+         * (non-Javadoc)\n+         * \n+         * @see org.apache.james.mailbox.MailboxACL.MailboxACLEntryKey#getName()\n+         */\n+        public String getName() {\n+            return name;\n+        }\n+\n+        @Override\n+        public int hashCode() {\n+            return name.hashCode();\n+        }\n+\n+        @Override\n+        public String toString() {\n+            return new StringBuilder(name.length()).append(name).toString();\n+        }\n+\n+    }\n+\n+    public static class SimpleMailboxAnnotationEntryValue implements MailboxAnnotationEntryValue {\n+        private final int hash;\n+        private final Object value;\n+        private final AnnotationValue valueType;\n+\n+        public static final MailboxAnnotationEntryValue NIL;\n+\n+        static {\n+            NIL = new SimpleMailboxAnnotationEntryValue();\n+        }\n+\n+        public SimpleMailboxAnnotationEntryValue(Object value, AnnotationValue valueType) {","path":"mailbox/api/src/main/java/org/apache/james/mailbox/model/SimpleMailboxAnnotation.java","position":157,"original_position":157,"commit_id":"72b0fd0850dfbdfb0b154974b373e84b6cee50db","original_commit_id":"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},"body":"It's changed. Could you double check on MailboxAnnotation POJO?","created_at":"2016-06-01T08:55:51Z","updated_at":"2016-06-01T08:55:51Z","html_url":"https://github.com/linagora/james-project/pull/253#discussion_r65324630","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/65324630"},"html":{"href":"https://github.com/linagora/james-project/pull/253#discussion_r65324630"},"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-06-01T08:55:51Z","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-06-01T08:31: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":13674,"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":18,"forks":8,"open_issues":18,"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":"quynhn"}}