diff --git a/config/alfresco/application-context-highlevel.xml b/config/alfresco/application-context-highlevel.xml
index b2df6758e0..d684be07dd 100644
--- a/config/alfresco/application-context-highlevel.xml
+++ b/config/alfresco/application-context-highlevel.xml
@@ -10,8 +10,9 @@
-
+
+
diff --git a/config/alfresco/discussions-services-context.xml b/config/alfresco/discussions-services-context.xml
new file mode 100644
index 0000000000..c28a8c6b85
--- /dev/null
+++ b/config/alfresco/discussions-services-context.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+ org.alfresco.service.cmr.discussion.DiscussionService
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${server.transaction.mode.default}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/alfresco/public-services-security-context.xml b/config/alfresco/public-services-security-context.xml
index 74d1fa2bf6..28f3553a6f 100644
--- a/config/alfresco/public-services-security-context.xml
+++ b/config/alfresco/public-services-security-context.xml
@@ -1057,6 +1057,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.alfresco.service.cmr.discussion.DiscussionService.listPosts=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/java/org/alfresco/repo/discussion/DiscussionServiceImpl.java b/source/java/org/alfresco/repo/discussion/DiscussionServiceImpl.java
index fa1d4e704e..cbfc6626f8 100644
--- a/source/java/org/alfresco/repo/discussion/DiscussionServiceImpl.java
+++ b/source/java/org/alfresco/repo/discussion/DiscussionServiceImpl.java
@@ -298,18 +298,31 @@ public class DiscussionServiceImpl implements DiscussionService
throw new IllegalArgumentException("Can't create posts for a topic that was never persisted!");
}
+ // Are we going to be the primary post?
+ boolean isPrimary = false;
+ if(getPrimaryPost(topic) == null)
+ {
+ isPrimary = true;
+ }
+
// Decide on the name. If this is the first post in a topic,
// it should share the topic's name, otherwise needs a new one
String name = generateName();
- if(getPrimaryPost(topic) == null)
+ if(isPrimary)
{
name = topic.getSystemName();
}
- // Get the properties for the node
+ // Create the properties for the node
Map props = new HashMap();
props.put(ContentModel.PROP_NAME, name);
- props.put(ContentModel.PROP_TITLE, topic.getTitle());
+
+ // Do we want a title? By default, primary posts share a title
+ // with the topic, but replies are title-free
+ if(isPrimary)
+ {
+ props.put(ContentModel.PROP_TITLE, topic.getTitle());
+ }
// Build the node
NodeRef nodeRef = nodeService.createNode(
@@ -329,6 +342,31 @@ public class DiscussionServiceImpl implements DiscussionService
// Build it that way, so creator and created date come through
return buildPost(nodeRef, topic, name, contents);
}
+
+ @Override
+ public PostInfo createReply(PostInfo parentPost, String contents)
+ {
+ // Sanity check what we were given
+ if(parentPost.getNodeRef() == null)
+ {
+ throw new IllegalArgumentException("Can't reply to a post that was never persisted");
+ }
+ if(parentPost.getTopic() == null)
+ {
+ throw new IllegalArgumentException("Can't reply to a post with no attached topic");
+ }
+
+ // Have the post created
+ PostInfo reply = createPost(parentPost.getTopic(), contents);
+
+ // Now make it a reply
+ nodeService.createAssociation(
+ reply.getNodeRef(), parentPost.getNodeRef(), ContentModel.ASSOC_REFERENCES
+ );
+
+ // All done
+ return reply;
+ }
@Override
@@ -467,7 +505,7 @@ public class DiscussionServiceImpl implements DiscussionService
PostInfo post = getPost(topic, topic.getSystemName());
if(post != null)
{
- return null;
+ return post;
}
// Cater for the explorer case, we want the first child
@@ -484,6 +522,35 @@ public class DiscussionServiceImpl implements DiscussionService
return buildPost(postNodeRef, topic, postName, null);
}
+
+ @Override
+ public PagingResults listTopics(String siteShortName,
+ PagingRequest paging) {
+ NodeRef container = getSiteWikiContainer(siteShortName, false);
+ if(container == null)
+ {
+ // No topics
+ return new EmptyPagingResults();
+ }
+
+ // We can now fetch by parent nodeRef
+ return listTopics(container, paging);
+ }
+
+ @Override
+ public PagingResults listTopics(NodeRef nodeRef,
+ PagingRequest paging) {
+ // TODO
+ return new EmptyPagingResults();
+ }
+
+ @Override
+ public PagingResults listPosts(TopicInfo topic, PagingRequest paging)
+ {
+ // TODO
+ return new EmptyPagingResults();
+ }
+
@Override
public PagingResults listPostReplies(PostInfo primaryPost,
diff --git a/source/java/org/alfresco/service/cmr/discussion/DiscussionService.java b/source/java/org/alfresco/service/cmr/discussion/DiscussionService.java
index 80235dc9a2..961cbc3b8e 100644
--- a/source/java/org/alfresco/service/cmr/discussion/DiscussionService.java
+++ b/source/java/org/alfresco/service/cmr/discussion/DiscussionService.java
@@ -33,13 +33,28 @@ import org.alfresco.service.cmr.repository.NodeRef;
public interface DiscussionService {
/**
* Creates a new {@link PostInfo} in the given topic,
- * specified contents
+ * with the specified contents.
+ * Normally only one post is created this way on a topic,
+ * and the remainder of the posts are created as
+ * replies to the {@link #getPrimaryPost(TopicInfo)}
+ * primary post.
*
* @return The newly created {@link PostInfo}
*/
@NotAuditable
PostInfo createPost(TopicInfo topic, String contents);
+ /**
+ * Creates a new {@link PostInfo} which is a reply to
+ * the specified other post, with the given contents.
+ * The link between the parent post and the reply is
+ * created as part of this.
+ *
+ * @return The newly created {@link PostInfo}
+ */
+ @NotAuditable
+ PostInfo createReply(PostInfo parentPost, String contents);
+
/**
* Creates a new {@link TopicInfo} in the given site
*/
@@ -113,6 +128,24 @@ public interface DiscussionService {
TopicInfo getTopic(NodeRef parentNodeRef, String topicName);
+ /**
+ * Retrieves all topics in a site
+ */
+ @NotAuditable
+ PagingResults listTopics(String siteShortName, PagingRequest paging);
+
+ /**
+ * Retrieves all topics attached to the specified Node
+ */
+ @NotAuditable
+ PagingResults listTopics(NodeRef nodeRef, PagingRequest paging);
+
+ /**
+ * Retrieves all posts in a topic, ordered by creation date
+ */
+ @NotAuditable
+ PagingResults listPosts(TopicInfo topic, PagingRequest paging);
+
/**
* Retrieves all replies on a Topic
*/
@@ -126,13 +159,13 @@ public interface DiscussionService {
PagingResults listPostReplies(PostInfo primaryPost, int levels, PagingRequest paging);
/**
- * Retrieves all posts in a site
+ * Retrieves all posts in a site, across all topics
*/
@NotAuditable
PagingResults listPosts(String siteShortName, PagingRequest paging);
/**
- * Retrieves all posts attached to the specified Node
+ * Retrieves all posts attached to the specified Node, across all topics
*/
@NotAuditable
PagingResults listPosts(NodeRef nodeRef, PagingRequest paging);