use of org.hisp.dhis.program.message.ProgramMessageBatch in project dhis2-core by dhis2.
the class ProgramMessageController method saveMessages.
// -------------------------------------------------------------------------
// POST
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')")
@RequestMapping(method = RequestMethod.POST, consumes = { "application/json" }, produces = { "application/json" })
public void saveMessages(HttpServletRequest request, HttpServletResponse response) throws IOException, WebMessageException {
ProgramMessageBatch batch = renderService.fromJson(request.getInputStream(), ProgramMessageBatch.class);
for (ProgramMessage programMessage : batch.getProgramMessages()) {
programMessageService.validatePayload(programMessage);
}
BatchResponseStatus status = programMessageService.sendMessages(batch.getProgramMessages());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
renderService.toJson(response.getOutputStream(), status);
}
Aggregations