From a997a5af5785ee040a9ef2bca66904c7624c0b60 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 29 Feb 2016 12:57:49 +0000
Subject: [PATCH] OPENDJ-2688 Upgrade: Error in matching rule when starting server after upgrade
---
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java | 47 +++++++++++++++++++++++
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java | 16 +++----
opendj-server-legacy/src/messages/org/opends/messages/tool.properties | 1
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java | 42 +++++++++++++++-----
4 files changed, 86 insertions(+), 20 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
index 9089f82..7a332cf 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/Upgrade.java
@@ -580,6 +580,53 @@
"ds-cfg-java-class: org.opends.server.extensions.BcryptPasswordStorageScheme",
"ds-cfg-enabled: true"));
+ /** See OPENDJ-2683 */
+ register("4.0.0",
+ deleteConfigEntry(INFO_UPGRADE_TASK_REMOVE_MATCHING_RULES.get(),
+ "cn=Auth Password Exact Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Bit String Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Boolean Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Exact Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Exact Ordering Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Exact Substring Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Exact IA5 Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Exact IA5 Substring Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Ignore Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Ignore Ordering Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Ignore Substring Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Ignore IA5 Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Ignore IA5 Substring Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Ignore List Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Case Ignore List Substring Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Certificate Exact Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Directory String First Component Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Distinguished Name Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Double Metaphone Approximate Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Generalized Time Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Generalized Time Ordering Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Integer Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Integer Ordering Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Integer First Component Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Keyword Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Numeric String Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Numeric String Ordering Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Numeric String Substring Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Object Identifier Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Object Identifier First Component Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Octet String Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Octet String Ordering Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Octet String Substring Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Presentation Address Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Protocol Information Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Telephone Number Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Telephone Number Substring Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Time Based Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Unique Member Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=User Password Exact Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=UUID Equality Matching Rule,cn=Matching Rules,cn=config",
+ "cn=UUID Ordering Matching Rule,cn=Matching Rules,cn=config",
+ "cn=Word Equality Matching Rule,cn=Matching Rules,cn=config"));
+
/**
* All upgrades will refresh the server configuration schema and generate a new upgrade folder.
*/
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
index 7bfdb7e..e78e571 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -195,20 +195,18 @@
}
/**
- * Returns a new upgrade task which deletes a config entry from the underlying
- * config file.
+ * Returns a new upgrade task which deletes a config entry from the underlying config file.
*
* @param summary
* The summary of this upgrade task.
- * @param dnInLDIF
- * The dn to delete in the form of LDIF.
- * @return A new upgrade task which applies an LDIF record to all
- * configuration entries matching the provided filter.
+ * @param dnsInLDIF
+ * The dns to delete in the form of LDIF.
+ * @return A new upgrade task which applies an LDIF record to all configuration entries matching
+ * the provided filter.
*/
- public static UpgradeTask deleteConfigEntry(final LocalizableMessage summary,
- final String dnInLDIF)
+ public static UpgradeTask deleteConfigEntry(final LocalizableMessage summary, final String... dnsInLDIF)
{
- return updateConfigEntry(summary, null, ChangeOperationType.DELETE, dnInLDIF);
+ return updateConfigEntry(summary, null, ChangeOperationType.DELETE, dnsInLDIF);
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java
index b3d87e0..6699965 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -23,8 +23,10 @@
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -401,13 +403,29 @@
writer.writeComment(INFO_CONFIG_FILE_HEADER.get());
writer.setWrapColumn(0);
- boolean entryAlreadyExist = false;
DN ldifDN = null;
- if (filter == null && (changeType == ADD || changeType == DELETE))
+ Set<DN> ldifDNs = new HashSet<>();
+ if (filter == null)
{
- // The first line should start with dn:
- ldifDN = DN.valueOf(ldifLines[0].replaceFirst("dn: ", ""));
+ switch (changeType)
+ {
+ case ADD:
+ // The first line should start with dn:
+ ldifDN = DN.valueOf(removeDnPrefix(ldifLines[0]));
+ ldifDNs.add(ldifDN);
+ break;
+
+ case DELETE:
+ // All lines represent dns
+ for (String dnLine : ldifLines)
+ {
+ ldifDNs.add(DN.valueOf(removeDnPrefix(dnLine)));
+ }
+ break;
+ }
}
+
+ boolean entryAlreadyExist = false;
final Filter f = filter != null ? filter : Filter.alwaysFalse();
final Matcher matcher = f.matcher(schema);
while (entryReader.hasNext())
@@ -424,8 +442,7 @@
readLDIFLines(entryDN, changeType, ldifLines));
entry = Entries.modifyEntryPermissive(entry, mr.getModifications());
changeCount++;
- logger.debug(LocalizableMessage.raw(
- "The following entry has been modified : %s", entryDN));
+ logger.debug(LocalizableMessage.raw("The following entry has been modified : %s", entryDN));
}
catch (Exception ex)
{
@@ -433,7 +450,7 @@
}
}
- if (entryDN.equals(ldifDN))
+ if (ldifDNs.remove(entryDN))
{
logger.debug(LocalizableMessage.raw("Entry %s found", entryDN));
entryAlreadyExist = true;
@@ -442,8 +459,7 @@
{
entry = null;
changeCount++;
- logger.debug(LocalizableMessage.raw(
- "The following entry has been deleted : %s", entryDN));
+ logger.debug(LocalizableMessage.raw("The following entry has been deleted : %s", entryDN));
}
}
@@ -457,8 +473,7 @@
{
final AddRequest ar = Requests.newAddRequest(ldifLines);
writer.writeEntry(ar);
- logger.debug(LocalizableMessage.raw("Entry successfully added %s in %s",
- ldifDN, original.getAbsolutePath()));
+ logger.debug(LocalizableMessage.raw("Entry successfully added %s in %s", ldifDN, original.getAbsolutePath()));
changeCount++;
}
}
@@ -485,6 +500,11 @@
return changeCount;
}
+ private static String removeDnPrefix(String dnLine)
+ {
+ return dnLine.replaceFirst("dn: ", "");
+ }
+
/**
* This task adds new attributes / object classes to the specified destination
* file. The new attributes and object classes must be originally defined in
diff --git a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
index adbb9b3..e4fd49a 100644
--- a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
+++ b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
@@ -2620,6 +2620,7 @@
INFO_UPGRADE_TASK_RENAME_JE_DB_DIR_20022=Renaming local-db backend directory '%s' to '%s'
INFO_UPGRADE_TASK_RENAME_JE_DB_DIR_WARNING_20023=You must reimport all your data into the PDB \
backends in order to have a fully functional server
+INFO_UPGRADE_TASK_REMOVE_MATCHING_RULES_2683=Removing configuration for matching rules
INFO_LDAP_CONN_PROMPT_SECURITY_LDAP=LDAP
INFO_LDAP_CONN_PROMPT_SECURITY_USE_SSL=LDAP with SSL
--
Gitblit v1.10.0