Package org.apache.directory.shared.ldap.entry

Examples of org.apache.directory.shared.ldap.entry.Entry


     */
    @Test
    public void testLookup() throws Exception
    {
        DN dn = new DN( "cn=test,ou=system" );
        Entry entry = service.getAdminSession().lookup( dn );
       
        assertNotNull( entry );
       
        // We should have 3 attributes
        assertEquals( 3, entry.size() );

        // Check that all the user attributes are present
        assertEquals( "test", entry.get( "cn" ).getString() );
        assertEquals( "sn_test", entry.get( "sn" ).getString() );
        assertTrue( entry.contains( "objectClass", "top", "person" ) );
    }
View Full Code Here


        cursor.beforeFirst();
        int nbRes = 0;
       
        while ( cursor.next() )
        {
            Entry entry = cursor.get();
            assertNotNull( entry );
            assertNotNull( entry.get( "ou" ) );
            assertEquals( "Roles", entry.get( "ou" ).getString() );
            nbRes++;
        }
       
        assertEquals( 1, nbRes );
    }
View Full Code Here

            {
                DN dn = ldifEntry.getDn();

                if ( ldifEntry.isEntry() )
                {
                    Entry entry = ldifEntry.getEntry();
                    boolean filterAccepted = applyFilters( dn, entry );

                    if ( !filterAccepted )
                    {
                        continue;
View Full Code Here

        LOG.debug( "------------- starting handleSearchResult ------------" );

        try
        {
            Entry remoteEntry = syncResult.getEntry();

            Control ctrl = syncResult.getControl( SyncStateValueControl.CONTROL_OID );
            SyncStateValueControl syncStateCtrl = new SyncStateValueControl();

            try
            {
                syncStateCtrl = ( SyncStateValueControl ) syncStateControlDecoder.decode( ctrl.getValue(), syncStateCtrl );
            }
            catch ( Exception e )
            {
                LOG.error( "Failed to decode syncStateControl", e );
            }

            if ( syncStateCtrl.getCookie() != null )
            {
                syncCookie = syncStateCtrl.getCookie();
                LOG.debug( "assigning the cookie from sync state value control: "
                    + StringTools.utf8ToString( syncCookie ) );
            }

            SyncStateTypeEnum state = syncStateCtrl.getSyncStateType();

            LOG.debug( "state name {}", state.name() );

            // check to avoid conversion of UUID from byte[] to String
            if ( LOG.isDebugEnabled() )
            {
                LOG.debug( "entryUUID = {}", StringTools.uuidToString( syncStateCtrl.getEntryUUID() ) );
            }

            switch ( state )
            {
                case ADD:
                    if ( !session.exists( remoteEntry.getDn() ) )
                    {
                        LOG.debug( "adding entry with dn {}", remoteEntry.getDn().getName() );
                        LOG.debug( remoteEntry.toString() );
                        session.add( new DefaultServerEntry( schemaManager, remoteEntry ) );
                    }
                    // in refreshOnly mode the modified entry will be sent with state ADD
                    else if( !config.isRefreshPersist() )
                    {
                        LOG.debug( "updating entry in refreshOnly mode {}", remoteEntry.getDn().getName() );
                        modify( remoteEntry );
                    }

                    break;

                case MODIFY:
                    LOG.debug( "modifying entry with dn {}", remoteEntry.getDn().getName() );
                    modify( remoteEntry );
                    break;

                case DELETE:
                    LOG.debug( "deleting entry with dn {}", remoteEntry.getDn().getName() );
                    session.delete( remoteEntry.getDn() );
                    break;

                case PRESENT:
                    LOG.debug( "entry present {}", remoteEntry );
                    break;
View Full Code Here

    }


    private void modify( Entry remoteEntry ) throws Exception
    {
        Entry localEntry = session.lookup( remoteEntry.getDn() );

        remoteEntry.removeAttributes( MOD_IGNORE_AT );

        List<Modification> mods = new ArrayList<Modification>();
        Iterator<EntryAttribute> itr = localEntry.iterator();

        while ( itr.hasNext() )
        {
            EntryAttribute localAttr = itr.next();
            String attrId = localAttr.getId();
View Full Code Here

     * Test for method DefaultServerEntry()
     */
    @Test
    public void testDefaultServerEntry() throws Exception
    {
        Entry entry = new DefaultServerEntry();
        assertNotNull( entry );
        assertEquals( DN.EMPTY_DN, entry.getDn() );
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test for method DefaultServerEntry( registries )
     */
    @Test
    public void testDefaultServerEntryRegistries() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager );
        assertNotNull( entry );
        assertEquals( DN.EMPTY_DN, entry.getDn() );
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test for method DefaultServerEntry( registries, DN )
     */
    @Test
    public void testDefaultServerEntryRegistriesDN() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
        assertNotNull( entry );
        assertEquals( EXAMPLE_DN, entry.getDn() );
        assertEquals( 0, entry.size() );
    }
View Full Code Here

     * Test for method add( EntryAttribute...)
     */
    @Test
    public void testAddEntryAttribute() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        EntryAttribute oc = new DefaultServerAttribute( atObjectClass, "top", "person" );
        EntryAttribute cn = new DefaultServerAttribute( atCN, "test1", "test2" );
        EntryAttribute sn = new DefaultServerAttribute( atSN, "Test1", "Test2" );
        EntryAttribute up = new DefaultServerAttribute( atPwd, BYTES1, BYTES2 );
        EntryAttribute c = new DefaultServerAttribute( atC, "FR", "US" );
       
        entry.add( oc, cn, sn, c );
       
        assertEquals( 4, entry.size() );
        assertTrue( entry.containsAttribute( "ObjectClass" ) );
        assertTrue( entry.containsAttribute( "CN" ) );
        assertTrue( entry.containsAttribute( "  sn  " ) );
        assertTrue( entry.containsAttribute( " countryName  " ) );
   
        EntryAttribute attr = entry.get( "objectclass" );
        assertEquals( 2, attr.size() );
       
        EntryAttribute c2 = new DefaultServerAttribute( atC, "UK", "DE" );
        entry.add( c2, up );
        assertEquals( 5, entry.size() );
       
        assertTrue( entry.containsAttribute( "userPassword" ) );
        assertTrue( entry.containsAttribute( " countryName " ) );

        EntryAttribute attrC = entry.get( "countryName" );
        assertEquals( 4, attrC.size() );
       
        entry.clear();
    }
View Full Code Here

        for ( LdifEntry testEntry : testEntries )
        {
            try
            {
                LdifEntry ldifEntry = testEntry.clone();
                Entry entry = ldifEntry.getEntry();
                String dn = ldifEntry.getDn().getName();

                try
                {
                    getAdminSession().add( new DefaultServerEntry( schemaManager, entry ) );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.Entry

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.