Browse code

Fix: ignore replication command on deleted user

Thomas Fricker authored on 02/05/2019 09:55:46
Showing 2 changed files
... ...
@@ -26,9 +26,12 @@ import java.sql.SQLException;
26 26
 
27 27
 import javax.sql.DataSource;
28 28
 
29
+import org.slf4j.LoggerFactory;
30
+
29 31
 import net.bluemind.backend.mail.replica.api.MailReplicaContainerTypes;
30 32
 import net.bluemind.backend.mail.replica.api.MailboxRecord;
31 33
 import net.bluemind.backend.mail.replica.persistence.MailboxRecordStore;
34
+import net.bluemind.backend.mail.replica.service.internal.NoopMailboxRecordService;
32 35
 import net.bluemind.backend.mail.replica.service.internal.RecordsItemFlagProvider;
33 36
 import net.bluemind.core.api.fault.ServerFault;
34 37
 import net.bluemind.core.container.model.Container;
... ...
@@ -64,7 +67,8 @@ public abstract class AbstractMailboxRecordServiceFactory<T>
64 67
 			ContainerStore cs = new ContainerStore(context, ds, context.getSecurityContext());
65 68
 			Container recordsContainer = cs.get(uid);
66 69
 			if (recordsContainer == null) {
67
-				throw ServerFault.notFound("Missing container " + uid);
70
+				LoggerFactory.getLogger(this.getClass()).warn("Missing container " + uid);
71
+				return (T) new NoopMailboxRecordService();
68 72
 			}
69 73
 			MailboxRecordStore recordStore = new MailboxRecordStore(ds, recordsContainer);
70 74
 			ContainerStoreService<MailboxRecord> storeService = new ContainerStoreService<>(ds,
71 75
new file mode 100644
... ...
@@ -0,0 +1,162 @@
1
+/* BEGIN LICENSE
2
+ * Copyright © Blue Mind SAS, 2012-2018
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
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
+ *
16
+ * See LICENSE.txt
17
+ * END LICENSE
18
+ */
19
+package net.bluemind.backend.mail.replica.service.internal;
20
+
21
+import java.util.List;
22
+
23
+import org.slf4j.Logger;
24
+import org.slf4j.LoggerFactory;
25
+
26
+import net.bluemind.backend.mail.replica.api.IDbMailboxRecords;
27
+import net.bluemind.backend.mail.replica.api.ImapBinding;
28
+import net.bluemind.backend.mail.replica.api.MailboxRecord;
29
+import net.bluemind.core.api.Stream;
30
+import net.bluemind.core.api.fault.ServerFault;
31
+import net.bluemind.core.container.model.ContainerChangelog;
32
+import net.bluemind.core.container.model.ContainerChangeset;
33
+import net.bluemind.core.container.model.ItemChangelog;
34
+import net.bluemind.core.container.model.ItemFlagFilter;
35
+import net.bluemind.core.container.model.ItemValue;
36
+import net.bluemind.core.container.model.ItemVersion;
37
+
38
+public class NoopMailboxRecordService implements IDbMailboxRecords {
39
+
40
+	private static final Logger logger = LoggerFactory.getLogger(NoopMailboxRecordService.class);
41
+
42
+	@Override
43
+	public ItemChangelog itemChangelog(String itemUid, Long since) throws ServerFault {
44
+		logger.info("NOOP operation IDbMailboxRecords#itemChangelog");
45
+		return null;
46
+	}
47
+
48
+	@Override
49
+	public ContainerChangelog containerChangelog(Long since) throws ServerFault {
50
+		logger.info("NOOP operation IDbMailboxRecords#containerChangelog");
51
+		return null;
52
+	}
53
+
54
+	@Override
55
+	public ContainerChangeset<String> changeset(Long since) throws ServerFault {
56
+		logger.info("NOOP operation IDbMailboxRecords#changeset");
57
+		return null;
58
+	}
59
+
60
+	@Override
61
+	public ContainerChangeset<Long> changesetById(Long since) throws ServerFault {
62
+		logger.info("NOOP operation IDbMailboxRecords#changesetById");
63
+		return null;
64
+	}
65
+
66
+	@Override
67
+	public ContainerChangeset<ItemVersion> filteredChangesetById(Long since, ItemFlagFilter filter) throws ServerFault {
68
+		logger.info("NOOP operation IDbMailboxRecords#filteredChangesetById");
69
+		return null;
70
+	}
71
+
72
+	@Override
73
+	public long getVersion() throws ServerFault {
74
+		logger.info("NOOP operation IDbMailboxRecords#getVersion");
75
+		return 0;
76
+	}
77
+
78
+	@Override
79
+	public void xfer(String serverUid) throws ServerFault {
80
+		logger.info("NOOP operation IDbMailboxRecords#xfer");
81
+
82
+	}
83
+
84
+	@Override
85
+	public ItemValue<MailboxRecord> getComplete(String uid) {
86
+		logger.info("NOOP operation IDbMailboxRecords#getComplete");
87
+		return null;
88
+	}
89
+
90
+	@Override
91
+	public ItemValue<MailboxRecord> getCompleteById(long id) {
92
+		logger.info("NOOP operation IDbMailboxRecords#getCompleteById");
93
+		return null;
94
+	}
95
+
96
+	@Override
97
+	public List<ImapBinding> imapBindings(List<Long> ids) {
98
+		logger.info("NOOP operation IDbMailboxRecords#containerChangelog");
99
+		return null;
100
+	}
101
+
102
+	@Override
103
+	public List<ItemValue<MailboxRecord>> all() {
104
+		logger.info("NOOP operation IDbMailboxRecords#containerChangelog");
105
+		return null;
106
+	}
107
+
108
+	@Override
109
+	public void create(String uid, MailboxRecord mail) {
110
+		logger.info("NOOP operation IDbMailboxRecords#create");
111
+
112
+	}
113
+
114
+	@Override
115
+	public void update(String uid, MailboxRecord mail) {
116
+		logger.info("NOOP operation IDbMailboxRecords#update");
117
+
118
+	}
119
+
120
+	@Override
121
+	public void delete(String uid) {
122
+		logger.info("NOOP operation IDbMailboxRecords#containerChangelog");
123
+
124
+	}
125
+
126
+	@Override
127
+	public void updates(List<MailboxRecord> records) {
128
+		logger.info("NOOP operation IDbMailboxRecords#updates");
129
+
130
+	}
131
+
132
+	@Override
133
+	public void deleteImapUids(List<Long> uids) {
134
+		logger.info("NOOP operation IDbMailboxRecords#deleteImapUids");
135
+
136
+	}
137
+
138
+	@Override
139
+	public void deleteAll() {
140
+		logger.info("NOOP operation IDbMailboxRecords#deleteAll");
141
+
142
+	}
143
+
144
+	@Override
145
+	public void prepareContainerDelete() {
146
+		logger.info("NOOP operation IDbMailboxRecords#prepareContainerDelete");
147
+
148
+	}
149
+
150
+	@Override
151
+	public Stream fetchComplete(long imapUid) {
152
+		logger.info("NOOP operation IDbMailboxRecords#fetchComplete");
153
+		return null;
154
+	}
155
+
156
+	@Override
157
+	public List<ImapBinding> havingBodyVersionLowerThan(int version) {
158
+		logger.info("NOOP operation IDbMailboxRecords#havingBodyVersionLowerThan");
159
+		return null;
160
+	}
161
+
162
+}