From 4204e17ef5a801f50836310143394d801229ba3b Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 04 Sep 2007 01:55:31 +0000
Subject: [PATCH] Update the LDIFPluginResult object to provide the ability to specify a reject message that explains why the entry should not be imported/exported.
---
opends/src/server/org/opends/server/plugins/SevenBitCleanPlugin.java | 15 ++-----
opends/src/server/org/opends/server/api/plugin/LDIFPluginResult.java | 56 +++++++++++++++++++++++++++
opends/src/server/org/opends/server/core/PluginConfigManager.java | 8 ++--
opends/src/server/org/opends/server/util/LDIFReader.java | 18 +++++++-
opends/src/messages/messages/utility.properties | 5 ++
opends/src/messages/messages/plugin.properties | 2 +
6 files changed, 85 insertions(+), 19 deletions(-)
diff --git a/opends/src/messages/messages/plugin.properties b/opends/src/messages/messages/plugin.properties
index 2739baa..a8ba1b9 100644
--- a/opends/src/messages/messages/plugin.properties
+++ b/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
diff --git a/opends/src/messages/messages/utility.properties b/opends/src/messages/messages/utility.properties
index 10f1636..6c2799c 100644
--- a/opends/src/messages/messages/utility.properties
+++ b/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
+
diff --git a/opends/src/server/org/opends/server/api/plugin/LDIFPluginResult.java b/opends/src/server/org/opends/server/api/plugin/LDIFPluginResult.java
index 882f90e..af1ff06 100644
--- a/opends/src/server/org/opends/server/api/plugin/LDIFPluginResult.java
+++ b/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(")");
}
}
diff --git a/opends/src/server/org/opends/server/core/PluginConfigManager.java b/opends/src/server/org/opends/server/core/PluginConfigManager.java
index 74c459d..1552f9f 100644
--- a/opends/src/server/org/opends/server/core/PluginConfigManager.java
+++ b/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())
{
diff --git a/opends/src/server/org/opends/server/plugins/SevenBitCleanPlugin.java b/opends/src/server/org/opends/server/plugins/SevenBitCleanPlugin.java
index e7e0f32..ceb5d5e 100644
--- a/opends/src/server/org/opends/server/plugins/SevenBitCleanPlugin.java
+++ b/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;
}
diff --git a/opends/src/server/org/opends/server/util/LDIFReader.java b/opends/src/server/org/opends/server/util/LDIFReader.java
index 8ea36e2..aa53bd4 100644
--- a/opends/src/server/org/opends/server/util/LDIFReader.java
+++ b/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;
}
}
--
Gitblit v1.10.0