Search in sources :

Example 31 with ForumThread

use of fi.otavanopisto.muikku.plugins.forum.model.ForumThread 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)

Example 32 with ForumThread

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

the class ForumAcceptanceTestsRESTService method deleteForumThread.

@DELETE
@Path("/areas/{AREAID}/threads/{THREADID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteForumThread(@PathParam("AREAID") Long forumAreaId, @PathParam("THREADID") Long forumThreadId) {
    ForumThread forumThread = forumController.getForumThread(forumThreadId);
    if (forumThread == null) {
        return Response.status(Status.NOT_FOUND).entity("ForumThread not found").build();
    }
    forumController.deleteThread(forumThread);
    return Response.noContent().build();
}
Also used : ForumThread(fi.otavanopisto.muikku.plugins.forum.model.ForumThread) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Aggregations

ForumThread (fi.otavanopisto.muikku.plugins.forum.model.ForumThread)32 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)24 Path (javax.ws.rs.Path)24 ForumArea (fi.otavanopisto.muikku.plugins.forum.model.ForumArea)22 WorkspaceForumArea (fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea)15 EnvironmentForumArea (fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea)14 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)12 ForumThreadReply (fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply)11 GET (javax.ws.rs.GET)10 ArrayList (java.util.ArrayList)6 DELETE (javax.ws.rs.DELETE)6 EntityManager (javax.persistence.EntityManager)5 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)5 ForumAreaGroup (fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup)4 POST (javax.ws.rs.POST)4 PUT (javax.ws.rs.PUT)4 Document (org.jsoup.nodes.Document)2