in ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java [2233:2567]
public boolean check()
{
// Check the Syntaxes : check for a SyntaxChecker
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13717_CHECKING_SYNTAXES ) );
}
for ( LdapSyntax syntax : ldapSyntaxRegistry )
{
// Check that each Syntax has a SyntaxChecker
if ( syntax.getSyntaxChecker() == null )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13729_SYN_WITH_NO_SYNTAX_CHECKER, syntax ) );
}
return false;
}
if ( !syntaxCheckerRegistry.contains( syntax.getSyntaxChecker().getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13713_CANT_FIND_SC_FOR_SYN, syntax.getSyntaxChecker().getOid(),
syntax ) );
}
return false;
}
// Check the references : Syntax -> SyntaxChecker and SyntaxChecker -> Syntax
if ( !checkReferences( syntax, syntax.getSyntaxChecker(), "SyntaxChecker" ) )
{
return false;
}
}
// Check the MatchingRules : check for a Normalizer, a Comparator and a Syntax
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13715_CHECKING_MATCHING_RULES ) );
}
for ( MatchingRule matchingRule : matchingRuleRegistry )
{
// Check that each MatchingRule has a Normalizer
if ( matchingRule.getNormalizer() == null )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13727_MR_WITH_NO_NORMALIZER, matchingRule ) );
}
return false;
}
// Check that each MatchingRule has a Normalizer
if ( !normalizerRegistry.contains( matchingRule.getNormalizer().getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13709_CANT_FIND_NORM_FOR_MR, matchingRule.getNormalizer()
.getOid(), matchingRule ) );
}
return false;
}
// Check that each MatchingRule has a Comparator
if ( matchingRule.getLdapComparator() == null )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13726_MR_WITH_NO_COMPARATOR, matchingRule ) );
}
return false;
}
if ( !comparatorRegistry.contains( matchingRule.getLdapComparator().getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13707_CANT_FIND_AT_FOR_MR, matchingRule.getLdapComparator().getOid(),
matchingRule ) );
}
return false;
}
// Check that each MatchingRule has a Syntax
if ( matchingRule.getSyntax() == null )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13728_MR_WITH_NO_SYNTAX, matchingRule ) );
}
return false;
}
if ( !ldapSyntaxRegistry.contains( matchingRule.getSyntax().getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13712_CANT_FIND_SYN_FOR_MR, matchingRule.getSyntax().getOid(),
matchingRule ) );
}
return false;
}
// Check the references : MR -> S and S -> MR
if ( !checkReferences( matchingRule, matchingRule.getSyntax(), "Syntax" ) )
{
return false;
}
// Check the references : MR -> N
if ( !checkReferences( matchingRule, matchingRule.getNormalizer(), "Normalizer" ) )
{
return false;
}
// Check the references : MR -> C and C -> MR
if ( !checkReferences( matchingRule, matchingRule.getLdapComparator(), "Comparator" ) )
{
return false;
}
}
// Check the ObjectClasses : check for MAY, MUST, SUPERIORS
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13716_CHECKING_OBJECT_CLASSES ) );
}
for ( ObjectClass objectClass : objectClassRegistry )
{
// Check that each ObjectClass has all the MAY AttributeTypes
if ( objectClass.getMayAttributeTypes() != null )
{
for ( AttributeType may : objectClass.getMayAttributeTypes() )
{
if ( !attributeTypeRegistry.contains( may.getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13705_CANT_FIND_AT_IN_MAY, may, objectClass ) );
}
return false;
}
// Check the references : OC -> AT and AT -> OC (MAY)
if ( !checkReferences( objectClass, may, "AttributeType" ) )
{
return false;
}
}
}
// Check that each ObjectClass has all the MUST AttributeTypes
if ( objectClass.getMustAttributeTypes() != null )
{
for ( AttributeType must : objectClass.getMustAttributeTypes() )
{
if ( !attributeTypeRegistry.contains( must.getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13706_CANT_FIND_AT_IN_MUST, must, objectClass ) );
}
return false;
}
// Check the references : OC -> AT and AT -> OC (MUST)
if ( !checkReferences( objectClass, must, "AttributeType" ) )
{
return false;
}
}
}
// Check that each ObjectClass has all the SUPERIORS ObjectClasses
if ( objectClass.getSuperiors() != null )
{
for ( ObjectClass superior : objectClass.getSuperiors() )
{
if ( !objectClassRegistry.contains( objectClass.getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13710_CANT_FIND_OC_WITH_SUPERIOR, superior, objectClass ) );
}
return false;
}
// Check the references : OC -> OC and OC -> OC (SUPERIORS)
if ( !checkReferences( objectClass, superior, "ObjectClass" ) )
{
return false;
}
}
}
}
// Check the AttributeTypes : check for MatchingRules, Syntaxes
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13714_CHECKING_ATTRIBUTE_TYPES ) );
}
for ( AttributeType attributeType : attributeTypeRegistry )
{
// Check that each AttributeType has a SYNTAX
if ( attributeType.getSyntax() == null )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13725_AT_WITH_NO_SYNTAX, attributeType ) );
}
return false;
}
if ( !ldapSyntaxRegistry.contains( attributeType.getSyntax().getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13711_CANT_FIND_SYN_FOR_AT, attributeType.getSyntax().getOid(),
attributeType ) );
}
return false;
}
// Check the references for AT -> S and S -> AT
if ( !checkReferences( attributeType, attributeType.getSyntax(), "AttributeType" ) )
{
return false;
}
// Check the EQUALITY MatchingRule
if ( attributeType.getEquality() != null )
{
if ( !matchingRuleRegistry.contains( attributeType.getEquality().getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13708_CANT_FIND_MR_FOR_AT, attributeType.getEquality()
.getOid(), attributeType ) );
}
return false;
}
// Check the references for AT -> MR and MR -> AT
if ( !checkReferences( attributeType, attributeType.getEquality(), "AttributeType" ) )
{
return false;
}
}
// Check the ORDERING MatchingRule
if ( attributeType.getOrdering() != null )
{
if ( !matchingRuleRegistry.contains( attributeType.getOrdering().getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13708_CANT_FIND_MR_FOR_AT, attributeType.getOrdering()
.getOid(), attributeType ) );
}
return false;
}
// Check the references for AT -> MR and MR -> AT
if ( !checkReferences( attributeType, attributeType.getOrdering(), "AttributeType" ) )
{
return false;
}
}
// Check the SUBSTR MatchingRule
if ( attributeType.getSubstring() != null )
{
if ( !matchingRuleRegistry.contains( attributeType.getSubstring().getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13708_CANT_FIND_MR_FOR_AT, attributeType.getSubstring()
.getOid(), attributeType ) );
}
return false;
}
// Check the references for AT -> MR and MR -> AT
if ( !checkReferences( attributeType, attributeType.getSubstring(), "AttributeType" ) )
{
return false;
}
}
// Check the SUP
if ( attributeType.getSuperior() != null )
{
AttributeType superior = attributeType.getSuperior();
if ( !attributeTypeRegistry.contains( superior.getOid() ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_13704_CANT_FIND_AT_WITH_SUPERIOR, superior, attributeType ) );
}
return false;
}
// Check the references : AT -> AT and AT -> AT (SUPERIOR)
if ( !checkReferences( attributeType, superior, "AttributeType" ) )
{
return false;
}
}
}
return true;
}