How to list Folder Comments using Alfresco JAVA API

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2013 12:02 PM
I am searching for sample code to list down all the comments for particular node .
I found some webscript to list down the comments of the folder but could not find the sample code for JAVA API.
I want create custom webscript to list down the comments of the folder.
Can anyone help me please.
I found some webscript to list down the comments of the folder but could not find the sample code for JAVA API.
public class CommentsController extends AbstractWebScript { private ServiceRegistry serviceRegistry; @Override public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException { WebScriptServletRequest servletRequest = (WebScriptServletRequest) req; response.setContentType("application/json"); String nodeId = "afef8c4e-2022-49dd-8427-9321d4f84491";// write the json object for all the comments}}
I want create custom webscript to list down the comments of the folder.
Can anyone help me please.
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2013 06:34 AM
By comment you mean description of the node?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2013 10:47 AM
The comments user posts on folder-detail page,
http://localhost:8080/share/page/folder-details?nodeRef=workspace://SpacesStore/910d38f8-a897-491f-a...
http://localhost:8080/share/page/folder-details?nodeRef=workspace://SpacesStore/910d38f8-a897-491f-a...

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2013 02:34 AM
Got The way to lsit the comments posted on folder / node.
Node stores comments as following way,
The node will have child node discussion, discussion will have child node topic and the topic will have all the comments as its child nodes.
<java>
/* List all the child of the node, as all the comments are stored in node -> discussion -> topic -> comments(list) */
List<ChildAssociationRef> childList = serviceRegistry
.getNodeService().getChildAssocs(node);
for (ChildAssociationRef s : childList) {
if (ForumModel.ASSOC_DISCUSSION.equals(s.getTypeQName())) {
List<ChildAssociationRef> topicList = serviceRegistry
.getNodeService().getChildAssocs(s.getChildRef());
for (ChildAssociationRef topic : topicList) {
if (ForumModel.TYPE_TOPIC.equals(serviceRegistry
.getNodeService().getType(topic.getChildRef()))) {
/* list of all the comments node */
List<ChildAssociationRef> postList = serviceRegistry
.getNodeService().getChildAssocs(
topic.getChildRef());
/* read the last comment posted on the node */
String latestCommentHtml = serviceRegistry
.getContentService()
.getReader(
postList.get(postList.size() - 1)
.getChildRef(),
ContentModel.PROP_CONTENT)
.getReader().getContentString();
latestCommentHtml= "<div class='comment-content'>"+comment+"</div>";
latestCommentHtml= HtmlUtils.htmlUnescape(comment);
return latestCommentHtml;
}
}
}
}
</java>
There is also a javascript data webscript to list down all the comments of the node.
http://localhost:8080/share/page/components/node/workspace/SpacesStore/910d38f8-a897-491f-aa2d-1d48d...
Node stores comments as following way,
The node will have child node discussion, discussion will have child node topic and the topic will have all the comments as its child nodes.
<java>
/* List all the child of the node, as all the comments are stored in node -> discussion -> topic -> comments(list) */
List<ChildAssociationRef> childList = serviceRegistry
.getNodeService().getChildAssocs(node);
for (ChildAssociationRef s : childList) {
if (ForumModel.ASSOC_DISCUSSION.equals(s.getTypeQName())) {
List<ChildAssociationRef> topicList = serviceRegistry
.getNodeService().getChildAssocs(s.getChildRef());
for (ChildAssociationRef topic : topicList) {
if (ForumModel.TYPE_TOPIC.equals(serviceRegistry
.getNodeService().getType(topic.getChildRef()))) {
/* list of all the comments node */
List<ChildAssociationRef> postList = serviceRegistry
.getNodeService().getChildAssocs(
topic.getChildRef());
/* read the last comment posted on the node */
String latestCommentHtml = serviceRegistry
.getContentService()
.getReader(
postList.get(postList.size() - 1)
.getChildRef(),
ContentModel.PROP_CONTENT)
.getReader().getContentString();
latestCommentHtml= "<div class='comment-content'>"+comment+"</div>";
latestCommentHtml= HtmlUtils.htmlUnescape(comment);
return latestCommentHtml;
}
}
}
}
</java>
There is also a javascript data webscript to list down all the comments of the node.
http://localhost:8080/share/page/components/node/workspace/SpacesStore/910d38f8-a897-491f-aa2d-1d48d...
