Search in sources :

Example 6 with CommunicatorMessageTemplate

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

the class CommunicatorRESTService method createUserMessageTemplate.

@POST
@Path("/templates")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response createUserMessageTemplate(CommunicatorMessageTemplateRESTModel template) throws AuthorizationException {
    UserEntity userEntity = sessionController.getLoggedUserEntity();
    CommunicatorMessageTemplate messageTemplate = communicatorController.createMessageTemplate(template.getName(), template.getContent(), userEntity);
    CommunicatorMessageTemplateRESTModel result = new CommunicatorMessageTemplateRESTModel(messageTemplate.getId(), messageTemplate.getName(), messageTemplate.getContent());
    return Response.ok(result).build();
}
Also used : CommunicatorMessageTemplate(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageTemplate) 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 CommunicatorMessageTemplate

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

the class CommunicatorRESTService method listUserMessageTemplates.

@GET
@Path("/templates")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listUserMessageTemplates() throws AuthorizationException {
    UserEntity userEntity = sessionController.getLoggedUserEntity();
    List<CommunicatorMessageTemplate> templates = communicatorController.listMessageTemplates(userEntity);
    List<CommunicatorMessageTemplateRESTModel> result = new ArrayList<CommunicatorMessageTemplateRESTModel>();
    for (CommunicatorMessageTemplate template : templates) {
        result.add(new CommunicatorMessageTemplateRESTModel(template.getId(), template.getName(), template.getContent()));
    }
    return Response.ok(result).build();
}
Also used : CommunicatorMessageTemplate(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageTemplate) ArrayList(java.util.ArrayList) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

CommunicatorMessageTemplate (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageTemplate)7 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)5 Path (javax.ws.rs.Path)5 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 ArrayList (java.util.ArrayList)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 DELETE (javax.ws.rs.DELETE)1