DN2ID.java revision fb249f25fe98af8c2dcbf498872fd48c2c3ed854
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* This class represents the dn2id index, which has one record
* for each entry. The key is the normalized entry DN and the value
* is the entry ID.
*/
@SuppressWarnings("javadoc")
class DN2ID extends AbstractTree
{
{
{
return null;
}
};
private static final CursorTransformer.ValueTransformer<ByteString, ByteString, EntryID, Exception> TO_ENTRY_ID =
{
{
}
};
/**
* Create a DN2ID instance for in a given entryContainer.
*
* @param treeName The name of the DN tree.
* @param baseDN The base DN of the tree.
* @throws StorageRuntimeException If an error occurs in the storage.
*/
{
super(treeName);
}
/**
* Adds a new record into the DN tree replacing any existing record having the same DN.
*
* @param txn a non null transaction
* @param dn The entry DN, which is the key to the record.
* @param entryID The entry ID, which is the value of the record.
* @throws StorageRuntimeException If an error occurred while attempting to insert the new record.
*/
void put(final WriteableTransaction txn, DN dn, final EntryID entryID) throws StorageRuntimeException
{
}
boolean insert(final WriteableTransaction txn, DN dn, final EntryID entryID) throws StorageRuntimeException
{
{
{
if (oldEntryID != null)
{
// no change
return oldEntryID;
}
// it did not exist before, insert the new value
}
});
}
{
}
{
// TODO JNR do we want to use compacted longs?
return entryID.toByteString();
}
/**
* Remove a record from the DN tree.
* @param txn a non null transaction
* @param dn The entry DN, which is the key to the record.
* @return true if the record was removed, false if it was not removed.
* @throws StorageRuntimeException If an error occurred while attempting to remove
* the record.
*/
{
}
/**
* Fetch the entry ID for a given DN.
* @param txn a non null transaction
* @param dn The DN for which the entry ID is desired.
* @return The entry ID, or null if the given DN is not in the DN tree.
* @throws StorageRuntimeException If an error occurs in the storage.
*/
{
}
{
}
return cursor;
}
{
}
}
/**
* Check if two DN have a parent-child relationship.
*
* @param parent
* The potential parent
* @param child
* The potential child of parent
* @return true if child is a direct children of parent, false otherwise.
*/
{
{
return false;
}
// Immediate children should only have one RDN separator past the parent length
{
{
return false;
}
}
return true;
}
/**
* Decorator overriding the next() behavior to iterate through children of the entry pointed by the given cursor at
* creation.
*/
private static final class ChildrenCursor extends SequentialCursorForwarding {
private final ByteStringBuilder builder;
private final ByteString limit;
private boolean cursorOnParent;
{
super(delegate);
cursorOnParent = true;
}
public boolean next()
{
if (cursorOnParent) {
// Go to the first children
cursorOnParent = false;
} else {
// Go to the next sibling
}
}
private ByteStringBuilder nextSibling()
{
}
}
/**
* Decorator overriding the next() behavior to iterate through subordinates of the entry pointed by the given cursor
* at creation.
*/
private static final class SubtreeCursor extends SequentialCursorForwarding {
private final ByteString limit;
{
super(delegate);
}
public boolean next()
{
}
}
/**
* Decorator allowing to partially overrides methods of a given cursor while keeping the default behavior for other
* methods.
*/
}
public boolean isDefined()
{
}
public boolean next()
{
}
{
return null;
}
{
}
public void close()
{
}
}
}