Search in sources :

Example 1 with ProgramMessageBatch

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);
}
Also used : ProgramMessageBatch(org.hisp.dhis.program.message.ProgramMessageBatch) BatchResponseStatus(org.hisp.dhis.outboundmessage.BatchResponseStatus) ProgramMessage(org.hisp.dhis.program.message.ProgramMessage) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BatchResponseStatus (org.hisp.dhis.outboundmessage.BatchResponseStatus)1 ProgramMessage (org.hisp.dhis.program.message.ProgramMessage)1 ProgramMessageBatch (org.hisp.dhis.program.message.ProgramMessageBatch)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1