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

Jean-Noël Rouvignac
21.08.2016 4aeaf5775f4edc7af87aa33058ae3db25d27f9a9
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())