Author: bibryam
Date: Thu Jan 17 01:03:54 2008 New Revision: 612767 URL: http://svn.apache.org/viewvc?rev=612767&view=rev Log: Applied my modified patch from JIRA Issue # OFBIZ-1154 "Black list is not working". Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=612767&r1=612766&r2=612767&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java Thu Jan 17 01:03:54 2008 @@ -35,6 +35,7 @@ import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.marketing.tracking.TrackingCodeEvents; +import org.ofbiz.party.party.PartyWorker; import org.ofbiz.product.catalog.CatalogWorker; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.GenericServiceException; @@ -574,7 +575,11 @@ Map callResult = checkOutHelper.checkOrderBlacklist(userLogin); if (callResult.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) { - result = (String) callResult.get(ModelService.ERROR_MESSAGE); + request.setAttribute("_ERROR_MESSAGE_", callResult.get(ModelService.ERROR_MESSAGE)); + result = "error"; + } else if (callResult.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_FAIL)) { + request.setAttribute("_ERROR_MESSAGE_", callResult.get(ModelService.ERROR_MESSAGE)); + result = "failed"; } else { result = (String) callResult.get(ModelService.SUCCESS_MESSAGE); } @@ -587,7 +592,9 @@ ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingCart"); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); + String orderPartyId = cart.getOrderPartyId(); + GenericValue userLogin = PartyWorker.findPartyLatestUserLogin(orderPartyId, delegator); + GenericValue currentUser = (GenericValue) session.getAttribute("userLogin"); String result; // Load the properties store @@ -599,8 +606,9 @@ ServiceUtil.getMessages(request, callResult, null); // wipe the session - session.invalidate(); - + if (("anonymous".equals(currentUser.getString("userLoginId"))) || (currentUser.getString("userLoginId")).equals(userLogin.getString("userLoginId"))) { + session.invalidate(); + } //Determine whether it was a success or not if (callResult.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) { result = (String) callResult.get(ModelService.ERROR_MESSAGE); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=612767&r1=612766&r2=612767&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Thu Jan 17 01:03:54 2008 @@ -1182,7 +1182,7 @@ } if (blacklistFound != null && blacklistFound.size() > 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderFailed", (cart != null ? cart.getLocale() : Locale.getDefault()))); + return ServiceUtil.returnFailure(UtilProperties.getMessage(resource_error,"OrderFailed", (cart != null ? cart.getLocale() : Locale.getDefault()))); } else { return ServiceUtil.returnSuccess("success"); } @@ -1191,25 +1191,26 @@ public Map failedBlacklistCheck(GenericValue userLogin, GenericValue productStore) { Map result; String errMsg=null; - String REJECT_MESSAGE = productStore.getString("authFraudMessage"); - - // Get the orderId from the cart. String orderId = this.cart.getOrderId(); - - // set the order/item status - reverse inv - OrderChangeHelper.rejectOrder(dispatcher, userLogin, orderId); - - // nuke the userlogin - userLogin.set("enabled", "N"); + try { - userLogin.store(); + if (userLogin != null) { + // nuke the userlogin + userLogin.set("enabled", "N"); + userLogin.store(); + } else { + userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "system")); + } } catch (GenericEntityException e) { - Debug.logError(e, "Problems de-activating userLogin.", module); + Debug.logError(e, module); errMsg = UtilProperties.getMessage(resource,"checkhelper.database_error", (cart != null ? cart.getLocale() : Locale.getDefault())); result = ServiceUtil.returnError(errMsg); return result; } + + // set the order/item status - reverse inv + OrderChangeHelper.rejectOrder(dispatcher, userLogin, orderId); result = ServiceUtil.returnSuccess(); result.put(ModelService.ERROR_MESSAGE, REJECT_MESSAGE); Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?rev=612767&r1=612766&r2=612767&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Thu Jan 17 01:03:54 2008 @@ -855,8 +855,14 @@ <security direct-request="false"/> <event type="java" path="org.ofbiz.order.shoppingcart.CheckOutEvents" invoke="checkOrderBlacklist"/> <response name="success" type="request" value="processpayment"/> - <response name="failed" type="view" value="confirm"/> + <response name="failed" type="request" value="failedBlacklist"/> <response name="error" type="view" value="confirm"/> + </request-map> + <request-map uri="failedBlacklist"> + <security direct-request="false"/> + <event type="java" path="org.ofbiz.order.shoppingcart.CheckOutEvents" invoke="failedBlacklistCheck"/> + <response name="success" type="view" value="main"/> + <response name="error" type="view" value="main"/> </request-map> <request-map uri="processpayment"> <security direct-request="false"/> |
Free forum by Nabble | Edit this page |