From 64c92108755e3200a8ce2ba435a3191a58e6bc2e Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 11 Oct 2007 10:43:16 +0000
Subject: [PATCH] When reading the configuration file, get two String representations of the file: one in lower case to retrieve the attribute value position and the other respecting the case to get the actual values. With the previous code if a path contained capital letters the code failed and some paths under the installation appeared as external files.
---
opends/src/quicksetup/org/opends/quicksetup/Configuration.java | 39 +++++++++++++++++++++++++++------------
1 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Configuration.java b/opends/src/quicksetup/org/opends/quicksetup/Configuration.java
index 158be28..36caf7b 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Configuration.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Configuration.java
@@ -46,6 +46,7 @@
Logger.getLogger(Configuration.class.getName());
private String contents = null;
+ private String lowerCaseContents = null;
private Installation install = null;
private File file = null;
@@ -116,7 +117,7 @@
*/
public int getReplicationPort() throws IOException {
int port = -1;
- String contents = getContents();
+ String contents = getLowerCaseContents();
int index = contents.indexOf("cn=replication server");
if (index != -1) {
@@ -156,7 +157,7 @@
private int getLDAPPort(String portAttr) throws IOException {
int port = -1;
- String contents = getContents();
+ String contents = getLowerCaseContents();
int index = contents.indexOf("cn=ldap connection handler");
if (index != -1) {
@@ -199,7 +200,7 @@
// Note: a better way might be to diff this file with
// /config/ldif/upgrade/config.ldif.<svn rev>
isConfigFileModified =
- getContents().indexOf("# cddl header start") == -1;
+ getLowerCaseContents().indexOf("# cddl header start") == -1;
}
return isConfigFileModified;
@@ -263,6 +264,20 @@
}
/**
+ * Provides the contents of the config.ldif file in a lower case String.
+ *
+ * @return a lower case String representing the contents of the config.ldif
+ * file.
+ * @throws IOException if there was a problem reading the file
+ */
+ public String getLowerCaseContents() throws IOException {
+ if (lowerCaseContents == null) {
+ load();
+ }
+ return lowerCaseContents;
+ }
+
+ /**
* Returns the list of paths where the databases are installed as they appear
* in the configuration file.
*
@@ -298,7 +313,8 @@
buf.append(line).append(Constants.LINE_SEPARATOR);
}
reader.close();
- contents = buf.toString().toLowerCase();
+ contents = buf.toString();
+ lowerCaseContents = contents.toLowerCase();
}
private Set<String> getConfigurationValues(String attrName)
@@ -306,18 +322,17 @@
{
Set<String> set = new HashSet<String>();
attrName += ":";
+ String lowerCaseContents = getLowerCaseContents();
String contents = getContents();
- int index1 = contents.indexOf(attrName);
+ int index1 = lowerCaseContents.indexOf(attrName);
while (index1 != -1) {
- int index2 = contents.indexOf(Constants.LINE_SEPARATOR, index1);
+ int index2 = lowerCaseContents.indexOf(Constants.LINE_SEPARATOR, index1);
String value;
if (index2 > (index1 + attrName.length())) {
- value = contents.substring(attrName.length() + index1,
- index2).trim();
- } else if (contents.length() > (index1 + attrName.length())) {
+ value = contents.substring(attrName.length() + index1, index2).trim();
+ } else if (lowerCaseContents.length() > (index1 + attrName.length())) {
// Assume end of file
- value = contents.substring(
- attrName.length() + index1).trim();
+ value = contents.substring(attrName.length() + index1).trim();
} else {
value = null;
}
@@ -326,7 +341,7 @@
set.add(value);
}
- index1 = contents.indexOf(attrName,
+ index1 = lowerCaseContents.indexOf(attrName,
index1 + attrName.length());
}
return set;
--
Gitblit v1.10.0