this.forumQueryService()
.forumIdOfExclusiveOwner(
aTenantId,
anExclusiveOwner);
Forum forum = null;
if (forumId != null) {
forum = this.forumRepository()
.forumOfId(
tenant,
new ForumId(forumId));
}
if (forum == null) {
forum = this.startNewForum(
tenant,
aCreatorId,
aModeratorId,
aForumSubject,
aForumDescription,
anExclusiveOwner);
}
String discussionId =
this.discussionQueryService()
.discussionIdOfExclusiveOwner(
aTenantId,
anExclusiveOwner);
Discussion discussion = null;
if (discussionId != null) {
discussion = this.discussionRepository()
.discussionOfId(
tenant,
new DiscussionId(discussionId));
}
if (discussion == null) {
Author author =
this.collaboratorService().authorFrom(tenant, anAuthorId);
discussion =
forum.startDiscussionFor(
this.forumIdentityService(),
author,
aDiscussionSubject,
anExclusiveOwner);
this.discussionRepository().save(discussion);
}
if (aResult != null) {
aResult.resultingForumId(forum.forumId().id());
aResult.resultingDiscussionId(discussion.discussionId().id());
}
}