Class LdifRevertor
java.lang.Object
org.apache.directory.api.ldap.model.ldif.LdifRevertor
A helper class which provides methods to reverse a LDIF modification operation.
- Author:
- Apache Directory Project
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanFlag used when we want to delete the old Rdnstatic final booleanFlag used when we want to keep the old Rdn -
Method Summary
Modifier and TypeMethodDescriptionstatic LdifEntryreverseAdd(Dn dn) Compute a reverse LDIF of an AddRequest.static LdifEntryreverseDel(Dn dn, Entry deletedEntry) Compute a reverse LDIF of a DeleteRequest.static LdifEntryreverseModify(Dn dn, List<Modification> forwardModifications, Entry modifiedEntry) Compute the reversed LDIF for a modify request.static LdifEntryreverseMove(Dn newSuperiorDn, Dn modifiedDn) Compute a reverse LDIF for a forward change which if in LDIF format would represent a Move operation.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.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.
-
Field Details
-
DELETE_OLD_RDN
public static final boolean DELETE_OLD_RDNFlag used when we want to delete the old Rdn- See Also:
-
KEEP_OLD_RDN
public static final boolean KEEP_OLD_RDNFlag used when we want to keep the old Rdn- See Also:
-
-
Method Details
-
reverseAdd
-
reverseDel
Compute a reverse LDIF of a DeleteRequest. We have to get the previous entry in order to restore it.- Parameters:
dn- The deleted entry DndeletedEntry- The entry which has been deleted- Returns:
- A reverse LDIF
- Throws:
LdapException- If something went wrong
-
reverseModify
public static LdifEntry reverseModify(Dn dn, 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
- Parameters:
dn- the dn of the modified entryforwardModifications- the modification items for the forward changemodifiedEntry- The modified entry. Necessary for the destructive modifications- Returns:
- A reversed LDIF
- Throws:
LdapException- If something went wrong
-
reverseMove
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:
LdapException- if something went wrong
-
reverseRename
public static 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 EntrynewRdn- The new RdndeleteOldRdn- A flag which tells to delete the old Rdn AVAs- Returns:
- A list of LDIF reverted entries
- Throws:
LdapInvalidDnException- If the name reverting failed
-
reverseMoveAndRename
public static 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 EntrynewSuperior- The new superior Dn (can be null if it's just a rename)newRdn- The new RdndeleteOldRdn- A flag which tells to delete the old Rdn AVAs- Returns:
- A list of LDIF reverted entries
- Throws:
LdapInvalidDnException- If the name reverting failed
-