Browse code

BM-14614 Fix: c&r flat hierarchy, list user hierarchy

David Phan authored on 11/04/2019 12:23:54
Showing 1 changed files
... ...
@@ -42,7 +42,9 @@ import net.bluemind.core.container.api.internal.IInternalContainersFlatHierarchy
42 42
 import net.bluemind.core.container.model.BaseContainerDescriptor;
43 43
 import net.bluemind.core.container.model.ItemValue;
44 44
 import net.bluemind.core.container.persistance.DataSourceRouter;
45
+import net.bluemind.core.context.SecurityContext;
45 46
 import net.bluemind.core.rest.BmContext;
47
+import net.bluemind.core.rest.ServerSideServiceProvider;
46 48
 import net.bluemind.core.task.service.IServerTaskMonitor;
47 49
 import net.bluemind.directory.api.BaseDirEntry.Kind;
48 50
 import net.bluemind.directory.api.DirEntry;
... ...
@@ -98,13 +100,19 @@ public class FlatHierarchyRepair implements IDirEntryRepairSupport {
98 100
 			IContainers contApi = context.provider().instance(IContainers.class);
99 101
 			List<BaseContainerDescriptor> ownedContainers = contApi
100 102
 					.allLight(ContainerQuery.ownerAndType(entry.entryUid, null)).stream()
101
-					// as we did not clear the directory db, all databases have a copy of the
103
+					// as we did not clear the directory db, all databases have
104
+					// a copy of the
102 105
 					// containers...
103 106
 					.filter(distinctByKey(c -> c.uid)) //
104 107
 					.filter(c -> entry.dataLocation == null
105 108
 							|| entry.dataLocation.equals(DataSourceRouter.location(context, c.uid)))
106 109
 					.collect(Collectors.toList());
107
-			List<ItemValue<ContainerHierarchyNode>> knownNodes = hierApi.list();
110
+
111
+			IInternalContainersFlatHierarchy adminHierApi = ServerSideServiceProvider
112
+					.getProvider(SecurityContext.SYSTEM)
113
+					.instance(IInternalContainersFlatHierarchy.class, domainUid, entry.entryUid);
114
+			List<ItemValue<ContainerHierarchyNode>> knownNodes = adminHierApi.list();
115
+
108 116
 			monitor.begin(ownedContainers.size(), "Repairing hierarchy with " + ownedContainers.size() + " containers ("
109 117
 					+ knownNodes.size() + " known nodes)");
110 118
 			Set<String> nodeContUids = knownNodes.stream().map(n -> n.value.containerUid).collect(Collectors.toSet());