org.apache.ldap.server
Class RootNexus

java.lang.Object
  extended byorg.apache.ldap.server.RootNexus
All Implemented Interfaces:
BackingStore, PartitionNexus

public class RootNexus
extends java.lang.Object
implements PartitionNexus

A nexus for partitions dedicated for storing entries specific to a naming context.

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

Constructor Summary
RootNexus(SystemPartition system, javax.naming.directory.Attributes rootDSE)
          Creates the root nexus singleton of the entire system.
 
Method Summary
 void add(java.lang.String updn, javax.naming.Name dn, javax.naming.directory.Attributes an_entry)
          Looks up the backend corresponding to the entry first, then checks to see if the entry already exists.
 void close()
          Closes or shuts down this BackingStore.
 void delete(javax.naming.Name dn)
          Deletes a leaf entry from this BackingStore: non-leaf entries cannot be deleted until this operation has been applied to their children.
 javax.naming.ldap.LdapContext getLdapContext()
          Gets the LdapContext associated with the calling thread.
 javax.naming.Name getMatchedDn(javax.naming.Name dn, boolean normalized)
          Gets the most significant Dn that exists within the server for any Dn.
 javax.naming.directory.Attributes getRootDSE()
          Get's the RootDSE entry for the DSA.
 javax.naming.Name getSuffix(javax.naming.Name dn, boolean normalized)
          Gets the distinguished name of the suffix that would hold an entry with the supplied distinguished name parameter.
 boolean hasEntry(javax.naming.Name dn)
          Fast operation to check and see if a particular entry exists.
 boolean isClosed()
          Checks to see if this BackingStore has been closed or shut down.
 boolean isSuffix(javax.naming.Name dn)
          Checks to see if name is a context suffix.
 javax.naming.NamingEnumeration list(javax.naming.Name base)
          A specialized form of one level search used to return a minimal set of information regarding child entries under a base.
 java.util.Iterator listSuffixes(boolean normalized)
          Gets an iteration over the Name suffixes of the Backends managed by this BackendNexus.
 javax.naming.directory.Attributes lookup(javax.naming.Name dn)
          Looks up an entry by distinguished/absolute name.
 javax.naming.directory.Attributes lookup(javax.naming.Name dn, java.lang.String[] attrIds)
          Looks up an entry by distinguished name.
 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)
          Modifies an entry by changing its relative name.
 void move(javax.naming.Name oriChildName, javax.naming.Name newParentName)
          Transplants a child entry, to a position in the namespace under a new parent entry.
 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 register(ContextPartition backend)
          Registers an ContextPartition with this BackendManager.
 javax.naming.NamingEnumeration search(javax.naming.Name base, java.util.Map env, org.apache.ldap.common.filter.ExprNode filter, javax.naming.directory.SearchControls searchCtls)
          Conducts a search against this BackingStore.
 void sync()
          Cue to BackingStores with caches to flush entry and index changes to disk.
 void unregister(ContextPartition backend)
          Unregisters an ContextPartition with this BackendManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RootNexus

public RootNexus(SystemPartition system,
                 javax.naming.directory.Attributes rootDSE)
Creates the root nexus singleton of the entire system. The root DSE has several attributes that are injected into it besides those that may already exist. As partitions are added to the system more namingContexts attributes are added to the rootDSE.

See Also:
Vendor Information
Method Detail

getLdapContext

public javax.naming.ldap.LdapContext getLdapContext()
Description copied from interface: PartitionNexus
Gets the LdapContext associated with the calling thread.

Specified by:
getLdapContext in interface PartitionNexus
Returns:
The LdapContext associated with the thread of execution or null if no context is associated with the calling thread.
See Also:
PartitionNexus.getLdapContext()

getMatchedDn

public javax.naming.Name getMatchedDn(javax.naming.Name dn,
                                      boolean normalized)
                               throws javax.naming.NamingException
Description copied from interface: PartitionNexus
Gets the most significant Dn that exists within the server for any Dn.

Specified by:
getMatchedDn in interface PartitionNexus
Parameters:
dn - the normalized distinguished name to use for matching.
normalized - boolean if true cause the return of a normalized Dn, if false it returns the original user provided distinguished name for the matched portion of the Dn as it was provided on entry creation.
Returns:
a distinguished name representing the matching portion of dn, as originally provided by the user on creation of the matched entry or the empty string distinguished name if no match was found.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
PartitionNexus.getMatchedDn(javax.naming.Name, boolean)

getSuffix

public javax.naming.Name getSuffix(javax.naming.Name dn,
                                   boolean normalized)
                            throws javax.naming.NamingException
Description copied from interface: PartitionNexus
Gets the distinguished name of the suffix that would hold an entry with the supplied distinguished name parameter. If the DN argument does not fall under a partition suffix then the empty string Dn is returned.

Specified by:
getSuffix in interface PartitionNexus
Parameters:
dn - the normalized distinguished name to use for finding a suffix.
normalized - if true causes the return of a normalized Dn, but if false it returns the original user provided distinguished name for the suffix Dn as it was provided on suffix entry creation.
Returns:
the suffix portion of dn, or the valid empty string Dn if no naming context was found for dn.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
PartitionNexus.getSuffix(javax.naming.Name, boolean)

listSuffixes

public java.util.Iterator listSuffixes(boolean normalized)
                                throws javax.naming.NamingException
Description copied from interface: PartitionNexus
Gets an iteration over the Name suffixes of the Backends managed by this BackendNexus.

Specified by:
listSuffixes in interface PartitionNexus
Parameters:
normalized - if true the returned Iterator contains normalized Dn but, if false, it returns the original user provided distinguished names in the Iterator.
Returns:
Iteration over ContextPartition suffix names as Names.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
PartitionNexus.listSuffixes(boolean)

getRootDSE

public javax.naming.directory.Attributes getRootDSE()
Get's the RootDSE entry for the DSA.

Returns:
the attributes of the RootDSE

register

public void register(ContextPartition backend)
Description copied from interface: PartitionNexus
Registers an ContextPartition with this BackendManager. Called by each ContextPartition implementation after it has started to register for backend operation calls. This method effectively puts the ContextPartition's naming context online. Operations against the naming context should result in an LDAP BUSY result code in the returnValue if the naming context is not online.

Specified by:
register in interface PartitionNexus
Parameters:
backend - ContextPartition component to register with this BackendNexus.
See Also:
PartitionNexus.register( ContextPartition)

unregister

public void unregister(ContextPartition backend)
Description copied from interface: PartitionNexus
Unregisters an ContextPartition with this BackendManager. Called for each registered Backend right befor it is to be stopped. This prevents protocol server requests from reaching the Backend and effectively puts the ContextPartition's naming context offline. Operations against the naming context should result in an LDAP BUSY result code in the returnValue if the naming context is not online.

Specified by:
unregister in interface PartitionNexus
Parameters:
backend - ContextPartition component to unregister with this BackendNexus.
See Also:
PartitionNexus.unregister( ContextPartition)

delete

public void delete(javax.naming.Name dn)
            throws javax.naming.NamingException
Description copied from interface: BackingStore
Deletes a leaf entry from this BackingStore: non-leaf entries cannot be deleted until this operation has been applied to their children.

Specified by:
delete in interface BackingStore
Parameters:
dn - the normalized distinguished/absolute name of the entry to delete from this BackingStore.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.delete(javax.naming.Name)

add

public void add(java.lang.String updn,
                javax.naming.Name dn,
                javax.naming.directory.Attributes an_entry)
         throws javax.naming.NamingException
Looks up the backend corresponding to the entry first, then checks to see if the entry already exists. If so an exception is thrown. If not the add operation against the backend proceeds. This check is performed here so backend implementors do not have to worry about performing these kinds of checks.

Specified by:
add in interface BackingStore
Parameters:
updn - the user provided distinguished/absolute name of the entry
dn - the normalized distinguished/absolute name of the entry
an_entry - the entry to add to this BackingStore
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.add(String, Name, Attributes)

modify

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

Specified by:
modify in interface BackingStore
Parameters:
dn - the normalized distinguished/absolute name of the entry to modify
modOp - the modification operation to perform on the entry which is one of constants specified by the DirContext interface: ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE.
mods - the attributes and their values used to affect the modification with.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.modify(Name, int,Attributes)

modify

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

Specified by:
modify in interface BackingStore
Parameters:
dn - the normalized distinguished/absolute name of the entry to modify
mods - the ModificationItems used to affect the modification with
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.modify(javax.naming.Name, javax.naming.directory.ModificationItem[])

list

public javax.naming.NamingEnumeration list(javax.naming.Name base)
                                    throws javax.naming.NamingException
Description copied from interface: BackingStore
A specialized form of one level search used to return a minimal set of information regarding child entries under a base. Convenience method used to optimize operations rather than conducting a full search with retrieval.

Specified by:
list in interface BackingStore
Parameters:
base - the base distinguished/absolute name for the search/listing
Returns:
a NamingEnumeration containing objects of type DbSearchResult
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.list(javax.naming.Name)

search

public javax.naming.NamingEnumeration search(javax.naming.Name base,
                                             java.util.Map env,
                                             org.apache.ldap.common.filter.ExprNode filter,
                                             javax.naming.directory.SearchControls searchCtls)
                                      throws javax.naming.NamingException
Description copied from interface: BackingStore
Conducts a search against this BackingStore. Namespace specific parameters for search are contained within the environment using namespace specific keys into the hash. For example in the LDAP namespace a BackingStore implementation may look for search Controls using a namespace specific or implementation specific key for the set of LDAP Controls.

Specified by:
search in interface BackingStore
Parameters:
base - the normalized distinguished/absolute name of the search base
env - the environment under which operation occurs
filter - the root node of the filter expression tree
searchCtls - the search controls
Returns:
a NamingEnumeration containing objects of type SearchResult.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.search(Name, Map, ExprNode, SearchControls)

lookup

public javax.naming.directory.Attributes lookup(javax.naming.Name dn)
                                         throws javax.naming.NamingException
Description copied from interface: BackingStore
Looks up an entry by distinguished/absolute name. This is a simplified version of the search operation used to point read an entry used for convenience.

Specified by:
lookup in interface BackingStore
Parameters:
dn - the normalized distinguished name of the object to lookup
Returns:
an Attributes object representing the entry
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.lookup(javax.naming.Name)

lookup

public javax.naming.directory.Attributes lookup(javax.naming.Name dn,
                                                java.lang.String[] attrIds)
                                         throws javax.naming.NamingException
Description copied from interface: BackingStore
Looks up an entry by distinguished name. This is a simplified version of the search operation used to point read an entry used for convenience with a set of attributes to return. If the attributes are null or emty this defaults to the lookup opertion without the attributes.

Specified by:
lookup in interface BackingStore
Parameters:
dn - the normalized distinguished name of the object to lookup
attrIds - the set of attributes to return
Returns:
an Attributes object representing the entry
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.lookup(javax.naming.Name, String[])

hasEntry

public boolean hasEntry(javax.naming.Name dn)
                 throws javax.naming.NamingException
Description copied from interface: BackingStore
Fast operation to check and see if a particular entry exists.

Specified by:
hasEntry in interface BackingStore
Parameters:
dn - the normalized distinguished/absolute name of the object to check for existance
Returns:
true if the entry exists, false if it does not
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.hasEntry(javax.naming.Name)

isSuffix

public boolean isSuffix(javax.naming.Name dn)
                 throws javax.naming.NamingException
Description copied from interface: BackingStore
Checks to see if name is a context suffix.

Specified by:
isSuffix in interface BackingStore
Parameters:
dn - the normalized distinguished/absolute name of the context
Returns:
true if the name is a context suffix, false if it is not.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.isSuffix(javax.naming.Name)

modifyRn

public void modifyRn(javax.naming.Name dn,
                     java.lang.String newRdn,
                     boolean deleteOldRdn)
              throws javax.naming.NamingException
Description copied from interface: BackingStore
Modifies an entry by changing its relative name. Optionally attributes associated with the old relative name can be removed from the entry. This makes sense only in certain namespaces like LDAP and will be ignored if it is irrelavent.

Specified by:
modifyRn in interface BackingStore
Parameters:
dn - the normalized distinguished/absolute name of the entry to modify the RN of.
newRdn - the new RN of the entry specified by name
deleteOldRdn - boolean flag which removes the old RN attribute from the entry if set to true, and has no affect if set to false
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.modifyRn(Name, String, boolean)

move

public void move(javax.naming.Name oriChildName,
                 javax.naming.Name newParentName)
          throws javax.naming.NamingException
Description copied from interface: BackingStore
Transplants a child entry, to a position in the namespace under a new parent entry.

Specified by:
move in interface BackingStore
Parameters:
newParentName - the normalized distinguished/absolute name of the new parent to move the target entry to
oriChildName - the normalized distinguished/absolute name of the original child name representing the child entry to move
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.move(Name, Name)

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: BackingStore
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 BackingStore
Parameters:
oldChildDn - the normalized distinguished/absolute name of the original child name representing the child entry to move
newParentDn - the normalized distinguished/absolute name of the new parent to move the targeted entry to
newRdn - the new RN of the entry
deleteOldRdn - boolean flag which removes the old RN attribute from the entry if set to true, and has no affect if set to false
Throws:
javax.naming.NamingException - if there are any problems
See Also:
BackingStore.move(javax.naming.Name, javax.naming.Name, java.lang.String, boolean)

sync

public void sync()
          throws javax.naming.NamingException
Description copied from interface: BackingStore
Cue to BackingStores with caches to flush entry and index changes to disk.

Specified by:
sync in interface BackingStore
Throws:
javax.naming.NamingException - if there are problems flushing caches
See Also:
BackingStore.sync()

isClosed

public boolean isClosed()
Description copied from interface: BackingStore
Checks to see if this BackingStore has been closed or shut down. Operations against closed BackingStores will fail.

Specified by:
isClosed in interface BackingStore
Returns:
true if shut down, false otherwise
See Also:
BackingStore.isClosed()

close

public void close()
           throws javax.naming.NamingException
Description copied from interface: BackingStore
Closes or shuts down this BackingStore. Operations against closed BackingStores will fail.

Specified by:
close in interface BackingStore
Throws:
javax.naming.NamingException - if there are problems shutting down
See Also:
BackingStore.close()