| | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.schema.GeneralizedTimeSyntax.*; |
| | | import static org.opends.server.schema.ServerSchemaElement.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.SchemaUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.File; |
| | |
| | | for (SchemaElement element : elements) |
| | | { |
| | | /* Add the file name to the description of the element if this was requested by the caller. */ |
| | | String value = includeSchemaFile ? getDefinitionWithFileName(element) : element.toString(); |
| | | String value = includeSchemaFile ? getElementDefinitionWithFileName(element) : element.toString(); |
| | | if (stripSyntaxMinimumUpperBound && value.indexOf('{') != -1) |
| | | { |
| | | // Strip the minimum upper bound value from the attribute value. |
| | |
| | | */ |
| | | private String addNewSchemaElement(Set<String> modifiedSchemaFiles, SchemaElement elem) |
| | | { |
| | | String schemaFile = getSchemaFile(elem); |
| | | String schemaFile = getElementSchemaFile(elem); |
| | | String finalFile = schemaFile != null ? schemaFile : FILE_USER_SCHEMA_ELEMENTS; |
| | | modifiedSchemaFiles.add(finalFile); |
| | | return schemaFile == null ? finalFile : null; |
| | |
| | | private String replaceExistingSchemaElement(Set<String> modifiedSchemaFiles, SchemaElement newElem, |
| | | SchemaElement existingElem) |
| | | { |
| | | String newSchemaFile = getSchemaFile(newElem); |
| | | String oldSchemaFile = getSchemaFile(existingElem); |
| | | String newSchemaFile = getElementSchemaFile(newElem); |
| | | String oldSchemaFile = getElementSchemaFile(existingElem); |
| | | if (newSchemaFile == null) |
| | | { |
| | | if (oldSchemaFile == null) |
| | |
| | | |
| | | // If we've gotten here, then it's OK to remove the attribute type from the schema. |
| | | schema.deregisterAttributeType(removeType); |
| | | addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeType)); |
| | | addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeType)); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // If we've gotten here, then it's OK to remove the objectclass from the schema. |
| | | schema.deregisterObjectClass(removeClass); |
| | | addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeClass)); |
| | | addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeClass)); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // Now remove the name form from the schema. |
| | | schema.deregisterNameForm(removeNF); |
| | | addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeNF)); |
| | | addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeNF)); |
| | | } |
| | | |
| | | /** |
| | |
| | | // just remove the DIT content rule now, and if it is added back later then |
| | | // there still won't be any conflict. |
| | | schema.deregisterDITContentRule(removeDCR); |
| | | addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeDCR)); |
| | | addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeDCR)); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // If we've gotten here, then it's OK to remove the DIT structure rule from the schema. |
| | | schema.deregisterDITStructureRule(removeDSR); |
| | | addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeDSR)); |
| | | addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeDSR)); |
| | | } |
| | | |
| | | /** |
| | |
| | | // just remove the DIT content rule now, and if it is added back later then |
| | | // there still won't be any conflict. |
| | | schema.deregisterMatchingRuleUse(removeMRU); |
| | | addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeMRU)); |
| | | addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeMRU)); |
| | | } |
| | | |
| | | /** |
| | |
| | | String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, FILE_USER_SCHEMA_ELEMENTS); |
| | | schema.registerSyntax(def, false); |
| | | |
| | | modifiedSchemaFiles.add(getSchemaFile(schema.getSyntax(oid))); |
| | | modifiedSchemaFiles.add(getElementSchemaFile(schema.getSyntax(oid))); |
| | | } |
| | | else |
| | | { |
| | | schema.deregisterSyntax(existingLS); |
| | | |
| | | String oldSchemaFile = getSchemaFile(existingLS); |
| | | String oldSchemaFile = getElementSchemaFile(existingLS); |
| | | String schemaFile = oldSchemaFile != null && oldSchemaFile.length() > 0 ? |
| | | oldSchemaFile : FILE_USER_SCHEMA_ELEMENTS; |
| | | String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, schemaFile); |
| | | schema.registerSyntax(def, false); |
| | | |
| | | String newSchemaFile = getSchemaFile(schema.getSyntax(oid)); |
| | | String newSchemaFile = getElementSchemaFile(schema.getSyntax(oid)); |
| | | addIfNotNull(modifiedSchemaFiles, oldSchemaFile); |
| | | addIfNotNull(modifiedSchemaFiles, newSchemaFile); |
| | | } |
| | |
| | | } |
| | | |
| | | schema.deregisterSyntax(removeLS); |
| | | addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeLS)); |
| | | addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeLS)); |
| | | } |
| | | |
| | | /** |
| | |
| | | Set<ByteString> values = new LinkedHashSet<>(); |
| | | for (SchemaElement schemaElement : schemaElements) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(schemaElement))) |
| | | if (schemaFile.equals(getElementSchemaFile(schemaElement))) |
| | | { |
| | | values.add(ByteString.valueOfUtf8(schemaElement.toString())); |
| | | } |
| | |
| | | Set<ByteString> values = new LinkedHashSet<>(); |
| | | for (AttributeType at : schema.getAttributeTypes()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(at))) |
| | | if (schemaFile.equals(getElementSchemaFile(at))) |
| | | { |
| | | addAttrTypeToSchemaFile(schema, schemaFile, at, values, addedTypes, 0); |
| | | } |
| | |
| | | Set<ByteString> values = new LinkedHashSet<>(); |
| | | for (ObjectClass oc : schema.getObjectClasses()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(oc))) |
| | | if (schemaFile.equals(getElementSchemaFile(oc))) |
| | | { |
| | | addObjectClassToSchemaFile(schema, schemaFile, oc, values, addedClasses, 0); |
| | | } |
| | |
| | | Set<ByteString> values = new LinkedHashSet<>(); |
| | | for (DITStructureRule dsr : schema.getDITStructureRules()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(dsr))) |
| | | if (schemaFile.equals(getElementSchemaFile(dsr))) |
| | | { |
| | | addDITStructureRuleToSchemaFile(schema, schemaFile, dsr, values, addedDSRs, 0); |
| | | } |
| | |
| | | |
| | | AttributeType superiorType = attributeType.getSuperiorType(); |
| | | if (superiorType != null && |
| | | schemaFile.equals(getSchemaFile(attributeType)) && |
| | | schemaFile.equals(getElementSchemaFile(attributeType)) && |
| | | !addedTypes.contains(superiorType)) |
| | | { |
| | | addAttrTypeToSchemaFile(schema, schemaFile, superiorType, values, |
| | |
| | | |
| | | for(ObjectClass superiorClass : objectClass.getSuperiorClasses()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(superiorClass)) && |
| | | if (schemaFile.equals(getElementSchemaFile(superiorClass)) && |
| | | !addedClasses.contains(superiorClass)) |
| | | { |
| | | addObjectClassToSchemaFile(schema, schemaFile, superiorClass, values, |
| | |
| | | |
| | | for (DITStructureRule dsr : ditStructureRule.getSuperiorRules()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(dsr)) && !addedDSRs.contains(dsr)) |
| | | if (schemaFile.equals(getElementSchemaFile(dsr)) && !addedDSRs.contains(dsr)) |
| | | { |
| | | addDITStructureRuleToSchemaFile(schema, schemaFile, dsr, values, |
| | | addedDSRs, depth+1); |
| | |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType attrType = schema.parseAttributeType(v.toString()); |
| | | String schemaFile = getSchemaFile(attrType); |
| | | String schemaFile = getElementSchemaFile(attrType); |
| | | if (is02ConfigLdif(schemaFile)) |
| | | { |
| | | continue; |
| | |
| | | // them from the new schema if they are not in the imported schema entry. |
| | | for (AttributeType removeType : newSchema.getAttributeTypes()) |
| | | { |
| | | String schemaFile = getSchemaFile(removeType); |
| | | String schemaFile = getElementSchemaFile(removeType); |
| | | if (is02ConfigLdif(schemaFile) || CORE_SCHEMA_ELEMENTS_FILE.equals(schemaFile)) |
| | | { |
| | | // Also never delete anything from the core schema file. |
| | |
| | | // It IS important here to allow the unknown elements that could |
| | | // appear in the new config schema. |
| | | ObjectClass newObjectClass = newSchema.parseObjectClass(v.toString()); |
| | | String schemaFile = getSchemaFile(newObjectClass); |
| | | String schemaFile = getElementSchemaFile(newObjectClass); |
| | | if (is02ConfigLdif(schemaFile)) |
| | | { |
| | | continue; |
| | |
| | | // them from the new schema if they are not in the imported schema entry. |
| | | for (ObjectClass removeClass : newSchema.getObjectClasses()) |
| | | { |
| | | String schemaFile = getSchemaFile(removeClass); |
| | | String schemaFile = getElementSchemaFile(removeClass); |
| | | if (is02ConfigLdif(schemaFile)) |
| | | { |
| | | continue; |