You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/03/28 23:21:03 UTC
svn commit: r523465 -
/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
Author: jaz
Date: Wed Mar 28 14:21:02 2007
New Revision: 523465
URL: http://svn.apache.org/viewvc?view=rev&rev=523465
Log:
due to the nature of the checkout helper's payment processing events; it is necessary to disable transaction to appear like we are operating under an event style processing. The actual payment processing code should be reviewed and converted over to a service based structure
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=523465&r1=523464&r2=523465
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Wed Mar 28 14:21:02 2007
@@ -34,6 +34,8 @@
import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.transaction.TransactionUtil;
+import org.ofbiz.entity.transaction.GenericTransactionException;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityConditionList;
import org.ofbiz.entity.condition.EntityExpr;
@@ -58,6 +60,8 @@
import org.ofbiz.service.ServiceUtil;
import org.ofbiz.workflow.WfUtil;
+import javax.transaction.Transaction;
+
/**
* Order Processing Services
*/
@@ -4099,30 +4103,46 @@
LocalDispatcher dispatcher = dctx.getDispatcher();
GenericDelegator delegator = dctx.getDelegator();
- ShoppingCart cart = (ShoppingCart) context.get("shoppingCart");
- GenericValue userLogin = cart.getUserLogin();
- Boolean manualHold = (Boolean) context.get("manualHold");
- if (manualHold == null) {
- manualHold = Boolean.FALSE;
- }
+ Transaction trans = null;
+ try {
+ // disable transaction procesing
+ trans = TransactionUtil.suspend();
- String productStoreId = cart.getProductStoreId();
-
- GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);
- CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart);
+ // get the cart
+ ShoppingCart cart = (ShoppingCart) context.get("shoppingCart");
+ GenericValue userLogin = cart.getUserLogin();
+ Boolean manualHold = (Boolean) context.get("manualHold");
+ if (manualHold == null) {
+ manualHold = Boolean.FALSE;
+ }
- // process payment
- Map payResp;
- try {
- payResp = coh.processPayment(productStore, userLogin, false, manualHold.booleanValue());
- } catch (GeneralException e) {
- Debug.logError(e, module);
+ String productStoreId = cart.getProductStoreId();
+
+ GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);
+ CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart);
+
+ // process payment
+ Map payResp;
+ try {
+ payResp = coh.processPayment(productStore, userLogin, false, manualHold.booleanValue());
+ } catch (GeneralException e) {
+ Debug.logError(e, module);
+ return ServiceUtil.returnError(e.getMessage());
+ }
+ if (ServiceUtil.isError(payResp)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(payResp));
+ }
+
+ return ServiceUtil.returnSuccess();
+ } catch (GenericTransactionException e) {
return ServiceUtil.returnError(e.getMessage());
+ } finally {
+ // resume transaction
+ try {
+ TransactionUtil.resume(trans);
+ } catch (GenericTransactionException e) {
+ Debug.logWarning(e, e.getMessage(), module);
+ }
}
- if (ServiceUtil.isError(payResp)) {
- return ServiceUtil.returnError(ServiceUtil.getErrorMessage(payResp));
- }
-
- return ServiceUtil.returnSuccess();
}
}