Package org.apache.directory.server.core.partition

Examples of org.apache.directory.server.core.partition.Partition


    @Test
    public void testAddAndRemove() throws Exception
    {
        PartitionFactory partitionFactory = DefaultDirectoryServiceFactory.DEFAULT.getPartitionFactory();
        Partition partition = partitionFactory.createPartition( "removable", "ou=removable", 100, service
            .getWorkingDirectory() );

        // Test AddContextPartition
        service.addPartition( partition );

        DN suffixDn = new DN( "ou=removable" );
        suffixDn.normalize( service.getSchemaManager().getNormalizerMapping() );
        ServerEntry ctxEntry = new DefaultServerEntry( service.getSchemaManager(), suffixDn );
        ctxEntry.put( "objectClass", "top" );
        ctxEntry.get( "objectClass" ).add( "organizationalUnit" );
        ctxEntry.put( "ou", "removable" );
        ctxEntry.put( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        ctxEntry.put( "entryUUID", UUID.randomUUID().toString() );
        partition.add( new AddOperationContext( service.getAdminSession(), ctxEntry ) );

        Hashtable<String, Object> env = new Hashtable<String, Object>();
        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
        env.put( DirectoryService.JNDI_KEY, service );
        env.put( Context.SECURITY_CREDENTIALS, "secret" );
View Full Code Here


            ModificationItem[] mods = new ModificationItem[]
                { new ModificationItem( DirContext.REMOVE_ATTRIBUTE, disabled ) };
            schemaRoot.modifyAttributes( "cn=nis", mods );
        }

        Partition systemPartition = service.getSystemPartition();
        DefaultDirectoryServiceFactory.DEFAULT.getPartitionFactory().addIndex( systemPartition, "gidNumber", 100 );

        // -------------------------------------------------------------------
        // Add a bunch of nis groups
        // -------------------------------------------------------------------
View Full Code Here

        // change the working directory to something that is unique
        // on the system and somewhere either under target directory
        // or somewhere in a temp area of the machine.

        // Inject the System Partition
        Partition systemPartition = partitionFactory.createPartition( "system", ServerDNConstants.SYSTEM_DN, 500,
            new File( directoryService.getWorkingDirectory(), "system" ) );
        systemPartition.setSchemaManager( directoryService.getSchemaManager() );

        partitionFactory.addIndex( systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100 );

        directoryService.setSystemPartition( systemPartition );
    }
View Full Code Here

        dsf.init( dsBuilder.name() );

        // Process the Partition, if any.
        for ( CreatePartition createPartition : dsBuilder.partitions() )
        {
            Partition partition;

            // Determine the partition type
            if ( createPartition.type() == Partition.class )
            {
                // The annotation does not specify a specific partition type.
                // We use the partition factory to create partition and index instances.
                PartitionFactory partitionFactory = dsf.getPartitionFactory();
                partition = partitionFactory.createPartition( createPartition.name(), createPartition.suffix(),
                    createPartition.cacheSize(), new File( service.getWorkingDirectory(), createPartition.name() ) );

                CreateIndex[] indexes = createPartition.indexes();
                for ( CreateIndex createIndex : indexes )
                {
                    partitionFactory.addIndex( partition, createIndex.attribute(), createIndex.cacheSize() );
                }
            }
            else
            {
                // The annotation contains a specific partition type, we use that type.
                partition = createPartition.type().newInstance();
                partition.setId( createPartition.name() );
                partition.setSuffix( createPartition.suffix() );

                if ( partition instanceof BTreePartition<?> )
                {
                    BTreePartition<?> btreePartition = ( BTreePartition<?> ) partition;
                    btreePartition.setCacheSize( createPartition.cacheSize() );
                    btreePartition.setPartitionDir( new File( service.getWorkingDirectory(), createPartition.name() ) );

                    // Process the indexes if any
                    CreateIndex[] indexes = createPartition.indexes();

                    for ( CreateIndex createIndex : indexes )
                    {
                        Index index;
                        if ( createIndex.type() == Index.class )
                        {
                            // The annotation does not specify a specific index type.
                            // We use the generic index implementation.
                            index = new GenericIndex( createIndex.attribute(), createIndex.cacheSize() );
                        }
                        else
                        {
                            // The annotation contains a specific index type, we use that type.
                            index = createIndex.type().newInstance();
                            index.setAttributeId( createIndex.attribute() );
                            index.setCacheSize( createIndex.cacheSize() );
                        }
                        btreePartition.addIndexedAttributes( index );
                    }
                }
            }

            partition.setSchemaManager( service.getSchemaManager() );

            // Inject the partition into the DirectoryService
            service.addPartition( partition );

            // Last, process the context entry
View Full Code Here

    {
        /** A structure to hold all the partitions */
        DnNode<Partition> partitionLookupTree = new DnNode<Partition>();

        Dn suffix = new Dn( schemaManager, "dc=example, dc=com" );
        Partition partition = new JdbmPartition( schemaManager );
        partition.setSuffixDn( suffix );

        partitionLookupTree.add( suffix, partition );

        assertNotNull( partitionLookupTree );
        assertTrue( partitionLookupTree.hasChildren() );
View Full Code Here

    {
        /** A structure to hold all the partitions */
        DnNode<Partition> partitionLookupTree = new DnNode<Partition>();

        Dn suffix1 = new Dn( schemaManager, "dc=example, dc=com" );
        Partition partition1 = new JdbmPartition( schemaManager );
        partition1.setSuffixDn( suffix1 );

        partitionLookupTree.add( suffix1, partition1 );

        Dn suffix2 = new Dn( schemaManager, "ou=system" );
        Partition partition2 = new JdbmPartition( schemaManager );
        partition2.setSuffixDn( suffix2 );

        partitionLookupTree.add( suffix2, partition2 );

        assertNotNull( partitionLookupTree );
        assertTrue( partitionLookupTree.hasChildren() );
View Full Code Here

    {
        /** A structure to hold all the partitions */
        DnNode<Partition> partitionLookupTree = new DnNode<Partition>();

        Dn suffix1 = new Dn( schemaManager, "dc=example1, dc=com" );
        Partition partition1 = new JdbmPartition( schemaManager );
        partition1.setSuffixDn( suffix1 );

        partitionLookupTree.add( suffix1, partition1 );

        Dn suffix2 = new Dn( schemaManager, "dc=example2, dc=com" );
        Partition partition2 = new JdbmPartition( schemaManager );
        partition2.setSuffixDn( suffix2 );

        partitionLookupTree.add( suffix2, partition2 );

        assertNotNull( partitionLookupTree );

View Full Code Here

        interceptors.add(new KeyDerivationInterceptor());
        directoryService.setInterceptors(interceptors);
        directoryServiceFactory.init("defaultDS");

        PartitionFactory partitionFactory = directoryServiceFactory.getPartitionFactory();
        Partition partition = partitionFactory.createPartition("example", "dc=example,dc=com",
                1000, new File(directoryService.getWorkingDirectory(), "example"));

        partitionFactory.addIndex(partition, "objectClass", 1000);
        partitionFactory.addIndex(partition, "dc", 1000);
        partitionFactory.addIndex(partition, "ou", 1000);

        partition.setSchemaManager(directoryService.getSchemaManager());
        // Inject the partition into the DirectoryService
        directoryService.addPartition(partition);

        InputStream is = KerberosServiceStarter.class.getClassLoader().getResourceAsStream("kerberos/kerberos.ldif");
        LdifReader ldifReader = new LdifReader(is);
View Full Code Here

            {
                TaggableSearchableChangeLogStore tmp = ( TaggableSearchableChangeLogStore ) store;
               
                tmp.createPartition( partitionSuffix, revContainerName, tagContainerName );
               
                Partition partition = tmp.getPartition();
                partition.init( service );

                service.addPartition( partition );
            }
        }
       
View Full Code Here

    {
        /** A structure to hold all the partitions */
        DnBranchNode<Partition> partitionLookupTree = new DnBranchNode<Partition>();
       
        LdapDN suffix = new LdapDN( "dc=example, dc=com" );
        Partition partition = new JdbmPartition();
        partition.setSuffix( suffix.getUpName() );
       
        partitionLookupTree.add( suffix, partition );
       
        assertNotNull( partitionLookupTree );
        assertTrue( partitionLookupTree instanceof DnBranchNode );
View Full Code Here

TOP

Related Classes of org.apache.directory.server.core.partition.Partition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.