org.apache.directory.mitosis.operation
Class OperationFactory

java.lang.Object
  extended by org.apache.directory.mitosis.operation.OperationFactory

public class OperationFactory
extends java.lang.Object

Creates an Operation instance for a JNDI operation. The Operation instance returned by the provided factory methods are mostly a CompositeOperation, which consists smaller JNDI operations. The elements of the CompositeOperation differs from the original JNDI operation to make the operation more robust to replication conflict. All Operations created by OperationFactory whould be robust to the replication conflict and should be able to recover from the conflict.

"Add" (or "bind") is the only operation that doesn't return a CompositeOperation but returns an AddEntryOperation. It is because all other operations needs to update its related entry's Constants.ENTRY_CSN or Constants.ENTRY_DELETED attribute with additional sub-operations. In contrast, "add" operation doesn't need to create a CompositeOperation because those attributes can be added just modifying an AddEntryOperation rather than creating a parent operation and add sub-operations there.

Please note that all operations update Constants.ENTRY_CSN and documentation for each method won't explain this behavior.

Author:
Apache Directory Project

Constructor Summary
OperationFactory(DirectoryService directoryService, ReplicationConfiguration cfg)
           
 
Method Summary
 Operation newAdd(org.apache.directory.shared.ldap.name.LdapDN normalizedName, ServerEntry entry)
          Creates a new Operation that performs LDAP "add" operation with a newly generated CSN.
 Operation newDelete(org.apache.directory.shared.ldap.name.LdapDN normalizedName)
          Creates a new Operation that performs "delete" operation.
 Operation newModify(ModifyOperationContext opContext)
          Returns a new Operation that performs "modify" operation.
 Operation newModifyRn(org.apache.directory.shared.ldap.name.LdapDN oldName, org.apache.directory.shared.ldap.name.Rdn newRdn, boolean deleteOldRn)
          Returns a new Operation that performs "modifyRN" operation.
 Operation newMove(org.apache.directory.shared.ldap.name.LdapDN oldName, org.apache.directory.shared.ldap.name.LdapDN newParentName)
          Returns a new Operation that performs "move" operation.
 Operation newMove(org.apache.directory.shared.ldap.name.LdapDN oldName, org.apache.directory.shared.ldap.name.LdapDN newParentName, org.apache.directory.shared.ldap.name.Rdn newRdn, boolean deleteOldRn)
          Returns a new Operation that performs "move" operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationFactory

public OperationFactory(DirectoryService directoryService,
                        ReplicationConfiguration cfg)
Method Detail

newAdd

public Operation newAdd(org.apache.directory.shared.ldap.name.LdapDN normalizedName,
                        ServerEntry entry)
                 throws java.lang.Exception
Creates a new Operation that performs LDAP "add" operation with a newly generated CSN.

Throws:
java.lang.Exception

newDelete

public Operation newDelete(org.apache.directory.shared.ldap.name.LdapDN normalizedName)
                    throws javax.naming.NamingException
Creates a new Operation that performs "delete" operation. The created Operation doesn't actually delete the entry. Instead, it sets Constants.ENTRY_DELETED to "TRUE".

Throws:
javax.naming.NamingException

newModify

public Operation newModify(ModifyOperationContext opContext)
                    throws javax.naming.NamingException
Returns a new Operation that performs "modify" operation.

Returns:
a CompositeOperation that consists of one or more AttributeOperations and one additional operation that sets Constants.ENTRY_DELETED to "FALSE" to resurrect the entry the modified attributes belong to.
Throws:
javax.naming.NamingException

newModifyRn

public Operation newModifyRn(org.apache.directory.shared.ldap.name.LdapDN oldName,
                             org.apache.directory.shared.ldap.name.Rdn newRdn,
                             boolean deleteOldRn)
                      throws java.lang.Exception
Returns a new Operation that performs "modifyRN" operation. This operation is a subset of "move" operation. Calling this method actually forwards the call to newMove(LdapDN, LdapDN, Rdn, boolean) with unchanged newParentName.

Throws:
java.lang.Exception

newMove

public Operation newMove(org.apache.directory.shared.ldap.name.LdapDN oldName,
                         org.apache.directory.shared.ldap.name.LdapDN newParentName)
                  throws java.lang.Exception
Returns a new Operation that performs "move" operation. Calling this method actually forwards the call to newMove(LdapDN, LdapDN, Rdn, boolean) with unchanged newRdn and 'true' deleteOldRn.

Throws:
java.lang.Exception

newMove

public Operation newMove(org.apache.directory.shared.ldap.name.LdapDN oldName,
                         org.apache.directory.shared.ldap.name.LdapDN newParentName,
                         org.apache.directory.shared.ldap.name.Rdn newRdn,
                         boolean deleteOldRn)
                  throws java.lang.Exception
Returns a new Operation that performs "move" operation. Please note this operation is the most fragile operation I've written so it should be reviewed completely again.

Throws:
java.lang.Exception


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