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

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


        if ( this == obj )
        {
            return true;
        }
       
        Entry other;
       
        if ( obj instanceof ClonedServerEntry )
        {
            other = ((ClonedServerEntry)obj).getClonedEntry();
        }
View Full Code Here


       
       
        public Entry toClientEntry() throws NamingException
        {
            // Copy the DN
            Entry clientEntry = new DefaultClientEntry( dn );
           
            // Convert each attribute
            for ( EntryAttribute serverAttribute:this )
            {
                EntryAttribute clientAttribute = ((ServerAttribute)serverAttribute).toClientAttribute();
                clientEntry.add( clientAttribute );
            }
           
            return clientEntry;
        }
View Full Code Here

     * @throws Exception if there are failures accessing the underlying store
     */
    @SuppressWarnings("unchecked")
    public Entry getAttributes( Store<Object, Long> store, Long id ) throws Exception
    {
        Entry entry = new DefaultClientEntry();

        // Get the distinguishedName to id mapping
        entry.put( "_nDn", store.getEntryDn( id ) );
        entry.put( "_upDn", store.getEntryUpdn( id ) );
        entry.put( "_parent", Long.toString( store.getParentId( id ) ) );

        // Get all standard index attribute to value mappings
        for ( Index index : store.getUserIndices() )
        {
            Cursor<ForwardIndexEntry> list = index.reverseCursor();
            ForwardIndexEntry recordForward = new ForwardIndexEntry();
            recordForward.setId( id );
            list.before( recordForward );

            while ( list.next() )
            {
                IndexEntry rec = list.get();
                String val = rec.getValue().toString();
                String attrId = index.getAttribute().getName();
                EntryAttribute attr = entry.get( attrId );

                if ( attr == null )
                {
                    attr = new DefaultClientAttribute( attrId );
                }

                attr.add( val );
                entry.put( attr );
            }
        }

        // Get all existence mappings for this id creating a special key
        // that looks like so 'existence[attribute]' and the value is set to id
        IndexCursor<String, Object, Long> list = store.getPresenceIndex().reverseCursor();
        ForwardIndexEntry recordForward = new ForwardIndexEntry();
        recordForward.setId( id );
        list.before( recordForward );
        StringBuffer val = new StringBuffer();

        while ( list.next() )
        {
            IndexEntry rec = list.get();
            val.append( "_existence[" );
            val.append( rec.getValue().toString() );
            val.append( "]" );

            String valStr = val.toString();
            EntryAttribute attr = entry.get( valStr );

            if ( attr == null )
            {
                attr = new DefaultClientAttribute( valStr );
            }

            attr.add( rec.getId().toString() );
            entry.put( attr );
            val.setLength( 0 );
        }

        // Get all parent child mappings for this entry as the parent using the
        // key 'child' with many entries following it.
        IndexCursor<Long, Object, Long> children = store.getOneLevelIndex().forwardCursor();
        ForwardIndexEntry longRecordForward = new ForwardIndexEntry();
        recordForward.setId( id );
        children.before( longRecordForward );

        EntryAttribute childAttr = new DefaultClientAttribute( "_child" );
        entry.put( childAttr );

        while ( children.next() )
        {
            IndexEntry rec = children.get();
            childAttr.add( rec.getId().toString() );
View Full Code Here

    public void testLookup() throws Exception
    {
        SearchResponse resp = connection.lookup( ADMIN_DN );
        assertNotNull( resp );
       
        Entry entry = ( ( SearchResultEntry ) resp ).getEntry();
        assertNull( entry.get( SchemaConstants.ENTRY_UUID_AT ) );

        // perform lookup with operational attributes
        resp = connection.lookup( ADMIN_DN, "+", "*" );
        entry = ( ( SearchResultEntry ) resp ).getEntry();
        assertNotNull( entry.get( SchemaConstants.ENTRY_UUID_AT ) );
    }
View Full Code Here

    @Ignore( "failing to lookup an existing entry based on the entryUUID AT" )
    @Test
    public void searchByEntryUuid() throws Exception
    {
        SearchResponse resp = connection.lookup( ADMIN_DN, "+" );
        Entry entry = ( ( SearchResultEntry ) resp ).getEntry();
       
        String uuid = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
       
        EqualityNode<String> filter = new EqualityNode<String>( SchemaConstants.ENTRY_UUID_AT, new ClientStringValue( uuid ) );
       
        Cursor<SearchResponse> cursor = connection.search( ADMIN_DN, filter.toString(), SearchScope.SUBTREE, "+" );
        cursor.next();

        Entry readEntry = ( ( SearchResultEntry ) cursor.get() ).getEntry();
        assertEquals( uuid, readEntry.get( SchemaConstants.ENTRY_UUID_AT ).getString() );
       
        cursor.close();
    }
View Full Code Here

   
    @Ignore( "failing to treat the userPassword AT as a binary attribute" )
    @Test
    public void testRetrieveBinaryAttibute() throws Exception
    {
        Entry entry = ( ( SearchResultEntry ) connection.lookup( "uid=admin,ou=system" ) ).getEntry();
       
        assertTrue( Arrays.equals( "secret".getBytes(), entry.get( SchemaConstants.USER_PASSWORD_AT ).getBytes() ) );
    }
View Full Code Here

   
    @Test
    public void testAdd() throws Exception
    {
        DN dn = new DN( "cn=testadd,ou=system" );
        Entry entry = new DefaultClientEntry( dn );
        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
        entry.add( SchemaConstants.CN_AT, "testadd_cn" );
        entry.add( SchemaConstants.SN_AT, "testadd_sn" );
       
        assertFalse( session.exists( dn ) );
       
        AddResponse response = connection.add( entry );
        assertNotNull( response );
View Full Code Here

   
    @Test
    public void testAddAsync() throws Exception
    {
        DN dn = new DN( "cn=testAsyncAdd,ou=system" );
        Entry entry = new DefaultClientEntry( dn );
        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
        entry.add( SchemaConstants.CN_AT, "testAsyncAdd_cn" );
        entry.add( SchemaConstants.SN_AT, "testAsyncAdd_sn" );
       
        assertFalse( session.exists( dn ) );

        AddFuture addFuture = connection.addAsync( new AddRequest( entry ));
View Full Code Here

        assertNotNull( resp );
       
        DN oldDn = new DN( dn );
        assertFalse( session.exists( oldDn ) );
       
        Entry entry = session.lookup( new DN( "cn=modifyDnWithString,ou=system" ) );
        assertNotNull( entry );
       
        RDN oldRdn = oldDn.getRdn();
        assertTrue( entry.contains( oldRdn.getUpType(), ( String ) oldRdn.getNormValue() ) );
    }
View Full Code Here

    @Test
    public void testModifyWithEntry() throws Exception
    {
        DN dn = new DN( "uid=admin,ou=system" );
       
        Entry entry = new DefaultClientEntry( dn );
       
        String expectedSn = String.valueOf( System.currentTimeMillis() );
        String expectedCn = String.valueOf( System.currentTimeMillis() );
       
        entry.add( SchemaConstants.SN_AT, expectedSn );
       
        entry.add( SchemaConstants.CN_AT, expectedCn );
       
        connection.modify( entry, ModificationOperation.REPLACE_ATTRIBUTE );
       
        ServerEntry lookupEntry = session.lookup( dn );
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.