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

Jean-Noël Rouvignac
21.08.2016 4aeaf5775f4edc7af87aa33058ae3db25d27f9a9
OPENDJ-3149 Upgrade 3.0.0 -> 4.0.0: Error in logs after upgrading a replication topology

UpgradeTasks.java:
In restoreCsvDelimiterAttributeTypeInConcatenatedSchemaFile(), also add the X-SCHEMA-FILE
when appending "ds-cfg-csv-delimiter-char" attribute type definition to the concatenated schema

SchemaBackend.java:
In removeAttributeType(), restore code that checked whether the attribute type to be removed
will be added back as part of the same change. This code has been lost during OPENDJ-1632.
2 files modified
46 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 42 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java 4 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -800,7 +800,7 @@
      for (ByteString v : a)
      {
        AttributeType type = newSchema.parseAttributeType(v.toString());
        removeAttributeType(type, newSchema, modifiedSchemaFiles);
        removeAttributeType(type, newSchema, mods, pos, modifiedSchemaFiles);
      }
    }
    else if (at.equals(objectClassesType))
@@ -1108,8 +1108,8 @@
   *                              the provided attribute type from the server
   *                              schema.
   */
  private void removeAttributeType(AttributeType attributeType, Schema schema, Set<String> modifiedSchemaFiles)
          throws DirectoryException
  private void removeAttributeType(AttributeType attributeType, Schema schema, List<Modification> modifications,
      int currentPosition, Set<String> modifiedSchemaFiles) throws DirectoryException
  {
    // See if the specified attribute type is actually defined in the server
    // schema.  If not, then fail.
@@ -1121,6 +1121,42 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // See if there is another modification later to add the attribute type back
    // into the schema. If so, then it's a replace and we should ignore the
    // remove because adding it back will handle the replace.
    for (int i = currentPosition + 1; i < modifications.size(); i++)
    {
      Modification m = modifications.get(i);
      Attribute a = m.getAttribute();
      if (m.getModificationType() != ModificationType.ADD
          || !a.getAttributeDescription().getAttributeType().equals(attributeTypesType))
      {
        continue;
      }
      for (ByteString v : a)
      {
        String oid;
        try
        {
          oid = Schema.parseOID(v.toString(), ERR_PARSING_ATTRIBUTE_TYPE_OID);
        }
        catch (DirectoryException de)
        {
          logger.traceException(de);
          throw de;
        }
        if (attributeType.getOID().equals(oid))
        {
          // We found a match where the attribute type is added back later,
          // so we don't need to do anything else here.
          return;
        }
      }
    }
    // Make sure that the attribute type isn't used as the superior type for
    // any other attributes.
    for (AttributeType at : schema.getAttributeTypes())
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -25,6 +25,7 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.tools.upgrade.FileManager.copy;
import static org.opends.server.tools.upgrade.UpgradeUtils.*;
import static org.opends.server.types.Schema.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.BufferedWriter;
@@ -1431,11 +1432,12 @@
        if (!configCsvCharAT.isPlaceHolder() && concatenatedCsvCharAT.isPlaceHolder())
        {
          final String csvCharAttrTypeDefinition = configCsvCharAT.toString().trim();
          try (BufferedWriter writer = Files.newBufferedWriter(concatenatedSchemaFile.toPath(), UTF_8, APPEND))
          {
            writer.append(CoreSchema.getAttributeTypesAttributeType().getNameOrOID());
            writer.append(": ");
            writer.append(configCsvCharAT.toString().trim());
            writer.append(addSchemaFileToElementDefinitionIfAbsent(csvCharAttrTypeDefinition, "02-config.ldif"));
            writer.newLine();
          }
          catch (IOException e)