svn commit: r559695 - in /ofbiz/trunk/specialpurpose/oagis: config/ entitydef/ src/org/ofbiz/oagis/ webapp/oagis/WEB-INF/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r559695 - in /ofbiz/trunk/specialpurpose/oagis: config/ entitydef/ src/org/ofbiz/oagis/ webapp/oagis/WEB-INF/

jonesde
Author: jonesde
Date: Wed Jul 25 22:34:47 2007
New Revision: 559695

URL: http://svn.apache.org/viewvc?view=rev&rev=559695
Log:
Added stuff to save messages to the database, both incomng and outgoing, if properties set in oagis.properties (which they are by default now)

Modified:
    ofbiz/trunk/specialpurpose/oagis/config/oagis.properties
    ofbiz/trunk/specialpurpose/oagis/entitydef/entitymodel.xml
    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
    ofbiz/trunk/specialpurpose/oagis/webapp/oagis/WEB-INF/controller.xml

Modified: ofbiz/trunk/specialpurpose/oagis/config/oagis.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/config/oagis.properties?view=diff&rev=559695&r1=559694&r2=559695
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/config/oagis.properties (original)
+++ ofbiz/trunk/specialpurpose/oagis/config/oagis.properties Wed Jul 25 22:34:47 2007
@@ -23,6 +23,10 @@
 # -- auth id is required to access machine that generated the BOD (50 char max)
 CNTROLAREA.SENDER.AUTHID=Ofbiz
 
+# if these are set to true the XML content of the messages will be saved to OagisMessageInfo.fullMessageXml
+Oagis.Debug.Save.Xml.Out=true
+Oagis.Debug.Save.Xml.In=true
+
 Oagis.Template.ConfirmBod=component://oagis/widget/MessageInfoScreens.xml#ConfirmBod
 Oagis.Template.ReceiveDelivery=component://oagis/widget/MessageInfoScreens.xml#ReceiveDelivery
 Oagis.Template.ProcessShipment=component://oagis/widget/MessageInfoScreens.xml#ProcessShipment

Modified: ofbiz/trunk/specialpurpose/oagis/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/entitydef/entitymodel.xml?view=diff&rev=559695&r1=559694&r2=559695
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/entitydef/entitymodel.xml Wed Jul 25 22:34:47 2007
@@ -67,6 +67,7 @@
         <field name="orderId" type="id"></field>
         <field name="returnId" type="id"></field>
         <field name="shipmentId" type="id"></field>
+        <field name="fullMessageXml" type="very-long"></field>
         <prim-key field="logicalId"/>
         <prim-key field="component"/>
         <prim-key field="task"/>

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?view=diff&rev=559695&r1=559694&r2=559695
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java Wed Jul 25 22:34:47 2007
@@ -286,6 +286,15 @@
         comiCtx.put("receivedDate", UtilDateTime.nowTimestamp());
         comiCtx.put("outgoingMessage", "N");
         comiCtx.put("userLogin", userLogin);
+        if (OagisServices.debugSaveXmlIn) {
+            try {
+                comiCtx.put("fullMessageXml", UtilXml.writeXmlDocument(doc));
+            } catch (IOException e) {
+                // this is just for debug info, so just log and otherwise ignore error
+                String errMsg = "Warning: error creating text from XML Document for saving to database: " + e.toString();
+                Debug.logWarning(errMsg, module);
+            }
+        }
         try {
             Map comiResult = dispatcher.runSync("createOagisMessageInfo", comiCtx);
             if (ServiceUtil.isError(comiResult)) {
@@ -359,8 +368,8 @@
         // get RECEIPTLN elements from message
         List acknowledgeElementList = UtilXml.childElementList(acknowledgeDeliveryElement, "ns:RECEIPTLN");
         if (UtilValidate.isNotEmpty(acknowledgeElementList)) {
-         Iterator acknowledgeElementIter = acknowledgeElementList.iterator();
-         while (acknowledgeElementIter.hasNext()) {
+            Iterator acknowledgeElementIter = acknowledgeElementList.iterator();
+            while (acknowledgeElementIter.hasNext()) {
                 Map ripCtx = FastMap.newInstance();
                 Element receiptLnElement = (Element) acknowledgeElementIter.next();
                 Element qtyElement = UtilXml.firstChildElement(receiptLnElement, "os:QUANTITY");
@@ -475,6 +484,15 @@
         comiCtx.put("bsrNoun", bsrNoun);
         comiCtx.put("bsrRevision", bsrRevision);
         comiCtx.put("userLogin", userLogin);
+        if (OagisServices.debugSaveXmlIn) {
+            try {
+                comiCtx.put("fullMessageXml", UtilXml.writeXmlDocument(doc));
+            } catch (IOException e) {
+                // this is just for debug info, so just log and otherwise ignore error
+                String errMsg = "Warning: error creating text from XML Document for saving to database: " + e.toString();
+                Debug.logWarning(errMsg, module);
+            }
+        }
         try {
             Map comiResult = dispatcher.runSync("createOagisMessageInfo", comiCtx);
             if (ServiceUtil.isError(comiResult)) {
@@ -484,7 +502,7 @@
         } catch (GenericServiceException e) {
             String errMsg = "Error creating OagisMessageInfo for the Incoming Message: " + e.toString();
             // TODO: reconsider sending this error back to other server, not much they can do about it, and it may not be a critical error causing the message to be rejected...
- errorMapList.add(UtilMisc.toMap("reasonCode", "CreateOagisMessageInfoError", "description", errMsg));
+            errorMapList.add(UtilMisc.toMap("reasonCode", "CreateOagisMessageInfoError", "description", errMsg));
             Debug.logError(e, errMsg, module);
         }
         Map result = FastMap.newInstance();
@@ -706,6 +724,15 @@
         comiCtx.put("bsrNoun", bsrNoun);
         comiCtx.put("bsrRevision", bsrRevision);
         comiCtx.put("userLogin", userLogin);
+        if (OagisServices.debugSaveXmlIn) {
+            try {
+                comiCtx.put("fullMessageXml", UtilXml.writeXmlDocument(doc));
+            } catch (IOException e) {
+                // this is just for debug info, so just log and otherwise ignore error
+                String errMsg = "Warning: error creating text from XML Document for saving to database: " + e.toString();
+                Debug.logWarning(errMsg, module);
+            }
+        }
         try {
             Map comiResult = dispatcher.runSync("createOagisMessageInfo", comiCtx);
             if (ServiceUtil.isError(comiResult)) {

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=559695&r1=559694&r2=559695
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Wed Jul 25 22:34:47 2007
@@ -71,7 +71,10 @@
     public static final String certAlias = UtilProperties.getPropertyValue("oagis.properties", "auth.client.certificate.alias");
     public static final String basicAuthUsername = UtilProperties.getPropertyValue("oagis.properties", "auth.basic.username");
     public static final String basicAuthPassword = UtilProperties.getPropertyValue("oagis.properties", "auth.basic.password");
-    
+
+    public static final boolean debugSaveXmlOut = "true".equals(UtilProperties.getPropertyValue("oagis.properties", "Oagis.Debug.Save.Xml.Out"));
+    public static final boolean debugSaveXmlIn = "true".equals(UtilProperties.getPropertyValue("oagis.properties", "Oagis.Debug.Save.Xml.In"));
+
     public static Map oagisSendConfirmBod(DispatchContext ctx, Map context) {
         
         GenericDelegator delegator = ctx.getDelegator();

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=559695&r1=559694&r2=559695
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Wed Jul 25 22:34:47 2007
@@ -144,6 +144,15 @@
         oagisMsgInfoCtx.put("authId", authId);
         oagisMsgInfoCtx.put("outgoingMessage", "N");
         oagisMsgInfoCtx.put("userLogin", userLogin);
+        if (OagisServices.debugSaveXmlIn) {
+            try {
+                oagisMsgInfoCtx.put("fullMessageXml", UtilXml.writeXmlDocument(doc));
+            } catch (IOException e) {
+                // this is just for debug info, so just log and otherwise ignore error
+                String errMsg = "Warning: error creating text from XML Document for saving to database: " + e.toString();
+                Debug.logWarning(errMsg, module);
+            }
+        }
         
         try {
             Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoCtx);
@@ -461,7 +470,7 @@
                         return ServiceUtil.returnError(errMsg);
                     }
                 } else if (UtilValidate.isNotEmpty(sendToUrl)) {
-                 writer = new StringWriter();
+                    writer = new StringWriter();
                 }
 
                 ScreenRenderer screens = new ScreenRenderer(writer, bodyParameters, new HtmlScreenRenderer());
@@ -469,12 +478,12 @@
                     screens.render(bodyScreenUri);
                     writer.close();
                 } catch (Exception e) {
-                 String errMsg = "Error rendering message: " + e.toString();
+                    String errMsg = "Error rendering message: " + e.toString();
                     Debug.logError(e, errMsg, module);
                     return ServiceUtil.returnError(errMsg);
                 }
                 
-                // TODO: call service with require-new-transaction=true to save the OagisMessageInfo data (to make sure it saves before)
+                // TODO: should we make sure this is saved in error conditions
                 // prepare map to Create Oagis Message Info
                 comiCtx.put("component", "INVENTORY");
                 comiCtx.put("task", "SHIPREQUES"); // Actual value of task is "SHIPREQUEST" which is more than 10 char
@@ -487,6 +496,9 @@
                 comiCtx.put("orderId", orderId);
                 comiCtx.put("shipmentId", shipmentId);
                 comiCtx.put("userLogin", userLogin);
+                if (OagisServices.debugSaveXmlOut) {
+                    comiCtx.put("fullMessageXml", writer.toString());
+                }
                 
                 try {
                     Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", comiCtx);
@@ -506,7 +518,7 @@
                       
                     // needed XML post parameters
                     if (UtilValidate.isNotEmpty(certAlias)) {
-                     http.setClientCertificateAlias(certAlias);
+                        http.setClientCertificateAlias(certAlias);
                     }
                     if (UtilValidate.isNotEmpty(basicAuthUsername)) {
                         http.setBasicAuthInfo(basicAuthUsername, basicAuthPassword);
@@ -515,9 +527,9 @@
                     http.setKeepAlive(true);
 
                     try {
-                     http.post(writer.toString());
+                        http.post(writer.toString());
                     } catch (Exception e) {
-                     String errMsg = "Error posting message to server with UTL [" + sendToUrl + "]: " + e.toString();
+                        String errMsg = "Error posting message to server with UTL [" + sendToUrl + "]: " + e.toString();
                         Debug.logError(e, errMsg, module);
                         return ServiceUtil.returnError(errMsg);
                     }
@@ -668,6 +680,10 @@
                 comiCtx.put("processingStatusId", statusId);
                 comiCtx.put("returnId", returnId);
                 comiCtx.put("userLogin", userLogin);
+                if (OagisServices.debugSaveXmlOut) {
+                    comiCtx.put("fullMessageXml", writer.toString());
+                }
+
                 try {
                     dispatcher.runSync("createOagisMessageInfo", comiCtx);
                 } catch (GenericServiceException e) {

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=559695&r1=559694&r2=559695
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/webapp/oagis/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/oagis/webapp/oagis/WEB-INF/controller.xml Wed Jul 25 22:34:47 2007
@@ -212,11 +212,17 @@
     </request-map>
     
     <request-map uri="oagisMessageHandler">
-        <security https="true" auth="false"/>
+        <security https="true" auth="false" cert="true"/>
         <event type="stream" invoke="oagisMessageHandler"/>
         <response name="success" type="none"/>
     </request-map>
-
+    <!-- this doesn't require a cert and is for testing; should be removed or blocked in production -->
+    <request-map uri="oagisMessageHandlerTest">
+        <security https="false" auth="false" cert="false"/>
+        <event type="stream" invoke="oagisMessageHandler"/>
+        <response name="success" type="none"/>
+    </request-map>
+    
 
 
     <!-- end of request mappings -->