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

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


    {
        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


        if ( text == null )
        {
            text = "";
        }

        Entry entry = readEntry( text );
        setValue( entry );
    }
View Full Code Here

     * Test method for hasObjectClass( String )
     */
    @Test
    public void testHasObjectClassString() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        assertFalse( entry.containsAttribute( "objectClass" ) );
        assertFalse( entry.hasObjectClass( "top" ) );
       
        entry.add( new DefaultServerAttribute( atOC, "top", "person" ) );
       
        assertTrue( entry.hasObjectClass( "top" ) );
        assertTrue( entry.hasObjectClass( "person" ) );
        assertFalse( entry.hasObjectClass( "inetorgperson" ) );
        assertFalse( entry.hasObjectClass( null ) );
        assertFalse( entry.hasObjectClass( "" ) );
    }
View Full Code Here

     * Test method for setDN( DN )
     */
    @Test
    public void testSetDn()
    {
        Entry entry = new DefaultServerEntry( schemaManager );
        
        assertEquals( DN.EMPTY_DN, entry.getDn() );
        
        entry.setDn( EXAMPLE_DN );
        assertEquals( EXAMPLE_DN, entry.getDn() );
    }
View Full Code Here

     * Test the copy constructor of a ServerEntry
     */
    @Test
    public void testCopyConstructorServerEntry() throws NamingException
    {
        Entry serverEntry = new DefaultServerEntry( schemaManager );
        serverEntry.add( "cn", "test1", "test2" );
        serverEntry.add( "objectClass", "top", "person" );
       
        Entry copyEntry = new DefaultServerEntry( schemaManager, serverEntry );
       
        assertEquals( copyEntry, serverEntry );
        assertTrue( copyEntry.contains( "objectClass", "top", "person" ) );
        assertTrue( copyEntry.contains( "cn", "test1", "test2" ) );
       
        serverEntry.removeAttributes( "cn" );

        assertNotSame( copyEntry, serverEntry );
        assertTrue( copyEntry.contains( "objectClass", "top", "person" ) );
        assertTrue( copyEntry.contains( "cn", "test1", "test2" ) );
    }
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

        ServerEntry serverEntry = new DefaultServerEntry( schemaManager );
        serverEntry.setDn( dn );
        serverEntry.add( "cn", "test1", "test2" );
        serverEntry.add( "objectClass", "top", "person" );
       
        Entry clientEntry = serverEntry.toClientEntry();
       
        assertTrue( clientEntry instanceof ClientEntry );
        assertFalse( clientEntry instanceof ServerEntry );
       
        assertTrue( clientEntry.containsAttribute( "cn", "objectClass" ) );
        assertEquals( dn, clientEntry.getDn() );
       
        serverEntry.removeAttributes( "cn" );
        assertTrue( clientEntry
            .contains( "cn", "test1", "test2" ) );
       
        serverEntry.remove"objectClass", "person" );
        assertTrue( clientEntry
            .contains( "objectClass", "top", "person" ) );
    }
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

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.