Package org.apache.directory.server.xdbm

Examples of org.apache.directory.server.xdbm.Index



    @Test
    public void testConvertIndex() throws Exception
    {
        Index nonJdbmIndex = new GenericIndex( "ou", 10, new File( "." ) );

        Method convertIndex = store.getClass().getDeclaredMethod( "convertIndex", Index.class );
        convertIndex.setAccessible( true );
        Object obj = convertIndex.invoke( store, nonJdbmIndex );
View Full Code Here


                    // 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 );
                    }
                }
            }
View Full Code Here


    @Test
    public void testSubLevelIndex() throws Exception
    {
        Index idx = store.getSubLevelIndex();

        assertEquals( 19, idx.count() );

        Cursor<IndexEntry<Long, Entry, Long>> cursor = idx.forwardCursor( 2L );

        assertTrue( cursor.next() );
        assertEquals( 2, ( long ) cursor.get().getId() );

        assertTrue( cursor.next() );
        assertEquals( 5, ( long ) cursor.get().getId() );

        assertTrue( cursor.next() );
        assertEquals( 6, ( long ) cursor.get().getId() );

        assertFalse( cursor.next() );

        idx.drop( 5L );

        cursor = idx.forwardCursor( 2L );

        assertTrue( cursor.next() );
        assertEquals( 2, ( long ) cursor.get().getId() );

        assertTrue( cursor.next() );
        assertEquals( 6, ( long ) cursor.get().getId() );

        assertFalse( cursor.next() );

        // dn id 12
        Dn martinDn = new Dn( schemaManager, "cn=Marting King,ou=Sales,o=Good Times Co." );
        Entry entry = new DefaultEntry( schemaManager, martinDn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Sales" );
        entry.add( "cn", "Martin King" );
        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        entry.add( "entryUUID", UUID.randomUUID().toString() );
        AddOperationContext addContext = new AddOperationContext( null, entry );
        store.add( addContext );

        cursor = idx.forwardCursor( 2L );
        cursor.afterLast();
        assertTrue( cursor.previous() );
        assertEquals( 12, ( long ) cursor.get().getId() );

        Dn newParentDn = new Dn( schemaManager, "ou=Board of Directors,o=Good Times Co." );

        Dn newDn = newParentDn.add( martinDn.getRdn() );

        store.move( martinDn, newParentDn, newDn, entry );
        cursor = idx.forwardCursor( 3L );
        cursor.afterLast();
        assertTrue( cursor.previous() );
        assertEquals( 12, ( long ) cursor.get().getId() );

        // dn id 13
        Dn marketingDn = new Dn( schemaManager, "ou=Marketing,ou=Sales,o=Good Times Co." );
        entry = new DefaultEntry( schemaManager, marketingDn );
        entry.add( "objectClass", "top", "organizationalUnit" );
        entry.add( "ou", "Marketing" );
        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        entry.add( "entryUUID", UUID.randomUUID().toString() );
        addContext = new AddOperationContext( null, entry );
        store.add( addContext );

        // dn id 14
        Dn jimmyDn = new Dn( schemaManager, "cn=Jimmy Wales,ou=Marketing, ou=Sales,o=Good Times Co." );
        entry = new DefaultEntry( schemaManager, jimmyDn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Marketing" );
        entry.add( "cn", "Jimmy Wales" );
        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        entry.add( "entryUUID", UUID.randomUUID().toString() );
        addContext = new AddOperationContext( null, entry );
        store.add( addContext );

        newDn = newParentDn.add( marketingDn.getRdn() );

        store.move( marketingDn, newParentDn, newDn, entry );

        cursor = idx.forwardCursor( 3L );
        cursor.afterLast();

        assertTrue( cursor.previous() );
        assertEquals( 14, ( long ) cursor.get().getId() );
View Full Code Here

     * @param idxAttr the name of the index or its attribute
     * @throws Exception if the indices cannot be accessed
     */
    public void showIndexDialog( String idxAttr ) throws Exception
    {
        Index index;
        boolean isSystem = partition.hasSystemIndexOn( idxAttr );

        if ( isSystem )
        {
            index = partition.getSystemIndex( idxAttr );
View Full Code Here


    @Test
    public void testSubLevelIndex() throws Exception
    {
        Index idx = store.getSubLevelIndex();

        assertEquals( 19, idx.count() );

        Cursor<IndexEntry<Long, Attributes, Long>> cursor = idx.forwardCursor( 2L );

        assertTrue( cursor.next() );
        assertEquals( 2, ( long ) cursor.get().getId() );

        assertTrue( cursor.next() );
        assertEquals( 5, ( long ) cursor.get().getId() );

        assertTrue( cursor.next() );
        assertEquals( 6, ( long ) cursor.get().getId() );

        assertFalse( cursor.next() );

        idx.drop( 5L );

        cursor = idx.forwardCursor( 2L );

        assertTrue( cursor.next() );
        assertEquals( 2, ( long ) cursor.get().getId() );

        assertTrue( cursor.next() );
        assertEquals( 6, ( long ) cursor.get().getId() );

        assertFalse( cursor.next() );

        // dn id 12
        DN martinDn = new DN( "cn=Marting King,ou=Sales,o=Good Times Co." );
        martinDn.normalize( schemaManager.getNormalizerMapping() );
        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, martinDn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Sales" );
        entry.add( "cn", "Martin King" );
        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        entry.add( "entryUUID", UUID.randomUUID().toString() );
        store.add( entry );

        cursor = idx.forwardCursor( 2L );
        cursor.afterLast();
        assertTrue( cursor.previous() );
        assertEquals( 12, ( long ) cursor.get().getId() );

        DN newParentDn = new DN( "ou=Board of Directors,o=Good Times Co." );
        newParentDn.normalize( schemaManager.getNormalizerMapping() );

        store.move( martinDn, newParentDn );
        cursor = idx.forwardCursor( 3L );
        cursor.afterLast();
        assertTrue( cursor.previous() );
        assertEquals( 12, ( long ) cursor.get().getId() );

        // dn id 13
        DN marketingDn = new DN( "ou=Marketing,ou=Sales,o=Good Times Co." );
        marketingDn.normalize( schemaManager.getNormalizerMapping() );
        entry = new DefaultServerEntry( schemaManager, marketingDn );
        entry.add( "objectClass", "top", "organizationalUnit" );
        entry.add( "ou", "Marketing" );
        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        entry.add( "entryUUID", UUID.randomUUID().toString() );
        store.add( entry );

        // dn id 14
        DN jimmyDn = new DN( "cn=Jimmy Wales,ou=Marketing, ou=Sales,o=Good Times Co." );
        jimmyDn.normalize( schemaManager.getNormalizerMapping() );
        entry = new DefaultServerEntry( schemaManager, jimmyDn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Marketing" );
        entry.add( "cn", "Jimmy Wales" );
        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
        entry.add( "entryUUID", UUID.randomUUID().toString() );
        store.add( entry );

        store.move( marketingDn, newParentDn );

        cursor = idx.forwardCursor( 3L );
        cursor.afterLast();

        assertTrue( cursor.previous() );
        assertEquals( 14, ( long ) cursor.get().getId() );
View Full Code Here


    @Test
    public void testConvertIndex() throws Exception
    {
        Index nonAvlIndex = new GenericIndex( "ou", 10, new File( "." ) );

        Method convertIndex = store.getClass().getDeclaredMethod( "convert", Index.class );
        convertIndex.setAccessible( true );
        Object obj = convertIndex.invoke( store, nonAvlIndex );
View Full Code Here

   

    @Test
    public void testSubLevelIndex() throws Exception
    {
      Index idx = store.getSubLevelIndex();
     
      assertEquals( 19, idx.count() );
     
      Cursor<IndexEntry<Long,Attributes>> cursor = idx.forwardCursor( 2L );
     
      assertTrue( cursor.next() );
      assertEquals( 2, ( long ) cursor.get().getId() );
     
      assertTrue( cursor.next() );
      assertEquals( 5, ( long ) cursor.get().getId() );
     
      assertTrue( cursor.next() );
      assertEquals( 6, ( long ) cursor.get().getId() );

      assertFalse( cursor.next() );
     
      idx.drop( 5L );
     
      cursor = idx.forwardCursor( 2L );

      assertTrue( cursor.next() );
      assertEquals( 2, ( long ) cursor.get().getId() );
     
      assertTrue( cursor.next() );
      assertEquals( 6, ( long ) cursor.get().getId() );
     
      assertFalse( cursor.next() );
     
      // dn id 12
      LdapDN martinDn = new LdapDN( "cn=Marting King,ou=Sales,o=Good Times Co." );
      martinDn.normalize( attributeRegistry.getNormalizerMapping() );
      DefaultServerEntry entry = new DefaultServerEntry( registries, martinDn );
      entry.add( "objectClass", "top", "person", "organizationalPerson" );
      entry.add( "ou", "Sales" );
      entry.add( "cn""Martin King");
      entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
      entry.add( "entryUUID", SchemaUtils.uuidToBytes( UUID.randomUUID() ) );
      store.add( entry );
     
      cursor = idx.forwardCursor( 2L);
      cursor.afterLast();
      assertTrue( cursor.previous() );
      assertEquals( 12, ( long ) cursor.get().getId() );
     
      LdapDN newParentDn = new LdapDN( "ou=Board of Directors,o=Good Times Co." );
      newParentDn.normalize( attributeRegistry.getNormalizerMapping() );
     
      store.move( martinDn, newParentDn );
      cursor = idx.forwardCursor( 3L);
      cursor.afterLast();
      assertTrue( cursor.previous() );
      assertEquals( 12, ( long ) cursor.get().getId() );
     
      // dn id 13
      LdapDN marketingDn = new LdapDN( "ou=Marketing,ou=Sales,o=Good Times Co." );
      marketingDn.normalize( attributeRegistry.getNormalizerMapping() );
      entry = new DefaultServerEntry( registries, marketingDn );
      entry.add( "objectClass", "top", "organizationalUnit" );
      entry.add( "ou", "Marketing" );
      entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
      entry.add( "entryUUID", SchemaUtils.uuidToBytes( UUID.randomUUID() ) );
      store.add( entry );

      // dn id 14
      LdapDN jimmyDn = new LdapDN( "cn=Jimmy Wales,ou=Marketing, ou=Sales,o=Good Times Co." );
      jimmyDn.normalize( attributeRegistry.getNormalizerMapping() );
      entry = new DefaultServerEntry( registries, jimmyDn );
      entry.add( "objectClass", "top", "person", "organizationalPerson" );
      entry.add( "ou", "Marketing" );
      entry.add( "cn""Jimmy Wales");
      entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
      entry.add( "entryUUID", SchemaUtils.uuidToBytes( UUID.randomUUID() ) );
      store.add( entry );
     
      store.move( marketingDn, newParentDn );

      cursor = idx.forwardCursor( 3L);
      cursor.afterLast();

      assertTrue( cursor.previous() );
      assertEquals( 14, ( long ) cursor.get().getId() );
     
View Full Code Here

  
   
    @Test
    public void testConvertIndex() throws Exception
    {
        Index nonJdbmIndex = new Index()
        {

            public void add( Object attrVal, Long id ) throws Exception { }

            public void close() throws Exception { }
View Full Code Here

     * @param idxAttr the name of the index or its attribute
     * @throws Exception if the indices cannot be accessed
     */
    public void showIndexDialog( String idxAttr ) throws Exception
    {
        Index index;
        boolean isSystem = partition.hasSystemIndexOn( idxAttr );

        if ( isSystem )
        {
            index = partition.getSystemIndex( idxAttr );
View Full Code Here

     */
    public void showIndexDialog( String idxAttr ) throws Exception
    {
        AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( idxAttr );

        Index index;
        boolean isSystem = partition.hasSystemIndexOn( attributeType );

        if ( isSystem )
        {
            index = partition.getSystemIndex( attributeType );
View Full Code Here

TOP

Related Classes of org.apache.directory.server.xdbm.Index

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.