Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java Sun Dec 31 11:11:46 2017 @@ -42,7 +42,6 @@ import org.apache.ofbiz.entity.condition import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.entity.util.EntityUtil; import org.apache.ofbiz.manufacturing.bom.BOMNode; -import org.apache.ofbiz.order.order.OrderReadHelper; import org.apache.ofbiz.service.DispatchContext; import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; @@ -512,6 +511,10 @@ public class MrpServices { } else { resultMap = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); } + if (ServiceUtil.isError(resultMap)) { + String errorMessage = ServiceUtil.getErrorMessage(resultMap); + Debug.logError(errorMessage, module); + } } catch (GenericServiceException e) { Debug.logError(e, "Error calling getProductInventoryAvailableByFacility service", module); logMrpError(mrpId, productId, "Unable to count inventory", delegator); @@ -663,6 +666,9 @@ public class MrpServices { parameters.put("manufacturingFacilityId", manufacturingFacilityId); try { result = dispatcher.runSync("initMrpEvents", parameters); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } catch (GenericServiceException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpErrorRunningInitMrpEvents", UtilMisc.toMap("errorString", e.getMessage()), locale)); } @@ -735,6 +741,9 @@ public class MrpServices { Map<String, Object> serviceResponse = null; try { serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "quantity", positiveEventQuantity, "excludeWIPs", Boolean.FALSE, "userLogin", userLogin)); + if (ServiceUtil.isError(serviceResponse)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResponse)); + } } catch (GenericServiceException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpErrorExplodingProduct", UtilMisc.toMap("productId", product.getString("productId")), locale)); } catch (Exception e) { @@ -769,6 +778,9 @@ public class MrpServices { Map<String, Object> serviceResponse = null; try { serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "quantity", proposedOrder.getQuantity(), "excludeWIPs", Boolean.FALSE, "userLogin", userLogin)); + if (ServiceUtil.isError(serviceResponse)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResponse)); + } } catch (GenericServiceException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpErrorExplodingProduct", UtilMisc.toMap("productId", product.getString("productId")), locale)); } catch (Exception e) { Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java Sun Dec 31 11:11:46 2017 @@ -41,6 +41,7 @@ import org.apache.ofbiz.manufacturing.te import org.apache.ofbiz.service.DispatchContext; import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ServiceUtil; /** * Proposed Order Object generated by the MRP process or other re-Order process @@ -116,6 +117,10 @@ public class ProposedOrder { Map<String, Object> routingInMap = UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "ignoreDefaultRouting", "Y", "userLogin", userLogin); Map<String, Object> routingOutMap = dispatcher.runSync("getProductRouting", routingInMap); + if (ServiceUtil.isError(routingOutMap)) { + String errorMessage = ServiceUtil.getErrorMessage(routingOutMap); + Debug.logError(errorMessage, module); + } routing = (GenericValue)routingOutMap.get("routing"); listRoutingTaskAssoc = UtilGenerics.checkList(routingOutMap.get("tasks")); if (routing == null) { @@ -134,6 +139,10 @@ public class ProposedOrder { if (tree != null && tree.getRoot() != null && tree.getRoot().getProduct() != null) { routingInMap = UtilMisc.toMap("productId", tree.getRoot().getProduct().getString("productId"), "userLogin", userLogin); routingOutMap = dispatcher.runSync("getProductRouting", routingInMap); + if (ServiceUtil.isError(routingOutMap)) { + String errorMessage = ServiceUtil.getErrorMessage(routingOutMap); + Debug.logError(errorMessage, module); + } routing = (GenericValue)routingOutMap.get("routing"); } } @@ -149,6 +158,10 @@ public class ProposedOrder { Map<String, Object> routingTasksInMap = UtilMisc.<String, Object>toMap("workEffortId", routing.getString("workEffortId"), "userLogin", userLogin); Map<String, Object> routingTasksOutMap = dispatcher.runSync("getRoutingTaskAssocs", routingTasksInMap); + if (ServiceUtil.isError(routingTasksOutMap)) { + String errorMessage = ServiceUtil.getErrorMessage(routingTasksOutMap); + Debug.logError(errorMessage, module); + } listRoutingTaskAssoc = UtilGenerics.checkList(routingTasksOutMap.get("routingTaskAssocs")); } catch (GenericServiceException gse) { Debug.logWarning(gse.getMessage(), module); @@ -247,6 +260,11 @@ public class ProposedOrder { } try { Map<String, Object> result = dispatcher.runSync("createRequirement", parameters); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + Debug.logError(errorMessage, module); + return null; + } return (String) result.get("requirementId"); } catch (GenericServiceException e) { Debug.logError(e,"Error : createRequirement with parameters = "+parameters+"--"+e.getMessage(), module); Modified: ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java Sun Dec 31 11:11:46 2017 @@ -208,6 +208,9 @@ public class VCard { } } Map<String, Object> resp = dispatcher.runSync(serviceName, serviceCtx); + if (ServiceUtil.isError(resp)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resp)); + } partiesCreated.add(UtilMisc.toMap("partyId", (String) resp.get("partyId"))); if (formattedName != null) { @@ -217,6 +220,9 @@ public class VCard { createPartyIdentificationMap.put("partyIdentificationTypeId", "VCARD_FN_ORIGIN"); createPartyIdentificationMap.put("idValue", formattedName.getValue()); resp = dispatcher.runSync("createPartyIdentification", createPartyIdentificationMap); + if (ServiceUtil.isError(resp)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resp)); + } } } } catch (IOException | GenericEntityException | GenericServiceException e) { Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java Sun Dec 31 11:11:46 2017 @@ -48,7 +48,7 @@ import org.apache.ofbiz.order.order.Orde import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ModelService; - +import org.apache.ofbiz.service.ServiceUtil; /** * Order Manager Events */ @@ -91,19 +91,18 @@ public class OrderManagerEvents { try { results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.toMap("orderPaymentPreferenceId", ppref.get("orderPaymentPreferenceId"), "paymentFromId", placingCustomer.getString("partyId"), "comments", "Payment received offline and manually entered.")); + if (ServiceUtil.isError(results)) { + String errorMessage = ServiceUtil.getErrorMessage(results); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (GenericServiceException e) { Debug.logError(e, "Failed to execute service createPaymentFromPreference", module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } - - if (ModelService.RESPOND_ERROR.equals(results.get(ModelService.RESPONSE_MESSAGE))) { - Debug.logError((String) results.get(ModelService.ERROR_MESSAGE), module); - request.setAttribute("_ERROR_MESSAGE_", results.get(ModelService.ERROR_MESSAGE)); - return "error"; - } } - // store the updated preferences try { delegator.storeAll(toBeStored); @@ -202,17 +201,17 @@ public class OrderManagerEvents { "paymentRefNum", paymentMethodReference, "comments", "Payment received offline and manually entered.", "userLogin", userLogin)); + if (ServiceUtil.isError(results)) { + String errorMessage = ServiceUtil.getErrorMessage(results); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (GenericServiceException e) { Debug.logError(e, "Failed to execute service createPaymentFromOrder", module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } - - if (ModelService.RESPOND_ERROR.equals(results.get(ModelService.RESPONSE_MESSAGE))) { - Debug.logError((String) results.get(ModelService.ERROR_MESSAGE), module); - request.setAttribute("_ERROR_MESSAGE_", results.get(ModelService.ERROR_MESSAGE)); - return "error"; - } } OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId); return "success"; @@ -260,17 +259,17 @@ public class OrderManagerEvents { results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.toMap("userLogin", userLogin, "orderPaymentPreferenceId", paymentPreference.get("orderPaymentPreferenceId"), "paymentRefNum", paymentReference, "paymentFromId", placingCustomer.getString("partyId"), "comments", "Payment received offline and manually entered.")); + if (ServiceUtil.isError(results)) { + String errorMessage = ServiceUtil.getErrorMessage(results); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (GenericServiceException e) { Debug.logError(e, "Failed to execute service createPaymentFromPreference", module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } - - if (results.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) { - Debug.logError((String) results.get(ModelService.ERROR_MESSAGE), module); - request.setAttribute("_ERROR_MESSAGE_", results.get(ModelService.ERROR_MESSAGE)); - return "error"; - } } } } Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java Sun Dec 31 11:11:46 2017 @@ -140,8 +140,10 @@ public final class OrderChangeHelper { // set the status on the order header Map<String, Object> statusFields = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", orderStatus, "userLogin", userLogin); Map<String, Object> statusResult = dispatcher.runSync("changeOrderStatus", statusFields); - if (statusResult.containsKey(ModelService.ERROR_MESSAGE)) { - Debug.logError("Problems adjusting order header status for order #" + orderId, module); + if (ServiceUtil.isError(statusResult)) { + String errorMessage = ServiceUtil.getErrorMessage(statusResult); + Debug.logError(errorMessage, module); + throw new GenericServiceException(errorMessage); } // set the status on the order item(s) @@ -150,8 +152,10 @@ public final class OrderChangeHelper { itemStatusFields.put("fromStatusId", fromItemStatus); } Map<String, Object> itemStatusResult = dispatcher.runSync("changeOrderItemStatus", itemStatusFields); - if (itemStatusResult.containsKey(ModelService.ERROR_MESSAGE)) { - Debug.logError("Problems adjusting order item status for order #" + orderId, module); + if (ServiceUtil.isError(itemStatusResult)) { + String errorMessage = ServiceUtil.getErrorMessage(itemStatusResult); + Debug.logError(errorMessage, module); + throw new GenericServiceException(errorMessage); } // now set the status for digital items @@ -193,8 +197,10 @@ public final class OrderChangeHelper { // update the status Map<String, Object> digitalStatusFields = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", digitalItemStatus, "userLogin", userLogin); Map<String, Object> digitalStatusChange = dispatcher.runSync("changeOrderItemStatus", digitalStatusFields); - if (ModelService.RESPOND_ERROR.equals(digitalStatusChange.get(ModelService.RESPONSE_MESSAGE))) { - Debug.logError("Problems with digital product status change : " + product, module); + if (ServiceUtil.isError(digitalStatusChange)) { + String errorMessage = ServiceUtil.getErrorMessage(digitalStatusChange); + Debug.logError(errorMessage, module); + throw new GenericServiceException(errorMessage); } } } @@ -204,8 +210,10 @@ public final class OrderChangeHelper { // non-product items don't ship; treat as a digital item Map<String, Object> digitalStatusFields = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", digitalItemStatus, "userLogin", userLogin); Map<String, Object> digitalStatusChange = dispatcher.runSync("changeOrderItemStatus", digitalStatusFields); - if (ModelService.RESPOND_ERROR.equals(digitalStatusChange.get(ModelService.RESPONSE_MESSAGE))) { - Debug.logError("Problems with digital product status change", module); + if (ServiceUtil.isError(digitalStatusChange)) { + String errorMessage = ServiceUtil.getErrorMessage(digitalStatusChange); + Debug.logError(errorMessage, module); + throw new GenericServiceException(errorMessage); } } } @@ -219,16 +227,20 @@ public final class OrderChangeHelper { // cancel the inventory reservations Map<String, Object> cancelInvFields = UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin); Map<String, Object> cancelInvResult = dispatcher.runSync("cancelOrderInventoryReservation", cancelInvFields); - if (ModelService.RESPOND_ERROR.equals(cancelInvResult.get(ModelService.RESPONSE_MESSAGE))) { - Debug.logError("Problems reversing inventory reservations for order #" + orderId, module); + if (ServiceUtil.isError(cancelInvResult)) { + String errorMessage = ServiceUtil.getErrorMessage(cancelInvResult); + Debug.logError(errorMessage, module); + throw new GenericServiceException(errorMessage); } } public static void releasePaymentAuthorizations(LocalDispatcher dispatcher, GenericValue userLogin, String orderId) throws GenericServiceException { Map<String, Object> releaseFields = UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin); Map<String, Object> releaseResult = dispatcher.runSync("releaseOrderPayments", releaseFields); - if (ModelService.RESPOND_ERROR.equals(releaseResult.get(ModelService.RESPONSE_MESSAGE))) { - Debug.logError("Problems releasing payment authorizations for order #" + orderId, module); + if (ServiceUtil.isError(releaseResult)) { + String errorMessage = ServiceUtil.getErrorMessage(releaseResult); + Debug.logError(errorMessage, module); + throw new GenericServiceException(errorMessage); } } @@ -256,8 +268,10 @@ public final class OrderChangeHelper { Map<String, Object> results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.<String, Object>toMap("userLogin", userLogin, "orderPaymentPreferenceId", opp.getString("orderPaymentPreferenceId"), "paymentRefNum", UtilDateTime.nowTimestamp().toString(), "paymentFromId", partyId)); - if (results.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) { - Debug.logError((String) results.get(ModelService.ERROR_MESSAGE), module); + if (ServiceUtil.isError(results)) { + String errorMessage = ServiceUtil.getErrorMessage(results); + Debug.logError(errorMessage, module); + throw new GenericServiceException(errorMessage); } } } @@ -279,7 +293,9 @@ public final class OrderChangeHelper { Map<String, Object> serviceParam = UtilMisc.<String, Object>toMap("orderId", orderId, "billItems", items, "userLogin", userLogin); Map<String, Object> serviceRes = dispatcher.runSync("createInvoiceForOrder", serviceParam); if (ServiceUtil.isError(serviceRes)) { - throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceRes)); + String errorMessage = ServiceUtil.getErrorMessage(serviceRes); + Debug.logError(errorMessage, module); + throw new GenericServiceException(errorMessage); } } } Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java Sun Dec 31 11:11:46 2017 @@ -119,14 +119,12 @@ public class OrderEvents { contextMap.put("locale", locale); try { resultMap = dispatcher.runSync("cancelOrderItem", contextMap); - if (ServiceUtil.isError(resultMap)) { String errorMessage = ServiceUtil.getErrorMessage(resultMap); - Debug.logError(errorMessage, module); request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); return "error"; } - } catch (GenericServiceException e) { Debug.logError(e, module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java Sun Dec 31 11:11:46 2017 @@ -405,6 +405,9 @@ public class OrderLookupServices { List<GenericValue> variants = null; try { varLookup = dispatcher.runSync("getAllProductVariants", UtilMisc.toMap("productId", productId)); + if (ServiceUtil.isError(varLookup)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(varLookup)); + } variants = UtilGenerics.checkList(varLookup.get("assocProducts")); } catch (GenericServiceException e) { Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java Sun Dec 31 11:11:46 2017 @@ -283,18 +283,16 @@ public class OrderReturnServices { Map<String, Object> sendResp = null; try { sendResp = dispatcher.runSync("sendMailFromScreen", sendMap); + if (ServiceUtil.isError(sendResp)) { + sendResp.put("emailType", emailType); + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, + "OrderProblemSendingEmail", locale), null, null, sendResp); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem sending mail", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderProblemSendingEmail", locale)); } - - // check for errors - if (sendResp != null && ServiceUtil.isError(sendResp)) { - sendResp.put("emailType", emailType); - return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, - "OrderProblemSendingEmail", locale), null, null, sendResp); - } return ServiceUtil.returnSuccess(); } } @@ -364,7 +362,10 @@ public class OrderReturnServices { GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", replacementOrderId).queryOne(); if ("ORDER_HOLD".equals(orderHeader.getString("statusId"))) { try { - dispatcher.runSync("cancelOrderItem", svcCtx); + Map<String, Object> result = dispatcher.runSync("cancelOrderItem", svcCtx); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem calling service cancelOrderItem: " + svcCtx, module); } @@ -522,14 +523,14 @@ public class OrderReturnServices { Map<String, Object> serviceResult = null; try { serviceResult = dispatcher.runSync("getReturnableQuantity", UtilMisc.toMap("orderItem", item)); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } catch (GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderErrorUnableToGetTheItemReturnableQuantity", locale)); } - if (serviceResult.containsKey(ModelService.ERROR_MESSAGE)) { - return ServiceUtil.returnError((String) serviceResult.get(ModelService.ERROR_MESSAGE)); - } // Don't add the OrderItem to the map of returnable OrderItems if there isn't any returnable quantity. if (((BigDecimal) serviceResult.get("returnableQuantity")).compareTo(BigDecimal.ZERO) == 0) { continue; @@ -601,6 +602,7 @@ public class OrderReturnServices { GenericValue userLogin = (GenericValue) context.get("userLogin"); String returnId = (String) context.get("returnId"); Locale locale = (Locale) context.get("locale"); + Map<String, Object> serviceResult = new HashMap<String, Object>(); GenericValue returnHeader = null; List<GenericValue> returnItems = null; @@ -659,9 +661,13 @@ public class OrderReturnServices { // to the final status if (currentStatus != null && "RETURN_ACCEPTED".equals(currentStatus)) { try { - dispatcher.runSync("updateReturnHeader", UtilMisc.<String, Object>toMap("returnId", returnId, + serviceResult = dispatcher.runSync("updateReturnHeader", UtilMisc.<String, Object>toMap("returnId", returnId, "statusId", "RETURN_RECEIVED", "userLogin", userLogin)); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, + "OrderErrorUnableToCreateReturnStatusHistory", locale)); + } } catch (GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, @@ -669,9 +675,13 @@ public class OrderReturnServices { } } else if (currentStatus != null && "RETURN_RECEIVED".equals(currentStatus)) { try { - dispatcher.runSync("updateReturnHeader", UtilMisc.<String, Object>toMap("returnId", returnId, + serviceResult = dispatcher.runSync("updateReturnHeader", UtilMisc.<String, Object>toMap("returnId", returnId, "statusId", "RETURN_COMPLETED", "userLogin", userLogin)); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, + "OrderErrorUnableToCreateReturnStatusHistory", locale)); + } } catch (GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, @@ -1064,7 +1074,7 @@ public class OrderReturnServices { input.put("thruDate", thruDate); Map<String, Object> results = dispatcher.runSync("createBillingAccount", input); if (ServiceUtil.isError(results)) { - return results; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); } String billingAccountId = (String) results.get("billingAccountId"); @@ -1236,6 +1246,9 @@ public class OrderReturnServices { Map<String, Object> acctgPreferencesResult = null; try { acctgPreferencesResult = dispatcher.runSync("getPartyAccountingPreferences", UtilMisc.toMap("organizationPartyId", productStore.get("payToPartyId"), "userLogin", userLogin)); + if (ServiceUtil.isError(acctgPreferencesResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(acctgPreferencesResult)); + } } catch (GenericServiceException e) { Debug.logError(e, "Error retrieving PartyAcctgPreference for partyId " + productStore.get("payToPartyId"), module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, @@ -1373,6 +1386,9 @@ public class OrderReturnServices { serviceContext.put("maxAmount", amountToRefund.setScale(decimals, rounding)); String orderPaymentPreferenceNewId = null; Map<String, Object> result = dispatcher.runSync("createOrderPaymentPreference", serviceContext); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } orderPaymentPreferenceNewId = (String) result.get("orderPaymentPreferenceId"); try { refundOrderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceNewId).queryOne(); @@ -1558,7 +1574,7 @@ public class OrderReturnServices { try { Map<String, Object> paymentCreationResult = dispatcher.runSync("createPayment", paymentCtx); if (ServiceUtil.isError(paymentCreationResult)) { - return paymentCreationResult; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(paymentCreationResult)); } paymentId = (String) paymentCreationResult.get("paymentId"); } catch (GenericServiceException e) { @@ -1581,7 +1597,7 @@ public class OrderReturnServices { Map<String, Object> paymentApplResult = dispatcher.runSync("createPaymentApplication", UtilMisc.<String, Object>toMap("paymentId", paymentId, "billingAccountId", billingAccount.getString("billingAccountId"), "amountApplied", refundAmount, "userLogin", userLogin)); if (ServiceUtil.isError(paymentApplResult)) { - return paymentApplResult; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(paymentApplResult)); } } catch (GenericServiceException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, @@ -1663,7 +1679,7 @@ public class OrderReturnServices { } Map<String, Object> serviceResults = dispatcher.runSync("createPaymentApplication", input); if (ServiceUtil.isError(serviceResults)) { - return ServiceUtil.returnError(errorMsg, null, null, serviceResults); + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResults)); } if (Debug.verboseOn()) { Debug.logInfo("Created PaymentApplication for response with amountApplied " + amountApplied.toString(), module); } } @@ -2047,6 +2063,9 @@ public class OrderReturnServices { Map<String, Object> orderResult = null; try { orderResult = dispatcher.runSync("storeOrder", orderMap); + if (ServiceUtil.isError(orderResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(orderResult)); + } } catch (GenericServiceException e) { Debug.logInfo(e, "Problem creating the order!", module); } @@ -2061,6 +2080,9 @@ public class OrderReturnServices { Map<String, Object> serviceResult = null; try { serviceResult = dispatcher.runSync("changeOrderStatus", UtilMisc.toMap("orderId", createdOrderId, "statusId", "ORDER_HOLD", "userLogin", userLogin)); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } catch (GenericServiceException e) { Debug.logError(e, "Service invocation error, status changes were not updated for order #" + createdOrderId, module); return ServiceUtil.returnError(e.getMessage()); @@ -2308,14 +2330,14 @@ public class OrderReturnServices { Map<String, Object> serviceResult = null; try { serviceResult = dispatcher.runSync("getReturnAmountByOrder", org.apache.ofbiz.base.util.UtilMisc.toMap("returnId", returnId)); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem running the getReturnAmountByOrder service", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderProblemsWithGetReturnAmountByOrder", locale)); } - if (ServiceUtil.isError(serviceResult)) { - return ServiceUtil.returnError((String) serviceResult.get(ModelService.ERROR_MESSAGE)); - } returnAmountByOrder = UtilGenerics.checkMap(serviceResult.get("orderReturnAmountMap")); if ((returnAmountByOrder != null) && (returnAmountByOrder.entrySet() != null)) { @@ -2518,7 +2540,11 @@ public class OrderReturnServices { // when the return item is created because they are selectable by the user inMap.put("includeAdjustments", "N"); } - return dispatcher.runSync(serviceName, inMap); + Map<String, Object> serviceResult = dispatcher.runSync(serviceName, inMap); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } + return serviceResult; } catch (org.apache.ofbiz.service.GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -2535,7 +2561,11 @@ public class OrderReturnServices { String serviceName = UtilValidate.isEmpty(returnAdjustmentId) ? "updateReturnItem" : "updateReturnAdjustment"; Debug.logInfo("serviceName:" + serviceName, module); try { - return dispatcher.runSync(serviceName, dctx.makeValidContext(serviceName, ModelService.IN_PARAM, context)); + Map<String, Object> serviceResult = dispatcher.runSync(serviceName, dctx.makeValidContext(serviceName, ModelService.IN_PARAM, context)); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } + return serviceResult; } catch (org.apache.ofbiz.service.GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java Sun Dec 31 11:11:46 2017 @@ -282,7 +282,10 @@ public class OrderServices { try { // count product ordered quantities // run this synchronously so it will run in the same transaction - dispatcher.runSync("countProductQuantityOrdered", UtilMisc.<String, Object>toMap("productId", currentProductId, "quantity", orderItem.getBigDecimal("quantity"), "userLogin", userLogin)); + Map<String, Object> result = dispatcher.runSync("countProductQuantityOrdered", UtilMisc.<String, Object>toMap("productId", currentProductId, "quantity", orderItem.getBigDecimal("quantity"), "userLogin", userLogin)); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } catch (GenericServiceException e1) { Debug.logError(e1, "Error calling countProductQuantityOrdered service", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, @@ -354,7 +357,7 @@ public class OrderServices { try { Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryAvailableOrNotRequired", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "quantity", currentQuantity)); if (ServiceUtil.isError(invReqResult)) { - errorMessages.add((String) invReqResult.get(ModelService.ERROR_MESSAGE)); + errorMessages.add(ServiceUtil.getErrorMessage(invReqResult)); List<String> errMsgList = UtilGenerics.checkList(invReqResult.get(ModelService.ERROR_MESSAGE_LIST)); errorMessages.addAll(errMsgList); } else if (!"Y".equals(invReqResult.get("availableOrNotRequired"))) { @@ -448,7 +451,7 @@ public class OrderServices { if (ServiceUtil.isError(getNextOrderIdResult)) { String errMsg = UtilProperties.getMessage(resource_error, "OrderErrorGettingNextOrderIdWhileCreatingOrder", locale); - return ServiceUtil.returnError(errMsg, null, null, getNextOrderIdResult); + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(getNextOrderIdResult)); } orderId = (String) getNextOrderIdResult.get("orderId"); } catch (GenericServiceException e) { @@ -1216,7 +1219,7 @@ public class OrderServices { if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG_PICK")) { Map<String, Object> componentsRes = dispatcher.runSync("getAssociatedProducts", UtilMisc.toMap("productId", orderItem.getString("productId"), "type", "PRODUCT_COMPONENT")); if (ServiceUtil.isError(componentsRes)) { - resErrorMessages.add((String)componentsRes.get(ModelService.ERROR_MESSAGE)); + resErrorMessages.add(ServiceUtil.getErrorMessage(componentsRes)); continue; } List<GenericValue> assocProducts = UtilGenerics.checkList(componentsRes.get("assocProducts")); @@ -1234,7 +1237,6 @@ public class OrderServices { reserveInput.put("userLogin", userLogin); reserveInput.put("facilityId", shipGroupFacilityId); Map<String, Object> reserveResult = dispatcher.runSync("reserveStoreInventory", reserveInput); - if (ServiceUtil.isError(reserveResult)) { String invErrMsg = "The product "; if (product != null) { @@ -1504,6 +1506,9 @@ public class OrderServices { Map<String, Object> resetResult = null; try { resetResult = dispatcher.runSync("resetGrandTotal", UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin)); + if (ServiceUtil.isError(resetResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resetResult)); + } } catch (GenericServiceException e) { Debug.logError(e, "ERROR: Cannot reset order totals - " + orderId, module); } @@ -1990,7 +1995,7 @@ public class OrderServices { LocalDispatcher dispatcher = ctx.getDispatcher(); Delegator delegator = ctx.getDelegator(); Locale locale = (Locale) context.get("locale"); - + Map<String, Object> resp = new HashMap<String, Object>(); GenericValue userLogin = (GenericValue) context.get("userLogin"); BigDecimal cancelQuantity = (BigDecimal) context.get("cancelQuantity"); String orderId = (String) context.get("orderId"); @@ -2112,7 +2117,10 @@ public class OrderServices { "shipGroupSeqId", orderItemShipGroupAssoc.getString("shipGroupSeqId")); if (availableQuantity.compareTo(thisCancelQty) == 0) { try { - dispatcher.runSync("deleteOrderItemShipGroupAssoc", localCtx); + resp= dispatcher.runSync("deleteOrderItemShipGroupAssoc", localCtx); + if (ServiceUtil.isError(resp)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resp)); + } } catch (GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -2139,24 +2147,26 @@ public class OrderServices { serviceCtx.put("reasonEnumId", reasonEnumId); serviceCtx.put("changeComments", changeComments); serviceCtx.put("userLogin", userLogin); - Map<String, Object> resp = null; try { resp = dispatcher.runSync("createOrderItemChange", serviceCtx); + if (ServiceUtil.isError(resp)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resp)); + } } catch (GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } - if (ServiceUtil.isError(resp)) { - return ServiceUtil.returnError((String)resp.get(ModelService.ERROR_MESSAGE)); - } } // log an order note try { BigDecimal quantity = thisCancelQty.setScale(1, orderRounding); String cancelledItemToOrder = UtilProperties.getMessage(resource, "OrderCancelledItemToOrder", locale); - dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", cancelledItemToOrder + + resp = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", cancelledItemToOrder + orderItem.getString("productId") + " (" + quantity + ")", "internalNote", "Y", "userLogin", userLogin)); + if (ServiceUtil.isError(resp)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resp)); + } } catch (GenericServiceException e) { Debug.logError(e, module); } @@ -2689,6 +2699,9 @@ public class OrderServices { Map<String, Object> sendResp = null; try { sendResp = dispatcher.runSync("sendMailFromScreen", sendMap); + if (ServiceUtil.isError(sendResp)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(sendResp)); + } } catch (GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, @@ -2918,9 +2931,8 @@ public class OrderServices { try { // Store the note. Map<String, Object> noteRes = dispatcher.runSync("createNote", noteCtx); - if (ServiceUtil.isError(noteRes)) { - return noteRes; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(noteRes)); } String noteId = (String) noteRes.get("noteId"); @@ -3056,7 +3068,10 @@ public class OrderServices { Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", "ITEM_CANCELLED", "userLogin", userLogin); try { // TODO: looks like result is ignored here, but we should be looking for errors - dispatcher.runSync("changeOrderItemStatus", svcCtx); + Map<String, Object> serviceResult = dispatcher.runSync("changeOrderItemStatus", svcCtx); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem calling change item status service : " + svcCtx, module); } @@ -3091,7 +3106,10 @@ public class OrderServices { Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", "ITEM_CANCELLED", "userLogin", userLogin); try { // TODO: check service result for an error return - dispatcher.runSync("changeOrderItemStatus", svcCtx); + Map<String, Object> serviceResult = dispatcher.runSync("changeOrderItemStatus", svcCtx); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem calling change item status service : " + svcCtx, module); } @@ -3201,15 +3219,14 @@ public class OrderServices { GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); Map<String, Object> invoiceContext = UtilMisc.<String, Object>toMap("orderId", orderId, "billItems", itemsToInvoice, "userLogin", permUserLogin); invoiceResult = dispatcher.runSync("createInvoiceForOrder", invoiceContext); + if (ServiceUtil.isError(invoiceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(invoiceResult)); + } } catch (GenericEntityException | GenericServiceException e) { Debug.logError(e, "ERROR: Unable to invoice digital items", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderProblemWithInvoiceCreationDigitalItemsNotFulfilled", locale)); } - if (ModelService.RESPOND_ERROR.equals(invoiceResult.get(ModelService.RESPONSE_MESSAGE))) { - return ServiceUtil.returnError((String) invoiceResult.get(ModelService.ERROR_MESSAGE)); - } - // update the status of digital goods to COMPLETED; leave physical/digital as APPROVED for pick/ship for (GenericValue item : itemsToInvoice) { GenericValue productType = null; @@ -3451,15 +3468,14 @@ public class OrderServices { GenericValue permUserLogin = ServiceUtil.getUserLogin(dctx, context, "system"); Map<String, Object> invoiceContext = UtilMisc.toMap("orderId", orderId, "billItems", billItems, "userLogin", permUserLogin); invoiceResult = dispatcher.runSync("createInvoiceForOrder", invoiceContext); + if (ServiceUtil.isError(invoiceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(invoiceResult)); + } } catch (GenericServiceException e) { Debug.logError(e, "ERROR: Unable to invoice service items", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderProblemWithInvoiceCreationServiceItems", locale)); } - if (ModelService.RESPOND_ERROR.equals(invoiceResult.get(ModelService.RESPONSE_MESSAGE))) { - return ServiceUtil.returnError((String) invoiceResult.get(ModelService.ERROR_MESSAGE)); - } - // update the status of service goods to COMPLETED; for (GenericValue item : serviceItems) { Map<String, Object> statusCtx = new HashMap<>(); @@ -3619,8 +3635,11 @@ public class OrderServices { // log an order note try { String addedItemToOrder = UtilProperties.getMessage(resource, "OrderAddedItemToOrder", locale); - dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", addedItemToOrder + + Map<String, Object> result = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", addedItemToOrder + productId + " (" + quantity + ")", "internalNote", "Y", "userLogin", userLogin)); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } catch (GenericServiceException e) { Debug.logError(e, module); } @@ -3883,7 +3902,10 @@ public class OrderServices { // log an order note try { - dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", "Updated order.", "internalNote", "Y", "userLogin", userLogin)); + Map<String, Object> result = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", "Updated order.", "internalNote", "Y", "userLogin", userLogin)); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } catch (GenericServiceException e) { Debug.logError(e, module); } @@ -4442,7 +4464,7 @@ public class OrderServices { throw new GeneralException(e.getMessage()); } if (ServiceUtil.isError(resp)) { - throw new GeneralException((String) resp.get(ModelService.ERROR_MESSAGE)); + throw new GeneralException(ServiceUtil.getErrorMessage(resp)); } } } @@ -4631,7 +4653,11 @@ public class OrderServices { } paymentParams.put("userLogin", userLogin); - return dispatcher.runSync("createPayment", paymentParams); + Map<String, Object> result = dispatcher.runSync("createPayment", paymentParams); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } + return result; } catch (GenericEntityException | GenericServiceException ex) { Debug.logError(ex, "Unable to create payment using payment preference.", module); @@ -5131,7 +5157,7 @@ public class OrderServices { BigDecimal requiredQuantity = (BigDecimal) productRequirementQuantities.get(productId); Map<String, Object> createRequirementResult = dispatcher.runSync("createRequirement", UtilMisc.<String, Object>toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "facilityId", facilityId, "productId", productId, "quantity", requiredQuantity, "userLogin", userLogin)); if (ServiceUtil.isError(createRequirementResult)) { - return createRequirementResult; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(createRequirementResult)); } } @@ -5204,7 +5230,7 @@ public class OrderServices { if (quantityToCancel.compareTo(BigDecimal.ZERO) > 0) { Map<String, Object> cancelOrderItemResult = dispatcher.runSync("cancelOrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "cancelQuantity", quantityToCancel, "userLogin", userLogin)); if (ServiceUtil.isError(cancelOrderItemResult)) { - return cancelOrderItemResult; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(cancelOrderItemResult)); } } @@ -5213,7 +5239,7 @@ public class OrderServices { if ("ITEM_APPROVED".equals(orderItem.getString("statusId"))) { Map<String, Object> changeOrderItemStatusResult = dispatcher.runSync("changeOrderItemStatus", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "statusId", "ITEM_COMPLETED", "userLogin", userLogin)); if (ServiceUtil.isError(changeOrderItemStatusResult)) { - return changeOrderItemStatusResult; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(changeOrderItemStatusResult)); } } } @@ -5276,7 +5302,7 @@ public class OrderServices { return ServiceUtil.returnError(e.getMessage()); } if (ServiceUtil.isError(createResp)) { - return createResp; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(createResp)); } // auth the order (new tx) @@ -5288,7 +5314,7 @@ public class OrderServices { return ServiceUtil.returnError(e.getMessage()); } if (ServiceUtil.isError(authResp)) { - return authResp; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(authResp)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -5604,6 +5630,9 @@ public class OrderServices { } result = dispatcher.runSync("loadCartFromOrder", UtilMisc.toMap("orderId", subscription.get("orderId"), "userLogin", userLogin)); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } ShoppingCart cart = (ShoppingCart) result.get("shoppingCart"); // remove former orderId from cart (would cause duplicate entry). @@ -5760,15 +5789,13 @@ public class OrderServices { //create new oisg try { result = dctx.getDispatcher().runSync("createOrderItemShipGroup", createOrderItemShipGroupMap); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } catch (GenericServiceException gse) { String errMsg = mainErrorMessage + gse.toString(); return ServiceUtil.returnError(errMsg); } - - if (ServiceUtil.isError(result)) { - String errMsg = UtilProperties.getMessage(resource, mainErrorMessage + ServiceUtil.getErrorMessage(result), locale); - return ServiceUtil.returnError(errMsg); - } return result; } @@ -5851,6 +5878,9 @@ public class OrderServices { //call service to create new oisg Map<String, Object> result = null; result = dispatcher.runSync("addOrderItemShipGroup", addOrderItemShipGroupMap); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } if (result.containsKey("shipGroupSeqId")) { shipGroupSeqId = (String) result.get("shipGroupSeqId"); } @@ -5957,12 +5987,12 @@ public class OrderServices { Map<String, Object> cancelOrderInventoryReservationMap = dctx.makeValidContext("cancelOrderInventoryReservation", ModelService.IN_PARAM, context); Map<String, Object> localResult = dispatcher.runSync("cancelOrderInventoryReservation", cancelOrderInventoryReservationMap); if (ServiceUtil.isError(localResult)) { - return localResult; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(localResult)); } Map<String, Object> deleteOrderItemShipGroupAssocMap = dctx.makeValidContext("deleteOrderItemShipGroupAssoc", ModelService.IN_PARAM, context); localResult = dispatcher.runSync("deleteOrderItemShipGroupAssoc", deleteOrderItemShipGroupAssocMap); if (ServiceUtil.isError(localResult)) { - return localResult; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(localResult)); } } catch (GenericServiceException e) { return ServiceUtil.returnError(e.toString()); @@ -6226,7 +6256,10 @@ public class OrderServices { svcIn.put("userLogin", context.get("userLogin")); svcIn.put("orderId", orderId); try { - dispatcher.runSync("createAlsoBoughtProductAssocsForOrder", svcIn); + Map<String, Object> serviceResult = dispatcher.runSync("createAlsoBoughtProductAssocsForOrder", svcIn); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } catch (GenericServiceException e) { Debug.logError(e, module); } @@ -6240,6 +6273,7 @@ public class OrderServices { String orderId = (String) context.get("orderId"); OrderReadHelper orh = new OrderReadHelper(delegator, orderId); List<GenericValue> orderItems = orh.getOrderItems(); + Map<String, Object> serviceResult = new HashMap<String, Object>(); // In order to improve efficiency a little bit, we will always create the ProductAssoc records // with productId < productIdTo when the two are compared. This way when checking for an existing // record we don't have to check both possible combinations of productIds @@ -6287,7 +6321,10 @@ public class OrderServices { Map<String, Object> updateCtx = updateProductAssoc.makeValid(context, ModelService.IN_PARAM, true, null); updateCtx.putAll(updateProductAssoc.makeValid(existingProductAssoc, ModelService.IN_PARAM)); updateCtx.put("quantity", newQuantity); - dispatcher.runSync("updateProductAssoc", updateCtx); + serviceResult = dispatcher.runSync("updateProductAssoc", updateCtx); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } else { Map<String, Object> createCtx = new HashMap<>(); createCtx.put("userLogin", context.get("userLogin")); @@ -6296,7 +6333,10 @@ public class OrderServices { createCtx.put("productAssocTypeId", "ALSO_BOUGHT"); createCtx.put("fromDate", UtilDateTime.nowTimestamp()); createCtx.put("quantity", BigDecimal.ONE); - dispatcher.runSync("createProductAssoc", createCtx); + serviceResult = dispatcher.runSync("createProductAssoc", createCtx); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } } catch (GenericServiceException e) { Debug.logError(e, module); Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java Sun Dec 31 11:11:46 2017 @@ -126,6 +126,9 @@ public class QuoteServices { Map<String, Object> sendResp = null; try { sendResp = dispatcher.runSync("sendMailFromScreen", sendMap); + if (ServiceUtil.isError(sendResp)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(sendResp)); + } } catch (GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderServiceExceptionSeeLogs",locale)); @@ -162,6 +165,7 @@ public class QuoteServices { List<GenericValue> quoteWorkEfforts = UtilGenerics.checkList(context.get("quoteWorkEfforts")); List<GenericValue> quoteAdjustments = UtilGenerics.checkList(context.get("quoteAdjustments")); Locale locale = (Locale) context.get("locale"); + Map<String, Object> serviceResult = new HashMap<String, Object>(); //TODO create Quote Terms still to be implemented //TODO create Quote Term Attributes still to be implemented @@ -183,7 +187,9 @@ public class QuoteServices { // create Quote Map<String, Object> quoteOut = dispatcher.runSync("createQuote", quoteIn); - + if (ServiceUtil.isError(quoteOut)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(quoteOut)); + } if (UtilValidate.isNotEmpty(quoteOut) && UtilValidate.isNotEmpty(quoteOut.get("quoteId"))) { String quoteId = (String)quoteOut.get("quoteId"); result.put("quoteId", quoteId); @@ -195,7 +201,10 @@ public class QuoteServices { Map<String, Object> quoteItemIn = quoteItem.getAllFields(); quoteItemIn.put("userLogin", userLogin); - dispatcher.runSync("createQuoteItem", quoteItemIn); + serviceResult = dispatcher.runSync("createQuoteItem", quoteItemIn); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } } @@ -206,7 +215,10 @@ public class QuoteServices { Map<String, Object> quoteAttrIn = quoteAttr.getAllFields(); quoteAttrIn.put("userLogin", userLogin); - dispatcher.runSync("createQuoteAttribute", quoteAttrIn); + serviceResult = dispatcher.runSync("createQuoteAttribute", quoteAttrIn); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } } @@ -217,7 +229,10 @@ public class QuoteServices { Map<String, Object> quoteCoefficientIn = quoteCoefficient.getAllFields(); quoteCoefficientIn.put("userLogin", userLogin); - dispatcher.runSync("createQuoteCoefficient", quoteCoefficientIn); + serviceResult = dispatcher.runSync("createQuoteCoefficient", quoteCoefficientIn); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } } @@ -227,8 +242,10 @@ public class QuoteServices { quoteRole.set("quoteId", quoteId); Map<String, Object> quoteRoleIn = quoteRole.getAllFields(); quoteRoleIn.put("userLogin", userLogin); - - dispatcher.runSync("createQuoteRole", quoteRoleIn); + serviceResult = dispatcher.runSync("createQuoteRole", quoteRoleIn); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } } @@ -238,8 +255,10 @@ public class QuoteServices { quoteWorkEffort.set("quoteId", quoteId); Map<String, Object> quoteWorkEffortIn = quoteWorkEffort.getAllFields(); quoteWorkEffortIn.put("userLogin", userLogin); - - dispatcher.runSync("createQuoteWorkEffort", quoteWorkEffortIn); + serviceResult = dispatcher.runSync("createQuoteWorkEffort", quoteWorkEffortIn); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } } @@ -249,8 +268,10 @@ public class QuoteServices { quoteAdjustment.set("quoteId", quoteId); Map<String, Object> quoteAdjustmentIn = quoteAdjustment.getAllFields(); quoteAdjustmentIn.put("userLogin", userLogin); - - dispatcher.runSync("createQuoteAdjustment", quoteAdjustmentIn); + serviceResult = dispatcher.runSync("createQuoteAdjustment", quoteAdjustmentIn); + if (ServiceUtil.isError(serviceResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); + } } } Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java Sun Dec 31 11:11:46 2017 @@ -153,7 +153,7 @@ public class RequirementServices { if (inventory == null) { inventory = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); if (ServiceUtil.isError(inventory)) { - return inventory; + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(inventory)); } inventories.put(inventoryKey, inventory); } @@ -238,12 +238,16 @@ public class RequirementServices { Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "facilityId", facilityId, "productId", product.get("productId"), "quantity", required, "requirementTypeId", "PRODUCT_REQUIREMENT"); Map<String, Object> results = dispatcher.runSync("createRequirement", input); - if (ServiceUtil.isError(results)) return results; + if (ServiceUtil.isError(results)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); + } String requirementId = (String) results.get("requirementId"); input = UtilMisc.toMap("userLogin", userLogin, "orderId", order.get("orderId"), "orderItemSeqId", item.get("orderItemSeqId"), "requirementId", requirementId, "quantity", required); results = dispatcher.runSync("createOrderRequirementCommitment", input); - if (ServiceUtil.isError(results)) return results; + if (ServiceUtil.isError(results)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); + } } } catch (GenericEntityException e) { Debug.logError(e, module); @@ -304,7 +308,9 @@ public class RequirementServices { // get the facility ATP for product, which should be updated for this item's reservation Map<String, Object> results = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("userLogin", userLogin, "productId", product.get("productId"), "facilityId", facilityId)); - if (ServiceUtil.isError(results)) return results; + if (ServiceUtil.isError(results)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); + } BigDecimal atp = ((BigDecimal) results.get("availableToPromiseTotal")); // safe since this is a required OUT param // count all current requirements for this product @@ -328,12 +334,16 @@ public class RequirementServices { Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "facilityId", facilityId, "productId", product.get("productId"), "quantity", required, "requirementTypeId", "PRODUCT_REQUIREMENT"); results = dispatcher.runSync("createRequirement", input); - if (ServiceUtil.isError(results)) return results; + if (ServiceUtil.isError(results)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); + } String requirementId = (String) results.get("requirementId"); input = UtilMisc.toMap("userLogin", userLogin, "orderId", order.get("orderId"), "orderItemSeqId", item.get("orderItemSeqId"), "requirementId", requirementId, "quantity", required); results = dispatcher.runSync("createOrderRequirementCommitment", input); - if (ServiceUtil.isError(results)) return results; + if (ServiceUtil.isError(results)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); + } } } catch (GenericEntityException e) { Debug.logError(e, module); @@ -359,7 +369,10 @@ public class RequirementServices { /* Change status of requirement to ordered */ Map<String, Object> inputMap = UtilMisc.<String, Object>toMap("userLogin", userLogin, "requirementId", requirementId, "statusId", "REQ_ORDERED", "quantity", orderItem.getBigDecimal("quantity")); // TODO: check service result for an error return - dispatcher.runSync("updateRequirement", inputMap); + Map<String, Object> results = dispatcher.runSync("updateRequirement", inputMap); + if (ServiceUtil.isError(results)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); + } } } } catch(GenericEntityException e){ Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java Sun Dec 31 11:11:46 2017 @@ -129,6 +129,9 @@ public class CheckOutEvents { UtilMisc.<String, Object>toMap("partyId", cart.getPartyId(), "taxAuthPartyGeoIds", taxAuthPartyGeoIds, "partyTaxId", partyTaxId, "isExempt", isExempt, "userLogin", userLogin)); ServiceUtil.getMessages(request, createCustomerTaxAuthInfoResult, null); if (ServiceUtil.isError(createCustomerTaxAuthInfoResult)) { + String errorMessage = ServiceUtil.getErrorMessage(createCustomerTaxAuthInfoResult); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); return "error"; } } catch (GenericServiceException e) { @@ -388,6 +391,9 @@ public class CheckOutEvents { UtilMisc.toMap("partyId", cart.getPartyId(), "taxAuthPartyGeoIds", taxAuthPartyGeoIds, "partyTaxId", partyTaxId, "isExempt", isExempt)); ServiceUtil.getMessages(request, createCustomerTaxAuthInfoResult, null); if (ServiceUtil.isError(createCustomerTaxAuthInfoResult)) { + String errorMessage = ServiceUtil.getErrorMessage(createCustomerTaxAuthInfoResult); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); return "error"; } } catch (GenericServiceException e) { |
Free forum by Nabble | Edit this page |