| | |
| | | Logger.getLogger(Configuration.class.getName()); |
| | | |
| | | private String contents = null; |
| | | private String lowerCaseContents = null; |
| | | private Installation install = null; |
| | | private File file = null; |
| | | |
| | |
| | | */ |
| | | public int getReplicationPort() throws IOException { |
| | | int port = -1; |
| | | String contents = getContents(); |
| | | String contents = getLowerCaseContents(); |
| | | int index = contents.indexOf("cn=replication server"); |
| | | |
| | | if (index != -1) { |
| | |
| | | |
| | | 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) { |
| | |
| | | // 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; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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. |
| | | * |
| | |
| | | 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) |
| | |
| | | { |
| | | 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; |
| | | } |
| | |
| | | set.add(value); |
| | | } |
| | | |
| | | index1 = contents.indexOf(attrName, |
| | | index1 = lowerCaseContents.indexOf(attrName, |
| | | index1 + attrName.length()); |
| | | } |
| | | return set; |