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

ludovicp
31.44.2010 4b1d6c96c36b2c9de904520649dac89bd46c544c
Fix an issue in MakeLDIF (NPE) with presence:n tag on RDN attribute
2 files modified
38 ■■■■ changed files
opendj-sdk/opends/src/messages/messages/tools.properties 4 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java 34 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/messages/messages/tools.properties
@@ -2564,3 +2564,7 @@
INFO_TIMEOUT_PLACEHOLDER_1711={timeout}
INFO_DESCRIPTION_CONNECTION_TIMEOUT_1712=Maximum length of time (in \
 milliseconds) that can be taken to establish a connection
MILD_ERR_MAKELDIF_CANNOT_WRITE_ENTRY_WITHOUT_DN_1713=An error occurred while \
attempting to write entry to LDIF:  Could not calculate the DN for the \
entry (no value found for the RDN attribute %s)
opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools.makeldif;
import org.opends.messages.Message;
@@ -37,6 +37,7 @@
import java.util.Random;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.NullOutputStream;
@@ -434,12 +435,33 @@
  {
    try
    {
      ldifWriter.writeTemplateEntry(entry);
      if ((++entriesWritten % 1000) == 0)
      if (entry.getDN() != null)
      {
        Message message = INFO_MAKELDIF_PROCESSED_N_ENTRIES.get(entriesWritten);
        out.println(wrapText(message, MAX_LINE_WIDTH));
        ldifWriter.writeTemplateEntry(entry);
        if ((++entriesWritten % 1000) == 0)
        {
          Message message =
            INFO_MAKELDIF_PROCESSED_N_ENTRIES.get(entriesWritten);
          out.println(wrapText(message, MAX_LINE_WIDTH));
        }
      }
      else
      {
        AttributeType[] rdnAttrs = entry.getTemplate().getRDNAttributes();
        String nullRdn = "";
        for (AttributeType att : rdnAttrs)
        {
          if (entry.getValue(att) == null)
          {
            nullRdn = att.getNameOrOID();
            break ;
          }
        }
        Message message =
          ERR_MAKELDIF_CANNOT_WRITE_ENTRY_WITHOUT_DN.get(nullRdn);
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return true;
      }
      return true;