<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating a forum post from restlet in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313153#M154</link>
    <description>&lt;P&gt;I strongly recommend you to look example of Nuxeo into our source code. You have many examples in the nuxeo-platform-ui-web project.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Mar 2012 15:14:37 GMT</pubDate>
    <dc:creator>Benjamin_Jalon1</dc:creator>
    <dc:date>2012-03-12T15:14:37Z</dc:date>
    <item>
      <title>Creating a forum post from restlet</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313150#M151</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a forum topic and I try to add a post to it.&lt;/P&gt;
&lt;P&gt;I have the following restlet:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@Name(value = "discussionService")
@Scope(ScopeType.EVENT)
public class DiscussionService extends BaseStatelessNuxeoRestlet {...
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And declaration:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;restletPlugin
        name="discussionService"
        class="com.sirma.itt.rs.rest.DiscussionService"
        enabled="true"
        useSeam="true"
        useConversation="true"&amp;gt;
        &amp;lt;urlPatterns&amp;gt;
            &amp;lt;urlPattern&amp;gt;/discussionService&amp;lt;/urlPattern&amp;gt;
        &amp;lt;/urlPatterns&amp;gt;
    &amp;lt;/restletPlugin&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, navigationContext is injected:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@In(create = true)
private transient NavigationContext navigationContext;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then I get a json request, that contains Nuxeo UID of an existing forum topic and I try to add a post to it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    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);
    ....
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am getting the following exception:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;java.lang.NullPointerException
	at org.nuxeo.ecm.webapp.context.NavigationContextBean.setCurrentDocument(NavigationContextBean.java:192)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Unfortunately, I could not get the 5.5 source code so I have no idea what's on row 192 in NavigationContextBean.&lt;/P&gt;
&lt;P&gt;Is this the proper way of doing this task? Is there a similar example somewhere? And what is the reason for the NullPointerException?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2012 20:30:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313150#M151</guid>
      <dc:creator>jana01_</dc:creator>
      <dc:date>2012-03-09T20:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a forum post from restlet</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313151#M152</link>
      <description>&lt;P&gt;I changed my code to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    navigationContext.setCurrentServerLocation(new RepositoryLocation("default"));
    documentManager = navigationContext.getOrCreateDocumentManager();
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and saving the post seems to work.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2012 22:02:48 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313151#M152</guid>
      <dc:creator>jana01_</dc:creator>
      <dc:date>2012-03-09T22:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a forum post from restlet</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313152#M153</link>
      <description>&lt;UL&gt;
&lt;LI&gt;If you want the source code download it fom [here][1] and go to the 5.5 branch.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 12 Mar 2012 15:05:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313152#M153</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-03-12T15:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a forum post from restlet</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313153#M154</link>
      <description>&lt;P&gt;I strongly recommend you to look example of Nuxeo into our source code. You have many examples in the nuxeo-platform-ui-web project.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2012 15:14:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/creating-a-forum-post-from-restlet/m-p/313153#M154</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-03-12T15:14:37Z</dc:date>
    </item>
  </channel>
</rss>

