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

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


            "employeeNumber: A-A-R.Awg-Rosli",
            "pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config" );

        connection.add( entry );

        EntryCursor results = connection.search( "dc=example,dc=com", "(displayName=1*)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            Entry result = results.get();
            assertTrue( result.contains( "displayName", "1Awg-Rosli" ) );
        }

        results.close();

        // Now, modify it
        connection
            .modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "displayName", "test" ) );

        results = connection.search( "dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            Entry result = results.get();
            assertTrue( result.contains( "displayName", "test" ) );
        }

        results.close();

        results = connection.search( "dc=example,dc=com", "(displayName=1*)", SearchScope.SUBTREE, "*" );

        assertFalse( results.next() );

        results.close();
    }
View Full Code Here


        Entry entry1 = null;
        Entry entry2 = null;
        Entry entry3 = null;

        long ns0 = System.currentTimeMillis();
        EntryCursor results = connection.search("dc=example,dc=com", "(displayName=1234Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D)", SearchScope.SUBTREE, "*" );
       
        while ( results.next() )
        {
            if ( entry1 == null )
            {
                entry1 = results.get();
            }
        }

        results.close();

        long ns1 = System.currentTimeMillis();

        System.out.println( "Delta search : " + ( ns1 - ns0 ) );

        long ns2 = System.currentTimeMillis();
        results = connection.search( "dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE, "*" );
               
        while ( results.next() )
        {
            if ( entry2 == null )
            {
                entry2 = results.get();
            }
        }

        results.close();
        long ns3 = System.currentTimeMillis();

        System.out.println( "Delta search substring : " + ( ns3 - ns2 ) );

        long ns4 = System.currentTimeMillis();
        results = connection.search("dc=example,dc=com", "(uid=6789)", SearchScope.SUBTREE, "*" );
               
        while ( results.next() )
        {
            if ( entry3 == null )
            {
                entry3 = results.get();
            }
        }

        results.close();
        long ns5 = System.currentTimeMillis();

        System.out.println( "Delta search no index : " + ( ns5 - ns4 ) );

        //System.out.println( "Entry 1 : " + entry1 );
        //System.out.println( "Entry 2 : " + entry2 );
        //System.out.println( "Entry 3 : " + entry3 );
        connection.close();

        // Now, shutdown and restart the server once more
        System.out.println( "--------------> Shuting Down" );
        getService().shutdown();
        getService().startup();

        // and do a search again
        connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );

        long ns6 = System.currentTimeMillis();
        results = connection.search( "dc=example,dc=com", "(displayName=345*)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            entry3 = results.get();
            break;
        }

        results.close();
        long ns7 = System.currentTimeMillis();
        System.out.println( "New Delta search substring : " + ( ns7 - ns6 ) );

        connection.close();
    }
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

        Dn base = addSearchData( new Dn( "ou=system" ), 3, 10 );
        Dn userDn = new Dn( "uid=" + uid + ",ou=users,ou=system" );
        results.clear();
        LdapConnection userCtx = getConnectionAs( userDn, password );
        EntryCursor cursor = userCtx.search( base.getName(), filter, scope, "*" );
        int counter = 0;

        while ( cursor.next() )
        {
            Entry result = cursor.get();
            results.put( result.getDn().getName(), result );
            counter++;
        }

        cursor.close();

        recursivelyDelete( base );

        return counter == resultSetSz;
    }
View Full Code Here

        addEntryACI( base, aci );
        Dn userDn = new Dn( "uid=" + uid + ",ou=users,ou=system" );

        results.clear();
        LdapConnection userCtx = getConnectionAs( userDn, password );
        EntryCursor cursor = userCtx.search( base.getName(), "(objectClass=*)", scope, "*" );
        int counter = 0;

        while ( cursor.next() )
        {
            Entry result = cursor.get();
            results.put( result.getDn().getName(), result );
            counter++;
        }

        cursor.close();

        recursivelyDelete( base );

        return counter == resultSetSz;
    }
View Full Code Here

    public void testAddSearchData() throws Exception
    {
        LdapConnection connection = getAdminConnection();
        Dn base = addSearchData( new Dn( "ou=system" ), 3, 10 );

        EntryCursor entries = connection.search( base.getName(), "(objectClass=*)", SearchScope.SUBTREE,
            "+" );
        int counter = 0;

        while ( entries.next() )
        {
            entries.get();
            counter++;
        }

        entries.close();

        assertEquals( 10, counter );
        recursivelyDelete( base );

        Entry entry = connection.lookup( base.getName() );
View Full Code Here

     */
    private Entry checkCanSearchSubentryAs( String uid, String password, Dn dn ) throws Exception
    {
        LdapConnection userCtx = getConnectionAs( new Dn( "uid=" + uid + ",ou=users,ou=system" ), password );
        Entry result = null;
        EntryCursor list = null;

        list = userCtx.search( dn.getName(), "(objectClass=*)", SearchScope.OBJECT, "*" );

        if ( list.next() )
        {
            result = list.get();
        }

        list.close();

        return result;
    }
View Full Code Here

        System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 5000 ) * 1000 ) / deltaWarmed )
            + " per s ) /" + ( t1 - t0 ) );

        int nbFound = 0;
        long t2 = System.currentTimeMillis();
        EntryCursor result = connection.search( "dc=example,dc=com", "(sn=test123*)", SearchScope.SUBTREE, "*" );

        while ( result.next() )
        {
            Entry res = result.get();

            System.out.println( res.getDn() );
            nbFound++;
        }

        result.close();
        long t3 = System.currentTimeMillis();
        System.out.println( "Delta search : " + ( t3 - t2 ) + " for " + nbFound + " entries" );

        connection.close();
    }
View Full Code Here

        Entry entry1 = null;
        Entry entry2 = null;
        Entry entry3 = null;

        long ns0 = System.currentTimeMillis();
        EntryCursor results = connection.search( "dc=example,dc=com",
            "(displayName=1234Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            if ( entry1 == null )
            {
                entry1 = results.get();
            }
        }

        results.close();

        long ns1 = System.currentTimeMillis();

        System.out.println( "Delta search : " + ( ns1 - ns0 ) );

        long ns2 = System.currentTimeMillis();
        results = connection.search( "dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            if ( entry2 == null )
            {
                entry2 = results.get();
            }
        }

        results.close();
        long ns3 = System.currentTimeMillis();

        System.out.println( "Delta search substring : " + ( ns3 - ns2 ) );

        long ns4 = System.currentTimeMillis();
        results = connection.search( "dc=example,dc=com", "(uid=6789)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            if ( entry3 == null )
            {
                entry3 = results.get();
            }
        }

        results.close();
        long ns5 = System.currentTimeMillis();

        System.out.println( "Delta search no index : " + ( ns5 - ns4 ) );

        //System.out.println( "Entry 1 : " + entry1 );
        //System.out.println( "Entry 2 : " + entry2 );
        //System.out.println( "Entry 3 : " + entry3 );
        connection.close();

        // Now, shutdown and restart the server once more
        System.out.println( "--------------> Shuting Down" );
        long ns6 = System.currentTimeMillis();
        getService().shutdown();
        long ns7 = System.currentTimeMillis();
        System.out.println( "--------------> completed in " + ( ns7 - ns6 ) );

        long ns8 = System.currentTimeMillis();
        getService().startup();
        long ns9 = System.currentTimeMillis();
        System.out.println( "--------------> Starting up completed in " + ( ns9 - ns8 ) );

        // and do a search again
        connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );

        long ns10 = System.currentTimeMillis();
        results = connection.search( "dc=example,dc=com", "(displayName=345*)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            entry3 = results.get();
            break;
        }

        results.close();
        long ns11 = System.currentTimeMillis();
        System.out.println( "New Delta search substring : " + ( ns11 - ns10 ) );

        connection.close();

        // And again

        // Now, shutdown and restart the server once more
        System.out.println( "--------------> Shuting Down 2" );
        long ns12 = System.currentTimeMillis();
        getService().shutdown();
        long ns13 = System.currentTimeMillis();
        System.out.println( "--------------> completed in " + ( ns13 - ns12 ) );

        long ns14 = System.currentTimeMillis();
        getService().startup();
        long ns15 = System.currentTimeMillis();
        System.out.println( "--------------> Starting up completed in " + ( ns15 - ns14 ) );

        // and do a search again
        connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );

        long ns16 = System.currentTimeMillis();
        results = connection.search( "dc=example,dc=com", "(displayName=345*)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            entry3 = results.get();
            break;
        }

        results.close();
        long ns17 = System.currentTimeMillis();
        System.out.println( "New Delta search substring : " + ( ns17 - ns16 ) );

        connection.close();
    }
View Full Code Here

            "employeeNumber: A-A-R.Awg-Rosli",
            "pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config" );

        connection.add( entry );

        EntryCursor results = connection.search( "dc=example,dc=com", "(displayName=1*)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            Entry result = results.get();
            assertTrue( result.contains( "displayName", "1Awg-Rosli" ) );
        }

        results.close();

        // Now, modify it
        connection
            .modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "displayName", "test" ) );

        results = connection.search( "dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE, "*" );

        while ( results.next() )
        {
            Entry result = results.get();
            assertTrue( result.contains( "displayName", "test" ) );
        }

        results.close();

        results = connection.search( "dc=example,dc=com", "(displayName=1*)", SearchScope.SUBTREE, "*" );

        assertFalse( results.next() );

        results.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.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.