opendj-core/clirr-ignored-api-changes.xml
@@ -97,4 +97,46 @@ <differenceType>8001</differenceType> <justification>CompactDN has been migrated to server</justification> </difference> <difference> <className>org/forgerock/opendj/ldap/schema/Schema</className> <differenceType>7002</differenceType> <method>java.util.List getAttributeTypesWithName(java.lang.String)</method> <justification>No duplicate names allowed</justification> </difference> <difference> <className>org/forgerock/opendj/ldap/schema/Schema</className> <differenceType>7002</differenceType> <method>java.util.Collection getDITContentRulesWithName(java.lang.String)</method> <justification>No duplicate names allowed</justification> </difference> <difference> <className>org/forgerock/opendj/ldap/schema/Schema</className> <differenceType>7002</differenceType> <method>java.util.Collection getDITStructureRulesWithName(java.lang.String)</method> <justification>No duplicate names allowed</justification> </difference> <difference> <className>org/forgerock/opendj/ldap/schema/Schema</className> <differenceType>7002</differenceType> <method>java.util.Collection getMatchingRuleUsesWithName(java.lang.String)</method> <justification>No duplicate names allowed</justification> </difference> <difference> <className>org/forgerock/opendj/ldap/schema/Schema</className> <differenceType>7002</differenceType> <method>java.util.Collection getMatchingRulesWithName(java.lang.String)</method> <justification>No duplicate names allowed</justification> </difference> <difference> <className>org/forgerock/opendj/ldap/schema/Schema</className> <differenceType>7002</differenceType> <method>java.util.Collection getNameFormsWithName(java.lang.String)</method> <justification>No duplicate names allowed</justification> </difference> <difference> <className>org/forgerock/opendj/ldap/schema/Schema</className> <differenceType>7002</differenceType> <method>java.util.Collection getObjectClassesWithName(java.lang.String)</method> <justification>No duplicate names allowed</justification> </difference> </differences> opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
@@ -18,7 +18,6 @@ package org.forgerock.opendj.ldap.schema; import static com.forgerock.opendj.ldap.CoreMessages.*; import static org.forgerock.opendj.ldap.AttributeDescription.*; import java.util.Collection; @@ -81,21 +80,17 @@ Collection<AttributeType> getAttributeTypes(); List<AttributeType> getAttributeTypesWithName(String name); DITContentRule getDITContentRule(ObjectClass structuralClass); DITContentRule getDITContentRule(String nameOrOid); Collection<DITContentRule> getDITContentRules(); Collection<DITContentRule> getDITContentRulesWithName(String name); DITStructureRule getDITStructureRule(int ruleID); Collection<DITStructureRule> getDITStructureRules(NameForm nameForm); DITStructureRule getDITStructureRule(String name); Collection<DITStructureRule> getDITStructureRulesWithName(String name); Collection<DITStructureRule> getDITStructureRules(NameForm nameForm); Collection<DITStructureRule> getDITStuctureRules(); @@ -103,30 +98,22 @@ Collection<MatchingRule> getMatchingRules(); Collection<MatchingRule> getMatchingRulesWithName(String name); MatchingRuleUse getMatchingRuleUse(MatchingRule matchingRule); MatchingRuleUse getMatchingRuleUse(String nameOrOid); Collection<MatchingRuleUse> getMatchingRuleUses(); Collection<MatchingRuleUse> getMatchingRuleUsesWithName(String name); NameForm getNameForm(String nameOrOid); Collection<NameForm> getNameForms(); Collection<NameForm> getNameForms(ObjectClass structuralClass); Collection<NameForm> getNameFormsWithName(String name); ObjectClass getObjectClass(String nameOrOid); Collection<ObjectClass> getObjectClasses(); Collection<ObjectClass> getObjectClassesWithName(String name); String getSchemaName(); Syntax getSyntax(Schema schema, String numericOID); @@ -207,11 +194,6 @@ } @Override public List<AttributeType> getAttributeTypesWithName(final String name) { return strictImpl.getAttributeTypesWithName(name); } @Override public DITContentRule getDITContentRule(final ObjectClass structuralClass) { return strictImpl.getDITContentRule(structuralClass); } @@ -227,23 +209,18 @@ } @Override public Collection<DITContentRule> getDITContentRulesWithName(final String name) { return strictImpl.getDITContentRulesWithName(name); } @Override public DITStructureRule getDITStructureRule(final int ruleID) { return strictImpl.getDITStructureRule(ruleID); } @Override public Collection<DITStructureRule> getDITStructureRules(final NameForm nameForm) { return strictImpl.getDITStructureRules(nameForm); public DITStructureRule getDITStructureRule(final String name) { return strictImpl.getDITStructureRule(name); } @Override public Collection<DITStructureRule> getDITStructureRulesWithName(final String name) { return strictImpl.getDITStructureRulesWithName(name); public Collection<DITStructureRule> getDITStructureRules(final NameForm nameForm) { return strictImpl.getDITStructureRules(nameForm); } @Override @@ -262,11 +239,6 @@ } @Override public Collection<MatchingRule> getMatchingRulesWithName(final String name) { return strictImpl.getMatchingRulesWithName(name); } @Override public MatchingRuleUse getMatchingRuleUse(final MatchingRule matchingRule) { return strictImpl.getMatchingRuleUse(matchingRule); } @@ -282,11 +254,6 @@ } @Override public Collection<MatchingRuleUse> getMatchingRuleUsesWithName(final String name) { return strictImpl.getMatchingRuleUsesWithName(name); } @Override public NameForm getNameForm(final String nameOrOid) { return strictImpl.getNameForm(nameOrOid); } @@ -302,11 +269,6 @@ } @Override public Collection<NameForm> getNameFormsWithName(final String name) { return strictImpl.getNameFormsWithName(name); } @Override public ObjectClass getObjectClass(final String nameOrOid) { ObjectClass result = strictImpl.getObjectClass0(nameOrOid); return result != null ? result : ObjectClass.newPlaceHolder(nameOrOid); @@ -318,11 +280,6 @@ } @Override public Collection<ObjectClass> getObjectClassesWithName(final String name) { return strictImpl.getObjectClassesWithName(name); } @Override public String getSchemaName() { return strictImpl.getSchemaName(); } @@ -514,16 +471,6 @@ } @Override public List<AttributeType> getAttributeTypesWithName(final String name) { final List<AttributeType> attributes = name2AttributeTypes.get(StaticUtils.toLowerCase(name)); if (attributes != null) { return attributes; } return Collections.emptyList(); } @Override public DITContentRule getDITContentRule(final ObjectClass structuralClass) { return numericOID2ContentRules.get(structuralClass.getOID()); } @@ -535,11 +482,8 @@ return rule; } final List<DITContentRule> rules = name2ContentRules.get(StaticUtils.toLowerCase(nameOrOid)); if (rules != null) { if (rules.size() == 1) { return rules.get(0); } throw new UnknownSchemaElementException(WARN_DCR_AMBIGUOUS.get(nameOrOid)); if (rules != null && rules.size() == 1) { return rules.get(0); } throw new UnknownSchemaElementException(WARN_DCR_UNKNOWN.get(nameOrOid)); } @@ -550,15 +494,6 @@ } @Override public Collection<DITContentRule> getDITContentRulesWithName(final String name) { final List<DITContentRule> rules = name2ContentRules.get(StaticUtils.toLowerCase(name)); if (rules != null) { return rules; } return Collections.emptyList(); } @Override public DITStructureRule getDITStructureRule(final int ruleID) { final DITStructureRule rule = id2StructureRules.get(ruleID); if (rule == null) { @@ -578,13 +513,12 @@ } @Override public Collection<DITStructureRule> getDITStructureRulesWithName(final String name) { final List<DITStructureRule> rules = name2StructureRules.get(StaticUtils.toLowerCase(name)); if (rules != null) { return rules; public DITStructureRule getDITStructureRule(final String name) { List<DITStructureRule> rules = name2StructureRules.get(StaticUtils.toLowerCase(name)); if (rules != null && rules.size() == 1) { return rules.get(0); } return Collections.emptyList(); throw new UnknownSchemaElementException(WARN_DIT_SR_UNKNOWN.get(name)); } @Override @@ -599,11 +533,8 @@ return rule; } final List<MatchingRule> rules = name2MatchingRules.get(StaticUtils.toLowerCase(nameOrOid)); if (rules != null) { if (rules.size() == 1) { return rules.get(0); } throw new UnknownSchemaElementException(WARN_MR_AMBIGUOUS.get(nameOrOid)); if (rules != null && rules.size() == 1) { return rules.get(0); } throw new UnknownSchemaElementException(WARN_MR_UNKNOWN.get(nameOrOid)); } @@ -614,32 +545,19 @@ } @Override public Collection<MatchingRule> getMatchingRulesWithName(final String name) { final List<MatchingRule> rules = name2MatchingRules.get(StaticUtils.toLowerCase(name)); if (rules != null) { return rules; } return Collections.emptyList(); } @Override public MatchingRuleUse getMatchingRuleUse(final MatchingRule matchingRule) { return numericOID2MatchingRuleUses.get(matchingRule.getOID()); } @Override public MatchingRuleUse getMatchingRuleUse(final String nameOrOid) { final MatchingRuleUse rule = numericOID2MatchingRuleUses.get(nameOrOid); if (rule != null) { return rule; final MatchingRuleUse use = numericOID2MatchingRuleUses.get(nameOrOid); if (use != null) { return use; } final List<MatchingRuleUse> uses = name2MatchingRuleUses.get(StaticUtils.toLowerCase(nameOrOid)); if (uses != null) { if (uses.size() == 1) { return uses.get(0); } throw new UnknownSchemaElementException(WARN_MRU_AMBIGUOUS.get(nameOrOid)); final List<MatchingRuleUse> uses = name2MatchingRuleUses.get(StaticUtils.toLowerCase(nameOrOid)); if (uses != null && uses.size() == 1) { return uses.get(0); } throw new UnknownSchemaElementException(WARN_MRU_UNKNOWN.get(nameOrOid)); } @@ -650,27 +568,14 @@ } @Override public Collection<MatchingRuleUse> getMatchingRuleUsesWithName(final String name) { final List<MatchingRuleUse> rules = name2MatchingRuleUses.get(StaticUtils.toLowerCase(name)); if (rules != null) { return rules; } return Collections.emptyList(); } @Override public NameForm getNameForm(final String nameOrOid) { final NameForm form = numericOID2NameForms.get(nameOrOid); if (form != null) { return form; } final List<NameForm> forms = name2NameForms.get(StaticUtils.toLowerCase(nameOrOid)); if (forms != null) { if (forms.size() == 1) { return forms.get(0); } throw new UnknownSchemaElementException(WARN_NAMEFORM_AMBIGUOUS.get(nameOrOid)); if (forms != null && forms.size() == 1) { return forms.get(0); } throw new UnknownSchemaElementException(WARN_NAMEFORM_UNKNOWN.get(nameOrOid)); } @@ -690,15 +595,6 @@ } @Override public Collection<NameForm> getNameFormsWithName(final String name) { final List<NameForm> forms = name2NameForms.get(StaticUtils.toLowerCase(name)); if (forms != null) { return forms; } return Collections.emptyList(); } @Override public ObjectClass getObjectClass(final String nameOrOid) { ObjectClass result = getObjectClass0(nameOrOid); if (result != null) { @@ -713,11 +609,8 @@ return oc; } final List<ObjectClass> classes = name2ObjectClasses.get(StaticUtils.toLowerCase(nameOrOid)); if (classes != null) { if (classes.size() == 1) { return classes.get(0); } throw new UnknownSchemaElementException(WARN_OBJECTCLASS_AMBIGUOUS.get(nameOrOid)); if (classes != null && classes.size() == 1) { return classes.get(0); } return null; } @@ -728,15 +621,6 @@ } @Override public Collection<ObjectClass> getObjectClassesWithName(final String name) { final List<ObjectClass> classes = name2ObjectClasses.get(StaticUtils.toLowerCase(name)); if (classes != null) { return classes; } return Collections.emptyList(); } @Override public String getSchemaName() { return schemaName; } @@ -762,21 +646,14 @@ @Override public boolean hasAttributeType(final String nameOrOid) { if (numericOID2AttributeTypes.containsKey(nameOrOid)) { return true; } final List<AttributeType> attributes = name2AttributeTypes.get(StaticUtils.toLowerCase(nameOrOid)); return attributes != null && attributes.size() == 1; return numericOID2AttributeTypes.containsKey(nameOrOid) || name2AttributeTypes.containsKey(StaticUtils.toLowerCase(nameOrOid)); } @Override public boolean hasDITContentRule(final String nameOrOid) { if (numericOID2ContentRules.containsKey(nameOrOid)) { return true; } final List<DITContentRule> rules = name2ContentRules.get(StaticUtils.toLowerCase(nameOrOid)); return rules != null && rules.size() == 1; return numericOID2ContentRules.containsKey(nameOrOid) || name2ContentRules.containsKey(StaticUtils.toLowerCase(nameOrOid)); } @Override @@ -786,39 +663,26 @@ @Override public boolean hasMatchingRule(final String nameOrOid) { if (numericOID2MatchingRules.containsKey(nameOrOid)) { return true; } final List<MatchingRule> rules = name2MatchingRules.get(StaticUtils.toLowerCase(nameOrOid)); return rules != null && rules.size() == 1; return numericOID2MatchingRules.containsKey(nameOrOid) || name2MatchingRules.containsKey(StaticUtils.toLowerCase(nameOrOid)); } @Override public boolean hasMatchingRuleUse(final String nameOrOid) { if (numericOID2MatchingRuleUses.containsKey(nameOrOid)) { return true; } final List<MatchingRuleUse> uses = name2MatchingRuleUses.get(StaticUtils.toLowerCase(nameOrOid)); return uses != null && uses.size() == 1; return numericOID2MatchingRuleUses.containsKey(nameOrOid) || name2MatchingRuleUses.containsKey(StaticUtils.toLowerCase(nameOrOid)); } @Override public boolean hasNameForm(final String nameOrOid) { if (numericOID2NameForms.containsKey(nameOrOid)) { return true; } final List<NameForm> forms = name2NameForms.get(StaticUtils.toLowerCase(nameOrOid)); return forms != null && forms.size() == 1; return numericOID2NameForms.containsKey(nameOrOid) || name2NameForms.containsKey(StaticUtils.toLowerCase(nameOrOid)); } @Override public boolean hasObjectClass(final String nameOrOid) { if (numericOID2ObjectClasses.containsKey(nameOrOid)) { return true; } final List<ObjectClass> classes = name2ObjectClasses.get(StaticUtils.toLowerCase(nameOrOid)); return classes != null && classes.size() == 1; return numericOID2ObjectClasses.containsKey(nameOrOid) || name2ObjectClasses.containsKey(StaticUtils.toLowerCase(nameOrOid)); } @Override @@ -836,15 +700,8 @@ if (type != null) { return type; } final List<AttributeType> attributes = name2AttributeTypes.get(StaticUtils.toLowerCase(nameOrOid)); if (attributes != null) { if (attributes.size() == 1) { return attributes.get(0); } throw new UnknownSchemaElementException(WARN_ATTR_TYPE_AMBIGUOUS.get(nameOrOid)); } return null; final List<AttributeType> attrs = name2AttributeTypes.get(StaticUtils.toLowerCase(nameOrOid)); return attrs != null && attrs.size() == 1 ? attrs.get(0) : null; } } @@ -1117,7 +974,7 @@ * @return The requested attribute type. * @throws UnknownSchemaElementException * If this is a strict schema and the requested attribute type * was not found or if the provided name is ambiguous. * was not found. * @see AttributeType#isPlaceHolder() */ public AttributeType getAttributeType(final String nameOrOid) { @@ -1141,7 +998,7 @@ * @return The requested attribute type. * @throws UnknownSchemaElementException * If this is a strict schema and the requested attribute type * was not found or if the provided name is ambiguous. * was not found. * @see AttributeType#isPlaceHolder() */ public AttributeType getAttributeType(final String nameOrOid, final Syntax syntax) { @@ -1160,19 +1017,6 @@ } /** * Returns an unmodifiable collection containing all of the attribute types * having the specified name or numeric OID. * * @param name * The name of the attribute types to retrieve. * @return An unmodifiable collection containing all of the attribute types * having the specified name or numeric OID. */ public List<AttributeType> getAttributeTypesWithName(final String name) { return impl.getAttributeTypesWithName(name); } /** * Returns the DIT content rule associated with the provided structural * object class, or {@code null} if no rule is defined. * @@ -1193,7 +1037,7 @@ * @return The requested DIT content rule. * @throws UnknownSchemaElementException * If this is a strict schema and the requested DIT content rule * was not found or if the provided name is ambiguous. * was not found. */ public DITContentRule getDITContentRule(final String nameOrOid) { return impl.getDITContentRule(nameOrOid); @@ -1211,19 +1055,6 @@ } /** * Returns an unmodifiable collection containing all of the DIT content * rules having the specified name or numeric OID. * * @param name * The name of the DIT content rules to retrieve. * @return An unmodifiable collection containing all of the DIT content * rules having the specified name or numeric OID. */ public Collection<DITContentRule> getDITContentRulesWithName(final String name) { return impl.getDITContentRulesWithName(name); } /** * Returns the DIT structure rule with the specified name or numeric OID. * * @param ruleID @@ -1238,6 +1069,20 @@ } /** * Returns the DIT structure rule with the specified name or numeric OID. * * @param nameOrOid * The name or OID of the DIT structure rule to retrieve. * @return The requested DIT structure rule. * @throws UnknownSchemaElementException * If this is a strict schema and the requested DIT structure rule * was not found. */ public DITStructureRule getDITStructureRule(final String nameOrOid) { return impl.getDITStructureRule(nameOrOid); } /** * Returns an unmodifiable collection containing all of the DIT structure * rules associated with the provided name form. * @@ -1252,19 +1097,6 @@ /** * Returns an unmodifiable collection containing all of the DIT structure * rules having the specified name or numeric OID. * * @param name * The name of the DIT structure rules to retrieve. * @return An unmodifiable collection containing all of the DIT structure * rules having the specified name or numeric OID. */ public Collection<DITStructureRule> getDITStructureRulesWithName(final String name) { return impl.getDITStructureRulesWithName(name); } /** * Returns an unmodifiable collection containing all of the DIT structure * rules contained in this schema. * * @return An unmodifiable collection containing all of the DIT structure @@ -1282,7 +1114,7 @@ * @return The requested matching rule. * @throws UnknownSchemaElementException * If this is a strict schema and the requested matching rule * was not found or if the provided name is ambiguous. * was not found. */ public MatchingRule getMatchingRule(final String nameOrOid) { return impl.getMatchingRule(nameOrOid); @@ -1300,19 +1132,6 @@ } /** * Returns an unmodifiable collection containing all of the matching rules * having the specified name or numeric OID. * * @param name * The name of the matching rules to retrieve. * @return An unmodifiable collection containing all of the matching rules * having the specified name or numeric OID. */ public Collection<MatchingRule> getMatchingRulesWithName(final String name) { return impl.getMatchingRulesWithName(name); } /** * Returns the matching rule use associated with the provided matching rule, * or {@code null} if no use is defined. * @@ -1333,7 +1152,7 @@ * @return The requested matching rule use. * @throws UnknownSchemaElementException * If this is a strict schema and the requested matching rule * use was not found or if the provided name is ambiguous. * use was not found. */ public MatchingRuleUse getMatchingRuleUse(final String nameOrOid) { return impl.getMatchingRuleUse(nameOrOid); @@ -1351,19 +1170,6 @@ } /** * Returns an unmodifiable collection containing all of the matching rule * uses having the specified name or numeric OID. * * @param name * The name of the matching rule uses to retrieve. * @return An unmodifiable collection containing all of the matching rule * uses having the specified name or numeric OID. */ public Collection<MatchingRuleUse> getMatchingRuleUsesWithName(final String name) { return impl.getMatchingRuleUsesWithName(name); } /** * Returns the name form with the specified name or numeric OID. * * @param nameOrOid @@ -1371,7 +1177,7 @@ * @return The requested name form. * @throws UnknownSchemaElementException * If this is a strict schema and the requested name form was * not found or if the provided name is ambiguous. * not found. */ public NameForm getNameForm(final String nameOrOid) { return impl.getNameForm(nameOrOid); @@ -1403,19 +1209,6 @@ } /** * Returns an unmodifiable collection containing all of the name forms * having the specified name or numeric OID. * * @param name * The name of the name forms to retrieve. * @return An unmodifiable collection containing all of the name forms * having the specified name or numeric OID. */ public Collection<NameForm> getNameFormsWithName(final String name) { return impl.getNameFormsWithName(name); } /** * Returns the object class with the specified name or numeric OID. * <p> * If the requested object class is not registered in this schema and this @@ -1428,7 +1221,7 @@ * @return The requested object class. * @throws UnknownSchemaElementException * If this is a strict schema and the requested object class was * not found or if the provided name is ambiguous. * not found. * @see ObjectClass#isPlaceHolder() */ public ObjectClass getObjectClass(final String nameOrOid) { @@ -1447,19 +1240,6 @@ } /** * Returns an unmodifiable collection containing all of the object classes * having the specified name or numeric OID. * * @param name * The name of the object classes to retrieve. * @return An unmodifiable collection containing all of the object classes * having the specified name or numeric OID. */ public Collection<ObjectClass> getObjectClassesWithName(final String name) { return impl.getObjectClassesWithName(name); } /** * Returns the value associated to the provided {@link Option} or the option * default value, if there is no such option in this schema. * opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
@@ -18,7 +18,6 @@ package org.forgerock.opendj.ldap.schema; import static java.util.Collections.*; import static org.forgerock.opendj.ldap.LdapException.*; import static org.forgerock.opendj.ldap.schema.ObjectClass.*; import static org.forgerock.opendj.ldap.schema.ObjectClassType.*; @@ -26,7 +25,6 @@ import static org.forgerock.opendj.ldap.schema.SchemaConstants.*; import static org.forgerock.opendj.ldap.schema.SchemaOptions.*; import static org.forgerock.opendj.ldap.schema.SchemaUtils.*; import static com.forgerock.opendj.ldap.CoreMessages.*; import static com.forgerock.opendj.util.StaticUtils.*; @@ -2187,6 +2185,14 @@ defaultMatchingRule = Schema.getCoreSchema().getDefaultMatchingRule(); } removeDuplicateMatchingRulesNames(); removeDuplicateMatchingRuleUsesNames(); removeDuplicateAttributeTypesNames(); removeDuplicateObjectClassesNames(); removeDuplicateNameFormsNames(); removeDuplicateDITContentRulesNames(); removeDuplicateDITStructureRulesNames(); final Schema schema = new Schema.StrictImpl(localSchemaName, options, defaultSyntax, defaultMatchingRule, numericOID2Syntaxes, @@ -2771,4 +2777,138 @@ } } } private void removeDuplicateMatchingRulesNames() { for (final java.util.Map.Entry<String, List<MatchingRule>> entry : name2MatchingRules.entrySet()) { List<MatchingRule> rules = entry.getValue(); if (rules.size() > 1) { StringBuilder oids = new StringBuilder(); for (MatchingRule attr : rules) { if (oids.length() > 0) { oids.append(", "); } oids.append(attr.getOID()); } String name = entry.getKey(); warnings.add(WARN_MATCHING_RULES_DUPLICATED_NAME.get(oids, name, name, rules.get(0).getOID())); // keep only the first value rules.subList(1, rules.size()).clear(); } } } private void removeDuplicateMatchingRuleUsesNames() { for (final java.util.Map.Entry<String, List<MatchingRuleUse>> entry : name2MatchingRuleUses.entrySet()) { List<MatchingRuleUse> uses = entry.getValue(); if (uses.size() > 1) { StringBuilder oids = new StringBuilder(); for (MatchingRuleUse attr : uses) { if (oids.length() > 0) { oids.append(", "); } oids.append(attr.getMatchingRuleOID()); } String name = entry.getKey(); warnings.add(WARN_MATCHING_RULE_USES_DUPLICATED_NAME.get(oids, name, name, uses.get(0).getMatchingRuleOID())); // keep only the first value uses.subList(1, uses.size()).clear(); } } } private void removeDuplicateAttributeTypesNames() { for (final java.util.Map.Entry<String, List<AttributeType>> entry : name2AttributeTypes.entrySet()) { List<AttributeType> types = entry.getValue(); if (entry.getValue().size() > 1) { StringBuilder oids = new StringBuilder(); for (AttributeType attr : types) { if (oids.length() > 0) { oids.append(", "); } oids.append(attr.getOID()); } String name = entry.getKey(); warnings.add(WARN_ATTR_TYPES_DUPLICATED_NAME.get(oids, name, name, types.get(0).getOID())); // keep only the first value types.subList(1, types.size()).clear(); } } } private void removeDuplicateObjectClassesNames() { for (final java.util.Map.Entry<String, List<ObjectClass>> entry : name2ObjectClasses.entrySet()) { List<ObjectClass> classes = entry.getValue(); if (entry.getValue().size() > 1) { StringBuilder oids = new StringBuilder(); for (ObjectClass attr : classes) { if (oids.length() > 0) { oids.append(", "); } oids.append(attr.getOID()); } String name = entry.getKey(); warnings.add(WARN_CLASSES_DUPLICATED_NAME.get(oids, name, name, classes.get(0).getOID())); // keep only the first value classes.subList(1, classes.size()).clear(); } } } private void removeDuplicateNameFormsNames() { for (final java.util.Map.Entry<String, List<NameForm>> entry : name2NameForms.entrySet()) { List<NameForm> forms = entry.getValue(); if (entry.getValue().size() > 1) { StringBuilder oids = new StringBuilder(); for (NameForm attr : forms) { if (oids.length() > 0) { oids.append(", "); } oids.append(attr.getOID()); } String name = entry.getKey(); warnings.add(WARN_NAME_FORMS_DUPLICATED_NAME.get(oids, name, name, forms.get(0).getOID())); // keep only the first value forms.subList(1, forms.size()).clear(); } } } private void removeDuplicateDITStructureRulesNames() { for (final java.util.Map.Entry<String, List<DITStructureRule>> entry : name2StructureRules.entrySet()) { List<DITStructureRule> rules = entry.getValue(); if (entry.getValue().size() > 1) { StringBuilder ids = new StringBuilder(); for (DITStructureRule attr : rules) { if (ids.length() > 0) { ids.append(", "); } ids.append(attr.getRuleID()); } String name = entry.getKey(); warnings.add(WARN_DIT_SR_DUPLICATED_NAME.get(ids, name, name, rules.get(0).getRuleID())); // keep only the first value rules.subList(1, rules.size()).clear(); } } } private void removeDuplicateDITContentRulesNames() { for (final java.util.Map.Entry<String, List<DITContentRule>> entry : name2ContentRules.entrySet()) { List<DITContentRule> rules = entry.getValue(); if (entry.getValue().size() > 1) { StringBuilder ids = new StringBuilder(); for (DITContentRule attr : rules) { if (ids.length() > 0) { ids.append(", "); } ids.append(attr.getStructuralClassOID()); } String name = entry.getKey(); warnings.add(WARN_DIT_CR_DUPLICATED_NAME.get(ids, name, name, rules.get(0).getStructuralClassOID())); // keep only the first value rules.subList(1, rules.size()).clear(); } } } } opendj-core/src/main/resources/com/forgerock/opendj/ldap/core.properties
@@ -1661,7 +1661,29 @@ superior type "%s" which is marked as OBSOLETE in the schema WARN_ATTR_TYPE_HAS_OBSOLETE_MR=The attribute type "%s" specifies the \ matching rule "%s" which is marked as OBSOLETE in the schema WARN_ATTR_TYPES_DUPLICATED_NAME=The following attribute types share the \ name "%s": %s. To avoid ambiguity the name "%s" will only be associated with \ attribute type "%s" WARN_MATCHING_RULES_DUPLICATED_NAME=The following matching rules share the \ name "%s": %s. To avoid ambiguity the name "%s" will only be associated with \ matching rule "%s" WARN_MATCHING_RULE_USES_DUPLICATED_NAME=The following matching rule uses share the \ name "%s": %s. To avoid ambiguity the name "%s" will only be associated with \ matching rule use "%s" WARN_CLASSES_DUPLICATED_NAME=The following object classes share the \ name "%s": %s. To avoid ambiguity the name "%s" will only be associated with \ object class "%s" WARN_NAME_FORMS_DUPLICATED_NAME=The following name forms share the \ name "%s": %s. To avoid ambiguity the name "%s" will only be associated with \ name form "%s" WARN_DIT_SR_DUPLICATED_NAME=The following DIT structure rules share the \ name "%s": %s. To avoid ambiguity the name "%s" will only be associated with \ DIT structure rule "%s" WARN_DIT_CR_DUPLICATED_NAME=The following DIT content rules share the \ name "%s": %s. To avoid ambiguity the name "%s" will only be associated with \ DIT content rule "%s" WARN_DIT_SR_UNKNOWN=No DIT structure rule with name "%s" exists in the schema # Labels for generated documentation DOC_LOCALE_TAG=Code tag: %s DOC_LOCALE_OID=Collation order object identifier: %s opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AttributeTypeBuilderTestCase.java
@@ -11,7 +11,7 @@ * Header, with the fields enclosed by brackets [] replaced by your own identifying * information: "Portions Copyright [year] [name of copyright owner]". * * Copyright 2015 ForgeRock AS. * Copyright 2015-2016 ForgeRock AS. */ package org.forgerock.opendj.ldap.schema; @@ -132,7 +132,8 @@ sb.buildAttributeType(schema.getAttributeType("AttributeTypeToDuplicate")) .oid("1.1.1.43") .names("Copy") .removeAllNames() // mandatory to avoid duplicate names .names("DuplicatedAttributeType", "Copy") .obsolete(true) .addToSchemaOverwrite(); Schema schemaCopy = sb.toSchema(); @@ -143,7 +144,7 @@ assertThat(atCopy.getOID()).isEqualTo("1.1.1.43"); assertThat(atCopy.getDescription()).isEqualTo("Attribute type to duplicate"); assertThat(atCopy.isObsolete()).isTrue(); assertThat(atCopy.getNames()).containsOnly("AttributeTypeToDuplicate", "Copy"); assertThat(atCopy.getNames()).containsOnly("DuplicatedAttributeType", "Copy"); assertThat(atCopy.getExtraProperties()).isEmpty(); } opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AttributeTypeTest.java
@@ -16,6 +16,7 @@ */ package org.forgerock.opendj.ldap.schema; import static com.forgerock.opendj.ldap.CoreMessages.WARN_ATTR_TYPES_DUPLICATED_NAME; import static org.assertj.core.api.Assertions.fail; import static org.assertj.core.api.Assertions.assertThat; import static org.forgerock.opendj.ldap.schema.SchemaConstants.*; @@ -55,17 +56,17 @@ + "'user defined' ) X-SCHEMA-FILE '98sunEmp.ldif')", false); builder.buildAttributeType("1.2.3") .names("testType") .names("testType3") .superiorType("1.2.2") .syntax("1.3.6.1.4.1.1466.115.121.1.27") .collective(true) .usage(AttributeUsage.USER_APPLICATIONS) .addToSchema(); builder.addAttributeType("( 1.2.4 NAME 'testType' SUP 1.2.3 SINGLE-VALUE COLLECTIVE )", false); builder.addAttributeType("( 1.2.4 NAME 'testType4' SUP 1.2.3 SINGLE-VALUE COLLECTIVE )", false); builder.buildAttributeType("1.2.5") .names("testType", "testnamealias", "anothernamealias") .names("testType5", "testnamealias5", "anothernamealias5") .equalityMatchingRule(EMR_CASE_IGNORE_LIST_OID) .substringMatchingRule(SMR_CASE_IGNORE_LIST_OID) .approximateMatchingRule(AMR_DOUBLE_METAPHONE_OID) @@ -74,8 +75,8 @@ .usage(AttributeUsage.DSA_OPERATION) .addToSchema(); builder.addAttributeType("( 1.2.6 NAME ( 'testType' 'testnamealias' 'anothernamealias1' ) " + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SUP anothernamealias" builder.addAttributeType("( 1.2.6 NAME ( 'testType6' 'testnamealias6' 'anothernamealias6' ) " + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SUP anothernamealias5" + " USAGE dSAOperation NO-USER-MODIFICATION )", false); schema = builder.toSchema(); @@ -236,12 +237,12 @@ public final void testConstructorPrimaryName() throws Exception { AttributeType d = schema.getAttributeType("1.2.3"); Assert.assertTrue(d.hasName("testType")); Assert.assertTrue(d.hasName("testType3")); Assert.assertFalse(d.hasName("xxx")); d = schema.getAttributeType("1.2.4"); Assert.assertTrue(d.hasName("testType")); Assert.assertTrue(d.hasName("testType4")); Assert.assertFalse(d.hasName("xxx")); } @@ -269,15 +270,15 @@ public final void testConstructorTypeNames() throws Exception { AttributeType d = schema.getAttributeType("1.2.5"); Assert.assertTrue(d.hasName("testType")); Assert.assertTrue(d.hasName("testnamealias")); Assert.assertTrue(d.hasName("anothernamealias")); Assert.assertTrue(d.hasName("testType5")); Assert.assertTrue(d.hasName("testnamealias5")); Assert.assertTrue(d.hasName("anothernamealias5")); d = schema.getAttributeType("1.2.6"); Assert.assertTrue(d.hasName("testType")); Assert.assertTrue(d.hasName("testnamealias")); Assert.assertTrue(d.hasName("anothernamealias1")); Assert.assertTrue(d.hasName("testType6")); Assert.assertTrue(d.hasName("testnamealias6")); Assert.assertTrue(d.hasName("anothernamealias6")); } /** @@ -320,9 +321,9 @@ @Test public final void testGetNameOrOIDReturnsPrimaryName() throws Exception { AttributeType d = schema.getAttributeType("1.2.3"); Assert.assertEquals(d.getNameOrOID(), "testType"); Assert.assertEquals(d.getNameOrOID(), "testType3"); d = schema.getAttributeType("1.2.4"); Assert.assertEquals(d.getNameOrOID(), "testType"); Assert.assertEquals(d.getNameOrOID(), "testType4"); } /** @@ -335,15 +336,15 @@ public final void testGetNormalizedNames() throws Exception { AttributeType d = schema.getAttributeType("1.2.5"); Iterator<String> i = d.getNames().iterator(); Assert.assertEquals(i.next(), "testType"); Assert.assertEquals(i.next(), "testnamealias"); Assert.assertEquals(i.next(), "anothernamealias"); Assert.assertEquals(i.next(), "testType5"); Assert.assertEquals(i.next(), "testnamealias5"); Assert.assertEquals(i.next(), "anothernamealias5"); d = schema.getAttributeType("1.2.6"); i = d.getNames().iterator(); Assert.assertEquals(i.next(), "testType"); Assert.assertEquals(i.next(), "testnamealias"); Assert.assertEquals(i.next(), "anothernamealias1"); Assert.assertEquals(i.next(), "testType6"); Assert.assertEquals(i.next(), "testnamealias6"); Assert.assertEquals(i.next(), "anothernamealias6"); } /** @@ -385,12 +386,12 @@ public final void testHasNameOrOID() throws Exception { AttributeType d = schema.getAttributeType("1.2.3"); Assert.assertTrue(d.hasNameOrOID("testType")); Assert.assertTrue(d.hasNameOrOID("testType3")); Assert.assertTrue(d.hasNameOrOID("1.2.3")); Assert.assertFalse(d.hasNameOrOID("x.y.z")); d = schema.getAttributeType("1.2.4"); Assert.assertTrue(d.hasNameOrOID("testType")); Assert.assertTrue(d.hasNameOrOID("testType4")); Assert.assertTrue(d.hasNameOrOID("1.2.4")); Assert.assertFalse(d.hasNameOrOID("x.y.z")); } @@ -556,4 +557,14 @@ return builder.toSchema().getAttributeType("1.2.3"); } @Test public void testDuplicateNamesGenerateWarnings() { Schema dupSchema = new SchemaBuilder(schema).buildAttributeType("1.2.10") .names("testType3") .syntax("1.3.6.1.4.1.1466.115.121.1.27") .addToSchema().toSchema(); assertThat(dupSchema.getWarnings()).contains( WARN_ATTR_TYPES_DUPLICATED_NAME.get("1.2.3, 1.2.10", "testtype3", "testtype3", "1.2.3")); } } opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTestCase.java
@@ -512,6 +512,7 @@ // @formatter:off sb.buildMatchingRule(mr) .removeAllNames() // mandatory to remove duplicate names .names("Dolly") .oid("2.5.13.0.1") .obsolete(true) opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseBuilderTestCase.java
@@ -11,7 +11,7 @@ * Header, with the fields enclosed by brackets [] replaced by your own identifying * information: "Portions Copyright [year] [name of copyright owner]". * * Copyright 2015 ForgeRock AS. * Copyright 2015-2016 ForgeRock AS. */ package org.forgerock.opendj.ldap.schema; @@ -63,6 +63,7 @@ final Schema schemaCopy = builder.buildMatchingRuleUse(schema.getMatchingRuleUse(EMR_BIT_STRING_OID)) .oid(EMR_OCTET_STRING_OID) .removeAllNames() .names("Matching rule use test copy") .attributes("2.5.4.53") .addToSchema() @@ -72,7 +73,7 @@ final MatchingRuleUse mru = schemaCopy.getMatchingRuleUse(EMR_OCTET_STRING_OID); assertThat(mru).isNotNull(); assertThat(mru.getMatchingRuleOID()).isEqualTo(EMR_OCTET_STRING_OID); assertThat(mru.getNames()).containsOnly("Matching rule use test", "Matching rule use test copy"); assertThat(mru.getNames()).containsOnly("Matching rule use test copy"); assertThat(mru.getDescription()).isEqualTo("Matching rule use description"); assertThat(mru.getAttributes()).containsOnly(schema.getAttributeType("2.5.4.40"), schema.getAttributeType("2.5.4.53")); opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NameFormTestCase.java
@@ -399,6 +399,7 @@ assertThat(nf.getOID()).isEqualTo("1.3.6.1.4.1.1466.115.121.1.35"); sb.buildNameForm(nf) .removeAllNames() // mandatory to avoid duplicate names .names("Dolly") .oid("1.3.6.1.4.1.1466.115.121.1.36") .addToSchemaOverwrite(); @@ -411,7 +412,7 @@ i.next(); // Jump the first element (== nf) final NameForm dolly = i.next(); // Our new cloned NameForm. assertThat(dolly.getOID()).isEqualTo("1.3.6.1.4.1.1466.115.121.1.36"); // With the new OID ! assertThat(dolly.getNames().size()).isEqualTo(2); assertThat(dolly.getNames().size()).isEqualTo(1); } /** @@ -548,7 +549,7 @@ final Schema schema = sb.toSchema(); assertThat(schema.getWarnings()).isEmpty(); assertThat(schema.getNameFormsWithName("mycustomnameform")).isNotNull(); assertThat(schema.getNameForm("mycustomnameform")).isNotNull(); for (final NameForm o : schema.getNameForms()) { assertThat(o.getNameOrOID()).isEqualTo("myCustomNameForm"); assertThat(o.getOID()).isEqualTo("mycustomnameform-oid"); @@ -885,7 +886,8 @@ // @formatter:off. SchemaBuilder sb = new SchemaBuilder(Schema.getCoreSchema()); Builder nfBuilder = new Builder(nf, sb) .names("Dolly") .removeAllNames() // mandatory to avoid duplicate names .names("MyCopiedNewForm", "Dolly") .oid("1.3.6.1.4.1.1466.115.121.1.36") .removeOptionalAttribute("uid") .removeOptionalAttribute("nonExistentUid") opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ObjectClassBuilderTestCase.java
@@ -162,7 +162,8 @@ sb.buildObjectClass(schema.getObjectClass("ObjectClassToDuplicate")) .oid("1.1.1.43") .names("Copy") .removeAllNames() // mandatory to avoid duplicate names .names("DuplicatedOC", "Copy") .obsolete(true) .addToSchemaOverwrite(); final Schema schemaCopy = sb.toSchema(); @@ -173,7 +174,7 @@ assertThat(ocCopy.getOID()).isEqualTo("1.1.1.43"); assertThat(ocCopy.getDescription()).isEqualTo("Object class to duplicate"); assertThat(ocCopy.isObsolete()).isTrue(); assertThat(ocCopy.getNames()).containsOnly("ObjectClassToDuplicate", "Copy"); assertThat(ocCopy.getNames()).containsOnly("DuplicatedOC", "Copy"); assertSchemaElementsContainsAll(ocCopy.getSuperiorClasses(), TOP_OBJECTCLASS_NAME); assertSchemaElementsContainsAll(ocCopy.getRequiredAttributes(), "name"); assertThat(ocCopy.getOptionalAttributes()).isEmpty(); opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
@@ -110,10 +110,10 @@ @Test public void attributeTypeSuperiorFailureChildThenParent() { final Schema schema = new SchemaBuilder(Schema.getCoreSchema()).addAttributeType( "( childtype-oid NAME 'childtype' SUP parenttype )", false) .addAttributeType("( parenttype-oid NAME 'parenttype' SUP xxx )", false) .toSchema(); new SchemaBuilder(Schema.getCoreSchema()) .addAttributeType("( childtype-oid NAME 'childtype' SUP parenttype )", false) .addAttributeType("( parenttype-oid NAME 'parenttype' SUP xxx )", false) .toSchema(); try { schema.getAttributeType("childtype"); @@ -137,9 +137,10 @@ @Test public void attributeTypeSuperiorFailureParentThenChild() { final Schema schema = new SchemaBuilder(Schema.getCoreSchema()).addAttributeType( "( parenttype-oid NAME 'parenttype' SUP xxx )", false).addAttributeType( "( childtype-oid NAME 'childtype' SUP parenttype )", false).toSchema(); new SchemaBuilder(Schema.getCoreSchema()) .addAttributeType("( parenttype-oid NAME 'parenttype' SUP xxx )", false) .addAttributeType("( childtype-oid NAME 'childtype' SUP parenttype )", false) .toSchema(); try { schema.getAttributeType("childtype"); @@ -412,7 +413,7 @@ assertThat(schema.getAttributeType("myCustomAttribute").getUsage().toString()).isEqualTo( "userApplications"); assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotEmpty(); assertThat(schema.getObjectClass("myCustomObjClass").isPlaceHolder()).isFalse(); } /** @@ -990,7 +991,7 @@ assertThat(schema.getAttributeType("myCustomAttribute").getDescription()) .isEqualTo("A short description"); assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotEmpty(); assertThat(schema.getObjectClass("myCustomObjClass").isPlaceHolder()).isFalse(); } /** @@ -1025,7 +1026,7 @@ "userApplications"); assertThat(schema.getAttributeType("myCustomAttribute").getDescription()) .isEqualTo("A short description"); assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotEmpty(); assertThat(schema.getObjectClass("myCustomObjClass").isPlaceHolder()).isFalse(); } /** @@ -1380,7 +1381,6 @@ // @formatter:on assertThat(schema.getWarnings()).isEmpty(); assertThat(schema.getDITStructureRulesWithName("testAllowATRequiredByDCR")).isNotNull(); assertThat(schema.getDITStructureRule(999014).getDescription()).isEqualTo( "A short description"); assertThat(schema.getDITStructureRule(999014).getNameOrRuleID()).isEqualTo( @@ -1569,7 +1569,7 @@ // @formatter:on assertThat(schema.getWarnings()).isEmpty(); assertThat(schema.getMatchingRuleUsesWithName("bitStringMatch")).isNotEmpty(); assertThat(schema.getMatchingRuleUse("bitStringMatch")).isNotNull(); assertThat(schema.getMatchingRuleUses().size()).isEqualTo(1); for (MatchingRuleUse o : schema.getMatchingRuleUses()) { @@ -1636,7 +1636,7 @@ // @formatter:on assertThat(schema.getWarnings()).isEmpty(); assertThat(schema.getNameFormsWithName("testViolatesSingleValuedNameForm")).isNotNull(); assertThat(schema.getNameForm("testViolatesSingleValuedNameForm")).isNotNull(); for (NameForm o : schema.getNameForms()) { assertThat(o.getNameOrOID()).isEqualTo("testViolatesSingleValuedNameForm"); assertThat(o.getOID()).isEqualTo("testviolatessinglevaluednameform-oid");