mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Violette Roche-Montane
06.15.2013 d73c721e0be96c56728db0dfd404f1c433be3ffe
CR-2675 OPENDJ-1241 Server does not start after upgrade - Part II
- fixed upgrade (removed white spaces in upgrade tasks, added Filter instead of LDAPFilter, added matcher and setting schema default matching rule/syntax.)
3 files modified
45 ■■■■■ changed files
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java 16 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java 6 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java 23 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
@@ -103,7 +103,7 @@
    // @formatter:off
    register("2.5.0.6869",
        modifyConfigEntry(INFO_UPGRADE_TASK_6869_SUMMARY.get(),
        "(objectClass= ds-cfg-collation-matching-rule)",
        "(objectClass=ds-cfg-collation-matching-rule)",
        "add: ds-cfg-collation",
        "ds-cfg-collation: de:1.3.6.1.4.1.42.2.27.9.4.28.1",
        "ds-cfg-collation: de-DE:1.3.6.1.4.1.42.2.27.9.4.28.1",
@@ -114,7 +114,7 @@
    register("2.5.0.7192",
        modifyConfigEntry(INFO_UPGRADE_TASK_7192_SUMMARY.get(),
        "(objectClass= ds-cfg-password-policy)",
        "(objectClass=ds-cfg-password-policy)",
        "add: objectClass",
        "objectClass: ds-cfg-authentication-policy",
        "-",
@@ -123,7 +123,7 @@
    register("2.5.0.7364",
        modifyConfigEntry(INFO_UPGRADE_TASK_7364_SUMMARY.get(),
        "(ds-cfg-java-class= org.opends.server.loggers.TextAuditLogPublisher)",
        "(ds-cfg-java-class=org.opends.server.loggers.TextAuditLogPublisher)",
        "add: objectClass",
        "objectClass: ds-cfg-file-based-audit-log-publisher",
        "-",
@@ -167,7 +167,7 @@
    register("2.5.0.7979",
        modifyConfigEntry(INFO_UPGRADE_TASK_7979_SUMMARY.get(),
        "(ds-cfg-java-class= org.opends.server.schema.CertificateSyntax)",
        "(ds-cfg-java-class=org.opends.server.schema.CertificateSyntax)",
        "add: objectClass",
        "objectClass: ds-cfg-certificate-attribute-syntax",
        "-",
@@ -176,7 +176,7 @@
    register("2.5.0.8124",
        modifyConfigEntry(INFO_UPGRADE_TASK_8124_SUMMARY.get(),
        "(ds-cfg-java-class= org.opends.server.schema.JPEGSyntax)",
        "(ds-cfg-java-class=org.opends.server.schema.JPEGSyntax)",
        "add: objectClass",
        "objectClass: ds-cfg-jpeg-attribute-syntax",
        "-",
@@ -185,7 +185,7 @@
    register("2.5.0.8133",
        modifyConfigEntry(INFO_UPGRADE_TASK_8133_SUMMARY.get(),
        "(ds-cfg-java-class= org.opends.server.schema.CountryStringSyntax)",
        "(ds-cfg-java-class=org.opends.server.schema.CountryStringSyntax)",
        "add: objectClass",
        "objectClass: ds-cfg-country-string-attribute-syntax",
        "-",
@@ -206,13 +206,13 @@
    register("2.5.0.8387",
        modifyConfigEntry(INFO_UPGRADE_TASK_8387_SUMMARY.get(),
        "(objectClass= ds-cfg-dictionary-password-validator)",
        "(objectClass=ds-cfg-dictionary-password-validator)",
        "add: ds-cfg-check-substrings",
        "ds-cfg-check-substrings: false"));
    register("2.5.0.8389",
        modifyConfigEntry(INFO_UPGRADE_TASK_8389_SUMMARY.get(),
        "(objectClass= ds-cfg-attribute-value-password-validator)",
        "(objectClass=ds-cfg-attribute-value-password-validator)",
        "add: ds-cfg-check-substrings",
        "ds-cfg-check-substrings: false"));
opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -47,9 +47,9 @@
import javax.security.auth.callback.ConfirmationCallback;
import javax.security.auth.callback.TextOutputCallback;
import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException;
import org.opends.messages.Message;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.tools.ClientException;
import org.opends.server.tools.RebuildIndex;
import org.opends.server.util.BuildVersion;
@@ -907,8 +907,8 @@
                    Installation.CURRENT_CONFIG_FILE_NAME);
            final int changeCount =
                updateConfigFile(configFile.getPath(), LDAPFilter
                    .decode(filter), ChangeOperationType.MODIFY, ldif);
                updateConfigFile(configFile.getPath(), Filter.valueOf(filter),
                    ChangeOperationType.MODIFY, ldif);
            displayChangeCount(configFile.getPath(), changeCount);
opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -37,9 +37,9 @@
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy;
import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException;
import org.forgerock.opendj.ldif.EntryReader;
import org.forgerock.opendj.ldif.LDIF;
@@ -47,7 +47,6 @@
import org.forgerock.opendj.ldif.LDIFEntryWriter;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.util.ChangeOperationType;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.StaticUtils;
@@ -450,7 +449,7 @@
   * @return The changes number that have occurred.
   */
  static int updateConfigFile(final String configPath,
      final LDAPFilter filter, final ChangeOperationType changeType,
      final Filter filter, final ChangeOperationType changeType,
      final String... lines) throws IOException
  {
    final File original = new File(configPath);
@@ -462,8 +461,15 @@
    LDIFEntryWriter writer = null;
    try
    {
      entryReader = new LDIFEntryReader(new FileInputStream(configPath));
      entryReader.setSchemaValidationPolicy(SchemaValidationPolicy.ignoreAll());
      Schema schema =
          new SchemaBuilder(Schema.getCoreSchema()).defaultMatchingRule(
              CoreSchema.getCaseExactMatchingRule()).defaultSyntax(
              CoreSchema.getDirectoryStringSyntax()).toSchema()
              .asNonStrictSchema();
      entryReader =
          new LDIFEntryReader(new FileInputStream(configPath))
              .setSchema(schema);
      writer = new LDIFEntryWriter(new FileOutputStream(copyConfig));
      writer.setWrapColumn(80);
@@ -479,13 +485,14 @@
        // For an Add, the first line should start with dn:
        dn = lines[0].replaceFirst("dn: ","");
      }
      final Matcher matcher =
          filter != null ? filter.matcher(schema) : Filter.alwaysFalse()
              .matcher(schema);
      while (entryReader.hasNext())
      {
        Entry entry = entryReader.readEntry();
        // Searching for the related entries
        if (filter != null
            && Filter.valueOf(filter.toString()).matches(entry)
              == ConditionResult.TRUE)
        if (matcher.matches(entry) == ConditionResult.TRUE)
        {
          try
          {