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

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


            .lookupAttributeTypeRegistry( SchemaConstants.SURNAME_AT ) );

        String attribVal = "Walker";
        attrib.add( attribVal );

        Modification add = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attrib );
        mods.add( add );

        ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );

        store.modify( dn, mods );
View Full Code Here


            .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );

        String attribVal = "Johnny";
        attrib.add( attribVal );

        Modification add = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
        mods.add( add );

        ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );

        assertEquals( "WAlkeR", lookedup.get( "sn" ).get().getString() ); // before replacing
View Full Code Here

        List<Modification> mods = new ArrayList<Modification>();
        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SN_AT, schemaManager
            .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );

        Modification add = new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
        mods.add( add );

        ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );

        assertNotNull( lookedup.get( "sn" ).get() );
View Full Code Here

            .lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) );

        String attribVal = "Marketing";
        attrib.add( attribVal );

        Modification add = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
        mods.add( add );

        ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );

        assertNull( lookedup.get( "ou" ) ); // before replacing
View Full Code Here

    @Test public void testCreateServerModification()
    {
        ServerAttribute attribute = new DefaultServerAttribute( atCN );
        attribute.add( "test1", "test2" );
       
        Modification mod = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
        Modification clone = mod.clone();
       
        attribute.remove( "test2" );
       
        ServerAttribute clonedAttribute = (ServerAttribute)clone.getAttribute();
       
        assertEquals( 1, mod.getAttribute().size() );
        assertTrue( mod.getAttribute().contains( "test1" ) );

        assertEquals( 2, clonedAttribute.size() );
        assertTrue( clone.getAttribute().contains( "test1" ) );
        assertTrue( clone.getAttribute().contains( "test2" ) );
    }
View Full Code Here

    @Test
    public void testCopyServerModification()
    {
        ServerAttribute attribute = new DefaultServerAttribute( atC );
        attribute.add( "test1", "test2" );
        Modification serverModification = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
       
        Modification copy = new ServerModification( schemaManager, serverModification );
       
        assertTrue( copy instanceof ServerModification );
        assertEquals( copy, serverModification );
       
        serverModification.setOperation( ModificationOperation.REMOVE_ATTRIBUTE );
        assertEquals( ModificationOperation.ADD_ATTRIBUTE, copy.getOperation() );
       
        ServerAttribute attribute2 = new DefaultServerAttribute( atCN, "t" );
        serverModification.setAttribute( attribute2 );
        assertNotSame( attribute2, copy.getAttribute() );
    }
View Full Code Here

    @Test
    public void testCopyClientModification()
    {
        ClientAttribute attribute = new DefaultClientAttribute( atC.getName() );
        attribute.add( "test1", "test2" );
        Modification clientModification = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
       
        Modification copy = new ServerModification( schemaManager, clientModification );
       
        assertTrue( copy instanceof ServerModification );
        assertFalse( copy instanceof ClientModification );
        assertFalse( copy.equalsclientModification ) );
        assertTrue( copy.getAttribute() instanceof ServerAttribute );
        assertEquals( atC, ((ServerAttribute)copy.getAttribute()).getAttributeType() );
        assertEquals( ModificationOperation.ADD_ATTRIBUTE, copy.getOperation() );
        assertTrue( copy.getAttribute().contains( "test1", "test2" ) );
       
        clientModification.setOperation( ModificationOperation.REMOVE_ATTRIBUTE );
        assertEquals( ModificationOperation.ADD_ATTRIBUTE, copy.getOperation() );
       
        ClientAttribute attribute2 = new DefaultClientAttribute( "cn", "t" );
        clientModification.setAttribute( attribute2 );
        assertNotSame( attribute2, copy.getAttribute() );
    }
View Full Code Here

     *
     */
    public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws Exception
    {
        ServerEntry serverEntry = null;
        Modification modification = ServerEntryUtils.getModificationItem( opContext.getModItems(), entryDeleted );
        boolean isDelete = ( modification != null );

        if ( ! isDelete && ( changeLog.isEnabled() && opContext.isFirstOperation() ) )
        {
            // @todo make sure we're not putting in operational attributes that cannot be user modified
            serverEntry = getAttributes( opContext );
        }
       
        // Duplicate modifications so that the reverse does not contain the operational attributes
        List<Modification> clonedMods = new ArrayList<Modification>();

        for ( Modification mod : opContext.getModItems() )
        {
            clonedMods.add( mod.clone() );
        }

        // Call the next interceptor
        next.modify( opContext );

        // @TODO: needs big consideration!!!
        // NOTE: perhaps we need to log this as a system operation that cannot and should not be reapplied?
        if (
            isDelete ||  
            ! changeLog.isEnabled() ||
            ! opContext.isFirstOperation() ||
           
         // if there are no modifications due to stripping out bogus non-
         // existing attributes then we will have no modification items and
         // should ignore not this without registering it with the changelog
        
            opContext.getModItems().size() == 0
        {
            if ( isDelete )
            {
                LOG.debug( "Bypassing changelog on modify of entryDeleted attribute." );
            }
           
            return;
        }

        LdifEntry forward = new LdifEntry();
        forward.setChangeType( ChangeType.Modify );
        forward.setDn( opContext.getDn() );
       
        List<Modification> mods = new ArrayList<Modification>( clonedMods.size() );
       
        for ( Modification modItem : clonedMods )
        {
            Modification mod = ((ServerModification)modItem).toClientModification();
           
            // TODO: handle correctly http://issues.apache.org/jira/browse/DIRSERVER-1198
            mod.getAttribute().setId( modItem.getAttribute().getId() );
            mods.add( mod );
           
            forward.addModificationItem( mod );
        }
       
View Full Code Here

        EntryAttribute attribute = new DefaultServerAttribute( atCN );
        attribute.add( "test1", "test2" );
       
        ServerModification mod = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
       
        Modification modSer = deserializeValue( serializeValue( mod ) );
       
        assertEquals( mod, modSer );
    }
View Full Code Here

        EntryAttribute attribute = new DefaultServerAttribute( atCN );
        attribute.add( "test1", "test2" );
       
        ServerModification mod = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
       
        Modification modSer = deserializeValue( serializeValue( mod ) );
       
        assertEquals( mod, modSer );
    }
View Full Code Here

TOP

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

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.