Search in sources :

Example 31 with RESTPermit

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

the class CommunicatorRESTService method markInboxAsUnRead.

@POST
@Path("/items/{COMMUNICATORMESSAGEID}/markasunread")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response markInboxAsUnRead(@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 32 with RESTPermit

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

the class CommunicatorRESTService method listUserUnreadCommunicatorMessagesByMessageId.

@GET
@Path("/unread/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserUnreadCommunicatorMessagesByMessageId(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) {
    UserEntity user = sessionController.getLoggedUserEntity();
    CommunicatorMessageId threadId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
    List<CommunicatorMessage> receivedItems = communicatorController.listMessagesByMessageId(user, threadId, false);
    List<CommunicatorMessageIdLabel> labels = communicatorController.listMessageIdLabelsByUserEntity(user, threadId);
    List<CommunicatorMessageIdLabelRESTModel> restLabels = restModels.restLabel(labels);
    CommunicatorMessageId olderThread = communicatorController.findOlderThreadId(user, threadId, CommunicatorFolderType.UNREAD, null);
    CommunicatorMessageId newerThread = communicatorController.findNewerThreadId(user, threadId, CommunicatorFolderType.UNREAD, null);
    return Response.ok(restModels.restThreadViewModel(receivedItems, olderThread, newerThread, restLabels)).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) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 33 with RESTPermit

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

the class CommunicatorRESTService method listCommunicatorMessageRecipients.

@GET
@Path("/communicatormessages/{COMMUNICATORMESSAGEID}/recipients/{RECIPIENTID}/info")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listCommunicatorMessageRecipients(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId, @PathParam("RECIPIENTID") Long recipientId) throws AuthorizationException {
    CommunicatorMessageRecipient recipient = communicatorController.findCommunicatorMessageRecipient(recipientId);
    CommunicatorMessage communicatorMessage = communicatorController.findCommunicatorMessageById(communicatorMessageId);
    if (!hasCommunicatorMessageAccess(communicatorMessage)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    schoolDataBridgeSessionController.startSystemSession();
    try {
        UserEntity userEntity = userEntityController.findUserEntityById(recipient.getRecipient());
        fi.otavanopisto.muikku.schooldata.entity.User user = userController.findUserByUserEntityDefaults(userEntity);
        // TODO: userController.hasPicture(userEntity);
        Boolean hasPicture = false;
        fi.otavanopisto.muikku.rest.model.UserBasicInfo result = new fi.otavanopisto.muikku.rest.model.UserBasicInfo(userEntity.getId(), user.getFirstName(), user.getLastName(), user.getNickName(), user.getStudyProgrammeName(), hasPicture, user.hasEvaluationFees(), user.getCurriculumIdentifier());
        return Response.ok(result).build();
    } finally {
        schoolDataBridgeSessionController.endSystemSession();
    }
}
Also used : CommunicatorMessage(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage) UserBasicInfo(fi.otavanopisto.muikku.rest.model.UserBasicInfo) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) CommunicatorMessageRecipient(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient) UserBasicInfo(fi.otavanopisto.muikku.rest.model.UserBasicInfo) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 34 with RESTPermit

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

the class CommunicatorRESTService method listUserSentCommunicatorMessagesByMessageId.

@GET
@Path("/sentitems/{COMMUNICATORMESSAGEID}")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserSentCommunicatorMessagesByMessageId(@PathParam("COMMUNICATORMESSAGEID") Long communicatorMessageId) {
    UserEntity user = sessionController.getLoggedUserEntity();
    CommunicatorMessageId threadId = communicatorController.findCommunicatorMessageId(communicatorMessageId);
    List<CommunicatorMessage> receivedItems = communicatorController.listMessagesByMessageId(user, threadId, false);
    CommunicatorMessageId olderThread = communicatorController.findOlderThreadId(user, threadId, CommunicatorFolderType.SENT, null);
    CommunicatorMessageId newerThread = communicatorController.findNewerThreadId(user, threadId, CommunicatorFolderType.SENT, null);
    List<CommunicatorMessageIdLabel> labels = communicatorController.listMessageIdLabelsByUserEntity(user, threadId);
    List<CommunicatorMessageIdLabelRESTModel> restLabels = restModels.restLabel(labels);
    return Response.ok(restModels.restThreadViewModel(receivedItems, olderThread, newerThread, restLabels)).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) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 35 with RESTPermit

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

the class CommunicatorRESTService method deleteReceivedMessages.

@DELETE
@Path("/items/{COMMUNICATORMESSAGEID}")
@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.trashAllThreadMessages(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) 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