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. opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaHandler.java
@@ -15,6 +15,8 @@ */ package org.opends.server.schema; import static org.opends.server.util.SchemaUtils.is02ConfigLdif; import static java.util.Collections.emptyList; import static org.opends.messages.ConfigMessages.*; import static org.opends.messages.SchemaMessages.*; @@ -109,7 +111,6 @@ private static final String CORE_SCHEMA_PROVIDER_NAME = "Core Schema"; private static final String CORE_SCHEMA_FILE = "00-core.ldif"; private static final String RFC_3112_SCHEMA_FILE = "03-rfc3112.ldif"; private static final String CONFIG_SCHEMA_ELEMENTS_FILE = "02-config.ldif"; private static final String CORE_SCHEMA_ELEMENTS_FILE = "00-core.ldif"; private static final AttributeType attributeTypesType = CoreSchema.getAttributeTypesAttributeType(); @@ -569,10 +570,8 @@ { String definition = v.toString(); String schemaFile = SchemaUtils.parseSchemaFileFromElementDefinition(definition); if (is02ConfigLdif(schemaFile)) if (SchemaUtils.is02ConfigLdif(schemaFile)) { // Do not import the file containing the definitions of the Schema elements used for configuration // because these definitions may vary between versions of OpenDJ. continue; } @@ -670,11 +669,6 @@ } } private boolean is02ConfigLdif(String schemaFile) { return CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile); } private <T> void addElementIfNotNull(Collection<T> col, T element) { if (element != null) opendj-server-legacy/src/main/java/org/opends/server/util/SchemaUtils.java
@@ -54,6 +54,8 @@ // No implementation required. } private static final String CONFIG_SCHEMA_ELEMENTS_FILE = "02-config.ldif"; /** Represents a password type, including a "not a password" value. */ public enum PasswordType { @@ -124,7 +126,7 @@ public static String getElementDefinitionWithFileName(SchemaElement element) { final String definition = element.toString(); return addSchemaFileToElementDefinitionIfAbsent(definition, SchemaUtils.getElementSchemaFile(element)); return addSchemaFileToElementDefinitionIfAbsent(definition, getElementSchemaFile(element)); } /** @@ -489,4 +491,21 @@ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, parsingErrorMsg.get(definition), e); } } /** * Indicates if the provided schema file corresponds to the configuration schema. * <p> * The file containing the definitions of the schema elements used for configuration must not be * imported nor propagated to other servers because these definitions may vary between versions of * OpenDJ. * * @param schemaFile * The name of a file defining schema elements * @return {@code true} if the file defines configuration elements, * {@code false} otherwise */ public static boolean is02ConfigLdif(String schemaFile) { return CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile); } }