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

neil_a_wilson
04.55.2007 4204e17ef5a801f50836310143394d801229ba3b
Update the LDIFPluginResult object to provide the ability to specify a reject
message that explains why the entry should not be imported/exported.

OpenDS Issue Number: 2218
6 files modified
104 ■■■■ changed files
opends/src/messages/messages/plugin.properties 2 ●●●●● patch | view | raw | blame | history
opends/src/messages/messages/utility.properties 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/api/plugin/LDIFPluginResult.java 56 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/PluginConfigManager.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/plugins/SevenBitCleanPlugin.java 15 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/LDIFReader.java 18 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/plugin.properties
@@ -374,3 +374,5 @@
 have resulted in a value for attribute %s that was not 7-bit clean
MILD_ERR_PLUGIN_7BIT_MODIFYDN_ATTR_NOT_CLEAN_102=The modify DN operation \
 would have resulted in a value for attribute %s that was not 7-bit clean
MILD_ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN_103=The entry included a value for \
 attribute %s that was not 7-bit clean
opends/src/messages/messages/utility.properties
@@ -499,3 +499,8 @@
SEVERE_ERR_CONSOLE_INPUT_ERROR_221=The response could not be read from the console due to the following error: %s
INFO_MENU_OPTION_BACK_222=back
INFO_MENU_OPTION_BACK_KEY_223=b
SEVERE_ERR_LDIF_REJECTED_BY_PLUGIN_NOMESSAGE_224=Rejecting entry %s because \
 it was rejected by a plugin
SEVERE_ERR_LDIF_REJECTED_BY_PLUGIN_225=Rejecting entry %s because it was \
 rejected by a plugin:  %s
opends/src/server/org/opends/server/api/plugin/LDIFPluginResult.java
@@ -28,6 +28,10 @@
import org.opends.messages.Message;
/**
 * This class defines a data structure that holds information about
 * the result of processing an LDIF import or export plugin.
@@ -56,6 +60,9 @@
  // imported/exported.
  private final boolean continueEntryProcessing;
  // A message explaining why the entry was rejected.
  private final Message rejectMessage;
  /**
@@ -65,7 +72,7 @@
   */
  private LDIFPluginResult()
  {
    this(true, true);
    this(true, true, null);
  }
@@ -85,8 +92,33 @@
  public LDIFPluginResult(boolean continuePluginProcessing,
                          boolean continueEntryProcessing)
  {
    this(continuePluginProcessing, continueEntryProcessing, null);
  }
  /**
   * Creates a new pre-operation plugin result with the provided
   * information.
   *
   * @param  continuePluginProcessing  Indicates whether any further
   *                                   LDIF import/export plugins
   *                                   should be invoked for the
   *                                   associated entry.
   * @param  continueEntryProcessing   Indicates whether the
   *                                   associated entry should still
   *                                   be imported/exported.
   * @param  rejectMessage             A message explaining why the
   *                                   entry should not be
   *                                   imported/exported.
   */
  public LDIFPluginResult(boolean continuePluginProcessing,
                          boolean continueEntryProcessing,
                          Message rejectMessage)
  {
    this.continuePluginProcessing = continuePluginProcessing;
    this.continueEntryProcessing  = continueEntryProcessing;
    this.rejectMessage            = rejectMessage;
  }
@@ -121,6 +153,20 @@
  /**
   * Retrieves a message explaining why the entry should not be
   * imported/exported, if one was provided.
   *
   * @return  A message explaining why the entry should not be
   *          imported/exported, or {@code null} if none was provided.
   */
  public Message getRejectMessage()
  {
    return rejectMessage;
  }
  /**
   * Retrieves a string representation of this post-response plugin
   * result.
   *
@@ -149,6 +195,14 @@
    buffer.append(continuePluginProcessing);
    buffer.append(", continueEntryProcessing=");
    buffer.append(continueEntryProcessing);
    if (rejectMessage != null)
    {
      buffer.append(", rejectMessage=\"");
      buffer.append(rejectMessage);
      buffer.append("\"");
    }
    buffer.append(")");
  }
}
opends/src/server/org/opends/server/core/PluginConfigManager.java
@@ -1631,7 +1631,7 @@
                String.valueOf(entry.getDN()), stackTraceToSingleLineString(e));
        logError(message);
        return new LDIFPluginResult(false, false);
        return new LDIFPluginResult(false, false, message);
      }
      if (result == null)
@@ -1641,7 +1641,7 @@
                String.valueOf(entry.getDN()));
        logError(message);
        return new LDIFPluginResult(false, false);
        return new LDIFPluginResult(false, false, message);
      }
      else if (! result.continuePluginProcessing())
      {
@@ -1694,7 +1694,7 @@
                String.valueOf(entry.getDN()), stackTraceToSingleLineString(e));
        logError(message);
        return new LDIFPluginResult(false, false);
        return new LDIFPluginResult(false, false, message);
      }
      if (result == null)
@@ -1704,7 +1704,7 @@
                String.valueOf(entry.getDN()));
        logError(message);
        return new LDIFPluginResult(false, false);
        return new LDIFPluginResult(false, false, message);
      }
      else if (! result.continuePluginProcessing())
      {
opends/src/server/org/opends/server/plugins/SevenBitCleanPlugin.java
@@ -82,15 +82,6 @@
  /**
   * The result that should be returned if an imported entry fails the 7-bit
   * clean check.
   */
  private static final LDIFPluginResult LDIF_FAILURE_RESULT =
       new LDIFPluginResult(false, false);
  /**
   * The result that should be returned if a pre-parse operation fails the 7-bit
   * clean check.
   */
@@ -210,7 +201,10 @@
          {
            if (! is7BitClean(v.getValue()))
            {
              return LDIF_FAILURE_RESULT;
              Message rejectMessage =
                   ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(
                        a.getNameWithOptions());
              return new LDIFPluginResult(false, false, rejectMessage);
            }
          }
        }
@@ -219,7 +213,6 @@
    // If we've gotten here, then everything is acceptable.
System.err.println("  The entry is acceptable");
    return LDIFPluginResult.SUCCESS;
  }
opends/src/server/org/opends/server/util/LDIFReader.java
@@ -303,9 +303,21 @@
             pluginConfigManager.invokeLDIFImportPlugins(importConfig, entry);
        if (! pluginResult.continueEntryProcessing())
        {
          Message message = ERR_LDIF_SKIP.get(String.valueOf(entryDN));
          logToSkipWriter(lines, message);
          entriesIgnored++;
          Message m;
          Message rejectMessage = pluginResult.getRejectMessage();
          if (rejectMessage == null)
          {
            m = ERR_LDIF_REJECTED_BY_PLUGIN_NOMESSAGE.get(
                     String.valueOf(entryDN));
          }
          else
          {
            m = ERR_LDIF_REJECTED_BY_PLUGIN.get(String.valueOf(entryDN),
                                                rejectMessage);
          }
          logToRejectWriter(lines, m);
          entriesRejected++;
          continue;
        }
      }