You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by "clauds2x@gmail.com" <cl...@gmail.com> on 2017/01/27 12:16:55 UTC

[LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Hi,

I have an application running in an OSGi container that uses the LDAP 
API and DSML parser and I would like to use the server side sorting control.

When I send the following control...

         <ns2:control criticality="true" type="1.2.840.113556.1.4.473">
             <ns2:controlValue 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:type="xs:base64Binary">MAYwBAQCc24=</ns2:controlValue>
         </ns2:control>

...I get an error: "sorted results control value is absent".

2017-01-27 12:19:37,304 | DEBUG | NioProcessor-1   | 
CODEC_LOG                        | 94 - 
org.apache.directory.api.ldap.net.mina - 1.0.0.RC2 | Decoded LdapMessage 
: MessageType : SEARCH_RESULT_DONE
Message ID : 4
     Search Result Done
         Ldap Result
             Result code : (PROTOCOL_ERROR) protocolError
             Matched Dn : ''
             Diagnostic message : 'sorted results control value is absent'

I saw that an OpaqueControl is created for the sort control. Debugging I 
noticed that setEncodedValue is never called.

org.apache.directory.api.ldap.model.message.SearchRequestImpl@7ea4768c 
OpaqueControl Control
         Type OID    : '1.2.840.113556.1.4.473'
         Criticality : 'true'

Looking into this I came across the control factories registered on 
LdapApiService and saw that there are two implementations:
- DefaultLdapCodecService
- StandaloneLdapApiService

DefaultLdapCodecService is what is initialized in OSGi setup. I noticed 
that DefaultLdapCodecService unlike StandaloneLdapApiService does not 
register SortRequestFactory/SortResponseFactory. To try if this solves 
the issue I registered the two factories but then I get a 
ClassCastException:

Caused by: java.lang.ClassCastException: 
org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to 
org.apache.directory.api.ldap.model.message.controls.SortRequest
     at 
org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
     at 
org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:253)
     at 
org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:329)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
     at 
org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1072)
     at 
org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
     at 
org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:204)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
     at 
org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
     at 
org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:81)
     at 
org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
     ... 58 more

I do not understand how the DSMLv2 parser works together with the LDAP 
codec and start to wonder if the server side sort control is even 
supposed to work at the moment.
- Is it possible that the parser for DSMLv2 does not support the server 
side sort control?
- Should SortRequestFactory/SortResponseFactory be registered or is 
there a reason why they are not registered on DefaultLdapCodecService 
per default?

I would appreciate any hints to get this working.

Cheers
Claudia


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by Emmanuel Lécharny <el...@gmail.com>.

Le 30/01/2017 à 11:37, clauds2x@gmail.com a écrit :
> We don't directly send DSML, we have a custom version of Dsmlv2Engine
> that uses org.apache.directory.api.dsmlv2.Dsmlv2Parser. The issue only
> occurs if we provide the sort control, the code we have is working
> otherwise.

Yeah, sorry for having looked at the stack trace a bit too quickly.

DsmlControl don't have a type, while the various control factories are
expecting to work with a typed control like :

    public class SortRequestFactory implements ControlFactory<SortRequest>

Obviously, converting a DSMLControl, which definition is :

    public class DsmlControl<C extends Control> implements Control,
DsmlDecorator<C>

won't work because the factory expect a SortRequest instance.

Changing the factory to be :

    public class SortRequestFactory implements ControlFactory<Control>

would be better. Another (more 'typed') solution would be to create some
specific DSML control (ie, a SortRequestDsmlControl, etc)

Checking if it does not break the API code atm.

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by Emmanuel Lécharny <el...@gmail.com>.

Le 30/01/2017 à 20:39, clauds2x@gmail.com a écrit :
> Thx for the patch. (Btw is that an svn patch? 
Indeed... We probably wil migrate to Git after 2.0.


> I was unable to apply it using "git apply" and using "patch -p0" I had
> rejects for every file so I had to make most changes manually...)
>
> With the patch I still get the issue, just now in a different place:
>
> Caused by: java.lang.ClassCastException:
> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
> org.apache.directory.api.ldap.model.message.controls.SortRequest
>     at
> org.apache.directory.api.ldap.codec.controls.sort.SortRequestDecorator.getSortKeys(SortRequestDecorator.java:219)
>     at
> org.apache.directory.api.ldap.codec.controls.sort.SortRequestDecorator.computeLength(SortRequestDecorator.java:98)
>     at
> org.apache.directory.api.ldap.codec.api.LdapEncoder.computeControlLength(LdapEncoder.java:73)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.api.LdapEncoder.computeMessageLength(LdapEncoder.java:279)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:160)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:82)
>     at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>     ... 58 more
>
> I still have the feeling the issue is in the DSML lib rather than in
> the codec... IMHO DsmlControl should never reach the codec but it
> does, it gets wrapped:
>
> # SortRequestDecorator:219
>
> this    SortRequestDecorator  (id=12610)
>     decorated    DsmlControl<C>  (id=12489)
>         decorated    SortRequestDecorator  (id=12486)
>             decorated    SortRequestControlImpl  (id=12619)
>
> AbstractDsmlMessageDecorator is used by both request and response,
> addControl wraps the control into a DsmlControl if it isn't already...
> in case of request I would have expected the control to be added to
> the control map as is (without wrapping into DsmlControl). However,
> checking e.g. SearchRequestTest.testRequestWith1Control it expects
> DsmlControl in the assertion even though the request type is
> org.apache.directory.api.ldap.model.message.SearchRequest and not
> SearchRequestDsml.


It seems that you are converting a DSML request to a LDAP request, but
that the DsmlControl does not get converted in the process, is that
correct ? The SortRequestDecorator.computeLength is epxecting a
SortControl instance, when the DSMLControl is untyped. At some point, we
should make it so a DSMLControl is encapsulated into a typed control,
and that would either require a big convertor (ie, a method that check
the control's OID and create a typed control), or specific DSML controls
for each type of control.

I would go for option 2, it's more 'solid'.

Is it possible for you to provide a bit of code demonstrating the
problem (ideally, a unit test) ? I'd like to debug it in order to see
what's going on, and git this fixed.

thanks

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by "clauds2x@gmail.com" <cl...@gmail.com>.
Thx for the patch. (Btw is that an svn patch? I was unable to apply it 
using "git apply" and using "patch -p0" I had rejects for every file so 
I had to make most changes manually...)

With the patch I still get the issue, just now in a different place:

Caused by: java.lang.ClassCastException: 
org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to 
org.apache.directory.api.ldap.model.message.controls.SortRequest
     at 
org.apache.directory.api.ldap.codec.controls.sort.SortRequestDecorator.getSortKeys(SortRequestDecorator.java:219)
     at 
org.apache.directory.api.ldap.codec.controls.sort.SortRequestDecorator.computeLength(SortRequestDecorator.java:98)
     at 
org.apache.directory.api.ldap.codec.api.LdapEncoder.computeControlLength(LdapEncoder.java:73)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
     at 
org.apache.directory.api.ldap.codec.api.LdapEncoder.computeMessageLength(LdapEncoder.java:279)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
     at 
org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:160)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
     at 
org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:82)
     at 
org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
     ... 58 more

I still have the feeling the issue is in the DSML lib rather than in the 
codec... IMHO DsmlControl should never reach the codec but it does, it 
gets wrapped:

# SortRequestDecorator:219

this    SortRequestDecorator  (id=12610)
     decorated    DsmlControl<C>  (id=12489)
         decorated    SortRequestDecorator  (id=12486)
             decorated    SortRequestControlImpl  (id=12619)

AbstractDsmlMessageDecorator is used by both request and response, 
addControl wraps the control into a DsmlControl if it isn't already... 
in case of request I would have expected the control to be added to the 
control map as is (without wrapping into DsmlControl). However, checking 
e.g. SearchRequestTest.testRequestWith1Control it expects DsmlControl in 
the assertion even though the request type is 
org.apache.directory.api.ldap.model.message.SearchRequest and not 
SearchRequestDsml.

On 30/01/17 15:12, Emmanuel L�charny wrote:
> I have patched teh API code in a way that should solve the issue. Can
> you give it a tr, applying this patch :
>
>
> https://paste.apache.org/GDVb
>
>
> ?
>
>
> Le 30/01/2017 � 11:37, clauds2x@gmail.com a �crit :
>> We don't directly send DSML, we have a custom version of Dsmlv2Engine
>> that uses org.apache.directory.api.dsmlv2.Dsmlv2Parser. The issue only
>> occurs if we provide the sort control, the code we have is working
>> otherwise.
>>
>> I am curious if anybody out there is successfully using the sort
>> control with DSMLv2 (OSGi or non-OSGi setup) ?
>> If registering SortRequestFactory/SortResponseFactory was the only
>> known missing part (for OSGI setup) I suspect a bug in the
>> decorator/Dsmlv2Grammar/... Debugging I so far haven't been able to
>> pinpoint where it goes wrong but I will see what I can do, trying to
>> narrow it down and maybe produce a small test to reproduce the issue.
>>
>> On 28/01/17 09:32, Emmanuel L�charny wrote:
>>> Le 27/01/2017 � 19:13, clauds2x@gmail.com a �crit :
>>>> Thanks for the fix.
>>>>
>>>> As I wrote initially I had already tried with registering the two
>>>> factories and got a ClassCastException.
>>>> I tried now with RC3 but as suspected I still get the same
>>>> ClassCastException:
>>>>
>>>> java.lang.ClassCastException:
>>>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>>>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>>> org.apache.mina.filter.codec.ProtocolEncoderException:
>>>> java.lang.ClassCastException:
>>>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>>>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>>>       at
>>>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:330)
>>>>
>>>>       at
>>>> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>>>>
>>>>       at
>>>> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:48)
>>>>
>>>>       at
>>>> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:957)
>>>>
>>>>       at
>>>> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.filterWrite(DefaultIoFilterChain.java:881)
>>>>
>>>>       at
>>>> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>>>>
>>>>       at
>>>> org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterWrite(DefaultIoFilterChain.java:622)
>>>>
>>>>       at
>>>> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:574)
>>>>
>>>>       at
>>>> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:519)
>>>>
>>>>       at
>>>> org.apache.directory.ldap.client.api.LdapNetworkConnection.writeRequest(LdapNetworkConnection.java:4244)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>>>
>>>>       at
>>>> org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:1838)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>>>
>>>>       at
>>>> org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1865)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>>>
>>>>
>>>> ...
>>>>
>>>> Caused by: java.lang.ClassCastException:
>>>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>>>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>>>       at
>>>> org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)
>>>>
>>>>       at
>>>> org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:275)
>>>>
>>>>       at
>>>> org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:340)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>>>
>>>>       at
>>>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1118)
>>>>
>>>>       at
>>>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
>>>>
>>>>       at
>>>> org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:225)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>>>
>>>>       at
>>>> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>>>
>>>>       at
>>>> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:82)
>>>>
>>>>       at
>>>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>>>>
>>>>
>>>> I have the feeling that some link between DSML and codec is missing
>>>> for the (sort) control...
>>> Most certainly. D you have a fragment of code I can play with to find
>>> out what's going on ?
>>>


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by Emmanuel Lécharny <el...@gmail.com>.
I have patched teh API code in a way that should solve the issue. Can
you give it a tr, applying this patch :


https://paste.apache.org/GDVb


?


Le 30/01/2017 à 11:37, clauds2x@gmail.com a écrit :
> We don't directly send DSML, we have a custom version of Dsmlv2Engine
> that uses org.apache.directory.api.dsmlv2.Dsmlv2Parser. The issue only
> occurs if we provide the sort control, the code we have is working
> otherwise.
>
> I am curious if anybody out there is successfully using the sort
> control with DSMLv2 (OSGi or non-OSGi setup) ?
> If registering SortRequestFactory/SortResponseFactory was the only
> known missing part (for OSGI setup) I suspect a bug in the
> decorator/Dsmlv2Grammar/... Debugging I so far haven't been able to
> pinpoint where it goes wrong but I will see what I can do, trying to
> narrow it down and maybe produce a small test to reproduce the issue.
>
> On 28/01/17 09:32, Emmanuel Lécharny wrote:
>>
>> Le 27/01/2017 à 19:13, clauds2x@gmail.com a écrit :
>>> Thanks for the fix.
>>>
>>> As I wrote initially I had already tried with registering the two
>>> factories and got a ClassCastException.
>>> I tried now with RC3 but as suspected I still get the same
>>> ClassCastException:
>>>
>>> java.lang.ClassCastException:
>>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>> org.apache.mina.filter.codec.ProtocolEncoderException:
>>> java.lang.ClassCastException:
>>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>>      at
>>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:330)
>>>
>>>      at
>>> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>>>
>>>      at
>>> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:48)
>>>
>>>      at
>>> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:957)
>>>
>>>      at
>>> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.filterWrite(DefaultIoFilterChain.java:881)
>>>
>>>      at
>>> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>>>
>>>      at
>>> org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterWrite(DefaultIoFilterChain.java:622)
>>>
>>>      at
>>> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:574)
>>>
>>>      at
>>> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:519)
>>>
>>>      at
>>> org.apache.directory.ldap.client.api.LdapNetworkConnection.writeRequest(LdapNetworkConnection.java:4244)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>>
>>>      at
>>> org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:1838)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>>
>>>      at
>>> org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1865)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>>
>>>
>>> ...
>>>
>>> Caused by: java.lang.ClassCastException:
>>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>>      at
>>> org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:275)
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:340)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1118)
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:225)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:82)
>>>
>>>      at
>>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>>>
>>>
>>> I have the feeling that some link between DSML and codec is missing
>>> for the (sort) control...
>> Most certainly. D you have a fragment of code I can play with to find
>> out what's going on ?
>>
>

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by "clauds2x@gmail.com" <cl...@gmail.com>.
We don't directly send DSML, we have a custom version of Dsmlv2Engine 
that uses org.apache.directory.api.dsmlv2.Dsmlv2Parser. The issue only 
occurs if we provide the sort control, the code we have is working 
otherwise.

I am curious if anybody out there is successfully using the sort control 
with DSMLv2 (OSGi or non-OSGi setup) ?
If registering SortRequestFactory/SortResponseFactory was the only known 
missing part (for OSGI setup) I suspect a bug in the 
decorator/Dsmlv2Grammar/... Debugging I so far haven't been able to 
pinpoint where it goes wrong but I will see what I can do, trying to 
narrow it down and maybe produce a small test to reproduce the issue.

On 28/01/17 09:32, Emmanuel L�charny wrote:
>
> Le 27/01/2017 � 19:13, clauds2x@gmail.com a �crit :
>> Thanks for the fix.
>>
>> As I wrote initially I had already tried with registering the two
>> factories and got a ClassCastException.
>> I tried now with RC3 but as suspected I still get the same
>> ClassCastException:
>>
>> java.lang.ClassCastException:
>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>> org.apache.mina.filter.codec.ProtocolEncoderException:
>> java.lang.ClassCastException:
>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>      at
>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:330)
>>      at
>> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>>      at
>> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:48)
>>      at
>> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:957)
>>      at
>> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.filterWrite(DefaultIoFilterChain.java:881)
>>      at
>> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>>      at
>> org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterWrite(DefaultIoFilterChain.java:622)
>>      at
>> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:574)
>>      at
>> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:519)
>>      at
>> org.apache.directory.ldap.client.api.LdapNetworkConnection.writeRequest(LdapNetworkConnection.java:4244)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>      at
>> org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:1838)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>      at
>> org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1865)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>>
>> ...
>>
>> Caused by: java.lang.ClassCastException:
>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>      at
>> org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)
>>      at
>> org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:275)
>>      at
>> org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:340)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>      at
>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1118)
>>      at
>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
>>      at
>> org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:225)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>      at
>> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>>      at
>> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:82)
>>      at
>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>>
>> I have the feeling that some link between DSML and codec is missing
>> for the (sort) control...
> Most certainly. D you have a fragment of code I can play with to find
> out what's going on ?
>


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by Emmanuel Lécharny <el...@gmail.com>.

Le 27/01/2017 à 19:13, clauds2x@gmail.com a écrit :
> Thanks for the fix.
>
> As I wrote initially I had already tried with registering the two
> factories and got a ClassCastException.
> I tried now with RC3 but as suspected I still get the same
> ClassCastException:
>
> java.lang.ClassCastException:
> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
> org.apache.directory.api.ldap.model.message.controls.SortRequest
> org.apache.mina.filter.codec.ProtocolEncoderException:
> java.lang.ClassCastException:
> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
> org.apache.directory.api.ldap.model.message.controls.SortRequest
>     at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:330)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:48)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:957)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.filterWrite(DefaultIoFilterChain.java:881)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterWrite(DefaultIoFilterChain.java:622)
>     at
> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:574)
>     at
> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:519)
>     at
> org.apache.directory.ldap.client.api.LdapNetworkConnection.writeRequest(LdapNetworkConnection.java:4244)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:1838)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1865)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>
> ...
>
> Caused by: java.lang.ClassCastException:
> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
> org.apache.directory.api.ldap.model.message.controls.SortRequest
>     at
> org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)
>     at
> org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:275)
>     at
> org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:340)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1118)
>     at
> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
>     at
> org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:225)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:82)
>     at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>
> I have the feeling that some link between DSML and codec is missing
> for the (sort) control...

Most certainly. D you have a fragment of code I can play with to find
out what's going on ?

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by Emmanuel Lécharny <el...@gmail.com>.
Ah ! I think I see what's wrong  you are trying to send a DSML message
using a LdapNetwork connection. That will simply don't work because a
DSML request is not intended to be sent through a LDP connection, but
through a http connection.


Le 27/01/2017 à 19:13, clauds2x@gmail.com a écrit :
> Thanks for the fix.
>
> As I wrote initially I had already tried with registering the two
> factories and got a ClassCastException.
> I tried now with RC3 but as suspected I still get the same
> ClassCastException:
>
> java.lang.ClassCastException:
> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
> org.apache.directory.api.ldap.model.message.controls.SortRequest
> org.apache.mina.filter.codec.ProtocolEncoderException:
> java.lang.ClassCastException:
> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
> org.apache.directory.api.ldap.model.message.controls.SortRequest
>     at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:330)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:48)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:957)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.filterWrite(DefaultIoFilterChain.java:881)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
>     at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterWrite(DefaultIoFilterChain.java:622)
>     at
> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:574)
>     at
> org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:519)
>     at
> org.apache.directory.ldap.client.api.LdapNetworkConnection.writeRequest(LdapNetworkConnection.java:4244)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:1838)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1865)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
>
> ...
>
> Caused by: java.lang.ClassCastException:
> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
> org.apache.directory.api.ldap.model.message.controls.SortRequest
>     at
> org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)
>     at
> org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:275)
>     at
> org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:340)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1118)
>     at
> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
>     at
> org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:225)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
>     at
> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:82)
>     at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>
> I have the feeling that some link between DSML and codec is missing
> for the (sort) control...
>
> On 27/01/17 15:38, Emmanuel Lécharny wrote:
>> I have committed a fix for this problem. Yu might want to rebuild the
>> API and test it.
>>
>>
>> Le 27/01/2017 à 13:16, clauds2x@gmail.com a écrit :
>>> Hi,
>>>
>>> I have an application running in an OSGi container that uses the LDAP
>>> API and DSML parser and I would like to use the server side sorting
>>> control.
>>>
>>> When I send the following control...
>>>
>>>          <ns2:control criticality="true" type="1.2.840.113556.1.4.473">
>>>              <ns2:controlValue
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:type="xs:base64Binary">MAYwBAQCc24=</ns2:controlValue>
>>>          </ns2:control>
>>>
>>> ...I get an error: "sorted results control value is absent".
>>>
>>> 2017-01-27 12:19:37,304 | DEBUG | NioProcessor-1   |
>>> CODEC_LOG                        | 94 -
>>> org.apache.directory.api.ldap.net.mina - 1.0.0.RC2 | Decoded
>>> LdapMessage : MessageType : SEARCH_RESULT_DONE
>>> Message ID : 4
>>>      Search Result Done
>>>          Ldap Result
>>>              Result code : (PROTOCOL_ERROR) protocolError
>>>              Matched Dn : ''
>>>              Diagnostic message : 'sorted results control value is
>>> absent'
>>>
>>> I saw that an OpaqueControl is created for the sort control. Debugging
>>> I noticed that setEncodedValue is never called.
>>>
>>> org.apache.directory.api.ldap.model.message.SearchRequestImpl@7ea4768c
>>> OpaqueControl Control
>>>          Type OID    : '1.2.840.113556.1.4.473'
>>>          Criticality : 'true'
>>>
>>> Looking into this I came across the control factories registered on
>>> LdapApiService and saw that there are two implementations:
>>> - DefaultLdapCodecService
>>> - StandaloneLdapApiService
>>>
>>> DefaultLdapCodecService is what is initialized in OSGi setup. I
>>> noticed that DefaultLdapCodecService unlike StandaloneLdapApiService
>>> does not register SortRequestFactory/SortResponseFactory. To try if
>>> this solves the issue I registered the two factories but then I get a
>>> ClassCastException:
>>>
>>> Caused by: java.lang.ClassCastException:
>>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>>      at
>>> org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:253)
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:329)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1072)
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:204)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>>
>>>      at
>>> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:81)
>>>
>>>      at
>>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>>>
>>>      ... 58 more
>>>
>>> I do not understand how the DSMLv2 parser works together with the LDAP
>>> codec and start to wonder if the server side sort control is even
>>> supposed to work at the moment.
>>> - Is it possible that the parser for DSMLv2 does not support the
>>> server side sort control?
>>> - Should SortRequestFactory/SortResponseFactory be registered or is
>>> there a reason why they are not registered on DefaultLdapCodecService
>>> per default?
>>>
>>> I would appreciate any hints to get this working.
>>>
>>> Cheers
>>> Claudia
>>>
>

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by "clauds2x@gmail.com" <cl...@gmail.com>.
Thanks for the fix.

As I wrote initially I had already tried with registering the two 
factories and got a ClassCastException.
I tried now with RC3 but as suspected I still get the same 
ClassCastException:

java.lang.ClassCastException: 
org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to 
org.apache.directory.api.ldap.model.message.controls.SortRequest
org.apache.mina.filter.codec.ProtocolEncoderException: 
java.lang.ClassCastException: 
org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to 
org.apache.directory.api.ldap.model.message.controls.SortRequest
     at 
org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:330)
     at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
     at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:48)
     at 
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:957)
     at 
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.filterWrite(DefaultIoFilterChain.java:881)
     at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:629)
     at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterWrite(DefaultIoFilterChain.java:622)
     at 
org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:574)
     at 
org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:519)
     at 
org.apache.directory.ldap.client.api.LdapNetworkConnection.writeRequest(LdapNetworkConnection.java:4244)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
     at 
org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:1838)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]
     at 
org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1865)[88:org.apache.directory.api.ldap.client.api:1.0.0.RC3-SNAPSHOT]

...

Caused by: java.lang.ClassCastException: 
org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to 
org.apache.directory.api.ldap.model.message.controls.SortRequest
     at 
org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)
     at 
org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:275)
     at 
org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:340)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
     at 
org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1118)
     at 
org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
     at 
org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:225)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
     at 
org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC3-SNAPSHOT]
     at 
org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:82)
     at 
org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)

I have the feeling that some link between DSML and codec is missing for 
the (sort) control...

On 27/01/17 15:38, Emmanuel L�charny wrote:
> I have committed a fix for this problem. Yu might want to rebuild the
> API and test it.
>
>
> Le 27/01/2017 � 13:16, clauds2x@gmail.com a �crit :
>> Hi,
>>
>> I have an application running in an OSGi container that uses the LDAP
>> API and DSML parser and I would like to use the server side sorting
>> control.
>>
>> When I send the following control...
>>
>>          <ns2:control criticality="true" type="1.2.840.113556.1.4.473">
>>              <ns2:controlValue
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:type="xs:base64Binary">MAYwBAQCc24=</ns2:controlValue>
>>          </ns2:control>
>>
>> ...I get an error: "sorted results control value is absent".
>>
>> 2017-01-27 12:19:37,304 | DEBUG | NioProcessor-1   |
>> CODEC_LOG                        | 94 -
>> org.apache.directory.api.ldap.net.mina - 1.0.0.RC2 | Decoded
>> LdapMessage : MessageType : SEARCH_RESULT_DONE
>> Message ID : 4
>>      Search Result Done
>>          Ldap Result
>>              Result code : (PROTOCOL_ERROR) protocolError
>>              Matched Dn : ''
>>              Diagnostic message : 'sorted results control value is absent'
>>
>> I saw that an OpaqueControl is created for the sort control. Debugging
>> I noticed that setEncodedValue is never called.
>>
>> org.apache.directory.api.ldap.model.message.SearchRequestImpl@7ea4768c
>> OpaqueControl Control
>>          Type OID    : '1.2.840.113556.1.4.473'
>>          Criticality : 'true'
>>
>> Looking into this I came across the control factories registered on
>> LdapApiService and saw that there are two implementations:
>> - DefaultLdapCodecService
>> - StandaloneLdapApiService
>>
>> DefaultLdapCodecService is what is initialized in OSGi setup. I
>> noticed that DefaultLdapCodecService unlike StandaloneLdapApiService
>> does not register SortRequestFactory/SortResponseFactory. To try if
>> this solves the issue I registered the two factories but then I get a
>> ClassCastException:
>>
>> Caused by: java.lang.ClassCastException:
>> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
>> org.apache.directory.api.ldap.model.message.controls.SortRequest
>>      at
>> org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>      at
>> org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:253)
>>      at
>> org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:329)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>      at
>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1072)
>>      at
>> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
>>      at
>> org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:204)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>      at
>> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>      at
>> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:81)
>>      at
>> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>>      ... 58 more
>>
>> I do not understand how the DSMLv2 parser works together with the LDAP
>> codec and start to wonder if the server side sort control is even
>> supposed to work at the moment.
>> - Is it possible that the parser for DSMLv2 does not support the
>> server side sort control?
>> - Should SortRequestFactory/SortResponseFactory be registered or is
>> there a reason why they are not registered on DefaultLdapCodecService
>> per default?
>>
>> I would appreciate any hints to get this working.
>>
>> Cheers
>> Claudia
>>


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by Emmanuel Lécharny <el...@gmail.com>.
I have committed a fix for this problem. Yu might want to rebuild the
API and test it.


Le 27/01/2017 à 13:16, clauds2x@gmail.com a écrit :
> Hi,
>
> I have an application running in an OSGi container that uses the LDAP
> API and DSML parser and I would like to use the server side sorting
> control.
>
> When I send the following control...
>
>         <ns2:control criticality="true" type="1.2.840.113556.1.4.473">
>             <ns2:controlValue
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:type="xs:base64Binary">MAYwBAQCc24=</ns2:controlValue>
>         </ns2:control>
>
> ...I get an error: "sorted results control value is absent".
>
> 2017-01-27 12:19:37,304 | DEBUG | NioProcessor-1   |
> CODEC_LOG                        | 94 -
> org.apache.directory.api.ldap.net.mina - 1.0.0.RC2 | Decoded
> LdapMessage : MessageType : SEARCH_RESULT_DONE
> Message ID : 4
>     Search Result Done
>         Ldap Result
>             Result code : (PROTOCOL_ERROR) protocolError
>             Matched Dn : ''
>             Diagnostic message : 'sorted results control value is absent'
>
> I saw that an OpaqueControl is created for the sort control. Debugging
> I noticed that setEncodedValue is never called.
>
> org.apache.directory.api.ldap.model.message.SearchRequestImpl@7ea4768c
> OpaqueControl Control
>         Type OID    : '1.2.840.113556.1.4.473'
>         Criticality : 'true'
>
> Looking into this I came across the control factories registered on
> LdapApiService and saw that there are two implementations:
> - DefaultLdapCodecService
> - StandaloneLdapApiService
>
> DefaultLdapCodecService is what is initialized in OSGi setup. I
> noticed that DefaultLdapCodecService unlike StandaloneLdapApiService
> does not register SortRequestFactory/SortResponseFactory. To try if
> this solves the issue I registered the two factories but then I get a
> ClassCastException:
>
> Caused by: java.lang.ClassCastException:
> org.apache.directory.api.dsmlv2.DsmlControl cannot be cast to
> org.apache.directory.api.ldap.model.message.controls.SortRequest
>     at
> org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory.newCodecControl(SortRequestFactory.java:35)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>     at
> org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService.newControl(DefaultLdapCodecService.java:253)
>     at
> org.apache.directory.api.ldap.codec.api.MessageDecorator.addControl(MessageDecorator.java:329)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>     at
> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:1072)
>     at
> org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator.addControl(SearchRequestDecorator.java:83)
>     at
> org.apache.directory.api.ldap.codec.api.MessageDecorator.getDecorator(MessageDecorator.java:204)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>     at
> org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMessage(LdapEncoder.java:159)[89:org.apache.directory.api.ldap.codec.core:1.0.0.RC2]
>     at
> org.apache.directory.api.ldap.codec.protocol.mina.LdapProtocolEncoder.encode(LdapProtocolEncoder.java:81)
>     at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:299)
>     ... 58 more
>
> I do not understand how the DSMLv2 parser works together with the LDAP
> codec and start to wonder if the server side sort control is even
> supposed to work at the moment.
> - Is it possible that the parser for DSMLv2 does not support the
> server side sort control?
> - Should SortRequestFactory/SortResponseFactory be registered or is
> there a reason why they are not registered on DefaultLdapCodecService
> per default?
>
> I would appreciate any hints to get this working.
>
> Cheers
> Claudia
>

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by Emmanuel Lécharny <el...@gmail.com>.

Le 27/01/2017 à 14:09, Kiran Ayyagari a écrit :
> On Fri, Jan 27, 2017 at 5:46 PM, clauds2x@gmail.com <cl...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I have an application running in an OSGi container that uses the LDAP API
>> and DSML parser and I would like to use the server side sorting control.
>>
>> When I send the following control...
>>
>>         <ns2:control criticality="true" type="1.2.840.113556.1.4.473">
>>             <ns2:controlValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:type="xs:base64Binary">MAYwBAQCc24=</ns2:controlValue>
>>         </ns2:control>
>>
>> ...I get an error: "sorted results control value is absent".
>>
>> 2017-01-27 12:19:37,304 | DEBUG | NioProcessor-1   | CODEC_LOG
>>             | 94 - org.apache.directory.api.ldap.net.mina - 1.0.0.RC2 |
>> Decoded LdapMessage : MessageType : SEARCH_RESULT_DONE
>> Message ID : 4
>>     Search Result Done
>>         Ldap Result
>>             Result code : (PROTOCOL_ERROR) protocolError
>>             Matched Dn : ''
>>             Diagnostic message : 'sorted results control value is absent'
>>
>> I saw that an OpaqueControl is created for the sort control. Debugging I
>> noticed that setEncodedValue is never called.
>>
>> org.apache.directory.api.ldap.model.message.SearchRequestImpl@7ea4768c
>> OpaqueControl Control
>>         Type OID    : '1.2.840.113556.1.4.473'
>>         Criticality : 'true'
>>
>> Looking into this I came across the control factories registered on
>> LdapApiService and saw that there are two implementations:
>> - DefaultLdapCodecService
>> - StandaloneLdapApiService
>>
>> DefaultLdapCodecService is what is initialized in OSGi setup. I noticed
>> that DefaultLdapCodecService unlike StandaloneLdapApiService does not
>> register SortRequestFactory/SortResponseFactory. To try if this solves
>> the issue I registered the two factories but then I get a
>> ClassCastException:
>>
>> Caused by: java.lang.ClassCastException: org.apache.directory.api.dsmlv2.DsmlControl
>> cannot be cast to org.apache.directory.api.ldap.
>> model.message.controls.SortRequest
>>     at org.apache.directory.api.ldap.codec.controls.sort.SortReques
>> tFactory.newCodecControl(SortRequestFactory.java:35)[89:org.
>> apache.directory.api.ldap.codec.core:1.0.0.RC2]
>>     at org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecSer
>> vice.newControl(DefaultLdapCodecService.java:253)
>>     at org.apache.directory.api.ldap.codec.api.MessageDecorator.add
>> Control(MessageDecorator.java:329)[89:org.apache.directory.
>> api.ldap.codec.core:1.0.0.RC2]
>>     at org.apache.directory.api.ldap.codec.decorators.SearchRequest
>> Decorator.addControl(SearchRequestDecorator.java:1072)
>>     at org.apache.directory.api.ldap.codec.decorators.SearchRequest
>> Decorator.addControl(SearchRequestDecorator.java:83)
>>     at org.apache.directory.api.ldap.codec.api.MessageDecorator.get
>> Decorator(MessageDecorator.java:204)[89:org.apache.directory
>> .api.ldap.codec.core:1.0.0.RC2]
>>     at org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMe
>> ssage(LdapEncoder.java:159)[89:org.apache.directory.api.
>> ldap.codec.core:1.0.0.RC2]
>>     at org.apache.directory.api.ldap.codec.protocol.mina.LdapProtoc
>> olEncoder.encode(LdapProtocolEncoder.java:81)
>>     at org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite
>> (ProtocolCodecFilter.java:299)
>>     ... 58 more
>>
>> I do not understand how the DSMLv2 parser works together with the LDAP
>> codec and start to wonder if the server side sort control is even supposed
>> to work at the moment.
>> - Is it possible that the parser for DSMLv2 does not support the server
>> side sort control?
>>
> no this case shouldn't arise cause DSML engine internally uses LDAP API to
> perform the operation
>
>> - Should SortRequestFactory/SortResponseFactory be registered or is there
>> a reason why they are not registered on DefaultLdapCodecService per default?
>>
> I am suspecting that this might be the issue.

Yes, it seems the SortRequest/Response factories aren't declared in the
DefaultLdapCodecService. Adding those lines in the loadStockControls()
method should do the trick :


        ControlFactory<SortRequest> sortRequestFactory = new
SortRequestFactory( this );
        controlFactories.put( sortRequestFactory.getOid(),
sortRequestFactory );
        LOG.info( "Registered pre-bundled control factory: {}",
sortRequestFactory.getOid() );

        ControlFactory<SortResponse> sortResponseFactory = new
SortResponseFactory( this );
        controlFactories.put( sortResponseFactory.getOid(),
sortResponseFactory );
        LOG.info( "Registered pre-bundled control factory: {}",
sortResponseFactory.getOid() );

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org


Re: [LDAP API 1.0.0-RC2] server side sorting control with DSMLv2

Posted by Kiran Ayyagari <ka...@apache.org>.
On Fri, Jan 27, 2017 at 5:46 PM, clauds2x@gmail.com <cl...@gmail.com>
wrote:

> Hi,
>
> I have an application running in an OSGi container that uses the LDAP API
> and DSML parser and I would like to use the server side sorting control.
>
> When I send the following control...
>
>         <ns2:control criticality="true" type="1.2.840.113556.1.4.473">
>             <ns2:controlValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:type="xs:base64Binary">MAYwBAQCc24=</ns2:controlValue>
>         </ns2:control>
>
> ...I get an error: "sorted results control value is absent".
>
> 2017-01-27 12:19:37,304 | DEBUG | NioProcessor-1   | CODEC_LOG
>             | 94 - org.apache.directory.api.ldap.net.mina - 1.0.0.RC2 |
> Decoded LdapMessage : MessageType : SEARCH_RESULT_DONE
> Message ID : 4
>     Search Result Done
>         Ldap Result
>             Result code : (PROTOCOL_ERROR) protocolError
>             Matched Dn : ''
>             Diagnostic message : 'sorted results control value is absent'
>
> I saw that an OpaqueControl is created for the sort control. Debugging I
> noticed that setEncodedValue is never called.
>
> org.apache.directory.api.ldap.model.message.SearchRequestImpl@7ea4768c
> OpaqueControl Control
>         Type OID    : '1.2.840.113556.1.4.473'
>         Criticality : 'true'
>
> Looking into this I came across the control factories registered on
> LdapApiService and saw that there are two implementations:
> - DefaultLdapCodecService
> - StandaloneLdapApiService
>
> DefaultLdapCodecService is what is initialized in OSGi setup. I noticed
> that DefaultLdapCodecService unlike StandaloneLdapApiService does not
> register SortRequestFactory/SortResponseFactory. To try if this solves
> the issue I registered the two factories but then I get a
> ClassCastException:
>
> Caused by: java.lang.ClassCastException: org.apache.directory.api.dsmlv2.DsmlControl
> cannot be cast to org.apache.directory.api.ldap.
> model.message.controls.SortRequest
>     at org.apache.directory.api.ldap.codec.controls.sort.SortReques
> tFactory.newCodecControl(SortRequestFactory.java:35)[89:org.
> apache.directory.api.ldap.codec.core:1.0.0.RC2]
>     at org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecSer
> vice.newControl(DefaultLdapCodecService.java:253)
>     at org.apache.directory.api.ldap.codec.api.MessageDecorator.add
> Control(MessageDecorator.java:329)[89:org.apache.directory.
> api.ldap.codec.core:1.0.0.RC2]
>     at org.apache.directory.api.ldap.codec.decorators.SearchRequest
> Decorator.addControl(SearchRequestDecorator.java:1072)
>     at org.apache.directory.api.ldap.codec.decorators.SearchRequest
> Decorator.addControl(SearchRequestDecorator.java:83)
>     at org.apache.directory.api.ldap.codec.api.MessageDecorator.get
> Decorator(MessageDecorator.java:204)[89:org.apache.directory
> .api.ldap.codec.core:1.0.0.RC2]
>     at org.apache.directory.api.ldap.codec.api.LdapEncoder.encodeMe
> ssage(LdapEncoder.java:159)[89:org.apache.directory.api.
> ldap.codec.core:1.0.0.RC2]
>     at org.apache.directory.api.ldap.codec.protocol.mina.LdapProtoc
> olEncoder.encode(LdapProtocolEncoder.java:81)
>     at org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite
> (ProtocolCodecFilter.java:299)
>     ... 58 more
>
> I do not understand how the DSMLv2 parser works together with the LDAP
> codec and start to wonder if the server side sort control is even supposed
> to work at the moment.
> - Is it possible that the parser for DSMLv2 does not support the server
> side sort control?
>
no this case shouldn't arise cause DSML engine internally uses LDAP API to
perform the operation

> - Should SortRequestFactory/SortResponseFactory be registered or is there
> a reason why they are not registered on DefaultLdapCodecService per default?
>
I am suspecting that this might be the issue.

>
> I would appreciate any hints to get this working.
>
> Cheers
> Claudia
>
> Kiran Ayyagari