Search in sources :

Example 11 with RESTPermit

use of fi.otavanopisto.security.rest.RESTPermit in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method publishWorkspace.

@GET
@Path("/workspaces/{WORKSPACEENTITYID}/publish")
@RESTPermit(handling = Handling.UNSECURED)
public Response publishWorkspace(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId) {
    WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity == null) {
        return Response.status(404).entity("Not found").build();
    }
    workspaceEntityController.updatePublished(workspaceEntity, true);
    return Response.noContent().build();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 12 with RESTPermit

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

Example 13 with RESTPermit

use of fi.otavanopisto.security.rest.RESTPermit in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method deleteFlagShares.

@DELETE
@Path("/flags/share/{FLAGID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteFlagShares(@PathParam("FLAGID") Long flagId) {
    Flag flag = flagController.findFlagById(flagId);
    List<FlagShare> listShares = flagController.listShares(flag);
    for (FlagShare flagShare : listShares) {
        flagController.deleteFlagShare(flagShare);
    }
    return Response.noContent().build();
}
Also used : FlagShare(fi.otavanopisto.muikku.model.users.FlagShare) Flag(fi.otavanopisto.muikku.model.users.Flag) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 14 with RESTPermit

use of fi.otavanopisto.security.rest.RESTPermit in project muikku by otavanopisto.

the class ForumAcceptanceTestsRESTService method deleteForumThreadReply.

@DELETE
@Path("/areas/{AREAID}/threads/{THREADID}/replies/{REPLYID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteForumThreadReply(@PathParam("AREAID") Long forumAreaId, @PathParam("THREADID") Long forumThreadId, @PathParam("REPLYID") Long forumThreadReplyId) {
    ForumThreadReply forumThreadReply = forumController.getForumThreadReply(forumThreadReplyId);
    if (forumThreadReply == null) {
        return Response.status(Status.NOT_FOUND).entity("ForumThreadReply not found").build();
    }
    forumController.deleteReply(forumThreadReply);
    return Response.noContent().build();
}
Also used : 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 15 with RESTPermit

use of fi.otavanopisto.security.rest.RESTPermit in project muikku by otavanopisto.

the class AnnouncerRESTService method listAnnouncements.

@GET
@Path("/announcements")
@RESTPermit(handling = Handling.INLINE)
public Response listAnnouncements(@QueryParam("hideEnvironmentAnnouncements") @DefaultValue("false") boolean hideEnvironmentAnnouncements, @QueryParam("hideWorkspaceAnnouncements") @DefaultValue("false") boolean hideWorkspaceAnnouncements, @QueryParam("hideGroupAnnouncements") @DefaultValue("false") boolean hideGroupAnnouncements, @QueryParam("workspaceEntityId") Long workspaceEntityId, @QueryParam("onlyMine") @DefaultValue("false") boolean onlyMine, @QueryParam("onlyEditable") @DefaultValue("false") boolean onlyEditable, @QueryParam("onlyArchived") @DefaultValue("false") boolean onlyArchived, @QueryParam("timeFrame") @DefaultValue("CURRENT") AnnouncementTimeFrame timeFrame) {
    UserEntity currentUserEntity = sessionController.getLoggedUserEntity();
    if (currentUserEntity == null) {
        return Response.noContent().build();
    }
    List<Announcement> announcements = null;
    AnnouncementEnvironmentRestriction environment = hideEnvironmentAnnouncements ? AnnouncementEnvironmentRestriction.NONE : sessionController.hasEnvironmentPermission(AnnouncerPermissions.LIST_ENVIRONMENT_GROUP_ANNOUNCEMENTS) ? AnnouncementEnvironmentRestriction.PUBLICANDGROUP : AnnouncementEnvironmentRestriction.PUBLIC;
    if (workspaceEntityId == null) {
        boolean includeGroups = !hideGroupAnnouncements;
        boolean includeWorkspaces = !hideWorkspaceAnnouncements;
        announcements = announcementController.listAnnouncements(includeGroups, includeWorkspaces, environment, timeFrame, currentUserEntity, onlyMine, onlyArchived);
    } else {
        WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
        if (workspaceEntity == null) {
            return Response.status(Status.BAD_REQUEST).entity("Workspace entity with given ID not found").build();
        }
        if (!sessionController.hasWorkspacePermission(AnnouncerPermissions.LIST_WORKSPACE_ANNOUNCEMENTS, workspaceEntity)) {
            return Response.status(Status.FORBIDDEN).entity("You don't have the permission to list workspace announcements").build();
        }
        announcements = announcementController.listWorkspaceAnnouncements(Arrays.asList(workspaceEntity), environment, timeFrame, currentUserEntity, onlyMine, onlyArchived);
    }
    List<AnnouncementRESTModel> restModels = new ArrayList<>();
    for (Announcement announcement : announcements) {
        if (onlyEditable && !canEdit(announcement, currentUserEntity)) {
            continue;
        }
        List<AnnouncementUserGroup> announcementUserGroups = announcementController.listAnnouncementUserGroups(announcement);
        List<AnnouncementWorkspace> announcementWorkspaces = announcementController.listAnnouncementWorkspacesSortByUserFirst(announcement, currentUserEntity);
        AnnouncementRESTModel restModel = createRESTModel(announcement, announcementUserGroups, announcementWorkspaces);
        restModels.add(restModel);
    }
    return Response.ok(restModels).build();
}
Also used : Announcement(fi.otavanopisto.muikku.plugins.announcer.model.Announcement) AnnouncementUserGroup(fi.otavanopisto.muikku.plugins.announcer.model.AnnouncementUserGroup) ArrayList(java.util.ArrayList) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) AnnouncementWorkspace(fi.otavanopisto.muikku.plugins.announcer.workspace.model.AnnouncementWorkspace) AnnouncementEnvironmentRestriction(fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementEnvironmentRestriction) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

RESTPermit (fi.otavanopisto.security.rest.RESTPermit)215 Path (javax.ws.rs.Path)214 GET (javax.ws.rs.GET)99 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)90 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)83 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)61 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)57 POST (javax.ws.rs.POST)51 DELETE (javax.ws.rs.DELETE)45 ArrayList (java.util.ArrayList)36 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)30 ForumArea (fi.otavanopisto.muikku.plugins.forum.model.ForumArea)30 PUT (javax.ws.rs.PUT)26 ForumThread (fi.otavanopisto.muikku.plugins.forum.model.ForumThread)24 WorkspaceForumArea (fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea)21 CommunicatorMessageId (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)20 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)20 User (fi.otavanopisto.muikku.schooldata.entity.User)19 EnvironmentForumArea (fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea)18 Date (java.util.Date)16