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

Nicolas Capponi
12.50.2016 0ea193c303a1553fbde5a1637d40bfb46c8e5b73
opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaFilesWriter.java
@@ -16,6 +16,9 @@
 */
package org.opends.server.schema;
import static org.opends.server.util.SchemaUtils.is02ConfigLdif;
import static org.opends.server.util.SchemaUtils.parseSchemaFileFromElementDefinition;
import static org.forgerock.opendj.ldap.ModificationType.ADD;
import static org.forgerock.opendj.ldap.ModificationType.DELETE;
import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
@@ -228,7 +231,7 @@
        // so we don't re-find these same changes on the next startup.
        writeConcatenatedSchema();
      }
      return mods;
      return filterOutConfigSchemaElementFromModifications(mods);
    }
    catch (InitializationException ie)
    {
@@ -243,6 +246,29 @@
    }
  }
  private List<Modification> filterOutConfigSchemaElementFromModifications(final List<Modification> mods)
      throws DirectoryException
  {
    final List<Modification> filteredMods = new ArrayList<>();
    for (Modification modification : mods)
    {
      for (ByteString v : modification.getAttribute())
      {
        String definition = v.toString();
        if (!isFrom02ConfigLdif(definition))
        {
          filteredMods.add(modification);
        }
      }
    }
    return filteredMods;
  }
  private boolean isFrom02ConfigLdif(String definition) throws DirectoryException
  {
    return is02ConfigLdif(parseSchemaFileFromElementDefinition(definition));
  }
  /**
   * Writes a single file containing all schema element definitions, which can be used on startup to
   * determine whether the schema files were edited with the server offline.