Search in sources :

Example 6 with CommunicatorMessageId

use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId 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();
}
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 7 with CommunicatorMessageId

use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId 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();
}
Also used : 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) PUT(javax.ws.rs.PUT)

Example 8 with CommunicatorMessageId

use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId 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();
}
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)

Example 9 with CommunicatorMessageId

use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId 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();
}
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 10 with CommunicatorMessageId

use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId in project muikku by otavanopisto.

the class CommunicatorController method postMessage.

public CommunicatorMessage postMessage(UserEntity sender, String category, String subject, String content, List<UserEntity> recipients) {
    CommunicatorMessageId communicatorMessageId = createMessageId();
    // TODO Category not existing at this point would technically indicate an invalid state
    CommunicatorMessageCategory categoryEntity = persistCategory(category);
    return createMessage(communicatorMessageId, sender, recipients, null, null, null, categoryEntity, subject, content, null);
}
Also used : CommunicatorMessageCategory(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory) CommunicatorMessageId(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)

Aggregations

CommunicatorMessageId (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)26 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)22 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)20 Path (javax.ws.rs.Path)20 CommunicatorMessage (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage)10 CommunicatorMessageIdLabel (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageIdLabel)8 GET (javax.ws.rs.GET)8 POST (javax.ws.rs.POST)8 CommunicatorMessageRecipient (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient)6 ArrayList (java.util.ArrayList)6 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)5 CommunicatorMessageCategory (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory)4 Tag (fi.otavanopisto.muikku.model.base.Tag)3 UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)3 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)3 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)3 DELETE (javax.ws.rs.DELETE)3 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)2 User (fi.otavanopisto.muikku.schooldata.entity.User)2 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)2