As we know, IBM Content Navigator is a powerfull framework, but a complicated framework too. And, because IBM Content Navigator is a web application, you have to take care about concurrency !
The initial problematic
I wanted to retrieve all documents with some specific user-oriented security. I declared a simple service, querying the Content Engine Object Store, then returning my documents. In this case, and according to this bug, I noticed 2 things:
- the service returns only the user-oriented security documents,
- the service returns some documents without any relationship with my specific user.
It was at this moment he knew…
And yes, like I said in the excerpt, Content Navigator is a web based application, and I have to deal with thread safe problematics ! When a service is queried, Content Navigator is sending, in the PluginServiceCallbacks object, the P8 subject. Knowing that, we can push it to FileNet before querying it, and poping it when it’s done.
Ok so… How to do this ?
The easiest way to do it, as I know, is the following :
@Override public void execute(PluginServiceCallbacks callbacks, HttpServletRequest request, HttpServletResponse response) throws Exception { // Computing object, preparing request... try { // Retrieving subject Subject subject = callbacks.getP8Subject(callbacks.getRepositoryId()); // Pushing subject UserContext.get().pushSubject(subject); // Querying FileNet } catch (Exception e) { // Handling exception, maybe formatting response to Content Navigator... } finally { // Poping subject UserContext.get().popSubject(); } }
Before querying FileNet, you just have to retrieve the associated subject from the callback, then pushing it. When the request is done, you just have to pop the subject for next calls :-).