org.apache.directory.shared.ldap.ldif
Class LdifRevertor

java.lang.Object
  extended by org.apache.directory.shared.ldap.ldif.LdifRevertor

public class LdifRevertor
extends java.lang.Object

A helper class which provides methods to reverse a LDIF modification operation.

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

Field Summary
static boolean DELETE_OLD_RDN
          Two constants for the deleteOldRdn flag
static boolean KEEP_OLD_RDN
           
 
Constructor Summary
LdifRevertor()
           
 
Method Summary
static LdifEntry reverseAdd(DN dn)
          Compute a reverse LDIF of an AddRequest.
static LdifEntry reverseDel(DN dn, Entry deletedEntry)
          Compute a reverse LDIF of a DeleteRequest.
static LdifEntry reverseModify(DN dn, java.util.List<Modification> forwardModifications, Entry modifiedEntry)
          Compute the reversed LDIF for a modify request.
static LdifEntry reverseMove(DN newSuperiorDn, DN modifiedDn)
          Compute a reverse LDIF for a forward change which if in LDIF format would represent a Move operation.
static java.util.List<LdifEntry> reverseMoveAndRename(Entry entry, DN newSuperior, RDN newRdn, boolean deleteOldRdn)
          Revert a DN to it's previous version by removing the first RDN and adding the given RDN.
static java.util.List<LdifEntry> reverseRename(Entry entry, RDN newRdn, boolean deleteOldRdn)
          Revert a DN to it's previous version by removing the first RDN and adding the given RDN.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELETE_OLD_RDN

public static final boolean DELETE_OLD_RDN
Two constants for the deleteOldRdn flag

See Also:
Constant Field Values

KEEP_OLD_RDN

public static final boolean KEEP_OLD_RDN
See Also:
Constant Field Values
Constructor Detail

LdifRevertor

public LdifRevertor()
Method Detail

reverseAdd

public static LdifEntry reverseAdd(DN dn)
Compute a reverse LDIF of an AddRequest. It's simply a delete request of the added entry

Parameters:
dn - the dn of the added entry
Returns:
a reverse LDIF

reverseDel

public static LdifEntry reverseDel(DN dn,
                                   Entry deletedEntry)
                            throws LdapException
Compute a reverse LDIF of a DeleteRequest. We have to get the previous entry in order to restore it.

Parameters:
dn - The deleted entry DN
deletedEntry - The entry which has been deleted
Returns:
A reverse LDIF
Throws:
LdapException

reverseModify

public static LdifEntry reverseModify(DN dn,
                                      java.util.List<Modification> forwardModifications,
                                      Entry modifiedEntry)
                               throws LdapException
Compute the reversed LDIF for a modify request. We will deal with the three kind of modifications : - add - remove - replace As the modifications should be issued in a reversed order ( ie, for the initials modifications {A, B, C}, the reversed modifications will be ordered like {C, B, A}), we will change the modifications order.

Parameters:
dn - the dn of the modified entry
forwardModifications - the modification items for the forward change
modifiedEntry - The modified entry. Necessary for the destructive modifications
Returns:
A reversed LDIF
Throws:
NamingException - If something went wrong
LdapException

reverseMove

public static LdifEntry reverseMove(DN newSuperiorDn,
                                    DN modifiedDn)
                             throws LdapException
Compute a reverse LDIF for a forward change which if in LDIF format would represent a Move operation. Hence there is no newRdn in the picture here.

Parameters:
newSuperiorDn - the new parent dn to be (must not be null)
modifiedDn - the dn of the entry being moved (must not be null)
Returns:
a reverse LDIF
Throws:
NamingException - if something went wrong
LdapException

reverseRename

public static java.util.List<LdifEntry> reverseRename(Entry entry,
                                                      RDN newRdn,
                                                      boolean deleteOldRdn)
                                               throws LdapInvalidDnException
Revert a DN to it's previous version by removing the first RDN and adding the given RDN. It's a rename operation. The biggest issue is that we have many corner cases, depending on the RDNs we are manipulating, and on the content of the initial entry.

Parameters:
entry - The initial Entry
newRdn - The new RDN
deleteOldRdn - A flag which tells to delete the old RDN AVAs
Returns:
A list of LDIF reverted entries
Throws:
NamingException - If the name reverting failed
LdapInvalidDnException

reverseMoveAndRename

public static java.util.List<LdifEntry> reverseMoveAndRename(Entry entry,
                                                             DN newSuperior,
                                                             RDN newRdn,
                                                             boolean deleteOldRdn)
                                                      throws LdapInvalidDnException
Revert a DN to it's previous version by removing the first RDN and adding the given RDN. It's a rename operation. The biggest issue is that we have many corner cases, depending on the RDNs we are manipulating, and on the content of the initial entry.

Parameters:
entry - The initial Entry
newSuperior - The new superior DN (can be null if it's just a rename)
newRdn - The new RDN
deleteOldRdn - A flag which tells to delete the old RDN AVAs
Returns:
A list of LDIF reverted entries
Throws:
NamingException - If the name reverting failed
LdapInvalidDnException


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