You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ap...@apache.org on 2007/07/12 21:12:02 UTC

svn commit: r555723 - in /ofbiz/trunk/specialpurpose/oagis: servicedef/secas.xml servicedef/services.xml src/org/ofbiz/oagis/OagisServices.java src/org/ofbiz/oagis/OagisShipmentServices.java webapp/oagis/message/ConfirmBod.ftl

Author: apatel
Date: Thu Jul 12 12:12:01 2007
New Revision: 555723

URL: http://svn.apache.org/viewvc?view=rev&rev=555723
Log:
Improved error response handling.

Modified:
    ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml
    ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java
    ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl

Modified: ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml?view=diff&rev=555723&r1=555722&r2=555723
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml Thu Jul 12 12:12:01 2007
@@ -37,7 +37,7 @@
     </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 @@
     </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> 

Modified: ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml?view=diff&rev=555723&r1=555722&r2=555723
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml Thu Jul 12 12:12:01 2007
@@ -42,8 +42,7 @@
     
     <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 @@
         <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>
     

Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java?view=diff&rev=555723&r1=555722&r2=555723
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Thu Jul 12 12:12:01 2007
@@ -33,6 +33,7 @@
 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 @@
         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 @@
         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 @@
         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 @@
         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 @@
         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 @@
             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;
         }

Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java?view=diff&rev=555723&r1=555722&r2=555723
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Thu Jul 12 12:12:01 2007
@@ -97,13 +97,21 @@
         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 @@
         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 @@
         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 @@
             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 @@
         }    
         return result;
     }
-}
\ No newline at end of file
+}

Modified: ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl?view=diff&rev=555723&r1=555722&r2=555723
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl (original)
+++ ofbiz/trunk/specialpurpose/oagis/webapp/oagis/message/ConfirmBod.ftl Thu Jul 12 12:12:01 2007
@@ -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>