Browse code

Revert "BM-15170 Fix: convert cyrus path elements"

This reverts commit cc891f6e66191b5ba372beca0837db39b793794a.

Thomas Fricker authored on 05/09/2019 07:07:19
Showing 5 changed files
1 1
deleted file mode 100644
... ...
@@ -1,79 +0,0 @@
1
-/* BEGIN LICENSE
2
-  * Copyright © Blue Mind SAS, 2012-2019
3
-  *
4
-  * This file is part of BlueMind. BlueMind is a messaging and collaborative
5
-  * solution.
6
-  *
7
-  * This program is free software; you can redistribute it and/or modify
8
-  * it under the terms of either the GNU Affero General Public License as
9
-  * published by the Free Software Foundation (version 3 of the License).
10
-  *
11
-  * This program is distributed in the hope that it will be useful,
12
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
-  *
15
-  * See LICENSE.txt
16
-  * END LICENSE
17
-  */
18
-package net.bluemind.backend.cyrus.partitions.tests;
19
-
20
-import static org.junit.Assert.assertEquals;
21
-
22
-import org.junit.Test;
23
-
24
-import net.bluemind.backend.cyrus.partitions.CyrusFileSystemPathHelper;
25
-import net.bluemind.backend.cyrus.partitions.CyrusPartition;
26
-import net.bluemind.backend.cyrus.partitions.MailboxDescriptor;
27
-import net.bluemind.mailbox.api.Mailbox;
28
-
29
-public class PathHelperTest {
30
-
31
-	@Test
32
-	public void testMailshareSubfolderPath() {
33
-		MailboxDescriptor mboxDescriptor = new MailboxDescriptor();
34
-		mboxDescriptor.mailboxName = "social";
35
-		mboxDescriptor.type = Mailbox.Type.mailshare;
36
-		mboxDescriptor.utf7FolderPath = "social/CommissaireAComptes";
37
-		CyrusPartition partition = CyrusPartition.forServerAndDomain("srv", "bm.lan");
38
-		String path = CyrusFileSystemPathHelper.getFileSystemPath("bm.lan", mboxDescriptor, partition, 42L);
39
-		System.err.println("path: " + path);
40
-		assertEquals("/var/spool/cyrus/data/srv__bm_lan/domain/b/bm.lan/c/social/CommissaireAComptes/42.", path);
41
-	}
42
-
43
-	@Test
44
-	public void testMailshareRootPath() {
45
-		MailboxDescriptor mboxDescriptor = new MailboxDescriptor();
46
-		mboxDescriptor.mailboxName = "social";
47
-		mboxDescriptor.type = Mailbox.Type.mailshare;
48
-		mboxDescriptor.utf7FolderPath = "social";
49
-		CyrusPartition partition = CyrusPartition.forServerAndDomain("srv", "bm.lan");
50
-		String path = CyrusFileSystemPathHelper.getFileSystemPath("bm.lan", mboxDescriptor, partition, 42L);
51
-		System.err.println("path: " + path);
52
-		assertEquals("/var/spool/cyrus/data/srv__bm_lan/domain/b/bm.lan/s/social/42.", path);
53
-	}
54
-
55
-	@Test
56
-	public void testUserINBOX() {
57
-		MailboxDescriptor mboxDescriptor = new MailboxDescriptor();
58
-		mboxDescriptor.mailboxName = "roberto";
59
-		mboxDescriptor.type = Mailbox.Type.user;
60
-		mboxDescriptor.utf7FolderPath = "INBOX";
61
-		CyrusPartition partition = CyrusPartition.forServerAndDomain("srv", "bm.lan");
62
-		String path = CyrusFileSystemPathHelper.getFileSystemPath("bm.lan", mboxDescriptor, partition, 42L);
63
-		System.err.println("path: " + path);
64
-		assertEquals("/var/spool/cyrus/data/srv__bm_lan/domain/b/bm.lan/r/user/roberto/42.", path);
65
-	}
66
-
67
-	@Test
68
-	public void testUserSub() {
69
-		MailboxDescriptor mboxDescriptor = new MailboxDescriptor();
70
-		mboxDescriptor.mailboxName = "roberto";
71
-		mboxDescriptor.type = Mailbox.Type.user;
72
-		mboxDescriptor.utf7FolderPath = "social/call";
73
-		CyrusPartition partition = CyrusPartition.forServerAndDomain("srv", "bm.lan");
74
-		String path = CyrusFileSystemPathHelper.getFileSystemPath("bm.lan", mboxDescriptor, partition, 42L);
75
-		System.err.println("path: " + path);
76
-		assertEquals("/var/spool/cyrus/data/srv__bm_lan/domain/b/bm.lan/r/user/roberto/social/call/42.", path);
77
-	}
78
-
79
-}
80 0
new file mode 100644
... ...
@@ -0,0 +1,79 @@
1
+/* BEGIN LICENSE
2
+  * Copyright © Blue Mind SAS, 2012-2019
3
+  *
4
+  * This file is part of BlueMind. BlueMind is a messaging and collaborative
5
+  * solution.
6
+  *
7
+  * This program is free software; you can redistribute it and/or modify
8
+  * it under the terms of either the GNU Affero General Public License as
9
+  * published by the Free Software Foundation (version 3 of the License).
10
+  *
11
+  * This program is distributed in the hope that it will be useful,
12
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
+  *
15
+  * See LICENSE.txt
16
+  * END LICENSE
17
+  */
18
+package net.bluemind.backend.cyrus.partitions.tests;
19
+
20
+import static org.junit.Assert.assertEquals;
21
+
22
+import org.junit.Test;
23
+
24
+import net.bluemind.backend.cyrus.partitions.CyrusFileSystemPathHelper;
25
+import net.bluemind.backend.cyrus.partitions.CyrusPartition;
26
+import net.bluemind.backend.cyrus.partitions.MailboxDescriptor;
27
+import net.bluemind.mailbox.api.Mailbox;
28
+
29
+public class PathHelperTests {
30
+
31
+	@Test
32
+	public void testMailshareSubfolderPath() {
33
+		MailboxDescriptor mboxDescriptor = new MailboxDescriptor();
34
+		mboxDescriptor.mailboxName = "social";
35
+		mboxDescriptor.type = Mailbox.Type.mailshare;
36
+		mboxDescriptor.utf7FolderPath = "social/CommissaireAComptes";
37
+		CyrusPartition partition = CyrusPartition.forServerAndDomain("srv", "bm.lan");
38
+		String path = CyrusFileSystemPathHelper.getFileSystemPath("bm.lan", mboxDescriptor, partition, 42L);
39
+		System.err.println("path: " + path);
40
+		assertEquals("/var/spool/cyrus/data/srv__bm_lan/domain/b/bm.lan/c/social/CommissaireAComptes/42.", path);
41
+	}
42
+
43
+	@Test
44
+	public void testMailshareRootPath() {
45
+		MailboxDescriptor mboxDescriptor = new MailboxDescriptor();
46
+		mboxDescriptor.mailboxName = "social";
47
+		mboxDescriptor.type = Mailbox.Type.mailshare;
48
+		mboxDescriptor.utf7FolderPath = "social";
49
+		CyrusPartition partition = CyrusPartition.forServerAndDomain("srv", "bm.lan");
50
+		String path = CyrusFileSystemPathHelper.getFileSystemPath("bm.lan", mboxDescriptor, partition, 42L);
51
+		System.err.println("path: " + path);
52
+		assertEquals("/var/spool/cyrus/data/srv__bm_lan/domain/b/bm.lan/s/social/42.", path);
53
+	}
54
+
55
+	@Test
56
+	public void testUserINBOX() {
57
+		MailboxDescriptor mboxDescriptor = new MailboxDescriptor();
58
+		mboxDescriptor.mailboxName = "roberto";
59
+		mboxDescriptor.type = Mailbox.Type.user;
60
+		mboxDescriptor.utf7FolderPath = "INBOX";
61
+		CyrusPartition partition = CyrusPartition.forServerAndDomain("srv", "bm.lan");
62
+		String path = CyrusFileSystemPathHelper.getFileSystemPath("bm.lan", mboxDescriptor, partition, 42L);
63
+		System.err.println("path: " + path);
64
+		assertEquals("/var/spool/cyrus/data/srv__bm_lan/domain/b/bm.lan/r/user/roberto/42.", path);
65
+	}
66
+
67
+	@Test
68
+	public void testUserSub() {
69
+		MailboxDescriptor mboxDescriptor = new MailboxDescriptor();
70
+		mboxDescriptor.mailboxName = "roberto";
71
+		mboxDescriptor.type = Mailbox.Type.user;
72
+		mboxDescriptor.utf7FolderPath = "social/call";
73
+		CyrusPartition partition = CyrusPartition.forServerAndDomain("srv", "bm.lan");
74
+		String path = CyrusFileSystemPathHelper.getFileSystemPath("bm.lan", mboxDescriptor, partition, 42L);
75
+		System.err.println("path: " + path);
76
+		assertEquals("/var/spool/cyrus/data/srv__bm_lan/domain/b/bm.lan/r/user/roberto/social/call/42.", path);
77
+	}
78
+
79
+}
... ...
@@ -98,9 +98,9 @@ public class CyrusBoxes {
98 98
 			String login = deletedMailboxMatch.group(2);
99 99
 			logger.debug("Extracted p: {}, l: {}", domain, login);
100 100
 			ReplicatedBox rb = new ReplicatedBox();
101
-			rb.local = sanitizeCyrusPath(login);
101
+			rb.local = login;
102 102
 			rb.partition = domain.replace('.', '_');
103
-			rb.folderName = sanitizeCyrusPath(deletedMailboxMatch.group(3));
103
+			rb.folderName = deletedMailboxMatch.group(3).replace('.', '/').replace('^', '.');
104 104
 			rb.ns = Namespace.deleted;
105 105
 			return rb;
106 106
 		} else if (deletedSharedMailboxMatch.find()) {
... ...
@@ -108,9 +108,9 @@ public class CyrusBoxes {
108 108
 			String login = deletedSharedMailboxMatch.group(2);
109 109
 			logger.debug("Extracted p: {}, l: {}", domain, login);
110 110
 			ReplicatedBox rb = new ReplicatedBox();
111
-			rb.local = sanitizeCyrusPath(login);
111
+			rb.local = login;
112 112
 			rb.partition = domain.replace('.', '_');
113
-			rb.folderName = sanitizeCyrusPath(deletedSharedMailboxMatch.group(3));
113
+			rb.folderName = deletedSharedMailboxMatch.group(3).replace('.', '/').replace('^', '.');
114 114
 			rb.ns = Namespace.deletedShared;
115 115
 			return rb;
116 116
 		} else if (userMatch.find()) {
... ...
@@ -118,9 +118,9 @@ public class CyrusBoxes {
118 118
 			String login = userMatch.group(2);
119 119
 			logger.debug("Extracted p: {}, l: {}", domain, login);
120 120
 			ReplicatedBox rb = new ReplicatedBox();
121
-			rb.local = sanitizeCyrusPath(login);
121
+			rb.local = login;
122 122
 			rb.partition = domain.replace('.', '_');
123
-			rb.folderName = sanitizeCyrusPath(userMatch.group(3));
123
+			rb.folderName = userMatch.group(3).replace('.', '/').replace('^', '.');
124 124
 			rb.ns = Namespace.users;
125 125
 			return rb;
126 126
 		} else if (userRootMatch.find()) {
... ...
@@ -129,7 +129,7 @@ public class CyrusBoxes {
129 129
 			String login = userRootMatch.group(2);
130 130
 			logger.debug("Extracted p: {}, l: {}", domain, login);
131 131
 			ReplicatedBox rb = new ReplicatedBox();
132
-			rb.local = sanitizeCyrusPath(login);
132
+			rb.local = login;
133 133
 			rb.partition = domain.replace('.', '_');
134 134
 			rb.folderName = "INBOX";
135 135
 			rb.ns = Namespace.users;
... ...
@@ -144,7 +144,7 @@ public class CyrusBoxes {
144 144
 			int dot = afterPart.indexOf('.');
145 145
 			if (dot > 0) {
146 146
 				rb.local = afterPart.substring(0, dot);
147
-				rb.folderName = sanitizeCyrusPath(afterPart.substring(dot + 1));
147
+				rb.folderName = afterPart.substring(dot + 1).replace('.', '/').replace('^', '.');
148 148
 			} else {
149 149
 				rb.local = afterPart;
150 150
 				rb.folderName = afterPart;
... ...
@@ -154,8 +154,4 @@ public class CyrusBoxes {
154 154
 		}
155 155
 	}
156 156
 
157
-	private static String sanitizeCyrusPath(String element) {
158
-		return element.replace('.', '/').replace('^', '.');
159
-	}
160
-
161 157
 }
162 158
deleted file mode 100644
... ...
@@ -1,91 +0,0 @@
1
-/* BEGIN LICENSE
2
-  * Copyright © Blue Mind SAS, 2012-2017
3
-  *
4
-  * This file is part of BlueMind. BlueMind is a messaging and collaborative
5
-  * solution.
6
-  *
7
-  * This program is free software; you can redistribute it and/or modify
8
-  * it under the terms of either the GNU Affero General Public License as
9
-  * published by the Free Software Foundation (version 3 of the License).
10
-  *
11
-  * This program is distributed in the hope that it will be useful,
12
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
-  *
15
-  * See LICENSE.txt
16
-  * END LICENSE
17
-  */
18
-package net.bluemind.backend.cyrus.replication.server.tests;
19
-
20
-import static org.junit.Assert.assertEquals;
21
-import static org.junit.Assert.assertNotNull;
22
-import static org.junit.Assert.assertNull;
23
-
24
-import org.junit.Test;
25
-
26
-import net.bluemind.backend.cyrus.partitions.CyrusBoxes.ReplicatedBox;
27
-import net.bluemind.backend.cyrus.replication.server.utils.ReplicatedBoxes;
28
-
29
-public class ReplicatedBoxesTest {
30
-
31
-	@Test
32
-	public void testQuotedMboxName() {
33
-		String box = "\"ex2016.vmw!user.tom.Deleted Messages\"";
34
-		ReplicatedBox rBox = ReplicatedBoxes.forCyrusMailbox(box);
35
-		assertNotNull(rBox);
36
-		assertEquals("ex2016_vmw", rBox.partition);
37
-		assertEquals("tom", rBox.local);
38
-	}
39
-
40
-	@Test
41
-	public void testFromLogin() {
42
-		String box = "tom@ex2016.vmw";
43
-		ReplicatedBox rBox = ReplicatedBoxes.forLoginAtDomain(box);
44
-		assertNotNull(rBox);
45
-		assertEquals("ex2016_vmw", rBox.partition);
46
-	}
47
-
48
-	@Test
49
-	public void testUnqualified() {
50
-		ReplicatedBox rBox = ReplicatedBoxes.forLoginAtDomain("admin");
51
-		assertNull(rBox);
52
-	}
53
-
54
-	@Test
55
-	public void testDeletedMbox() {
56
-		String box = "bm.lan!DELETED.user.david.yeahyeah.5C614D43";
57
-		ReplicatedBox rBox = ReplicatedBoxes.forCyrusMailbox(box);
58
-		assertEquals("david", rBox.local);
59
-		assertEquals("bm_lan", rBox.partition);
60
-		assertEquals("yeahyeah/5C614D43", rBox.folderName);
61
-	}
62
-
63
-	@Test
64
-	public void testSharedDeletedMbox() {
65
-		String box = "bm.lan!DELETED.mailshare.yeahyeah.5C614D43";
66
-		ReplicatedBox rBox = ReplicatedBoxes.forCyrusMailbox(box);
67
-		assertEquals("mailshare", rBox.local);
68
-		assertEquals("bm_lan", rBox.partition);
69
-		assertEquals("yeahyeah/5C614D43", rBox.folderName);
70
-	}
71
-
72
-	@Test
73
-	public void testEscapingCyrusPAths() {
74
-		String box = "\"ex2016.vmw!user.t^om.Deleted Messages\"";
75
-		ReplicatedBox rBox = ReplicatedBoxes.forCyrusMailbox(box);
76
-		assertNotNull(rBox);
77
-		assertEquals("t.om", rBox.local);
78
-
79
-		box = "bm.lan!DELETED.user.da^vid.yeah^yeah.5C614D43";
80
-		rBox = ReplicatedBoxes.forCyrusMailbox(box);
81
-		assertEquals("da.vid", rBox.local);
82
-		assertEquals("bm_lan", rBox.partition);
83
-		assertEquals("yeah.yeah/5C614D43", rBox.folderName);
84
-
85
-		box = "bm.lan!DELETED.mail^share.yeah^yeah.5C614D43";
86
-		rBox = ReplicatedBoxes.forCyrusMailbox(box);
87
-		assertEquals("mail.share", rBox.local);
88
-		assertEquals("yeah.yeah/5C614D43", rBox.folderName);
89
-	}
90
-
91
-}
92 0
new file mode 100644
... ...
@@ -0,0 +1,73 @@
1
+/* BEGIN LICENSE
2
+  * Copyright © Blue Mind SAS, 2012-2017
3
+  *
4
+  * This file is part of BlueMind. BlueMind is a messaging and collaborative
5
+  * solution.
6
+  *
7
+  * This program is free software; you can redistribute it and/or modify
8
+  * it under the terms of either the GNU Affero General Public License as
9
+  * published by the Free Software Foundation (version 3 of the License).
10
+  *
11
+  * This program is distributed in the hope that it will be useful,
12
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
+  *
15
+  * See LICENSE.txt
16
+  * END LICENSE
17
+  */
18
+package net.bluemind.backend.cyrus.replication.server.tests;
19
+
20
+import static org.junit.Assert.assertEquals;
21
+import static org.junit.Assert.assertNotNull;
22
+import static org.junit.Assert.assertNull;
23
+
24
+import org.junit.Test;
25
+
26
+import net.bluemind.backend.cyrus.partitions.CyrusBoxes.ReplicatedBox;
27
+import net.bluemind.backend.cyrus.replication.server.utils.ReplicatedBoxes;
28
+
29
+public class ReplicatedBoxesTests {
30
+
31
+	@Test
32
+	public void testQuotedMboxName() {
33
+		String box = "\"ex2016.vmw!user.tom.Deleted Messages\"";
34
+		ReplicatedBox rBox = ReplicatedBoxes.forCyrusMailbox(box);
35
+		assertNotNull(rBox);
36
+		System.out.println("partition: '" + rBox.partition + "'");
37
+		assertEquals("ex2016_vmw", rBox.partition);
38
+		assertEquals("tom", rBox.local);
39
+	}
40
+
41
+	@Test
42
+	public void testFromLogin() {
43
+		String box = "tom@ex2016.vmw";
44
+		ReplicatedBox rBox = ReplicatedBoxes.forLoginAtDomain(box);
45
+		assertNotNull(rBox);
46
+		assertEquals("ex2016_vmw", rBox.partition);
47
+	}
48
+
49
+	@Test
50
+	public void testUnqualified() {
51
+		ReplicatedBox rBox = ReplicatedBoxes.forLoginAtDomain("admin");
52
+		assertNull(rBox);
53
+	}
54
+
55
+	@Test
56
+	public void testDeletedMbox() {
57
+		String box = "bm.lan!DELETED.user.david.yeahyeah.5C614D43";
58
+		ReplicatedBox rBox = ReplicatedBoxes.forCyrusMailbox(box);
59
+		assertEquals("david", rBox.local);
60
+		assertEquals("bm_lan", rBox.partition);
61
+		assertEquals("yeahyeah/5C614D43", rBox.folderName);
62
+	}
63
+
64
+	@Test
65
+	public void testSharedDeletedMbox() {
66
+		String box = "bm.lan!DELETED.mailshare.yeahyeah.5C614D43";
67
+		ReplicatedBox rBox = ReplicatedBoxes.forCyrusMailbox(box);
68
+		assertEquals("mailshare", rBox.local);
69
+		assertEquals("bm_lan", rBox.partition);
70
+		assertEquals("yeahyeah/5C614D43", rBox.folderName);
71
+	}
72
+
73
+}