Le 19/12/2017 à 11:02, Dineth Chalitha Basnayaka a écrit :
> Hi Emmanuel,
>
> After a long time. I hope you can remember me. :-)
The mailing list does :-)
> Your previous answer was very helpful for continuing my project and
> achieved some milestone. Here I got the user data from LDAP entry and store
> those things into different types of databases like MySQL. Now I need to
> build a message response.When I'm going to do that I got the problem "get a
> message ID at the interceptor level".
You can't.
Here, I tried using
> context(eg-addContext) parameter to get the message ID. But I could not get
> it. I would like to know am I missed something or are there have any
> limitations to get the message ID at the interceptor level.
The MessageId is already stored in the response that will be sent back
to the caller.
In the DefaultCoreSession, for each operation (AddRequest for instance),
we create a dedicated context :
public void add( AddRequest addRequest, LogChange log ) throws
LdapException
{
AddOperationContext addContext = new AddOperationContext( this,
addRequest );
...
Then we propagate this context to the server, which does what it has to do :
OperationManager operationManager =
directoryService.getOperationManager();
try
{
operationManager.add( addContext );
}
At this point, we can start thinking about returning a response, which
will contain some extra information if we've got an error (and this is
done in the caller, ie the AddRequestHandler class) :
public void handle( LdapSession session, AddRequest req )
{
LdapResult result = req.getResultResponse().getLdapResult();
try
{
// Call the underlying layer to inject the new entry
CoreSession coreSession = session.getCoreSession();
...
This is where we call the server :
coreSession.add( req );
Now deal with the response :
// If success, here now, otherwise, we would have an exception.
result.setResultCode( ResultCodeEnum.SUCCESS );
// Write the AddResponse message
session.getIoSession().write( req.getResultResponse() );
And we are done : the messageID is automatically stored in the response,
because the response is alrrady present and associaetd with the request
(actally, it has been created when the request has been received).
Note that the messageID for the response is the one stored in the request.
In any case, you never need to take care of that, just make it so the
response is properly returning the way it currently is.
--
Emmanuel Lecharny
Symas.com
directory.apache.org