Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions carRentalLabSessions_v6/src/main/java/ds/gae/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S
}

private void confirmQuotes(List<Quote> quotes) throws ReservationException {
Transaction tx = ds.newTransaction();
List<Entity> reslist = new ArrayList<Entity>();
try {
for (Quote quote : quotes) {
// confirmQuoteTx(quote, tx);
for (Quote quote : quotes) {
Transaction tx1 = ds.newTransaction();
try {
Key crcKey = ds.newKeyFactory().setKind("CarRentalCompany").newKey(quote.getRentalCompany());
Expand All @@ -71,25 +67,14 @@ private void confirmQuotes(List<Quote> quotes) throws ReservationException {
} finally {
if (tx1.isActive()) {
tx1.rollback();
//for (Entity e:reslist) {
//ds.delete(e.getKey());
//}
for (Entity e:reslist) {
ds.delete(e.getKey());
}
throw new ReservationException("Quote unavailable. Booking failed, rollback all reservations. ");
}

}}
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
for (Entity e:reslist) {
ds.delete(e.getKey());
}
throw new ReservationException("Outer transaction unavailable. Booking failed, rollback all reservations. ");
}

}

}

public void confirmQuoteTx(Quote quote, Transaction tx) throws ReservationException {
Expand Down