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