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/06 16:46:28 UTC

svn commit: r553909 [3/3] - in /ofbiz/trunk/specialpurpose/oagis: servicedef/secas.xml servicedef/services.xml src/org/ofbiz/oagis/OagisInventoryServices.java src/org/ofbiz/oagis/OagisServices.java src/org/ofbiz/oagis/OagisShipmentServices.java

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=553909&r1=553908&r2=553909
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Fri Jul  6 07:46:27 2007
@@ -1,207 +1,343 @@
-package org.ofbiz.oagis;
-
-/**
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
-**/
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.text.ParseException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Date;
-
-import org.ofbiz.base.util.*;
-import org.ofbiz.base.util.collections.MapStack;
-import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.GenericValue;
-import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.GenericServiceException;
-import org.ofbiz.service.LocalDispatcher;
-import org.ofbiz.service.ServiceUtil;
-import org.ofbiz.widget.html.HtmlScreenRenderer;
-import org.ofbiz.widget.screen.ScreenRenderer;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class OagisServices {
-    
-    public static final String module = OagisServices.class.getName();
-    
-    public static Map sendConfirmBod(DispatchContext ctx, Map context) {
-        
-        GenericDelegator delegator = ctx.getDelegator();
-        LocalDispatcher dispatcher = ctx.getDispatcher();
-        
-        GenericValue userLogin = null;
-        try {
-            userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "admin"));
-        } catch (GenericEntityException e) {
-            Debug.logError(e, "Error getting userLogin", module);
-        }
-        
-        String logicalId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.LOGICALID");
-        String authId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.AUTHID");
-        
-        MapStack bodyParameters =  MapStack.create();
-        bodyParameters.put("logicalId", logicalId);
-        bodyParameters.put("authId", authId);
-
-        String referenceId = delegator.getNextSeqId("OagisMessageInfo");
-        bodyParameters.put("referenceId", referenceId);
-
-        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'Z");
-        Timestamp timestamp = UtilDateTime.nowTimestamp();
-        String sentDate = dateFormat.format(timestamp);
-        bodyParameters.put("sentDate", sentDate);
-        
-        bodyParameters.put("errorLogicalId", context.get("logicalId"));
-        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("origRef", context.get("origRefId"));
-        OutputStream out = (OutputStream) context.get("outputStream");
-        String bodyScreenUri = UtilProperties.getPropertyValue("oagis.properties", "Oagis.Template.ConfirmBod");
-        Writer writer = new OutputStreamWriter(out);
-        ScreenRenderer screens = new ScreenRenderer(writer, bodyParameters, new HtmlScreenRenderer());
-        try {
-            screens.render(bodyScreenUri);
-        } catch (Exception e) {
-            Debug.logError(e, "Error rendering [text/xml]: ", module);
-        }
-        Map oagisMsgInfoContext = new HashMap();
-        oagisMsgInfoContext.put("logicalId", logicalId);
-        oagisMsgInfoContext.put("component", "EXCEPTION");
-        oagisMsgInfoContext.put("task", "RECIEPT");
-        oagisMsgInfoContext.put("referenceId", referenceId);
-        oagisMsgInfoContext.put("authId", authId);
-        oagisMsgInfoContext.put("sentDate", timestamp);
-        oagisMsgInfoContext.put("confirmation", "0");
-        oagisMsgInfoContext.put("bsrVerb", "CONFIRM");
-        oagisMsgInfoContext.put("bsrNoun", "BOD");
-        oagisMsgInfoContext.put("bsrRevision", "004");
-        oagisMsgInfoContext.put("userLogin", userLogin);
-        try
-        {
-            Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoContext);
-            if (ServiceUtil.isError(oagisMsgInfoResult)) return ServiceUtil.returnError("Error creating OagisMessageInfo");
-            
-            
-        } catch (GenericServiceException e) {
-            Debug.logError(e, "Saving message to database failed", module);
-        }
-        
-        return ServiceUtil.returnSuccess("Service Completed Successfully");
-    }
-
-    public static Map receiveConfirmBod(DispatchContext ctx, Map context) {
-        
-        GenericDelegator delegator = ctx.getDelegator();
-        LocalDispatcher dispatcher = ctx.getDispatcher();
-        InputStream in = (InputStream) context.get("inputStream");
-        
-        try{
-            GenericValue userLogin = delegator.findByPrimaryKey("UserLogin",UtilMisc.toMap("userLoginId","admin"));
-            Document doc = UtilXml.readXmlDocument(in, true, "RecieveConfirmBod");
-            Element confirmBodElement = doc.getDocumentElement();
-            confirmBodElement.normalize();
-            Element docCtrlAreaElement = UtilXml.firstChildElement(confirmBodElement, "N1:CNTROLAREA");
-            Element bsrElement = UtilXml.firstChildElement(docCtrlAreaElement, "N1:BSR");
-            String bsrVerb = UtilXml.childElementValue(bsrElement, "N2:VERB");
-            String bsrNoun = UtilXml.childElementValue(bsrElement, "N2:NOUN");
-            String bsrRevision = UtilXml.childElementValue(bsrElement, "N2:REVISION");
-            
-            Element docSenderElement = UtilXml.firstChildElement(docCtrlAreaElement, "N1:SENDER");
-            String logicalId = UtilXml.childElementValue(docSenderElement, "N2:LOGICALID");
-            String component = UtilXml.childElementValue(docSenderElement, "N2:COMPONENT");
-            String task = UtilXml.childElementValue(docSenderElement, "N2:TASK");
-            String referenceId = UtilXml.childElementValue(docSenderElement, "N2:REFERENCEID");
-            String confirmation = UtilXml.childElementValue(docSenderElement, "N2:CONFIRMATION");
-            String language = UtilXml.childElementValue(docSenderElement, "N2:LANGUAGE");
-            String codepage = UtilXml.childElementValue(docSenderElement, "N2:CODEPAGE");
-            String authId = UtilXml.childElementValue(docSenderElement, "N2:AUTHID");
-            String sentDate = UtilXml.childElementValue(docCtrlAreaElement, "N1:DATETIMEANY");
-            
-            Element dataAreaElement = UtilXml.firstChildElement(confirmBodElement, "n:DATAAREA");
-            Element dataAreaConfirmBodElement = UtilXml.firstChildElement(dataAreaElement, "n:CONFIRM_BOD");
-            Element dataAreaConfirmElement = UtilXml.firstChildElement(dataAreaConfirmBodElement, "n:CONFIRM");
-            Element dataAreaCtrlElement = UtilXml.firstChildElement(dataAreaConfirmElement, "N1:CNTROLAREA");
-            Element dataAreaSenderElement = UtilXml.firstChildElement(dataAreaCtrlElement, "N1:SENDER");
-            String dataAreaLogicalId = UtilXml.childElementValue(dataAreaSenderElement, "N2:LOGICALID");
-            String dataAreaComponent = UtilXml.childElementValue(dataAreaSenderElement, "N2:COMPONENT");
-            String dataAreaTask = UtilXml.childElementValue(dataAreaSenderElement, "N2:TASK");
-            String dataAreaReferenceId = UtilXml.childElementValue(dataAreaSenderElement, "N2:REFERENCEID");
-            String dataAreaDate = UtilXml.childElementValue(dataAreaCtrlElement, "N1:DATETIMEANY");
-            String origRef = UtilXml.childElementValue(dataAreaConfirmElement, "N2:ORIGREF");
-            
-            Element dataAreaConfirmMsgElement = UtilXml.firstChildElement(dataAreaConfirmElement, "n:CONFIRMMSG");
-            String description = UtilXml.childElementValue(dataAreaConfirmMsgElement, "N2:DESCRIPTN");
-            String reasonCode = UtilXml.childElementValue(dataAreaConfirmMsgElement, "N2:REASONCODE");
-            
-            Timestamp timestamp = UtilDateTime.nowTimestamp();
-            Map oagisMsgInfoContext = new HashMap();
-            oagisMsgInfoContext.put("logicalId", logicalId);
-            oagisMsgInfoContext.put("component", component);
-            oagisMsgInfoContext.put("task", task);
-            oagisMsgInfoContext.put("referenceId", referenceId);
-            oagisMsgInfoContext.put("authId", authId);
-            oagisMsgInfoContext.put("receivedDate", timestamp);
-            oagisMsgInfoContext.put("confirmation", confirmation);
-            oagisMsgInfoContext.put("bsrVerb", bsrVerb);
-            oagisMsgInfoContext.put("bsrNoun", bsrNoun);
-            oagisMsgInfoContext.put("bsrRevision", bsrRevision);
-            oagisMsgInfoContext.put("userLogin", userLogin);
-            
-            Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoContext);
-            if (ServiceUtil.isError(oagisMsgInfoResult)) return ServiceUtil.returnError("Error creating OagisMessageInfo");
-            
-            Map oagisMsgErrorContext = new HashMap();
-            oagisMsgErrorContext.put("logicalId", dataAreaLogicalId);
-            oagisMsgErrorContext.put("component", dataAreaComponent);
-            oagisMsgErrorContext.put("task", dataAreaTask);
-            oagisMsgErrorContext.put("referenceId", dataAreaReferenceId);
-            
-            GenericValue oagisMsgInfo = delegator.findByPrimaryKey("OagisMessageInfo", oagisMsgErrorContext);
-            if (oagisMsgInfo != null){
-                oagisMsgErrorContext.put("reasonCode", reasonCode);
-                oagisMsgErrorContext.put("description", description);
-                oagisMsgErrorContext.put("userLogin", userLogin);
-                Map oagisMsgErrorInfoResult = dispatcher.runSync("createOagisMessageErrorInfo", oagisMsgErrorContext);
-                if (ServiceUtil.isError(oagisMsgInfoResult)) return ServiceUtil.returnError("Error creating OagisMessageErrorInfo");
-            } else{
-                Debug.logWarning("No such message with an error was found in OagisMessageInfoEntity ; Not creating OagisMessageErrorInfo", module);
-            }
-        }catch (Exception e){
-            String errMsg = "Error running method receiveConfirmBod";
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
-        }
-        
-        Map result = ServiceUtil.returnSuccess("Service Completed Successfully");
-        result.put("contentType", "text/plain");
-        return result;
-    }
-}
+package org.ofbiz.oagis;
+
+/**
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+**/
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Date;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import javolution.util.FastList;
+
+import org.ofbiz.base.util.*;
+import org.ofbiz.base.util.collections.MapStack;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.widget.fo.FoFormRenderer;
+import org.ofbiz.widget.html.HtmlScreenRenderer;
+import org.ofbiz.widget.screen.ScreenRenderer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+public class OagisServices {
+    
+    public static final String module = OagisServices.class.getName();
+    
+    protected static final HtmlScreenRenderer htmlScreenRenderer = new HtmlScreenRenderer();
+    protected static final FoFormRenderer foFormRenderer = new FoFormRenderer();
+    
+    public static final String resource = "OagisUiLabels";
+
+    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 Map oagisSendConfirmBod(DispatchContext ctx, Map context) {
+        
+        GenericDelegator delegator = ctx.getDelegator();
+        LocalDispatcher dispatcher = ctx.getDispatcher();
+
+        String sendToUrl = (String) context.get("sendToUrl");
+        String saveToFilename = (String) context.get("saveToFilename");
+        String saveToDirectory = (String) context.get("saveToDirectory");
+        OutputStream out = (OutputStream) context.get("outputStream");
+        
+        GenericValue userLogin = null;
+        try {
+            userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "admin"));
+        } catch (GenericEntityException e) {
+            Debug.logError(e, "Error getting userLogin", module);
+        }
+        
+        String logicalId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.LOGICALID");
+        String authId = UtilProperties.getPropertyValue("oagis.properties", "CNTROLAREA.SENDER.AUTHID");
+        
+        MapStack bodyParameters =  MapStack.create();
+        bodyParameters.put("logicalId", logicalId);
+        bodyParameters.put("authId", authId);
+
+        String referenceId = delegator.getNextSeqId("OagisMessageInfo");
+        bodyParameters.put("referenceId", referenceId);
+
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'Z");
+        Timestamp timestamp = UtilDateTime.nowTimestamp();
+        String sentDate = dateFormat.format(timestamp);
+        bodyParameters.put("sentDate", sentDate);
+        
+        bodyParameters.put("errorLogicalId", context.get("logicalId"));
+        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("origRef", context.get("origRefId"));
+        String bodyScreenUri = UtilProperties.getPropertyValue("oagis.properties", "Oagis.Template.ConfirmBod");
+        
+        Writer writer = null;
+        if (out != null) {
+            writer = new OutputStreamWriter(out);
+        } else if (UtilValidate.isNotEmpty(saveToFilename)) {
+            try {
+                File outdir = new File(saveToDirectory);
+                if (!outdir.exists()) {
+                    outdir.mkdir();
+                }
+                writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, saveToFilename)), "UTF-8")));
+            } catch (Exception e) {
+                String errMsg = "Error opening file to save message to [" + saveToFilename + "]: " + e.toString();
+                Debug.logError(e, errMsg, module);
+                return ServiceUtil.returnError(errMsg);
+            }
+        } else if (UtilValidate.isNotEmpty(sendToUrl)) {
+            writer = new StringWriter();
+        }
+
+        ScreenRenderer screens = new ScreenRenderer(writer, bodyParameters, new HtmlScreenRenderer());
+        try {
+            screens.render(bodyScreenUri);
+            writer.close();
+        } catch (Exception e) {
+            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)
+
+        if (UtilValidate.isNotEmpty(sendToUrl)) {
+            HttpClient http = new HttpClient(sendToUrl);
+
+            // test parameters
+            http.setHostVerificationLevel(SSLUtil.HOSTCERT_NO_CHECK);
+            http.setAllowUntrusted(true);
+            http.setDebug(true);
+              
+            // needed XML post parameters
+            if (UtilValidate.isNotEmpty(certAlias)) {
+                http.setClientCertificateAlias(certAlias);
+            }
+            if (UtilValidate.isNotEmpty(basicAuthUsername)) {
+                http.setBasicAuthInfo(basicAuthUsername, basicAuthPassword);
+            }
+            http.setContentType("text/xml");
+            http.setKeepAlive(true);
+
+            try {
+                String resp = http.post(writer.toString());
+            } catch (Exception e) {
+                String errMsg = "Error posting message to server with UTL [" + sendToUrl + "]: " + e.toString();
+                Debug.logError(e, errMsg, module);
+                return ServiceUtil.returnError(errMsg);
+            }
+        }
+        
+        
+        
+        Map oagisMsgInfoContext = new HashMap();
+        oagisMsgInfoContext.put("logicalId", logicalId);
+        oagisMsgInfoContext.put("component", "EXCEPTION");
+        oagisMsgInfoContext.put("task", "RECIEPT");
+        oagisMsgInfoContext.put("referenceId", referenceId);
+        oagisMsgInfoContext.put("authId", authId);
+        oagisMsgInfoContext.put("sentDate", timestamp);
+        oagisMsgInfoContext.put("confirmation", "0");
+        oagisMsgInfoContext.put("bsrVerb", "CONFIRM");
+        oagisMsgInfoContext.put("bsrNoun", "BOD");
+        oagisMsgInfoContext.put("bsrRevision", "004");
+        oagisMsgInfoContext.put("userLogin", userLogin);
+        try
+        {
+            Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoContext);
+            if (ServiceUtil.isError(oagisMsgInfoResult)) return ServiceUtil.returnError("Error creating OagisMessageInfo");
+            
+        } catch (GenericServiceException e) {
+            Debug.logError(e, "Saving message to database failed", module);
+        }
+        
+        return ServiceUtil.returnSuccess("Service Completed Successfully");
+    }
+
+    public static Map receiveConfirmBod(DispatchContext ctx, Map context) {
+        
+        GenericDelegator delegator = ctx.getDelegator();
+        LocalDispatcher dispatcher = ctx.getDispatcher();
+        InputStream in = (InputStream) context.get("inputStream");
+        FastList errorList = 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'";
+            Debug.logError(e, errMsg, module);
+        }
+        
+        Document doc = null;
+        try {
+            doc = UtilXml.readXmlDocument(in, true, "RecieveConfirmBod");
+        } catch (SAXException e) {
+            String errMsg = "Error parsing the ConfirmBodResponse";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        } catch (ParserConfigurationException e) {
+            String errMsg = "Error parsing the ConfirmBodResponse";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        } catch (IOException e) {
+            String errMsg = "Error parsing the ConfirmBodResponse";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        }
+
+        Element confirmBodElement = doc.getDocumentElement();
+        confirmBodElement.normalize();
+        Element docCtrlAreaElement = UtilXml.firstChildElement(confirmBodElement, "N1:CNTROLAREA");
+        Element bsrElement = UtilXml.firstChildElement(docCtrlAreaElement, "N1:BSR");
+        String bsrVerb = UtilXml.childElementValue(bsrElement, "N2:VERB");
+        String bsrNoun = UtilXml.childElementValue(bsrElement, "N2:NOUN");
+        String bsrRevision = UtilXml.childElementValue(bsrElement, "N2:REVISION");
+            
+        Element docSenderElement = UtilXml.firstChildElement(docCtrlAreaElement, "N1:SENDER");
+        String logicalId = UtilXml.childElementValue(docSenderElement, "N2:LOGICALID");
+        String component = UtilXml.childElementValue(docSenderElement, "N2:COMPONENT");
+        String task = UtilXml.childElementValue(docSenderElement, "N2:TASK");
+        String referenceId = UtilXml.childElementValue(docSenderElement, "N2:REFERENCEID");
+        String confirmation = UtilXml.childElementValue(docSenderElement, "N2:CONFIRMATION");
+        String language = UtilXml.childElementValue(docSenderElement, "N2:LANGUAGE");
+        String codepage = UtilXml.childElementValue(docSenderElement, "N2:CODEPAGE");
+        String authId = UtilXml.childElementValue(docSenderElement, "N2:AUTHID");
+        String sentDate = UtilXml.childElementValue(docCtrlAreaElement, "N1:DATETIMEANY");
+          
+        Element dataAreaElement = UtilXml.firstChildElement(confirmBodElement, "n:DATAAREA");
+        Element dataAreaConfirmBodElement = UtilXml.firstChildElement(dataAreaElement, "n:CONFIRM_BOD");
+        Element dataAreaConfirmElement = UtilXml.firstChildElement(dataAreaConfirmBodElement, "n:CONFIRM");
+        Element dataAreaCtrlElement = UtilXml.firstChildElement(dataAreaConfirmElement, "N1:CNTROLAREA");
+        Element dataAreaSenderElement = UtilXml.firstChildElement(dataAreaCtrlElement, "N1:SENDER");
+        String dataAreaLogicalId = UtilXml.childElementValue(dataAreaSenderElement, "N2:LOGICALID");
+        String dataAreaComponent = UtilXml.childElementValue(dataAreaSenderElement, "N2:COMPONENT");
+        String dataAreaTask = UtilXml.childElementValue(dataAreaSenderElement, "N2:TASK");
+        String dataAreaReferenceId = UtilXml.childElementValue(dataAreaSenderElement, "N2:REFERENCEID");
+        String dataAreaDate = UtilXml.childElementValue(dataAreaCtrlElement, "N1:DATETIMEANY");
+        String origRef = UtilXml.childElementValue(dataAreaConfirmElement, "N2:ORIGREF");
+         
+        Element dataAreaConfirmMsgElement = UtilXml.firstChildElement(dataAreaConfirmElement, "n:CONFIRMMSG");
+        String description = UtilXml.childElementValue(dataAreaConfirmMsgElement, "N2:DESCRIPTN");
+        String reasonCode = UtilXml.childElementValue(dataAreaConfirmMsgElement, "N2:REASONCODE");
+          
+        Timestamp timestamp = UtilDateTime.nowTimestamp();
+        Map oagisMsgInfoCtx = new HashMap();
+        oagisMsgInfoCtx.put("logicalId", logicalId);
+        oagisMsgInfoCtx.put("component", component);
+        oagisMsgInfoCtx.put("task", task);
+        oagisMsgInfoCtx.put("referenceId", referenceId);
+        oagisMsgInfoCtx.put("authId", authId);
+        oagisMsgInfoCtx.put("receivedDate", timestamp);
+        oagisMsgInfoCtx.put("confirmation", confirmation);
+        oagisMsgInfoCtx.put("bsrVerb", bsrVerb);
+        oagisMsgInfoCtx.put("bsrNoun", bsrNoun);
+        oagisMsgInfoCtx.put("bsrRevision", bsrRevision);
+        oagisMsgInfoCtx.put("outgoingMessage", "N");
+        oagisMsgInfoCtx.put("userLogin", userLogin);
+        try {
+            Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoCtx);
+            if (ServiceUtil.isError(oagisMsgInfoResult)){
+                String errMsg = "Error creating OagisMessageInfo for the Incoming Message";
+                errorList.add(errMsg);
+                Debug.logError(errMsg, module);
+            }
+        } catch (GenericServiceException e){
+            String errMsg = "Error creating OagisMessageInfo for the Incoming Message";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        }
+
+        Map oagisMsgErrorCtx = new HashMap();
+        oagisMsgErrorCtx.put("logicalId", dataAreaLogicalId);
+        oagisMsgErrorCtx.put("component", dataAreaComponent);
+        oagisMsgErrorCtx.put("task", dataAreaTask);
+        oagisMsgErrorCtx.put("referenceId", dataAreaReferenceId);
+          
+        GenericValue oagisMsgInfo = null;
+        try {
+            oagisMsgInfo = delegator.findByPrimaryKey("OagisMessageInfo", oagisMsgErrorCtx);
+        } catch (GenericEntityException e){
+            String errMsg = "Error Getting Entity OagisMessageInfo";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        }
+        
+        if (oagisMsgInfo != null){
+            oagisMsgErrorCtx.put("reasonCode", reasonCode);
+            oagisMsgErrorCtx.put("description", description);
+            oagisMsgErrorCtx.put("userLogin", userLogin);
+            try {
+                Map oagisMsgErrorInfoResult = dispatcher.runSync("createOagisMessageErrorInfo", oagisMsgErrorCtx);
+                if (ServiceUtil.isError(oagisMsgErrorInfoResult)){
+                    String errMsg = "Error creating OagisMessageErrorInfo";
+                    errorList.add(errMsg);
+                    Debug.logError(errMsg, module);
+                }
+            } catch (GenericServiceException e){
+                String errMsg = "Error creating OagisMessageErrorInfo";
+                errorList.add(errMsg);
+                Debug.logError(e, errMsg, module);
+            }
+        } else{
+            String errMsg = "No such message with an error was found in OagisMessageInfoEntity ; Not creating OagisMessageErrorInfo";
+            Debug.logWarning(errMsg, module);
+            errorList.add(errMsg);
+        }
+        
+        Map result = new HashMap();
+        result.put("contentType", "text/plain");
+        
+        if (errorList.size()>0){
+            result.putAll(oagisMsgInfoCtx);
+            String errMsg = "Error Processing Received Message";
+            result.put("description", errMsg);
+            result.put("reasonCode", "00000");
+            //result.putAll(ServiceUtil.returnError(errMsg));
+            return result;
+        }
+        
+        result.putAll(ServiceUtil.returnSuccess("Service Completed Successfully"));
+        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=553909&r1=553908&r2=553909
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Fri Jul  6 07:46:27 2007
@@ -21,6 +21,7 @@
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -39,6 +40,8 @@
 import java.util.Set;
 import java.util.TreeSet;
 
+import javax.xml.parsers.ParserConfigurationException;
+
 import javolution.util.FastList;
 
 import org.ofbiz.base.util.Debug;
@@ -69,6 +72,7 @@
 import org.ofbiz.widget.screen.ScreenRenderer;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
 
 
 public class OagisShipmentServices {
@@ -88,98 +92,138 @@
         InputStream in = (InputStream) context.get("inputStream");
         LocalDispatcher dispatcher = ctx.getDispatcher();
         GenericDelegator delegator = ctx.getDelegator();
-        Map result = new HashMap();
+        
         List errorList = new LinkedList();
+        Document doc = null;
         try {
-            Document doc = UtilXml.readXmlDocument(in, true, "ShowShipment");
-            GenericValue userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "admin"));            
-            Element showShipmentElement = doc.getDocumentElement();
-            showShipmentElement.normalize();
-            
-            Element controlAreaElement = UtilXml.firstChildElement(showShipmentElement, "N1:CNTROLAREA");
-            Element bsrElement = UtilXml.firstChildElement(controlAreaElement, "N1:BSR");
-            String bsrVerb = UtilXml.childElementValue(bsrElement, "N2:VERB");
-            String bsrNoun = UtilXml.childElementValue(bsrElement, "N2:NOUN");
-            String bsrRevision = UtilXml.childElementValue(bsrElement, "N2:REVISION");
-            
-            result.put("bsrVerb", bsrVerb);
-            result.put("bsrNoun", bsrNoun);
-            result.put("bsrRevision", bsrRevision);
-            
-            Element senderElement = UtilXml.firstChildElement(controlAreaElement, "N1:SENDER");
-            String logicalId = UtilXml.childElementValue(senderElement, "N2:LOGICALID");
-            String component = UtilXml.childElementValue(senderElement, "N2:COMPONENT");
-            String task = UtilXml.childElementValue(senderElement, "N2:TASK");
-            String referenceId = UtilXml.childElementValue(senderElement, "N2:REFERENCEID");
-            String confirmation = UtilXml.childElementValue(senderElement, "N2:CONFIRMATION");
-            String authId = UtilXml.childElementValue(senderElement, "N2:AUTHID");
+            doc = UtilXml.readXmlDocument(in, true, "ShowShipment");
+        } catch (SAXException e) {
+            String errMsg = "Error parsing the ShowShipmentResponse";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        } catch (ParserConfigurationException e) {
+            String errMsg = "Error parsing the ShowShipmentResponse";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        } catch (IOException e) {
+            String errMsg = "Error parsing the ShowShipmentResponse";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        }
             
-            result.put("logicalId", logicalId);
-            result.put("component", component);
-            result.put("task", task);
-            result.put("referenceId", referenceId);
-            result.put("confirmation", confirmation);
-            result.put("authId", authId);
-            result.put("outgoingMessage", "N");
-            result.put("userLogin", userLogin);
+        GenericValue userLogin =null; 
+        try {
+            userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "admin"));    
+        } catch (GenericEntityException e){
+            String errMsg = "Error Getting UserLogin with userLoginId 'admin'";
+            Debug.logError(e, errMsg, module);
+        }
+                    
+        Element showShipmentElement = doc.getDocumentElement();
+        showShipmentElement.normalize();
+          
+        Element controlAreaElement = UtilXml.firstChildElement(showShipmentElement, "N1:CNTROLAREA");
+        Element bsrElement = UtilXml.firstChildElement(controlAreaElement, "N1:BSR");
+        String bsrVerb = UtilXml.childElementValue(bsrElement, "N2:VERB");
+        String bsrNoun = UtilXml.childElementValue(bsrElement, "N2:NOUN");
+        String bsrRevision = UtilXml.childElementValue(bsrElement, "N2:REVISION");
+          
+        Map oagisMsgInfoCtx = new HashMap();
+        oagisMsgInfoCtx.put("bsrVerb", bsrVerb);
+        oagisMsgInfoCtx.put("bsrNoun", bsrNoun);
+        oagisMsgInfoCtx.put("bsrRevision", bsrRevision);
             
-            Element dataAreaElement = UtilXml.firstChildElement(showShipmentElement, "n:DATAAREA");
-            Element daShowShipmentElement = UtilXml.firstChildElement(dataAreaElement, "n:SHOW_SHIPMENT");
-            Element shipmentElement = UtilXml.firstChildElement(daShowShipmentElement, "n:SHIPMENT");                                  
-            String shipmentId = UtilXml.childElementValue(shipmentElement, "N2:DOCUMENTID");            
+        Element senderElement = UtilXml.firstChildElement(controlAreaElement, "N1:SENDER");
+        String logicalId = UtilXml.childElementValue(senderElement, "N2:LOGICALID");
+        String component = UtilXml.childElementValue(senderElement, "N2:COMPONENT");
+        String task = UtilXml.childElementValue(senderElement, "N2:TASK");
+        String referenceId = UtilXml.childElementValue(senderElement, "N2:REFERENCEID");
+        String confirmation = UtilXml.childElementValue(senderElement, "N2:CONFIRMATION");
+        String authId = UtilXml.childElementValue(senderElement, "N2:AUTHID");
+          
+        oagisMsgInfoCtx.put("logicalId", logicalId);
+        oagisMsgInfoCtx.put("component", component);
+        oagisMsgInfoCtx.put("task", task);
+        oagisMsgInfoCtx.put("referenceId", referenceId);
+        oagisMsgInfoCtx.put("confirmation", confirmation);
+        oagisMsgInfoCtx.put("authId", authId);
+        oagisMsgInfoCtx.put("outgoingMessage", "N");
+        oagisMsgInfoCtx.put("userLogin", userLogin);
+        
+        try {
+            Map oagisMsgInfoResult = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoCtx);
+            if (ServiceUtil.isError(oagisMsgInfoResult)){
+                String errMsg = "Error creating OagisMessageInfo for the Incoming Message";
+                errorList.add(errMsg);
+                Debug.logError(errMsg, module);
+            }
+        } catch (GenericServiceException e){
+            String errMsg = "Error creating OagisMessageInfo for the Incoming Message";
+            errorList.add(errMsg);
+            Debug.logError(e, errMsg, module);
+        }
+           
+        Element dataAreaElement = UtilXml.firstChildElement(showShipmentElement, "n:DATAAREA");
+        Element daShowShipmentElement = UtilXml.firstChildElement(dataAreaElement, "n:SHOW_SHIPMENT");
+        Element shipmentElement = UtilXml.firstChildElement(daShowShipmentElement, "n:SHIPMENT");                                  
+        String shipmentId = UtilXml.childElementValue(shipmentElement, "N2:DOCUMENTID");            
            
-            Element shipUnitElement = UtilXml.firstChildElement(daShowShipmentElement, "n:SHIPUNIT");
-            String trackingNum = UtilXml.childElementValue(shipUnitElement, "N2:TRACKINGID");            
+        Element shipUnitElement = UtilXml.firstChildElement(daShowShipmentElement, "n:SHIPUNIT");
+        String trackingNum = UtilXml.childElementValue(shipUnitElement, "N2:TRACKINGID");            
             
-            Element invItem = UtilXml.firstChildElement(shipUnitElement, "n:INVITEM");            
-            String productId = UtilXml.childElementValue(invItem, "N2:ITEM");
+        Element invItem = UtilXml.firstChildElement(shipUnitElement, "n:INVITEM");            
+        String productId = UtilXml.childElementValue(invItem, "N2:ITEM");
             
-            Element invDetail = UtilXml.firstChildElement(invItem, "n:INVDETAIL");
-            String serialNumber = UtilXml.childElementValue(invDetail,"N1:SERIALNUM");
-            try {                
-                GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
-                String shipGroupSeqId = shipment.getString("primaryShipGroupSeqId");                
-                String originFacilityId = shipment.getString("originFacilityId");                              
-                GenericValue shipmentItem = EntityUtil.getFirst(delegator.findByAnd("ShipmentItem", UtilMisc.toMap("shipmentId", shipmentId, "productId",productId)));                
-                String shipmentItemSeqId = shipmentItem.getString("shipmentItemSeqId");                
-                GenericValue orderShipment = EntityUtil.getFirst(delegator.findByAnd("OrderShipment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentItemSeqId", shipmentItemSeqId)));                
-                String orderId = orderShipment.getString("orderId");                
-                String orderItemSeqId = orderShipment.getString("orderItemSeqId");                
-                GenericValue product = delegator.findByPrimaryKey("Product",UtilMisc.toMap("productId",productId)); 
-                String requireInventory = product.getString("requireInventory");
-                if(requireInventory == null) {
-                    requireInventory = "N";
-                }                
-                GenericValue orderItemShipGrpInvReservation = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGrpInvRes", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId,"shipGroupSeqId",shipGroupSeqId)));               
-                Map isitspastCtx = UtilMisc.toMap("orderId", orderId, "shipGroupSeqId", shipGroupSeqId, "orderItemSeqId", orderItemSeqId, "quantity", shipmentItem.get("quantity"), "quantityNotReserved", shipmentItem.get("quantity"));                
-                isitspastCtx.put("productId", productId);
-                isitspastCtx.put("reservedDatetime", orderItemShipGrpInvReservation.get("reservedDatetime"));
-                isitspastCtx.put("requireInventory", requireInventory);
-                isitspastCtx.put("reserveOrderEnumId", orderItemShipGrpInvReservation.get("reserveOrderEnumId"));
-                isitspastCtx.put("sequenceId", orderItemShipGrpInvReservation.get("sequenceId"));
-                isitspastCtx.put("originFacilityId", originFacilityId);
-                isitspastCtx.put("userLogin", userLogin);
-                isitspastCtx.put("serialNumber", serialNumber);
-                isitspastCtx.put("trackingNum", trackingNum);
-                isitspastCtx.put("inventoryItemId", orderItemShipGrpInvReservation.get("inventoryItemId"));                
-                isitspastCtx.put("shipmentId", shipmentId);      
-                try {                    
-                    dispatcher.runSync("issueSerializedInvToShipmentPackageAndSetTracking", isitspastCtx);                                      
-                } catch(GenericServiceException e) {
-                    Debug.logInfo(e, module);
-                    errorList.add(e.getMessage());
+        Element invDetail = UtilXml.firstChildElement(invItem, "n:INVDETAIL");
+        String serialNumber = UtilXml.childElementValue(invDetail,"N1:SERIALNUM");
+        try {                
+            GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
+            String shipGroupSeqId = shipment.getString("primaryShipGroupSeqId");                
+            String originFacilityId = shipment.getString("originFacilityId");                              
+            GenericValue shipmentItem = EntityUtil.getFirst(delegator.findByAnd("ShipmentItem", UtilMisc.toMap("shipmentId", shipmentId, "productId",productId)));                
+            String shipmentItemSeqId = shipmentItem.getString("shipmentItemSeqId");                
+            GenericValue orderShipment = EntityUtil.getFirst(delegator.findByAnd("OrderShipment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentItemSeqId", shipmentItemSeqId)));                
+            String orderId = orderShipment.getString("orderId");                
+            String orderItemSeqId = orderShipment.getString("orderItemSeqId");                
+            GenericValue product = delegator.findByPrimaryKey("Product",UtilMisc.toMap("productId",productId)); 
+            String requireInventory = product.getString("requireInventory");
+            if(requireInventory == null) {
+                requireInventory = "N";
+            }                
+            GenericValue orderItemShipGrpInvReservation = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGrpInvRes", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId,"shipGroupSeqId",shipGroupSeqId)));               
+            Map isitspastCtx = UtilMisc.toMap("orderId", orderId, "shipGroupSeqId", shipGroupSeqId, "orderItemSeqId", orderItemSeqId, "quantity", shipmentItem.get("quantity"), "quantityNotReserved", shipmentItem.get("quantity"));                
+            isitspastCtx.put("productId", productId);
+            isitspastCtx.put("reservedDatetime", orderItemShipGrpInvReservation.get("reservedDatetime"));
+            isitspastCtx.put("requireInventory", requireInventory);
+            isitspastCtx.put("reserveOrderEnumId", orderItemShipGrpInvReservation.get("reserveOrderEnumId"));
+            isitspastCtx.put("sequenceId", orderItemShipGrpInvReservation.get("sequenceId"));
+            isitspastCtx.put("originFacilityId", originFacilityId);
+            isitspastCtx.put("userLogin", userLogin);
+            isitspastCtx.put("serialNumber", serialNumber);
+            isitspastCtx.put("trackingNum", trackingNum);
+            isitspastCtx.put("inventoryItemId", orderItemShipGrpInvReservation.get("inventoryItemId"));                
+            isitspastCtx.put("shipmentId", shipmentId);      
+            try {                    
+                Map resultMap = dispatcher.runSync("issueSerializedInvToShipmentPackageAndSetTracking", isitspastCtx);
+                if (ServiceUtil.isError(resultMap)){
+                    String errMsg = "Error executing issueSerializedInvToShipmentPackageAndSetTracking Service";
+                    errorList.add(errMsg);
+                    Debug.logError(errMsg, module);
                 }
-            } catch (GenericEntityException e) {
+            } catch(GenericServiceException e) {
                 Debug.logInfo(e, module);
                 errorList.add(e.getMessage());
             }
-        } catch (Exception e) {
-            Debug.logError(e, module);
+        } catch (GenericEntityException e) {
+            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"); 
@@ -411,10 +455,16 @@
         return result;
     }
     
-    public static Map receiveDelivery(DispatchContext dctx, Map context) {
+    public static Map oagisReceiveDelivery(DispatchContext dctx, Map context) {
         GenericDelegator delegator = dctx.getDelegator();
         String returnId = (String) context.get("returnId");
         GenericValue userLogin = (GenericValue) context.get("userLogin");
+        
+        String sendToUrl = (String) context.get("sendToUrl");
+        String saveToFilename = (String) context.get("saveToFilename");
+        String saveToDirectory = (String) context.get("saveToDirectory");
+        OutputStream out = (OutputStream) context.get("outputStream");
+        
         Map result = ServiceUtil.returnSuccess();
         MapStack bodyParameters =  MapStack.create();
         if (userLogin == null) {
@@ -495,13 +545,63 @@
                 
                 bodyParameters.put("returnId", returnId);
                 String bodyScreenUri = UtilProperties.getPropertyValue("oagis.properties", "Oagis.Template.ReceiveDelivery");
-                OutputStream out = (OutputStream) context.get("outputStream");
-                Writer writer = new OutputStreamWriter(out);
+                
+                Writer writer = null;
+                if (out != null) {
+                    writer = new OutputStreamWriter(out);
+                } else if (UtilValidate.isNotEmpty(saveToFilename)) {
+                    try {
+                        File outdir = new File(saveToDirectory);
+                        if (!outdir.exists()) {
+                            outdir.mkdir();
+                        }
+                        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, saveToFilename)), "UTF-8")));
+                    } catch (Exception e) {
+                        String errMsg = "Error opening file to save message to [" + saveToFilename + "]: " + e.toString();
+                        Debug.logError(e, errMsg, module);
+                        return ServiceUtil.returnError(errMsg);
+                    }
+                } else if (UtilValidate.isNotEmpty(sendToUrl)) {
+                    writer = new StringWriter();
+                }
+
                 ScreenRenderer screens = new ScreenRenderer(writer, bodyParameters, new HtmlScreenRenderer());
                 try {
                     screens.render(bodyScreenUri);
+                    writer.close();
                 } catch (Exception e) {
-                      Debug.logError(e, "Error rendering [text/xml]: ", module);
+                    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)
+
+                if (UtilValidate.isNotEmpty(sendToUrl)) {
+                    HttpClient http = new HttpClient(sendToUrl);
+
+                    // test parameters
+                    http.setHostVerificationLevel(SSLUtil.HOSTCERT_NO_CHECK);
+                    http.setAllowUntrusted(true);
+                    http.setDebug(true);
+                      
+                    // needed XML post parameters
+                    if (UtilValidate.isNotEmpty(certAlias)) {
+                        http.setClientCertificateAlias(certAlias);
+                    }
+                    if (UtilValidate.isNotEmpty(basicAuthUsername)) {
+                        http.setBasicAuthInfo(basicAuthUsername, basicAuthPassword);
+                    }
+                    http.setContentType("text/xml");
+                    http.setKeepAlive(true);
+
+                    try {
+                        String resp = http.post(writer.toString());
+                    } catch (Exception e) {
+                        String errMsg = "Error posting message to server with UTL [" + sendToUrl + "]: " + e.toString();
+                        Debug.logError(e, errMsg, module);
+                        return ServiceUtil.returnError(errMsg);
+                    }
                 }
                 // prepare map to store BOD information
                 result.put("component", "INVENTORY");