Changed the error message handling for incoming messages and sending outgoing CBOD messages; also cleaned up the services.xml file to eliminate unused service defs and organize the services better

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@565576 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David E. Jones
2007-08-13 23:50:59 +00:00
parent 04b2c57f66
commit 8c3a762c0e
6 changed files with 261 additions and 162 deletions
+13 -9
View File
@@ -18,10 +18,10 @@
###############################################################################
# -- logical location of server (10 char max)
CNTROLAREA.SENDER.LOGICALID=1234567890
CNTROLAREA.SENDER.LOGICALID=792024833
# -- auth id is required to access machine that generated the BOD (50 char max)
CNTROLAREA.SENDER.AUTHID=Ofbiz
CNTROLAREA.SENDER.AUTHID=VUDU
# if these are set to true the XML content of the messages will be saved to OagisMessageInfo.fullMessageXml
Oagis.Debug.Save.Xml.Out=true
@@ -40,18 +40,22 @@ Oagis.Warehouse.SyncInventoryFacilityId=WebStoreWarehouse
Oagis.Warehouse.SyncInventoryProductStoreId=9001
# email notification
#oagis.notification.email.sendTo=foo@bar.org
oagis.notification.email.sendTo=jonesde@hotwaxmedia.com
# Client Cert, etc settings
#auth.client.certificate.alias=testrpckey
#auth.basic.username=foo
#auth.basic.password=bar
auth.basic.username=792024833
auth.basic.password=aZ79202uS
# URLs for outgoing messages
#url.send.processShipment=https://foo.bar.baz/oagis/control/processShipment
#url.send.confirmBod=https://foo.bar.baz/oagis/control/confirmBod
#url.send.receiveDelivery=https://foo.bar.baz/oagis/control/receiveDelivery
#url.send.processShipment=https://b2b.avnet.com:5361/invoke/wm.tn/receive
#url.send.confirmBod=https://b2b.avnet.com:5361/invoke/wm.tn/receive
#url.send.receiveDelivery=https://b2b.avnet.com:5361/invoke/wm.tn/receive
# test URLs
url.send.processShipment=https://b2b-test.avnet.com:5361/invoke/wm.tn/receive
url.send.confirmBod=https://b2b-test.avnet.com:5361/invoke/wm.tn/receive
url.send.receiveDelivery=https://b2b-test.avnet.com:5361/invoke/wm.tn/receive
# if the test.save.outgoing.directory is specified the files will be saved there but not sent to any URL that might be specified
test.save.outgoing.directory=.
test.save.outgoing.directory=/Users/jonesde
test.save.outgoing.filename.base=Test
+1 -10
View File
@@ -20,15 +20,13 @@ under the License.
<service-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/service-eca.xsd">
<!-- order status changes -->
<!--
<!-- uncomment these to enable OAGIS message sending
<eca service="changeOrderStatus" event="commit" run-on-error="false">
<condition field-name="statusId" operator="equals" value="ORDER_APPROVED"/>
<condition field-name="orderTypeId" operator="equals" value="SALES_ORDER"/>
<condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
<action service="oagisProcessShipment" mode="async" persist="true"/>
</eca>
<eca service="updateReturnHeader" event="commit">
<condition field-name="statusId" operator="equals" value="RETURN_ACCEPTED"/>
<action service="oagisReceiveDelivery" mode="async" persist="true"/>
@@ -38,11 +36,4 @@ under the License.
<action service="oagisProcessShipment" mode="sync"/>
</eca>
-->
<eca service="oagisMessageHandler" event="commit" run-on-error="true">
<condition field-name="errorMapList" operator="is-not-empty"/>
<action service="createOagisMsgErrInfosFromErrMapList" mode="sync"/>
<action service="oagisSendConfirmBod" mode="sync"/>
</eca>
</service-eca>
+43 -75
View File
@@ -20,48 +20,28 @@ under the License.
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd">
<service name="oagisMessageInfoInterface" engine="interface">
<attribute name="logicalId" type="String" mode="OUT" optional="false"/>
<attribute name="component" type="String" mode="OUT" optional="false"/>
<attribute name="task" type="String" mode="OUT" optional="false"/>
<attribute name="referenceId" type="String" mode="OUT" optional="false"/>
<attribute name="authId" type="String" mode="OUT" optional="true"/>
<attribute name="outgoingMessage" type="String" mode="OUT" optional="true"/>
<attribute name="sentDate" type="Timestamp" mode="OUT" optional="true"/>
<attribute name="receivedDate" type="Timestamp" mode="OUT" optional="true"/>
<attribute name="confirmation" type="String" mode="OUT" optional="true"/>
<attribute name="bsrVerb" type="String" mode="OUT" optional="true"/>
<attribute name="bsrNoun" type="String" mode="OUT" optional="true"/>
<attribute name="bsrRevision" type="String" mode="OUT" optional="true"/>
<attribute name="processingStatusId" type="String" mode="OUT" optional="true"/>
<attribute name="orderId" type="String" mode="INOUT" optional="true"/>
<attribute name="returnId" type="String" mode="INOUT" optional="true"/>
<attribute name="shipmentId" type="String" mode="INOUT" optional="true"/>
</service>
<service name="oagisMessageErrorInfoInterface" engine="interface">
<!-- General Interfaces -->
<service name="oagisMessageIdOutInterface" engine="interface">
<attribute name="logicalId" type="String" mode="OUT" optional="true"/>
<attribute name="component" type="String" mode="OUT" optional="true"/>
<attribute name="task" type="String" mode="OUT" optional="true"/>
<attribute name="referenceId" type="String" mode="OUT" optional="true"/>
<attribute name="errorMapList" type="java.util.List" mode="OUT" optional="true"/>
</service>
<!-- Low Level CrUD Services -->
<service name="createOagisMessageInfo" engine="simple" default-entity-name="OagisMessageInfo" require-new-transaction="true"
location="org/ofbiz/oagis/OagisMessageServices.xml" invoke="createOagisMessageInfo" auth="true">
<description>Create MessageInfo</description>
<auto-attributes mode="IN" include="pk" optional="false"/>
<auto-attributes mode="IN" include="nonpk" optional="true"/>
</service>
<service name="updateOagisMessageInfo" engine="simple" default-entity-name="OagisMessageInfo" require-new-transaction="true"
location="org/ofbiz/oagis/OagisMessageServices.xml" invoke="updateOagisMessageInfo" auth="true">
<description>Update MessageInfo</description>
<auto-attributes mode="IN" include="pk" optional="false"/>
<auto-attributes mode="IN" include="nonpk" optional="true"/>
</service>
<service name="createOagisMessageErrorInfo" engine="simple" default-entity-name="OagisMessageErrorInfo"
location="org/ofbiz/oagis/OagisMessageServices.xml" invoke="createOagisMessageErrorInfo" auth="true">
<description>Create MessageErrorInfo</description>
@@ -69,7 +49,6 @@ under the License.
<auto-attributes mode="IN" include="nonpk" optional="true"/>
<override name="errorSeqId" optional="true"/>
</service>
<service name="updateOagisMessageErrorInfo" engine="simple" default-entity-name="OagisMessageErrorInfo"
location="org/ofbiz/oagis/OagisMessageServices.xml" invoke="updateOagisMessageErrorInfo" auth="true">
<description>Update MessageErrorInfo</description>
@@ -77,22 +56,21 @@ under the License.
<auto-attributes mode="IN" include="nonpk" optional="true"/>
</service>
<service name="createOagisMsgErrInfosFromErrMapList" engine="simple" default-entity-name="OagisMessageErrorInfo"
<service name="createOagisMsgErrInfosFromErrMapList" engine="simple"
location="org/ofbiz/oagis/OagisMessageServices.xml" invoke="createOagisMsgErrInfosFromErrMapList" auth="true">
<description>Create MessageErrorInfo From Error Map List</description>
<auto-attributes mode="IN" include="pk" optional="false"/>
<auto-attributes entity-name="OagisMessageInfo" mode="IN" include="pk" optional="false"/>
<attribute type="List" mode="IN" name="errorMapList" optional="true"/>
<override name="errorSeqId" optional="true"/>
</service>
<!-- DEJ20070808 added max-rety=3 because this is run async persisted just in case there is a transaction problem under heavy load -->
<service name="showShipment" engine="java" transaction-timeout="300" max-retry="3"
location="org.ofbiz.oagis.OagisShipmentServices" invoke="showShipment" auth="false">
<description>Process incoming shipment message</description>
<implements service="oagisMessageErrorInfoInterface"/>
<attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
<!-- Routing service to handle all incoming messages and send them to the appropriate processing service -->
<service name="oagisMessageHandler" engine="java" transaction-timeout="300"
location="org.ofbiz.oagis.OagisServices" invoke="oagisMessageHandler" auth="false">
<implements service="serviceStreamInterface"/>
<implements service="oagisMessageIdOutInterface"/>
</service>
<!-- Confirm BOD Messages, general flow and error handling -->
<service name="oagisSendConfirmBod" engine="java" transaction-timeout="300"
location="org.ofbiz.oagis.OagisServices" invoke="oagisSendConfirmBod" auth="false">
<description>Send ConfirmBod</description>
@@ -107,18 +85,10 @@ under the License.
<attribute name="errorMapList" type="java.util.List" mode="IN" optional="true"/>
<attribute name="origRefId" type="String" mode="IN" optional="true"/>
</service>
<service name="receiveConfirmBod" engine="java" transaction-timeout="300"
location="org.ofbiz.oagis.OagisServices" invoke="receiveConfirmBod" auth="false">
<description>Process incoming ConfirmBod</description>
<implements service="oagisMessageErrorInfoInterface"/>
<attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
</service>
<service name="syncInventory" engine="java" transaction-timeout="300" max-retry="3"
location="org.ofbiz.oagis.OagisInventoryServices" invoke="syncInventory" auth="false">
<description>Process incoming Inventory Sync message</description>
<implements service="oagisMessageErrorInfoInterface"/>
<implements service="oagisMessageIdOutInterface"/>
<attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
</service>
@@ -130,12 +100,13 @@ under the License.
<attribute name="body" type="String" mode="OUT" optional="true"/>
</service>
<!-- ==================================== -->
<!-- Outgoing Message Services -->
<service name="oagisProcessShipment" max-retry="0" engine="java"
location="org.ofbiz.oagis.OagisShipmentServices" invoke="oagisProcessShipment">
<description>Prepare and Optionally Send OAGIS Process Shipment Message.
Note on usage: you can pass in either sendToUrl, saveToFilename, or outputStream.
If none are passed in the URL in oagis.properties will be used at the target for the message.</description>
<!--implements service="oagisMessageInfoInterface"/-->
<attribute name="sendToUrl" type="String" mode="IN" optional="true"/>
<attribute name="saveToFilename" type="String" mode="IN" optional="true"/>
<attribute name="saveToDirectory" type="String" mode="IN" optional="true"/>
@@ -143,16 +114,6 @@ under the License.
<attribute name="orderId" mode="IN" type="String" optional="false"/>
</service>
<service name="sendProcessShipmentMsg" max-retry="0" engine="simple"
location="org/ofbiz/oagis/OagisMessageServices.xml" invoke="sendProcessShipmentMsg">
<description>Send Process Shipment Message</description>
<attribute name="shipmentId" mode="IN" type="String" optional="false"/>
<attribute name="logicalId" mode="IN" type="String" optional="false"/>
<attribute name="authId" mode="IN" type="String" optional="false"/>
<attribute name="referenceId" mode="IN" type="String" optional="false"/>
<attribute name="sentDate" mode="IN" type="Timestamp" optional="false"/>
</service>
<service name="oagisReceiveDelivery" max-retry="0" engine="java"
location="org.ofbiz.oagis.OagisShipmentServices" invoke="oagisReceiveDelivery">
<description>Receive Delivery</description>
@@ -163,28 +124,35 @@ under the License.
<attribute name="returnId" mode="IN" type="String" optional="false"/>
</service>
<service name="receivePoAcknowledge" engine="java" transaction-timeout="300" max-retry="3"
location="org.ofbiz.oagis.OagisInventoryServices" invoke="receivePoAcknowledge" auth="false">
<description>Process PO Acknowledge message</description>
<implements service="oagisMessageErrorInfoInterface"/>
<!-- ==================================== -->
<!-- Incoming Message Services -->
<service name="syncInventory" engine="java" transaction-timeout="300" max-retry="3"
location="org.ofbiz.oagis.OagisInventoryServices" invoke="syncInventory" auth="false">
<description>Process incoming Inventory Sync message</description>
<implements service="oagisMessageIdOutInterface"/>
<attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
</service>
<service name="receiveRmaAcknowledge" engine="java" transaction-timeout="300" max-retry="3"
location="org.ofbiz.oagis.OagisInventoryServices" invoke="receiveRmaAcknowledge" auth="false">
<description>Process RMA Acknowledge message</description>
<implements service="oagisMessageErrorInfoInterface"/>
<attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
<attribute name="inventoryItemIdList" type="List" mode="OUT" optional="true"/>
</service>
<service name="oagisMessageHandler" engine="java" transaction-timeout="300"
location="org.ofbiz.oagis.OagisServices" invoke="oagisMessageHandler" auth="false">
<implements service="serviceStreamInterface"/>
<implements service="oagisMessageErrorInfoInterface"/>
<!--Added the following attribute for RMA Acknowledge service to be used in the development environment.
Might not be used and hence can be removed in the production when the RMA service is called Asynchronously.-->
<attribute name="inventoryItemIdList" type="List" mode="OUT" optional="true"/>
</service>
<!-- DEJ20070808 added max-rety=3 because this is run async persisted just in case there is a transaction problem under heavy load -->
<service name="showShipment" engine="java" transaction-timeout="300" max-retry="3"
location="org.ofbiz.oagis.OagisShipmentServices" invoke="showShipment" auth="false">
<description>Process incoming shipment message</description>
<implements service="oagisMessageIdOutInterface"/>
<attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
</service>
<service name="receivePoAcknowledge" engine="java" transaction-timeout="300" max-retry="3"
location="org.ofbiz.oagis.OagisInventoryServices" invoke="receivePoAcknowledge" auth="false">
<description>Process PO Acknowledge message</description>
<implements service="oagisMessageIdOutInterface"/>
<attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
</service>
<service name="receiveRmaAcknowledge" engine="java" transaction-timeout="300" max-retry="3"
location="org.ofbiz.oagis.OagisInventoryServices" invoke="receiveRmaAcknowledge" auth="false">
<description>Process RMA Acknowledge message</description>
<implements service="oagisMessageIdOutInterface"/>
<attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
<attribute name="inventoryItemIdList" type="List" mode="OUT" optional="true"/>
</service>
</services>
@@ -98,7 +98,7 @@ public class OagisInventoryServices {
String authId = UtilXml.childElementValue(docSenderElement, "of:AUTHID");
// create oagis message info
Map comiCtx= FastMap.newInstance();
Map comiCtx = FastMap.newInstance();
comiCtx.put("logicalId", logicalId);
comiCtx.put("component", component);
comiCtx.put("task", task);
@@ -294,14 +294,6 @@ public class OagisInventoryServices {
}
}
comiCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
try {
dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true);
} catch (GenericServiceException e) {
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
Debug.logError(e, errMsg, module);
}
Map result = FastMap.newInstance();
result.put("logicalId", logicalId);
result.put("component", component);
@@ -309,14 +301,49 @@ public class OagisInventoryServices {
result.put("referenceId", referenceId);
result.put("userLogin", userLogin);
// check error list if there is any
if (errorMapList.size() > 0) {
result.put("errorMapList", errorMapList);
String errMsg = "Error Processing Received Messages";
result.putAll(ServiceUtil.returnError(errMsg));
// call services createOagisMsgErrInfosFromErrMapList and for incoming messages oagisSendConfirmBod
Map saveErrorMapListCtx = FastMap.newInstance();
saveErrorMapListCtx.put("logicalId", logicalId);
saveErrorMapListCtx.put("component", component);
saveErrorMapListCtx.put("task", task);
saveErrorMapListCtx.put("referenceId", referenceId);
saveErrorMapListCtx.put("errorMapList", errorMapList);
try {
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);
}
try {
Map sendConfirmBodCtx = FastMap.newInstance();
sendConfirmBodCtx.putAll(saveErrorMapListCtx);
// NOTE: this is different for each service, should be shipmentId or returnId or PO orderId or etc
// for sync inventory no such ID: sendConfirmBodCtx.put("origRefId", shipmentId);
// run async because this will send a message back to the other server and may take some time, and/or fail
dispatcher.runAsync("oagisSendConfirmBod", sendConfirmBodCtx, null, true, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
Debug.logError(e, errMsg, module);
}
// DEJ20070807 what was this next line commented out? if there are errors we want to return an error so this will roll back
result.putAll(ServiceUtil.returnError("Errors found processing message; information saved and return error sent back"));
return result;
} else {
comiCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
try {
dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
// don't pass this back, nothing they can do about it: errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
Debug.logError(e, errMsg, module);
}
}
result.putAll(ServiceUtil.returnSuccess("Action Performed Successfully"));
result.putAll(ServiceUtil.returnSuccess("Service Completed Successfully"));
return result;
}
@@ -393,6 +420,7 @@ public class OagisInventoryServices {
String facilityId = UtilProperties.getPropertyValue("oagis.properties", "Oagis.Warehouse.PoReceiptFacilityId");
String productId = null;
String orderId = null;
// get RECEIPTLN elements from message
List acknowledgeElementList = UtilXml.childElementList(acknowledgeDeliveryElement, "ns:RECEIPTLN");
if (UtilValidate.isNotEmpty(acknowledgeElementList)) {
@@ -409,7 +437,7 @@ public class OagisInventoryServices {
productId = UtilXml.childElementValue(receiptLnElement, "of:ITEM");
Element documentRefElement = UtilXml.firstChildElement(receiptLnElement, "os:DOCUMNTREF");
String orderId = UtilXml.childElementValue(documentRefElement, "of:DOCUMENTID");
orderId = UtilXml.childElementValue(documentRefElement, "of:DOCUMENTID");
String orderTypeId = UtilXml.childElementValue(documentRefElement, "of:DOCTYPE");
if(orderTypeId.equals("PO")) {
orderTypeId = "PURCHASE_ORDER";
@@ -420,7 +448,7 @@ public class OagisInventoryServices {
ripCtx.put("datetimeReceived", timestampItemReceived);
// Check reference to PO number, if exists
GenericValue orderHeader = null;
if(orderId != null) {
if (orderId != null) {
try {
List toStore = FastList.newInstance();
orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
@@ -487,14 +515,6 @@ public class OagisInventoryServices {
}
}
}
comiCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
try {
dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true);
} catch (GenericServiceException e) {
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
Debug.logError(e, errMsg, module);
}
Map result = FastMap.newInstance();
result.put("logicalId", logicalId);
@@ -502,14 +522,50 @@ public class OagisInventoryServices {
result.put("task", task);
result.put("referenceId", referenceId);
result.put("userLogin", userLogin);
if (errorMapList.size() > 0) {
result.put("errorMapList", errorMapList);
String errMsg = "Error Processing Received Messages";
result.putAll(ServiceUtil.returnError(errMsg));
// call services createOagisMsgErrInfosFromErrMapList and for incoming messages oagisSendConfirmBod
Map saveErrorMapListCtx = FastMap.newInstance();
saveErrorMapListCtx.put("logicalId", logicalId);
saveErrorMapListCtx.put("component", component);
saveErrorMapListCtx.put("task", task);
saveErrorMapListCtx.put("referenceId", referenceId);
saveErrorMapListCtx.put("errorMapList", errorMapList);
try {
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);
}
try {
Map sendConfirmBodCtx = FastMap.newInstance();
sendConfirmBodCtx.putAll(saveErrorMapListCtx);
// NOTE: this is different for each service, should be shipmentId or returnId or PO orderId or etc
sendConfirmBodCtx.put("origRefId", orderId);
// run async because this will send a message back to the other server and may take some time, and/or fail
dispatcher.runAsync("oagisSendConfirmBod", sendConfirmBodCtx, null, true, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
Debug.logError(e, errMsg, module);
}
// DEJ20070807 what was this next line commented out? if there are errors we want to return an error so this will roll back
result.putAll(ServiceUtil.returnError("Errors found processing message; information saved and return error sent back"));
return result;
} else {
comiCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
try {
dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
// don't pass this back, nothing they can do about it: errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
Debug.logError(e, errMsg, module);
}
}
result.putAll(ServiceUtil.returnSuccess("Action Performed Successfully"));
result.putAll(ServiceUtil.returnSuccess("Service Completed Successfully"));
return result;
}
@@ -604,7 +660,7 @@ public class OagisInventoryServices {
String sign = UtilXml.childElementValue(qtyElement, "of:SIGN");
String productId = UtilXml.childElementValue(receiptLnElement, "of:ITEM");
if ( productId == null ) {
if (productId == null) {
String errMsg = "productId not available in Message" ;
errorMapList.add(UtilMisc.toMap("reasonCode", "ParseException", "description", errMsg));
Debug.logError(errMsg, module);
@@ -793,23 +849,50 @@ public class OagisInventoryServices {
result.put("task", task);
result.put("referenceId", referenceId);
result.put("userLogin", userLogin);
if (errorMapList.size() > 0) {
result.put("errorMapList", errorMapList);
String errMsg = "Error Processing Received Messages";
result.putAll(ServiceUtil.returnError(errMsg));
// call services createOagisMsgErrInfosFromErrMapList and for incoming messages oagisSendConfirmBod
Map saveErrorMapListCtx = FastMap.newInstance();
saveErrorMapListCtx.put("logicalId", logicalId);
saveErrorMapListCtx.put("component", component);
saveErrorMapListCtx.put("task", task);
saveErrorMapListCtx.put("referenceId", referenceId);
saveErrorMapListCtx.put("errorMapList", errorMapList);
try {
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);
}
try {
Map sendConfirmBodCtx = FastMap.newInstance();
sendConfirmBodCtx.putAll(saveErrorMapListCtx);
// NOTE: this is different for each service, should be shipmentId or returnId or PO orderId or etc
sendConfirmBodCtx.put("origRefId", returnId);
// run async because this will send a message back to the other server and may take some time, and/or fail
dispatcher.runAsync("oagisSendConfirmBod", sendConfirmBodCtx, null, true, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
Debug.logError(e, errMsg, module);
}
// DEJ20070807 what was this next line commented out? if there are errors we want to return an error so this will roll back
result.putAll(ServiceUtil.returnError("Errors found processing message; information saved and return error sent back"));
return result;
} else {
comiCtx.put("returnId", returnId);
comiCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
try {
dispatcher.runSync("updateOagisMessageInfo", comiCtx, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
// don't pass this back, nothing they can do about it: errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
Debug.logError(e, errMsg, module);
}
}
result.putAll(ServiceUtil.returnSuccess("Action Performed Successfully"));
result.putAll(ServiceUtil.returnSuccess("Service Completed Successfully"));
result.put("inventoryItemIdList", invItemIds);
return result;
}
+47 -15
View File
@@ -351,20 +351,49 @@ public class OagisServices {
result.put("task", task);
result.put("referenceId", referenceId);
result.put("userLogin", userLogin);
if (errorMapList.size() > 0) {
String errMsg = "Error Processing Received Message";
result.put("errorMapList", errorMapList);
//result.putAll(ServiceUtil.returnError(errMsg));
// call services createOagisMsgErrInfosFromErrMapList and for incoming messages oagisSendConfirmBod
Map saveErrorMapListCtx = FastMap.newInstance();
saveErrorMapListCtx.put("logicalId", logicalId);
saveErrorMapListCtx.put("component", component);
saveErrorMapListCtx.put("task", task);
saveErrorMapListCtx.put("referenceId", referenceId);
saveErrorMapListCtx.put("errorMapList", errorMapList);
try {
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);
}
// TODO and NOTE DEJ20070813: should we really send back a Confirm BOD if there is an error with the Confirm BOD they send us? probably so... will do for now...
try {
Map sendConfirmBodCtx = FastMap.newInstance();
sendConfirmBodCtx.putAll(saveErrorMapListCtx);
// NOTE: this is different for each service, should be shipmentId or returnId or PO orderId or etc
// no such thing for confirm bod: sendConfirmBodCtx.put("origRefId", shipmentId);
// run async because this will send a message back to the other server and may take some time, and/or fail
dispatcher.runAsync("oagisSendConfirmBod", sendConfirmBodCtx, null, true, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
Debug.logError(e, errMsg, module);
}
// DEJ20070807 what was this next line commented out? if there are errors we want to return an error so this will roll back
result.putAll(ServiceUtil.returnError("Errors found processing message; information saved and return error sent back"));
return result;
}
oagisMsgInfoCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
try {
dispatcher.runSync("updateOagisMessageInfo", oagisMsgInfoCtx, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
Debug.logError(e, errMsg, module);
} else {
oagisMsgInfoCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");
try {
dispatcher.runSync("updateOagisMessageInfo", oagisMsgInfoCtx, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
// don't pass this back, nothing they can do about it: errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
Debug.logError(e, errMsg, module);
}
}
result.putAll(ServiceUtil.returnSuccess("Service Completed Successfully"));
@@ -437,11 +466,12 @@ public class OagisServices {
Debug.logError(e, errMsg, module);
}
Map subServiceResult = FastMap.newInstance();
// call async, no additional results to return: Map subServiceResult = FastMap.newInstance();
if (UtilValidate.isEmpty(oagisMessageInfo)) {
if (bsrVerb.equalsIgnoreCase("CONFIRM") && bsrNoun.equalsIgnoreCase("BOD")) {
try {
subServiceResult = dispatcher.runSync("receiveConfirmBod", UtilMisc.toMap("document", doc));
// subServiceResult = dispatcher.runSync("receiveConfirmBod", UtilMisc.toMap("document", doc));
dispatcher.runAsync("receiveConfirmBod", UtilMisc.toMap("document", doc), true);
} catch (GenericServiceException e) {
String errMsg = "Error running service receiveConfirmBod: " + e.toString();
errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
@@ -506,9 +536,10 @@ public class OagisServices {
}
Map result = ServiceUtil.returnSuccess();
result.putAll(subServiceResult);
result.put("contentType", "text/plain");
/* no sub-service error processing to be done here, all handled in the sub-services:
result.putAll(subServiceResult);
List errorMapList = (List) subServiceResult.get("errorMapList");
if (UtilValidate.isNotEmpty(errorList)) {
Iterator errListItr = errorList.iterator();
@@ -518,6 +549,7 @@ public class OagisServices {
}
result.put("errorMapList", errorMapList);
}
*/
return result;
}
@@ -122,13 +122,6 @@ public class OagisShipmentServices {
Element shipmentElement = UtilXml.firstChildElement(daShowShipmentElement, "ns:SHIPMENT"); // n
String shipmentId = UtilXml.childElementValue(shipmentElement, "of:DOCUMENTID"); // of
Map result = FastMap.newInstance();
result.put("logicalId", logicalId);
result.put("component", component);
result.put("task", task);
result.put("referenceId", referenceId);
result.put("userLogin", userLogin);
oagisMsgInfoCtx.put("logicalId", logicalId);
oagisMsgInfoCtx.put("component", component);
oagisMsgInfoCtx.put("task", task);
@@ -180,17 +173,11 @@ public class OagisShipmentServices {
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "ShipmentIdNotValid"));
}
if (errorMapList.size() > 0) {
result.putAll(ServiceUtil.returnError("Errors found getting shipment information for incoming Show Shipment message; here is the first: " + errorMapList.get(0)));
result.put("errorMapList", errorMapList);
return result;
}
String shipGroupSeqId = shipment.getString("primaryShipGroupSeqId");
String originFacilityId = shipment.getString("originFacilityId");
List shipUnitElementList = UtilXml.childElementList(daShowShipmentElement, "ns:SHIPUNIT"); // n
if(UtilValidate.isNotEmpty(shipUnitElementList)) {
if(errorMapList.size() == 0 && UtilValidate.isNotEmpty(shipUnitElementList)) {
Element shipUnitElement = (Element)shipUnitElementList.get(0);
String trackingNum = UtilXml.childElementValue(shipUnitElement, "of:TRACKINGID"); // of
String carrierCode = UtilXml.childElementValue(shipUnitElement, "of:CARRIER"); // of
@@ -257,7 +244,7 @@ public class OagisShipmentServices {
requireInventory = "N";
}
// TODO and NOTE: could there be more than one reservation record for a given shipment item? for example if there wasn't enough quantity in one inventory item and reservations on two were needed? yes
// NOTE: there could be more than one reservation record for a given shipment item? for example if there wasn't enough quantity in one inventory item and reservations on two were needed
List orderItemShipGrpInvReservationList = delegator.findByAnd("OrderItemShipGrpInvRes", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId,"shipGroupSeqId",shipGroupSeqId));
// find the total quantity for all reservations
@@ -298,6 +285,8 @@ public class OagisShipmentServices {
continueLoop = true;
}
// TODO: if serialNumber does not exist in database add an error message
if (continueLoop) {
continue;
}
@@ -359,7 +348,6 @@ public class OagisShipmentServices {
}
}
}
} catch (NumberFormatException e) {
String errMsg = "Error in format for number: " + e.toString();
errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "NumberFormatException"));
@@ -386,10 +374,43 @@ public class OagisShipmentServices {
}
}
Map result = FastMap.newInstance();
result.put("logicalId", logicalId);
result.put("component", component);
result.put("task", task);
result.put("referenceId", referenceId);
result.put("userLogin", userLogin);
if (errorMapList.size() > 0) {
// call services createOagisMsgErrInfosFromErrMapList and for incoming messages oagisSendConfirmBod
Map saveErrorMapListCtx = FastMap.newInstance();
saveErrorMapListCtx.put("logicalId", logicalId);
saveErrorMapListCtx.put("component", component);
saveErrorMapListCtx.put("task", task);
saveErrorMapListCtx.put("referenceId", referenceId);
saveErrorMapListCtx.put("errorMapList", errorMapList);
try {
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);
}
try {
Map sendConfirmBodCtx = FastMap.newInstance();
sendConfirmBodCtx.putAll(saveErrorMapListCtx);
// NOTE: this is different for each service, should be shipmentId or returnId or PO orderId or etc
sendConfirmBodCtx.put("origRefId", shipmentId);
// run async because this will send a message back to the other server and may take some time, and/or fail
dispatcher.runAsync("oagisSendConfirmBod", sendConfirmBodCtx, null, true, 60, true);
} catch (GenericServiceException e){
String errMsg = "Error updating OagisMessageInfo for the Incoming Message: " + e.toString();
Debug.logError(e, errMsg, module);
}
// DEJ20070807 what was this next line commented out? if there are errors we want to return an error so this will roll back
result.putAll(ServiceUtil.returnError("Errors found processing message"));
result.put("errorMapList", errorMapList);
result.putAll(ServiceUtil.returnError("Errors found processing message; information saved and return error sent back"));
return result;
} else {
oagisMsgInfoCtx.put("processingStatusId", "OAGMP_PROC_SUCCESS");