mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9153 Start on unit tests for the new Discussions Service
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29715 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
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<TopicInfo> listTopics(String siteShortName,
|
||||
PagingRequest paging) {
|
||||
NodeRef container = getSiteWikiContainer(siteShortName, false);
|
||||
if(container == null)
|
||||
{
|
||||
// No topics
|
||||
return new EmptyPagingResults<TopicInfo>();
|
||||
}
|
||||
|
||||
// We can now fetch by parent nodeRef
|
||||
return listTopics(container, paging);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PagingResults<TopicInfo> listTopics(NodeRef nodeRef,
|
||||
PagingRequest paging) {
|
||||
// TODO
|
||||
return new EmptyPagingResults<TopicInfo>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PagingResults<PostInfo> listPosts(TopicInfo topic, PagingRequest paging)
|
||||
{
|
||||
// TODO
|
||||
return new EmptyPagingResults<PostInfo>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PagingResults<PostInfo> listPostReplies(PostInfo primaryPost,
|
||||
|
Reference in New Issue
Block a user