use of io.narayana.sra.demo.model.Booking in project narayana by jbosstm.
the class TripService method cancelBooking.
public Booking cancelBooking(Booking booking) {
System.out.printf("Canceling booking id %s (%s) status: %s%n", booking.getId(), booking.getName(), booking.getStatus());
if (booking.getStatus() != BookingStatus.CANCEL_REQUESTED && booking.getStatus() != BookingStatus.PROVISIONAL)
throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity("To late to requestCancel booking").build());
Booking prev = add(booking);
if (prev != null)
System.out.printf("Seen this booking before%n");
booking.requestCancel();
lraClient.cancelSRA(SRAClient.lraToURL(booking.getId(), "Invalid trip booking id format"));
booking.setCanceled();
return mergeBookingResponse(booking);
}
Aggregations