org.apache.directory.server.core.partition
Class DefaultPartitionNexus

java.lang.Object
  extended by org.apache.directory.server.core.partition.PartitionNexus
      extended by org.apache.directory.server.core.partition.DefaultPartitionNexus
All Implemented Interfaces:
Partition

public class DefaultPartitionNexus
extends PartitionNexus

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

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

Field Summary
 
Fields inherited from class org.apache.directory.server.core.partition.PartitionNexus
ADMIN_PASSWORD, ADMIN_PRINCIPAL, ADMIN_PRINCIPAL_NORMALIZED, ADMIN_UID, GROUPS_BASE_NAME, SYSTEM_PARTITION_SUFFIX, USERS_BASE_NAME
 
Fields inherited from interface org.apache.directory.server.core.partition.Partition
ALIAS_ATTRIBUTE, ALIAS_OBJECT
 
Constructor Summary
DefaultPartitionNexus(javax.naming.directory.Attributes rootDSE)
          Creates the root nexus singleton of the entire system.
 
Method Summary
 void add(LdapDN dn, javax.naming.directory.Attributes entry)
          Looks up the backend corresponding to the entry first, then checks to see if the entry already exists.
 void addContextPartition(PartitionConfiguration config)
           
 void bind(LdapDN bindDn, byte[] credentials, java.util.List mechanisms, java.lang.String saslAuthId)
          Represents a bind operation issued to authenticate a client.
 boolean compare(LdapDN name, java.lang.String oid, java.lang.Object value)
          Performs a comparison check to see if an attribute of an entry has a specified value.
 void delete(LdapDN 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.
 LdapDN getMatchedName(LdapDN dn)
          Gets the most significant Dn that exists within the server for any Dn.
 Partition getPartition(LdapDN dn)
          Get's the partition corresponding to a distinguished name.
 javax.naming.directory.Attributes getRootDSE()
          Get's the RootDSE entry for the DSA.
 LdapDN getSuffix()
          Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.
 LdapDN getSuffix(LdapDN dn)
          Gets the distinguished name of the suffix that would hold an entry with the supplied distinguished name parameter.
 Partition getSystemPartition()
           
 LdapDN getUpSuffix()
          Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.
 boolean hasEntry(LdapDN dn)
          Fast operation to check and see if a particular entry exists.
 void init(DirectoryServiceConfiguration factoryCfg, PartitionConfiguration cfg)
          Initializes this partition.
 boolean isInitialized()
          Checks to see if this partition is initialized or not.
 boolean isSuffix(LdapDN dn)
          Checks to see if name is a context suffix.
 javax.naming.NamingEnumeration list(LdapDN 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()
          Gets an iteration over the Name suffixes of the partitions managed by this PartitionNexus.
 javax.naming.directory.Attributes lookup(LdapDN dn)
          Looks up an entry by distinguished/absolute name.
 javax.naming.directory.Attributes lookup(LdapDN dn, java.lang.String[] attrIds)
          Looks up an entry by distinguished/absolute name.
 void modify(LdapDN dn, int modOp, javax.naming.directory.Attributes mods)
          Modifies an entry by adding, removing or replacing a set of attributes.
 void modify(LdapDN 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(LdapDN dn, java.lang.String newRdn, boolean deleteOldRdn)
          Modifies an entry by changing its relative name.
 void move(LdapDN oriChildName, LdapDN newParentName)
          Transplants a child entry, to a position in the namespace under a new parent entry.
 void move(LdapDN oldChildDn, LdapDN 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 registerSupportedExtensions(java.util.Set extensionOids)
          Adds a set of supportedExtension (OID Strings) to the RootDSE.
 void removeContextPartition(LdapDN suffix)
           
 javax.naming.NamingEnumeration search(LdapDN base, java.util.Map env, ExprNode filter, javax.naming.directory.SearchControls searchCtls)
          Conducts a search against this ContextPartition.
 void sync()
          Flushes any changes made to this partition now.
 void unbind(LdapDN bindDn)
          Represents an unbind operation issued by an authenticated client.
 
Methods inherited from class org.apache.directory.server.core.partition.PartitionNexus
getAdminName, getGroupsBaseName, getUsersBaseName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPartitionNexus

public DefaultPartitionNexus(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(DirectoryServiceConfiguration factoryCfg,
                 PartitionConfiguration cfg)
          throws javax.naming.NamingException
Description copied from interface: Partition
Initializes this partition.

Throws:
javax.naming.NamingException

isInitialized

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


destroy

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


sync

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

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

compare

public boolean compare(LdapDN name,
                       java.lang.String oid,
                       java.lang.Object value)
                throws javax.naming.NamingException
Description copied from class: PartitionNexus
Performs a comparison check to see if an attribute of an entry has a specified value.

Specified by:
compare in class PartitionNexus
Parameters:
name - the normalized name of the entry
oid - the attribute being compared
value - the value the attribute is compared to
Returns:
true if the entry contains an attribute with the value, false otherwise
Throws:
javax.naming.NamingException - if there is a problem accessing the entry and its values

addContextPartition

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

removeContextPartition

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

getSystemPartition

public Partition getSystemPartition()
Specified by:
getSystemPartition in class PartitionNexus

getLdapContext

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

Specified by:
getLdapContext in class 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()

getMatchedName

public LdapDN getMatchedName(LdapDN dn)
                      throws javax.naming.NamingException
Description copied from class: PartitionNexus
Gets the most significant Dn that exists within the server for any Dn.

Specified by:
getMatchedName in class PartitionNexus
Parameters:
dn - the normalized distinguished name to use for matching.
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#getMatchedName(org.apache.directory.shared.ldap.name.LdapDN)

getSuffix

public LdapDN getSuffix()
Description copied from interface: Partition
Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.

Returns:
Name representing the distinguished/absolute name of this ContextPartitions root context.

getUpSuffix

public LdapDN getUpSuffix()
Description copied from interface: Partition
Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.

Returns:
Name representing the distinguished/absolute name of this ContextPartitions root context.

getSuffix

public LdapDN getSuffix(LdapDN dn)
                 throws javax.naming.NamingException
Description copied from class: 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 class PartitionNexus
Parameters:
dn - the normalized distinguished name to use for finding a suffix.
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(org.apache.directory.shared.ldap.name.LdapDN)

listSuffixes

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

Specified by:
listSuffixes in class PartitionNexus
Returns:
Iteration over ContextPartition suffix names as Names.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
PartitionNexus.listSuffixes()

getRootDSE

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

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

bind

public void bind(LdapDN bindDn,
                 byte[] credentials,
                 java.util.List mechanisms,
                 java.lang.String saslAuthId)
          throws javax.naming.NamingException
Description copied from interface: Partition
Represents a bind operation issued to authenticate a client. Partitions need not support this operation. This operation is here to enable those interested in implementing virtual directories with ApacheDS.

Parameters:
bindDn - the normalized dn of the principal
credentials - the credentials of the principal
mechanisms - the mechanisms requested by the JNDI caller or a single mechanism representing the SASL bind mechanism used by a networked client (Strings)
saslAuthId - the SASL authentication (may be null)
Throws:
javax.naming.NamingException - if something goes wrong

unbind

public void unbind(LdapDN bindDn)
            throws javax.naming.NamingException
Description copied from interface: Partition
Represents an unbind operation issued by an authenticated client. Partitions need not support this operation. This operation is here to enable those interested in implementing virtual directories with ApacheDS.

Parameters:
bindDn - the normalized dn of the principal attempting to unbind
Throws:
javax.naming.NamingException - if something goes wrong

delete

public void delete(LdapDN dn)
            throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#delete(org.apache.directory.shared.ldap.name.LdapDN)

add

public void add(LdapDN dn,
                javax.naming.directory.Attributes 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.

entry - the entry to add to this ContextPartition
Throws:
javax.naming.NamingException - if there are any problems
See Also:
Partition#add(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.Attributes)

modify

public void modify(LdapDN dn,
                   int modOp,
                   javax.naming.directory.Attributes mods)
            throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#modify(org.apache.directory.shared.ldap.name.LdapDN,int,javax.naming.directory.Attributes)

modify

public void modify(LdapDN dn,
                   javax.naming.directory.ModificationItem[] mods)
            throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#modify(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.ModificationItem[])

list

public javax.naming.NamingEnumeration list(LdapDN base)
                                    throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#list(org.apache.directory.shared.ldap.name.LdapDN)

search

public javax.naming.NamingEnumeration search(LdapDN base,
                                             java.util.Map env,
                                             ExprNode filter,
                                             javax.naming.directory.SearchControls searchCtls)
                                      throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#search(org.apache.directory.shared.ldap.name.LdapDN,java.util.Map,org.apache.directory.shared.ldap.filter.ExprNode,javax.naming.directory.SearchControls)

lookup

public javax.naming.directory.Attributes lookup(LdapDN dn)
                                         throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#lookup(org.apache.directory.shared.ldap.name.LdapDN)

lookup

public javax.naming.directory.Attributes lookup(LdapDN dn,
                                                java.lang.String[] attrIds)
                                         throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#lookup(org.apache.directory.shared.ldap.name.LdapDN,String[])

hasEntry

public boolean hasEntry(LdapDN dn)
                 throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#hasEntry(org.apache.directory.shared.ldap.name.LdapDN)

isSuffix

public boolean isSuffix(LdapDN dn)
Description copied from interface: Partition
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:
Partition#isSuffix(org.apache.directory.shared.ldap.name.LdapDN)

modifyRn

public void modifyRn(LdapDN dn,
                     java.lang.String newRdn,
                     boolean deleteOldRdn)
              throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#modifyRn(org.apache.directory.shared.ldap.name.LdapDN,String,boolean)

move

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

Parameters:
oriChildName - the normalized distinguished/absolute name of the original child name representing the child entry to move
newParentName - the normalized distinguished/absolute name of the new parent to move the target entry to
Throws:
javax.naming.NamingException - if there are any problems
See Also:
Partition#move(org.apache.directory.shared.ldap.name.LdapDN,org.apache.directory.shared.ldap.name.LdapDN)

move

public void move(LdapDN oldChildDn,
                 LdapDN newParentDn,
                 java.lang.String newRdn,
                 boolean deleteOldRdn)
          throws javax.naming.NamingException
Description copied from interface: Partition
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:
Partition#move(org.apache.directory.shared.ldap.name.LdapDN,org.apache.directory.shared.ldap.name.LdapDN,String,boolean)

getPartition

public Partition getPartition(LdapDN dn)
                       throws javax.naming.NamingException
Description copied from class: PartitionNexus
Get's the partition corresponding to a distinguished name. This name need not be the name of the partition suffix. When used in conjunction with get suffix this can properly find the partition associated with the DN. Make sure to use the normalized DN.

Specified by:
getPartition in class PartitionNexus
Parameters:
dn - the normalized distinguished name to get a partition for
Returns:
the partition containing the entry represented by the dn
Throws:
javax.naming.NamingException - if there is no partition for the dn

registerSupportedExtensions

public void registerSupportedExtensions(java.util.Set extensionOids)
Description copied from class: PartitionNexus
Adds a set of supportedExtension (OID Strings) to the RootDSE.

Specified by:
registerSupportedExtensions in class PartitionNexus
Parameters:
extensionOids - a set of OID strings to add to the supportedExtension attribute in the RootDSE