Package org.apache.directory.shared.ldap.model.cursor

Examples of org.apache.directory.shared.ldap.model.cursor.EntryCursor


            // Use the client API as JNDI cannot be used to do a search without
            // first binding. (hmmm, even client API won't allow searching without binding)
            connection.bind( "uid=admin,ou=system", "secret" );

            // Searches for all the entries in ou=system
            EntryCursor cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)",
                SearchScope.OBJECT, "*" );

            int i = 0;

            while ( cursor.next() )
            {
                cursor.get();
                ++i;
            }

            cursor.close();
            assertEquals( 1, i );

            for ( int j = 0; j < 10000; j++ )
            {
                cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)", SearchScope.OBJECT, "*" );

                while ( cursor.next() )
                {
                }

                cursor.close();
            }

            Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" );

            SearchRequest searchRequest = new SearchRequestImpl();

            searchRequest.setBase( dn );
            searchRequest.setFilter( "(ObjectClass=*)" );
            searchRequest.setScope( SearchScope.OBJECT );
            searchRequest.addAttributes( "*" );
            searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );

            long t0 = System.currentTimeMillis();
            long t00 = 0L;
            long tt0 = System.currentTimeMillis();
            int nbIterations = 200000;
            int count = 0;

            for ( int j = 0; j < nbIterations; j++ )
            {
                if ( j % 10000 == 0 )
                {
                    long tt1 = System.currentTimeMillis();

                    System.out.println( j + ", " + ( tt1 - tt0 ) );
                    tt0 = tt1;
                }

                if ( j == 50000 )
                {
                    t00 = System.currentTimeMillis();
                }

                long dt0 = System.nanoTime();
                cursor = new EntryCursorImpl( connection.search( searchRequest ) );
                long dt1 = System.nanoTime();

                deltaSearch += Math.abs( dt1 - dt0 );

                while ( cursor.next() )
                {
                    long dt2 = System.nanoTime();
                    cursor.get();
                    count++;
                    long dt3 = System.nanoTime();

                    deltaGet += Math.abs( dt3 - dt2 );
                }

                long dt4 = System.nanoTime();
                cursor.close();
                long dt5 = System.nanoTime();

                deltaClose += Math.abs( dt5 - dt4 );
            }

View Full Code Here


            // Use the client API as JNDI cannot be used to do a search without
            // first binding. (hmmm, even client API won't allow searching without binding)
            connection.bind( "uid=admin,ou=system", "secret" );

            // Searches for all the entries in ou=system
            EntryCursor cursor = connection.search( "ou=system", "(ObjectClass=*)",
                SearchScope.ONELEVEL, "*" );

            int i = 0;

            while ( cursor.next() )
            {
                cursor.get();
                ++i;
            }

            cursor.close();
            assertEquals( 5, i );

            for ( int j = 0; j < 10000; j++ )
            {
                cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.ONELEVEL, "*" );

                while ( cursor.next() )
                {
                    cursor.get();
                }

                cursor.close();
            }

            Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" );

            SearchRequest searchRequest = new SearchRequestImpl();

            searchRequest.setBase( dn );
            searchRequest.setFilter( "(ObjectClass=*)" );
            searchRequest.setScope( SearchScope.ONELEVEL );
            searchRequest.addAttributes( "*" );
            searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );

            long t0 = System.currentTimeMillis();
            long t00 = 0L;
            long tt0 = System.currentTimeMillis();
            int nbIterations = 200000;
            int count = 0;

            for ( int j = 0; j < nbIterations; j++ )
            {
                if ( j % 10000 == 0 )
                {
                    long tt1 = System.currentTimeMillis();

                    System.out.println( j + ", " + ( tt1 - tt0 ) );
                    tt0 = tt1;
                }

                if ( j == 50000 )
                {
                    t00 = System.currentTimeMillis();
                }

                cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.ONELEVEL, "*" );

                while ( cursor.next() )
                {
                    count++;
                    cursor.get();
                }

                cursor.close();
            }

            long t1 = System.currentTimeMillis();

            Long deltaWarmed = ( t1 - t00 );
View Full Code Here

            // Use the client API as JNDI cannot be used to do a search without
            // first binding. (hmmm, even client API won't allow searching without binding)
            connection.bind( "uid=admin,ou=system", "secret" );

            // Searches for all the entries in ou=system
            EntryCursor cursor = connection.search( "ou=system", "(ObjectClass=*)",
                SearchScope.SUBTREE, "*" );

            int i = 0;

            while ( cursor.next() )
            {
                cursor.get();
                ++i;
            }

            cursor.close();
            assertEquals( 10, i );

            for ( int j = 0; j < 10000; j++ )
            {
                cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.SUBTREE, "*" );

                while ( cursor.next() )
                {
                    cursor.get();
                }

                cursor.close();
            }

            Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" );

            SearchRequest searchRequest = new SearchRequestImpl();

            searchRequest.setBase( dn );
            searchRequest.setFilter( "(ObjectClass=*)" );
            searchRequest.setScope( SearchScope.SUBTREE );
            searchRequest.addAttributes( "*" );
            searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );

            long t0 = System.currentTimeMillis();
            long t00 = 0L;
            long tt0 = System.currentTimeMillis();
            int nbIterations = 200000;
            int count = 0;

            for ( int j = 0; j < nbIterations; j++ )
            {
                if ( j % 10000 == 0 )
                {
                    long tt1 = System.currentTimeMillis();

                    System.out.println( j + ", " + ( tt1 - tt0 ) );
                    tt0 = tt1;
                }

                if ( j == 50000 )
                {
                    t00 = System.currentTimeMillis();
                }

                cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.SUBTREE, "*" );

                while ( cursor.next() )
                {
                    count++;
                    cursor.get();
                }

                cursor.close();
            }

            long t1 = System.currentTimeMillis();

            Long deltaWarmed = ( t1 - t00 );
View Full Code Here

            if ( filter == null )
            {
                filter = FILTER;
            }

            EntryCursor cursor = connection.search( new Dn( baseDn ), filter, SearchScope.ONELEVEL, "*", "+" );

            while ( cursor.next() )
            {
                Entry entry = cursor.get();
                entries.add( entry );
            }

            cursor.close();

            return entries;
        }
        catch ( LdapException e )
        {
View Full Code Here

    private Map<String, Entry> getAllEntries() throws Exception
    {
        Map<String, Entry> resultMap = new HashMap<String, Entry>();

        EntryCursor cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "+",
            "*" );

        while ( cursor.next() )
        {
            Entry entry = cursor.get();

            resultMap.put( entry.getDn().getName(), entry );
        }
       
        cursor.close();

        return resultMap;
    }
View Full Code Here

    private Map<String, Entry> getAllEntriesRestrictAttributes() throws Exception
    {
        Map<String, Entry> resultMap = new HashMap<String, Entry>();

        EntryCursor cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "cn" );

        while ( cursor.next() )
        {
            Entry entry = cursor.get();
            resultMap.put( entry.getDn().getName(), entry );
        }
       
        cursor.close();

        return resultMap;
    }
View Full Code Here

    private Map<String, Entry> getAllEntriesCollectiveAttributesOnly() throws Exception
    {
        Map<String, Entry> resultMap = new HashMap<String, Entry>();

        EntryCursor cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE,
            "c-ou", "c-st" );

        while ( cursor.next() )
        {
            Entry entry = cursor.get();

            resultMap.put( entry.getDn().getName(), entry );
        }
       
        cursor.close();

        return resultMap;
    }
View Full Code Here

        // Setup the collective attribute specific administration point
        // -------------------------------------------------------------------
        addAdministrativeRole( "collectiveAttributeSpecificArea" );
        connection.add( getTestSubentry( "cn=testsubentry,ou=system" ) );

        EntryCursor cursor = connection.search( "ou=system", "(c-ou=configuration)", SearchScope.SUBTREE, "+",
            "*" );

        boolean found = false;

        while ( cursor.next() )
        {
            Entry entry = cursor.get();

            found = true;
            break;
        }
       
        cursor.close();

        assertTrue( found );
    }
View Full Code Here

        assertEquals( "configuration", c_ou.getString() );

        // -------------------------------------------------------------------
        // Test searching for subtypes
        // -------------------------------------------------------------------
        EntryCursor responses = connection.search( "ou=services,ou=configuration,ou=system",
            "(ObjectClass=*)", SearchScope.OBJECT, "ou" );

        while ( responses.next() )
        {
            entry = responses.get();

            assertEquals( 2, entry.size() );
            assertTrue( entry.containsAttribute( "ou" ) );
            assertTrue( entry.containsAttribute( "c-ou" ) );
            assertTrue( entry.contains( "ou", "services" ) );
            assertTrue( entry.contains( "c-ou", "configuration" ) );
        }
       
        responses.close();

        // ------------------------------------------------------------------
        // test an entry that should show the collective attribute c-ou,
        // but restrict returned attributes to c-ou and c-st
        // ------------------------------------------------------------------
View Full Code Here

     * @param rdn the relative dn from ou=system of the entry to delete recursively
     * @throws Exception if there are problems deleting entries
     */
    private void recursivelyDelete( Dn rdn ) throws Exception
    {
        EntryCursor entries = reusableAdminCon.search( rdn.getName(), "(objectClass=*)",
            SearchScope.ONELEVEL, "*" );

        while ( entries.next() )
        {
            Entry entry = entries.get();
            Dn childRdn = entry.getDn();

            recursivelyDelete( childRdn );
        }

        entries.close();

        reusableAdminCon.delete( rdn );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.cursor.EntryCursor

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.