Browse code

[eas] BM-14988 Fix: FolderSync on container deleted AND subscription removed

David Phan authored on 26/06/2019 07:35:03
Showing 1 changed files
... ...
@@ -28,6 +28,8 @@ import net.bluemind.backend.mail.api.IMailboxFolders;
28 28
 import net.bluemind.backend.mail.api.MailboxFolder;
29 29
 import net.bluemind.backend.mail.replica.api.IMailReplicaUids;
30 30
 import net.bluemind.calendar.api.ICalendarUids;
31
+import net.bluemind.core.api.fault.ErrorCode;
32
+import net.bluemind.core.api.fault.ServerFault;
31 33
 import net.bluemind.core.container.api.ContainerHierarchyNode;
32 34
 import net.bluemind.core.container.api.ContainerSubscriptionModel;
33 35
 import net.bluemind.core.container.api.IContainers;
... ...
@@ -255,15 +257,25 @@ public class FolderBackend extends CoreConnect {
255 257
 			IContainers containers = getService(bs, IContainers.class);
256 258
 			allSubs.deleted.forEach(uid -> {
257 259
 				String containerUid = uid.replace(String.format("sub-of-%s-to-", bs.getUser().getUid()), "");
258
-				ContainerDescriptor cd = containers.get(containerUid);
259
-				String nodeUid = ContainerHierarchyNode.uidFor(containerUid, cd.type, bs.getUser().getDomain());
260
-				ItemValue<ContainerHierarchyNode> h = flatH.getComplete(nodeUid);
261
-				if (h != null) {
262
-					FolderChangeReference f = getDeletedItemChange(h.internalId);
263
-					ret.items.add(f);
264
-				} else {
265
-					logger.warn("[{}] delete subscription: no node uid {} for container {} in hierarchy",
266
-							bs.getUser().getDefaultEmail(), nodeUid, cd);
260
+				try {
261
+					ContainerDescriptor cd = containers.get(containerUid);
262
+					String nodeUid = ContainerHierarchyNode.uidFor(containerUid, cd.type, bs.getUser().getDomain());
263
+					ItemValue<ContainerHierarchyNode> h = flatH.getComplete(nodeUid);
264
+					if (h != null) {
265
+						FolderChangeReference f = getDeletedItemChange(h.internalId);
266
+						ret.items.add(f);
267
+					} else {
268
+						logger.warn("[{}] delete subscription: no node uid {} for container {} in hierarchy",
269
+								bs.getUser().getDefaultEmail(), nodeUid, cd);
270
+					}
271
+				} catch (ServerFault sf) {
272
+					if (sf.getCode() == ErrorCode.NOT_FOUND) {
273
+						logger.warn("[{}] delete subscription: container {} not found", bs.getUser().getDefaultEmail(),
274
+								containerUid);
275
+					} else {
276
+						throw sf;
277
+					}
278
+
267 279
 				}
268 280
 			});
269 281
 		}