Author: jleroux
Date: Sun Dec 31 11:11:46 2017 New Revision: 1819730 URL: http://svn.apache.org/viewvc?rev=1819730&view=rev Log: Improved: Handle service response effectively (OFBIZ-9981) As per discussion on Dev ML: ========================== Every service calling from java/groovy must handle errors by service util methods such as isError, returnError etc. and similarly in case of XML <call-service, there should be <check-error/> to make sure service was executed successfully. Apart from this, one suggestion is to include *Debug.logError* in *ServiceUtil.returnProblem* so that in case of any error occurred and handled, it will always be logged on the console. ========================== jleroux: this is the applications part with some slight changes Thanks: Suraj Khurana Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java ofbiz/ofbiz-framework/trunk/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderLookupServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/PurchaseOrderTest.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyRelationshipServices.java ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/CropImage.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/FrameImage.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ImageManagementServices.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/RotateImage.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentEvents.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServicesTests.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java ofbiz/ofbiz-framework/trunk/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortPartyAssignmentServices.java ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java Sun Dec 31 11:11:46 2017 @@ -43,11 +43,9 @@ import org.apache.ofbiz.entity.util.Enti import org.apache.ofbiz.security.Security; import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; -import org.apache.ofbiz.service.ModelService; +import org.apache.ofbiz.service.ServiceUtil; import org.apache.ofbiz.webapp.website.WebSiteWorker; - - /** * ContentManagementEvents Class */ @@ -63,6 +61,7 @@ public class ContentManagementEvents { Delegator delegator = (Delegator)request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher"); Map<String, Object> paramMap = UtilHttp.getParameterMap(request); + Map<String, Object> result = new HashMap<>(); String parentPlaceholderId = (String)paramMap.get("ph"); if (UtilValidate.isEmpty(parentPlaceholderId)) { request.setAttribute("_ERROR_MESSAGE_", "ParentPlaceholder is empty."); @@ -99,12 +98,24 @@ public class ContentManagementEvents { if (!paramValue.equals(pubValue)) { if ("Y".equalsIgnoreCase(paramValue)) { serviceIn.put("fromDate", UtilDateTime.nowTimestamp()); - dispatcher.runSync("createContentAssoc", serviceIn); + result = dispatcher.runSync("createContentAssoc", serviceIn); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } else if ("N".equalsIgnoreCase(paramValue) && "Y".equalsIgnoreCase(pubValue)) { serviceIn.put("thruDate", UtilDateTime.nowTimestamp()); Timestamp fromDate = (Timestamp)map.get(pubContentId + "FromDate"); serviceIn.put("fromDate", fromDate); - dispatcher.runSync("updateContentAssoc", serviceIn); + result = dispatcher.runSync("updateContentAssoc", serviceIn); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } } } else if (UtilValidate.isNotEmpty(pubValue)) { @@ -112,7 +123,13 @@ public class ContentManagementEvents { serviceIn.put("thruDate", UtilDateTime.nowTimestamp()); Timestamp fromDate = (Timestamp)map.get(pubContentId + "FromDate"); serviceIn.put("fromDate", fromDate); - dispatcher.runSync("updateContentAssoc", serviceIn); + result = dispatcher.runSync("updateContentAssoc", serviceIn); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } } } catch (GenericServiceException e) { @@ -196,10 +213,8 @@ public class ContentManagementEvents { // Loop thru all the possible subsites Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); - String responseMessage = null; - String errorMessage = null; boolean statusIdUpdated = false; - Map<String, Object> results = null; + Map<String, Object> result = new HashMap<>(); for (Object [] arr : origPublishedLinkList) { String contentId = (String)arr[0]; // main (2nd level) site id String origSubContentId = null; @@ -243,13 +258,11 @@ public class ContentManagementEvents { serviceIn.put("targetOperationList", targetOperationList); // TODO check if this should be removed (see above) serviceIn.put("contentPurposeList", contentPurposeList); - results = dispatcher.runSync("createContentAssoc", serviceIn); - responseMessage = (String)results.get(ModelService.RESPONSE_MESSAGE); - if (UtilValidate.isNotEmpty(responseMessage)) { - errorMessage = (String)results.get(ModelService.ERROR_MESSAGE); - Debug.logError("in updatePublishLinks, serviceIn:" + serviceIn , module); - Debug.logError(errorMessage, module); + result = dispatcher.runSync("createContentAssoc", serviceIn); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); return "error"; } @@ -263,7 +276,13 @@ public class ContentManagementEvents { serviceIn.put("targetOperationList", targetOperationList); // TODO check if this should be removed (see above) serviceIn.put("contentPurposeList", contentPurposeList); - results = dispatcher.runSync("createContentAssoc", serviceIn); + result = dispatcher.runSync("createContentAssoc", serviceIn); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } if (!statusIdUpdated) { try { GenericValue targContent = EntityQuery.use(delegator).from("Content").where("contentId", targContentId).queryOne(); Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java Sun Dec 31 11:11:46 2017 @@ -359,9 +359,8 @@ public class ContentManagementServices { Map<String, Object> ctx = contentAssocModel.makeValid(contentAssoc, ModelService.IN_PARAM); contentAssocContext.putAll(ctx); thisResult = dispatcher.runSync("createContentAssoc", contentAssocContext); - String errMsg = ServiceUtil.getErrorMessage(thisResult); - if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult) || UtilValidate.isNotEmpty(errMsg)) { - return ServiceUtil.returnError(errMsg); + if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); } results.put("caContentIdTo", thisResult.get("contentIdTo")); @@ -379,9 +378,8 @@ public class ContentManagementServices { Map<String, Object> ctx = contentAssocModel.makeValid(contentAssocExisting, ModelService.IN_PARAM); contentAssocContext.putAll(ctx); thisResult = dispatcher.runSync("updateContentAssoc", contentAssocContext); - String errMsg = ServiceUtil.getErrorMessage(thisResult); - if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult) || UtilValidate.isNotEmpty(errMsg)) { - return ServiceUtil.returnError(errMsg); + if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); } } } catch (GenericEntityException e) { @@ -455,12 +453,14 @@ public class ContentManagementServices { newContext.put("roleTypeId", serviceContext.get("roleTypeId")); newContext.put("userLogin", userLogin); Map<String, Object> permResults = dispatcher.runSync("deactivateAllContentRoles", newContext); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults)); + } serviceContext.put("fromDate", UtilDateTime.nowTimestamp()); if (Debug.infoOn()) Debug.logInfo("updateSiteRoles, serviceContext(1):" + serviceContext, module); permResults = dispatcher.runSync("createContentRole", serviceContext); - String errMsg = ServiceUtil.getErrorMessage(permResults); - if (UtilValidate.isNotEmpty(errMsg)) { - return ServiceUtil.returnError(errMsg); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults)); } } catch (GenericServiceException e) { Debug.logError(e, e.toString(), module); @@ -481,9 +481,9 @@ public class ContentManagementServices { newContext.put("roleTypeId", serviceContext.get("roleTypeId")); newContext.put("userLogin", userLogin); Map<String, Object> permResults = dispatcher.runSync("deactivateAllContentRoles", newContext); - String errMsg = ServiceUtil.getErrorMessage(permResults); - if (UtilValidate.isNotEmpty(errMsg)) - return ServiceUtil.returnError(errMsg); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults)); + } } catch (GenericServiceException e) { Debug.logError(e, e.toString(), module); return ServiceUtil.returnError(e.toString()); @@ -505,6 +505,9 @@ public class ContentManagementServices { ModelService checkPermModel = dispatcher.getDispatchContext().getModelService("checkContentPermission"); Map<String, Object> ctx = checkPermModel.makeValid(context, ModelService.IN_PARAM); Map<String, Object> thisResult = dispatcher.runSync("checkContentPermission", ctx); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); + } String permissionStatus = (String)thisResult.get("permissionStatus"); if (UtilValidate.isNotEmpty(permissionStatus) && "granted".equalsIgnoreCase(permissionStatus)) { result = persistDataResourceAndDataMethod(dctx, context); @@ -585,9 +588,8 @@ public class ContentManagementServices { if (!dataResourceExists) { // Create Map<String, Object> thisResult = dispatcher.runSync("createDataResource", newDrContext); - String errorMsg = ServiceUtil.getErrorMessage(thisResult); - if (UtilValidate.isNotEmpty(errorMsg)) { - throw(new Exception(errorMsg)); + if (ServiceUtil.isError(thisResult)) { + throw(new Exception(ServiceUtil.getErrorMessage(thisResult))); } dataResourceId = (String)thisResult.get("dataResourceId"); if (Debug.infoOn()) { @@ -601,9 +603,8 @@ public class ContentManagementServices { fileContext.put("dataResourceId", dataResourceId); fileContext.put("imageData", imageDataBytes); thisResult = dispatcher.runSync("createImage", fileContext); - errorMsg = ServiceUtil.getErrorMessage(thisResult); - if (UtilValidate.isNotEmpty(errorMsg)) { - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); } } } else if ("SHORT_TEXT".equals(dataResourceTypeId)) { @@ -617,24 +618,25 @@ public class ContentManagementServices { uploadImage.put("uploadedFile", imageDataBytes); uploadImage.put("_uploadedFile_fileName", (String) context.get("_imageData_fileName")); uploadImage.put("_uploadedFile_contentType", (String) context.get("_imageData_contentType")); - dispatcher.runSync("attachUploadToDataResource", uploadImage); + thisResult = dispatcher.runSync("attachUploadToDataResource", uploadImage); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); + } } else { // assume ELECTRONIC_TEXT if (UtilValidate.isNotEmpty(textData)) { fileContext.put("dataResourceId", dataResourceId); fileContext.put("textData", textData); thisResult = dispatcher.runSync("createElectronicText", fileContext); - errorMsg = ServiceUtil.getErrorMessage(thisResult); - if (UtilValidate.isNotEmpty(errorMsg)) { - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); } } } } else { // Update Map<String, Object> thisResult = dispatcher.runSync("updateDataResource", newDrContext); - String errorMsg = ServiceUtil.getErrorMessage(thisResult); - if (UtilValidate.isNotEmpty(errorMsg)) { - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); } Map<String, Object> fileContext = new HashMap<String, Object>(); fileContext.put("userLogin", userLogin); @@ -644,9 +646,8 @@ public class ContentManagementServices { fileContext.put("dataResourceId", dataResourceId); fileContext.put("imageData", imageDataBytes); thisResult = dispatcher.runSync("updateImage", fileContext); - errorMsg = ServiceUtil.getErrorMessage(thisResult); - if (UtilValidate.isNotEmpty(errorMsg)) { - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); } } } else if ("SHORT_TEXT".equals(dataResourceTypeId)) { @@ -660,15 +661,17 @@ public class ContentManagementServices { uploadImage.put("uploadedFile", imageDataBytes); uploadImage.put("_uploadedFile_fileName", (String) context.get("_imageData_fileName")); uploadImage.put("_uploadedFile_contentType", (String) context.get("_imageData_contentType")); - dispatcher.runSync("attachUploadToDataResource", uploadImage); + thisResult = dispatcher.runSync("attachUploadToDataResource", uploadImage); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); + } } else { if (UtilValidate.isNotEmpty(textData) || "true".equalsIgnoreCase(forceElectronicText)) { fileContext.put("dataResourceId", dataResourceId); fileContext.put("textData", textData); thisResult = dispatcher.runSync("updateElectronicText", fileContext); - errorMsg = ServiceUtil.getErrorMessage(thisResult); - if (UtilValidate.isNotEmpty(errorMsg)) { - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); } } } @@ -680,11 +683,15 @@ public class ContentManagementServices { } public static void addRoleToUser(Delegator delegator, LocalDispatcher dispatcher, Map<String, Object> serviceContext) throws GenericServiceException, GenericEntityException { + Map<String, Object> result = new HashMap<>(); List<GenericValue> userLoginList = EntityQuery.use(delegator).from("UserLogin").where("partyId", serviceContext.get("partyId")).queryList(); for (GenericValue partyUserLogin : userLoginList) { String partyUserLoginId = partyUserLogin.getString("userLoginId"); serviceContext.put("contentId", partyUserLoginId); // author contentId - dispatcher.runSync("createContentRole", serviceContext); + result = dispatcher.runSync("createContentRole", serviceContext); + if (ServiceUtil.isError(result)) { + Debug.logError(ServiceUtil.getErrorMessage(result), module); + } } } @@ -692,6 +699,7 @@ public class ContentManagementServices { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); Map<String, Object> results = new HashMap<String, Object>(); + Map<String, Object> thisResult = new HashMap<String, Object>(); Map<String, Object> serviceContext = new HashMap<String, Object>(); // siteContentId will equal "ADMIN_MASTER", "AGINC_MASTER", etc. // Remember that this service is called in the "multi" mode, @@ -725,7 +733,10 @@ public class ContentManagementServices { Debug.logInfo("updateSiteRoles, serviceContext(1):" + serviceContext, module); } addRoleToUser(delegator, dispatcher, serviceContext); - dispatcher.runSync("createContentRole", serviceContext); + thisResult = dispatcher.runSync("createContentRole", serviceContext); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); + } } catch (GenericServiceException e) { Debug.logError(e, e.toString(), module); } catch (Exception e2) { @@ -742,7 +753,10 @@ public class ContentManagementServices { newContext.put("contentId", serviceContext.get("contentId")); newContext.put("partyId", serviceContext.get("partyId")); newContext.put("roleTypeId", serviceContext.get("roleTypeId")); - dispatcher.runSync("deactivateAllContentRoles", newContext); + thisResult = dispatcher.runSync("deactivateAllContentRoles", newContext); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); + } } catch (GenericServiceException e) { Debug.logError(e, e.toString(), module); } catch (Exception e2) { @@ -892,6 +906,7 @@ public class ContentManagementServices { Map<String, Object> result = new HashMap<String, Object>(); Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); + Map<String, Object> thisResult = new HashMap<String, Object>(); String contentId = (String)context.get("contentId"); GenericValue userLogin = (GenericValue)context.get("userLogin"); String userLoginId = userLogin.getString("userLoginId"); @@ -926,7 +941,10 @@ public class ContentManagementServices { serviceIn.put("contentAssocTypeId", "SUB_CONTENT"); serviceIn.put("sequenceNum", Long.valueOf(50)); try { - dispatcher.runSync("persistContentAndAssoc", serviceIn); + thisResult = dispatcher.runSync("persistContentAndAssoc", serviceIn); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); + } } catch (ServiceAuthException e) { return ServiceUtil.returnError(e.toString()); } @@ -1281,7 +1299,7 @@ public class ContentManagementServices { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); - + Map<String, Object> thisResult = new HashMap<String, Object>(); String partyId = (String) context.get("partyId"); String webPubPt = (String) context.get("contentId"); String roleTypeId = (String) context.get("useRoleTypeId"); @@ -1347,7 +1365,10 @@ public class ContentManagementServices { map.put("partyId", partyId); map.put("roleTypeId", roleTypeId); map.put("userLogin", userLogin); - dispatcher.runSync("ensurePartyRole", map); + thisResult = dispatcher.runSync("ensurePartyRole", map); + if (ServiceUtil.isError(thisResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResult)); + } contentRole.create(); } } catch (GenericEntityException e) { @@ -1402,6 +1423,9 @@ public class ContentManagementServices { ModelService subscriptionModel = dispatcher.getDispatchContext().getModelService("updateContentSubscription"); Map<String, Object> ctx = subscriptionModel.makeValid(context, ModelService.IN_PARAM); result = dispatcher.runSync("updateContentSubscription", ctx); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } return result; } @@ -1447,7 +1471,10 @@ public class ContentManagementServices { context.put("productId", productId); context.put("quantity", Integer.valueOf(qty.intValue())); Map<String, Object> ctx = subscriptionModel.makeValid(context, ModelService.IN_PARAM); - dispatcher.runSync("updateContentSubscriptionByProduct", ctx); + result = dispatcher.runSync("updateContentSubscriptionByProduct", ctx); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } } } catch (GenericEntityException e) { @@ -1510,6 +1537,9 @@ public class ContentManagementServices { GenericValue userLogin = (GenericValue)context.get("userLogin"); result = dispatcher.runSync(serviceName, UtilMisc.toMap("content", content, "userLogin", userLogin)); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } List<GenericValue> kids = ContentWorker.getAssociatedContent(content, "from", contentAssocTypeIdList, null, null, null); for (GenericValue kidContent : kids) { @@ -1545,9 +1575,8 @@ public class ContentManagementServices { ctx.remove("drDataResourceId"); } result = dispatcher.runSync("persistContentAndAssoc", ctx); - String errorMsg = ServiceUtil.getErrorMessage(result); - if (UtilValidate.isNotEmpty(errorMsg)) { - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } String contentId = (String)result.get("contentId"); List<String> parentList = new LinkedList<String>(); @@ -1557,6 +1586,9 @@ public class ContentManagementServices { traversMap.put("direction", "To"); traversMap.put("contentAssocTypeId", "COMPDOC_PART"); Map<String, Object> traversResult = dispatcher.runSync("traverseContent", traversMap); + if (ServiceUtil.isError(traversResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(traversResult)); + } parentList = UtilGenerics.checkList(traversResult.get("parentList")); } else { parentList.add(masterRevisionContentId); @@ -1572,9 +1604,8 @@ public class ContentManagementServices { String thisContentId = parentList.get(i); contentRevisionMap.put("contentId", thisContentId); result = dispatcher.runSync("persistContentRevisionAndItem", contentRevisionMap); - errorMsg = ServiceUtil.getErrorMessage(result); - if (UtilValidate.isNotEmpty(errorMsg)) { - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } } } catch (GenericServiceException e) { Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java Sun Dec 31 11:11:46 2017 @@ -70,6 +70,7 @@ In order to make this service active add Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); String file = (String) context.get("file"); + Map<String, Object> result = new HashMap<String, Object>(); String errMsg = "", sucMsg= ""; GenericValue Entity = null; if (UtilValidate.isNotEmpty(file)) { @@ -77,8 +78,6 @@ In order to make this service active add String line = null; int size = 0; int counterLine = 0; - //Home Document - Entity = null; Entity = delegator.makeValue("Content"); Entity.set("contentId", "ROOT"); Entity.set("contentName", "ROOT"); @@ -92,7 +91,6 @@ In order to make this service active add Entity.set("createdTxStamp", UtilDateTime.nowTimestamp()); delegator.create(Entity); - Entity = null; Entity = delegator.makeValue("Content"); Entity.set("contentId", "HOME_DOCUMENT"); Entity.set("contentName", "Home"); @@ -111,7 +109,10 @@ In order to make this service active add contentAssoc.put("contentAssocTypeId", "TREE_CHILD"); contentAssoc.put("contentIdTo", "ROOT"); contentAssoc.put("userLogin", userLogin); - dispatcher.runSync("createContentAssoc", contentAssoc); + result = dispatcher.runSync("createContentAssoc", contentAssoc); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } while ((line = input.readLine()) != null) {//start line boolean hasFolder = true; String rootContent = null, contentId = null; counterLine++; @@ -162,7 +163,6 @@ In order to make this service active add } if (contentAssocSize == 0 && contentNameMatch == false) {//New Root Content - Entity = null; contentId = delegator.getNextSeqId("Content"); Entity = delegator.makeValue("Content"); Entity.set("contentId", contentId); @@ -192,7 +192,10 @@ In order to make this service active add contentAssoc.put("contentAssocTypeId", "TREE_CHILD"); contentAssoc.put("contentIdTo", rootContent); contentAssoc.put("userLogin", userLogin); - dispatcher.runSync("createContentAssoc", contentAssoc); + result = dispatcher.runSync("createContentAssoc", contentAssoc); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } rootContent = contentId; } else { //Debug.logInfo("ContentAssoc [contentId= " + contentId + ", contentIdTo=" + rootContent + "] already exist.");//ShoW log file @@ -230,6 +233,7 @@ In order to make this service active add Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); + Map<String, Object> result = new HashMap<String, Object>(); String subContents = null, check = ",", oldChar = "\"", newChar = "", contentNameInprogress = "", contentName = "", contentId = null; GenericValue Entity = null; String errMsg = "", sucMsg= ""; @@ -259,16 +263,17 @@ In order to make this service active add } } } - contentId = null; if (contentNameMatch == false) { //create DataResource Map<String,Object> data = new HashMap<String, Object>(); data.put("userLogin", userLogin); - String dataResourceId = dispatcher.runSync("createDataResource", data).get("dataResourceId").toString(); - + result = dispatcher.runSync("createDataResource", data); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } + String dataResourceId = (String) result.get("dataResourceId"); //create Content contentId = delegator.getNextSeqId("Content"); - Entity = null; Entity = delegator.makeValue("Content"); Entity.set("contentId", contentId); Entity.set("contentName", contentName); @@ -289,7 +294,10 @@ In order to make this service active add contentAssoc.put("contentAssocTypeId", "SUB_CONTENT"); contentAssoc.put("contentIdTo", rootContent); contentAssoc.put("userLogin", userLogin); - dispatcher.runSync("createContentAssoc", contentAssoc); + result = dispatcher.runSync("createContentAssoc", contentAssoc); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } contentName =""; contentNameInprogress=""; @@ -320,16 +328,17 @@ In order to make this service active add } } } - contentId = null; if (contentNameMatch == false) { //create DataResource Map<String,Object> data = new HashMap<String, Object>(); data.put("userLogin", userLogin); - String dataResourceId = dispatcher.runSync("createDataResource",data).get("dataResourceId").toString(); - + result = dispatcher.runSync("createDataResource", data); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } + String dataResourceId = (String) result.get("dataResourceId"); //create Content contentId = delegator.getNextSeqId("Content"); - Entity = null; Entity = delegator.makeValue("Content"); Entity.set("contentId", contentId); Entity.set("contentName", contentName); @@ -350,7 +359,10 @@ In order to make this service active add contentAssoc.put("contentAssocTypeId", "SUB_CONTENT"); contentAssoc.put("contentIdTo", rootContent); contentAssoc.put("userLogin", userLogin); - dispatcher.runSync("createContentAssoc", contentAssoc); + result = dispatcher.runSync("createContentAssoc", contentAssoc); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } } } Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java Sun Dec 31 11:11:46 2017 @@ -101,6 +101,12 @@ public class CompDocEvents { persistMap.put("userLogin", userLogin); try { Map<String, Object> persistResult = dispatcher.runSync("persistContentAndAssoc", persistMap); + if (ServiceUtil.isError(persistResult)) { + String errMsg = "Error running serviceName, 'persistContentAndAssoc'. " + ServiceUtil.getErrorMessage(persistResult); + request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "</li>"); + Debug.logError(errMsg, module); + return "error"; + } contentId = (String)persistResult.get("contentId"); //request.setAttribute("contentId", contentId); for (Entry<String, Object> entry : persistResult.entrySet()) { @@ -114,19 +120,17 @@ public class CompDocEvents { contentRevisionMap.put("contentId", contentId); contentRevisionMap.put("userLogin", userLogin); Map<String, Object> result = dispatcher.runSync("persistContentRevisionAndItem", contentRevisionMap); + if (ServiceUtil.isError(result)) { + String errMsg = "Error running serviceName, 'persistContentRevisionAndItem'. " + ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "</li>"); + Debug.logError(errMsg, module); + return "error"; + } for (Entry<String, Object> entry : result.entrySet()) { Object obj = entry.getValue(); Object val = result.get(obj); request.setAttribute(obj.toString(), val); } - String errorMsg = ServiceUtil.getErrorMessage(result); - if (UtilValidate.isNotEmpty(errorMsg)) { - String errMsg = "Error running serviceName, 'persistContentRevisionAndItem'. " + errorMsg; - Debug.logError(errMsg, module); - request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "</li>"); - return "error"; - } - } catch (GenericServiceException e) { String errMsg = "Error running serviceName, 'persistContentAndAssoc'. " + e.toString(); Debug.logError(errMsg, module); @@ -166,6 +170,12 @@ public class CompDocEvents { Map<String, Object> results = null; try { results = dispatcher.runSync("renderCompDocPdf", mapIn); + if (ServiceUtil.isError(results)) { + String errorMessage = ServiceUtil.getErrorMessage(results); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (ServiceAuthException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; @@ -177,11 +187,6 @@ public class CompDocEvents { return "error"; } - if (ServiceUtil.isError(results)) { - request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(results)); - return "error"; - } - ByteBuffer outByteBuffer = (ByteBuffer) results.get("outByteBuffer"); // setup content type @@ -222,6 +227,12 @@ public class CompDocEvents { Map<String, Object> results = null; try { results = dispatcher.runSync("renderContentPdf", mapIn); + if (ServiceUtil.isError(results)) { + String errorMessage = ServiceUtil.getErrorMessage(results); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (ServiceAuthException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; @@ -233,11 +244,6 @@ public class CompDocEvents { return "error"; } - if (ServiceUtil.isError(results)) { - request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(results)); - return "error"; - } - ByteBuffer outByteBuffer = (ByteBuffer) results.get("outByteBuffer"); // setup content type Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java Sun Dec 31 11:11:46 2017 @@ -291,6 +291,9 @@ public class ContentPermissionServices { try { permResults = dispatcher.runSync("checkContentPermission", serviceInMap); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); } @@ -307,6 +310,9 @@ public class ContentPermissionServices { serviceInMap.put("contentPurposeList", relatedPurposes); try { permResults = dispatcher.runSync("checkContentPermission", serviceInMap); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); } Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java Sun Dec 31 11:11:46 2017 @@ -105,6 +105,9 @@ public class ContentServices { serviceInMap.put("currentContent", content); try { permResults = dispatcher.runSync("checkContentPermission", serviceInMap); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPermissionNotGranted", locale)); @@ -140,10 +143,8 @@ public class ContentServices { traversMap.put("contentAssocTypeId", contentAssocTypeId); try { Map<String, Object> thisResults = dispatcher.runSync("traverseContent", traversMap); - String errorMsg = ServiceUtil.getErrorMessage(thisResults); - if (UtilValidate.isNotEmpty(errorMsg)) { - Debug.logError("Problem in traverseContent. " + errorMsg, module); - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(thisResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResults)); } Map<String, Object> nodeMap = UtilGenerics.checkMap(thisResults.get("nodeMap")); walkParentTree(nodeMap, parentList); @@ -442,14 +443,13 @@ public class ContentServices { Map<String, Object> permResults = null; permResults = dispatcher.runSync("checkAssocPermission", serviceInMap); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnFailure(ServiceUtil.getErrorMessage(permResults)); + } permissionStatus = (String) permResults.get("permissionStatus"); if (permissionStatus != null && "granted".equals(permissionStatus)) { contentAssoc.create(); - } else { - String errorMsg = (String)permResults.get(ModelService.ERROR_MESSAGE); - result.put(ModelService.ERROR_MESSAGE, errorMsg); - return ServiceUtil.returnFailure(errorMsg); } result.put("contentIdTo", contentIdTo); @@ -518,7 +518,10 @@ public class ContentServices { if (UtilValidate.isNotEmpty(context.get("statusId"))) { Map<String, Object> statusInMap = UtilMisc.<String, Object>toMap("contentId", context.get("contentId"), "statusId", context.get("statusId"), "userLogin", userLogin); try { - dispatcher.runSync("setContentStatus", statusInMap); + result = dispatcher.runSync("setContentStatus", statusInMap); + if (ServiceUtil.isError(result)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem updating content Status", "ContentServices"); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentStatusUpdateError", UtilMisc.toMap("errorString", e), locale)); @@ -635,6 +638,9 @@ public class ContentServices { Map<String, Object> permResults = null; try { permResults = dispatcher.runSync("checkAssocPermission", serviceInMap); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPermissionNotGranted", locale)); @@ -726,6 +732,9 @@ public class ContentServices { Map<String, Object> permResults = null; try { permResults = dispatcher.runSync("checkAssocPermission", serviceInMap); + if (ServiceUtil.isError(permResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(permResults)); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPermissionNotGranted", locale)); @@ -958,19 +967,14 @@ public class ContentServices { // Only deactive if currently published if (isPublished) { Map<String, Object> thisResults = dispatcher.runSync("deactivateAssocs", mapIn); - String errorMsg = ServiceUtil.getErrorMessage(thisResults); - if (UtilValidate.isNotEmpty(errorMsg)) { - Debug.logError("Problem running deactivateAssocs. " + errorMsg, "ContentServices"); - return ServiceUtil.returnError(errorMsg); + if (ServiceUtil.isError(thisResults)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResults)); } } } - } catch (GenericEntityException e) { + } catch (GenericEntityException | GenericServiceException e) { Debug.logError(e, "Problem getting existing content", "ContentServices"); return ServiceUtil.returnError(e.getMessage()); - } catch (GenericServiceException e) { - Debug.logError(e, "Problem running deactivateAssocs", "ContentServices"); - return ServiceUtil.returnError(e.getMessage()); } return results; Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java Sun Dec 31 11:11:46 2017 @@ -207,15 +207,16 @@ public class ContentWorker implements or Map<String,Object> serviceRes; try { serviceRes = dispatcher.runSync(serviceName, serviceCtx); + if (ServiceUtil.isError(serviceRes)) { + String errorMessage = ServiceUtil.getErrorMessage(serviceRes); + Debug.logError(errorMessage, module); + throw new GeneralException(errorMessage); + } } catch (GenericServiceException e) { Debug.logError(e, module); throw e; } - if (ServiceUtil.isError(serviceRes)) { - throw new GeneralException(ServiceUtil.getErrorMessage(serviceRes)); - } else { - templateContext.putAll(serviceRes); - } + templateContext.putAll(serviceRes); } } @@ -1058,6 +1059,9 @@ public class ContentWorker implements or try { permResults = dispatcher.runSync("checkContentPermission", serviceInMap); + if (ServiceUtil.isError(permResults)) { + Debug.logError(ServiceUtil.getErrorMessage(permResults) + "Problem checking permissions", "ContentServices"); + } } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); } Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java Sun Dec 31 11:11:46 2017 @@ -144,9 +144,10 @@ public class UploadContentAndImage { String contentAssocTypeId = (String)passedParams.get("contentAssocTypeId"); ftlContext.put("contentAssocTypeId", null); // Don't post assoc at this time Map<String, Object> ftlResults = dispatcher.runSync("persistContentAndAssoc", ftlContext); - boolean isError = ModelService.RESPOND_ERROR.equals(ftlResults.get(ModelService.RESPONSE_MESSAGE)); - if (isError) { - request.setAttribute("_ERROR_MESSAGE_", ftlResults.get(ModelService.ERROR_MESSAGE)); + if (ServiceUtil.isError(ftlResults)) { + String errorMessage = ServiceUtil.getErrorMessage(ftlResults); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); TransactionUtil.rollback(); return "error"; } @@ -176,9 +177,10 @@ public class UploadContentAndImage { } if (UtilValidate.isNotEmpty(map.get("contentAssocTypeId"))) { ftlResults = dispatcher.runSync("createContentAssoc", map); - isError = ModelService.RESPOND_ERROR.equals(ftlResults.get(ModelService.RESPONSE_MESSAGE)); - if (isError) { - request.setAttribute("_ERROR_MESSAGE_", ftlResults.get(ModelService.ERROR_MESSAGE)); + if (ServiceUtil.isError(ftlResults)) { + String errorMessage = ServiceUtil.getErrorMessage(ftlResults); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); TransactionUtil.rollback(); return "error"; } @@ -213,9 +215,10 @@ public class UploadContentAndImage { sumContext.put("mapKey", "SUMMARY"); sumContext.put("dataTemplateTypeId", "NONE"); Map<String, Object> sumResults = dispatcher.runSync("persistContentAndAssoc", sumContext); - isError = ModelService.RESPOND_ERROR.equals(sumResults.get(ModelService.RESPONSE_MESSAGE)); - if (isError) { - request.setAttribute("_ERROR_MESSAGE_", sumResults.get(ModelService.ERROR_MESSAGE)); + if (ServiceUtil.isError(ftlResults)) { + String errorMessage = ServiceUtil.getErrorMessage(ftlResults); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); TransactionUtil.rollback(); return "error"; } @@ -242,9 +245,10 @@ public class UploadContentAndImage { txtContext.put("mapKey", "ARTICLE"); txtContext.put("dataTemplateTypeId", "NONE"); Map<String, Object> txtResults = dispatcher.runSync("persistContentAndAssoc", txtContext); - isError = ModelService.RESPOND_ERROR.equals(txtResults.get(ModelService.RESPONSE_MESSAGE)); - if (isError) { - request.setAttribute("_ERROR_MESSAGE_", txtResults.get(ModelService.ERROR_MESSAGE)); + if (ServiceUtil.isError(ftlResults)) { + String errorMessage = ServiceUtil.getErrorMessage(ftlResults); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); TransactionUtil.rollback(); return "error"; } @@ -274,9 +278,10 @@ public class UploadContentAndImage { imgContext.put("rootDir", "rootDir"); if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]imgContext " + imgContext, module); Map<String, Object> imgResults = dispatcher.runSync("persistContentAndAssoc", imgContext); - isError = ModelService.RESPOND_ERROR.equals(imgResults.get(ModelService.RESPONSE_MESSAGE)); - if (isError) { - request.setAttribute("_ERROR_MESSAGE_", imgResults.get(ModelService.ERROR_MESSAGE)); + if (ServiceUtil.isError(ftlResults)) { + String errorMessage = ServiceUtil.getErrorMessage(ftlResults); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); TransactionUtil.rollback(); return "error"; } @@ -511,8 +516,8 @@ public class UploadContentAndImage { errorMsgList.add(msg); return "error"; } - String msg = ServiceUtil.getErrorMessage(ftlResults); - if (UtilValidate.isNotEmpty(msg)) { + if (ServiceUtil.isError(ftlResults)) { + String msg = ServiceUtil.getErrorMessage(ftlResults); request.setAttribute("_ERROR_MESSAGE_", msg); List<String> errorMsgList = UtilGenerics.checkList(request.getAttribute("_EVENT_MESSAGE_LIST_")); if (errorMsgList == null) { @@ -541,8 +546,14 @@ public class UploadContentAndImage { resequenceContext.put("userLogin", userLogin); try { ftlResults = dispatcher.runSync("resequence", resequenceContext); + if (ServiceUtil.isError(ftlResults)) { + String errorMessage = ServiceUtil.getErrorMessage(ftlResults); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (ServiceAuthException e) { - msg = e.getMessage(); + String msg = e.getMessage(); request.setAttribute("_ERROR_MESSAGE_", msg); List<String> errorMsgList = UtilGenerics.checkList(request.getAttribute("_EVENT_MESSAGE_LIST_")); if (Debug.infoOn()) { Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java Sun Dec 31 11:11:46 2017 @@ -312,29 +312,33 @@ public class DataEvents { String mode = (String)paramMap.get("mode"); Locale locale = UtilHttp.getLocale(request); - if (mode != null && "UPDATE".equals(mode)) { - try { + try { + if (mode != null && "UPDATE".equals(mode)) { result = dispatcher.runSync("updateDataResource", serviceInMap); - } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(DataEvents.err_resource, "dataEvents.error_call_update_service", locale); - String errorMsg = "Error calling the updateDataResource service." + e.toString(); - Debug.logError(e, errorMsg, module); - request.setAttribute("_ERROR_MESSAGE_", errMsg + e.toString()); - return "error"; - } - } else { - mode = "CREATE"; - try { + if (ServiceUtil.isError(result)) { + String errMsg = UtilProperties.getMessage(DataEvents.err_resource, "dataEvents.error_call_update_service", locale); + String errorMsg = ServiceUtil.getErrorMessage(result); + Debug.logError(errorMsg, module); + request.setAttribute("_ERROR_MESSAGE_", errMsg); + return "error"; + } + } else { + mode = "CREATE"; result = dispatcher.runSync("createDataResource", serviceInMap); - } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(DataEvents.err_resource, "dataEvents.error_call_create_service", locale); - String errorMsg = "Error calling the createDataResource service." + e.toString(); - Debug.logError(e, errorMsg, module); - request.setAttribute("_ERROR_MESSAGE_", errMsg + e.toString()); - return "error"; + if (ServiceUtil.isError(result)) { + String errMsg = UtilProperties.getMessage(DataEvents.err_resource, "dataEvents.error_call_create_service", locale); + String errorMsg = ServiceUtil.getErrorMessage(result); + Debug.logError(errorMsg, module); + request.setAttribute("_ERROR_MESSAGE_", errMsg); + return "error"; + } + dataResourceId = (String)result.get("dataResourceId"); + dataResource.set("dataResourceId", dataResourceId); } - dataResourceId = (String)result.get("dataResourceId"); - dataResource.set("dataResourceId", dataResourceId); + } catch (GenericServiceException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.toString()); + return "error"; } String returnStr = "success"; Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java Sun Dec 31 11:11:46 2017 @@ -79,6 +79,7 @@ import org.apache.ofbiz.entity.util.Enti import org.apache.ofbiz.entity.util.EntityUtilProperties; import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ServiceUtil; import org.apache.ofbiz.widget.model.FormFactory; import org.apache.ofbiz.widget.model.ModelForm; import org.apache.ofbiz.widget.model.ModelScreen; @@ -335,6 +336,9 @@ public class DataResourceWorker impleme } try { permResults = dispatcher.runSync("checkContentPermission", serviceInMap); + if (ServiceUtil.isError(permResults)) { + return permResults; + } } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); } Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java Sun Dec 31 11:11:46 2017 @@ -49,6 +49,7 @@ import org.apache.ofbiz.minilang.SimpleM import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ModelService; +import org.apache.ofbiz.service.ServiceUtil; /** * LayoutEvents Class @@ -111,6 +112,12 @@ public class LayoutEvents { } Map<String, Object> result = dispatcher.runSync("persistContentAndAssoc", context); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } String dataResourceId = (String) result.get("dataResourceId"); String activeContentId = (String) result.get("contentId"); @@ -126,8 +133,14 @@ public class LayoutEvents { context2.put("contentIdTo", formInput.get("contentIdTo")); context2.put("mapKey", formInput.get("mapKey")); - - dispatcher.runSync("deactivateAssocs", context2); + Map<String, Object> serviceResult = new HashMap<String, Object>(); + serviceResult = dispatcher.runSync("deactivateAssocs", context2); + if (ServiceUtil.isError(serviceResult)) { + String errorMessage = ServiceUtil.getErrorMessage(serviceResult); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne(); @@ -247,6 +260,12 @@ public class LayoutEvents { try { Map<String, Object> result = dispatcher.runSync("persistContentAndAssoc", context); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } request.setAttribute("contentId", contentIdTo); Map<String, Object> context2 = new HashMap<String, Object>(); context2.put("activeContentId", contentId); @@ -258,8 +277,14 @@ public class LayoutEvents { context2.put("contentIdTo", contentIdTo); context2.put("mapKey", mapKey); - - dispatcher.runSync("deactivateAssocs", context2); + Map<String, Object> serviceResult = new HashMap<String, Object>(); + serviceResult = dispatcher.runSync("deactivateAssocs", context2); + if (ServiceUtil.isError(serviceResult)) { + String errorMessage = ServiceUtil.getErrorMessage(serviceResult); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (GenericServiceException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -348,6 +373,12 @@ public class LayoutEvents { serviceIn.put("assocTypes", UtilMisc.toList("SUB_CONTENT")); try { results = dispatcher.runSync("getAssocAndContentAndDataResource", serviceIn); + if (ServiceUtil.isError(results)) { + String errorMessage = ServiceUtil.getErrorMessage(results); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } entityList = UtilGenerics.checkList(results.get("entityList")); if (UtilValidate.isEmpty(entityList)) { String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.no_subcontent", locale); @@ -390,6 +421,12 @@ public class LayoutEvents { serviceIn.put("thruDate", null); try { results = dispatcher.runSync("persistContentAndAssoc", serviceIn); + if (ServiceUtil.isError(results)) { + String errorMessage = ServiceUtil.getErrorMessage(results); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (GenericServiceException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -452,9 +489,10 @@ public class LayoutEvents { Debug.logVerbose("in createSubContent, context:" + context, module); } Map<String, Object> result = dispatcher.runSync("persistContentAndAssoc", context); - boolean isError = ModelService.RESPOND_ERROR.equals(result.get(ModelService.RESPONSE_MESSAGE)); - if (isError) { - request.setAttribute("_ERROR_MESSAGE_", result.get(ModelService.ERROR_MESSAGE)); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); return "error"; } @@ -473,8 +511,14 @@ public class LayoutEvents { context2.put("contentIdTo", contentIdTo); context2.put("mapKey", mapKey); context2.put("userLogin", userLogin); - - dispatcher.runSync("deactivateAssocs", context2); + Map<String, Object> serviceResult = new HashMap<String, Object>(); + serviceResult = dispatcher.runSync("deactivateAssocs", context2); + if (ServiceUtil.isError(serviceResult)) { + String errorMessage = ServiceUtil.getErrorMessage(serviceResult); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } catch (GenericServiceException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -517,9 +561,10 @@ public class LayoutEvents { context.put("textData", paramMap.get("textData")); context.put("contentAssocTypeId", null); Map<String, Object> result = dispatcher.runSync("persistContentAndAssoc", context); - boolean isError = ModelService.RESPOND_ERROR.equals(result.get(ModelService.RESPONSE_MESSAGE)); - if (isError) { - request.setAttribute("_ERROR_MESSAGE_", result.get(ModelService.ERROR_MESSAGE)); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); return "error"; } String contentId = (String) result.get("contentId"); Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java Sun Dec 31 11:11:46 2017 @@ -106,6 +106,9 @@ public class PdfSurveyServices { // create a SurveyQuestionCategory to put the questions in Map<String, Object> createCategoryResultMap = dispatcher.runSync("createSurveyQuestionCategory", UtilMisc.<String, Object>toMap("description", "From AcroForm in Content [" + contentId + "] for Survey [" + surveyId + "]", "userLogin", userLogin)); + if (ServiceUtil.isError(createCategoryResultMap)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(createCategoryResultMap)); + } String surveyQuestionCategoryId = (String) createCategoryResultMap.get("surveyQuestionCategoryId"); pdfStamper.setFormFlattening(true); @@ -516,7 +519,7 @@ public class PdfSurveyServices { ctx.put("contentId", acroFormContentId); Map<String, Object> map = dispatcher.runSync("setAcroFields", ctx); if (ServiceUtil.isError(map)) { - return ServiceUtil.returnError(ServiceUtil.makeErrorMessage(map, null, null, null, null)); + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(map)); } String pdfFileNameOut = (String) context.get("pdfFileNameOut"); ByteBuffer outByteBuffer = (ByteBuffer) map.get("outByteBuffer"); Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java?rev=1819730&r1=1819729&r2=1819730&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java Sun Dec 31 11:11:46 2017 @@ -21,6 +21,7 @@ package org.apache.ofbiz.manufacturing.b import java.util.Date; import java.util.List; +import java.util.Map; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilMisc; @@ -31,6 +32,7 @@ import org.apache.ofbiz.entity.GenericVa import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ServiceUtil; /** Helper class containing static method useful when dealing * with product's bills of materials. @@ -150,7 +152,15 @@ public final class BOMHelper { Debug.logError("Production Run for order item (" + orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") + ") not created.", module); continue; } - dispatcher.runSync("createProductionRunsForOrder", UtilMisc.<String, Object>toMap("quantity", shipmentPlan.getBigDecimal("quantity"), "orderId", shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"), "shipGroupSeqId", shipmentPlan.getString("shipGroupSeqId"), "shipmentId", shipmentId, "userLogin", userLogin)); + Map<String, Object> result = dispatcher.runSync("createProductionRunsForOrder", UtilMisc.<String, Object>toMap("quantity", shipmentPlan.getBigDecimal("quantity"), "orderId", + shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"), "shipGroupSeqId", shipmentPlan.getString("shipGroupSeqId"), "shipmentId", + shipmentId, "userLogin", userLogin)); + if (ServiceUtil.isError(result)) { + String errorMessage = ServiceUtil.getErrorMessage(result); + request.setAttribute("_ERROR_MESSAGE_", errorMessage); + Debug.logError(errorMessage, module); + return "error"; + } } } catch (GenericEntityException|GenericServiceException ge) { Debug.logWarning(ge, module); |
Free forum by Nabble | Edit this page |