orderId = _dbControl.getLastOrderIdForUser(order.getUserId());
if (orderId == -1)
{
// somehow the order didn't get recorded
_logger.error( "Unexpected DAO exception");
throw new DataStoreException("unexpected database exception");
}
// Add the cart items and update the quantities in the DB
Item item = null;
Iterator i = cart.getLineItems().iterator();
while (i.hasNext())
{
LineItem lineItem = (LineItem) i.next();
_catalogControl.updateItemQuantity(lineItem.getItem().getItemId(), lineItem.getQuantity());
_dbControl.addOrderItem(orderId, lineItem.getItem().getItemId(), lineItem.getQuantity());
}
connection.commit();
connection.setAutoCommit( true );
} catch (SQLException e) {
_logger.error( "Unexpected DAO exception", e );
throw new DataStoreException("unexpected database exception");
}
return orderId;
}