use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel in project muikku by otavanopisto.
the class CommunicatorLabelRESTService method deleteUserLabel.
@DELETE
@Path("/userLabels/{USERLABELID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response deleteUserLabel(@PathParam("USERLABELID") Long userLabelId) throws AuthorizationException {
UserEntity userEntity = sessionController.getLoggedUserEntity();
CommunicatorUserLabel userLabel = communicatorController.findUserLabelById(userLabelId);
if ((userLabel != null) && canAccessLabel(userEntity, userLabel)) {
communicatorController.delete(userLabel);
return Response.noContent().build();
} else {
return Response.status(Status.NOT_FOUND).build();
}
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel in project muikku by otavanopisto.
the class CommunicatorLabelRESTService method getUserLabel.
@GET
@Path("/userLabels/{USERLABELID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response getUserLabel(@PathParam("USERLABELID") Long userLabelId) throws AuthorizationException {
UserEntity userEntity = sessionController.getLoggedUserEntity();
CommunicatorUserLabel userLabel = communicatorController.findUserLabelById(userLabelId);
if ((userLabel != null) && canAccessLabel(userEntity, userLabel)) {
return Response.ok(restModels.restUserLabel(userLabel)).build();
} else {
return Response.status(Status.NOT_FOUND).build();
}
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel in project muikku by otavanopisto.
the class CommunicatorLabelRESTService method listUserUnreadCommunicatorMessagesByMessageId.
@GET
@Path("/userLabels/{USERLABELID}/messages/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserUnreadCommunicatorMessagesByMessageId(@PathParam("USERLABELID") Long userLabelId, @PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) {
UserEntity userEntity = sessionController.getLoggedUserEntity();
CommunicatorUserLabel userLabel = communicatorController.findUserLabelById(userLabelId);
if ((userLabel != null) && canAccessLabel(userEntity, userLabel)) {
CommunicatorMessageId threadId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
List<CommunicatorMessage> receivedItems = communicatorController.listMessagesByMessageId(userEntity, threadId, false);
List<CommunicatorMessageIdLabel> labels = communicatorController.listMessageIdLabelsByUserEntity(userEntity, threadId);
List<CommunicatorMessageIdLabelRESTModel> restLabels = restModels.restLabel(labels);
CommunicatorMessageId olderThread = communicatorController.findOlderThreadId(userEntity, threadId, CommunicatorFolderType.LABEL, userLabel);
CommunicatorMessageId newerThread = communicatorController.findNewerThreadId(userEntity, threadId, CommunicatorFolderType.LABEL, userLabel);
return Response.ok(restModels.restThreadViewModel(receivedItems, olderThread, newerThread, restLabels)).build();
} else {
return Response.status(Status.NOT_FOUND).build();
}
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method deleteCommunicatorUserLabels.
@DELETE
@Path("/communicator/labels/user/{ID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteCommunicatorUserLabels(@PathParam("ID") Long userId) {
UserEntity userEntity = userEntityController.findUserEntityById(userId);
List<CommunicatorUserLabel> userLabels = communicatorController.listUserLabelsByUserEntity(userEntity);
for (CommunicatorUserLabel communicatorUserLabel : userLabels) {
communicatorController.delete(communicatorUserLabel);
}
return Response.noContent().build();
}
Aggregations