org.apache.ldap.server.partition
Class DefaultContextPartitionNexus

java.lang.Object
  extended byorg.apache.ldap.server.partition.ContextPartitionNexus
      extended byorg.apache.ldap.server.partition.DefaultContextPartitionNexus
All Implemented Interfaces:
ContextPartition

public class DefaultContextPartitionNexus
extends ContextPartitionNexus

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

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

Field Summary
 
Fields inherited from class org.apache.ldap.server.partition.ContextPartitionNexus
ADMIN_PRINCIPAL, ADMIN_PW, ADMIN_UID, GROUPS_BASE_NAME, SYSTEM_PARTITION_SUFFIX, USERS_BASE_NAME
 
Fields inherited from interface org.apache.ldap.server.partition.ContextPartition
ALIAS_ATTRIBUTE, ALIAS_OBJECT
 
Constructor Summary
DefaultContextPartitionNexus(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 addContextPartition(ContextPartitionConfiguration config)
           
 void delete(javax.naming.Name dn)
          Deletes a leaf entry from this ContextPartition: non-leaf entries cannot be deleted until this operation has been applied to their children.
 void destroy()
          Deinitialized this partition.
 javax.naming.ldap.LdapContext getLdapContext()
          Gets the LdapContext associated with the calling thread.
 javax.naming.Name getMatchedName(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(boolean normalized)
          Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.
 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.
 ContextPartition getSystemPartition()
           
 boolean hasEntry(javax.naming.Name dn)
          Fast operation to check and see if a particular entry exists.
 void init(ContextFactoryConfiguration factoryCfg, ContextPartitionConfiguration cfg)
          Initializes this partition.
 boolean isInitialized()
          Checks to see if this partition is initialized or not.
 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 ContextPartitionNexus.
 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/absolute 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 removeContextPartition(javax.naming.Name suffix)
           
 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 ContextPartition.
 void sync()
          Flushes any changes made to this partition now.
 
Methods inherited from class org.apache.ldap.server.partition.ContextPartitionNexus
getAdminName, getGroupsBaseName, getUsersBaseName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultContextPartitionNexus

public DefaultContextPartitionNexus(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

init

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

Throws:
javax.naming.NamingException

isInitialized

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


destroy

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


sync

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

Throws:
javax.naming.NamingException
See Also:
ContextPartition.sync()

addContextPartition

public void addContextPartition(ContextPartitionConfiguration config)
                         throws javax.naming.NamingException
Specified by:
addContextPartition in class ContextPartitionNexus
Throws:
javax.naming.NamingException

removeContextPartition

public void removeContextPartition(javax.naming.Name suffix)
                            throws javax.naming.NamingException
Specified by:
removeContextPartition in class ContextPartitionNexus
Throws:
javax.naming.NamingException

getSystemPartition

public ContextPartition getSystemPartition()
Specified by:
getSystemPartition in class ContextPartitionNexus

getLdapContext

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

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

getMatchedName

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

Specified by:
getMatchedName in class ContextPartitionNexus
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:
ContextPartitionNexus.getMatchedName(javax.naming.Name, boolean)

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.

getSuffix

public javax.naming.Name getSuffix(javax.naming.Name dn,
                                   boolean normalized)
                            throws javax.naming.NamingException
Description copied from class: ContextPartitionNexus
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 class ContextPartitionNexus
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:
ContextPartitionNexus.getSuffix(javax.naming.Name, boolean)

listSuffixes

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

Specified by:
listSuffixes in class ContextPartitionNexus
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:
ContextPartitionNexus.listSuffixes(boolean)

getRootDSE

public javax.naming.directory.Attributes getRootDSE()
Description copied from class: ContextPartitionNexus
Get's the RootDSE entry for the DSA.

Specified by:
getRootDSE in class ContextPartitionNexus
Returns:
the attributes of the RootDSE

delete

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

Parameters:
dn - the normalized distinguished/absolute name of the entry to delete from this ContextPartition.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
ContextPartition.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.

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 ContextPartition
Throws:
javax.naming.NamingException - if there are any problems
See Also:
ContextPartition.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: ContextPartition
Modifies an entry by adding, removing or replacing a set of attributes.

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:
ContextPartition.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: ContextPartition
Modifies an entry by using a combination of adds, removes or replace operations using a set of ModificationItems.

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:
ContextPartition.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: ContextPartition
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.

Parameters:
base - the base distinguished/absolute name for the search/listing
Returns:
a NamingEnumeration containing objects of type SearchResult
Throws:
javax.naming.NamingException - if there are any problems
See Also:
ContextPartition.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: ContextPartition
Conducts a search against this ContextPartition. Namespace specific parameters for search are contained within the environment using namespace specific keys into the hash. For example in the LDAP namespace a ContextPartition implementation may look for search Controls using a namespace specific or implementation specific key for the set of LDAP Controls.

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:
ContextPartition.search(Name, Map, ExprNode, SearchControls)

lookup

public javax.naming.directory.Attributes lookup(javax.naming.Name dn)
                                         throws javax.naming.NamingException
Description copied from interface: ContextPartition
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.

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:
ContextPartition.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: ContextPartition
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 with a set of attributes to return. If the attributes is null or empty, the returned entry will contain all attributes.

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:
ContextPartition.lookup(javax.naming.Name, String[])

hasEntry

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

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:
ContextPartition.hasEntry(javax.naming.Name)

isSuffix

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

Parameters:
dn - the normalized distinguished/absolute name of the context
Returns:
true if the name is a context suffix, false if it is not.
See Also:
ContextPartition.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: ContextPartition
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.

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:
ContextPartition.modifyRn(Name, String, boolean)

move

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

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:
ContextPartition.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: 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.

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:
ContextPartition.move(javax.naming.Name, javax.naming.Name, java.lang.String, boolean)


Copyright © 2002-2005 . All Rights Reserved.