From a425b353d3888ba91e9e022717f7e4ad13e27f9a Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 20 Sep 2007 20:54:36 +0000
Subject: [PATCH] Update the local backend modify processing to break out the account status notifications into a separate method, which helps improve performance and make garbage collection more stable and predictable.
---
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java | 161 +++++++++++++++++++++++++++++++----------------------
1 files changed, 94 insertions(+), 67 deletions(-)
diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
index c6f4b33..8200408 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
@@ -469,11 +469,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, de);
}
- localOp.setResultCode(de.getResultCode());
- localOp.appendErrorMessage(de.getMessageObject());
- localOp.setMatchedDN(de.getMatchedDN());
- localOp.setReferralURLs(de.getReferralURLs());
-
+ localOp.setResponseData(de);
break modifyProcessing;
}
@@ -2291,70 +2287,15 @@
backend.replaceEntry(modifiedEntry, localOp);
- // If the modification was successful, then see if there's any other
- // work that we need to do here before handing off to postop
- // plugins.
- if (passwordChanged)
- {
- if (selfChange)
- {
- AuthenticationInfo authInfo =
- clientConnection.getAuthenticationInfo();
- if (authInfo.getAuthenticationDN().equals(entryDN))
- {
- clientConnection.setMustChangePassword(false);
- }
- Message message = INFO_MODIFY_PASSWORD_CHANGED.get();
- pwPolicyState.generateAccountStatusNotification(
- AccountStatusNotificationType.PASSWORD_CHANGED,
- modifiedEntry, message,
- AccountStatusNotification.createProperties(pwPolicyState,
- false, -1, localOp.getCurrentPasswords(),
- localOp.getNewPasswords()));
- }
- else
- {
- Message message = INFO_MODIFY_PASSWORD_RESET.get();
- pwPolicyState.generateAccountStatusNotification(
- AccountStatusNotificationType.PASSWORD_RESET, modifiedEntry,
- message,
- AccountStatusNotification.createProperties(pwPolicyState,
- false, -1, localOp.getCurrentPasswords(),
- localOp.getNewPasswords()));
- }
- }
-
- if (enabledStateChanged)
+ // See if we need to generate any account status notifications as a
+ // result of the changes.
+ if (passwordChanged || enabledStateChanged || wasLocked)
{
- if (isEnabled)
- {
- Message message = INFO_MODIFY_ACCOUNT_ENABLED.get();
- pwPolicyState.generateAccountStatusNotification(
- AccountStatusNotificationType.ACCOUNT_ENABLED,
- modifiedEntry, message,
- AccountStatusNotification.createProperties(pwPolicyState,
- false, -1, null, null));
- }
- else
- {
- Message message = INFO_MODIFY_ACCOUNT_DISABLED.get();
- pwPolicyState.generateAccountStatusNotification(
- AccountStatusNotificationType.ACCOUNT_DISABLED,
- modifiedEntry, message,
- AccountStatusNotification.createProperties(pwPolicyState,
- false, -1, null, null));
- }
- }
-
- if (wasLocked)
- {
- Message message = INFO_MODIFY_ACCOUNT_UNLOCKED.get();
- pwPolicyState.generateAccountStatusNotification(
- AccountStatusNotificationType.ACCOUNT_UNLOCKED, modifiedEntry,
- message,
- AccountStatusNotification.createProperties(pwPolicyState,
- false, -1, null, null));
+ handleAccountStatusNotifications(passwordChanged, selfChange,
+ enabledStateChanged, isEnabled,
+ wasLocked, localOp,
+ pwPolicyState, modifiedEntry);
}
}
@@ -2603,6 +2544,92 @@
}
/**
+ * Handles any account status notifications that may be needed as a result of
+ * modify processing using the provided information.
+ *
+ * @param passwordChanged Indicates whether the modify operation
+ * included a password change.
+ * @param selfChange Indicates whether the password change was
+ * performed by the end user or an administrator.
+ * @param enabledStateChanged Indicates whether the user's account changed
+ * from enabled to disabled (or vice versa)
+ * @param isEnabled Indicates whether the user's account is now
+ * enabled.
+ * @param wasLocked Indicates whether the user's account was
+ * previously locked.
+ * @param localOp The modify operation being processed.
+ * @param pwPolicyState The password policy state for the user.
+ * @param modifiedEntry The updated version of the entry.
+ */
+ private void handleAccountStatusNotifications(boolean passwordChanged,
+ boolean selfChange, boolean enabledStateChanged,
+ boolean isEnabled, boolean wasLocked,
+ LocalBackendModifyOperation localOp,
+ PasswordPolicyState pwPolicyState, Entry modifiedEntry)
+ {
+ if (passwordChanged)
+ {
+ if (selfChange)
+ {
+ AuthenticationInfo authInfo =
+ localOp.getClientConnection().getAuthenticationInfo();
+ if (authInfo.getAuthenticationDN().equals(modifiedEntry.getDN()))
+ {
+ localOp.getClientConnection().setMustChangePassword(false);
+ }
+
+ Message message = INFO_MODIFY_PASSWORD_CHANGED.get();
+ pwPolicyState.generateAccountStatusNotification(
+ AccountStatusNotificationType.PASSWORD_CHANGED,
+ modifiedEntry, message,
+ AccountStatusNotification.createProperties(pwPolicyState, false, -1,
+ localOp.getCurrentPasswords(), localOp.getNewPasswords()));
+ }
+ else
+ {
+ Message message = INFO_MODIFY_PASSWORD_RESET.get();
+ pwPolicyState.generateAccountStatusNotification(
+ AccountStatusNotificationType.PASSWORD_RESET, modifiedEntry,
+ message,
+ AccountStatusNotification.createProperties(pwPolicyState, false, -1,
+ localOp.getCurrentPasswords(), localOp.getNewPasswords()));
+ }
+ }
+
+ if (enabledStateChanged)
+ {
+ if (isEnabled)
+ {
+ Message message = INFO_MODIFY_ACCOUNT_ENABLED.get();
+ pwPolicyState.generateAccountStatusNotification(
+ AccountStatusNotificationType.ACCOUNT_ENABLED,
+ modifiedEntry, message,
+ AccountStatusNotification.createProperties(pwPolicyState, false, -1,
+ null, null));
+ }
+ else
+ {
+ Message message = INFO_MODIFY_ACCOUNT_DISABLED.get();
+ pwPolicyState.generateAccountStatusNotification(
+ AccountStatusNotificationType.ACCOUNT_DISABLED,
+ modifiedEntry, message,
+ AccountStatusNotification.createProperties(pwPolicyState, false, -1,
+ null, null));
+ }
+ }
+
+ if (wasLocked)
+ {
+ Message message = INFO_MODIFY_ACCOUNT_UNLOCKED.get();
+ pwPolicyState.generateAccountStatusNotification(
+ AccountStatusNotificationType.ACCOUNT_UNLOCKED, modifiedEntry,
+ message,
+ AccountStatusNotification.createProperties(pwPolicyState, false, -1,
+ null, null));
+ }
+ }
+
+ /**
* Perform a search operation against a local backend.
*
* @param operation - The operation to perform
--
Gitblit v1.10.0