It's all about the answers!

Ask a question

How can I add a comment to a RAM discussion using the Java API?


Dennis Schultz (55157) | asked Oct 25 '14, 1:03 a.m.
JAZZ DEVELOPER
I want to add a comment programmatically through the Java API.  I have made a few attempts with things like

topic.createPost("title", "description") and asset.getForums()[0].getTopics()[0].setPosts(newPostArray).  I get no errors or exceptions, but my the comments in the discussion area of my asset are not updated.

Is it possible to add comments to an asset? 

I will also need to add ratings to assets as well.  Is that also possible?

Thanks,
Dennis

One answer



permanent link
Lin Lu (3063) | answered Oct 26 '14, 9:12 p.m.
JAZZ DEVELOPER
Hi,

I think the sample in documentation works for me in 7521, here is a url for your reference:
http://pic.dhe.ibm.com/infocenter/ramhelp/v7r5m1/topic/com.ibm.ram.doc/topics/r_api_createaforum.html

My guess is that you may need to call put in the end of process to make you change in client side about forum and topics submitted to server.

Thanks.

Comments
Dennis Schultz commented Oct 26 '14, 10:21 p.m.
JAZZ DEVELOPER

Ah yes, you are correct - I had forgotten the "put".  Thanks for that.

Now I have a follow-up question.  I have been able to add a new post to the topic, but the post always is authored by the person that created the session.  I would like to have that comment authored by someone else.  I have tried the following:

        RAMTopic topic = (RAMTopic)asset.getForums()[0].getTopics()[0];
        RAMPost post = topic.createPost("title", "description");
        RAMUser user = session.getUser("username@company.com");
        System.out.println("Comment author is " + user.getName());
        post.setSubmitter(user);

I have also tried extracting the posts array from the topic, adding my new post and then setting the new post array with
     topic.setPosts(newPostsArray);
but get an error "Method is not executable by the client".


Lin Lu commented Oct 27 '14, 1:53 a.m.
JAZZ DEVELOPER

I think

RAMUser user = session.getUser("username@company.com");
System.out.println("Comment author is " + user.getName());
post.setSubmitter(user); 
works. One thing need to be noticed is that one need to make sure the user has the access to asset and asset's discussion, or I am afraid that the new post will NOT be udpated.

Would you check if the user id you specified has the access to target asset and its discussion? if it is a yes, would you offer the info of the RAM repository you are using, like the version, and the user role you specify for that user id.

Thanks.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.