03-09-2012 03:30 PM
Hi,
I have a forum topic and I try to add a post to it.
I have the following restlet:
@Name(value = "discussionService")
@Scope(ScopeType.EVENT)
public class DiscussionService extends BaseStatelessNuxeoRestlet {...
And declaration:
<restletPlugin
name="discussionService"
class="com.sirma.itt.rs.rest.DiscussionService"
enabled="true"
useSeam="true"
useConversation="true">
<urlPatterns>
<urlPattern>/discussionService</urlPattern>
</urlPatterns>
</restletPlugin>
Also, navigationContext is injected:
@In(create = true)
private transient NavigationContext navigationContext;
Then I get a json request, that contains Nuxeo UID of an existing forum topic and I try to add a post to it:
documentManager = SessionFactory.getSession(getHttpRequest(req));
DocumentModel replyToDoc = documentManager.getDocument(new IdRef(replyTo));
log.debug("replyToDoc "+replyTo); // this is the topic; it exists
if (replyToDoc != null) {
navigationContext.setCurrentDocument(replyToDoc);
navigationContext.setChangeableDocument(replyToDoc);
}
DocumentModel dm = documentManager.createDocumentModel("CustomPost");
dm.setProperty(....);
dm.setProperty(....);
....
dm = commentManagerActions.addComment(dm);
....
I am getting the following exception:
java.lang.NullPointerException
at org.nuxeo.ecm.webapp.context.NavigationContextBean.setCurrentDocument(NavigationContextBean.java:192)
Unfortunately, I could not get the 5.5 source code so I have no idea what's on row 192 in NavigationContextBean.
Is this the proper way of doing this task? Is there a similar example somewhere? And what is the reason for the NullPointerException?
Thanks!
03-09-2012 05:02 PM
I changed my code to:
navigationContext.setCurrentServerLocation(new RepositoryLocation("default"));
documentManager = navigationContext.getOrCreateDocumentManager();
and saving the post seems to work.
03-09-2012 05:02 PM
I changed my code to:
navigationContext.setCurrentServerLocation(new RepositoryLocation("default"));
documentManager = navigationContext.getOrCreateDocumentManager();
and saving the post seems to work.
03-12-2012 11:14 AM
I strongly recommend you to look example of Nuxeo into our source code. You have many examples in the nuxeo-platform-ui-web project.
03-12-2012 11:05 AM
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.