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