From 0a6fe185727ab8da0560fe4ea343afd27957e2ca Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 14 Aug 2015 11:57:52 +0000
Subject: [PATCH] Removed code duplication, made code more readable
---
opendj-server-legacy/src/main/java/org/opends/server/core/DeleteOperationBasis.java | 30 -
opendj-server-legacy/src/main/java/org/opends/server/core/UnbindOperationBasis.java | 16
opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java | 31
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java | 62 -
opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java | 26
opendj-server-legacy/src/main/java/org/opends/server/types/SynchronizationProviderResult.java | 110 +---
opendj-server-legacy/src/main/java/org/opends/server/api/plugin/PluginResult.java | 568 +++++++---------------
opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java | 31 -
opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java | 37 -
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java | 64 -
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java | 121 +---
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java | 50 -
opendj-server-legacy/src/main/java/org/opends/server/core/BindOperationBasis.java | 24
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java | 65 -
opendj-server-legacy/src/main/java/org/opends/server/types/AbstractOperation.java | 45 +
opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java | 26
opendj-server-legacy/src/main/java/org/opends/server/core/ExtendedOperationBasis.java | 34 -
opendj-server-legacy/src/main/java/org/opends/server/core/AbandonOperationBasis.java | 30
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java | 24
opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java | 24
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java | 42 -
21 files changed, 456 insertions(+), 1,004 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/PluginResult.java b/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/PluginResult.java
index 585dec3..3b7edb0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/PluginResult.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/PluginResult.java
@@ -44,6 +44,50 @@
mayInvoke=true)
public final class PluginResult
{
+ /** Contract for operation results. */
+ public static interface OperationResult
+ {
+ /**
+ * Indicates whether processing on the associated operation should continue.
+ *
+ * @return {@code true} if processing on the associated operation should continue, or
+ * {@code false} if it should stop.
+ */
+ boolean continueProcessing();
+
+ /**
+ * Retrieves the error message if {@link #continueProcessing()} returned {@code false}.
+ *
+ * @return An error message explaining why processing should stop or {@code null} if none is
+ * provided.
+ */
+ LocalizableMessage getErrorMessage();
+
+ /**
+ * Retrieves the result code for the operation if {@link #continueProcessing()} returned
+ * {@code false}.
+ *
+ * @return the result code for the operation or {@code null} if none is provided.
+ */
+ ResultCode getResultCode();
+
+ /**
+ * Retrieves the matched DN for the operation if {@link #continueProcessing()} returned
+ * {@code false}.
+ *
+ * @return the matched DN for the operation or {@code null} if none is provided.
+ */
+ DN getMatchedDN();
+
+ /**
+ * Retrieves the referral URLs for the operation if {@link #continueProcessing()} returned
+ * {@code false}.
+ *
+ * @return the referral URLs for the operation or {@code null} if none is provided.
+ */
+ List<String> getReferralURLs();
+ }
+
/**
* Defines a startup plugin result consisting of either continue
* skip further plugins, or stop startup with an error message.
@@ -63,13 +107,12 @@
new Startup(true, true, null);
/**
- * Construct a new startup plugin result.
+ * Constructs a new startup plugin result.
*
* @param continueProcessing Whether to continue startup.
* @param continuePluginProcessing Whether to invoke the rest
* of the plugins.
- * @param errorMessage An message explaining why startup should
- * stop.
+ * @param errorMessage An message explaining why startup should stop.
*/
private Startup(boolean continueProcessing,
boolean continuePluginProcessing,
@@ -93,8 +136,7 @@
/**
* Defines a skip further plugin processing startup plugin result.
*
- * @return a skip further plugin processing startup plugin
- * result.
+ * @return a skip further plugin processing startup plugin result.
*/
public static Startup skipFurtherPluginProcesssing()
{
@@ -117,8 +159,8 @@
/**
* Whether to continue startup.
*
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
+ * @return {@code true} if processing should continue
+ * or {@code false} otherwise.
*/
public boolean continueProcessing()
{
@@ -128,9 +170,8 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
@@ -138,11 +179,11 @@
}
/**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
+ * Retrieves the error message if {@link #continueProcessing()}
+ * returned {@code false}.
*
* @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
+ * stop or {@code null} if none is provided.
*/
public LocalizableMessage getErrorMessage()
{
@@ -156,7 +197,7 @@
* plugins, or stop operation processing with a result code,
* matched DN, referral URLs, and error message.
*/
- public static final class PreParse
+ public static final class PreParse implements OperationResult
{
/** Whether to continue operation processing. */
private final boolean continueProcessing;
@@ -180,17 +221,15 @@
new PreParse(true, true, null, null, null, null);
/**
- * Construct a new pre parse plugin result.
+ * Constructs a new pre parse plugin result.
*
* @param continueProcessing Whether to continue startup.
* @param continuePluginProcessing Whether to invoke the rest
* of the plugins.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param resultCode The result code for this result.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
- * stop.
*/
private PreParse (boolean continueProcessing,
boolean continuePluginProcessing,
@@ -217,11 +256,9 @@
}
/**
- * Defines a skip further plugin processing pre parse plugin
- * result.
+ * Defines a skip further plugin processing pre parse plugin result.
*
- * @return a skip further plugin processing pre parse plugin
- * result.
+ * @return a skip further plugin processing pre parse plugin result.
*/
public static PreParse skipFurtherPluginProcesssing()
{
@@ -232,8 +269,7 @@
* Defines a new stop processing pre parse plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
*
@@ -249,11 +285,10 @@
}
/**
- * Contrust a new stop processing pre parse plugin result.
+ * Constructs a new stop processing pre parse plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
*
* @return a new stop processing pre parse plugin result.
*/
@@ -264,12 +299,7 @@
null, null);
}
- /**
- * Whether to continue operation processing.
- *
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
- */
+ @Override
public boolean continueProcessing()
{
return continueProcessing;
@@ -278,58 +308,33 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
return continuePluginProcessing;
}
- /**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
- *
- * @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
- */
+ @Override
public LocalizableMessage getErrorMessage()
{
return errorMessage;
}
- /**
- * Retrieves the result code for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the result code for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public ResultCode getResultCode()
{
return resultCode;
}
- /**
- * Retrieves the matched DN for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the matched DN for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public DN getMatchedDN()
{
return matchedDN;
}
- /**
- * Retrieves the referral URLs for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the refferal URLs for the operation or
- * <code>null</code> if none is provided.
- */
+ @Override
public List<String> getReferralURLs()
{
return referralURLs;
@@ -342,7 +347,7 @@
* plugins, or stop operation processing with a result code,
* matched DN, referral URLs, and error message.
*/
- public static final class PreOperation
+ public static final class PreOperation implements OperationResult
{
/** Whether to continue operation processing. */
private final boolean continueProcessing;
@@ -366,17 +371,15 @@
new PreOperation(true, true, null, null, null, null);
/**
- * Construct a new pre operation plugin result.
+ * Constructs a new pre operation plugin result.
*
* @param continueProcessing Whether to continue startup.
* @param continuePluginProcessing Whether to invoke the rest
* of the plugins.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param resultCode The result code for this result.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
- * stop.
*/
private PreOperation (boolean continueProcessing,
boolean continuePluginProcessing,
@@ -403,11 +406,9 @@
}
/**
- * Defines a skip further plugin processing pre operation plugin
- * result.
+ * Defines a skip further plugin processing pre operation plugin result.
*
- * @return a skip further plugin processing pre operation plugin
- * result.
+ * @return a skip further plugin processing pre operation plugin result.
*/
public static PreOperation skipFurtherPluginProcesssing()
{
@@ -418,8 +419,7 @@
* Defines a new stop processing pre operation plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
*
@@ -434,11 +434,10 @@
}
/**
- * Contrust a new stop processing pre operation plugin result.
+ * Constructs a new stop processing pre operation plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
*
* @return a new stop processing pre operation plugin result.
*/
@@ -449,12 +448,7 @@
null, null);
}
- /**
- * Whether to continue operation processing.
- *
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
- */
+ @Override
public boolean continueProcessing()
{
return continueProcessing;
@@ -463,58 +457,33 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
return continuePluginProcessing;
}
- /**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
- *
- * @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
- */
+ @Override
public LocalizableMessage getErrorMessage()
{
return errorMessage;
}
- /**
- * Retrieves the result code for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the result code for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public ResultCode getResultCode()
{
return resultCode;
}
- /**
- * Retrieves the matched DN for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the matched DN for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public DN getMatchedDN()
{
return matchedDN;
}
- /**
- * Retrieves the referral URLs for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the refferal URLs for the operation or
- * <code>null</code> if none is provided.
- */
+ @Override
public List<String> getReferralURLs()
{
return referralURLs;
@@ -527,7 +496,7 @@
* plugins, or stop operation processing with a result code,
* matched DN, referral URLs, and error message.
*/
- public static final class PostOperation
+ public static final class PostOperation implements OperationResult
{
/** Whether to continue operation processing. */
private final boolean continueProcessing;
@@ -551,8 +520,7 @@
* Constructs a new post operation plugin result.
*
* @param continueProcessing Whether to continue startup.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param resultCode The result code for this result.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
@@ -583,8 +551,7 @@
* Defines a new stop processing post operation plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
*
@@ -599,11 +566,10 @@
}
/**
- * Contrust a new stop processing post operation plugin result.
+ * Constructs a new stop processing post operation plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
*
* @return a new stop processing post operation plugin result.
*/
@@ -614,60 +580,31 @@
null);
}
- /**
- * Whether to continue operation processing.
- *
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
- */
+ @Override
public boolean continueProcessing()
{
return continueProcessing;
}
- /**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
- *
- * @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
- */
+ @Override
public LocalizableMessage getErrorMessage()
{
return errorMessage;
}
- /**
- * Retrieves the result code for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the result code for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public ResultCode getResultCode()
{
return resultCode;
}
- /**
- * Retrieves the matched DN for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the matched DN for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public DN getMatchedDN()
{
return matchedDN;
}
- /**
- * Retrieves the referral URLs for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the refferal URLs for the operation or
- * <code>null</code> if none is provided.
- */
+ @Override
public List<String> getReferralURLs()
{
return referralURLs;
@@ -677,8 +614,7 @@
/**
* Defines a post response plugin result for core server operation
- * processing consisting of either continue or skip further
- * plugins.
+ * processing consisting of either continue or skip further plugins.
*/
public static final class PostResponse
{
@@ -710,11 +646,9 @@
}
/**
- * Defines a skip further plugin processing post response plugin
- * result.
+ * Defines a skip further plugin processing post response plugin result.
*
- * @return a skip further plugin processing post response plugin
- * result.
+ * @return a skip further plugin processing post response plugin result.
*/
public static PostResponse skipFurtherPluginProcesssing()
{
@@ -724,9 +658,8 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
@@ -754,13 +687,12 @@
new ImportLDIF(true, true, null);
/**
- * Construct a new import LDIF plugin result.
+ * Constructs a new import LDIF plugin result.
*
* @param continueProcessing Whether to continue startup.
* @param continuePluginProcessing Whether to invoke the rest
* of the plugins.
- * @param errorMessage An message explaining why startup should
- * stop.
+ * @param errorMessage An message explaining why startup should stop.
*/
private ImportLDIF(boolean continueProcessing,
boolean continuePluginProcessing,
@@ -782,11 +714,9 @@
}
/**
- * Defines a skip further plugin processing LDIF import plugin
- * result.
+ * Defines a skip further plugin processing LDIF import plugin result.
*
- * @return a skip further plugin processing LDIF import plugin
- * result.
+ * @return a skip further plugin processing LDIF import plugin result.
*/
public static ImportLDIF skipFurtherPluginProcesssing()
{
@@ -809,8 +739,8 @@
/**
* Whether to continue operation processing.
*
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
+ * @return {@code true} if processing should continue
+ * or {@code false} otherwise.
*/
public boolean continueProcessing()
{
@@ -820,9 +750,8 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
@@ -830,11 +759,11 @@
}
/**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
+ * Retrieves the error message if {@link #continueProcessing()}
+ * returned {@code false}.
*
* @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
+ * stop or {@code null} if none is provided.
*/
public LocalizableMessage getErrorMessage()
{
@@ -848,7 +777,7 @@
* plugins, or stop operation processing with a result code,
* matched DN, referral URLs, and error message.
*/
- public static final class SubordinateModifyDN
+ public static final class SubordinateModifyDN implements OperationResult
{
/** Whether to continue operation processing. */
private final boolean continueProcessing;
@@ -872,17 +801,15 @@
new SubordinateModifyDN(true, true, null, null, null, null);
/**
- * Construct a new subordinate modify DN plugin result.
+ * Constructs a new subordinate modify DN plugin result.
*
* @param continueProcessing Whether to continue startup.
* @param continuePluginProcessing Whether to invoke the rest
* of the plugins.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param resultCode The result code for this result.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
- * stop.
*/
private SubordinateModifyDN(boolean continueProcessing,
boolean continuePluginProcessing,
@@ -899,11 +826,9 @@
}
/**
- * Defines a continue processing subordinate modify DN plugin
- * result.
+ * Defines a continue processing subordinate modify DN plugin result.
*
- * @return a continue processing subordinate modify DN plugin
- * result.
+ * @return a continue processing subordinate modify DN plugin result.
*/
public static SubordinateModifyDN continueOperationProcessing()
{
@@ -924,17 +849,14 @@
}
/**
- * Defines a new stop processing subordinate modify DN plugin
- * result.
+ * Defines a new stop processing subordinate modify DN plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
*
- * @return a new stop processing subordinate modify DN plugin
- * result.
+ * @return a new stop processing subordinate modify DN plugin result.
*/
public static SubordinateModifyDN stopProcessing(
ResultCode resultCode, LocalizableMessage errorMessage, DN matchedDN,
@@ -945,15 +867,11 @@
}
/**
- * Contrust a new stop processing subordinate modify DN plugin
- * result.
+ * Constructs a new stop processing subordinate modify DN plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
- *
- * @return a new stop processing subordinate modify DN plugin
- * result.
+ * @param errorMessage An message explaining why processing should stop.
+ * @return a new stop processing subordinate modify DN plugin result.
*/
public static SubordinateModifyDN stopProcessing(
ResultCode resultCode, LocalizableMessage errorMessage)
@@ -962,12 +880,7 @@
resultCode, null, null);
}
- /**
- * Whether to continue operation processing.
- *
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
- */
+ @Override
public boolean continueProcessing()
{
return continueProcessing;
@@ -976,58 +889,33 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
return continuePluginProcessing;
}
- /**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
- *
- * @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
- */
+ @Override
public LocalizableMessage getErrorMessage()
{
return errorMessage;
}
- /**
- * Retrieves the result code for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the result code for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public ResultCode getResultCode()
{
return resultCode;
}
- /**
- * Retrieves the matched DN for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the matched DN for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public DN getMatchedDN()
{
return matchedDN;
}
- /**
- * Retrieves the referral URLs for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the refferal URLs for the operation or
- * <code>null</code> if none is provided.
- */
+ @Override
public List<String> getReferralURLs()
{
return referralURLs;
@@ -1040,7 +928,7 @@
* further plugins, or stop operation processing with a result
* code, matched DN, referral URLs, and error message.
*/
- public static final class SubordinateDelete
+ public static final class SubordinateDelete implements OperationResult
{
/** Whether to continue operation processing. */
private final boolean continueProcessing;
@@ -1064,17 +952,14 @@
new SubordinateDelete(true, true, null, null, null, null);
/**
- * Construct a new subordinate delete plugin result.
+ * Constructs a new subordinate delete plugin result.
*
* @param continueProcessing Whether to continue startup.
- * @param continuePluginProcessing Whether to invoke the rest
- * of the plugins.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param continuePluginProcessing Whether to invoke the rest of the plugins.
+ * @param errorMessage An message explaining why processing should stop.
* @param resultCode The result code for this result.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
- * stop.
*/
private SubordinateDelete(boolean continueProcessing,
boolean continuePluginProcessing,
@@ -1091,11 +976,9 @@
}
/**
- * Defines a continue processing subordinate delete plugin
- * result.
+ * Defines a continue processing subordinate delete plugin result.
*
- * @return a continue processing subordinate delete plugin
- * result.
+ * @return a continue processing subordinate delete plugin result.
*/
public static SubordinateDelete continueOperationProcessing()
{
@@ -1116,17 +999,14 @@
}
/**
- * Defines a new stop processing subordinate delete plugin
- * result.
+ * Defines a new stop processing subordinate delete plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
*
- * @return a new stop processing subordinate delete plugin
- * result.
+ * @return a new stop processing subordinate delete plugin result.
*/
public static SubordinateDelete stopProcessing(
ResultCode resultCode, LocalizableMessage errorMessage, DN matchedDN,
@@ -1137,15 +1017,11 @@
}
/**
- * Contrust a new stop processing subordinate delete plugin
- * result.
+ * Constructs a new stop processing subordinate delete plugin result.
*
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
- *
- * @return a new stop processing subordinate delete plugin
- * result.
+ * @param errorMessage An message explaining why processing should stop.
+ * @return a new stop processing subordinate delete plugin result.
*/
public static SubordinateDelete stopProcessing(
ResultCode resultCode, LocalizableMessage errorMessage)
@@ -1154,12 +1030,7 @@
resultCode, null, null);
}
- /**
- * Whether to continue operation processing.
- *
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
- */
+ @Override
public boolean continueProcessing()
{
return continueProcessing;
@@ -1168,58 +1039,33 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
return continuePluginProcessing;
}
- /**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
- *
- * @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
- */
+ @Override
public LocalizableMessage getErrorMessage()
{
return errorMessage;
}
- /**
- * Retrieves the result code for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the result code for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public ResultCode getResultCode()
{
return resultCode;
}
- /**
- * Retrieves the matched DN for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the matched DN for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public DN getMatchedDN()
{
return matchedDN;
}
- /**
- * Retrieves the referral URLs for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the refferal URLs for the operation or
- * <code>null</code> if none is provided.
- */
+ @Override
public List<String> getReferralURLs()
{
return referralURLs;
@@ -1232,7 +1078,7 @@
* plugins, or stop operation processing with a result code,
* matched DN, referral URLs, and error message.
*/
- public static final class IntermediateResponse
+ public static final class IntermediateResponse implements OperationResult
{
/** Whether to continue operation processing. */
private final boolean continueProcessing;
@@ -1260,19 +1106,17 @@
null);
/**
- * Construct a new intermediate response plugin result.
+ * Constructs a new intermediate response plugin result.
*
* @param continueProcessing Whether to continue startup.
* @param continuePluginProcessing Whether to invoke the rest
* of the plugins.
* @param sendResponse Whether to send the intermediate response
* to the client.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param resultCode The result code for this result.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
- * stop.
*/
private IntermediateResponse(boolean continueProcessing,
boolean continuePluginProcessing,
@@ -1291,13 +1135,11 @@
}
/**
- * Defines a continue processing intermediate response plugin
- * result.
+ * Defines a continue processing intermediate response plugin result.
*
* @param sendResponse Whether to send the intermediate response
* to the client.
- * @return a continue processing intermediate response plugin
- * result.
+ * @return a continue processing intermediate response plugin result.
*/
public static IntermediateResponse
continueOperationProcessing(boolean sendResponse)
@@ -1331,19 +1173,16 @@
}
/**
- * Defines a new stop processing intermediate response plugin
- * result.
+ * Defines a new stop processing intermediate response plugin result.
*
* @param sendResponse Whether to send the intermediate response
* to the client.
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param matchedDN The matched DN for this result.
* @param referralURLs The set of referral URLs for this result.
*
- * @return a new stop processing intermediate response plugin
- * result.
+ * @return a new stop processing intermediate response plugin result.
*/
public static IntermediateResponse stopProcessing(
boolean sendResponse, ResultCode resultCode,
@@ -1354,17 +1193,14 @@
}
/**
- * Contrust a new stop processing intermediate response plugin
- * result.
+ * Constructs a new stop processing intermediate response plugin result.
*
* @param sendResponse Whether to send the intermediate response
* to the client.
* @param resultCode The result code for this result.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
*
- * @return a new stop processing intermediate response plugin
- * result.
+ * @return a new stop processing intermediate response plugin result.
*/
public static IntermediateResponse stopProcessing(
boolean sendResponse, ResultCode resultCode,
@@ -1374,12 +1210,7 @@
errorMessage, resultCode, null, null);
}
- /**
- * Whether to continue operation processing.
- *
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
- */
+ @Override
public boolean continueProcessing()
{
return continueProcessing;
@@ -1388,9 +1219,8 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
@@ -1400,57 +1230,33 @@
/**
* Whether to send the intermediate response to the client.
*
- * @return <code>true</code> if the intermediate response should
- * be sent to the client or <code>false</code> otherwise.
+ * @return {@code true} if the intermediate response should
+ * be sent to the client or {@code false} otherwise.
*/
public boolean sendResponse()
{
return sendResponse;
}
- /**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
- *
- * @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
- */
+ @Override
public LocalizableMessage getErrorMessage()
{
return errorMessage;
}
- /**
- * Retrieves the result code for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the result code for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public ResultCode getResultCode()
{
return resultCode;
}
- /**
- * Retrieves the matched DN for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the matched DN for the operation or <code>null</code>
- * if none is provided.
- */
+ @Override
public DN getMatchedDN()
{
return matchedDN;
}
- /**
- * Retrieves the referral URLs for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the refferal URLs for the operation or
- * <code>null</code> if none is provided.
- */
+ @Override
public List<String> getReferralURLs()
{
return referralURLs;
@@ -1483,13 +1289,12 @@
new PostConnect(true, true, null, null, false);
/**
- * Construct a new post connect plugin result.
+ * Constructs a new post connect plugin result.
*
* @param continueProcessing Whether to continue startup.
* @param continuePluginProcessing Whether to invoke the rest
* of the plugins.
- * @param errorMessage An message explaining why processing
- * should stop.
+ * @param errorMessage An message explaining why processing should stop.
* @param disconnectReason The generic cause for the disconnect.
* @param sendDisconnectNotification Whether to send a disconnect
* notification to the client.
@@ -1518,11 +1323,9 @@
}
/**
- * Defines a skip further plugin processing post connect plugin
- * result.
+ * Defines a skip further plugin processing post connect plugin result.
*
- * @return a skip further plugin processing post connect plugin
- * result.
+ * @return a skip further plugin processing post connect plugin result.
*/
public static PostConnect skipFurtherPluginProcesssing()
{
@@ -1551,8 +1354,8 @@
/**
* Whether to continue operation processing.
*
- * @return <code>true</code> if processing should continue
- * or <code>false</code> otherwise.
+ * @return {@code true} if processing should continue
+ * or {@code false} otherwise.
*/
public boolean continueProcessing()
{
@@ -1562,9 +1365,8 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
@@ -1572,11 +1374,11 @@
}
/**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
+ * Retrieves the error message if {@link #continueProcessing()}
+ * returned {@code false}.
*
* @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
+ * stop or {@code null} if none is provided.
*/
public LocalizableMessage getErrorMessage()
{
@@ -1598,8 +1400,8 @@
* Indicates whether to try to provide notification to the client
* that the connection will be closed.
*
- * @return <code>true</code> if notification should be provided or
- * <code>false</code> otherwise.
+ * @return {@code true} if notification should be provided or
+ * {@code false} otherwise.
*/
public boolean sendDisconnectNotification()
{
@@ -1609,8 +1411,7 @@
/**
* Defines a post disconnect plugin result for client connection
- * processing consisting of either continue or skip further
- * plugins.
+ * processing consisting of either continue or skip further plugins.
*/
public static final class PostDisconnect
{
@@ -1621,7 +1422,7 @@
new PostDisconnect(true);
/**
- * Construct a new post disconnect plugin result.
+ * Constructs a new post disconnect plugin result.
*
* @param continuePluginProcessing Whether to invoke the rest
* of the plugins.
@@ -1656,9 +1457,8 @@
/**
* Whether to invoke the rest of the plugins.
*
- * @return <code>true</code> if the rest of the plugins should
- * be invoked for <code>false</code> to skip the rest of the
- * plugins.
+ * @return {@code true} if the rest of the plugins should
+ * be invoked for {@code false} to skip the rest of the plugins.
*/
public boolean continuePluginProcessing()
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/AbandonOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/AbandonOperationBasis.java
index c05f050..434bbf6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/AbandonOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/AbandonOperationBasis.java
@@ -27,15 +27,15 @@
package org.opends.server.core;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
-import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.api.ClientConnection;
+import org.opends.server.types.*;
import org.opends.server.types.operation.PostOperationAbandonOperation;
import org.opends.server.types.operation.PreParseAbandonOperation;
@@ -168,26 +168,14 @@
// Start the processing timer.
setProcessingStartTime();
- // Log the abandon request message.
logAbandonRequest(this);
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
- // Create a labeled block of code that we can break out of if a problem is
- // detected.
+ // Create a labeled block of code that we can break out of if a problem is detected.
abandonProcessing:
{
// Invoke the pre-parse abandon plugins.
- PluginResult.PreParse preParseResult =
- pluginConfigManager.invokePreParseAbandonPlugins(this);
- if (!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseAbandonPlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
break abandonProcessing;
}
@@ -213,14 +201,8 @@
setResultCode(result.getResultCode());
appendErrorMessage(result.getResponseMessage());
- PluginResult.PostOperation postOpResult =
- pluginConfigManager.invokePostOperationAbandonPlugins(this);
- if (!postOpResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePostOperationAbandonPlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
break abandonProcessing;
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
index c8c2564..44f50d5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
@@ -35,7 +35,6 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.*;
@@ -45,6 +44,7 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.StaticUtils.*;
@@ -213,11 +213,7 @@
catch (DirectoryException de)
{
logger.traceException(de);
-
- setResultCode(de.getResultCode());
- appendErrorMessage(de.getMessageObject());
- setMatchedDN(de.getMatchedDN());
- setReferralURLs(de.getReferralURLs());
+ setResults(de);
}
return entryDN;
}
@@ -517,31 +513,18 @@
// Start the processing timer.
setProcessingStartTime();
- // Log the add request message.
logAddRequest(this);
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// This flag is set to true as soon as a workflow has been executed.
boolean workflowExecuted = false;
-
try
{
// Check for and handle a request to cancel this operation.
checkIfCanceled(false);
// Invoke the pre-parse add plugins.
- PluginResult.PreParse preParseResult =
- pluginConfigManager.invokePreParseAddPlugins(this);
-
- if(!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseAddPlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
return;
}
@@ -612,10 +595,6 @@
@SuppressWarnings({ "unchecked", "rawtypes" })
private void invokePostResponsePlugins(boolean workflowExecuted)
{
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// Invoke the post response plugins
if (workflowExecuted)
{
@@ -628,7 +607,7 @@
{
for (LocalBackendAddOperation localOp : localOperations)
{
- pluginConfigManager.invokePostResponseAddPlugins(localOp);
+ getPluginConfigManager().invokePostResponseAddPlugins(localOp);
}
}
}
@@ -636,7 +615,7 @@
{
// Invoke the post response plugins that have been registered with
// the current operation
- pluginConfigManager.invokePostResponseAddPlugins(this);
+ getPluginConfigManager().invokePostResponseAddPlugins(this);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/BindOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/BindOperationBasis.java
index 517bdae..19eedfb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/BindOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/BindOperationBasis.java
@@ -34,7 +34,6 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.types.*;
import org.opends.server.types.operation.PreParseBindOperation;
import org.opends.server.workflowelement.localbackend.LocalBackendBindOperation;
@@ -537,14 +536,8 @@
try
{
// Invoke the pre-parse bind plugins.
- PluginResult.PreParse preParseResult =
- getPluginConfigManager().invokePreParseBindPlugins(this);
- if (!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseBindPlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
return;
}
@@ -611,25 +604,18 @@
*/
private void invokePostResponsePlugins(boolean workflowExecuted)
{
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// Invoke the post response plugins
if (workflowExecuted)
{
- // The post responses are provided by the workflow elements of the
- // workflow.
- List localOperations =
- (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
+ // The post responses are provided by the workflow elements of the workflow.
+ List localOperations = (List) getAttachment(Operation.LOCALBACKENDOPERATIONS);
if (localOperations != null)
{
for (Object localOp : localOperations)
{
- LocalBackendBindOperation localOperation =
- (LocalBackendBindOperation)localOp;
+ LocalBackendBindOperation localOperation = (LocalBackendBindOperation) localOp;
// Invoke the post-response bind plugins.
- pluginConfigManager.invokePostResponseBindPlugins(localOperation);
+ getPluginConfigManager().invokePostResponseBindPlugins(localOperation);
}
}
else
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java
index 75a107a..ffa747d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java
@@ -35,13 +35,13 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.types.*;
import org.opends.server.types.operation.PostResponseCompareOperation;
import org.opends.server.types.operation.PreParseCompareOperation;
import org.opends.server.workflowelement.localbackend.LocalBackendCompareOperation;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*;
@@ -353,30 +353,18 @@
// Start the processing timer.
setProcessingStartTime();
- // Log the compare request message.
logCompareRequest(this);
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// This flag is set to true as soon as a workflow has been executed.
boolean workflowExecuted = false;
-
try
{
// Check for and handle a request to cancel this operation.
checkIfCanceled(false);
// Invoke the pre-parse compare plugins.
- PluginResult.PreParse preParseResult =
- pluginConfigManager.invokePreParseComparePlugins(this);
- if(!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseComparePlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
return;
}
@@ -453,10 +441,6 @@
*/
private void invokePostResponsePlugins(boolean workflowExecuted)
{
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// Invoke the post response plugins
if (workflowExecuted)
{
@@ -469,7 +453,7 @@
{
for (LocalBackendCompareOperation localOperation : localOperations)
{
- pluginConfigManager.invokePostResponseComparePlugins(localOperation);
+ getPluginConfigManager().invokePostResponseComparePlugins(localOperation);
}
}
}
@@ -477,7 +461,7 @@
{
// Invoke the post response plugins that have been registered with
// the current operation
- pluginConfigManager.invokePostResponseComparePlugins(this);
+ getPluginConfigManager().invokePostResponseComparePlugins(this);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DeleteOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DeleteOperationBasis.java
index 54bf497..083932d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DeleteOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DeleteOperationBasis.java
@@ -33,13 +33,13 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.types.*;
import org.opends.server.types.operation.PostResponseDeleteOperation;
import org.opends.server.types.operation.PreParseDeleteOperation;
import org.opends.server.workflowelement.localbackend.LocalBackendDeleteOperation;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*;
@@ -152,11 +152,7 @@
catch (DirectoryException de)
{
logger.traceException(de);
-
- setResultCode(de.getResultCode());
- appendErrorMessage(de.getMessageObject());
- setMatchedDN(de.getMatchedDN());
- setReferralURLs(de.getReferralURLs());
+ setResults(de);
}
return entryDN;
@@ -228,27 +224,15 @@
// Start the processing timer.
setProcessingStartTime();
- // Log the delete request message.
logDeleteRequest(this);
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// This flag is set to true as soon as a workflow has been executed.
boolean workflowExecuted = false;
-
try
{
// Invoke the pre-parse delete plugins.
- PluginResult.PreParse preParseResult =
- pluginConfigManager.invokePreParseDeletePlugins(this);
- if(!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseDeletePlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
return;
}
@@ -319,10 +303,6 @@
*/
private void invokePostResponsePlugins(boolean workflowExecuted)
{
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// Invoke the post response plugins
if (workflowExecuted)
{
@@ -335,7 +315,7 @@
{
for (LocalBackendDeleteOperation localOperation : localOperations)
{
- pluginConfigManager.invokePostResponseDeletePlugins(localOperation);
+ getPluginConfigManager().invokePostResponseDeletePlugins(localOperation);
}
}
}
@@ -343,7 +323,7 @@
{
// Invoke the post response plugins that have been registered with
// the current operation
- pluginConfigManager.invokePostResponseDeletePlugins(this);
+ getPluginConfigManager().invokePostResponseDeletePlugins(this);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/ExtendedOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/ExtendedOperationBasis.java
index 371de07..496658d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/ExtendedOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/ExtendedOperationBasis.java
@@ -27,6 +27,7 @@
package org.opends.server.core;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.util.ServerConstants.*;
@@ -34,13 +35,12 @@
import java.util.Iterator;
import java.util.List;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ExtendedOperationHandler;
-import org.opends.server.api.plugin.PluginResult;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.operation.PostOperationExtendedOperation;
import org.opends.server.types.operation.PostResponseExtendedOperation;
import org.opends.server.types.operation.PreOperationExtendedOperation;
@@ -273,28 +273,16 @@
// Start the processing timer.
setProcessingStartTime();
- // Log the extended request message.
logExtendedRequest(this);
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
try
{
// Check for and handle a request to cancel this operation.
checkIfCanceled(false);
// Invoke the pre-parse extended plugins.
- PluginResult.PreParse preParseResult =
- pluginConfigManager.invokePreParseExtendedPlugins(this);
-
- if(!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseExtendedPlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
return;
}
@@ -391,14 +379,8 @@
try
{
// Invoke the pre-operation extended plugins.
- PluginResult.PreOperation preOpResult =
- pluginConfigManager.invokePreOperationExtendedPlugins(this);
- if(!preOpResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreOperationExtendedPlugins(this)))
{
- setResultCode(preOpResult.getResultCode());
- appendErrorMessage(preOpResult.getErrorMessage());
- setMatchedDN(preOpResult.getMatchedDN());
- setReferralURLs(preOpResult.getReferralURLs());
return;
}
@@ -410,7 +392,7 @@
}
finally
{
- pluginConfigManager.invokePostOperationExtendedPlugins(this);
+ getPluginConfigManager().invokePostOperationExtendedPlugins(this);
}
}
@@ -446,7 +428,7 @@
}
// Invoke the post-response extended plugins.
- pluginConfigManager.invokePostResponseExtendedPlugins(this);
+ getPluginConfigManager().invokePostResponseExtendedPlugins(this);
// If no cancel result, set it
if(cancelResult == null)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java
index cdda8dd..a750b33 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyDNOperationBasis.java
@@ -33,13 +33,13 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.types.*;
import org.opends.server.types.operation.PostResponseModifyDNOperation;
import org.opends.server.types.operation.PreParseModifyDNOperation;
import org.opends.server.workflowelement.localbackend.LocalBackendModifyDNOperation;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*;
@@ -408,32 +408,18 @@
// Start the processing timer.
setProcessingStartTime();
- // Log the modify DN request message.
logModifyDNRequest(this);
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// This flag is set to true as soon as a workflow has been executed.
boolean workflowExecuted = false;
-
-
try
{
// Check for and handle a request to cancel this operation.
checkIfCanceled(false);
// Invoke the pre-parse modify DN plugins.
- PluginResult.PreParse preParseResult =
- pluginConfigManager.invokePreParseModifyDNPlugins(this);
-
- if(!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseModifyDNPlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
return;
}
@@ -503,10 +489,6 @@
*/
private void invokePostResponsePlugins(boolean workflowExecuted)
{
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// Invoke the post response plugins
if (workflowExecuted)
{
@@ -521,7 +503,7 @@
{
for (LocalBackendModifyDNOperation localOperation : localOperations)
{
- pluginConfigManager.invokePostResponseModifyDNPlugins(localOperation);
+ getPluginConfigManager().invokePostResponseModifyDNPlugins(localOperation);
}
}
}
@@ -529,7 +511,7 @@
{
// Invoke the post response plugins that have been registered with
// the current operation
- pluginConfigManager.invokePostResponseModifyDNPlugins(this);
+ getPluginConfigManager().invokePostResponseModifyDNPlugins(this);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java
index 6eaa221..e4c7527 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java
@@ -33,7 +33,6 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.protocols.ldap.LDAPResultCode;
@@ -43,6 +42,7 @@
import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*;
@@ -325,32 +325,18 @@
// Start the processing timer.
setProcessingStartTime();
- // Log the modify request message.
logModifyRequest(this);
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// This flag is set to true as soon as a workflow has been executed.
boolean workflowExecuted = false;
-
-
try
{
// Check for and handle a request to cancel this operation.
checkIfCanceled(false);
// Invoke the pre-parse modify plugins.
- PluginResult.PreParse preParseResult =
- pluginConfigManager.invokePreParseModifyPlugins(this);
-
- if(!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseModifyPlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
return;
}
@@ -419,10 +405,6 @@
*/
private void invokePostResponsePlugins(boolean workflowExecuted)
{
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// Invoke the post response plugins
if (workflowExecuted)
{
@@ -436,7 +418,7 @@
{
for (LocalBackendModifyOperation localOperation : localOperations)
{
- pluginConfigManager.invokePostResponseModifyPlugins(localOperation);
+ getPluginConfigManager().invokePostResponseModifyPlugins(localOperation);
}
}
}
@@ -444,7 +426,7 @@
{
// Invoke the post response plugins that have been registered with
// the current operation
- pluginConfigManager.invokePostResponseModifyPlugins(this);
+ getPluginConfigManager().invokePostResponseModifyPlugins(this);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java
index a2dd6c1..0676541 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java
@@ -69,6 +69,7 @@
import org.opends.server.util.TimeThread;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -323,11 +324,7 @@
catch (DirectoryException de)
{
logger.traceException(de);
-
- setResultCode(de.getResultCode());
- appendErrorMessage(de.getMessageObject());
- setMatchedDN(de.getMatchedDN());
- setReferralURLs(de.getReferralURLs());
+ setResults(de);
}
return baseDN;
}
@@ -439,11 +436,7 @@
catch (DirectoryException de)
{
logger.traceException(de);
-
- setResultCode(de.getResultCode());
- appendErrorMessage(de.getMessageObject());
- setMatchedDN(de.getMatchedDN());
- setReferralURLs(de.getReferralURLs());
+ setResults(de);
}
return filter;
}
@@ -1034,15 +1027,10 @@
// Start the processing timer.
setProcessingStartTime();
- // Log the search request message.
logSearchRequest(this);
setSendResponse(true);
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
int timeLimit = getTimeLimit();
long timeLimitExpiration;
if (timeLimit <= 0)
@@ -1061,15 +1049,8 @@
// Check for and handle a request to cancel this operation.
checkIfCanceled(false);
- PluginResult.PreParse preParseResult =
- pluginConfigManager.invokePreParseSearchPlugins(this);
-
- if(!preParseResult.continueProcessing())
+ if (!processOperationResult(getPluginConfigManager().invokePreParseSearchPlugins(this)))
{
- setResultCode(preParseResult.getResultCode());
- appendErrorMessage(preParseResult.getErrorMessage());
- setMatchedDN(preParseResult.getMatchedDN());
- setReferralURLs(preParseResult.getReferralURLs());
return;
}
@@ -1133,18 +1114,12 @@
}
- /**
- * Invokes the post response plugins.
- */
+ /** Invokes the post response plugins. */
private void invokePostResponsePlugins()
{
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// Invoke the post response plugins that have been registered with
// the current operation
- pluginConfigManager.invokePostResponseSearchPlugins(this);
+ getPluginConfigManager().invokePostResponseSearchPlugins(this);
}
/** {@inheritDoc} */
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/UnbindOperationBasis.java b/opendj-server-legacy/src/main/java/org/opends/server/core/UnbindOperationBasis.java
index 305a382..123ff01 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/UnbindOperationBasis.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/UnbindOperationBasis.java
@@ -27,14 +27,15 @@
package org.opends.server.core;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.loggers.AccessLogger.*;
import java.util.List;
-import org.opends.server.api.ClientConnection;
import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.api.ClientConnection;
+import org.opends.server.types.*;
import org.opends.server.types.operation.PostOperationUnbindOperation;
import org.opends.server.types.operation.PreParseUnbindOperation;
@@ -125,19 +126,12 @@
@Override
public final void run()
{
- // Get the plugin config manager that will be used for invoking plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
setProcessingStartTime();
-
// Invoke the pre-parse unbind plugins. We don't care about the result
// since we're going to close the connection anyway.
- pluginConfigManager.invokePreParseUnbindPlugins(this);
+ getPluginConfigManager().invokePreParseUnbindPlugins(this);
-
- // Log the unbind request.
logUnbind(this);
@@ -151,7 +145,7 @@
// Invoke the post-operation unbind plugins.
- pluginConfigManager.invokePostOperationUnbindPlugins(this);
+ getPluginConfigManager().invokePostOperationUnbindPlugins(this);
setProcessingStopTime();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java
index d0737dc..1af3d22 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java
@@ -409,19 +409,7 @@
// Determine whether the user is changing his own password or if it's an administrative reset.
// If it's an administrative reset, then the requester must have the PASSWORD_RESET privilege.
- boolean selfChange;
- if (userIdentity == null)
- {
- selfChange = true;
- }
- else if (requestorEntry != null)
- {
- selfChange = userDN.equals(requestorEntry.getName());
- }
- else
- {
- selfChange = oldPassword != null;
- }
+ boolean selfChange = isSelfChange(userIdentity, requestorEntry, userDN, oldPassword);
if (! selfChange)
{
@@ -804,6 +792,7 @@
{
operation.setResultCode(resultCode);
operation.setErrorMessage(modifyOperation.getErrorMessage());
+ // FIXME should it also call setMatchedDN()
operation.setReferralURLs(modifyOperation.getReferralURLs());
return;
}
@@ -908,6 +897,22 @@
}
}
+ private boolean isSelfChange(ByteString userIdentity, Entry requestorEntry, DN userDN, ByteString oldPassword)
+ {
+ if (userIdentity == null)
+ {
+ return true;
+ }
+ else if (requestorEntry != null)
+ {
+ return userDN.equals(requestorEntry.getName());
+ }
+ else
+ {
+ return oldPassword != null;
+ }
+ }
+
private Modification newModification(ModificationType modType, AttributeType attrType, Collection<ByteString> value)
{
AttributeBuilder builder = new AttributeBuilder(attrType);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/AbstractOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/types/AbstractOperation.java
index 99c0d6d..693bfe6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/AbstractOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/AbstractOperation.java
@@ -39,6 +39,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.util.Reject;
import org.opends.server.api.ClientConnection;
+import org.opends.server.api.plugin.PluginResult.OperationResult;
import org.opends.server.controls.ControlDecoder;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.ldap.LDAPControl;
@@ -792,4 +793,48 @@
{
// do nothing by default
}
+
+ /**
+ * Processes the provided operation result for the current operation.
+ *
+ * @param operationResult the operation result
+ * @return {@code true} if processing can continue, {@code false} otherwise
+ */
+ public boolean processOperationResult(OperationResult operationResult)
+ {
+ return processOperationResult(this, operationResult);
+ }
+
+ /**
+ * Processes the provided operation result for the provided operation.
+ *
+ * @param op the operation
+ * @param opResult the operation result
+ * @return {@code true} if processing can continue, {@code false} otherwise
+ */
+ public static boolean processOperationResult(Operation op, OperationResult opResult)
+ {
+ if (!opResult.continueProcessing())
+ {
+ op.setResultCode(opResult.getResultCode());
+ op.appendErrorMessage(opResult.getErrorMessage());
+ op.setMatchedDN(opResult.getMatchedDN());
+ op.setReferralURLs(opResult.getReferralURLs());
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sets the results from the provided directory exception on the current operation.
+ *
+ * @param de the directory exception
+ */
+ public void setResults(DirectoryException de)
+ {
+ setResultCode(de.getResultCode());
+ appendErrorMessage(de.getMessageObject());
+ setMatchedDN(de.getMatchedDN());
+ setReferralURLs(de.getReferralURLs());
+ }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/SynchronizationProviderResult.java b/opendj-server-legacy/src/main/java/org/opends/server/types/SynchronizationProviderResult.java
index f510a35..c65639c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/SynchronizationProviderResult.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/SynchronizationProviderResult.java
@@ -30,7 +30,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ResultCode;
-
+import org.opends.server.api.plugin.PluginResult.OperationResult;
/**
* This class defines a data structure that holds information about
@@ -41,112 +41,58 @@
mayInstantiate=false,
mayExtend=false,
mayInvoke=true)
-public interface SynchronizationProviderResult
+public interface SynchronizationProviderResult extends OperationResult
{
- /**
- * Indicates whether processing on the associated operation should
- * continue.
- *
- * @return <CODE>true</CODE> if processing on the associated
- * operation should continue, or <CODE>false</CODE> if it
- * should stop.
- */
- boolean continueProcessing();
-
- /**
- * Retrieves the error message if <code>continueProcessing</code>
- * returned <code>false</code>.
- *
- * @return An error message explaining why processing should
- * stop or <code>null</code> if none is provided.
- */
- LocalizableMessage getErrorMessage();
-
- /**
- * Retrieves the result code for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the result code for the operation or <code>null</code>
- * if none is provided.
- */
- ResultCode getResultCode();
-
- /**
- * Retrieves the matched DN for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the matched DN for the operation or <code>null</code>
- * if none is provided.
- */
- DN getMatchedDN();
-
- /**
- * Retrieves the referral URLs for the operation
- * if <code>continueProcessing</code> returned <code>false</code>.
- *
- * @return the referral URLs for the operation or
- * <code>null</code> if none is provided.
- */
- List<String> getReferralURLs();
-
- /**
- * Defines a continue processing synchronization provider result.
- */
- public class ContinueProcessing
- implements SynchronizationProviderResult
+ /** Defines a continue processing synchronization provider result. */
+ public class ContinueProcessing implements SynchronizationProviderResult
{
- /** {@inheritDoc} */
@Override
public ResultCode getResultCode()
{
return null;
}
- /** {@inheritDoc} */
@Override
public DN getMatchedDN()
{
return null;
}
- /** {@inheritDoc} */
@Override
public List<String> getReferralURLs()
{
return null;
}
- /** {@inheritDoc} */
@Override
public boolean continueProcessing()
{
return true;
}
- /** {@inheritDoc} */
@Override
public LocalizableMessage getErrorMessage()
{
return null;
}
+
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName();
+ }
}
- /**
- * Defines a stop processing synchronization provider result.
- */
- public class StopProcessing
- implements SynchronizationProviderResult
+ /** Defines a stop processing synchronization provider result. */
+ public class StopProcessing implements SynchronizationProviderResult
{
- /** The matched DN for this result. */
- private final DN matchedDN;
-
- /** The set of referral URLs for this result. */
- private final List<String> referralURLs;
-
/** The result code for this result. */
private final ResultCode resultCode;
-
private final LocalizableMessage errorMessage;
+ /** The matched DN for this result. */
+ private final DN matchedDN;
+ /** The set of referral URLs for this result. */
+ private final List<String> referralURLs;
/**
* Construct a new stop processing synchronization provider result.
@@ -185,40 +131,52 @@
this.referralURLs = null;
}
- /** {@inheritDoc} */
@Override
public ResultCode getResultCode()
{
return resultCode;
}
- /** {@inheritDoc} */
@Override
public DN getMatchedDN()
{
return matchedDN;
}
- /** {@inheritDoc} */
@Override
public List<String> getReferralURLs()
{
return referralURLs;
}
- /** {@inheritDoc} */
@Override
public boolean continueProcessing()
{
return false;
}
- /** {@inheritDoc} */
@Override
public LocalizableMessage getErrorMessage()
{
return errorMessage;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder(getClass().getSimpleName())
+ .append("(resultCode=").append(resultCode)
+ .append(", errorMessage=").append(errorMessage);
+ if (matchedDN != null)
+ {
+ sb.append(", matchedDN=").append(matchedDN);
+ }
+ if (referralURLs != null && !referralURLs.isEmpty())
+ {
+ sb.append(", referralURLs=").append(referralURLs);
+ }
+ sb.append(")");
+ return sb.toString();
+ }
}
}
-
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
index 11cd04a..521143d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -37,13 +37,13 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.Syntax;
+import org.opends.server.api.AccessControlHandler;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.PasswordValidator;
import org.opends.server.api.SynchronizationProvider;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.controls.LDAPAssertionRequestControl;
import org.opends.server.controls.LDAPPostReadRequestControl;
import org.opends.server.controls.PasswordPolicyErrorType;
@@ -54,7 +54,6 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PasswordPolicy;
import org.opends.server.core.PersistentSearch;
-import org.opends.server.core.PluginConfigManager;
import org.opends.server.schema.AuthPasswordSyntax;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.Attribute;
@@ -71,7 +70,6 @@
import org.opends.server.types.Privilege;
import org.opends.server.types.RDN;
import org.opends.server.types.SearchFilter;
-import org.opends.server.types.SynchronizationProviderResult;
import org.opends.server.types.operation.PostOperationAddOperation;
import org.opends.server.types.operation.PostResponseAddOperation;
import org.opends.server.types.operation.PostSynchronizationAddOperation;
@@ -80,6 +78,8 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.types.AbstractOperation.*;
+import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -172,28 +172,19 @@
AtomicBoolean executePostOpPlugins = new AtomicBoolean(false);
processAdd(clientConnection, executePostOpPlugins);
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
-
// Invoke the post-operation or post-synchronization add plugins.
if (isSynchronizationOperation())
{
if (getResultCode() == ResultCode.SUCCESS)
{
- pluginConfigManager.invokePostSynchronizationAddPlugins(this);
+ getPluginConfigManager().invokePostSynchronizationAddPlugins(this);
}
}
else if (executePostOpPlugins.get())
{
// FIXME -- Should this also be done while holding the locks?
- PluginResult.PostOperation postOpResult =
- pluginConfigManager.invokePostOperationAddPlugins(this);
- if (!postOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePostOperationAddPlugins(this)))
{
- setResultCode(postOpResult.getResultCode());
- appendErrorMessage(postOpResult.getErrorMessage());
- setMatchedDN(postOpResult.getMatchedDN());
- setReferralURLs(postOpResult.getReferralURLs());
return;
}
}
@@ -273,19 +264,12 @@
// Invoke any conflict resolution processing that might be needed by the
// synchronization provider.
- for (SynchronizationProvider<?> provider : DirectoryServer
- .getSynchronizationProviders())
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders())
{
try
{
- SynchronizationProviderResult result =
- provider.handleConflictResolution(this);
- if (!result.continueProcessing())
+ if (!processOperationResult(this, provider.handleConflictResolution(this)))
{
- setResultCode(result.getResultCode());
- appendErrorMessage(result.getErrorMessage());
- setMatchedDN(result.getMatchedDN());
- setReferralURLs(result.getReferralURLs());
return;
}
}
@@ -430,8 +414,7 @@
// sensitive information to the client.
try
{
- if (!AccessControlConfigManager.getInstance().getAccessControlHandler()
- .isAllowed(this))
+ if (!getAccessControlHandler().isAllowed(this))
{
setResultCodeAndMessageNoInfoDisclosure(entryDN,
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -454,15 +437,8 @@
if (!isSynchronizationOperation())
{
executePostOpPlugins.set(true);
- PluginResult.PreOperation preOpResult =
- DirectoryServer.getPluginConfigManager()
- .invokePreOperationAddPlugins(this);
- if (!preOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePreOperationAddPlugins(this)))
{
- setResultCode(preOpResult.getResultCode());
- appendErrorMessage(preOpResult.getErrorMessage());
- setMatchedDN(preOpResult.getMatchedDN());
- setReferralURLs(preOpResult.getReferralURLs());
return;
}
}
@@ -477,19 +453,12 @@
}
else
{
- for (SynchronizationProvider<?> provider : DirectoryServer
- .getSynchronizationProviders())
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders())
{
try
{
- SynchronizationProviderResult result =
- provider.doPreOperation(this);
- if (!result.continueProcessing())
+ if (!processOperationResult(this, provider.doPreOperation(this)))
{
- setResultCode(result.getResultCode());
- appendErrorMessage(result.getErrorMessage());
- setMatchedDN(result.getMatchedDN());
- setReferralURLs(result.getReferralURLs());
return;
}
}
@@ -532,7 +501,7 @@
private void processSynchPostOperationPlugins()
{
- for (SynchronizationProvider<?> provider : DirectoryServer.getSynchronizationProviders())
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders())
{
try
{
@@ -1040,10 +1009,8 @@
entryDN, de.getMessageObject()));
}
- // Check if the current user has permission to make
- // this determination.
- if (!AccessControlConfigManager.getInstance().
- getAccessControlHandler().isAllowed(this, entry, filter))
+ // Check if the current user has permission to make this determination.
+ if (!getAccessControlHandler().isAllowed(this, entry, filter))
{
throw new DirectoryException(
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -1102,8 +1069,8 @@
}
}
- private DN getName(Entry e)
+ private AccessControlHandler<?> getAccessControlHandler()
{
- return e != null ? e.getName() : DN.rootDN();
+ return AccessControlConfigManager.getInstance().getAccessControlHandler();
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
index b3fe472..573980f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
@@ -39,7 +39,6 @@
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.SASLMechanismHandler;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.controls.*;
import org.opends.server.core.*;
import org.opends.server.types.*;
@@ -49,6 +48,7 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.types.AbstractOperation.*;
import static org.opends.server.types.Privilege.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -184,15 +184,7 @@
// Invoke the post-operation bind plugins.
if (executePostOpPlugins)
{
- PluginResult.PostOperation postOpResult =
- pluginConfigManager.invokePostOperationBindPlugins(this);
- if (!postOpResult.continueProcessing())
- {
- setResultCode(postOpResult.getResultCode());
- appendErrorMessage(postOpResult.getErrorMessage());
- setMatchedDN(postOpResult.getMatchedDN());
- setReferralURLs(postOpResult.getReferralURLs());
- }
+ processOperationResult(this, pluginConfigManager.invokePostOperationBindPlugins(this));
}
// Update the authentication information for the user.
@@ -753,17 +745,7 @@
private boolean invokePreOpPlugins()
{
executePostOpPlugins = true;
- PluginResult.PreOperation preOpResult = pluginConfigManager
- .invokePreOperationBindPlugins(this);
- if (!preOpResult.continueProcessing())
- {
- setResultCode(preOpResult.getResultCode());
- appendErrorMessage(preOpResult.getErrorMessage());
- setMatchedDN(preOpResult.getMatchedDN());
- setReferralURLs(preOpResult.getReferralURLs());
- return false;
- }
- return true;
+ return processOperationResult(this, pluginConfigManager.invokePreOperationBindPlugins(this));
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
index fcd9ffc..cb18057 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
@@ -25,32 +25,33 @@
* Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.workflowelement.localbackend;
-
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.api.Backend;
-import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
-import org.opends.server.controls.LDAPAssertionRequestControl;
-import org.opends.server.core.*;
+import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2;
import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.api.AccessControlHandler;
+import org.opends.server.api.Backend;
+import org.opends.server.api.ClientConnection;
+import org.opends.server.controls.LDAPAssertionRequestControl;
+import org.opends.server.core.*;
+import org.opends.server.types.*;
import org.opends.server.types.operation.PostOperationCompareOperation;
import org.opends.server.types.operation.PostResponseCompareOperation;
import org.opends.server.types.operation.PreOperationCompareOperation;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
+import static org.opends.server.types.AbstractOperation.*;
import static org.opends.server.util.ServerConstants.*;
/**
* This class defines an operation that may be used to determine whether a
- * specified entry in the Directory Server contains a given attribute-value
- * pair.
+ * specified entry in the Directory Server contains a given attribute-value pair.
*/
public class LocalBackendCompareOperation
extends CompareOperationWrapper
@@ -59,26 +60,13 @@
{
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-
- /**
- * The backend in which the comparison is to be performed.
- */
+ /** The backend in which the comparison is to be performed. */
private Backend<?> backend;
-
- /**
- * The client connection for this operation.
- */
+ /** The client connection for this operation. */
private ClientConnection clientConnection;
-
- /**
- * The DN of the entry to compare.
- */
+ /** The DN of the entry to compare. */
private DN entryDN;
-
- /**
- * The entry to be compared.
- */
+ /** The entry to be compared. */
private Entry entry;
@@ -139,16 +127,7 @@
// Invoke the post-operation compare plugins.
if (executePostOpPlugins.get())
{
- PluginResult.PostOperation postOpResult =
- DirectoryServer.getPluginConfigManager()
- .invokePostOperationComparePlugins(this);
- if (!postOpResult.continueProcessing())
- {
- setResultCode(postOpResult.getResultCode());
- appendErrorMessage(postOpResult.getErrorMessage());
- setMatchedDN(postOpResult.getMatchedDN());
- setReferralURLs(postOpResult.getReferralURLs());
- }
+ processOperationResult(this, getPluginConfigManager().invokePostOperationComparePlugins(this));
}
}
finally
@@ -223,8 +202,7 @@
// have already exposed sensitive information to the client.
try
{
- if (!AccessControlConfigManager.getInstance().getAccessControlHandler()
- .isAllowed(this))
+ if (!getAccessControlHandler().isAllowed(this))
{
setResultCodeAndMessageNoInfoDisclosure(entry, entryDN,
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -245,60 +223,30 @@
// Invoke the pre-operation compare plugins.
executePostOpPlugins.set(true);
- PluginResult.PreOperation preOpResult =
- DirectoryServer.getPluginConfigManager()
- .invokePreOperationComparePlugins(this);
- if (!preOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePreOperationComparePlugins(this)))
{
- setResultCode(preOpResult.getResultCode());
- appendErrorMessage(preOpResult.getErrorMessage());
- setMatchedDN(preOpResult.getMatchedDN());
- setReferralURLs(preOpResult.getReferralURLs());
return;
}
// Get the base attribute type and set of options.
Set<String> options = getAttributeOptions();
-
- // Actually perform the compare operation.
AttributeType attrType = getAttributeType();
+ // Actually perform the compare operation.
List<Attribute> attrList = entry.getAttribute(attrType, options);
if (attrList == null || attrList.isEmpty())
{
setResultCode(ResultCode.NO_SUCH_ATTRIBUTE);
- if (options == null)
- {
- appendErrorMessage(WARN_COMPARE_OP_NO_SUCH_ATTR.get(entryDN, getRawAttributeType()));
- }
- else
- {
- appendErrorMessage(WARN_COMPARE_OP_NO_SUCH_ATTR_WITH_OPTIONS.get(entryDN, getRawAttributeType()));
- }
+ Arg2<Object, Object> errorMsg = options == null
+ ? WARN_COMPARE_OP_NO_SUCH_ATTR
+ : WARN_COMPARE_OP_NO_SUCH_ATTR_WITH_OPTIONS;
+ appendErrorMessage(errorMsg.get(entryDN, getRawAttributeType()));
}
else
{
ByteString value = getAssertionValue();
-
- boolean matchFound = false;
- for (Attribute a : attrList)
- {
- if (a.contains(value))
- {
- matchFound = true;
- break;
- }
- }
-
- if (matchFound)
- {
- setResultCode(ResultCode.COMPARE_TRUE);
- }
- else
- {
- setResultCode(ResultCode.COMPARE_FALSE);
- }
+ setResultCode(matchExists(attrList, value));
}
}
catch (DirectoryException de)
@@ -308,6 +256,18 @@
}
}
+ private ResultCode matchExists(List<Attribute> attrList, ByteString value)
+ {
+ for (Attribute a : attrList)
+ {
+ if (a.contains(value))
+ {
+ return ResultCode.COMPARE_TRUE;
+ }
+ }
+ return ResultCode.COMPARE_FALSE;
+ }
+
private DirectoryException newDirectoryException(Entry entry,
ResultCode resultCode, LocalizableMessage message) throws DirectoryException
{
@@ -382,10 +342,8 @@
ERR_COMPARE_CANNOT_PROCESS_ASSERTION_FILTER.get(entryDN, de.getMessageObject()));
}
- // Check if the current user has permission to make
- // this determination.
- if (!AccessControlConfigManager.getInstance().
- getAccessControlHandler().isAllowed(this, entry, filter))
+ // Check if the current user has permission to make this determination.
+ if (!getAccessControlHandler().isAllowed(this, entry, filter))
{
throw new DirectoryException(
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -429,4 +387,9 @@
}
}
}
+
+ private AccessControlHandler<?> getAccessControlHandler()
+ {
+ return AccessControlConfigManager.getInstance().getAccessControlHandler();
+ }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java
index bf1e5ee..b9cf97a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java
@@ -32,10 +32,10 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.api.AccessControlHandler;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.SynchronizationProvider;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.controls.LDAPAssertionRequestControl;
import org.opends.server.controls.LDAPPreReadRequestControl;
import org.opends.server.core.AccessControlConfigManager;
@@ -43,21 +43,22 @@
import org.opends.server.core.DeleteOperationWrapper;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PersistentSearch;
-import org.opends.server.core.PluginConfigManager;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
+import org.opends.server.types.LockManager.DNLock;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.SynchronizationProviderResult;
-import org.opends.server.types.LockManager.DNLock;
import org.opends.server.types.operation.PostOperationDeleteOperation;
import org.opends.server.types.operation.PostResponseDeleteOperation;
import org.opends.server.types.operation.PostSynchronizationDeleteOperation;
import org.opends.server.types.operation.PreOperationDeleteOperation;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
+import static org.opends.server.types.AbstractOperation.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -145,25 +146,17 @@
processDelete(executePostOpPlugins);
// Invoke the post-operation or post-synchronization delete plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
if (isSynchronizationOperation())
{
if (getResultCode() == ResultCode.SUCCESS)
{
- pluginConfigManager.invokePostSynchronizationDeletePlugins(this);
+ getPluginConfigManager().invokePostSynchronizationDeletePlugins(this);
}
}
else if (executePostOpPlugins.get())
{
- PluginResult.PostOperation postOpResult =
- pluginConfigManager.invokePostOperationDeletePlugins(this);
- if (!postOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePostOperationDeletePlugins(this)))
{
- setResultCode(postOpResult.getResultCode());
- appendErrorMessage(postOpResult.getErrorMessage());
- setMatchedDN(postOpResult.getMatchedDN());
- setReferralURLs(postOpResult.getReferralURLs());
return;
}
}
@@ -232,8 +225,7 @@
return;
}
- // Check to see if the client has permission to perform the
- // delete.
+ // Check to see if the client has permission to perform the delete.
// Check to see if there are any controls in the request. If so, then
// see if there is any special processing required.
@@ -247,8 +239,7 @@
// have already exposed sensitive information to the client.
try
{
- if (!AccessControlConfigManager.getInstance().getAccessControlHandler()
- .isAllowed(this))
+ if (!getAccessControlHandler().isAllowed(this))
{
setResultCodeAndMessageNoInfoDisclosure(entry,
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -271,15 +262,8 @@
if (!isSynchronizationOperation())
{
executePostOpPlugins.set(true);
- PluginResult.PreOperation preOpResult =
- DirectoryServer.getPluginConfigManager()
- .invokePreOperationDeletePlugins(this);
- if (!preOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePreOperationDeletePlugins(this)))
{
- setResultCode(preOpResult.getResultCode());
- appendErrorMessage(preOpResult.getErrorMessage());
- setMatchedDN(preOpResult.getMatchedDN());
- setReferralURLs(preOpResult.getReferralURLs());
return;
}
}
@@ -353,6 +337,11 @@
}
}
+ private AccessControlHandler<?> getAccessControlHandler()
+ {
+ return AccessControlConfigManager.getInstance().getAccessControlHandler();
+ }
+
private DirectoryException newDirectoryException(Entry entry,
ResultCode resultCode, LocalizableMessage message) throws DirectoryException
{
@@ -427,10 +416,8 @@
ERR_DELETE_CANNOT_PROCESS_ASSERTION_FILTER.get(entryDN, de.getMessageObject()));
}
- // Check if the current user has permission to make
- // this determination.
- if (!AccessControlConfigManager.getInstance().
- getAccessControlHandler().isAllowed(this, entry, filter))
+ // Check if the current user has permission to make this determination.
+ if (!getAccessControlHandler().isAllowed(this, entry, filter))
{
throw new DirectoryException(
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -494,8 +481,7 @@
* {@code false} if not.
*/
private boolean handleConflictResolution() {
- for (SynchronizationProvider<?> provider :
- DirectoryServer.getSynchronizationProviders()) {
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders()) {
try {
SynchronizationProviderResult result =
provider.handleConflictResolution(this);
@@ -521,8 +507,7 @@
* Invoke post operation synchronization providers.
*/
private void processSynchPostOperationPlugins() {
- for (SynchronizationProvider<?> provider :
- DirectoryServer.getSynchronizationProviders()) {
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders()) {
try {
provider.doPostOperation(this);
} catch (DirectoryException de) {
@@ -541,16 +526,9 @@
* {@code false} if not.
*/
private boolean processPreOperation() {
- for (SynchronizationProvider<?> provider :
- DirectoryServer.getSynchronizationProviders()) {
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders()) {
try {
- SynchronizationProviderResult result =
- provider.doPreOperation(this);
- if (! result.continueProcessing()) {
- setResultCode(result.getResultCode());
- appendErrorMessage(result.getErrorMessage());
- setMatchedDN(result.getMatchedDN());
- setReferralURLs(result.getReferralURLs());
+ if (!processOperationResult(this, provider.doPreOperation(this))) {
return false;
}
} catch (DirectoryException de) {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
index 5f1fe7d..7f076b2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -40,7 +40,6 @@
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.SynchronizationProvider;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.controls.LDAPAssertionRequestControl;
import org.opends.server.controls.LDAPPostReadRequestControl;
import org.opends.server.controls.LDAPPreReadRequestControl;
@@ -49,7 +48,6 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyDNOperationWrapper;
import org.opends.server.core.PersistentSearch;
-import org.opends.server.core.PluginConfigManager;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
@@ -58,17 +56,18 @@
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
+import org.opends.server.types.LockManager.DNLock;
import org.opends.server.types.Modification;
import org.opends.server.types.RDN;
import org.opends.server.types.SearchFilter;
-import org.opends.server.types.SynchronizationProviderResult;
-import org.opends.server.types.LockManager.DNLock;
import org.opends.server.types.operation.PostOperationModifyDNOperation;
import org.opends.server.types.operation.PostResponseModifyDNOperation;
import org.opends.server.types.operation.PostSynchronizationModifyDNOperation;
import org.opends.server.types.operation.PreOperationModifyDNOperation;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
+import static org.opends.server.types.AbstractOperation.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -184,25 +183,17 @@
processModifyDN(executePostOpPlugins);
// Invoke the post-operation or post-synchronization modify DN plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
if (isSynchronizationOperation())
{
if (getResultCode() == ResultCode.SUCCESS)
{
- pluginConfigManager.invokePostSynchronizationModifyDNPlugins(this);
+ getPluginConfigManager().invokePostSynchronizationModifyDNPlugins(this);
}
}
else if (executePostOpPlugins.get())
{
- PluginResult.PostOperation postOpResult =
- pluginConfigManager.invokePostOperationModifyDNPlugins(this);
- if (!postOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePostOperationModifyDNPlugins(this)))
{
- setResultCode(postOpResult.getResultCode());
- appendErrorMessage(postOpResult.getErrorMessage());
- setMatchedDN(postOpResult.getMatchedDN());
- setReferralURLs(postOpResult.getReferralURLs());
return;
}
}
@@ -420,15 +411,8 @@
int modCount = modifications.size();
executePostOpPlugins.set(true);
- PluginResult.PreOperation preOpResult =
- DirectoryServer.getPluginConfigManager()
- .invokePreOperationModifyDNPlugins(this);
- if (!preOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePreOperationModifyDNPlugins(this)))
{
- setResultCode(preOpResult.getResultCode());
- appendErrorMessage(preOpResult.getErrorMessage());
- setMatchedDN(preOpResult.getMatchedDN());
- setReferralURLs(preOpResult.getReferralURLs());
return;
}
@@ -814,16 +798,9 @@
*/
private boolean handleConflictResolution()
{
- for (SynchronizationProvider<?> provider :
- DirectoryServer.getSynchronizationProviders()) {
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders()) {
try {
- SynchronizationProviderResult result =
- provider.handleConflictResolution(this);
- if (!result.continueProcessing()) {
- setResultCode(result.getResultCode());
- appendErrorMessage(result.getErrorMessage());
- setMatchedDN(result.getMatchedDN());
- setReferralURLs(result.getReferralURLs());
+ if (!processOperationResult(this, provider.handleConflictResolution(this))) {
return false;
}
} catch (DirectoryException de) {
@@ -845,16 +822,9 @@
*/
private boolean processPreOperation()
{
- for (SynchronizationProvider<?> provider :
- DirectoryServer.getSynchronizationProviders()) {
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders()) {
try {
- SynchronizationProviderResult result =
- provider.doPreOperation(this);
- if (! result.continueProcessing()) {
- setResultCode(result.getResultCode());
- appendErrorMessage(result.getErrorMessage());
- setMatchedDN(result.getMatchedDN());
- setReferralURLs(result.getReferralURLs());
+ if (!processOperationResult(this, provider.doPreOperation(this))) {
return false;
}
} catch (DirectoryException de) {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index 9cb0911..cd7d90a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -44,12 +44,12 @@
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Reject;
import org.forgerock.util.Utils;
+import org.opends.server.api.AccessControlHandler;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.SynchronizationProvider;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.controls.LDAPAssertionRequestControl;
import org.opends.server.controls.LDAPPostReadRequestControl;
import org.opends.server.controls.LDAPPreReadRequestControl;
@@ -62,7 +62,6 @@
import org.opends.server.core.PasswordPolicy;
import org.opends.server.core.PasswordPolicyState;
import org.opends.server.core.PersistentSearch;
-import org.opends.server.core.PluginConfigManager;
import org.opends.server.schema.AuthPasswordSyntax;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.AcceptRejectWarn;
@@ -91,6 +90,8 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.core.DirectoryServer.*;
+import static org.opends.server.types.AbstractOperation.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -310,31 +311,22 @@
// send the corresponding response control.
if (pwPolicyControlRequested)
{
- addResponseControl(new PasswordPolicyResponseControl(null, 0,
- pwpErrorType));
+ addResponseControl(new PasswordPolicyResponseControl(null, 0, pwpErrorType));
}
// Invoke the post-operation or post-synchronization modify plugins.
- PluginConfigManager pluginConfigManager =
- DirectoryServer.getPluginConfigManager();
if (isSynchronizationOperation())
{
if (getResultCode() == ResultCode.SUCCESS)
{
- pluginConfigManager.invokePostSynchronizationModifyPlugins(this);
+ getPluginConfigManager().invokePostSynchronizationModifyPlugins(this);
}
}
else if (executePostOpPlugins.get())
{
// FIXME -- Should this also be done while holding the locks?
- PluginResult.PostOperation postOpResult =
- pluginConfigManager.invokePostOperationModifyPlugins(this);
- if (!postOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePostOperationModifyPlugins(this)))
{
- setResultCode(postOpResult.getResultCode());
- appendErrorMessage(postOpResult.getErrorMessage());
- setMatchedDN(postOpResult.getMatchedDN());
- setReferralURLs(postOpResult.getReferralURLs());
return;
}
}
@@ -484,8 +476,7 @@
// already exposed sensitive information to the client.
try
{
- if (!AccessControlConfigManager.getInstance().getAccessControlHandler()
- .isAllowed(this))
+ if (!getAccessControlHandler().isAllowed(this))
{
setResultCodeAndMessageNoInfoDisclosure(modifiedEntry,
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -534,15 +525,8 @@
if (!isSynchronizationOperation())
{
executePostOpPlugins.set(true);
- PluginResult.PreOperation preOpResult =
- DirectoryServer.getPluginConfigManager()
- .invokePreOperationModifyPlugins(this);
- if (!preOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePreOperationModifyPlugins(this)))
{
- setResultCode(preOpResult.getResultCode());
- appendErrorMessage(preOpResult.getErrorMessage());
- setMatchedDN(preOpResult.getMatchedDN());
- setReferralURLs(preOpResult.getReferralURLs());
return;
}
}
@@ -606,6 +590,11 @@
}
}
+ private AccessControlHandler<?> getAccessControlHandler()
+ {
+ return AccessControlConfigManager.getInstance().getAccessControlHandler();
+ }
+
private DirectoryException newDirectoryException(Entry entry,
ResultCode resultCode, LocalizableMessage message) throws DirectoryException
{
@@ -682,10 +671,8 @@
entryDN, de.getMessageObject()));
}
- // Check if the current user has permission to make
- // this determination.
- if (!AccessControlConfigManager.getInstance().
- getAccessControlHandler().isAllowed(this, currentEntry, filter))
+ // Check if the current user has permission to make this determination.
+ if (!getAccessControlHandler().isAllowed(this, currentEntry, filter))
{
throw new DirectoryException(
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -1774,8 +1761,7 @@
* {@code false} if not.
*/
private boolean handleConflictResolution() {
- for (SynchronizationProvider<?> provider :
- DirectoryServer.getSynchronizationProviders()) {
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders()) {
try {
SynchronizationProviderResult result =
provider.handleConflictResolution(this);
@@ -1803,16 +1789,9 @@
* {@code false} if not.
*/
private boolean processPreOperation() {
- for (SynchronizationProvider<?> provider :
- DirectoryServer.getSynchronizationProviders()) {
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders()) {
try {
- SynchronizationProviderResult result =
- provider.doPreOperation(this);
- if (! result.continueProcessing()) {
- setResultCode(result.getResultCode());
- appendErrorMessage(result.getErrorMessage());
- setMatchedDN(result.getMatchedDN());
- setReferralURLs(result.getReferralURLs());
+ if (!processOperationResult(this, provider.doPreOperation(this))) {
return false;
}
} catch (DirectoryException de) {
@@ -1826,12 +1805,9 @@
return true;
}
- /**
- * Invoke post operation synchronization providers.
- */
+ /** Invoke post operation synchronization providers. */
private void processSynchPostOperationPlugins() {
- for (SynchronizationProvider<?> provider :
- DirectoryServer.getSynchronizationProviders()) {
+ for (SynchronizationProvider<?> provider : getSynchronizationProviders()) {
try {
provider.doPostOperation(this);
} catch (DirectoryException de) {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java
index 19b3b9a..7a4bd73 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java
@@ -30,19 +30,21 @@
import java.util.concurrent.atomic.AtomicBoolean;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.api.AccessControlHandler;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.plugin.PluginResult;
import org.opends.server.controls.*;
import org.opends.server.core.*;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.operation.PostOperationSearchOperation;
import org.opends.server.types.operation.PreOperationSearchOperation;
import org.opends.server.types.operation.SearchEntrySearchOperation;
import org.opends.server.types.operation.SearchReferenceSearchOperation;
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.core.DirectoryServer.*;
+import static org.opends.server.types.AbstractOperation.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -114,16 +116,7 @@
// Invoke the post-operation search plugins.
if (executePostOpPlugins.get())
{
- PluginResult.PostOperation postOpResult =
- DirectoryServer.getPluginConfigManager()
- .invokePostOperationSearchPlugins(this);
- if (!postOpResult.continueProcessing())
- {
- setResultCode(postOpResult.getResultCode());
- appendErrorMessage(postOpResult.getErrorMessage());
- setMatchedDN(postOpResult.getMatchedDN());
- setReferralURLs(postOpResult.getReferralURLs());
- }
+ processOperationResult(this, getPluginConfigManager().invokePostOperationSearchPlugins(this));
}
}
finally
@@ -160,16 +153,14 @@
}
- // Check to see if the client has permission to perform the
- // search.
+ // Check to see if the client has permission to perform the search.
// FIXME: for now assume that this will check all permission
// pertinent to the operation. This includes proxy authorization
// and any other controls specified.
try
{
- if (!AccessControlConfigManager.getInstance().getAccessControlHandler()
- .isAllowed(this))
+ if (!getAccessControlHandler().isAllowed(this))
{
setResultCode(ResultCode.INSUFFICIENT_ACCESS_RIGHTS);
appendErrorMessage(ERR_SEARCH_AUTHZ_INSUFFICIENT_ACCESS_RIGHTS.get(baseDN));
@@ -189,15 +180,8 @@
// Invoke the pre-operation search plugins.
executePostOpPlugins.set(true);
- PluginResult.PreOperation preOpResult =
- DirectoryServer.getPluginConfigManager()
- .invokePreOperationSearchPlugins(this);
- if (!preOpResult.continueProcessing())
+ if (!processOperationResult(this, getPluginConfigManager().invokePreOperationSearchPlugins(this)))
{
- setResultCode(preOpResult.getResultCode());
- appendErrorMessage(preOpResult.getErrorMessage());
- setMatchedDN(preOpResult.getMatchedDN());
- setReferralURLs(preOpResult.getReferralURLs());
return;
}
@@ -347,10 +331,8 @@
ERR_SEARCH_NO_SUCH_ENTRY_FOR_ASSERTION.get());
}
- // Check if the current user has permission to make
- // this determination.
- if (!AccessControlConfigManager.getInstance().
- getAccessControlHandler().isAllowed(this, entry, assertionFilter))
+ // Check if the current user has permission to make this determination.
+ if (!getAccessControlHandler().isAllowed(this, entry, assertionFilter))
{
throw new DirectoryException(
ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -439,9 +421,9 @@
}
}
- private DN getName(Entry e)
+ private AccessControlHandler<?> getAccessControlHandler()
{
- return e != null ? e.getName() : DN.rootDN();
+ return AccessControlConfigManager.getInstance().getAccessControlHandler();
}
/** Indicates if the backend supports the control corresponding to provided oid. */
--
Gitblit v1.10.0