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

matthew_swift
14.03.2009 cb874f4953806e281bc7030a098dbd3acce9cf86
Fix issue 3579: import-ldif countRejects does not work as expected

Prevent count rejects argument from being used during online imports since result codes greater than 1 are not supported by the task framework.
2 files modified
70 ■■■■■ changed files
opendj-sdk/opends/src/messages/messages/tools.properties 15 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java 55 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/messages/messages/tools.properties
@@ -2432,12 +2432,13 @@
 already a backup location for backend %s
INFO_RECURRING_TASK_PLACEHOLDER_1651={schedulePattern}
INFO_DESCRIPTION_RECURRING_TASK_1652=Indicates the task is recurring and will \
 be scheduled according to the value argument expressed in crontab(5) \
 compatible time/date pattern
INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED_1653=Recurring %s task %s scheduled \
 successfully
SEVERE_ERR_ENCPW_CANNOT_INITIALIZE_SERVER_COMPONENTS_1654=An error occurred \
SEVERE_ERR_ENCPW_CANNOT_INITIALIZE_SERVER_COMPONENTS_1652=An error occurred \
 while attempting to initialize server components to run the encode \
 password tool:  %s
SEVERE_ERR_LDIFIMPORT_COUNT_REJECTS_REQUIRES_OFFLINE_1653=The %s \
 argument is not supported for online imports
INFO_DESCRIPTION_RECURRING_TASK_1654=Indicates the task is recurring and will \
 be scheduled according to the value argument expressed in crontab(5) \
 compatible time/date pattern
INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED_1655=Recurring %s task %s scheduled \
 successfully
opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java
@@ -22,12 +22,19 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.tools.ToolConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -36,50 +43,42 @@
import java.util.List;
import java.util.Random;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.config.ConfigException;
import static org.opends.server.config.ConfigConstants.*;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.tasks.ImportTask;
import org.opends.server.tools.makeldif.TemplateFile;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.LDIFImportResult;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.RawAttribute;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.IntegerArgument;
import org.opends.server.util.args.StringArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.messages.ToolMessages.*;
import org.opends.messages.Message;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.tools.ToolConstants.*;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.tasks.ImportTask;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.util.args.StringArgument;
/**
@@ -448,6 +447,19 @@
      return 1;
    }
    // Count rejects option requires the ability to return result codes
    // which are potentially greater than 1. This is not supported by
    // the task framework.
    if (countRejects.isPresent()
        && argParser.connectionArgumentsPresent())
    {
      Message message =
          ERR_LDIFIMPORT_COUNT_REJECTS_REQUIRES_OFFLINE
              .get(countRejects.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    // Don't write non-error messages to console if quite
    if (quietMode.isPresent()) {
      out = new PrintStream(NullOutputStream.instance());
@@ -653,6 +665,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  protected int processLocal(boolean initializeServer,
                           PrintStream out,
                           PrintStream err) {