/**
* Process OrderCancelRequest. Cancels the order if the status change is valid.
*/
public void processOrderCancelRequest(String clOrdID) {
Order order = orderRepository.findOrderByClientOrderId(clOrdID);
if (order == null) {
logger.error("OrderCancelRequest: clOrdID {} not found", clOrdID);
return;
}
order.cancel();
if (order.getStatus() == OrderStatus.Canceled) {
orderEventPublisher.publish(new OrderCanceled(order));
}
else {
orderEventPublisher.publish(new OrderCancelRejected(order));
}