You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/09/01 05:51:27 UTC

svn commit: r571678 - in /ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis: OagisInventoryServices.java OagisServices.java OagisShipmentServices.java

Author: jonesde
Date: Fri Aug 31 20:51:27 2007
New Revision: 571678

URL: http://svn.apache.org/viewvc?rev=571678&view=rev
Log:
After some testing fixed issues with setting rollback only too early causing error info to not be saved, AND with retrying messages for other than system errors, ie we should't retry on business level errors

Modified:
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java

Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java?rev=571678&r1=571677&r2=571678&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java Fri Aug 31 20:51:27 2007
@@ -43,6 +43,7 @@
 import org.ofbiz.entity.condition.EntityConditionList;
 import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.transaction.GenericTransactionException;
 import org.ofbiz.entity.transaction.TransactionUtil;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.product.product.ProductWorker;
@@ -414,13 +415,11 @@
         }
         
         if (previousOagisMessageInfo != null) {
-            if ("OAGMP_PROC_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_ERRCONFSENT".equals(previousOagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_SYS_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId"))) {
+            if ("OAGMP_SYS_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId"))) {
                 isErrorRetry = true;
             } else {
-                // message already in the db, but is not in an error state...
-                String errMsg = "Message received for message ID [" + omiPkMap + "] was already partially processed but is not in an error state, needs manual review; message ID: " + omiPkMap;
+                // message already in the db, but is not in a system error state...
+                String errMsg = "Message received for message ID [" + omiPkMap + "] was already partially processed but is not in a system error state, needs manual review; message ID: " + omiPkMap;
                 Debug.logError(errMsg, module);
                 return ServiceUtil.returnError(errMsg);
             }
@@ -558,11 +557,6 @@
                         errorMapList.add(UtilMisc.toMap("reasonCode", "ReceiveInventoryServiceError", "description", errMsg));
                     }
                 }
-                
-                if (errorMapList.size() > 0) {
-                    // however, we still don't want to save the partial results, so set rollbackOnly
-                    TransactionUtil.setRollbackOnly("Found business level errors in message processing, not saving results", null);
-                }
             } catch (Throwable t) {
                 String errMsg = "System Error processing Acknowledge Delivery PO message for message [" + omiPkMap + "]: " + t.toString();
                 errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "SystemError"));
@@ -631,8 +625,18 @@
                 Debug.logError(e, errMsg, module);
             }
             
+            String errMsg = "Found business level errors in message processing, not saving results; first error is: " + errorMapList.get(0);
+            
             // return success here so that the message won't be retried and the Confirm BOD, etc won't be sent multiple times 
-            result.putAll(ServiceUtil.returnSuccess("Errors found processing message; information saved and return error sent back"));
+            result.putAll(ServiceUtil.returnSuccess(errMsg));
+            
+            // however, we still don't want to save the partial results, so set rollbackOnly
+            try {
+                TransactionUtil.setRollbackOnly(errMsg, null);
+            } catch (GenericTransactionException e) {
+                Debug.logError(e, "Error setting rollback only ", module);
+            }
+
             return result;
         } else {
             comiCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
@@ -711,13 +715,11 @@
         }
         
         if (previousOagisMessageInfo != null) {
-            if ("OAGMP_PROC_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_ERRCONFSENT".equals(previousOagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_SYS_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId"))) {
+            if ("OAGMP_SYS_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId"))) {
                 isErrorRetry = true;
             } else {
-                // message already in the db, but is not in an error state...
-                String errMsg = "Message received for message ID [" + omiPkMap + "] was already partially processed but is not in an error state, needs manual review; message ID: " + omiPkMap;
+                // message already in the db, but is not in a system error state...
+                String errMsg = "Message received for message ID [" + omiPkMap + "] was already partially processed but is not in a system error state, needs manual review; message ID: " + omiPkMap;
                 Debug.logError(errMsg, module);
                 return ServiceUtil.returnError(errMsg);
             }
@@ -1076,11 +1078,6 @@
                         }
                     }
                 }
-                
-                if (errorMapList.size() > 0) {
-                    // however, we still don't want to save the partial results, so set rollbackOnly
-                    TransactionUtil.setRollbackOnly("Found business level errors in message processing, not saving results", null);
-                }
             } catch (Throwable t) {
                 String errMsg = "System Error processing Acknowledge Delivery RMA message for message [" + omiPkMap + "]: " + t.toString();
                 errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "SystemError"));
@@ -1149,9 +1146,18 @@
                 String errMsg = "Error sending Confirm BOD: " + e.toString();
                 Debug.logError(e, errMsg, module);
             }
+            String errMsg = "Found business level errors in message processing, not saving results; first error is: " + errorMapList.get(0);
             
             // return success here so that the message won't be retried and the Confirm BOD, etc won't be sent multiple times 
-            result.putAll(ServiceUtil.returnSuccess("Errors found processing message; information saved and return error sent back"));
+            result.putAll(ServiceUtil.returnSuccess(errMsg));
+            
+            // however, we still don't want to save the partial results, so set rollbackOnly
+            try {
+                TransactionUtil.setRollbackOnly(errMsg, null);
+            } catch (GenericTransactionException e) {
+                Debug.logError(e, "Error setting rollback only ", module);
+            }
+
             return result;
         } else {
             comiCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
@@ -1231,13 +1237,11 @@
         }
         
         if (previousOagisMessageInfo != null) {
-            if ("OAGMP_PROC_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_ERRCONFSENT".equals(previousOagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_SYS_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId"))) {
+            if ("OAGMP_SYS_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId"))) {
                 isErrorRetry = true;
             } else {
-                // message already in the db, but is not in an error state...
-                String errMsg = "Message received for message ID [" + omiPkMap + "] was already partially processed but is not in an error state, needs manual review; message ID: " + omiPkMap;
+                // message already in the db, but is not in a system error state...
+                String errMsg = "Message received for message ID [" + omiPkMap + "] was already partially processed but is not in a system error state, needs manual review; message ID: " + omiPkMap;
                 Debug.logError(errMsg, module);
                 return ServiceUtil.returnError(errMsg);
             }
@@ -1408,11 +1412,6 @@
                         errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "NoSerialNumbersInMessage"));
                     }
                 }
-                
-                if (errorMapList.size() > 0) {
-                    // however, we still don't want to save the partial results, so set rollbackOnly
-                    TransactionUtil.setRollbackOnly("Found business level errors in message processing, not saving results", null);
-                }
             } catch (Throwable t) {
                 String errMsg = "System Error processing Acknowledge Delivery Status message for message [" + omiPkMap + "]: " + t.toString();
                 errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "SystemError"));
@@ -1473,8 +1472,18 @@
                 Debug.logError(e, errMsg, module);
             }
             
+            String errMsg = "Found business level errors in message processing, not saving results; first error is: " + errorMapList.get(0);
+            
             // return success here so that the message won't be retried and the Confirm BOD, etc won't be sent multiple times 
-            result.putAll(ServiceUtil.returnSuccess("Errors found processing message; information saved and return error sent back"));
+            result.putAll(ServiceUtil.returnSuccess(errMsg));
+            
+            // however, we still don't want to save the partial results, so set rollbackOnly
+            try {
+                TransactionUtil.setRollbackOnly(errMsg, null);
+            } catch (GenericTransactionException e) {
+                Debug.logError(e, "Error setting rollback only ", module);
+            }
+
             return result;
         } else {
             comiCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");

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?rev=571678&r1=571677&r2=571678&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Fri Aug 31 20:51:27 2007
@@ -105,6 +105,7 @@
         LocalDispatcher dispatcher = ctx.getDispatcher();
         
         String errorReferenceId = (String) context.get("referenceId");
+        List errorMapList = (List) context.get("errorMapList");
 
         String sendToUrl = (String) context.get("sendToUrl");
         if (UtilValidate.isEmpty(sendToUrl)) {
@@ -146,11 +147,14 @@
         String sentDate = isoDateFormat.format(timestamp);
         bodyParameters.put("sentDate", sentDate);
         
+        Map omiPkMap = FastMap.newInstance();
+        omiPkMap.put("logicalId", logicalId);
+        omiPkMap.put("component", "EXCEPTION");
+        omiPkMap.put("task", "RECIEPT");
+        omiPkMap.put("referenceId", referenceId);
+        
         Map oagisMsgInfoContext = FastMap.newInstance();
-        oagisMsgInfoContext.put("logicalId", logicalId);
-        oagisMsgInfoContext.put("component", "EXCEPTION");
-        oagisMsgInfoContext.put("task", "RECIEPT");
-        oagisMsgInfoContext.put("referenceId", referenceId);
+        oagisMsgInfoContext.putAll(omiPkMap);
         oagisMsgInfoContext.put("authId", authId);
         oagisMsgInfoContext.put("sentDate", timestamp);
         oagisMsgInfoContext.put("confirmation", "0");
@@ -169,11 +173,23 @@
             Debug.logError(e, "Saving message to database failed", module);
         }
         
+        try {
+            // call services createOagisMsgErrInfosFromErrMapList and for incoming messages oagisSendConfirmBod
+            Map saveErrorMapListCtx = FastMap.newInstance();
+            saveErrorMapListCtx.putAll(omiPkMap);
+            saveErrorMapListCtx.put("errorMapList", errorMapList);
+            saveErrorMapListCtx.put("userLogin", userLogin);
+            dispatcher.runSync("createOagisMsgErrInfosFromErrMapList", saveErrorMapListCtx, 60, true);
+        } catch (GenericServiceException e) {
+            String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
+            Debug.logError(e, errMsg, module);
+        }
+        
         bodyParameters.put("errorLogicalId", context.get("logicalId"));
         bodyParameters.put("errorComponent", context.get("component"));
         bodyParameters.put("errorTask", context.get("task"));
         bodyParameters.put("errorReferenceId", errorReferenceId);
-        bodyParameters.put("errorMapList",(List) context.get("errorMapList"));
+        bodyParameters.put("errorMapList", errorMapList);
         bodyParameters.put("origRef", context.get("origRefId"));
         String bodyScreenUri = UtilProperties.getPropertyValue("oagis.properties", "Oagis.Template.ConfirmBod");
         
@@ -192,11 +208,11 @@
         
         if (Debug.infoOn()) Debug.logInfo("Finished rendering oagisSendConfirmBod message for errorReferenceId [" + errorReferenceId + "]", module);
 
-        oagisMsgInfoContext.put("processingStatusId", "OAGMP_OGEN_SUCCESS");
-        if (OagisServices.debugSaveXmlOut) {
-            oagisMsgInfoContext.put("fullMessageXml", outText);
-        }
         try {
+            oagisMsgInfoContext.put("processingStatusId", "OAGMP_OGEN_SUCCESS");
+            if (OagisServices.debugSaveXmlOut) {
+                oagisMsgInfoContext.put("fullMessageXml", outText);
+            }
             dispatcher.runSync("updateOagisMessageInfo", oagisMsgInfoContext, 60, true);
         } catch (GenericServiceException e) {
             String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale"));
@@ -209,8 +225,8 @@
         }
         if (Debug.infoOn()) Debug.logInfo("Message send done for oagisSendConfirmBod for errorReferenceId [" + errorReferenceId + "], sendToUrl=[" + sendToUrl + "], saveToDirectory=[" + saveToDirectory + "], saveToFilename=[" + saveToFilename + "]", module);
 
-        oagisMsgInfoContext.put("processingStatusId", "OAGMP_SENT");
         try {
+            oagisMsgInfoContext.put("processingStatusId", "OAGMP_SENT");
             dispatcher.runSync("updateOagisMessageInfo", oagisMsgInfoContext, 60, true);
         } catch (GenericServiceException e) {
             String errMsg = UtilProperties.getMessage(ServiceUtil.resource, "OagisErrorInCreatingDataForOagisMessageInfoEntity", (Locale) context.get("locale"));
@@ -505,9 +521,7 @@
         
         // call async, no additional results to return: Map subServiceResult = FastMap.newInstance();
         if (UtilValidate.isNotEmpty(oagisMessageInfo)) {
-            if ("OAGMP_PROC_ERROR".equals(oagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_ERRCONFSENT".equals(oagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_SYS_ERROR".equals(oagisMessageInfo.getString("processingStatusId"))) {
+            if ("OAGMP_SYS_ERROR".equals(oagisMessageInfo.getString("processingStatusId"))) {
                 // there was an error last time, tell the service this is a retry
                 messageProcessContext.put("isErrorRetry", Boolean.TRUE);
             } else {

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?rev=571678&r1=571677&r2=571678&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Fri Aug 31 20:51:27 2007
@@ -49,6 +49,7 @@
 import org.ofbiz.entity.condition.EntityConditionList;
 import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.transaction.GenericTransactionException;
 import org.ofbiz.entity.transaction.TransactionUtil;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.order.order.OrderReadHelper;
@@ -143,13 +144,11 @@
         }
         
         if (previousOagisMessageInfo != null) {
-            if ("OAGMP_PROC_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_ERRCONFSENT".equals(previousOagisMessageInfo.getString("processingStatusId")) ||
-                    "OAGMP_SYS_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId"))) {
+            if ("OAGMP_SYS_ERROR".equals(previousOagisMessageInfo.getString("processingStatusId"))) {
                 isErrorRetry = true;
             } else {
-                // message already in the db, but is not in an error state...
-                String errMsg = "Message received for shipmentId [" + shipmentId + "] message ID [" + omiPkMap + "] was already partially processed but is not in an error state, needs manual review; message ID: " + omiPkMap;
+                // message already in the db, but is not in a system error state...
+                String errMsg = "Message received for shipmentId [" + shipmentId + "] message ID [" + omiPkMap + "] was already partially processed but is not in a system error state, needs manual review; message ID: " + omiPkMap;
                 Debug.logError(errMsg, module);
                 return ServiceUtil.returnError(errMsg);
             }
@@ -500,9 +499,6 @@
                         errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "SetShipmentStatusPackedAndShippedError"));
                         Debug.logError(errMsg, module);
                     }
-                } else {
-                    // however, we still don't want to save the partial results, so set rollbackOnly
-                    TransactionUtil.setRollbackOnly("Found business level errors in message processing, not saving results", null);
                 }
             } catch (Throwable t) {
                 String errMsg = "System Error processing Show Shipment message for shipmentId [" + shipmentId + "] message [" + omiPkMap + "]: " + t.toString();
@@ -568,9 +564,18 @@
                 Debug.logError(e, errMsg, module);
             }
             
+            String errMsg = "Found business level errors in message processing, not saving those changes but saving error messages; first error is: " + errorMapList.get(0);
+            
             // return success here so that the message won't be retried and the Confirm BOD, etc won't be sent multiple times 
-            result.putAll(ServiceUtil.returnSuccess("Errors found processing message; information saved and return error sent back"));
+            result.putAll(ServiceUtil.returnSuccess(errMsg));
             
+            // however, we still don't want to save the partial results, so set rollbackOnly
+            try {
+                TransactionUtil.setRollbackOnly(errMsg, null);
+            } catch (GenericTransactionException e) {
+                Debug.logError(e, "Error setting rollback only ", module);
+            }
+
             return result;
         } else {
             try {