[
https://issues.apache.org/jira/browse/OFBIZ-9981?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16307439#comment-16307439 ]
Jacques Le Roux commented on OFBIZ-9981:
----------------------------------------
BTW the pattern I suggest is used in ContentServices
{code}
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));
}
{code}
Sometimes with a failure variant, I'm not sure why. We really need to discuss and take generic decisions. Then always use them but with a grain of salt, since in some, hopefully rare cases, the patterns will not automatically apply.
{code}
try {
Map<String, Object> thisResults = dispatcher.runSync("traverseContent", traversMap);
if (ServiceUtil.isError(thisResults)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResults));
}
Map<String, Object> nodeMap = UtilGenerics.checkMap(thisResults.get("nodeMap"));
walkParentTree(nodeMap, parentList);
} catch (GenericServiceException e) {
return ServiceUtil.returnFailure(e.getMessage());
}
{code}
> Handle service response effectively
> -----------------------------------
>
> Key: OFBIZ-9981
> URL:
https://issues.apache.org/jira/browse/OFBIZ-9981> Project: OFBiz
> Issue Type: Improvement
> Reporter: Suraj Khurana
> Assignee: Jacques Le Roux
> Attachments: OFBIZ-9981-MAR-SECEXT-WE.patch, OFBIZ-9981-content.patch, OFBIZ-9981-manufacturing.patch, OFBIZ-9981-order.patch, OFBIZ-9981-party.patch, OFBIZ-9981-plugins.patch, OFBIZ-9981-product.patch, OFBIZ-9981.patch
>
>
> [As per discussion on Dev ML|
http://markmail.org/message/dfriai337uxlx5mo]:
> ==========================
> Every service calling from java/groovy must handle errors by service util methods such as isError, reutrnError 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.
> ==========================
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)