Search in sources :

Example 11 with ForumAreaGroup

use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup 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();
}
Also used : ForumAreaGroup(fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup) ForumThread(fi.otavanopisto.muikku.plugins.forum.model.ForumThread) ForumArea(fi.otavanopisto.muikku.plugins.forum.model.ForumArea) EnvironmentForumArea(fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea) WorkspaceForumArea(fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea) ForumThreadReply(fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 12 with ForumAreaGroup

use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method createWorkspaceDiscussionThread.

@POST
@Path("/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}/threads")
@RESTPermit(handling = Handling.UNSECURED)
public Response createWorkspaceDiscussionThread(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("GROUPID") Long groupId, @PathParam("DISCUSSIONID") Long discussionId, fi.otavanopisto.muikku.atests.DiscussionThread 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();
    }
    ForumArea discussion = forumController.getForumArea(discussionId);
    if (discussion == null) {
        return Response.status(Status.NOT_FOUND).entity("Discussion not found").build();
    }
    return Response.ok(createRestEntity(forumController.createForumThread(discussion, payload.getTitle(), payload.getMessage(), payload.getSticky(), payload.getLocked()))).build();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) ForumAreaGroup(fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup) ForumArea(fi.otavanopisto.muikku.plugins.forum.model.ForumArea) EnvironmentForumArea(fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea) WorkspaceForumArea(fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Example 13 with ForumAreaGroup

use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method deleteDiscussionThread.

@DELETE
@Path("/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}/threads/{ID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteDiscussionThread(@PathParam("GROUPID") Long groupId, @PathParam("DISCUSSIONID") Long discussionId, @PathParam("ID") Long id) {
    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();
    }
    ForumThread thread = forumController.getForumThread(id);
    if (thread == null) {
        return Response.status(Status.NOT_FOUND).entity("Thread not found").build();
    }
    forumController.deleteThread(thread);
    return Response.noContent().build();
}
Also used : ForumAreaGroup(fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup) ForumThread(fi.otavanopisto.muikku.plugins.forum.model.ForumThread) ForumArea(fi.otavanopisto.muikku.plugins.forum.model.ForumArea) EnvironmentForumArea(fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea) WorkspaceForumArea(fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 14 with ForumAreaGroup

use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method createDiscussionThread.

@POST
@Path("/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}/threads")
@RESTPermit(handling = Handling.UNSECURED)
public Response createDiscussionThread(@PathParam("GROUPID") Long groupId, @PathParam("DISCUSSIONID") Long discussionId, fi.otavanopisto.muikku.atests.DiscussionThread payload) {
    ForumAreaGroup group = forumController.findForumAreaGroup(groupId);
    if (group == null) {
        return Response.status(Status.NOT_FOUND).entity("Group not found").build();
    }
    ForumArea discussion = forumController.getForumArea(discussionId);
    if (discussion == null) {
        return Response.status(Status.NOT_FOUND).entity("Discussion not found").build();
    }
    return Response.ok(createRestEntity(forumController.createForumThread(discussion, payload.getTitle(), payload.getMessage(), payload.getSticky(), payload.getLocked()))).build();
}
Also used : ForumAreaGroup(fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup) ForumArea(fi.otavanopisto.muikku.plugins.forum.model.ForumArea) EnvironmentForumArea(fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea) WorkspaceForumArea(fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Example 15 with ForumAreaGroup

use of fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method deleteWorkspaceDiscussionThread.

@DELETE
@Path("/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}/threads/{ID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteWorkspaceDiscussionThread(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("GROUPID") Long groupId, @PathParam("DISCUSSIONID") Long discussionId, @PathParam("ID") Long id) {
    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();
    }
    ForumThread thread = forumController.getForumThread(id);
    if (thread == null) {
        return Response.status(Status.NOT_FOUND).entity("Thread not found").build();
    }
    forumController.deleteThread(thread);
    return Response.noContent().build();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) ForumAreaGroup(fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup) ForumThread(fi.otavanopisto.muikku.plugins.forum.model.ForumThread) ForumArea(fi.otavanopisto.muikku.plugins.forum.model.ForumArea) EnvironmentForumArea(fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea) WorkspaceForumArea(fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Aggregations

ForumAreaGroup (fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup)16 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)12 Path (javax.ws.rs.Path)12 EnvironmentForumArea (fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea)7 WorkspaceForumArea (fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea)7 DELETE (javax.ws.rs.DELETE)7 ForumArea (fi.otavanopisto.muikku.plugins.forum.model.ForumArea)6 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)5 ForumThread (fi.otavanopisto.muikku.plugins.forum.model.ForumThread)4 POST (javax.ws.rs.POST)4 ResourceRights (fi.otavanopisto.muikku.model.security.ResourceRights)2 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 ForumThreadReply (fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply)2 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 GET (javax.ws.rs.GET)1