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

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


    service.setWorkingDirectory(new File("target/ldap-work"));
   
    service.getChangeLog().setEnabled(false);
    service.setDenormalizeOpAttrsEnabled(true);   

    Partition camundaPartition = createPartition("camunda", BASE_DN);
    createIndex(camundaPartition, "objectClass", "ou", "uid");

    ldapService = new LdapServer();
    ldapService.setTransports(new TcpTransport(Integer.parseInt(port)));
    ldapService.setDirectoryService(service);

    service.startup();
    ldapService.start();

    // Create the root entry
    if (!service.getAdminSession().exists(camundaPartition.getSuffixDn())) {
      LdapDN dn = new LdapDN(BASE_DN);
      ServerEntry entry = service.newEntry(dn);
      entry.add("objectClass", "top", "domain");
      entry.add("dc", "camunda");
      service.getAdminSession().add(entry);
View Full Code Here


      service.getAdminSession().add(entry);
    }
  }

  protected Partition createPartition(String partitionId, String partitionDn) throws Exception {
    Partition partition = new JdbmPartition();
    partition.setId(partitionId);
    partition.setSuffix(partitionDn);
    service.addPartition(partition);
    return partition;
  }
View Full Code Here

     */
    @Test
    public void testImportContextEntryRefreshesRootDSE() throws Exception
    {
        // add a new partition
        Partition partition = new JdbmPartition();
        partition.setId( "example" );
        partition.setSuffix( "dc=example,dc=com" );
        ldapServer.getDirectoryService().addPartition( partition );

        // refresh root DSE and ensure that the partition is in root DSE
        browserViewBot.selectEntry( "DIT", "Root DSE" );
        browserViewBot.refresh();
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

    }
   
   
    private void initializeSystemPartition() throws Exception
    {
        Partition system = getSystemPartition();
       
        // Add root context entry for system partition
        Dn systemSuffixDn = getDnFactory().create( ServerDNConstants.SYSTEM_DN );
        CoreSession adminSession = getAdminSession();

        if ( !system.hasEntry( new EntryOperationContext( adminSession, systemSuffixDn ) ) )
        {
            Entry systemEntry = new DefaultEntry( schemaManager, systemSuffixDn );
           
            // Add the ObjectClasses
            systemEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC,
                SchemaConstants.ORGANIZATIONAL_UNIT_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC );
           
            // Add some operational attributes
            systemEntry.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN );
            systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
            systemEntry.add( SchemaConstants.ENTRY_CSN_AT, getCSN().toString() );
            systemEntry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
            systemEntry.put( DnUtils.getRdnAttributeType( ServerDNConstants.SYSTEM_DN ), DnUtils
                .getRdnValue( ServerDNConstants.SYSTEM_DN ) );
           
            AddOperationContext addOperationContext = new AddOperationContext( adminSession, systemEntry );
            system.add( addOperationContext );
        }
    }
View Full Code Here

            if ( partitionBean.isDisabled() )
            {
                continue;
            }
           
            Partition partition = createPartition( directoryService, partitionBean );
           
            if ( partition != null )
            {
                partitions.put( partitionBean.getPartitionId(), partition );
            }
View Full Code Here

        directoryService.setInterceptors( interceptors );
       
        // Partitions
        Map<String, Partition> partitions = createPartitions( directoryService, directoryServiceBean.getPartitions() );

        Partition systemPartition = partitions.remove( "system" );

        if ( systemPartition == null )
        {
            //throw new Exception( I18n.err( I18n.ERR_505 ) );
        }
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(
                        service.getSchemaManager(),
                        createPartition.name(),
                        createPartition.suffix(),
                        createPartition.cacheSize(),
                        new File( service.getInstanceLayout().getPartitionsDirectory(), 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.
                Class<?> partypes[] = new Class[]{SchemaManager.class};
                Constructor<?> constructor = createPartition.type().getConstructor(partypes);
                partition = (Partition)constructor.newInstance( new Object[]{service.getSchemaManager()} );
                partition.setId( createPartition.name() );
                partition.setSuffixDn( new Dn( service.getSchemaManager(), createPartition.suffix() ) );

                if ( partition instanceof AbstractBTreePartition<?> )
                {
                    AbstractBTreePartition<?> btreePartition = ( AbstractBTreePartition<?> ) partition;
                    btreePartition.setCacheSize( createPartition.cacheSize() );
                    btreePartition.setPartitionPath( new File( service
                            .getInstanceLayout().getPartitionsDirectory(),
                            createPartition.name() ).toURI() );

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

                    for ( CreateIndex createIndex : indexes )
                    {
                        // The annotation does not specify a specific index
                        // type.
                        // We use the generic index implementation.
                        JdbmIndex index = new JdbmIndex();
                        index.setAttributeId( createIndex.attribute() );

                        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

        // 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( directoryService.getSchemaManager(),
            "system", ServerDNConstants.SYSTEM_DN, 500,
            new File( directoryService.getInstanceLayout().getPartitionsDirectory(), "system" ) );
        systemPartition.setSchemaManager( directoryService.getSchemaManager() );

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

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

                    LOG.info( "setting the schema manager for partition {}", p.getSuffixDn() );
                    p.setSchemaManager( schemaManager );
                }
            }
           
            Partition sysPartition = directoryService.getSystemPartition();
           
            if( sysPartition instanceof AbstractBTreePartition )
            {
                File partitionPath = new File( directoryService.getInstanceLayout().getPartitionsDirectory(), sysPartition.getId() );
                ( ( AbstractBTreePartition ) sysPartition ).setPartitionPath( partitionPath.toURI() );
            }

            if( sysPartition.getSchemaManager() == null )
            {
                LOG.info( "setting the schema manager for partition {}", sysPartition.getSuffixDn() );
                sysPartition.setSchemaManager( schemaManager );
            }
           
            // Start the directory service if not started yet
            LOG.debug( "1. Starting the DirectoryService" );
            directoryService.startup();
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.