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

Examples of org.apache.directory.shared.ldap.entry.client.DefaultClientEntry


     * @return An instance of ClientEntry
     */
    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


        try
        {
            String cn = "entry-" + System.currentTimeMillis();
            LdapDN dn = new LdapDN( "cn=" + cn + "," + config.getBaseDn() );
            DefaultClientEntry entry = new DefaultClientEntry();
            entry.add( "objectclass", "inetOrgPerson", "organizationalPerson", "person" );
            entry.add( "cn", cn );
            entry.add( "sn", cn );
            entry.setDn( dn );

            LOG.debug( "adding entry with dn: {}" + dn );
            connection.add( entry );
        }
        catch ( Exception e )
View Full Code Here

    {
        StringReader strIn = new StringReader( text );
        BufferedReader in = new BufferedReader( strIn );

        String line = null;
        Entry entry = new DefaultClientEntry();

        try
        {
            while ( ( line = in.readLine() ) != null )
            {
                if ( line.length() == 0 )
                {
                    continue;
                }

                String addedLine = line.trim();

                if ( StringTools.isEmpty( addedLine ) )
                {
                    continue;
                }

                EntryAttribute attribute = AttributeUtils.toClientAttribute(
                    LdifReader.parseAttributeValue( addedLine ) );
                EntryAttribute oldAttribute = entry.get( attribute.getId() );

                if ( oldAttribute != null )
                {
                    try
                    {
                        oldAttribute.add( attribute.get() );
                        entry.put( oldAttribute );
                    }
                    catch ( NamingException ne )
                    {
                        // Do nothing
                    }
                }
                else
                {
                    try
                    {
                        entry.put( attribute );
                    }
                    catch ( NamingException ne )
                    {
                        // TODO do nothing ...
                    }
View Full Code Here

     * Test the copy constructor of a ClientEntry
     */
    @Test
    public void testCopyConstructorClientEntry() throws NamingException
    {
        Entry clientEntry = new DefaultClientEntry();
        clientEntry.setDn( new DN( "ou=system" ) );
        clientEntry.add( "cn", "test1", "test2" );
        clientEntry.add( "objectClass", "top", "person" );
       
        Entry copyEntry = new DefaultServerEntry( schemaManager, clientEntry );
       
        assertTrue( copyEntry instanceof ServerEntry );
        assertTrue( copyEntry.contains( "objectClass", "top", "person" ) );
        assertTrue( copyEntry.contains( "cn", "test1", "test2" ) );
       
        clientEntry.removeAttributes( "cn" );

        assertTrue( copyEntry.contains( "objectClass", "top", "person" ) );
        assertTrue( copyEntry.contains( "cn", "test1", "test2" ) );
    }
View Full Code Here

    {
        StringReader strIn = new StringReader( text );
        BufferedReader in = new BufferedReader( strIn );

        String line = null;
        Entry entry = new DefaultClientEntry();

        try
        {
            while ( ( line = in.readLine() ) != null )
            {
                if ( line.length() == 0 )
                {
                    continue;
                }

                String addedLine = line.trim();

                if ( StringTools.isEmpty( addedLine ) )
                {
                    continue;
                }

                EntryAttribute attribute = AttributeUtils.toClientAttribute( LdifReader.parseAttributeValue( addedLine ) );
                EntryAttribute oldAttribute = entry.get( attribute.getId() );

                if ( oldAttribute != null )
                {
                    try
                    {
                        oldAttribute.add( attribute.get() );
                        entry.put( oldAttribute );
                    }
                    catch (NamingException ne)
                    {
                        // Do nothing
                    }
                }
                else
                {
                    try
                    {
                        entry.put( attribute );
                    }
                    catch ( NamingException ne )
                    {
                        // Do nothing...
                    }
View Full Code Here

        LdifEntry forward = new LdifEntry();
        forward.setChangeType( ChangeType.Delete );
        forward.setDn( opContext.getDn() );
       
        Entry reverseEntry = new DefaultClientEntry( serverEntry.getDn() );

        for ( EntryAttribute attribute : serverEntry )
        {
            // filter collective attributes, they can't be added by the revert operation
            AttributeType at = schemaService.getSchemaManager().getAttributeTypeRegistry().lookup( attribute.getId() );
            if ( !at.isCollective() )
            {
                reverseEntry.add( ( ( ServerAttribute ) attribute ).toClientAttribute() );
            }
        }

        LdifEntry reverse = LdifRevertor.reverseDel( opContext.getDn(), reverseEntry );
        opContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverse ) );
View Full Code Here

            mods.add( mod );
           
            forward.addModificationItem( mod );
        }
       
        Entry clientEntry = new DefaultClientEntry( serverEntry.getDn() );
       
        for ( EntryAttribute attribute:serverEntry )
        {
            clientEntry.add( ((ServerAttribute)attribute).toClientAttribute() );
        }

        LdifEntry reverse = LdifRevertor.reverseModify(
            opContext.getDn(),
            mods,
View Full Code Here


    public Entry toClientEntry() throws NamingException
    {
        // Copy the DN
        Entry clientEntry = new DefaultClientEntry( clonedEntry.getDn() );
       
        // Convert each attribute
        for ( EntryAttribute clonedEntry:this )
        {
            EntryAttribute clientAttribute = ((ServerAttribute)clonedEntry).toClientAttribute();
            clientEntry.add( clientAttribute );
        }
       
        return clientEntry;
    }
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

TOP

Related Classes of org.apache.directory.shared.ldap.entry.client.DefaultClientEntry

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.