MAILBOX-270: getmetadata command, more testing on mpt
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a4164242 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a4164242 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a4164242 Branch: refs/heads/master Commit: a41642420e5d0da2bf6ed4ae3638763bd36692dc Parents: 5376a7e Author: Quynh Nguyen <[email protected]> Authored: Tue Jul 5 14:15:13 2016 +0700 Committer: Quynh Nguyen <[email protected]> Committed: Tue Aug 30 16:27:52 2016 +0700 ---------------------------------------------------------------------- .../inmemory/mail/InMemoryAnnotationMapper.java | 4 +- .../apache/james/imap/scripts/Annotation.test | 81 ++++++++++++++++++++ .../imap/processor/GetAnnotationProcessor.java | 13 ++-- 3 files changed, 91 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/a4164242/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java index c951e07..ff9f962 100644 --- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java +++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java @@ -65,11 +65,11 @@ public class InMemoryAnnotationMapper implements AnnotationMapper { lock.readLock().lock(); try { return Iterables.transform( - mailboxesAnnotations.row(maiboxId).entrySet(), + mailboxesAnnotations.row(mailboxId).entrySet(), new Function<Map.Entry<String, String>, MailboxAnnotation>() { @Override public MailboxAnnotation apply(Entry<String, String> input) { - return MailboxAnnotation.newInstance(input.getKey(), input.getValue()); + return MailboxAnnotation.newInstance(new MailboxAnnotationKey(input.getKey()), input.getValue()); } }); } finally { http://git-wip-us.apache.org/repos/asf/james-project/blob/a4164242/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Annotation.test ---------------------------------------------------------------------- diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Annotation.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Annotation.test index 870b76a..9b3066e 100644 --- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Annotation.test +++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Annotation.test @@ -23,6 +23,10 @@ S: a0 OK CAPABILITY completed. C: a1 SETMETADATA INBOX (/private/comment "My new comment") S: a1 OK SETMETADATA completed. +C: g1 GETMETADATA "INBOX" /private/comment +S: \* METADATA "INBOX" \(\/private\/comment "My new comment"\) +S: g1 OK GETMETADATA completed. + C: a2 SETMETADATA INBOX (/pri*vate/comment "My new comment") S: a2 BAD SETMETADATA failed. Illegal arguments. @@ -35,6 +39,11 @@ C: My new comment across C: two lines. ) S: a4 OK SETMETADATA completed. +C: g2 GETMETADATA "INBOX" /private/comment +S: \* METADATA "INBOX" \(\/private\/comment "My new comment across +S: two lines."\) +S: g2 OK GETMETADATA completed. + C: a5 SETMETADATA INBOX (/private/comment "My new comment" /shared/comment "This one is for you!") S: a5 OK SETMETADATA completed. @@ -61,3 +70,75 @@ S: a13 BAD SETMETADATA failed. Illegal arguments. C: a14 SETMETADATA INBOX (/private/comment My new comment) S: a14 BAD SETMETADATA failed. Illegal arguments. + +########################For get annotation############ + +C: s1 SETMETADATA INBOX (/private/comment "My own comment") +S: s1 OK SETMETADATA completed. + +C: s2 SETMETADATA INBOX (/shared/comment "The shared comment") +S: s2 OK SETMETADATA completed. + +C: g3 GETMETADATA "INBOX" (/shared/comment /private/comment) +S: \* METADATA "INBOX" \(\/private\/comment "My own comment" \/shared\/comment "The shared comment"\) +S: g3 OK GETMETADATA completed. + +C: g4 GETMETADATA "INBOX" +S: \* METADATA "INBOX" \(\/private\/comment "My own comment" \/shared\/comment "The shared comment"\) +S: g4 OK GETMETADATA completed. + +C: g5 GETMETADATA "INBOX" /shared/comment /private/comment) +S: g5 BAD GETMETADATA failed. Illegal arguments. + +C: g6 GETMETADATA "INBOX" (/shared/comment /private/comment +S: g6 BAD GETMETADATA failed. Illegal arguments. + +C: g7 GETMETADATA "INBOX" private/comment +S: g7 BAD GETMETADATA failed. Illegal arguments. + +C: g8 GETMETADATA "INBOX" (MAXSIZE 15) +S: \* METADATA "INBOX" \(\/private\/comment "My own comment"\) +S: g8 OK \[METADATA LONGENTRIES 18\] GETMETADATA completed. + +C: g9 GETMETADATA "INBOX" (MAXSIZE 100) +S: \* METADATA "INBOX" \(\/private\/comment "My own comment" \/shared\/comment "The shared comment"\) +S: g9 OK GETMETADATA completed. + +C: s3 SETMETADATA INBOX (/private/comment/user "My own comment for user") +S: s3 OK SETMETADATA completed. + +C: s4 SETMETADATA INBOX (/private/comment/user/name "My own comment for user name") +S: s4 OK SETMETADATA completed. + +C: g10 GETMETADATA "INBOX" (DEPTH 1) (MAXSIZE 15) (/private/comment) +S: \* METADATA "INBOX" \(\/private\/comment "My own comment"\) +S: g10 OK \[METADATA LONGENTRIES 23\] GETMETADATA completed. + +C: g11 GETMETADATA "INBOX" (DEPTH 1) (/private/comment) +S: \* METADATA "INBOX" \(\/private\/comment "My own comment" \/private\/comment\/user "My own comment for user"\) +S: g11 OK GETMETADATA completed. + +C: g12 GETMETADATA "INBOX" (DEPTH infinity) (/private/comment) +S: \* METADATA "INBOX" \(\/private\/comment.* "My own comment.* \/private\/comment.* "My own comment.* \/private\/comment.* "My own comment.*\) +S: g12 OK GETMETADATA completed. + +C: g13 GETMETADATA "INBOX" (/private/comment) (/another/key/group) +S: g13 BAD GETMETADATA failed. Illegal arguments. + +C: g14 GETMETADATA "INBOX" (MAXSIZE 10) (DEPTH 1) +S: g14 BAD GETMETADATA failed. Illegal arguments. + +C: g15 GETMETADATA "INBOX" (/private/comment) (MAXSIZE 10) +S: g15 BAD GETMETADATA failed. Illegal arguments. + +C: g17 GETMETADATA "INBOX" (/private/comment) (DEPTH 1) +S: g17 BAD GETMETADATA failed. Illegal arguments. + +C: g16 GETMETADATA "INBOX" (DEPTH -1) (/private/comment) +S: g16 BAD GETMETADATA failed. Illegal arguments. + +C: g18 GETMETADATA (/private/comment) +S: g18 BAD GETMETADATA failed. Illegal arguments. + +C: g19 GETMETADATA "INBOX" (MAXSIZE 0) (/private/comment) +S: g19 BAD GETMETADATA failed. Illegal arguments. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/a4164242/protocols/imap/src/main/java/org/apache/james/imap/processor/GetAnnotationProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetAnnotationProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetAnnotationProcessor.java index f8c03fa..052e533 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetAnnotationProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetAnnotationProcessor.java @@ -92,11 +92,14 @@ public class GetAnnotationProcessor extends AbstractMailboxProcessor<GetAnnotati } } - private Optional<Integer> getMaxSizeOfItemsOversize(List<MailboxAnnotation> mailboxAnnotations, long maxsize) { - if (maxsize > 0) { - return getMaxValueOverSize(mailboxAnnotations, maxsize); - } else { - return Optional.absent(); + private Optional<Integer> getMaxSizeValue(final List<MailboxAnnotation> mailboxAnnotations, Optional<Integer> maxsize) { + if (maxsize.isPresent()) { + return maxsize.transform(new Function<Integer, Optional<Integer>>() { + @Override + public Optional<Integer> apply(Integer input) { + return getMaxSizeOfOversizedItems(mailboxAnnotations, input); + } + }).get(); } return Optional.absent(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
