Browse code

Fix: finish removing normalizedUid from serialized directory

Nicolas Lascombes authored on 10/10/2018 15:32:29
Showing 3 changed files
... ...
@@ -29,7 +29,7 @@ import java.util.function.Predicate;
29 29
 import java.util.stream.Collectors;
30 30
 import java.util.stream.Stream;
31 31
 import java.util.stream.StreamSupport;
32
-import net.bluemind.serialization.client.HollowContext;
32
+
33 33
 import org.slf4j.Logger;
34 34
 import org.slf4j.LoggerFactory;
35 35
 
... ...
@@ -37,12 +37,14 @@ import com.netflix.hollow.api.consumer.HollowConsumer;
37 37
 import com.netflix.hollow.core.index.HollowPrefixIndex;
38 38
 import com.netflix.hollow.core.read.iterator.HollowOrdinalIterator;
39 39
 
40
+import net.bluemind.serialization.client.HollowContext;
41
+
40 42
 public class DirectoryDeserializer implements SerializedDirectorySearch {
41 43
 
42 44
 	private static final Logger logger = LoggerFactory.getLogger(DirectoryDeserializer.class);
43 45
 	private static final String BASE_DATA_DIR = "/var/spool/bm-hollowed/directory";
44 46
 	protected AddressBookRecordPrimaryKeyIndex uidIndex;
45
-	protected AddressBookRecordPrimaryKeyIndex normalizedUidIndex;
47
+	protected AddressBookRecordPrimaryKeyIndex distinguishedNameIndex;
46 48
 	protected AddressBookRecordPrimaryKeyIndex minimalIndex;
47 49
 	protected OfflineDirectoryAPIHashIndex kindIndex;
48 50
 	protected HollowConsumer consumer;
... ...
@@ -64,7 +66,7 @@ public class DirectoryDeserializer implements SerializedDirectorySearch {
64 64
 		logger.info("Current version: {}", consumer.getCurrentVersionId());
65 65
 
66 66
 		this.minimalIndex = new AddressBookRecordPrimaryKeyIndex(consumer, "minimalid");
67
-		this.normalizedUidIndex = new AddressBookRecordPrimaryKeyIndex(consumer, "normalizedUid");
67
+		this.distinguishedNameIndex = new AddressBookRecordPrimaryKeyIndex(consumer, "distinguishedName");
68 68
 		this.uidIndex = new AddressBookRecordPrimaryKeyIndex(consumer, "uid");
69 69
 		this.nameIndex = new HollowPrefixIndex(consumer.getStateEngine(), "AddressBookRecord", "name");
70 70
 		this.emailIndex = new HollowPrefixIndex(consumer.getStateEngine(), "AddressBookRecord", "emails.address");
... ...
@@ -87,8 +89,8 @@ public class DirectoryDeserializer implements SerializedDirectorySearch {
87 87
 	}
88 88
 
89 89
 	@Override
90
-	public Optional<AddressBookRecord> byNormalizedUid(String normalizedUid) {
91
-		return Optional.ofNullable(normalizedUidIndex.findMatch(normalizedUid));
90
+	public Optional<AddressBookRecord> byDistinguishedName(String distinguishedName) {
91
+		return Optional.ofNullable(distinguishedNameIndex.findMatch(distinguishedName));
92 92
 	}
93 93
 
94 94
 	@Override
... ...
@@ -27,7 +27,7 @@ public interface SerializedDirectorySearch {
27 27
 
28 28
 	public List<AddressBookRecord> search(List<Predicate<? super AddressBookRecord>> predicates);
29 29
 
30
-	public Optional<AddressBookRecord> byNormalizedUid(String normalizedUid);
30
+	public Optional<AddressBookRecord> byDistinguishedName(String distinguishedName);
31 31
 
32 32
 	public Optional<AddressBookRecord> byUid(String uid);
33 33
 
... ...
@@ -184,14 +184,16 @@ public class ProducerTests {
184 184
 					+ ab.getDistinguishedName().getValue());
185 185
 		});
186 186
 
187
+		String user7dn = "/o=mapi/ou=" + domainUid + "/cn=recipients/cn=user:" + "user7";
188
+
187 189
 		Optional<AddressBookRecord> byUid = search.byUid("uSeR7");
188 190
 		assertTrue(byUid.isPresent());
189
-		assertEquals("user7", byUid.get().getDistinguishedName().getValue());
191
+		assertEquals(user7dn, byUid.get().getDistinguishedName().getValue());
190 192
 		assertEquals("uSeR7", byUid.get().getUid().getValue());
191 193
 
192
-		byUid = search.byNormalizedUid("user7");
194
+		byUid = search.byDistinguishedName(user7dn);
193 195
 		assertTrue(byUid.isPresent());
194
-		assertEquals("user7", byUid.get().getDistinguishedName().getValue());
196
+		assertEquals(user7dn, byUid.get().getDistinguishedName().getValue());
195 197
 		assertEquals("uSeR7", byUid.get().getUid().getValue());
196 198
 	}
197 199