opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
@@ -27,6 +27,7 @@ import org.forgerock.opendj.ldap.ByteSequence; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ByteStringBuilder; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.Functions; import org.forgerock.util.Function; import org.forgerock.util.Pair; @@ -39,7 +40,6 @@ import org.opends.server.backends.pluggable.spi.TreeName; import org.opends.server.backends.pluggable.spi.WriteableTransaction; import org.opends.server.types.CanceledOperationException; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.Operation; /** @@ -211,7 +211,7 @@ int nbSeparator = 0; for (int i = parent.length() ; i < child.length(); i++) { if (child.byteAt(i) == DN.NORMALIZED_RDN_SEPARATOR) if (child.byteAt(i) == DnKeyFormat.NORMALIZED_RDN_SEPARATOR) { nbSeparator++; if (nbSeparator > 1) opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DnKeyFormat.java
@@ -27,6 +27,13 @@ /** The format version used by this class to encode and decode a ByteString. */ static final byte FORMAT_VERSION = 0x01; /** RDN separator for normalized byte string of a DN. */ public static final byte NORMALIZED_RDN_SEPARATOR = 0x00; /** AVA separator for normalized byte string of a DN. */ static final byte NORMALIZED_AVA_SEPARATOR = 0x01; /** Escape byte for normalized byte string of a DN. */ static final byte NORMALIZED_ESC_BYTE = 0x02; /** * Find the length of bytes that represents the superior DN of the given DN * key. The superior DN is represented by the initial bytes of the DN key. @@ -70,7 +77,7 @@ final int startSize = dn.size() - prefixRDNs - 1; for (int i = startSize; i >= 0; i--) { builder.appendByte(DN.NORMALIZED_RDN_SEPARATOR); builder.appendByte(NORMALIZED_RDN_SEPARATOR); dn.rdn(i).toNormalizedByteString(builder); } return builder.toByteString(); @@ -89,14 +96,14 @@ private static boolean positionIsRDNSeparator(ByteSequence key, int index) { return index > 0 && key.byteAt(index) == DN.NORMALIZED_RDN_SEPARATOR && key.byteAt(index - 1) != DN.NORMALIZED_ESC_BYTE; && key.byteAt(index) == NORMALIZED_RDN_SEPARATOR && key.byteAt(index - 1) != NORMALIZED_ESC_BYTE; } static ByteStringBuilder beforeFirstChildOf(final ByteSequence key) { final ByteStringBuilder beforeKey = new ByteStringBuilder(key.length() + 1); beforeKey.appendBytes(key); beforeKey.appendByte(DN.NORMALIZED_RDN_SEPARATOR); beforeKey.appendByte(NORMALIZED_RDN_SEPARATOR); return beforeKey; } @@ -104,7 +111,7 @@ { final ByteStringBuilder afterKey = new ByteStringBuilder(key.length() + 1); afterKey.appendBytes(key); afterKey.appendByte(DN.NORMALIZED_AVA_SEPARATOR); afterKey.appendByte(NORMALIZED_AVA_SEPARATOR); return afterKey; } } opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
@@ -29,6 +29,7 @@ import org.forgerock.opendj.ldap.RDN; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.TestCaseUtils; import org.opends.server.backends.pluggable.DnKeyFormat; import org.opends.server.core.DirectoryServer; import org.testng.Assert; import org.testng.annotations.BeforeClass; @@ -350,7 +351,7 @@ DN dn = DN.valueOf("dc=example,dc=com"); assertEquals(dn.toNormalizedByteString(), new ByteStringBuilder().appendUtf8("dc=com").appendByte(DN.NORMALIZED_RDN_SEPARATOR) new ByteStringBuilder().appendUtf8("dc=com").appendByte(DnKeyFormat.NORMALIZED_RDN_SEPARATOR) .appendUtf8("dc=example").toByteString()); assertEquals(dn.toNormalizedUrlSafeString(), "dc=com,dc=example"); }