mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

dugan
12.27.2006 c1aec34e50f3d7a387bdd9da9860b3cd06f398c5
Re-write entries in sorted order. Andy suggested changes
2 files modified
42 ■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/tools/LDIFModify.java 14 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/util/LDIFWriter.java 28 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tools/LDIFModify.java
@@ -129,7 +129,8 @@
      DNComparator comparator = new DNComparator();
      TreeMap<DN,AddChangeRecordEntry> adds =
          new TreeMap<DN,AddChangeRecordEntry>(comparator);
      TreeMap<DN,Entry> ldifEntries =
          new TreeMap<DN,Entry>(comparator);
    HashMap<DN,DeleteChangeRecordEntry> deletes =
         new HashMap<DN,DeleteChangeRecordEntry>();
    HashMap<DN,LinkedList<Modification>> modifications =
@@ -306,8 +307,8 @@
      // If we've gotten here, then the (possibly updated) entry should be
      // written to the output LDIF.
      targetWriter.writeEntry(entry);
      // written to the LDIF entry Map.
      ldifEntries.put(entry.getDN(),entry);
    }
@@ -358,7 +359,8 @@
      Entry e = new Entry(add.getDN(), objectClasses, userAttributes,
                          operationalAttributes);
      targetWriter.writeEntry(e);
      //Put the entry to be added into the LDIF entry map.
      ldifEntries.put(e.getDN(),e);
    }
@@ -381,8 +383,8 @@
        errorList.add(getMessage(msgID, String.valueOf(dn)));
      }
    }
    return errorList.isEmpty();
    return targetWriter.writeEntries(ldifEntries.values()) &&
            errorList.isEmpty();
  }
opendj-sdk/opends/src/server/org/opends/server/util/LDIFWriter.java
@@ -33,6 +33,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import java.util.Collection;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
@@ -204,6 +205,33 @@
    }
  }
  /**
 * Iterates over each entry contained in the map and writes out the entry in
 * LDIF format. The main benefit of this method is that the entries can be
 * sorted by DN and output in sorted order.
 *
 * @param entries The Map containing the entries keyed by DN.
 *
 * @return <CODE>true</CODE>of all of the entries were
 *                  written out, <CODE>false</CODE>if it was not
 *                  because of the export configuration.
 *
 * @throws IOException  If a problem occurs while writing the entry to LDIF.
 *
 * @throws LDIFException If a problem occurs while trying to determine
 *                         whether to include the entry in the export.
 */
public boolean writeEntries(Collection <Entry> entries)
  throws IOException, LDIFException {
      assert debugEnter(CLASS_NAME, "writeEntry", String.valueOf(entries));
     boolean ret=true;
     Iterator<Entry> i = entries.iterator();
     while(ret && i.hasNext()) {
         ret=writeEntry(i.next());
     }
      return ret;
  }
  /**