/** * Creates a new instance of DefaultSchemaManager with the default schema schemaLoader * * @param schemaLoader The schemaLoader containing the schemas to load */ public DefaultSchemaManager( SchemaLoader schemaLoader ) { // Default to the the root (one schemaManager for all the entries namingContext = Dn.ROOT_DSE; for ( Schema schema : schemaLoader.getAllSchemas() ) { schemaMap.put( schema.getSchemaName(), schema ); } registries = new Registries(); factory = new SchemaEntityFactory(); isRelaxed = STRICT; setErrorHandler( new LoggingSchemaErrorHandler() ); }
/** * Add all the Schema's comparators * * @param schema The schema in which the Comparators will be added * @param registries The Registries to process * @throws LdapException If the Comparators cannot be added * @throws IOException If the Comparators cannot be loaded */ private void addComparators( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadComparators( schema ) ) { LdapComparator<?> comparator = factory.getLdapComparator( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, comparator, schema ); } }
/** * Add all the Schema's AttributeTypes * * @param schema The schema in which the AttributeTypes will be added * @param registries The Registries to process * @throws LdapException If the AttributeTypes cannot be added * @throws IOException If the AttributeTypes cannot be loaded */ private void addAttributeTypes( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadAttributeTypes( schema ) ) { AttributeType attributeType = factory.getAttributeType( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, attributeType, schema ); } }
/** * Add all the Schema's Syntaxes * * @param schema The schema in which the Syntaxes will be added * @param registries The Registries to process * @throws LdapException If the Syntaxes cannot be added * @throws IOException If the Syntaxes cannot be loaded */ private void addSyntaxes( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadSyntaxes( schema ) ) { LdapSyntax syntax = factory.getSyntax( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, syntax, schema ); } }
/** * Add all the Schema's MatchingRules * * @param schema The schema in which the MatchingRules will be added * @param registries The Registries to process * @throws LdapException If the MatchingRules cannot be added * @throws IOException If the MatchingRules cannot be loaded */ private void addMatchingRules( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadMatchingRules( schema ) ) { MatchingRule matchingRule = factory.getMatchingRule( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, matchingRule, schema ); } }
/** * Add all the Schema's Normalizers * * @param schema The schema in which the Normalizers will be added * @param registries The Registries to process * @throws LdapException If the Normalizers cannot be added * @throws IOException If the Normalizers cannot be loaded */ private void addNormalizers( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadNormalizers( schema ) ) { Normalizer normalizer = factory.getNormalizer( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, normalizer, schema ); } }
/** * Add all the Schema's ObjectClasses * * @param schema The schema in which the ObjectClasses will be added * @param registries The Registries to process * @throws LdapException If the ObjectClasses cannot be added * @throws IOException If the ObjectClasses cannot be loaded */ private void addObjectClasses( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadObjectClasses( schema ) ) { ObjectClass objectClass = factory.getObjectClass( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, objectClass, schema ); } }
/** * Register all the Schema's SyntaxCheckers * * @param schema The schema in which the SyntaxChecker will be added * @param registries The Registries to process * @throws LdapException If the SyntaxChecker cannot be added * @throws IOException If the SyntaxChecker cannot be loaded */ private void addSyntaxCheckers( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadSyntaxCheckers( schema ) ) { SyntaxChecker syntaxChecker = factory.getSyntaxChecker( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, syntaxChecker, schema ); } }
if ( !tmp.getErrors().isEmpty() && loader.isStrict() )
Schema schemaDep = schema.getSchemaLoader().getSchema( depName ); loadDepsFirstRelaxed( schemaDep );
/** * Add all the Schema's AttributeTypes * * @param schema The schema in which the AttributeTypes will be added * @param registries The Registries to process * @throws LdapException If the AttributeTypes cannot be added * @throws IOException If the AttributeTypes cannot be loaded */ private void addAttributeTypes( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadAttributeTypes( schema ) ) { AttributeType attributeType = factory.getAttributeType( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, attributeType, schema ); } }
/** * Add all the Schema's Syntaxes * * @param schema The schema in which the Syntaxes will be added * @param registries The Registries to process * @throws LdapException If the Syntaxes cannot be added * @throws IOException If the Syntaxes cannot be loaded */ private void addSyntaxes( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadSyntaxes( schema ) ) { LdapSyntax syntax = factory.getSyntax( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, syntax, schema ); } }
/** * Add all the Schema's MatchingRules * * @param schema The schema in which the MatchingRules will be added * @param registries The Registries to process * @throws LdapException If the MatchingRules cannot be added * @throws IOException If the MatchingRules cannot be loaded */ private void addMatchingRules( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadMatchingRules( schema ) ) { MatchingRule matchingRule = factory.getMatchingRule( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, matchingRule, schema ); } }
/** * Add all the Schema's Normalizers * * @param schema The schema in which the Normalizers will be added * @param registries The Registries to process * @throws LdapException If the Normalizers cannot be added * @throws IOException If the Normalizers cannot be loaded */ private void addNormalizers( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadNormalizers( schema ) ) { Normalizer normalizer = factory.getNormalizer( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, normalizer, schema ); } }
/** * Add all the Schema's ObjectClasses * * @param schema The schema in which the ObjectClasses will be added * @param registries The Registries to process * @throws LdapException If the ObjectClasses cannot be added * @throws IOException If the ObjectClasses cannot be loaded */ private void addObjectClasses( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadObjectClasses( schema ) ) { ObjectClass objectClass = factory.getObjectClass( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, objectClass, schema ); } }
/** * Register all the Schema's SyntaxCheckers * * @param schema The schema in which the SyntaxChecker will be added * @param registries The Registries to process * @throws LdapException If the SyntaxChecker cannot be added * @throws IOException If the SyntaxChecker cannot be loaded */ private void addSyntaxCheckers( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadSyntaxCheckers( schema ) ) { SyntaxChecker syntaxChecker = factory.getSyntaxChecker( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, syntaxChecker, schema ); } }
if ( !tmp.getErrors().isEmpty() && loader.isStrict() )
Schema schemaDep = schema.getSchemaLoader().getSchema( depName ); loadDepsFirstRelaxed( schemaDep );
/** * Creates a new instance of DefaultSchemaManager with the default schema schemaLoader */ public DefaultSchemaManager() { // Default to the the root (one schemaManager for all the entries namingContext = Dn.ROOT_DSE; registries = new Registries(); factory = new SchemaEntityFactory(); isRelaxed = STRICT; setErrorHandler( new LoggingSchemaErrorHandler() ); try { SchemaLoader schemaLoader = new JarLdifSchemaLoader(); for ( Schema schema : schemaLoader.getAllSchemas() ) { schemaMap.put( schema.getSchemaName(), schema ); } loadAllEnabled(); } catch ( LdapException | IOException e ) { LOG.error( I18n.err( I18n.ERR_16077_SCHEMA_MANAGER_CANT_BE_LOADED, e.getMessage() ) ); throw new RuntimeException( e.getMessage() ); } }
/** * Add all the Schema's comparators * * @param schema The schema in which the Comparators will be added * @param registries The Registries to process * @throws LdapException If the Comparators cannot be added * @throws IOException If the Comparators cannot be loaded */ private void addComparators( Schema schema, Registries registries ) throws LdapException, IOException { if ( schema.getSchemaLoader() == null ) { return; } for ( Entry entry : schema.getSchemaLoader().loadComparators( schema ) ) { LdapComparator<?> comparator = factory.getLdapComparator( this, entry, registries, schema.getSchemaName() ); addSchemaObject( registries, comparator, schema ); } }