org.apache.directory.server.core.schema
Class SchemaPartition

java.lang.Object
  extended by org.apache.directory.server.core.partition.AbstractPartition
      extended by org.apache.directory.server.core.schema.SchemaPartition
All Implemented Interfaces:
Partition

public final class SchemaPartition
extends AbstractPartition

A special partition designed to contain the portion of the DIT where schema information for the server is stored. In an effort to make sure that all Partition implementations are equal citizens to ApacheDS we want to be able to swap in and out any kind of Partition to store schema. This also has the added advantage of making sure the core, and hence the server is not dependent on any specific partition, which reduces coupling in the server's modules. The SchemaPartition achieves this by not really being a backing store itself for the schema entries. It instead delegates to another Partition via containment. It delegates all calls to this contained Partition. While doing so it also manages certain things:

  1. Checks that schema changes are valid.
  2. Updates the schema Registries on valid schema changes making sure the schema on disk is in sync with the schema in memory.
  3. Will eventually manage transaction based changes to schema where between some sequence of operations the schema may be inconsistent.
  4. Delegates read/write operations to contained Partition.
  5. Responsible for initializing schema for the entire server. ApacheDS cannot start up other partitions until this Partition is started without having access to the Registries. This Partition supplies the Registries on initialization for the server. That's one of it's core responsibilities.
  6. So by containing another Partition, we abstract the storage mechanism away from the management responsibilities while decoupling the server from a specific partition implementation and removing complexity in the Schema interceptor service which before managed synchronization.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.server.core.partition.AbstractPartition
initialized
 
Constructor Summary
SchemaPartition()
           
 
Method Summary
 void add(AddOperationContext opContext)
          Adds an entry to this ContextPartition.
 void bind(BindOperationContext opContext)
          Represents a bind operation issued to authenticate a client.
 void delete(DeleteOperationContext opContext)
          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.
 java.lang.String getId()
          Get's the ID which is fixed: 'schema'.
 org.apache.directory.shared.ldap.schema.SchemaManager getSchemaManager()
          Gets the schema manager assigned to this Partition.
 java.lang.String getSuffix()
          Always returns ServerDNConstants#OU_SCHEMA_DN: 'ou=schema'.
 org.apache.directory.shared.ldap.name.DN getSuffixDn()
          Always returns ServerDNConstants#OU_SCHEMA_DN_NORMALIZED: '2.5.4.11=schema'.
 Partition getWrappedPartition()
          Gets the Partition being wrapped.
 boolean hasEntry(EntryOperationContext entryContext)
          This method calls Partition.lookup(LookupOperationContext) and return true if it returns an entry by default.
 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.
 ClonedServerEntry lookup(LookupOperationContext lookupContext)
          This method calls Partition.lookup(LookupOperationContext) with null attributeIds by default.
 void modify(ModifyOperationContext opContext)
          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 rename(RenameOperationContext opContext)
          Modifies an entry by changing its relative name.
 EntryFilteringCursor search(SearchOperationContext opContext)
          Conducts a search against this ContextPartition.
 void setId(java.lang.String id)
          Has no affect: the id is fixed at ID: 'schema'.
 void setSchemaManager(org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
          Sets the schema manager assigned to this Partition.
 void setSuffix(java.lang.String suffix)
          Has no affect: just logs a warning.
 void setWrappedPartition(Partition wrapped)
          Sets the wrapped Partition which must be supplied or Partition.initialize() will fail with a NullPointerException.
 void sync()
          This method does nothing by default.
 java.lang.String toString()
           
 void unbind(UnbindOperationContext opContext)
          Represents an unbind operation issued by an authenticated client.
 
Methods inherited from class org.apache.directory.server.core.partition.AbstractPartition
destroy, initialize, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SchemaPartition

public SchemaPartition()
Method Detail

setWrappedPartition

public void setWrappedPartition(Partition wrapped)
Sets the wrapped Partition which must be supplied or Partition.initialize() will fail with a NullPointerException.

Parameters:
wrapped - the Partition being wrapped

getWrappedPartition

public Partition getWrappedPartition()
Gets the Partition being wrapped.

Returns:
the wrapped Partition

getId

public final java.lang.String getId()
Get's the ID which is fixed: 'schema'.

Returns:
the unique identifier for this partition

setId

public final void setId(java.lang.String id)
Has no affect: the id is fixed at ID: 'schema'. A warning is logged.

Parameters:
id - the unique identifier for this partition

getSuffixDn

public final org.apache.directory.shared.ldap.name.DN getSuffixDn()
Always returns ServerDNConstants#OU_SCHEMA_DN_NORMALIZED: '2.5.4.11=schema'.

Returns:
the suffix for this Partition.

getSuffix

public final java.lang.String getSuffix()
Always returns ServerDNConstants#OU_SCHEMA_DN: 'ou=schema'.


setSuffix

public final void setSuffix(java.lang.String suffix)
Has no affect: just logs a warning.

Parameters:
suffix - the suffix String for this Partition.

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

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

add

public void add(AddOperationContext opContext)
         throws java.lang.Exception
Adds an entry to this ContextPartition.

Parameters:
opContext - the context used to add and entry to this ContextPartition
Throws:
java.lang.Exception - if there are any problems

bind

public void bind(BindOperationContext opContext)
          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.

Parameters:
opContext - the bind context, containing all the needed informations to bind
Throws:
java.lang.Exception - if something goes wrong

delete

public void delete(DeleteOperationContext opContext)
            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.

Parameters:
opContext - the context of the entry to delete from this ContextPartition.
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.

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

hasEntry

public boolean hasEntry(EntryOperationContext entryContext)
                 throws java.lang.Exception
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:
entryContext - 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

modify

public void modify(ModifyOperationContext opContext)
            throws java.lang.Exception
Modifies an entry by adding, removing or replacing a set of attributes.

Parameters:
opContext - 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.

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.

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

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.

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 opContext)
            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.

Parameters:
opContext - the context used to unbind
Throws:
java.lang.Exception - if something goes wrong

lookup

public ClonedServerEntry lookup(LookupOperationContext lookupContext)
                         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:
lookupContext - The context containing the parameters
Returns:
an Attributes object representing the entry
Throws:
java.lang.Exception - if there are any problems

setSchemaManager

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

Parameters:
schemaManager - the SchemaManager to set

getSchemaManager

public org.apache.directory.shared.ldap.schema.SchemaManager getSchemaManager()
Description copied from interface: Partition
Gets the schema manager assigned to this Partition.

Returns:
The schemaManager

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


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