From 00d37e85955e374be365f1c34de5af1f69a6476c Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 07 May 2013 13:50:59 +0000
Subject: [PATCH] svn merge https://svn.forgerock.org/opendj/trunk/opends@8851 https://svn.forgerock.org/opendj/branches/native-packaging@8851 .

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Configuration.java |   70 ++++++++++++++--------------------
 1 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Configuration.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Configuration.java
index c976104..eb8bfd0 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Configuration.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Configuration.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
+ *      Portions Copyright 2013 ForgeRock AS.
  */
 
 package org.opends.quicksetup;
@@ -163,58 +164,45 @@
     return getConfigurationValues("ds-cfg-log-file");
   }
 
-  private int getLDAPPort(String portAttr) throws IOException {
+  private int extractPort(String portAttr, int index)
+  {
     int port = -1;
-    String contents = getLowerCaseContents();
-    int index = contents.indexOf("cn=ldap connection handler");
-
-    if (index != -1) {
-      String attrWithPoints = portAttr + ":";
-      int index1 = contents.indexOf(attrWithPoints, index);
-      if (index1 != -1) {
-        int index2 =
-                contents.indexOf(Constants.LINE_SEPARATOR, index1);
-        if (index2 != -1) {
-          String sPort =
-                  contents.substring(attrWithPoints.length() +
-                          index1,
-                          index2).trim();
-          try {
-            port = Integer.parseInt(sPort);
-          } catch (NumberFormatException nfe) {
-            // do nothing;
-          }
+    String attrWithPoints = portAttr + ":";
+    int index1 = contents.indexOf(attrWithPoints, index);
+    if (index1 != -1) {
+      int index2 =
+        contents.indexOf(Constants.LINE_SEPARATOR, index1);
+      if (index2 != -1) {
+        String sPort =
+          contents.substring(attrWithPoints.length() +
+              index1, index2).trim();
+        try {
+          port = Integer.parseInt(sPort);
+        } catch (NumberFormatException nfe) {
+          // do nothing;
         }
       }
     }
     return port;
   }
 
+
+  private int getLDAPPort(String portAttr) throws IOException {
+    String contents = getLowerCaseContents();
+    int index = contents.indexOf("cn=ldap connection handler");
+    if (index != -1) {
+      return extractPort (portAttr, index);
+    }
+    return -1;
+  }
+
   private int getAdminConnectorPort(String portAttr) throws IOException {
-    int port = -1;
     String contents = getLowerCaseContents();
     int index = contents.indexOf("cn=administration connector");
-
     if (index != -1) {
-      String attrWithPoints = portAttr + ":";
-      int index1 = contents.indexOf(attrWithPoints, index);
-      if (index1 != -1) {
-        int index2 =
-                contents.indexOf(Constants.LINE_SEPARATOR, index1);
-        if (index2 != -1) {
-          String sPort =
-                  contents.substring(attrWithPoints.length() +
-                          index1,
-                          index2).trim();
-          try {
-            port = Integer.parseInt(sPort);
-          } catch (NumberFormatException nfe) {
-            // do nothing;
-          }
-        }
-      }
+      return extractPort(portAttr, index);
     }
-    return port;
+    return -1;
   }
 
   /**
@@ -235,7 +223,7 @@
       // Note: a better way might be to diff this file with
       // /config/ldif/upgrade/config.ldif.<svn rev>
       isConfigFileModified =
-              getLowerCaseContents().indexOf("# cddl header start") == -1;
+          !getLowerCaseContents().contains("# cddl header start");
     }
 
     return isConfigFileModified;

--
Gitblit v1.10.0