Search in sources :

Example 31 with ForumArea

use of fi.otavanopisto.muikku.plugins.forum.model.ForumArea 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 32 with ForumArea

use of fi.otavanopisto.muikku.plugins.forum.model.ForumArea 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 33 with ForumArea

use of fi.otavanopisto.muikku.plugins.forum.model.ForumArea 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 34 with ForumArea

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

the class ForumAcceptanceTestsRESTService method deleteForumArea.

@DELETE
@Path("/areas/{AREAID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteForumArea(@PathParam("AREAID") Long forumAreaId) {
    ForumArea forumArea = forumController.findForumAreaById(forumAreaId);
    if (forumArea == null) {
        return Response.status(Status.NOT_FOUND).entity("ForumArea not found").build();
    }
    forumController.deleteArea(forumArea);
    return Response.noContent().build();
}
Also used : ForumArea(fi.otavanopisto.muikku.plugins.forum.model.ForumArea) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Aggregations

ForumArea (fi.otavanopisto.muikku.plugins.forum.model.ForumArea)34 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)30 Path (javax.ws.rs.Path)30 WorkspaceForumArea (fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea)23 ForumThread (fi.otavanopisto.muikku.plugins.forum.model.ForumThread)22 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)17 EnvironmentForumArea (fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea)17 ForumThreadReply (fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply)11 GET (javax.ws.rs.GET)10 DELETE (javax.ws.rs.DELETE)8 ForumAreaGroup (fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup)6 POST (javax.ws.rs.POST)6 PUT (javax.ws.rs.PUT)6 ArrayList (java.util.ArrayList)4 Permission (fi.otavanopisto.muikku.model.security.Permission)2 RoleEntity (fi.otavanopisto.muikku.model.users.RoleEntity)2 CacheControl (javax.ws.rs.core.CacheControl)2 EntityTag (javax.ws.rs.core.EntityTag)2 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)2 Document (org.jsoup.nodes.Document)2