Improved error response handling.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@555723 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -37,7 +37,7 @@ under the License.
|
||||
</eca>-->
|
||||
|
||||
<eca service="receiveConfirmBod" event="commit" run-on-error="true">
|
||||
<condition field-name="description" operator="is-not-empty"/>
|
||||
<condition field-name="errorMapList" operator="is-not-empty"/>
|
||||
<action service="createOagisMessageErrorInfo" mode="sync"/>
|
||||
<action service="oagisSendConfirmBod" mode="sync"/>
|
||||
</eca>
|
||||
@@ -51,25 +51,25 @@ under the License.
|
||||
</eca>-->
|
||||
|
||||
<eca service="showShipment" event="commit" run-on-error="true">
|
||||
<condition field-name="description" operator="is-not-empty"/>
|
||||
<condition field-name="errorMapList" operator="is-not-empty"/>
|
||||
<action service="createOagisMessageErrorInfo" mode="sync"/>
|
||||
<action service="oagisSendConfirmBod" mode="sync"/>
|
||||
</eca>
|
||||
|
||||
<eca service="syncInventory" event="commit" run-on-error="true">
|
||||
<condition field-name="description" operator="is-not-empty"/>
|
||||
<condition field-name="errorMapList" operator="is-not-empty"/>
|
||||
<action service="createOagisMessageErrorInfo" mode="sync"/>
|
||||
<action service="oagisSendConfirmBod" mode="sync"/>
|
||||
</eca>
|
||||
|
||||
<eca service="receivePoAcknowledge" event="commit" run-on-error="true">
|
||||
<condition field-name="description" operator="is-not-empty"/>
|
||||
<condition field-name="errorMapList" operator="is-not-empty"/>
|
||||
<action service="createOagisMessageErrorInfo" mode="sync"/>
|
||||
<action service="oagisSendConfirmBod" mode="sync"/>
|
||||
</eca>
|
||||
|
||||
<eca service="receiveRmaAcknowledge" event="commit" run-on-error="true">
|
||||
<condition field-name="description" operator="is-not-empty"/>
|
||||
<condition field-name="errorMapList" operator="is-not-empty"/>
|
||||
<action service="createOagisMessageErrorInfo" mode="sync"/>
|
||||
<action service="oagisSendConfirmBod" mode="sync"/>
|
||||
</eca>
|
||||
|
||||
@@ -42,8 +42,7 @@ under the License.
|
||||
|
||||
<service name="oagisMessageErrorInfoInterface" engine="interface">
|
||||
<implements service="oagisMessageInfoInterface"/>
|
||||
<attribute name="description" type="String" mode="OUT" optional="true"/>
|
||||
<attribute name="reasonCode" type="String" mode="OUT" optional="true"/>
|
||||
<attribute name="errorMapList" type="java.util.List" mode="OUT" optional="true"/>
|
||||
</service>
|
||||
|
||||
<service name="createOagisMessageInfo" engine="simple" default-entity-name="OagisMessageInfo"
|
||||
@@ -92,8 +91,7 @@ under the License.
|
||||
<attribute name="component" type="String" mode="IN" optional="false"/>
|
||||
<attribute name="task" type="String" mode="IN" optional="false"/>
|
||||
<attribute name="referenceId" type="String" mode="IN" optional="false"/>
|
||||
<attribute name="description" type="String" mode="IN" optional="true"/>
|
||||
<attribute name="reasonCode" type="String" mode="IN" optional="true"/>
|
||||
<attribute name="errorMapList" type="java.util.List" mode="IN" optional="true"/>
|
||||
<attribute name="origRefId" type="String" mode="IN" optional="true"/>
|
||||
</service>
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -105,8 +106,9 @@ public class OagisServices {
|
||||
bodyParameters.put("errorComponent", context.get("component"));
|
||||
bodyParameters.put("errorTask", context.get("task"));
|
||||
bodyParameters.put("errorReferenceId", context.get("referenceId"));
|
||||
bodyParameters.put("errorDescription", context.get("description"));
|
||||
bodyParameters.put("errorReasonCode", context.get("reasonCode"));
|
||||
//bodyParameters.put("errorDescription", context.get("description"));
|
||||
//bodyParameters.put("errorReasonCode", context.get("reasonCode"));
|
||||
bodyParameters.put("errorMapList",(List) context.get("errorMapList"));
|
||||
bodyParameters.put("origRef", context.get("origRefId"));
|
||||
String bodyScreenUri = UtilProperties.getPropertyValue("oagis.properties", "Oagis.Template.ConfirmBod");
|
||||
|
||||
@@ -199,13 +201,13 @@ public class OagisServices {
|
||||
GenericDelegator delegator = ctx.getDelegator();
|
||||
LocalDispatcher dispatcher = ctx.getDispatcher();
|
||||
InputStream in = (InputStream) context.get("inputStream");
|
||||
FastList errorList = FastList.newInstance();
|
||||
List errorMapList = FastList.newInstance();
|
||||
|
||||
GenericValue userLogin = null;
|
||||
try {
|
||||
userLogin = delegator.findByPrimaryKey("UserLogin",UtilMisc.toMap("userLoginId","admin"));
|
||||
} catch (GenericEntityException e){
|
||||
String errMsg = "Error Getting UserLogin with userLoginId 'admin'";
|
||||
String errMsg = "Error Getting UserLogin with userLoginId 'admin':"+e.toString();
|
||||
Debug.logError(e, errMsg, module);
|
||||
}
|
||||
|
||||
@@ -213,16 +215,16 @@ public class OagisServices {
|
||||
try {
|
||||
doc = UtilXml.readXmlDocument(in, true, "RecieveConfirmBod");
|
||||
} catch (SAXException e) {
|
||||
String errMsg = "Error parsing the ConfirmBodResponse";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error parsing the ConfirmBodResponse: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "SAXException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
} catch (ParserConfigurationException e) {
|
||||
String errMsg = "Error parsing the ConfirmBodResponse";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error parsing the ConfirmBodResponse: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "ParserConfigurationException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
} catch (IOException e) {
|
||||
String errMsg = "Error parsing the ConfirmBodResponse";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error parsing the ConfirmBodResponse: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "IOException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
}
|
||||
|
||||
@@ -278,13 +280,13 @@ public class OagisServices {
|
||||
try {
|
||||
Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoCtx);
|
||||
if (ServiceUtil.isError(oagisMsgInfoResult)){
|
||||
String errMsg = "Error creating OagisMessageInfo for the Incoming Message";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error creating OagisMessageInfo for the Incoming Message: "+ServiceUtil.getErrorMessage(oagisMsgInfoResult);
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "CreateOagisMessageInfoServiceError"));
|
||||
Debug.logError(errMsg, module);
|
||||
}
|
||||
} catch (GenericServiceException e){
|
||||
String errMsg = "Error creating OagisMessageInfo for the Incoming Message";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error creating OagisMessageInfo for the Incoming Message: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
}
|
||||
|
||||
@@ -298,8 +300,8 @@ public class OagisServices {
|
||||
try {
|
||||
oagisMsgInfo = delegator.findByPrimaryKey("OagisMessageInfo", oagisMsgErrorCtx);
|
||||
} catch (GenericEntityException e){
|
||||
String errMsg = "Error Getting Entity OagisMessageInfo";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error Getting Entity OagisMessageInfo: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericEntityException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
}
|
||||
|
||||
@@ -310,29 +312,28 @@ public class OagisServices {
|
||||
try {
|
||||
Map oagisMsgErrorInfoResult = dispatcher.runSync("createOagisMessageErrorInfo", oagisMsgErrorCtx);
|
||||
if (ServiceUtil.isError(oagisMsgErrorInfoResult)){
|
||||
String errMsg = "Error creating OagisMessageErrorInfo";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error creating OagisMessageErrorInfo: "+ServiceUtil.getErrorMessage(oagisMsgErrorInfoResult);
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "CreateOagisMessageErrorInfoServiceError"));
|
||||
Debug.logError(errMsg, module);
|
||||
}
|
||||
} catch (GenericServiceException e){
|
||||
String errMsg = "Error creating OagisMessageErrorInfo";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error creating OagisMessageErrorInfo: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
}
|
||||
} else{
|
||||
String errMsg = "No such message with an error was found in OagisMessageInfoEntity ; Not creating OagisMessageErrorInfo";
|
||||
String errMsg = "No such message with an error was found in OagisMessageInfo Entity ; Not creating OagisMessageErrorInfo";
|
||||
Debug.logWarning(errMsg, module);
|
||||
errorList.add(errMsg);
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "OagisMessageInfoNotFoundError"));
|
||||
}
|
||||
|
||||
Map result = new HashMap();
|
||||
result.put("contentType", "text/plain");
|
||||
|
||||
if (errorList.size()>0){
|
||||
if (errorMapList.size()>0){
|
||||
result.putAll(oagisMsgInfoCtx);
|
||||
String errMsg = "Error Processing Received Message";
|
||||
result.put("description", errMsg);
|
||||
result.put("reasonCode", "00000");
|
||||
result.put("errorMapList", errorMapList);
|
||||
//result.putAll(ServiceUtil.returnError(errMsg));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -97,13 +97,21 @@ public class OagisShipmentServices {
|
||||
LocalDispatcher dispatcher = ctx.getDispatcher();
|
||||
GenericDelegator delegator = ctx.getDelegator();
|
||||
|
||||
List errorList = new LinkedList();
|
||||
List errorMapList = FastList.newInstance();
|
||||
Document doc = null;
|
||||
try {
|
||||
doc = UtilXml.readXmlDocument(in, true, "ShowShipment");
|
||||
} catch (Exception e) {
|
||||
String errMsg = "Error parsing the ShowShipmentResponse";
|
||||
errorList.add(errMsg);
|
||||
} catch (SAXException e) {
|
||||
String errMsg = "Error parsing the ShowShipmentResponse: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "SAXException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
} catch (ParserConfigurationException e) {
|
||||
String errMsg = "Error parsing the ShowShipmentResponse: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "ParserConfigurationException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
} catch (IOException e) {
|
||||
String errMsg = "Error parsing the ShowShipmentResponse: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "IOException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
}
|
||||
|
||||
@@ -111,8 +119,7 @@ public class OagisShipmentServices {
|
||||
try {
|
||||
userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
|
||||
} catch (GenericEntityException e){
|
||||
String errMsg = "Error Getting UserLogin with userLoginId system ";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error Getting UserLogin with userLoginId system: "+e.toString();
|
||||
Debug.logError(e, errMsg, module);
|
||||
}
|
||||
|
||||
@@ -147,13 +154,13 @@ public class OagisShipmentServices {
|
||||
try {
|
||||
Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoCtx);
|
||||
if (ServiceUtil.isError(oagisMsgInfoResult)){
|
||||
String errMsg = "Error creating OagisMessageInfo for the Incoming Message";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = ServiceUtil.getErrorMessage(oagisMsgInfoResult);
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "resonCode", "CreateOagisMessageInfoServiceError"));
|
||||
Debug.logError(errMsg, module);
|
||||
}
|
||||
} catch (GenericServiceException e){
|
||||
String errMsg = "Error creating OagisMessageInfo for the Incoming Message";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = "Error creating OagisMessageInfo for the Incoming Message: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "resonCode", "GenericServiceException"));
|
||||
Debug.logError(e, errMsg, module);
|
||||
}
|
||||
|
||||
@@ -200,31 +207,31 @@ public class OagisShipmentServices {
|
||||
try {
|
||||
Map resultMap = dispatcher.runSync("issueSerializedInvToShipmentPackageAndSetTracking", isitspastCtx);
|
||||
if (ServiceUtil.isError(resultMap)){
|
||||
String errMsg = "Error executing issueSerializedInvToShipmentPackageAndSetTracking Service";
|
||||
errorList.add(errMsg);
|
||||
String errMsg = ServiceUtil.getErrorMessage(resultMap);
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "resonCode", "IssueSerializedInvServiceError"));
|
||||
Debug.logError(errMsg, module);
|
||||
}
|
||||
} catch(GenericServiceException e) {
|
||||
Debug.logInfo(e, module);
|
||||
errorList.add(e.getMessage());
|
||||
String errMsg = "Error executing issueSerializedInvToShipmentPackageAndSetTracking Service: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "resonCode", "GenericServiceException"));
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
String errMsg = "Error executing issueSerializedInvToShipmentPackageAndSetTracking Service: "+e.toString();
|
||||
errorMapList.add(UtilMisc.toMap("description", errMsg, "resonCode", "GenericEntityException"));
|
||||
Debug.logInfo(e, module);
|
||||
errorList.add(e.getMessage());
|
||||
}
|
||||
|
||||
Map result = new HashMap();
|
||||
result.put("contentType","text/plain");
|
||||
if (errorList.size() > 0) {
|
||||
// error message generation
|
||||
result.putAll(oagisMsgInfoCtx);
|
||||
result.put(ModelService.RESPONSE_MESSAGE,ModelService.RESPOND_ERROR);
|
||||
result.put(ModelService.ERROR_MESSAGE_LIST, errorList);
|
||||
result.put("reasonCode", "1000");
|
||||
result.put("description", "processing message failed");
|
||||
} else {
|
||||
result.put(ModelService.RESPONSE_MESSAGE,ModelService.RESPOND_SUCCESS);
|
||||
if (errorMapList.size() > 0) {
|
||||
//result.putAll(ServiceUtil.returnError("Errors found processing message"));
|
||||
result.putAll(oagisMsgInfoCtx);
|
||||
result.put("errorMapList", errorMapList);
|
||||
return result;
|
||||
}
|
||||
|
||||
result.putAll(ServiceUtil.returnSuccess("Service Completed Successfully"));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -614,4 +621,4 @@ public class OagisShipmentServices {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +50,12 @@
|
||||
<N1:DATETIMEANY></N1:DATETIMEANY>
|
||||
</N1:CNTROLAREA>
|
||||
<N2:ORIGREF>${origRef?if_exists}</N2:ORIGREF>
|
||||
<n:CONFIRMMSG>
|
||||
<N2:DESCRIPTN>${errorDescription?if_exists}</N2:DESCRIPTN>
|
||||
<N2:REASONCODE>${errorReasonCode?if_exists}</N2:REASONCODE>
|
||||
</n:CONFIRMMSG>
|
||||
<#list errorMapList as errorMap>
|
||||
<n:CONFIRMMSG>
|
||||
<N2:DESCRIPTN>${errorMap.description?if_exists}</N2:DESCRIPTN>
|
||||
<N2:REASONCODE>${errorMap.reasonCode?if_exists}</N2:REASONCODE>
|
||||
</n:CONFIRMMSG>
|
||||
</#list>
|
||||
</n:CONFIRM>
|
||||
</n:CONFIRM_BOD>
|
||||
</n:DATAAREA>
|
||||
|
||||
Reference in New Issue
Block a user