Java Code Examples for org.apache.directory.api.ldap.model.schema.registries.Schema#isEnabled()

The following examples show how to use org.apache.directory.api.ldap.model.schema.registries.Schema#isEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultSchemaManager.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Schema> getEnabled()
{
    List<Schema> enabled = new ArrayList<>();

    for ( Schema schema : registries.getLoadedSchemas().values() )
    {
        if ( schema.isEnabled() )
        {
            enabled.add( schema );
        }
    }

    return enabled;
}
 
Example 2
Source File: DefaultSchemaManager.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Schema> getAllSchemas()
{
    List<Schema> schemas = new ArrayList<>();

    for ( Schema schema : schemaMap.values() )
    {
        if ( schema.isEnabled() )
        {
            schemas.add( schema );
        }
    }

    return schemas;
}
 
Example 3
Source File: DefaultSchemaManager.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean loadAllEnabled() throws LdapException
{
    Schema[] schemas = new Schema[schemaMap.size()];
    int i = 0;
    
    for ( Schema schema : schemaMap.values() )
    {
        if ( schema.isEnabled() )
        {
            schemas[i++] = schema;
        }
    }
    
    Schema[] enabledSchemas = new Schema[i];
    System.arraycopy( schemas, 0, enabledSchemas, 0, i );
    
    return loadWithDeps( enabledSchemas );
}
 
Example 4
Source File: DefaultSchemaManager.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean loadAllEnabledRelaxed() throws LdapException
{
    Schema[] enabledSchemas = new Schema[schemaMap.size()];
    int i = 0;
    
    for ( Schema schema : schemaMap.values() )
    {
        if ( schema.isEnabled() )
        {
            enabledSchemas[i++] = schema;
        }
    }
    
    return loadWithDepsRelaxed( enabledSchemas );
}
 
Example 5
Source File: DefaultSchemaManager.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Unload the schema from the registries. We will unload everything accordingly to the two flags :
 * - isRelaxed
 * - disabledAccepted
 * 
 * @param registries The Registries to process
 * @param schema The schema to unload from the Registries
 * @return <tt>true</tt> if the schema has been unloaded
 * @throws LdapException If the schema cannot be unloaded
 */
private boolean unload( Registries registries, Schema schema ) throws LdapException
{
    if ( schema == null )
    {
        if ( LOG.isInfoEnabled() )
        {
            LOG.info( I18n.msg( I18n.MSG_16013_SCHEMA_IS_NULL )  );
        }
        
        return false;
    }

    // First avoid unloading twice the same schema
    if ( !registries.isSchemaLoaded( schema.getSchemaName() ) )
    {
        return true;
    }

    if ( schema.isEnabled() )
    {
        if ( LOG.isInfoEnabled() )
        {
            LOG.info( I18n.msg( I18n.MSG_16016_UNLOADING_SCHEMA, schema.getSchemaName(), schema ) );
        }

        deleteSchemaObjects( schema, registries );
        registries.schemaUnloaded( schema );
    }

    return true;
}
 
Example 6
Source File: DefaultSchemaManager.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Add the schemaObject into the registries.
 *
 * @param registries The Registries
 * @param schemaObject The SchemaObject containing the SchemaObject description
 * @param schema The associated schema
 * @return the created schemaObject instance
 * @throws LdapException If the registering failed
 */
protected SchemaObject addSchemaObject( Registries registries, SchemaObject schemaObject, Schema schema )
    throws LdapException
{
    if ( registries.isRelaxed() )
    {
        if ( registries.isDisabledAccepted() || ( schema.isEnabled() && schemaObject.isEnabled() ) )
        {
            registries.add( schemaObject, false );
        }
        else
        {
            // What kind of error is this? TODO: better message
            errorHandler.handle( LOG, null, new Throwable() );
        }
    }
    else
    {
        if ( schema.isEnabled() && schemaObject.isEnabled() )
        {
            registries.add( schemaObject, false );
        }
        else
        {
            // What kind of error is this? TODO: better message
            errorHandler.handle( LOG, null, new Throwable() );
        }
    }

    return schemaObject;
}
 
Example 7
Source File: DefaultSchemaManager.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isEnabled( String schemaName )
{
    Schema schema = registries.getLoadedSchema( schemaName );

    return ( schema != null ) && schema.isEnabled();
}
 
Example 8
Source File: DefaultSchemaManager.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isEnabled( Schema schema )
{
    return ( schema != null ) && schema.isEnabled();
}
 
Example 9
Source File: SchemaInterceptor.java    From MyVirtualDirectory with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void add( AddOperationContext addContext ) throws LdapException
{
    Dn name = addContext.getDn();
    Entry entry = addContext.getEntry();

    // Not the responsibility of MyVD to verify schema
    //check( name, entry );

    // Special checks for the MetaSchema branch
    if ( name.isDescendantOf( schemaBaseDn ) )
    {
        // get the schema name
        String schemaName = getSchemaName( name );

        if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.META_SCHEMA_OC ) )
        {
            next( addContext );

            if ( schemaManager.isSchemaLoaded( schemaName ) )
            {
                // Update the OC superiors for each added ObjectClass
                computeSuperiors();
            }
        }
        else if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.META_OBJECT_CLASS_OC ) )
        {
            // This is an ObjectClass addition
            checkOcSuperior( addContext.getEntry() );

            next( addContext );

            // Update the structures now that the schema element has been added
            Schema schema = schemaManager.getLoadedSchema( schemaName );

            if ( ( schema != null ) && schema.isEnabled() )
            {
                Attribute oidAT = entry.get( MetaSchemaConstants.M_OID_AT );
                String ocOid = oidAT.getString();

                ObjectClass addedOC = schemaManager.lookupObjectClassRegistry( ocOid );
                computeSuperior( addedOC );
            }
        }
        else if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.META_ATTRIBUTE_TYPE_OC ) )
        {
            // This is an AttributeType addition
            next( addContext );
        }
        else
        {
            next( addContext );
        }

    }
    else
    {
        next( addContext );
    }
}
 
Example 10
Source File: SchemaInterceptor.java    From MyVirtualDirectory with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void add( AddOperationContext addContext ) throws LdapException
{
    Dn name = addContext.getDn();
    Entry entry = addContext.getEntry();

    // Not the responsibility of MyVD to verify schema
    //check( name, entry );

    // Special checks for the MetaSchema branch
    if ( name.isDescendantOf( schemaBaseDn ) )
    {
        // get the schema name
        String schemaName = getSchemaName( name );

        if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.META_SCHEMA_OC ) )
        {
            next( addContext );

            if ( schemaManager.isSchemaLoaded( schemaName ) )
            {
                // Update the OC superiors for each added ObjectClass
                computeSuperiors();
            }
        }
        else if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.META_OBJECT_CLASS_OC ) )
        {
            // This is an ObjectClass addition
            checkOcSuperior( addContext.getEntry() );

            next( addContext );

            // Update the structures now that the schema element has been added
            Schema schema = schemaManager.getLoadedSchema( schemaName );

            if ( ( schema != null ) && schema.isEnabled() )
            {
                Attribute oidAT = entry.get( MetaSchemaConstants.M_OID_AT );
                String ocOid = oidAT.getString();

                ObjectClass addedOC = schemaManager.lookupObjectClassRegistry( ocOid );
                computeSuperior( addedOC );
            }
        }
        else if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.META_ATTRIBUTE_TYPE_OC ) )
        {
            // This is an AttributeType addition
            next( addContext );
        }
        else
        {
            next( addContext );
        }

    }
    else
    {
        next( addContext );
    }
}