org.apache.ldap.server.partition.impl.btree.jdbm
Class JdbmContextPartition

java.lang.Object
  extended byorg.apache.ldap.server.partition.impl.btree.BTreeContextPartition
      extended byorg.apache.ldap.server.partition.impl.btree.jdbm.JdbmContextPartition
All Implemented Interfaces:
ContextPartition

public class JdbmContextPartition
extends BTreeContextPartition

A ContextPartition that stores entries in JDBM database.

Version:
$Rev: 264732 $
Author:
Apache Directory Project

Field Summary
 
Fields inherited from interface org.apache.ldap.server.partition.ContextPartition
ALIAS_ATTRIBUTE, ALIAS_OBJECT
 
Constructor Summary
JdbmContextPartition()
          Creates a store based on JDBM B+Trees.
 
Method Summary
 void add(java.lang.String updn, javax.naming.Name dn, javax.naming.directory.Attributes entry)
          Adds an entry to this ContextPartition.
 void addIndexOn(org.apache.ldap.common.schema.AttributeType spec)
           
 int count()
          Gets the count of the total number of entries in the database.
 void delete(java.math.BigInteger id)
           
 void destroy()
          Deinitialized this partition.
 Index getAliasIndex()
          Gets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would be the aliasedObjectName and for X.500 would be aliasedEntryName.
 int getChildCount(java.math.BigInteger id)
           
 java.lang.String getEntryDn(java.math.BigInteger id)
           
 java.math.BigInteger getEntryId(java.lang.String dn)
           
 java.lang.String getEntryUpdn(java.math.BigInteger id)
          Gets the user provided distinguished name.
 java.lang.String getEntryUpdn(java.lang.String dn)
          Gets the user provided distinguished name.
 Index getExistanceIndex()
           
 Index getHierarchyIndex()
          Gets the Index mapping the BigInteger primary keys of parents to the BigInteger primary keys of their children.
 javax.naming.directory.Attributes getIndices(java.math.BigInteger id)
           
 Index getNdnIndex()
          Gets the Index mapping the normalized distinguished names of entries as Strings to the BigInteger primary keys of entries.
 Index getOneAliasIndex()
          Gets the alias index mapping parent entries with scope expanding aliases children one level below them; this system index is used to dereference aliases on one/single level scoped searches.
 java.math.BigInteger getParentId(java.math.BigInteger childId)
           
 java.math.BigInteger getParentId(java.lang.String dn)
           
 java.lang.String getProperty(java.lang.String propertyName)
           
 Index getSubAliasIndex()
          Gets the alias index mapping relative entries with scope expanding alias descendents; this system index is used to dereference aliases on subtree scoped searches.
 javax.naming.Name getSuffix(boolean normalized)
          Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.
 javax.naming.directory.Attributes getSuffixEntry()
           
 Index getSystemIndex(java.lang.String indexName)
           
 java.util.Iterator getSystemIndices()
           
 Index getUpdnIndex()
          Gets the Index mapping user provided distinguished names of entries as Strings to the BigInteger primary keys of entries.
 Index getUserIndex(java.lang.String attribute)
           
 java.util.Iterator getUserIndices()
           
 boolean hasSystemIndexOn(java.lang.String attribute)
           
 boolean hasUserIndexOn(java.lang.String attribute)
           
 void init(ContextFactoryConfiguration factoryCfg, ContextPartitionConfiguration cfg)
          Initializes this partition.
 boolean isInitialized()
          Checks to see if this partition is initialized or not.
 javax.naming.NamingEnumeration list(java.math.BigInteger id)
           
 javax.naming.directory.Attributes lookup(java.math.BigInteger id)
           
 void modify(javax.naming.Name dn, int modOp, javax.naming.directory.Attributes mods)
          Modifies an entry by adding, removing or replacing a set of attributes.
 void modify(javax.naming.Name dn, javax.naming.directory.ModificationItem[] mods)
          Modifies an entry by using a combination of adds, removes or replace operations using a set of ModificationItems.
 void modifyRn(javax.naming.Name dn, java.lang.String newRdn, boolean deleteOldRdn)
          Changes the relative distinuished name of an entry specified by a distinguished name with the optional removal of the old Rdn attribute value from the entry.
 void move(javax.naming.Name oldChildDn, javax.naming.Name newParentDn)
          Moves an entry under a new parent.
 void move(javax.naming.Name oldChildDn, javax.naming.Name newParentDn, java.lang.String newRdn, boolean deleteOldRdn)
          Transplants a child entry, to a position in the namespace under a new parent entry and changes the RN of the child entry which can optionally have its old RN attributes removed.
 void setAliasIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
          Sets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would be the aliasedObjectName and for X.500 would be aliasedEntryName.
 void setExistanceIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
          Sets the attribute existance Index.
 void setHierarchyIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
          Sets the hierarchy Index.
 void setNdnIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
          Sets the normalized distinguished name Index.
 void setOneAliasIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
          Sets the alias index mapping parent entries with scope expanding aliases children one level below them; this system index is used to dereference aliases on one/single level scoped searches.
 void setProperty(java.lang.String propertyName, java.lang.String propertyValue)
           
 void setSubAliasIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
          Sets the alias index mapping relative entries with scope expanding alias descendents; this system index is used to dereference aliases on subtree scoped searches.
 void setUpdnIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
          Sets the user provided distinguished name Index.
 void sync()
          Flushes any changes made to this partition now.
 
Methods inherited from class org.apache.ldap.server.partition.impl.btree.BTreeContextPartition
delete, getSearchEngine, hasEntry, inspect, isSuffix, list, lookup, lookup, search
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbmContextPartition

public JdbmContextPartition()
Creates a store based on JDBM B+Trees.

Method Detail

init

public void init(ContextFactoryConfiguration factoryCfg,
                 ContextPartitionConfiguration cfg)
          throws javax.naming.NamingException
Description copied from interface: ContextPartition
Initializes this partition.

Specified by:
init in interface ContextPartition
Overrides:
init in class BTreeContextPartition
Throws:
javax.naming.NamingException

destroy

public void destroy()
Description copied from interface: ContextPartition
Deinitialized this partition.

Specified by:
destroy in interface ContextPartition
Specified by:
destroy in class BTreeContextPartition

isInitialized

public boolean isInitialized()
Description copied from interface: ContextPartition
Checks to see if this partition is initialized or not.

Specified by:
isInitialized in interface ContextPartition
Specified by:
isInitialized in class BTreeContextPartition

sync

public void sync()
          throws javax.naming.NamingException
Description copied from interface: ContextPartition
Flushes any changes made to this partition now.

Specified by:
sync in interface ContextPartition
Specified by:
sync in class BTreeContextPartition
Throws:
javax.naming.NamingException

addIndexOn

public void addIndexOn(org.apache.ldap.common.schema.AttributeType spec)
                throws javax.naming.NamingException
Specified by:
addIndexOn in class BTreeContextPartition
Throws:
javax.naming.NamingException

getExistanceIndex

public Index getExistanceIndex()
Specified by:
getExistanceIndex in class BTreeContextPartition

setExistanceIndexOn

public void setExistanceIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
                         throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Sets the attribute existance Index.

Specified by:
setExistanceIndexOn in class BTreeContextPartition
Parameters:
attrType - the attribute existance Index
Throws:
javax.naming.NamingException

getHierarchyIndex

public Index getHierarchyIndex()
Description copied from class: BTreeContextPartition
Gets the Index mapping the BigInteger primary keys of parents to the BigInteger primary keys of their children.

Specified by:
getHierarchyIndex in class BTreeContextPartition
Returns:
the hierarchy Index

setHierarchyIndexOn

public void setHierarchyIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
                         throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Sets the hierarchy Index.

Specified by:
setHierarchyIndexOn in class BTreeContextPartition
Parameters:
attrType - the hierarchy Index
Throws:
javax.naming.NamingException

getAliasIndex

public Index getAliasIndex()
Description copied from class: BTreeContextPartition
Gets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would be the aliasedObjectName and for X.500 would be aliasedEntryName.

Specified by:
getAliasIndex in class BTreeContextPartition
Returns:
the index on the ALIAS_ATTRIBUTE

setAliasIndexOn

public void setAliasIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
                     throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Sets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would be the aliasedObjectName and for X.500 would be aliasedEntryName.

Specified by:
setAliasIndexOn in class BTreeContextPartition
Parameters:
attrType - the index on the ALIAS_ATTRIBUTE
Throws:
javax.naming.NamingException

getOneAliasIndex

public Index getOneAliasIndex()
Description copied from class: BTreeContextPartition
Gets the alias index mapping parent entries with scope expanding aliases children one level below them; this system index is used to dereference aliases on one/single level scoped searches.

Specified by:
getOneAliasIndex in class BTreeContextPartition
Returns:
the one alias index

setOneAliasIndexOn

public void setOneAliasIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
                        throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Sets the alias index mapping parent entries with scope expanding aliases children one level below them; this system index is used to dereference aliases on one/single level scoped searches.

Specified by:
setOneAliasIndexOn in class BTreeContextPartition
Parameters:
attrType - a one level alias index
Throws:
javax.naming.NamingException

getSubAliasIndex

public Index getSubAliasIndex()
Description copied from class: BTreeContextPartition
Gets the alias index mapping relative entries with scope expanding alias descendents; this system index is used to dereference aliases on subtree scoped searches.

Specified by:
getSubAliasIndex in class BTreeContextPartition
Returns:
the sub alias index

setSubAliasIndexOn

public void setSubAliasIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
                        throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Sets the alias index mapping relative entries with scope expanding alias descendents; this system index is used to dereference aliases on subtree scoped searches.

Specified by:
setSubAliasIndexOn in class BTreeContextPartition
Parameters:
attrType - a subtree alias index
Throws:
javax.naming.NamingException

getUpdnIndex

public Index getUpdnIndex()
Description copied from class: BTreeContextPartition
Gets the Index mapping user provided distinguished names of entries as Strings to the BigInteger primary keys of entries.

Specified by:
getUpdnIndex in class BTreeContextPartition
Returns:
the user provided distinguished name Index

setUpdnIndexOn

public void setUpdnIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
                    throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Sets the user provided distinguished name Index.

Specified by:
setUpdnIndexOn in class BTreeContextPartition
Parameters:
attrType - the updn Index
Throws:
javax.naming.NamingException

getNdnIndex

public Index getNdnIndex()
Description copied from class: BTreeContextPartition
Gets the Index mapping the normalized distinguished names of entries as Strings to the BigInteger primary keys of entries.

Specified by:
getNdnIndex in class BTreeContextPartition
Returns:
the normalized distinguished name Index

setNdnIndexOn

public void setNdnIndexOn(org.apache.ldap.common.schema.AttributeType attrType)
                   throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Sets the normalized distinguished name Index.

Specified by:
setNdnIndexOn in class BTreeContextPartition
Parameters:
attrType - the ndn Index
Throws:
javax.naming.NamingException

getUserIndices

public java.util.Iterator getUserIndices()
Specified by:
getUserIndices in class BTreeContextPartition

getSystemIndices

public java.util.Iterator getSystemIndices()
Specified by:
getSystemIndices in class BTreeContextPartition

hasUserIndexOn

public boolean hasUserIndexOn(java.lang.String attribute)
Specified by:
hasUserIndexOn in class BTreeContextPartition

hasSystemIndexOn

public boolean hasSystemIndexOn(java.lang.String attribute)
Specified by:
hasSystemIndexOn in class BTreeContextPartition

getUserIndex

public Index getUserIndex(java.lang.String attribute)
                   throws IndexNotFoundException
Specified by:
getUserIndex in class BTreeContextPartition
Throws:
IndexNotFoundException
See Also:
BTreeContextPartition.getUserIndex(String)

getSystemIndex

public Index getSystemIndex(java.lang.String indexName)
                     throws IndexNotFoundException
Specified by:
getSystemIndex in class BTreeContextPartition
Throws:
IndexNotFoundException
See Also:
BTreeContextPartition.getEntryId(String)

getEntryId

public java.math.BigInteger getEntryId(java.lang.String dn)
                                throws javax.naming.NamingException
Specified by:
getEntryId in class BTreeContextPartition
Throws:
javax.naming.NamingException

getEntryDn

public java.lang.String getEntryDn(java.math.BigInteger id)
                            throws javax.naming.NamingException
Specified by:
getEntryDn in class BTreeContextPartition
Throws:
javax.naming.NamingException

getParentId

public java.math.BigInteger getParentId(java.lang.String dn)
                                 throws javax.naming.NamingException
Specified by:
getParentId in class BTreeContextPartition
Throws:
javax.naming.NamingException

getParentId

public java.math.BigInteger getParentId(java.math.BigInteger childId)
                                 throws javax.naming.NamingException
Specified by:
getParentId in class BTreeContextPartition
Throws:
javax.naming.NamingException

getEntryUpdn

public java.lang.String getEntryUpdn(java.math.BigInteger id)
                              throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Gets the user provided distinguished name.

Specified by:
getEntryUpdn in class BTreeContextPartition
Parameters:
id - the entry id
Returns:
the user provided distinguished name
Throws:
javax.naming.NamingException - if the updn index cannot be accessed

getEntryUpdn

public java.lang.String getEntryUpdn(java.lang.String dn)
                              throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Gets the user provided distinguished name.

Specified by:
getEntryUpdn in class BTreeContextPartition
Parameters:
dn - the normalized distinguished name
Returns:
the user provided distinguished name
Throws:
javax.naming.NamingException - if the updn and ndn indices cannot be accessed

count

public int count()
          throws javax.naming.NamingException
Description copied from class: BTreeContextPartition
Gets the count of the total number of entries in the database. TODO shouldn't this be a BigInteger instead of an int?

Specified by:
count in class BTreeContextPartition
Returns:
the number of entries in the database
Throws:
javax.naming.NamingException - if there is a failure to read the count

add

public void add(java.lang.String updn,
                javax.naming.Name dn,
                javax.naming.directory.Attributes entry)
         throws javax.naming.NamingException
Description copied from interface: ContextPartition
Adds an entry to this ContextPartition.

Specified by:
add in interface ContextPartition
Specified by:
add in class BTreeContextPartition
Throws:
javax.naming.NamingException

lookup

public javax.naming.directory.Attributes lookup(java.math.BigInteger id)
                                         throws javax.naming.NamingException
Specified by:
lookup in class BTreeContextPartition
Throws:
javax.naming.NamingException

delete

public void delete(java.math.BigInteger id)
            throws javax.naming.NamingException
Specified by:
delete in class BTreeContextPartition
Throws:
javax.naming.NamingException

list

public javax.naming.NamingEnumeration list(java.math.BigInteger id)
                                    throws javax.naming.NamingException
Specified by:
list in class BTreeContextPartition
Throws:
javax.naming.NamingException

getChildCount

public int getChildCount(java.math.BigInteger id)
                  throws javax.naming.NamingException
Specified by:
getChildCount in class BTreeContextPartition
Throws:
javax.naming.NamingException

getSuffix

public javax.naming.Name getSuffix(boolean normalized)
Description copied from interface: ContextPartition
Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.

Parameters:
normalized - boolean value used to control the normalization of the returned Name. If true the normalized Name is returned, otherwise the original user provided Name without normalization is returned.
Returns:
Name representing the distinguished/absolute name of this ContextPartitions root context.

getSuffixEntry

public javax.naming.directory.Attributes getSuffixEntry()
                                                 throws javax.naming.NamingException
Specified by:
getSuffixEntry in class BTreeContextPartition
Throws:
javax.naming.NamingException

setProperty

public void setProperty(java.lang.String propertyName,
                        java.lang.String propertyValue)
                 throws javax.naming.NamingException
Specified by:
setProperty in class BTreeContextPartition
Throws:
javax.naming.NamingException

getProperty

public java.lang.String getProperty(java.lang.String propertyName)
                             throws javax.naming.NamingException
Specified by:
getProperty in class BTreeContextPartition
Throws:
javax.naming.NamingException

getIndices

public javax.naming.directory.Attributes getIndices(java.math.BigInteger id)
                                             throws javax.naming.NamingException
Specified by:
getIndices in class BTreeContextPartition
Throws:
javax.naming.NamingException

modify

public void modify(javax.naming.Name dn,
                   int modOp,
                   javax.naming.directory.Attributes mods)
            throws javax.naming.NamingException
Description copied from interface: ContextPartition
Modifies an entry by adding, removing or replacing a set of attributes.

Specified by:
modify in interface ContextPartition
Specified by:
modify in class BTreeContextPartition
Throws:
javax.naming.NamingException

modify

public void modify(javax.naming.Name dn,
                   javax.naming.directory.ModificationItem[] mods)
            throws javax.naming.NamingException
Description copied from interface: ContextPartition
Modifies an entry by using a combination of adds, removes or replace operations using a set of ModificationItems.

Specified by:
modify in interface ContextPartition
Specified by:
modify in class BTreeContextPartition
Throws:
javax.naming.NamingException

modifyRn

public void modifyRn(javax.naming.Name dn,
                     java.lang.String newRdn,
                     boolean deleteOldRdn)
              throws javax.naming.NamingException
Changes the relative distinuished name of an entry specified by a distinguished name with the optional removal of the old Rdn attribute value from the entry. Name changes propagate down as dn changes to the descendants of the entry where the Rdn changed. An Rdn change operation does not change parent child relationships. It merely propagates a name change at a point in the DIT where the Rdn is changed. The change propagates down the subtree rooted at the distinguished name specified.

Specified by:
modifyRn in interface ContextPartition
Specified by:
modifyRn in class BTreeContextPartition
Parameters:
dn - the normalized distinguished name of the entry to alter
newRdn - the new Rdn to set
deleteOldRdn - whether or not to remove the old Rdn attr/val
Throws:
javax.naming.NamingException - if there are any errors propagating the name changes.

move

public void move(javax.naming.Name oldChildDn,
                 javax.naming.Name newParentDn,
                 java.lang.String newRdn,
                 boolean deleteOldRdn)
          throws javax.naming.NamingException
Description copied from interface: ContextPartition
Transplants a child entry, to a position in the namespace under a new parent entry and changes the RN of the child entry which can optionally have its old RN attributes removed. The removal of old RN attributes may not make sense in all namespaces. If the concept is undefined in a namespace this parameters is ignored. An example of a namespace where this parameter is significant is the LDAP namespace.

Specified by:
move in interface ContextPartition
Specified by:
move in class BTreeContextPartition
Throws:
javax.naming.NamingException

move

public void move(javax.naming.Name oldChildDn,
                 javax.naming.Name newParentDn)
          throws javax.naming.NamingException
Moves an entry under a new parent. The operation causes a shift in the parent child relationships between the old parent, new parent and the child moved. All other descendant entries under the child never change their direct parent child relationships. Hence after the parent child relationship changes are broken at the old parent and set at the new parent a modifyDn operation is conducted to handle name changes propagating down through the moved child and its descendants.

Specified by:
move in interface ContextPartition
Specified by:
move in class BTreeContextPartition
Parameters:
oldChildDn - the normalized dn of the child to be moved
newParentDn - the normalized dn of the new parent for the child
Throws:
javax.naming.NamingException - if something goes wrong