directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yiannis Mavroukakis <imavrouka...@gameaccount.com>
Subject Re: [ApacheDS] Using LdifEntry with a ModifyOperationContext
Date Wed, 18 Mar 2009 14:48:27 GMT


Emmanuel Lecharny wrote:
> Yiannis Mavroukakis wrote:
>>
>> Hello everyone :-)
>>
>> I've got a problem trying to use LdifEntry with 
>> ModifyOperationContext. If you remember from
>> previous emails, I'm using LdifEntry because it can be serialized. 
>> I'm stuffing my Modification
>> objects in the LdifEntry object like so
>>
>>        for( AttributeType attributeType : list )
>>        {
>>            EntryAttribute entryAttribute = ( (ServerAttribute) entry
>>                    .get( attributeType ) ).toClientAttribute( );
>>            ldiff.addAttribute( entryAttribute );
>>            if( changeType.equals( ChangeType.Modify ) )
>>            {
>>                ClientModification mod = new ClientModification(
>>                        ModificationOperation.REPLACE_ATTRIBUTE ,
>>                        entryAttribute );
>>                ldiff.addModificationItem( mod );
>>            }
>>        }
>>
>> This serializes fine, however ModifyOperationContext.modify() gives me a
>>
>> java.lang.ClassCastException: 
>> org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute 
>> cannot be cast to org.apache.directory.server.core.entry.ServerAttribute
>>
>> when I pass the LdifEntry object modification list to it because it 
>> expects ServerAttributes and not ClientAttributes and as far as I can 
>> remember, ServerAttributes are not serializable (?). Is there any way 
>> I can get around this requirement?
> Just store the initial entry.getAttribute() into the modification :
>
>       for( AttributeType attributeType : list )
>       {
>           EntryAttribute entryAttribute = ( (ServerAttribute) entry
>                   .get( attributeType ) ).toClientAttribute( );
>           ldiff.addAttribute( entryAttribute );
>           if( changeType.equals( ChangeType.Modify ) )
>           {
>               ClientModification mod = new ClientModification(
>                       ModificationOperation.REPLACE_ATTRIBUTE ,
>                       entry.get( attributeType ) );                  
> <----------------------
>               ldiff.addModificationItem( mod );
>           }
>       }
>
> It should work.
>
>
Whoops :-)

81d:36
java.lang.IllegalStateException: Cannot use standard serialization for a 
ServerAttribute
        at 
org.apache.directory.server.core.entry.DefaultServerAttribute.writeExternal(DefaultServerAttribute.java:1190)
        at 
java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1421)


Mime
View raw message