Search in sources :

Example 26 with RESTPermit

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

the class CommunicatorTrashRESTService method markTrashAsRead.

@POST
@Path("/trash/{COMMUNICATORMESSAGEID}/markasread")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response markTrashAsRead(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) {
    UserEntity user = sessionController.getLoggedUserEntity();
    CommunicatorMessageId messageId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
    List<CommunicatorMessageRecipient> list = communicatorController.listCommunicatorMessageRecipientsByUserAndMessage(user, messageId, true);
    for (CommunicatorMessageRecipient r : list) {
        communicatorController.updateRead(r, true);
    }
    return Response.noContent().build();
}
Also used : CommunicatorMessageRecipient(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient) CommunicatorMessageId(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Example 27 with RESTPermit

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

the class CommunicatorTrashRESTService method deleteReceivedMessages.

@PUT
@Path("/trash/{COMMUNICATORMESSAGEID}/restore")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response deleteReceivedMessages(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) throws AuthorizationException {
    UserEntity user = sessionController.getLoggedUserEntity();
    CommunicatorMessageId messageId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
    communicatorController.unTrashAllThreadMessages(user, messageId);
    return Response.noContent().build();
}
Also used : CommunicatorMessageId(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) PUT(javax.ws.rs.PUT)

Example 28 with RESTPermit

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

the class CommunicatorTrashRESTService method deleteTrashMessages.

@DELETE
@Path("/trash/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response deleteTrashMessages(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) throws AuthorizationException {
    UserEntity user = sessionController.getLoggedUserEntity();
    CommunicatorMessageId threadId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
    communicatorController.archiveTrashedMessages(user, threadId);
    return Response.noContent().build();
}
Also used : CommunicatorMessageId(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 29 with RESTPermit

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

the class CommunicatorTrashRESTService method markTrashAsUnRead.

@POST
@Path("/trash/{COMMUNICATORMESSAGEID}/markasunread")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response markTrashAsUnRead(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId, @QueryParam("messageIds") List<Long> messageIds) {
    UserEntity user = sessionController.getLoggedUserEntity();
    CommunicatorMessageId messageId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
    List<CommunicatorMessageRecipient> list = communicatorController.listCommunicatorMessageRecipientsByUserAndMessage(user, messageId, false);
    for (CommunicatorMessageRecipient r : list) {
        if ((messageIds != null) && (r.getCommunicatorMessage() != null)) {
            if (!messageIds.isEmpty() && !messageIds.contains(r.getCommunicatorMessage().getId()))
                continue;
        }
        communicatorController.updateRead(r, false);
    }
    return Response.noContent().build();
}
Also used : CommunicatorMessageRecipient(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient) CommunicatorMessageId(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Example 30 with RESTPermit

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

the class CommunicatorRESTService method deleteUserMessageSignature.

@DELETE
@Path("/signatures/{SIGNATUREID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response deleteUserMessageSignature(@PathParam("SIGNATUREID") Long signatureId) throws AuthorizationException {
    CommunicatorMessageSignature messageSignature = communicatorController.getMessageSignature(signatureId);
    if (!sessionController.hasPermission(CommunicatorPermissionCollection.COMMUNICATOR_MANAGE_SETTINGS, messageSignature)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    communicatorController.deleteMessageSignature(messageSignature);
    return Response.noContent().build();
}
Also used : CommunicatorMessageSignature(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

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