use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method createWorkspaceDiscussion.
@POST
@Path("/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions")
@RESTPermit(handling = Handling.UNSECURED)
public Response createWorkspaceDiscussion(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("GROUPID") Long groupId, fi.otavanopisto.muikku.atests.Discussion payload) {
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
if (workspaceEntity == null) {
return Response.status(Status.NOT_FOUND).entity("WorkspaceEntity not found").build();
}
ForumAreaGroup group = forumController.findForumAreaGroup(groupId);
if (group == null) {
return Response.status(Status.NOT_FOUND).entity("Group not found").build();
}
if (StringUtils.isBlank(payload.getName())) {
return Response.status(Status.BAD_REQUEST).entity("Mandatory name is missing").build();
}
return Response.ok(createRestEntity(forumController.createWorkspaceForumArea(workspaceEntity, payload.getName(), payload.getDescription(), group.getId()))).build();
}
use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method deleteWorkspaceDiscussion.
@DELETE
@Path("/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteWorkspaceDiscussion(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("GROUPID") Long groupId, @PathParam("DISCUSSIONID") Long discussionId) {
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
if (workspaceEntity == null) {
return Response.status(Status.NOT_FOUND).entity("WorkspaceEntity not found").build();
}
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();
}
use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method deleteDiscussionGroup.
@DELETE
@Path("/discussiongroups/{GROUPID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteDiscussionGroup(@PathParam("GROUPID") Long groupId) {
ForumAreaGroup group = forumController.findForumAreaGroup(groupId);
if (group == null) {
return Response.status(Status.NOT_FOUND).entity("Group not found").build();
}
forumController.deleteAreaGroup(group);
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.
the class ForumRESTService method createForumAreaGroup.
@POST
@Path("/areagroups")
@RESTPermit(ForumResourcePermissionCollection.FORUM_CREATEFORUMAREAGROUP)
public Response createForumAreaGroup(ForumAreaGroupRESTModel newGroup) {
ForumAreaGroup forumArea = forumController.createForumAreaGroup(newGroup.getName());
ForumAreaGroupRESTModel result = new ForumAreaGroupRESTModel(forumArea.getId(), forumArea.getName());
return Response.ok(result).build();
}
use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.
the class ForumRESTService method findAreaGroup.
@GET
@Path("/areagroups/{AREAGROUPID}")
@RESTPermit(ForumResourcePermissionCollection.FORUM_FIND_FORUMAREAGROUP)
public Response findAreaGroup(@PathParam("AREAGROUPID") Long areaGroupId) {
ForumAreaGroup forumArea = forumController.findForumAreaGroup(areaGroupId);
ForumAreaGroupRESTModel result = new ForumAreaGroupRESTModel(forumArea.getId(), forumArea.getName());
return Response.ok(result).build();
}
Aggregations