Search in sources :

Example 11 with UserEntity

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();
}
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 12 with UserEntity

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();
    }
}
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) PUT(javax.ws.rs.PUT)

Example 13 with UserEntity

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

Example 14 with UserEntity

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();
}
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 15 with UserEntity

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();
}
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)

Aggregations

UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)163 Path (javax.ws.rs.Path)101 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)88 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)65 GET (javax.ws.rs.GET)58 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)54 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)50 User (fi.otavanopisto.muikku.schooldata.entity.User)36 ArrayList (java.util.ArrayList)35 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)27 POST (javax.ws.rs.POST)26 Date (java.util.Date)24 CommunicatorMessageId (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)22 HashMap (java.util.HashMap)20 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)18 EnvironmentUser (fi.otavanopisto.muikku.model.users.EnvironmentUser)14 CommunicatorMessage (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage)14 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)13 UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)12 PUT (javax.ws.rs.PUT)12