From 0326322b342aa2dea86f71760521022411739879 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Wed, 19 Dec 2007 14:13:39 +0000
Subject: [PATCH] Fix issue 2451 part #1: https://opends.dev.java.net/issues/show_bug.cgi?id=2451

---
 opends/src/server/org/opends/server/tools/dsconfig/CLIProfile.java |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/dsconfig/CLIProfile.java b/opends/src/server/org/opends/server/tools/dsconfig/CLIProfile.java
index 86a9fe0..0ce6927 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/CLIProfile.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/CLIProfile.java
@@ -34,6 +34,7 @@
 import java.util.Set;
 
 import org.opends.server.admin.AbstractManagedObjectDefinition;
+import org.opends.server.admin.InstantiableRelationDefinition;
 import org.opends.server.admin.ManagedObjectDefinitionResource;
 import org.opends.server.admin.RelationDefinition;
 
@@ -42,7 +43,7 @@
 /**
  * This class is used to access CLI profile annotations.
  */
-class CLIProfile {
+final class CLIProfile {
 
   // The singleton instance.
   private static final CLIProfile INSTANCE = new CLIProfile();
@@ -88,6 +89,39 @@
 
 
   /**
+   * Gets the naming argument which should be used for a relation
+   * definition.
+   *
+   * @param r
+   *          The relation definition.
+   * @return Returns the naming argument which should be used for a
+   *         relation definition.
+   */
+  public String getNamingArgument(InstantiableRelationDefinition<?, ?> r) {
+    String s = resource.getString(r.getParentDefinition(),
+        "relation." + r.getName() + ".naming-argument-override").trim();
+
+    if (s.length() == 0) {
+      // Use the last word in the managed object name as the argument
+      // prefix.
+      StringBuilder builder = new StringBuilder();
+      s = r.getChildDefinition().getName();
+      int i = s.lastIndexOf('-');
+      if (i < 0 || i == (s.length() - 1)) {
+        builder.append(s);
+      } else {
+        builder.append(s.substring(i + 1));
+      }
+      builder.append("-name");
+      s = builder.toString();
+    }
+
+    return s;
+  }
+
+
+
+  /**
    * Determines if instances of the specified managed object
    * definition are to be used for customization.
    *

--
Gitblit v1.10.0