use of fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method deleteDiscussion.
@DELETE
@Path("/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteDiscussion(@PathParam("GROUPID") Long groupId, @PathParam("DISCUSSIONID") Long discussionId) {
ForumAreaGroup group = forumController.findForumAreaGroup(groupId);
if (group == null) {
return Response.status(Status.NOT_FOUND).entity("Group not found").build();
}
ForumArea forumArea = forumController.getForumArea(discussionId);
if (forumArea == null) {
return Response.status(Status.NOT_FOUND).entity("Discussion not found").build();
}
List<ForumThread> threads = forumController.listForumThreads(forumArea, 0, Integer.MAX_VALUE, true);
for (ForumThread thread : threads) {
List<ForumThreadReply> replies = forumController.listForumThreadReplies(thread, 0, Integer.MAX_VALUE, true);
for (ForumThreadReply reply : replies) {
forumController.deleteReply(reply);
}
forumController.deleteThread(thread);
}
forumController.deleteArea(forumArea);
return Response.noContent().build();
}
Aggregations