use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.
the class CommunicatorLabelRESTService method listUserLabels.
@GET
@Path("/userLabels")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserLabels() throws AuthorizationException {
UserEntity userEntity = sessionController.getLoggedUserEntity();
// Lists only labels of logged user so we can consider this safe
List<CommunicatorUserLabel> userLabels = communicatorController.listUserLabelsByUserEntity(userEntity);
return Response.ok(restModels.restUserLabel(userLabels)).build();
}
use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.
the class CommunicatorLabelRESTService method editUserLabel.
@PUT
@Path("/userLabels/{USERLABELID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response editUserLabel(@PathParam("USERLABELID") Long userLabelId, CommunicatorUserLabelRESTModel updatedUserLabel) throws AuthorizationException {
if (!updatedUserLabel.getId().equals(userLabelId)) {
return Response.status(Response.Status.BAD_REQUEST).entity("Id is immutable").build();
}
UserEntity userEntity = sessionController.getLoggedUserEntity();
CommunicatorUserLabel userLabel = communicatorController.findUserLabelById(userLabelId);
if ((userLabel != null) && canAccessLabel(userEntity, userLabel)) {
CommunicatorUserLabel editedUserLabel = communicatorController.updateUserLabel(userLabel, updatedUserLabel.getName(), updatedUserLabel.getColor());
return Response.ok(restModels.restUserLabel(editedUserLabel)).build();
} else {
return Response.status(Status.NOT_FOUND).build();
}
}
use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.
the class CommunicatorLabelRESTService method listMessageIdLabels.
@GET
@Path("/messages/{COMMUNICATORMESSAGEID}/labels")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listMessageIdLabels(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) throws AuthorizationException {
CommunicatorMessageId messageId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
// Lists only labels of logged user so we can consider this safe
UserEntity userEntity = sessionController.getLoggedUserEntity();
List<CommunicatorMessageIdLabel> labels = communicatorController.listMessageIdLabelsByUserEntity(userEntity, messageId);
return Response.ok(restModels.restLabel(labels)).build();
}
use of fi.otavanopisto.muikku.model.users.UserEntity 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.muikku.model.users.UserEntity 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();
}
Aggregations