james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [08/17] james-project git commit: JAMES-2436 Add MailboxId metadata to mailboxes
Date Wed, 27 Jun 2018 14:44:30 GMT
JAMES-2436 Add MailboxId metadata to mailboxes


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/10c80334
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/10c80334
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/10c80334

Branch: refs/heads/master
Commit: 10c80334002f8e97d6931f53fb60558da52d4935
Parents: f30001c
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Wed Jun 20 15:58:59 2018 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Wed Jun 27 16:36:12 2018 +0200

----------------------------------------------------------------------
 .../java/org/apache/james/mailbox/backup/Zipper.java    |  3 +++
 .../org/apache/james/mailbox/backup/ZipperTest.java     | 12 ++++++++++++
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/10c80334/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java
----------------------------------------------------------------------
diff --git a/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java b/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java
index 9b13bc2..a69ba24 100644
--- a/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java
+++ b/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java
@@ -57,6 +57,9 @@ public class Zipper implements Backup {
     private void storeInArchive(Mailbox mailbox, ZipArchiveOutputStream archiveOutputStream)
throws IOException {
         String name = mailbox.getName();
         ZipArchiveEntry archiveEntry = (ZipArchiveEntry) archiveOutputStream.createArchiveEntry(new
Directory(name), name);
+
+        archiveEntry.addExtraField(new MailboxIdExtraField(mailbox.getMailboxId().serialize()));
+
         archiveOutputStream.putArchiveEntry(archiveEntry);
         archiveOutputStream.closeArchiveEntry();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/10c80334/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java
b/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java
index 6e67a91..ca60d43 100644
--- a/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java
+++ b/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java
@@ -161,6 +161,18 @@ class ZipperTest {
         }
     }
 
+    @Test
+    void archiveShouldWriteMailboxMetadataWhenPresent() throws Exception {
+        testee.archive(ImmutableList.of(MAILBOX_1), Stream.of(), output);
+
+        try (ZipFile zipFile = new ZipFile(toSeekableByteChannel(output))) {
+            assertThatZip(zipFile)
+                .containsOnlyEntriesMatching(
+                    hasName(MAILBOX_1.getName() + "/")
+                        .containsExtraFields(new MailboxIdExtraField(MAILBOX_1.getMailboxId().serialize())));
+        }
+    }
+
     private SeekableInMemoryByteChannel toSeekableByteChannel(ByteArrayOutputStream output)
{
         return new SeekableInMemoryByteChannel(output.toByteArray());
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message