ResponseEntity process()

in service/src/main/java/org/apache/fineract/cn/cheque/service/rest/ChequeRestController.java [132:151]


  ResponseEntity<Void> process(@PathVariable("identifier") final String identifier,
                               @RequestBody @Valid final ChequeProcessingCommand chequeProcessingCommand) {

    if (!this.chequeService.findBy(MICRParser.fromIdentifier(identifier)).isPresent()) {
      throw ServiceException.notFound("Cheque {0} not found.", identifier);
    }

    switch (Action.valueOf(chequeProcessingCommand.getAction())) {
      case APPROVE:
        this.commandGateway.process(new ApproveChequeTransactionCommand(identifier));
        break;
      case CANCEL:
        this.commandGateway.process(new CancelChequeTransactionCommand(identifier));
        break;
      default:
        throw ServiceException.badRequest("Unknown cheque command {0}.", chequeProcessingCommand.getAction());
    }

    return ResponseEntity.accepted().build();
  }