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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations