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/24 09:59:51 UTC
svn commit: r558954 - in /ofbiz/trunk/specialpurpose/oagis:
servicedef/secas.xml servicedef/services.xml
src/org/ofbiz/oagis/OagisServices.java webapp/oagis/WEB-INF/controller.xml
Author: apatel
Date: Tue Jul 24 00:59:50 2007
New Revision: 558954
URL: http://svn.apache.org/viewvc?view=rev&rev=558954
Log:
adding message routing service.
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/webapp/oagis/WEB-INF/controller.xml
Modified: ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml?view=diff&rev=558954&r1=558953&r2=558954
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/servicedef/secas.xml Tue Jul 24 00:59:50 2007
@@ -28,7 +28,7 @@
<action service="oagisProcessShipment" mode="sync"/>
</eca-->
- <eca service="receiveConfirmBod" event="commit" run-on-error="true">
+ <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"/>
Modified: ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml?view=diff&rev=558954&r1=558953&r2=558954
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/servicedef/services.xml Tue Jul 24 00:59:50 2007
@@ -110,15 +110,17 @@
<service name="receiveConfirmBod" engine="java" transaction-timeout="300"
location="org.ofbiz.oagis.OagisServices" invoke="receiveConfirmBod" auth="false">
<description>Process incoming ConfirmBod</description>
- <implements service="serviceStreamInterface"/>
<implements service="oagisMessageErrorInfoInterface"/>
+ <attribute name="document" type="org.w3c.dom.Document" mode="IN" optional="false"/>
</service>
+
<service name="syncInventory" engine="java" transaction-timeout="300"
location="org.ofbiz.oagis.OagisInventoryServices" invoke="syncInventory" auth="false">
<description>Process incoming Inventory Sync message</description>
<implements service="serviceStreamInterface"/>
<implements service="oagisMessageErrorInfoInterface"/>
</service>
+
<service name="exportMsgFromScreen" max-retry="0" engine="java"
location="org.ofbiz.oagis.OagisShipmentServices" invoke="exportMsgFromScreen">
<description>Export Message From Screen</description>
@@ -126,6 +128,7 @@
<attribute name="bodyParameters" type="Map" mode="IN" optional="true"/>
<attribute name="body" type="String" mode="OUT" optional="true"/>
</service>
+
<service name="oagisProcessShipment" max-retry="0" engine="java"
location="org.ofbiz.oagis.OagisShipmentServices" invoke="oagisProcessShipment">
<description>Prepare and Optionally Send OAGIS Process Shipment Message.
@@ -138,6 +141,7 @@
<attribute name="outputStream" type="java.io.OutputStream" mode="IN" optional="true"/>
<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>
@@ -147,6 +151,7 @@
<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>
@@ -171,5 +176,10 @@
<implements service="oagisMessageErrorInfoInterface"/>
</service>
-
+ <service name="oagisMessageHandler" engine="java" transaction-timeout="300"
+ location="org.ofbiz.oagis.OagisServices" invoke="oagisMessageHandler" auth="false">
+ <implements service="serviceStreamInterface"/>
+ <implements service="oagisMessageErrorInfoInterface"/>
+ </service>
+
</services>
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=558954&r1=558953&r2=558954
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Tue Jul 24 00:59:50 2007
@@ -41,6 +41,7 @@
import javax.xml.parsers.ParserConfigurationException;
import javolution.util.FastList;
+import javolution.util.FastMap;
import org.ofbiz.base.util.*;
import org.ofbiz.base.util.collections.MapStack;
@@ -196,7 +197,7 @@
GenericDelegator delegator = ctx.getDelegator();
LocalDispatcher dispatcher = ctx.getDispatcher();
- InputStream in = (InputStream) context.get("inputStream");
+ Document doc = (Document) context.get("document");
List errorMapList = FastList.newInstance();
GenericValue userLogin = null;
@@ -207,23 +208,6 @@
Debug.logError(e, errMsg, module);
}
- Document doc = null;
- try {
- doc = UtilXml.readXmlDocument(in, true, "RecieveConfirmBod");
- } catch (SAXException e) {
- 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: "+e.toString();
- errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "ParserConfigurationException"));
- Debug.logError(e, errMsg, module);
- } catch (IOException e) {
- String errMsg = "Error parsing the ConfirmBodResponse: "+e.toString();
- errorMapList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "IOException"));
- Debug.logError(e, errMsg, module);
- }
-
Element confirmBodElement = doc.getDocumentElement();
confirmBodElement.normalize();
Element docCtrlAreaElement = UtilXml.firstChildElement(confirmBodElement, "N1:CNTROLAREA");
@@ -330,14 +314,13 @@
}
Map result = new HashMap();
- result.put("contentType", "text/plain");
+ result.put("logicalId", logicalId);
+ result.put("component", component);
+ result.put("task", task);
+ result.put("referenceId", referenceId);
+ result.put("userLogin", userLogin);
if (errorMapList.size()>0){
- result.put("logicalId", logicalId);
- result.put("component", component);
- result.put("task", task);
- result.put("referenceId", referenceId);
- result.put("userLogin", userLogin);
String errMsg = "Error Processing Received Message";
result.put("errorMapList", errorMapList);
//result.putAll(ServiceUtil.returnError(errMsg));
@@ -345,6 +328,109 @@
}
result.putAll(ServiceUtil.returnSuccess("Service Completed Successfully"));
+ return result;
+ }
+
+ public static Map oagisMessageHandler(DispatchContext ctx, Map context) {
+ LocalDispatcher dispatcher = ctx.getDispatcher();
+ InputStream in = (InputStream) context.get("inputStream");
+ List errorList = FastList.newInstance();
+ Map serviceResult = FastMap.newInstance();
+
+ Document doc = null;
+ try {
+ doc = UtilXml.readXmlDocument(in, true, "OagisMessage");
+ } catch (SAXException e) {
+ String errMsg = "Error parsing the Received Message: "+e.toString();
+ errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "SAXException"));
+ Debug.logError(e, errMsg, module);
+ } catch (ParserConfigurationException e) {
+ String errMsg = "Error parsing the Received Message: "+e.toString();
+ errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "ParserConfigurationException"));
+ Debug.logError(e, errMsg, module);
+ } catch (IOException e) {
+ String errMsg = "Error parsing the Received Message: "+e.toString();
+ errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "IOException"));
+ Debug.logError(e, errMsg, module);
+ }
+ if (UtilValidate.isNotEmpty(errorList)) {
+ return ServiceUtil.returnError("Unable to parse received message");
+ }
+
+ Element rootElement = doc.getDocumentElement();
+ rootElement.normalize();
+ Element controlAreaElement = UtilXml.firstChildElement(rootElement, "N1:CNTROLAREA");
+ Element bsrElement = UtilXml.firstChildElement(controlAreaElement, "N1:BSR");
+ String bsrVerb = UtilXml.childElementValue(bsrElement, "N2:VERB");
+ String bsrNoun = UtilXml.childElementValue(bsrElement, "N2:NOUN");
+
+ if (bsrVerb.equalsIgnoreCase("CONFIRM") && bsrNoun.equalsIgnoreCase("BOD")) {
+ try {
+ serviceResult = dispatcher.runSync("receiveConfirmBod", UtilMisc.toMap("document",doc));
+ } catch (GenericServiceException e) {
+ String errMsg = "Error running service receiveConfirmBod: "+e.toString();
+ errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
+ Debug.logError(e, errMsg, module);
+ }
+ } else if (bsrVerb.equalsIgnoreCase("SHOW") && bsrNoun.equalsIgnoreCase("SHIPMENT")) {
+ try {
+ serviceResult = dispatcher.runSync("showShipmnet", UtilMisc.toMap("document",doc));
+ } catch (GenericServiceException e) {
+ String errMsg = "Error running service showShipmnet: "+e.toString();
+ errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
+ Debug.logError(e, errMsg, module);
+ }
+ } else if (bsrVerb.equalsIgnoreCase("SYNC") && bsrNoun.equalsIgnoreCase("INVENTORY")) {
+ try {
+ serviceResult = dispatcher.runSync("syncInventory", UtilMisc.toMap("document",doc));
+ } catch (GenericServiceException e) {
+ String errMsg = "Error running service syncInventory: "+e.toString();
+ errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
+ Debug.logError(e, errMsg, module);
+ }
+ } else if (bsrVerb.equalsIgnoreCase("ACKNOWLEDGE") && bsrNoun.equalsIgnoreCase("DELIVERY")) {
+ Element dataAreaElement = UtilXml.firstChildElement(rootElement, "n:DATAAREA");
+ Element ackDeliveryElement = UtilXml.firstChildElement(dataAreaElement, "n:ACKNOWLEDGE_DELIVERY");
+ Element receiptlnElement = UtilXml.firstChildElement(ackDeliveryElement, "n:RECEIPTLN");
+ Element docRefElement = UtilXml.firstChildElement(receiptlnElement, "N1:DOCUMNTREF");
+ String docType = UtilXml.childElementValue(docRefElement, "N2:DOCTYPE");
+ if (docType.equalsIgnoreCase("PO")){
+ try {
+ serviceResult = dispatcher.runSync("receivePoAcknowledge", UtilMisc.toMap("document",doc));
+ } catch (GenericServiceException e) {
+ String errMsg = "Error running service receivePoAcknowledge: "+e.toString();
+ errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
+ Debug.logError(e, errMsg, module);
+ }
+ } else if (docType.equalsIgnoreCase("RMA")) {
+ try {
+ serviceResult = dispatcher.runSync("receiveRmaAcknowledge", UtilMisc.toMap("document",doc));
+ } catch (GenericServiceException e) {
+ String errMsg = "Error running service receiveRmaAcknowledge: "+e.toString();
+ errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));
+ Debug.logError(e, errMsg, module);
+ }
+ }
+ } else {
+ String errMsg = "Unknown Message Received";
+ Debug.logError(errMsg, module);
+ ServiceUtil.returnError(errMsg);
+ }
+
+ List errorMapList = FastList.newInstance();
+ errorMapList = (List) serviceResult.get("errorMapList");
+ if (UtilValidate.isNotEmpty(errorList)) {
+ Iterator errListItr = errorList.iterator();
+ while (errListItr.hasNext()) {
+ Map errorMap = (Map) errListItr.next();
+ errorMapList.add(UtilMisc.toMap("description", errorMap.get("description"), "reasonCode", errorMap.get("reasonCode")));
+ }
+ serviceResult.put("errorMapList", errorMapList);
+ }
+
+ Map result = FastMap.newInstance();
+ result.putAll(serviceResult);
+ result.put("contentType", "text/plain");
return result;
}
}
Modified: ofbiz/trunk/specialpurpose/oagis/webapp/oagis/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/webapp/oagis/WEB-INF/controller.xml?view=diff&rev=558954&r1=558953&r2=558954
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/webapp/oagis/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/webapp/oagis/WEB-INF/controller.xml Tue Jul 24 00:59:50 2007
@@ -210,6 +210,12 @@
<event type="stream" invoke="receiveRmaAcknowledge"/>
<response name="success" type="none"/>
</request-map>
+
+ <request-map uri="oagisMessageHandler">
+ <security https="true" auth="false"/>
+ <event type="stream" invoke="oagisMessageHandler"/>
+ <response name="success" type="none"/>
+ </request-map>