| | |
| | | private Map<String, ObjectClass> numericOID2ObjectClasses; |
| | | private Map<String, Syntax> numericOID2Syntaxes; |
| | | private Map<String, List<NameForm>> objectClass2NameForms; |
| | | private Map<String, String> name2OIDs; |
| | | private String schemaName; |
| | | private List<LocalizableMessage> warnings; |
| | | private Options options; |
| | |
| | | numericOID2ContentRules, id2StructureRules, name2MatchingRules, |
| | | name2MatchingRuleUses, name2AttributeTypes, name2ObjectClasses, |
| | | name2NameForms, name2ContentRules, name2StructureRules, |
| | | objectClass2NameForms, nameForm2StructureRules, name2OIDs, warnings).asStrictSchema(); |
| | | objectClass2NameForms, nameForm2StructureRules, warnings).asStrictSchema(); |
| | | validate(schema); |
| | | |
| | | // Re-init this builder so that it can continue to be used afterwards. |
| | |
| | | return schema; |
| | | } |
| | | |
| | | private void registerNameToOIDMapping(String name, String anOID) { |
| | | if (name2OIDs.put(name, anOID) != null) { |
| | | name2OIDs.put(name, AMBIGUOUS_OID); |
| | | } |
| | | } |
| | | |
| | | SchemaBuilder addAttributeType(final AttributeType attribute, final boolean overwrite) { |
| | | AttributeType conflictingAttribute; |
| | | if (numericOID2AttributeTypes.containsKey(attribute.getOID())) { |
| | |
| | | |
| | | objectClass2NameForms = new HashMap<>(); |
| | | nameForm2StructureRules = new HashMap<>(); |
| | | name2OIDs = new HashMap<>(); |
| | | warnings = new LinkedList<>(); |
| | | |
| | | if (copyOnWriteSchema != null) { |
| | |
| | | new Syntax[numericOID2Syntaxes.values().size()])) { |
| | | try { |
| | | syntax.validate(schema, warnings); |
| | | registerNameToOIDMapping(syntax.getName(), syntax.getOID()); |
| | | } catch (final SchemaException e) { |
| | | removeSyntax(syntax); |
| | | warnings.add(ERR_SYNTAX_VALIDATION_FAIL |
| | |
| | | new MatchingRule[numericOID2MatchingRules.values().size()])) { |
| | | try { |
| | | rule.validate(schema, warnings); |
| | | for (final String name : rule.getNames()) { |
| | | registerNameToOIDMapping(StaticUtils.toLowerCase(name), rule.getOID()); |
| | | } |
| | | } catch (final SchemaException e) { |
| | | removeMatchingRule(rule); |
| | | warnings.add(ERR_MR_VALIDATION_FAIL.get(rule.toString(), e.getMessageObject())); |
| | |
| | | removeAttributeType(attributeType); |
| | | } |
| | | |
| | | for (final AttributeType attributeType : numericOID2AttributeTypes.values()) { |
| | | for (final String name : attributeType.getNames()) { |
| | | registerNameToOIDMapping(StaticUtils.toLowerCase(name), attributeType.getOID()); |
| | | } |
| | | } |
| | | |
| | | // Object classes need special processing because they have hierarchical |
| | | // dependencies. |
| | | final List<ObjectClass> invalidObjectClasses = new LinkedList<>(); |
| | |
| | | removeObjectClass(objectClass); |
| | | } |
| | | |
| | | for (final ObjectClass objectClass : numericOID2ObjectClasses.values()) { |
| | | for (final String name : objectClass.getNames()) { |
| | | registerNameToOIDMapping(StaticUtils.toLowerCase(name), objectClass.getOID()); |
| | | } |
| | | } |
| | | for (final MatchingRuleUse use : numericOID2MatchingRuleUses.values().toArray( |
| | | new MatchingRuleUse[numericOID2MatchingRuleUses.values().size()])) { |
| | | try { |
| | | use.validate(schema); |
| | | for (final String name : use.getNames()) { |
| | | registerNameToOIDMapping(StaticUtils.toLowerCase(name), use.getMatchingRuleOID()); |
| | | } |
| | | } catch (final SchemaException e) { |
| | | removeMatchingRuleUse(use); |
| | | warnings.add(ERR_MRU_VALIDATION_FAIL.get(use.toString(), e.getMessageObject())); |
| | |
| | | } else { |
| | | forms.add(form); |
| | | } |
| | | for (final String name : form.getNames()) { |
| | | registerNameToOIDMapping(StaticUtils.toLowerCase(name), form.getOID()); |
| | | } |
| | | } catch (final SchemaException e) { |
| | | removeNameForm(form); |
| | | warnings.add(ERR_NAMEFORM_VALIDATION_FAIL |
| | |
| | | new DITContentRule[numericOID2ContentRules.values().size()])) { |
| | | try { |
| | | rule.validate(schema, warnings); |
| | | for (final String name : rule.getNames()) { |
| | | registerNameToOIDMapping(StaticUtils.toLowerCase(name), rule.getStructuralClassOID()); |
| | | } |
| | | } catch (final SchemaException e) { |
| | | removeDITContentRule(rule); |
| | | warnings.add(ERR_DCR_VALIDATION_FAIL.get(rule.toString(), e.getMessageObject())); |