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

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

public class DefaultPartitionNexus
extends AbstractPartition
implements PartitionNexus

A root Partition that contains all other partitions, and routes all operations to the child partition that matches to its base suffixes. It also provides some extended operations such as accessing rootDSE and listing base suffixes.

Version:
$Rev: 927404 $, $Date: 2010-03-25 14:55:18 +0100 (Thu, 25 Mar 2010) $
Author:
Apache Directory Project

Field Summary
 
Fields inherited from interface org.apache.directory.server.core.partition.PartitionNexus
ADMIN_PASSWORD_BYTES, ADMIN_PASSWORD_STRING, ADMIN_UID
 
Constructor Summary
DefaultPartitionNexus(org.apache.directory.shared.ldap.entry.ServerEntry rootDSE)
          Creates the root nexus singleton of the entire system.
 
Method Summary
 void add(AddOperationContext addContext)
          Adds an entry to this ContextPartition.
 void addContextPartition(AddContextPartitionOperationContext opContext)
          Add a partition to the server.
 void bind(BindOperationContext bindContext)
          Represents a bind operation issued to authenticate a client.
 boolean compare(CompareOperationContext compareContext)
           
 void delete(DeleteOperationContext deleteContext)
          Deletes a leaf entry from this ContextPartition: non-leaf entries cannot be deleted until this operation has been applied to their children.
protected  void doDestroy()
          Override this method to put your initialization code.
protected  void doInit()
          Override this method to put your initialization code.
 DirectoryService getDirectoryService()
           
 java.lang.String getId()
          Gets the unique identifier for this partition.
 org.apache.directory.shared.ldap.name.DN getMatchedName(GetMatchedNameOperationContext matchedNameContext)
          Gets the most significant Dn that exists within the server for any Dn.
 Partition getPartition(org.apache.directory.shared.ldap.name.DN dn)
          Get's the partition corresponding to a distinguished name.
 ClonedServerEntry getRootDSE(GetRootDSEOperationContext getRootDSEContext)
          Get's the RootDSE entry for the DSA.
 org.apache.directory.shared.ldap.schema.SchemaManager getSchemaManager()
          Gets the schema manager assigned to this Partition.
 java.lang.String getSuffix()
          Gets the user provided suffix for this Partition as a String.
 org.apache.directory.shared.ldap.name.DN getSuffix(GetSuffixOperationContext getSuffixContext)
          Gets the distinguished name of the suffix that would hold an entry with the supplied distinguished name parameter.
 org.apache.directory.shared.ldap.name.DN getSuffixDn()
          Gets the normalized suffix as an DN for this Partition after it has been initialized.
 Partition getSystemPartition()
           
 boolean hasEntry(EntryOperationContext opContext)
          This method calls Partition.lookup(LookupOperationContext) and return true if it returns an entry by default.
 boolean isInitialized()
          Returns true if this context partition is initialized successfully.
 EntryFilteringCursor list(ListOperationContext opContext)
          A specialized form of one level search used to return a minimal set of information regarding child entries under a base.
 java.util.Set<java.lang.String> listSuffixes(ListSuffixOperationContext emptyContext)
          Gets an iteration over the Name suffixes of the partitions managed by this DefaultPartitionNexus.
 ClonedServerEntry lookup(java.lang.Long id)
           
 ClonedServerEntry lookup(LookupOperationContext opContext)
          This method calls Partition.lookup(LookupOperationContext) with null attributeIds by default.
 void modify(ModifyOperationContext modifyContext)
          Modifies an entry by adding, removing or replacing a set of attributes.
 void move(MoveOperationContext opContext)
          Transplants a child entry, to a position in the namespace under a new parent entry.
 void moveAndRename(MoveAndRenameOperationContext opContext)
          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<java.lang.String> extensionOids)
          Adds a set of supportedExtension (OID Strings) to the RootDSE.
 void registerSupportedSaslMechanisms(java.util.Set<java.lang.String> supportedSaslMechanisms)
          Adds a set of supportedSaslMechanisms (OID Strings) to the RootDSE.
 void removeContextPartition(RemoveContextPartitionOperationContext removeContextPartition)
          Remove a partition from the server.
 void rename(RenameOperationContext opContext)
          Modifies an entry by changing its relative name.
 EntryFilteringCursor search(SearchOperationContext opContext)
          Conducts a search against this ContextPartition.
 void setDirectoryService(DirectoryService directoryService)
           
 void setId(java.lang.String id)
          Sets the unique identifier for this partition.
 void setSchemaManager(org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
          Sets the schema manager assigned to this Partition.
 void setSuffix(java.lang.String suffix)
          Sets the user provided suffix for this Partition as a String.
 void sync()
          This method does nothing by default.
 void unbind(UnbindOperationContext unbindContext)
          Represents an unbind operation issued by an authenticated client.
 
Methods inherited from class org.apache.directory.server.core.partition.AbstractPartition
destroy, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.server.core.partition.Partition
destroy, initialize
 

Constructor Detail

DefaultPartitionNexus

public DefaultPartitionNexus(org.apache.directory.shared.ldap.entry.ServerEntry rootDSE)
                      throws java.lang.Exception
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.

Parameters:
rootDSE - the root entry for the DSA
Throws:
javax.naming.Exception - on failure to initialize
java.lang.Exception
See Also:
Vendor Information
Method Detail

doInit

protected void doInit()
               throws java.lang.Exception
Description copied from class: AbstractPartition
Override this method to put your initialization code.

Specified by:
doInit in class AbstractPartition
Throws:
java.lang.Exception

doDestroy

protected void doDestroy()
Description copied from class: AbstractPartition
Override this method to put your initialization code.

Specified by:
doDestroy in class AbstractPartition

getId

public java.lang.String getId()
Description copied from interface: Partition
Gets the unique identifier for this partition.

Specified by:
getId in interface Partition
Returns:
the unique identifier for this partition

setId

public void setId(java.lang.String id)
Description copied from interface: Partition
Sets the unique identifier for this partition.

Specified by:
setId in interface Partition
Parameters:
id - the unique identifier for this partition

getSchemaManager

public org.apache.directory.shared.ldap.schema.SchemaManager getSchemaManager()
Gets the schema manager assigned to this Partition.

Specified by:
getSchemaManager in interface Partition
Returns:
the schema manager

setSchemaManager

public void setSchemaManager(org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
Sets the schema manager assigned to this Partition.

Specified by:
setSchemaManager in interface Partition

getSuffixDn

public org.apache.directory.shared.ldap.name.DN getSuffixDn()
Description copied from interface: Partition
Gets the normalized suffix as an DN for this Partition after it has been initialized. Attempts to get this DN before initialization throw an IllegalStateException.

Specified by:
getSuffixDn in interface Partition
Returns:
the suffix for this Partition.

getSuffix

public java.lang.String getSuffix()
Description copied from interface: Partition
Gets the user provided suffix for this Partition as a String.

Specified by:
getSuffix in interface Partition

setSuffix

public void setSuffix(java.lang.String suffix)
Description copied from interface: Partition
Sets the user provided suffix for this Partition as a String.

Specified by:
setSuffix in interface Partition
Parameters:
suffix - the suffix String for this Partition.

isInitialized

public boolean isInitialized()
Description copied from class: AbstractPartition
Returns true if this context partition is initialized successfully.

Specified by:
isInitialized in interface Partition
Overrides:
isInitialized in class AbstractPartition
Returns:
true if the partition is initialized, false otherwise

sync

public void sync()
          throws java.lang.Exception
Description copied from class: AbstractPartition
This method does nothing by default.

Specified by:
sync in interface Partition
Specified by:
sync in class AbstractPartition
Throws:
java.lang.Exception - if buffers cannot be flushed to disk

add

public void add(AddOperationContext addContext)
         throws java.lang.Exception
Description copied from interface: Partition
Adds an entry to this ContextPartition.

Specified by:
add in interface Partition
Parameters:
addContext - the context used to add and entry to this ContextPartition
Throws:
java.lang.Exception - if there are any problems

bind

public void bind(BindOperationContext bindContext)
          throws java.lang.Exception
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.

Specified by:
bind in interface Partition
Parameters:
bindContext - the bind context, containing all the needed informations to bind
Throws:
java.lang.Exception - if something goes wrong

compare

public boolean compare(CompareOperationContext compareContext)
                throws java.lang.Exception
Specified by:
compare in interface PartitionNexus
Throws:
java.lang.Exception

delete

public void delete(DeleteOperationContext deleteContext)
            throws java.lang.Exception
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.

Specified by:
delete in interface Partition
Parameters:
deleteContext - the context of the entry to delete from this ContextPartition.
Throws:
java.lang.Exception - if there are any problems

hasEntry

public boolean hasEntry(EntryOperationContext opContext)
                 throws java.lang.Exception
Description copied from class: AbstractPartition
This method calls Partition.lookup(LookupOperationContext) and return true if it returns an entry by default. Please override this method if there is more effective way for your implementation.

Specified by:
hasEntry in interface Partition
Overrides:
hasEntry in class AbstractPartition
Parameters:
opContext - The context used to pass informations
Returns:
true if the entry exists, false if it does not
Throws:
java.lang.Exception - if there are any problems

list

public EntryFilteringCursor list(ListOperationContext opContext)
                          throws java.lang.Exception
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.

Specified by:
list in interface Partition
Parameters:
opContext - the context containing the distinguished/absolute name for the search/listing
Returns:
a NamingEnumeration containing objects of type ServerSearchResult
Throws:
java.lang.Exception - if there are any problems

lookup

public ClonedServerEntry lookup(LookupOperationContext opContext)
                         throws java.lang.Exception
Description copied from class: AbstractPartition
This method calls Partition.lookup(LookupOperationContext) with null attributeIds by default. Please override this method if there is more effective way for your implementation.

Specified by:
lookup in interface Partition
Specified by:
lookup in class AbstractPartition
Parameters:
opContext - The context containing the parameters
Returns:
an Attributes object representing the entry
Throws:
java.lang.Exception - if there are any problems

lookup

public ClonedServerEntry lookup(java.lang.Long id)
                         throws java.lang.Exception
Throws:
java.lang.Exception

modify

public void modify(ModifyOperationContext modifyContext)
            throws java.lang.Exception
Description copied from interface: Partition
Modifies an entry by adding, removing or replacing a set of attributes.

Specified by:
modify in interface Partition
Parameters:
modifyContext - The context containing the modification operation to perform on the entry which is one of constants specified by the DirContext interface: ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE.
Throws:
java.lang.Exception - if there are any problems
See Also:
DirContext, DirContext.ADD_ATTRIBUTE, DirContext.REMOVE_ATTRIBUTE, DirContext.REPLACE_ATTRIBUTE

move

public void move(MoveOperationContext opContext)
          throws java.lang.Exception
Description copied from interface: Partition
Transplants a child entry, to a position in the namespace under a new parent entry.

Specified by:
move in interface Partition
Parameters:
opContext - The context containing the DNs to move
Throws:
java.lang.Exception - if there are any problems

moveAndRename

public void moveAndRename(MoveAndRenameOperationContext opContext)
                   throws java.lang.Exception
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.

Specified by:
moveAndRename in interface Partition
Parameters:
opContext - The context contain all the information about the modifyDN operation
Throws:
java.lang.Exception - if there are any problems

rename

public void rename(RenameOperationContext opContext)
            throws java.lang.Exception
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 irrelevant.

Specified by:
rename in interface Partition
Parameters:
opContext - the modify DN context
Throws:
java.lang.Exception - if there are any problems

search

public EntryFilteringCursor search(SearchOperationContext opContext)
                            throws java.lang.Exception
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.

Specified by:
search in interface Partition
Parameters:
opContext - The context containing the information used by the operation
Returns:
a NamingEnumeration containing objects of type
Throws:
java.lang.Exception - if there are any problems

unbind

public void unbind(UnbindOperationContext unbindContext)
            throws java.lang.Exception
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.

Specified by:
unbind in interface Partition
Parameters:
unbindContext - the context used to unbind
Throws:
java.lang.Exception - if something goes wrong

getRootDSE

public ClonedServerEntry getRootDSE(GetRootDSEOperationContext getRootDSEContext)
Description copied from interface: PartitionNexus
Get's the RootDSE entry for the DSA.

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

addContextPartition

public void addContextPartition(AddContextPartitionOperationContext opContext)
                         throws java.lang.Exception
Description copied from interface: PartitionNexus
Add a partition to the server.

Specified by:
addContextPartition in interface PartitionNexus
Parameters:
opContext - The Add Partition context
Throws:
java.lang.Exception - If the addition can't be done

removeContextPartition

public void removeContextPartition(RemoveContextPartitionOperationContext removeContextPartition)
                            throws java.lang.Exception
Description copied from interface: PartitionNexus
Remove a partition from the server.

Specified by:
removeContextPartition in interface PartitionNexus
Throws:
java.lang.Exception - If the removal can't be done

getSystemPartition

public Partition getSystemPartition()
Specified by:
getSystemPartition in interface PartitionNexus
Returns:
The ou=system partition

getPartition

public Partition getPartition(org.apache.directory.shared.ldap.name.DN dn)
                       throws java.lang.Exception
Description copied from interface: 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 interface PartitionNexus
Parameters:
dn - the normalized distinguished name to get a partition for
Returns:
the partition containing the entry represented by the dn
Throws:
java.lang.Exception - if there is no partition for the dn

getMatchedName

public org.apache.directory.shared.ldap.name.DN getMatchedName(GetMatchedNameOperationContext matchedNameContext)
                                                        throws java.lang.Exception
Description copied from interface: PartitionNexus
Gets the most significant Dn that exists within the server for any Dn.

Specified by:
getMatchedName in interface PartitionNexus
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:
java.lang.Exception - if there are any problems

getSuffix

public org.apache.directory.shared.ldap.name.DN getSuffix(GetSuffixOperationContext getSuffixContext)
                                                   throws java.lang.Exception
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
Returns:
the suffix portion of dn, or the valid empty string Dn if no naming context was found for dn.
Throws:
java.lang.Exception - if there are any problems

listSuffixes

public java.util.Set<java.lang.String> listSuffixes(ListSuffixOperationContext emptyContext)
                                             throws java.lang.Exception
Description copied from interface: PartitionNexus
Gets an iteration over the Name suffixes of the partitions managed by this DefaultPartitionNexus.

Specified by:
listSuffixes in interface PartitionNexus
Returns:
Iteration over ContextPartition suffix names as Names.
Throws:
java.lang.Exception - if there are any problems

registerSupportedExtensions

public void registerSupportedExtensions(java.util.Set<java.lang.String> extensionOids)
                                 throws java.lang.Exception
Description copied from interface: PartitionNexus
Adds a set of supportedExtension (OID Strings) to the RootDSE.

Specified by:
registerSupportedExtensions in interface PartitionNexus
Parameters:
extensionOids - a set of OID strings to add to the supportedExtension attribute in the RootDSE
Throws:
java.lang.Exception

registerSupportedSaslMechanisms

public void registerSupportedSaslMechanisms(java.util.Set<java.lang.String> supportedSaslMechanisms)
                                     throws java.lang.Exception
Description copied from interface: PartitionNexus
Adds a set of supportedSaslMechanisms (OID Strings) to the RootDSE.

Specified by:
registerSupportedSaslMechanisms in interface PartitionNexus
Throws:
java.lang.Exception

getDirectoryService

public DirectoryService getDirectoryService()
Returns:
the directoryService

setDirectoryService

public void setDirectoryService(DirectoryService directoryService)
Parameters:
directoryService - the directoryService to set


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.