From 959f728f4cc9d1b0e09ae7b99abf2457ac43e807 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 03 Aug 2016 16:05:42 +0000
Subject: [PATCH] OPENDJ-3205 Control-panel: fix java-settings

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
index 77ea9c8..36723de 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -1467,6 +1467,28 @@
   }
 
   /**
+   * Returns the attribute name with no options (or subtypes).
+   * <p>
+   * Note: normal code should use <code>AttributeDescription.valueOf(attrName).getNameOrOID()</code>
+   * <p>
+   * However this method is used by UI code which sometimes receives strings which are not valid
+   * attribute descriptions.
+   *
+   * @param attrDesc
+   *          the complete attribute name.
+   * @return the attribute name with no options (or subtypes).
+   */
+  public static String getAttributeNameWithoutOptions(String attrDesc)
+  {
+    int index = attrDesc.indexOf(";");
+    if (index != -1)
+    {
+      return attrDesc.substring(0, index);
+    }
+    return attrDesc;
+  }
+
+  /**
    * Strings any potential "separator" from a given string.
    * @param s string to strip
    * @param separator  the separator string to remove
@@ -1474,7 +1496,7 @@
    */
   private static String stripStringToSingleLine(String s, String separator)
   {
-    return (s == null) ? null : s.replaceAll(separator, "");
+    return (s != null) ? s.replaceAll(separator, "") : null;
   }
 
   /** The pattern for control characters. */

--
Gitblit v1.10.0