From 4afd3e991cb2de35cd0e58ea282cfdd6a75347b5 Mon Sep 17 00:00:00 2001
From: floblanc <floblanc@localhost>
Date: Tue, 02 Dec 2008 14:04:45 +0000
Subject: [PATCH] Add methods to read the configuration parameters from Network group resource limit.

---
 opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java |   46 +++++++++++++++++++++++
 opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java   |   48 +++++++++++++++++++++++
 2 files changed, 93 insertions(+), 1 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java b/opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
index 9e1ab1a..a827ddc 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
@@ -25,6 +25,7 @@
  *      Copyright 2007-2008 Sun Microsystems, Inc.
  */
 package org.opends.server.core.networkgroups;
+
 import org.opends.messages.Message;
 import static org.opends.messages.CoreMessages.*;
 import static org.opends.server.util.Validator.ensureNotNull;
@@ -34,6 +35,10 @@
 import java.util.TreeMap;
 import java.util.Collection;
 
+import org.opends.server.admin.std.meta.
+        NetworkGroupResourceLimitsCfgDefn.ReferralBindPolicy;
+import org.opends.server.admin.std.meta.
+        NetworkGroupResourceLimitsCfgDefn.ReferralPolicy;
 import org.opends.server.api.ClientConnection;
 import org.opends.server.core.*;
 import org.opends.server.protocols.ldap.LDAPMessage;
@@ -44,7 +49,6 @@
 import org.opends.server.types.operation.PreParseOperation;
 import org.opends.server.workflowelement.WorkflowElement;
 
-
 /**
  * This class defines the network group. A network group is used to categorize
  * client connections. A network group is defined by a set of criteria, a
@@ -852,6 +856,48 @@
     return 0;
   }
 
+  /**
+   * Gets the referral policy. The referral policy defines the behavior
+   * when a referral or a search continuation reference is received.
+   * The referral can either be discarded (ie an error is returned to the
+   * client), forwarded (ie the result is passed as-is to the client) or
+   * followed (ie the server contacts the server targeted by the referral to
+   * pursue the request).
+   * @return the referral policy for this network group
+   */
+  public ReferralPolicy getReferralPolicy() {
+    if (resourceLimits != null) {
+      return resourceLimits.getReferralPolicy();
+    }
+    return ReferralPolicy.FORWARD;
+  }
+
+  /**
+   * Gets the referral bind policy. The referral bind policy defines
+   * the bind credentials used when the server tries to follow a referral. It
+   * can either bind to the referred server anonymously, or using the same
+   * credentials as in the original request.
+   * @return the referral binf policy
+   */
+  public ReferralBindPolicy getReferralBindPolicy() {
+    if (resourceLimits != null) {
+      return resourceLimits.getReferralBindPolicy();
+    }
+    return ReferralBindPolicy.ANONYMOUS;
+  }
+
+  /**
+   * Gets the referral hop limit. When configured to follow referrals,
+   * the request to the referred server can also contain a referral. The hop
+   * limit is the maximum number of subsequent operations.
+   * @return the referral hop limit
+   */
+  public int getReferralHopLimit() {
+    if (resourceLimits != null) {
+      return resourceLimits.getReferralHopLimit();
+    }
+    return 0;
+  }
 
   /**
    * Checks the request filtering policy.
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java b/opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java
index b8687f8..b1f116b 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/core/networkgroups/ResourceLimits.java
@@ -33,6 +33,10 @@
 import org.opends.server.admin.server.ConfigurationAddListener;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.server.ConfigurationDeleteListener;
+import org.opends.server.admin.std.meta.
+        NetworkGroupResourceLimitsCfgDefn.ReferralBindPolicy;
+import org.opends.server.admin.std.meta.
+        NetworkGroupResourceLimitsCfgDefn.ReferralPolicy;
 import org.opends.server.admin.std.server.NetworkGroupResourceLimitsCfg;
 import org.opends.server.api.ClientConnection;
 import org.opends.server.types.ByteString;
@@ -78,6 +82,15 @@
   // The minimum substring length in a search
   private int minSearchSubstringLength;
 
+  // The referral policy
+  private ReferralPolicy referralPolicy = ReferralPolicy.FORWARD;
+
+  // The referral policy
+  private ReferralBindPolicy referralBindPolicy = ReferralBindPolicy.ANONYMOUS;
+
+  // The referral hop limit
+  private int referralHopLimit = 0;
+
   // The number of connections in the group
   private int numConnections = 0;
 
@@ -118,6 +131,11 @@
     searchSizeLimit = -1;
     searchTimeLimit = -1;
     minSearchSubstringLength = 0;
+
+    referralPolicy = ReferralPolicy.FORWARD;
+    referralBindPolicy = ReferralBindPolicy.ANONYMOUS;
+    referralHopLimit = 0;
+
     isConfigured = false;
     if (config != null) {
       config.removeChangeListener(this);
@@ -152,6 +170,10 @@
       }
       minSearchSubstringLength = resourcesCfg.getMinSubstringLength();
 
+      referralPolicy = resourcesCfg.getReferralPolicy();
+      referralBindPolicy = resourcesCfg.getReferralBindPolicy();
+      referralHopLimit = resourcesCfg.getReferralHopLimit();
+
       if (config == null) {
         resourcesCfg.addChangeListener(this);
       }
@@ -254,6 +276,30 @@
   }
 
   /**
+   * Returns the referral policy.
+   * @return referral policy
+   */
+  public ReferralPolicy getReferralPolicy() {
+    return referralPolicy;
+  }
+
+  /**
+   * Returns the referralBindPolicy.
+   * @return referral bind policy
+   */
+  public ReferralBindPolicy getReferralBindPolicy() {
+    return referralBindPolicy;
+  }
+
+  /**
+   * Returns the referral hop limit.
+   * @return referral hop limit
+   */
+  public int getReferralHopLimit() {
+    return referralHopLimit;
+  }
+
+  /**
    * Adds a connection to the resource group.
    *
    * @param connection the ClientConnection to ad

--
Gitblit v1.10.0