You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/11/27 16:54:43 UTC
svn commit: r721208 -
/directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
Author: elecharny
Date: Thu Nov 27 07:54:43 2008
New Revision: 721208
URL: http://svn.apache.org/viewvc?rev=721208&view=rev
Log:
Another cleanup, with another method helper.
Modified:
directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
Modified: directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java?rev=721208&r1=721207&r2=721208&view=diff
==============================================================================
--- directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java (original)
+++ directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java Thu Nov 27 07:54:43 2008
@@ -317,7 +317,32 @@
return reverted;
}
-
+
+
+ /**
+ * A helper method to generate the modified attribute after a rename.
+ */
+ private static LdifEntry generateModify( LdifEntry restored, Entry entry, Rdn oldRdn, Rdn newRdn )
+ {
+ for ( AttributeTypeAndValue ava:newRdn )
+ {
+ // No need to add something which has already been added
+ // in the previous modification
+ if ( !entry.contains( ava.getNormType(), (String)ava.getNormValue() ) &&
+ !(ava.getNormType().equals( oldRdn.getNormType() ) &&
+ ava.getNormValue().equals( oldRdn.getNormValue() ) ) )
+ {
+ // Create the modification, which is an Add
+ Modification modification = new ClientModification(
+ ModificationOperation.REMOVE_ATTRIBUTE,
+ new DefaultClientAttribute( oldRdn.getUpType(), (String)ava.getUpValue() ) );
+
+ restored.addModificationItem( modification );
+ }
+ }
+
+ return restored;
+ }
/**
@@ -447,23 +472,7 @@
// We have to use the parent DN, the entry has already
// been renamed
restored.setDn( parentDn );
-
- for ( AttributeTypeAndValue ava:newRdn )
- {
- // No need to add something which has already been added
- // in the previous modification
- if ( !entry.contains( ava.getNormType(), (String)ava.getNormValue() ) &&
- !(ava.getNormType().equals( oldRdn.getNormType() ) &&
- ava.getNormValue().equals( oldRdn.getNormValue() ) ) )
- {
- // Create the modification, which is an Add
- Modification modification = new ClientModification(
- ModificationOperation.REMOVE_ATTRIBUTE,
- new DefaultClientAttribute( oldRdn.getUpType(), (String)ava.getUpValue() ) );
-
- restored.addModificationItem( modification );
- }
- }
+ restored = generateModify( restored, entry, oldRdn, newRdn );
entries.add( restored );
}
@@ -480,8 +489,6 @@
entries.add( reverted );
}
-
- return entries;
}
else
{
@@ -506,23 +513,7 @@
// We have to use the parent DN, the entry has already
// been renamed
restored.setDn( parentDn );
-
- for ( AttributeTypeAndValue ava:newRdn )
- {
- // No need to add something which has already been added
- // in the previous modification
- if ( !entry.contains( ava.getNormType(), (String)ava.getNormValue() ) &&
- !(ava.getNormType().equals( oldRdn.getNormType() ) &&
- ava.getNormalizedValue().equals( oldRdn.getNormValue() ) ) )
- {
- // Create the modification, which is an Add
- Modification modification = new ClientModification(
- ModificationOperation.REMOVE_ATTRIBUTE,
- new DefaultClientAttribute( oldRdn.getUpType(), (String)ava.getUpValue() ) );
-
- restored.addModificationItem( modification );
- }
- }
+ restored = generateModify( restored, entry, oldRdn, newRdn );
entries.add( restored );
}
@@ -537,8 +528,6 @@
entries.add( reverted );
}
-
- return entries;
}
}
else
@@ -621,23 +610,7 @@
// We have to use the parent DN, the entry has already
// been renamed
restored.setDn( parentDn );
-
- for ( AttributeTypeAndValue ava:newRdn )
- {
- // No need to add something which has already been added
- // in the previous modification
- if ( !entry.contains( ava.getNormType(), (String)ava.getNormValue() ) &&
- !(ava.getNormType().equals( oldRdn.getNormType() ) &&
- ava.getNormalizedValue().equals( oldRdn.getNormValue() ) ) )
- {
- // Create the modification, which is an Add
- Modification modification = new ClientModification(
- ModificationOperation.REMOVE_ATTRIBUTE,
- new DefaultClientAttribute( oldRdn.getUpType(), (String)ava.getUpValue() ) );
-
- restored.addModificationItem( modification );
- }
- }
+ restored = generateModify( restored, entry, oldRdn, newRdn );
entries.add( restored );
}