Search in sources :

Example 6 with CommunicatorUserLabel

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();
    }
}
Also used : CommunicatorUserLabel(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 7 with CommunicatorUserLabel

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();
    }
}
Also used : CommunicatorUserLabel(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 8 with CommunicatorUserLabel

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();
    }
}
Also used : CommunicatorMessageIdLabel(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageIdLabel) CommunicatorMessageId(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId) CommunicatorMessage(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage) CommunicatorUserLabel(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 9 with CommunicatorUserLabel

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();
}
Also used : CommunicatorUserLabel(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) UserGroupUserEntity(fi.otavanopisto.muikku.model.users.UserGroupUserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Aggregations

CommunicatorUserLabel (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorUserLabel)9 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)7 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)7 Path (javax.ws.rs.Path)7 GET (javax.ws.rs.GET)3 DELETE (javax.ws.rs.DELETE)2 UserGroupUserEntity (fi.otavanopisto.muikku.model.users.UserGroupUserEntity)1 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 CommunicatorMessage (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage)1 CommunicatorMessageId (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)1 CommunicatorMessageIdLabel (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageIdLabel)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1