[OFBiz] SVN: r7847 - trunk/applications/order/src/org/ofbiz/order/shoppingcart

jacopo@svn.ofbiz.org jacopo at svn.ofbiz.org
Fri Jun 23 00:58:00 CDT 2006


Author: jacopo
Date: 2006-06-23 00:57:49 -0500 (Fri, 23 Jun 2006)
New Revision: 7847

Modified:
   trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
Log:
Production run related services are now run using the 'system' user to avoid permission errors when the order is created in the ecommerce site.

Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java	2006-06-22 23:06:52 UTC (rev 7846)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java	2006-06-23 05:57:49 UTC (rev 7847)
@@ -573,6 +573,9 @@
             String productId = orderItem.getString("productId");
             if (productId != null) {
                 try {
+                    // do something tricky here: run as a different user 
+                    // that can actually create and run a production run
+                    GenericValue permUserLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
                     GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);
                     GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
                     if ("AGGREGATED".equals(product.getString("productTypeId"))) {
@@ -583,7 +586,7 @@
                         inputMap.put("orderId", orderId);
                         inputMap.put("orderItemSeqId", orderItem.getString("orderItemSeqId"));
                         inputMap.put("quantity", orderItem.getDouble("quantity"));
-                        inputMap.put("userLogin", userLogin);
+                        inputMap.put("userLogin", permUserLogin);
                         
                         Map prunResult = dispatcher.runSync("createProductionRunFromConfiguration", inputMap);
                         if (ServiceUtil.isError(prunResult)) {
@@ -594,7 +597,7 @@
                         inputMap.put("facilityId", productStore.getString("inventoryFacilityId"));
                         inputMap.put("orderId", orderId);
                         inputMap.put("orderItemSeqId", orderItem.getString("orderItemSeqId"));
-                        inputMap.put("userLogin", userLogin);
+                        inputMap.put("userLogin", permUserLogin);
                         Map prunResult = dispatcher.runSync("createProductionRunForMktgPkg", inputMap);
                         if (ServiceUtil.isError(prunResult)) {
                             Debug.logError(ServiceUtil.getErrorMessage(prunResult) + " for input:" + inputMap, module);



More information about the Svn mailing list