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/06/24 07:37:09 UTC
svn commit: r550170 -
/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java
Author: apatel
Date: Sat Jun 23 22:37:09 2007
New Revision: 550170
URL: http://svn.apache.org/viewvc?view=rev&rev=550170
Log:
first pass of confirm service.
Modified:
ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.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=550170&r1=550169&r2=550170
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Sat Jun 23 22:37:09 2007
@@ -18,10 +18,23 @@
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.util.HashMap;
import java.util.Map;
+import org.ofbiz.base.util.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilXml;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
public class OagisServices {
@@ -32,6 +45,97 @@
}
public static Map receiveConfirmBod(DispatchContext ctx, Map context) {
- return ServiceUtil.returnError("Service not Implemented");
+
+ GenericDelegator delegator = ctx.getDelegator();
+ LocalDispatcher dispatcher = ctx.getDispatcher();
+ InputStream in = (InputStream) context.get("inputStream");
+ OutputStream out = (OutputStream) context.get("outputStream");
+ Map oagisMsgInfoContext = new HashMap();
+ Map oagisMsgErrorContext = new HashMap();
+ GenericValue userLogin = null;
+ String errMsg = null;
+ try{
+ 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");
+
+ oagisMsgInfoContext.put("logicalId", logicalId);
+ oagisMsgInfoContext.put("component", component);
+ oagisMsgInfoContext.put("task", task);
+ oagisMsgInfoContext.put("referenceId", referenceId);
+ oagisMsgInfoContext.put("authId", authId);
+ oagisMsgInfoContext.put("confirmation", confirmation);
+ oagisMsgInfoContext.put("bsrVerb", bsrVerb);
+ oagisMsgInfoContext.put("bsrNoun", bsrNoun);
+ oagisMsgInfoContext.put("bsrRevision", bsrRevision);
+ oagisMsgInfoContext.put("userLogin", userLogin);
+ Debug.logInfo("==============oagisMsgInfoContext===== "+oagisMsgInfoContext, module);
+
+ 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");
+
+ oagisMsgErrorContext.put("logicalId", dataAreaLogicalId);
+ oagisMsgErrorContext.put("component", dataAreaComponent);
+ oagisMsgErrorContext.put("task", dataAreaTask);
+ oagisMsgErrorContext.put("referenceId", dataAreaReferenceId);
+ oagisMsgErrorContext.put("reasonCode", reasonCode);
+ oagisMsgErrorContext.put("description", description);
+ oagisMsgErrorContext.put("userLogin", userLogin);
+ Debug.logInfo("==============oagisErrorMsgContext===== "+oagisMsgErrorContext, module);
+
+ Map resultMap = dispatcher.runSync("createOagisMessageInfo", oagisMsgInfoContext);
+ Debug.logInfo("==========resultMap-1======" +resultMap, module);
+ resultMap = dispatcher.runSync("createOagisMessageErrorInfo", oagisMsgErrorContext);
+ Debug.logInfo("==========resultMap-2======" +resultMap, module);
+
+ }catch (Exception e){
+ errMsg = "Error running method receiveConfirmBod";
+ Debug.logError(e, errMsg, module);
+ }
+ PrintWriter writer = new PrintWriter(new OutputStreamWriter(out));
+ if (errMsg!= null){
+ writer.println("Service failed");
+ writer.flush();
+ return ServiceUtil.returnError("Service failed");
+ } else {
+ writer.println("Service Completed Successfully");
+ writer.flush();
+ Map result = ServiceUtil.returnSuccess("Service Completed Successfully");
+ return result;
+ }
+
}
-}
\ No newline at end of file
+}