home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / mqaoad21.zip / MQAOAdapterImp.java < prev    next >
Text File  |  2003-01-13  |  74KB  |  1,571 lines

  1. package com.ibm.extricity.adapters.mqseries.mqak;
  2.  
  3. /**
  4.  * MQAOAdapterImp.java 1.0      10/4/2000
  5.  *
  6.  * The MQAOAdapterImp is derived from <EM>Adapter</EM> class.
  7.  * This class (originaly generated by Extricity Adapter Designer) is used
  8.  * as an interface for performing the Extricity MQAK Adapter functions
  9.  *
  10.  * OCO Source Materials
  11.  *
  12.  * 5799-RNK
  13.  *
  14.  * (C) Copyright IBM Corp. 2000
  15.  *
  16.  * The source code for this program is not published
  17.  * or otherwise divested of its trade secrets,
  18.  * irrespective of what has been deposited with the
  19.  * U. S. Copyright Office.
  20.  *
  21.  * @author Thomas W. Jaworski
  22. **/
  23. import java.io.*;
  24. import com.extricity.adapter.api.*;
  25. import com.extricity.document.api.*;
  26.  
  27. import java.net.URLClassLoader;
  28. import java.net.URL;
  29. import java.util.*;
  30. import javax.naming.*;
  31. import javax.naming.directory.*;
  32.  
  33. import javax.activation.*;import javax.mail.*;import com.ibm.misc.*;import javax.mail.internet.*;public class MQAOAdapterImp extends Adapter {
  34.         protected boolean _DEBUG = false;
  35.  
  36.         protected MQAOAdapterHelperInt helper;
  37.  
  38.         //-------------------------------------------------------------------------
  39.         // Constants - Protected - Internal
  40.         //-------------------------------------------------------------------------
  41.  
  42.         protected static final String UNKNOWN_OPERATION_TYPE_ID =
  43.                 "Trying to execute an Adapter operation with an unknown operation type";
  44.         protected static final String UNKNOWN_OPERATION_ID =
  45.                 "Trying to execute an unknown Adapter operation";
  46.  
  47.  
  48.         //-------------------------------------------------------------------------
  49.         // Constants - Protected - Adapter Properties
  50.         //-------------------------------------------------------------------------
  51.  
  52.         protected static final String PROP_DESTINATIONCOMPONENT =
  53.                 "DestinationComponent";
  54.         protected static final String PROP_PROTOCOLANDVERSION = "ProtocolAndVersion";
  55.         protected static final String PROP_MSGBODYCATEGORY = "MsgBodyCategory";
  56.         protected static final String PROP_GATEWAYCOMPONENT = "GatewayComponent";
  57.         protected static final String PROP_ENABLETRACE = "EnableTrace";
  58.         protected static final String PROP_EXPLICITCOMMIT = "ExplicitCommit";
  59.         protected static final String PROP_ADAPTMESSAGES = "AdaptMessages";
  60.         protected static final String PROP_EPICURL = "EpicURL";
  61.         protected static final String PROP_INTERNALAPPID = "InternalAppId";
  62.         protected static final String PROP_MQAKURL = "MQAKURL";
  63.         protected static final String PROP_PARTNERURL = "PartnerURL";
  64.  
  65.  
  66.         //-------------------------------------------------------------------------
  67.         // Constants - Protected - Adapter Events
  68.         //-------------------------------------------------------------------------
  69.  
  70.         protected static final String EVENT_PIP_START = "PIP Start";
  71.         protected static final String EVENT_PROCESS_END = "Process End";
  72.  
  73.         //-------------------------------------------------------------------------
  74.         // Constants - Private - Advanced Operations
  75.         //-------------------------------------------------------------------------
  76.  
  77.         // RecvBO constants
  78.         protected static final String RECVPREFIX = "Recv";
  79.         protected static final String RECVBO_INPUT_PROCESSID = "ProcessID";
  80.         protected static final String RECVBO_INPUT_MSGFILTER = "MsgFilter";
  81.         protected static final String RECVBO_INPUT_MSGID = "MsgId";
  82.         protected static final String RECVBO_INPUT_PEEKONLY = "PeekOnly";
  83.         protected static final String RECVBO_OUTPUT_MSGHDR = "MsgHdr";
  84.         protected static final String RECVBO_OUTPUT_OPSTATUS = "OPStatus";
  85.         protected static final String RECVBO_OUTPUT_MSGBO = "MsgBO";
  86.         protected static final String RECVBO_OUTPUT_COMMITCONTEXT = "CommitContext";
  87.  
  88.         // SendBO constants
  89.         protected static final String SENDPREFIX = "Send";
  90.         protected static final String SENDBO_INPUT_PROCESSID = "ProcessID";
  91.         protected static final String SENDBO_INPUT_MSGBO = "MsgBO";
  92.         protected static final String SENDBO_INPUT_MSGHDR = "MsgHdr";
  93.         protected static final String SENDBO_OUTPUT_OPSTATUS = "OPStatus";
  94.         protected static final String SENDBO_OUTPUT_COMMITCONTEXT = "CommitContext";
  95.  
  96.         // "RecvPip3A4PurchaseOrderRequest" constants
  97.         //protected static final String RECVPIP3A4PURCHASEORDERREQUEST = "RecvPip3A4PurchaseOrderRequest";
  98.  
  99.         // "SendPip3A4PurchaseOrderRequest" constants
  100.         //protected static final String SENDPIP3A4PURCHASEORDERREQUEST = "SendPip3A4PurchaseOrderRequest";
  101.  
  102.         // "RecvPip3A4PurchaseOrderAcceptance" constants
  103.         //protected static final String RECVPIP3A4PURCHASEORDERACCEPTANCE = "RecvPip3A4PurchaseOrderAcceptance";
  104.  
  105.         // "SendPip3A4PurchaseOrderAcceptance" constants
  106.         //protected static final String SENDPIP3A4PURCHASEORDERACCEPTANCE = "SendPip3A4PurchaseOrderAcceptance";
  107.  
  108.         // "RecvPip3A4PurchaseOrderChange" constants
  109.         //protected static final String RECVPIP3A4PURCHASEORDERCHANGE = "RecvPip3A4PurchaseOrderChange";
  110.  
  111.         // "SendPip3A4PurchaseOrderChange" constants
  112.         //protected static final String SENDPIP3A4PURCHASEORDERCHANGE = "SendPip3A4PurchaseOrderChange";
  113.  
  114.         // "RecvPip3A4PurchaseOrderCancellation" constants
  115.         //protected static final String RECVPIP3A4PURCHASEORDERCANCELLATION = "RecvPip3A4PurchaseOrderCancellation";
  116.  
  117.         // "SendPip3A4PurchaseOrderCancellation" constants
  118.         //protected static final String SENDPIP3A4PURCHASEORDERCANCELLATION = "SendPip3A4PurchaseOrderCancellation";
  119.  
  120.         // "RecvXMLMsg" constants
  121.         protected static final String RECVXMLMSG = "RecvXMLMsg";
  122.         protected static final String RECVXMLMSG_INPUT_PROCESSID = "ProcessID";
  123.         protected static final String RECVXMLMSG_INPUT_MSGFILTER = "MsgFilter";
  124.         protected static final String RECVXMLMSG_INPUT_MSGID = "MsgId";
  125.         protected static final String RECVXMLMSG_INPUT_PEEKONLY = "PeekOnly";
  126.         protected static final String RECVXMLMSG_OUTPUT_MSGXML = "MsgXML";
  127.         protected static final String RECVXMLMSG_OUTPUT_MSGHDR = "MsgHdr";
  128.         protected static final String RECVXMLMSG_OUTPUT_OPSTATUS = "OPStatus";
  129.         protected static final String RECVXMLMSG_OUTPUT_COMMITCONTEXT = "CommitContext";
  130.  
  131.         // "SendXMLMsg" constants
  132.         protected static final String SENDXMLMSG = "SendXMLMsg";
  133.         protected static final String SENDXMLMSGWCARD = "SendXMLMsgWithCard";
  134.  
  135.         protected static final String SENDXMLMSG_INPUT_PROCESSID = "ProcessID";
  136.         protected static final String SENDXMLMSG_INPUT_MSGXML = "MsgXML";
  137.         protected static final String SENDXMLMSG_INPUT_MSGHDR = "MsgHdr";
  138.         protected static final String SENDXMLMSG_OUTPUT_OPSTATUS = "OPStatus";
  139.         protected static final String SENDXMLMSG_OUTPUT_COMMITCONTEXT = "CommitContext";
  140.         protected static final String SENDXMLMSG_INPUT_CARDNUM = "PCardNumber";
  141.         protected static final String SENDXML_EXTRINSIC_OPEN = "<Extrinsic name=\"CardSuffix\">";
  142.         protected static final String SENDXML_EXTRINSIC_CLOSE = "</Extrinsic>";
  143.  
  144.         // "Commit" constants
  145.         protected static final String COMMIT = "Commit";
  146.         protected static final String COMMIT_INPUT_PROCESSID = "ProcessID";
  147.         protected static final String COMMIT_INPUT_COMMITCONTEXT = "CommitContext";
  148.         protected static final String COMMIT_OUTPUT_OPSTATUS = "OPStatus";
  149.  
  150.         // "GetPublicProcessID" constants
  151.         protected static final String GETPUBLICPROCESSID = "GetPublicProcessID";
  152.         protected static final String GETPUBLICPROCESSID_OUTPUT_OPSTATUS = "OPStatus";
  153.         protected static final String GETPUBLICPROCESSID_OUTPUT_PUBLICPROCESSID =
  154.                 "PublicProcessID";
  155.  
  156.         // "GetProcessData" constants
  157.         protected static final String GETPROCESSDATA = "GetProcessData";
  158.         protected static final String GETPROCESSDATA_INPUT_PROCESSID = "ProcessID";
  159.         protected static final String GETPROCESSDATA_OUTPUT_TRADINGPARTNER =
  160.                 "TradingPartner";
  161.         protected static final String GETPROCESSDATA_OUTPUT_BOCORRELATIONID =
  162.                 "BOCorrelationID";
  163.  
  164.         // "SetProcessData" constants
  165.         protected static final String SETPROCESSDATA = "SetProcessData";
  166.         protected static final String SETPROCESSDATA_INPUT_BOCORRELATIONID =
  167.                 "BOCorrelationID";
  168.         protected static final String SETPROCESSDATA_INPUT_TRADINGPARTNER =
  169.                 "TradingPartner";
  170.         protected static final String SETPROCESSDATA_INPUT_PROCESSID = "ProcessID";
  171.  
  172.         // "DelProcessData" constants
  173.         protected static final String DELPROCESSDATA = "DelProcessData";
  174.         protected static final String DELPROCESSDATA_INPUT_PROCESSID = "ProcessID";
  175.  
  176.         // "LogException" constants
  177.         protected static final String LOGEXCEPTION = "LogException";
  178.         protected static final String LOGEXCEPTION_INPUT_LOGMESSAGE = "LogMessage";
  179.         protected static final String LOGEXCEPTION_INPUT_PROCESSID = "ProcessID";
  180.         protected static final String LOGEXCEPTION_INPUT_SUBCOMPONENT = "SubComponent";
  181.         protected static final String LOGEXCEPTION_INPUT_EXCEPTIONID = "ExceptionID";
  182.         protected static final String LOGEXCEPTION_INPUT_PROCESSNAME = "ProcessName";
  183.         protected static final String LOGEXCEPTION_OUTPUT_OPSTATUS = "OPStatus";
  184.  
  185.         protected static final String ADMIN_EMAIL_ADDR = "adminEmailAddr";
  186.         // "Audit logging " constants
  187.         protected static final String AUDIT_LOG = "auditLog";           protected static final String AUDIT_LOG_CONTENT = "auditContent";
  188.         // "Buyer profile authentication" constants
  189.         protected static final String BUYER_AUTHENTICATION = "buyerAuthentication";     protected static final String BUYER_IDENTIFIER = "buyerId";
  190.         // "Retrieve admin user's email addrs " constants
  191.         protected static final String GET_ADMIN_EMAIL_ADDR = "getAdminEmailAddr";
  192.  
  193.         // "EncryptPCard" constants
  194.         protected static final String ENCRYPTCARD = "EncryptPCard";
  195.         protected static final String PCARDNUM = "PCardNum";
  196.         protected static final String CRPTONUM = "EncryptedPCardNum";
  197.  
  198.         // "Properties file" constants
  199.         protected static final String READPROPERTIES = "ReadResponseProperties";
  200.         protected static final String PROPERTY_FILENAME = "PropertyFile";
  201.         protected static final String LANG = "language";
  202.         protected static final String COUNTRY_CODE = "CountryCode";
  203.         protected static final String RESPONSE_STATUS = "ResponseStatus";
  204.         protected static final String RESPONSE_CODE = "ResponseCode";
  205.         protected static final String RESPONSE_TEXT = "ResponseText";
  206.         protected static final String RESPONSE_DATA = "ResponseData";
  207.  
  208.         // "Credit/Procurement Card Check" constants
  209.         protected static final String CHECK_CARD = "checkCardNumber";
  210.         protected static final String CARD_NUMBER = "CardNumber";
  211.         protected static final String IS_CARD_VALID = "isCardValid";
  212.  
  213.         //-------------------------------------------------------------------------
  214.         // Variables - Protected - Adapter Properties
  215.         //-------------------------------------------------------------------------
  216.  
  217.         /**
  218.         * Component to which communication will go to.  This corresponds to the
  219.         * MQAK Application in the directory.
  220.         */
  221.         protected String destinationcomponent;
  222.  
  223.         /**
  224.         * The protocol and version that will be set for all outgoing messages.
  225.         */
  226.         protected String protocolandversion;
  227.  
  228.         /**
  229.         * BodyCategory used for messaging.  Set to:
  230.         * "DEFAULT" - process all messages. (default)
  231.         * <specific protocol&version> - use defined specific protocol and version.
  232.         */
  233.         protected String msgbodycategory;
  234.  
  235.         /**
  236.         * Component which identifies the gateway.  This corresponds to the MQAK
  237.         * Application in the directory.
  238.         */
  239.         protected String gatewaycomponent;
  240.  
  241.         /**
  242.         * Enable Debug/Trace output.
  243.         */
  244.         protected boolean enabletrace;
  245.  
  246.         /**
  247.         * Explicit commit required for all Send & Receive opeartions.
  248.         */
  249.         protected boolean explicitcommit;
  250.  
  251.         /**
  252.         * Adapt to messages that are sent without MQSeries CorrelationID being set
  253.         * to the proper Extricity Process ID value.  (This feature allows for
  254.         * interoperability with older versions of MQAO).
  255.         */
  256.         protected boolean adaptmessages;
  257.  
  258.         /**
  259.         * URL for access to ePIC java classes.
  260.         */
  261.         protected String epicurl;
  262.  
  263.         /**
  264.         * Application ID used for access to STATE queues.  DEFAULT = use value of
  265.         * GatewayComponent.
  266.         */
  267.         protected String internalappid;
  268.  
  269.         /**
  270.         * URL for access to MQAK java classes.
  271.         */
  272.         protected String mqakurl;
  273.  
  274.         /**
  275.         * URL for access to partner java classes.
  276.         */
  277.         protected String partnerurl;
  278.  
  279.    //-------------------------------------------------------------------------
  280.    // Constructors
  281.    //-------------------------------------------------------------------------
  282.  
  283.    /**
  284.    * Default constructor.
  285.    */
  286.    public MQAOAdapterImp()
  287.    {
  288.          super();
  289.    }
  290.  
  291.  
  292.    //-------------------------------------------------------------------------
  293.    // Methods - Lifecycle
  294.    //-------------------------------------------------------------------------
  295.  
  296.    /**
  297.    * Called when the adapter is started for the first time.
  298.    *
  299.    * @param context Holds Adapter specific properties, may be empty.
  300.    *
  301.    * @exception ISException Thrown if there is a problem starting the
  302.    * Adapter.
  303.    */
  304.    public void startup(AdapterContext context)
  305.          throws ISException {
  306.  
  307.          // load the properties from the adapter
  308.          loadAdapterProperties(context);
  309.  
  310.          try
  311.          {
  312.                 URL[] mqakURL = new URL[]{new URL(mqakurl),new URL(partnerurl),new URL(epicurl)};
  313.                 ExtURLClassLoader theLoader = new ExtURLClassLoader(mqakURL,this.getClass().getClassLoader());
  314.  
  315.                 theLoader._DEBUG = enabletrace;
  316.                 // Load the helper using the special class loader
  317.                 helper = (MQAOAdapterHelperInt)theLoader.loadClass("com.ibm.extricity.adapters.mqseries.mqak.MQAOAdapterHelper").newInstance();
  318.                 if(helper == null)
  319.                 {
  320.                    System.out.println("--->Helper is: null");
  321.                    throw new ISException("Could not load helper class: com.ibm.extricity.adapters.mqseries.mqak.MQAOAdapterHelper");
  322.                 }
  323.                 else
  324.                 {
  325.                    System.out.println("--->Helper is: "+helper.toString());
  326.                 }
  327.          }
  328.          catch(Exception e)
  329.          {
  330.                 System.out.println("--->Exception when loading: "+e.toString());
  331.                 e.printStackTrace();
  332.                 throw new ISException(e.toString());
  333.          }
  334.  
  335.          // add startup code here
  336.          helper.startup(gatewaycomponent,internalappid,destinationcomponent,protocolandversion,msgbodycategory,exceptionlogext,enabletrace,explicitcommit,adaptmessages,recvpollrate);
  337.    }
  338.  
  339.  
  340.    /**
  341.    * Called when the adapter is stopped. Allows the adapter to perform any
  342.    * necessary cleanup work.  Please note that the method signature
  343.    * contains the <code>throws ISException</code> clause only for
  344.    * backward compatibility reasons.  Adapter developer should handle
  345.    * all error cases in shutdown, and should not throw
  346.    * <code>ISException</code> or
  347.    * <code>EndSystemNotAvailableException</code>.
  348.    *
  349.    * @param context Holds Adapter specific properties, may be empty.
  350.    *
  351.    * @exception ISException Thrown if there is a problem starting the
  352.    * Adapter.
  353.    */
  354.    public void shutdown(AdapterContext context)
  355.          throws ISException {
  356.  
  357.          // add shutdown code here
  358.          helper.shutdown();
  359.    }
  360.  
  361.  
  362. //-------------------------------------------------------------------------
  363. // Methods - Execution
  364. //-------------------------------------------------------------------------
  365.  
  366. /**
  367. * Called to execute a specific operation. This method must be overridden
  368. * by all Adapter subclasses.
  369. *
  370. * This method can be called by multiple threads.
  371. *
  372. * If the adapter subclass supports transactions, the transaction will be
  373. * either commited after this method returns or rolled back if an exception
  374. * is thrown. If the Adapter subclass does not support transactions, it
  375. * must either commit or rollback all stateful actions performed during
  376. * execution of this method.
  377. *
  378. * @param context Runtime context for the operation. Container for
  379. * operation inputs and outputs (output values must be added by the Adapter
  380. * subclass implementation).
  381. *
  382. * @exception ISException Thrown if there is an error during execution.
  383. */
  384. public void execute(OperationContext context) throws ISException {
  385.         int operation_type_id;
  386.         String operation_id;
  387.  
  388.         operation_type_id = context.getOperationTypeID();
  389.         operation_id = context.getOperationID();
  390.  
  391.         switch (operation_type_id) {
  392.                 case OperationContext.GET :
  393.                         throw new ISException(UNKNOWN_OPERATION_ID + ": " + operation_id);
  394.                         //break;
  395.  
  396.                 case OperationContext.POST :
  397.                         throw new ISException(UNKNOWN_OPERATION_ID + ": " + operation_id);
  398.                         //break;
  399.  
  400.                 case OperationContext.ADVANCED :
  401.                         if (operation_id.equals(COMMIT)) {
  402.                                 executeCommit(context);
  403.                         } else
  404.                                 if (operation_id.equals(RECVXMLMSG)) {
  405.                                         executeRecvXMLMsg(context);
  406.                                 } else
  407.                                         if (operation_id.equals(SENDXMLMSG)) {
  408.                                                 executeSendXMLMsg(context);
  409.                                         } else if(operation_id.equals(SENDXMLMSGWCARD)){
  410.                                                 executeSendXMLMsgWithCardSuffix(context);
  411.                                         } else
  412.                                                 if (operation_id.equals(GETPUBLICPROCESSID)) {
  413.                                                         executeGetPublicProcessID(context);
  414.                                                 } else
  415.                                                         if (operation_id.equals(GETPROCESSDATA)) {
  416.                                                                 executeGetProcessData(context);
  417.                                                         } else
  418.                                                                 if (operation_id.equals(SETPROCESSDATA)) {
  419.                                                                         executeSetProcessData(context);
  420.                                                                 } else
  421.                                                                         if (operation_id.equals(DELPROCESSDATA)) {
  422.                                                                                 executeDelProcessData(context);
  423.                                                                         } else
  424.                                                                                 if (operation_id.equals(LOGEXCEPTION)) {
  425.                                                                                         executeLogException(context);
  426.                                                                                 } else
  427.                                                                                         if (operation_id.equals(AUDIT_LOG)) {
  428.                                                                                                 executeAuditLog(context);
  429.                                                                                         } else
  430.                                                                                                 if (operation_id.equals(BUYER_AUTHENTICATION)) {
  431.                                                                                                         executeBuyerAuthentication(context);
  432.                                                                                                 } else
  433.                                                                                                         if (operation_id.equals(GET_ADMIN_EMAIL_ADDR)) {
  434.                                                                                                                 executeGetAdminUserEmailAddr(context);
  435.                                                                                                         } else
  436.                                                                                                                 if (operation_id.equals(READPROPERTIES)) {
  437.                                                                                                                         executeReadProperties(context);
  438.                                                                                                                 } else
  439.                                                                                                                         if (operation_id.equals(CHECK_CARD)) {
  440.                                                                                                                                 executeCardCheck(context);
  441.                                                                                                                         } else
  442.                                                                                                                                 if (operation_id.equals(ENCRYPTCARD)) {
  443.                                                                                                                                         executeEncryptPCardNumber(context);
  444.                                                                                                                                 } else
  445.                                                                                                                                         if (operation_id.substring(0, 4).equals(RECVPREFIX)) {
  446.                                                                                                                                                 executeRecvBO(context);
  447.                                                                                                                                         } else
  448.                                                                                                                                                 if (operation_id.substring(0, 4).equals(SENDPREFIX)) {
  449.                                                                                                                                                         executeSendBO(context);
  450.                                                                                                                                                 } else
  451.                                                                                                                                                         if (operation_id.equals(SENDMAIL)) {
  452.                                                                                                                                                                 executeSendMail(context);
  453.                                                                                                                                                         } else {
  454.                                                                                                                                                                 throw new ISException(UNKNOWN_OPERATION_ID + ": " + operation_id);
  455.                                                                                                                                                         }
  456.                         break;
  457.  
  458.                 default :
  459.                         throw new ISException(UNKNOWN_OPERATION_TYPE_ID + ": " + operation_type_id);
  460.         }
  461. }
  462.  
  463.  
  464.  
  465. /**
  466.    * If this method is multi-thread safe, you can remove the synchronized
  467.    * modifier to improve performance.
  468.    */
  469. protected void executeSendXMLMsg(OperationContext context) throws ISException {
  470.         String input_var_processid;
  471.         Element input_bo_msghdr;
  472.         String input_var_msgxml;
  473.         String output_var_commitcontext = null;
  474.         //Element output_bo_commitcontext;
  475.         Element output_bo_opstatus;
  476.  
  477.         // load the inputs from the OperationContext
  478.         input_var_processid = context.getInputVariant(SENDXMLMSG_INPUT_PROCESSID);
  479.         input_bo_msghdr = context.getInputBOElement(SENDXMLMSG_INPUT_MSGHDR);
  480.         input_var_msgxml = context.getInputVariant(SENDXMLMSG_INPUT_MSGXML);
  481.         if (_DEBUG) {
  482.                 System.out.println(
  483.                         "========== executeSendXMLMsg =========\n  input_var_processid="
  484.                                 + input_var_processid
  485.                                 + "\n  input_bo_msghdr="
  486.                                 + input_bo_msghdr.toString(true)
  487.                                 + "\n  input_var_msgxml="
  488.                                 + input_var_msgxml);
  489.         }
  490.         // create the output Business Objects
  491.         //output_bo_commitcontext = context.createOutputBOElement(SENDXMLMSG_OUTPUT_COMMITCONTEXT);
  492.         output_bo_opstatus = context.createOutputBOElement(SENDXMLMSG_OUTPUT_OPSTATUS);
  493.         output_bo_opstatus.setData("result", "success");
  494.  
  495.         // add execute code here
  496.         try {
  497.                 output_var_commitcontext =
  498.                         helper.executeSendMsg(
  499.                                 input_var_processid,
  500.                                 input_bo_msghdr,
  501.                                 input_var_msgxml,
  502.                                 output_bo_opstatus,
  503.                                 context.getExecutionID().getDisplayName());
  504.         } catch (Exception e) {
  505.                 if (_DEBUG) {
  506.                         System.out.println("\n  Error during executeSendXMLMsg: " + e.getMessage());
  507.                         System.out.println(
  508.                                 "\n  An Exception has been logged onto Solution Manager, processId= "
  509.                                         + input_var_processid);
  510.                 }
  511.                 output_bo_opstatus.setData("result", "failed");
  512.         }
  513.         //helper.executeSendMsg(input_var_processid,input_bo_msghdr,input_var_msgxml,output_bo_commitcontext,output_bo_opstatus,context.getExecutionID().getDisplayName());
  514.  
  515.         // store the output Variants in the OperationContext
  516.         context.setOutputVariant(
  517.                 SENDXMLMSG_OUTPUT_COMMITCONTEXT,
  518.                 output_var_commitcontext);
  519.         if (_DEBUG) {
  520.                 System.out.println("\n  output_var_commitcontext=" + output_var_commitcontext +
  521.                 //System.out.println("\n  output_bo_commitcontext="+output_bo_commitcontext.toString(true)+
  522.                 "\n  output_bo_opstatus="
  523.                         + output_bo_opstatus.toString(true)
  524.                         + "\n==========================================");
  525.         }
  526. }
  527.  
  528.  
  529. /**
  530.    * If this method is multi-thread safe, you can remove the synchronized
  531.    * modifier to improve performance.
  532.    */
  533. protected void executeRecvXMLMsg(OperationContext context) throws ISException {
  534.         String input_var_processid;
  535.         String input_var_msgid;
  536.         String input_var_peekonly;
  537.         Element input_bo_msgfilter;
  538.         Element output_bo_msghdr;
  539.         String output_var_msgxml = null;
  540.         String output_var_commitcontext = null;
  541.         //Element output_bo_commitcontext;
  542.         Element output_bo_opstatus;
  543.         boolean peekonly = false;
  544.  
  545.         // load the inputs from the OperationContext
  546.         input_var_processid = context.getInputVariant(RECVXMLMSG_INPUT_PROCESSID);
  547.         input_var_msgid = context.getInputVariant(RECVXMLMSG_INPUT_MSGID);
  548.         input_var_peekonly = context.getInputVariant(RECVXMLMSG_INPUT_PEEKONLY);
  549.         if (input_var_peekonly != null) {
  550.                 peekonly =
  551.                         (input_var_peekonly.compareToIgnoreCase("yes") == 0)
  552.                                 || (input_var_peekonly.compareToIgnoreCase("true") == 0)
  553.                                 || (input_var_peekonly.compareToIgnoreCase("1") == 0);
  554.         }
  555.         try {
  556.                 input_bo_msgfilter = context.getInputBOElement(RECVXMLMSG_INPUT_MSGFILTER);
  557.         } catch (Exception e) {
  558.                 input_bo_msgfilter = null;
  559.         }
  560.         if (_DEBUG) {
  561.                 System.out.println(
  562.                         "========== executeRecvXMLMsg =========\n  input_var_processid="
  563.                                 + input_var_processid
  564.                                 + "\n  input_var_msgid="
  565.                                 + input_var_msgid);
  566.                 if (input_bo_msgfilter == null) {
  567.                         System.out.println("  input_bo_msgfilter=null");
  568.                 } else {
  569.                         System.out.println("  input_bo_msgfilter=" + input_bo_msgfilter.toString(true));
  570.                 }
  571.         }
  572.         // create the output Business Objects
  573.         output_bo_msghdr = context.createOutputBOElement(RECVXMLMSG_OUTPUT_MSGHDR);
  574.         //output_bo_commitcontext = context.createOutputBOElement(RECVXMLMSG_OUTPUT_COMMITCONTEXT);
  575.         output_bo_opstatus = context.createOutputBOElement(RECVXMLMSG_OUTPUT_OPSTATUS);
  576.         output_bo_opstatus.setData("result", "success");
  577.  
  578.         // add execute code here
  579.         try {
  580.                 ProcessDataInt pd =
  581.                         helper.executeRecvMsg(
  582.                                 input_var_processid,
  583.                                 input_var_msgid,
  584.                                 peekonly,
  585.                                 input_bo_msgfilter,
  586.                                 output_bo_msghdr,
  587.                                 output_bo_opstatus);
  588.  
  589.                 if ((pd.getMsgXML() == null) && (recvpollrate > 0)) {
  590.                         context.requestRetry(recvpollrate);
  591.                         if (_DEBUG) {
  592.                                 System.out.println(
  593.                                         "\n  WAITING FOR MESSAGE" + "\n==========================================");
  594.                         }
  595.                 } else {
  596.                         // set the value of the output Variants
  597.                         output_var_msgxml = pd.getMsgXML();
  598.                         output_var_commitcontext = pd.getCommitContext();
  599.                         //output_var_msgxml = helper.executeRecvMsg(input_var_processid,input_var_msgid,peekonly,input_bo_msgfilter,
  600.                         //                 output_bo_msghdr,output_bo_commitcontext,output_bo_opstatus);
  601.  
  602.                         // store the output Variants in the OperationContext
  603.                         context.setOutputVariant(
  604.                                 RECVXMLMSG_OUTPUT_COMMITCONTEXT,
  605.                                 output_var_commitcontext);
  606.                         context.setOutputVariant(RECVXMLMSG_OUTPUT_MSGXML, output_var_msgxml);
  607.  
  608.                 }
  609.         } catch (Exception e) {
  610.                 if (_DEBUG) {
  611.                         System.out.println("\n  Error during executeRecvXMLMsg: " + e.getMessage());
  612.                         System.out.println(
  613.                                 "\n  An Exception has been logged onto Solution Manager, processId= "
  614.                                         + input_var_processid);
  615.                 }
  616.                 output_bo_opstatus.setData("result", "failed");
  617.         }
  618.         if (_DEBUG) {
  619.                 System.out
  620.                         .println(
  621.                                 "\n  output_bo_msghdr="
  622.                                 + output_bo_msghdr.toString(true)
  623.                                 + "\n  output_var_msgxml="
  624.                                 + output_var_msgxml
  625.                                 + "\n  output_var_commitcontext="
  626.                                 + output_var_commitcontext
  627.                                 +"\n  output_bo_opstatus="
  628.                         + output_bo_opstatus.toString(true)
  629.                         + "\n==========================================");
  630.         }
  631. }
  632.  
  633.  
  634.    /**
  635.    * Called when execute has already been called for this operation, but
  636.    * execution results were inconclusive.
  637.    *
  638.    * Operation output values must be set in the context.The multi-thread and
  639.    * transactional issues for execute() are the same for reExecute().
  640.    *
  641.    * @param context Runtime context for the operation. Container for
  642.    * operation inputs and outputs (output values must be added by the Adapter
  643.    * subclass implementation).
  644.    *
  645.    * @exception ISException Thrown if there is an error re-executing the
  646.    * operation.
  647.    */
  648.    public void reExecute(OperationContext context)
  649.          throws ISException {
  650.  
  651.          // add reExecute code here
  652.          execute(context);
  653.    }
  654.  
  655.  
  656.    //-------------------------------------------------------------------------
  657.    // Methods - Runtime - Event Production
  658.    //-------------------------------------------------------------------------
  659.  
  660.    /**
  661.    * Called to check for new IS events. Produced events must be added to the
  662.    * EventContext.
  663.    *
  664.    * @param context Context for the check call, functions as container for
  665.    * produced events.
  666.    *
  667.    * @exception ISException Thrown if there is an error checking for the
  668.    * event.
  669.    */
  670.    public final void checkForEvents(EventContext context)
  671.          throws ISException {
  672.  
  673.          if(_DEBUG)
  674.          {
  675.                 System.out.println("========== checkForEvents =========");
  676.          }
  677.          // add event production code here
  678.          helper.checkForEvents(context);
  679.          if(_DEBUG)
  680.          {
  681.                 System.out.println("\n==========================================");
  682.          }
  683.    }
  684.  
  685.  
  686.    //-------------------------------------------------------------------------
  687.    // Methods - Private
  688.    //-------------------------------------------------------------------------
  689.  
  690.    /**
  691.    * Loads values for declared properties from the AdapterContext.
  692.    */
  693.    private void loadAdapterProperties(AdapterContext context)
  694.          throws ISException {
  695.  
  696.          if (context == null) {
  697.            return;
  698.          }
  699.  
  700.          enabletrace = context.getPropertyAsBoolean(PROP_ENABLETRACE);
  701.          _DEBUG = enabletrace;
  702.          explicitcommit = context.getPropertyAsBoolean(PROP_EXPLICITCOMMIT);
  703.          destinationcomponent = context.getPropertyAsString(PROP_DESTINATIONCOMPONENT);
  704.          protocolandversion = context.getPropertyAsString(PROP_PROTOCOLANDVERSION);
  705.          gatewaycomponent = context.getPropertyAsString(PROP_GATEWAYCOMPONENT);
  706.          if (context.isPropertyBound(PROP_INTERNALAPPID))
  707.          {
  708.            internalappid = context.getPropertyAsString(PROP_INTERNALAPPID);
  709.            if(internalappid.compareTo("DEFAULT") == 0)
  710.            {
  711.              internalappid = gatewaycomponent;
  712.            }
  713.          }
  714.          else
  715.          {
  716.            internalappid = gatewaycomponent;
  717.          }
  718.  
  719.          if(context.isPropertyBound(PROP_EXCEPTIONLOGEXT))
  720.          {
  721.            exceptionlogext = context.getPropertyAsString(PROP_EXCEPTIONLOGEXT);
  722.          }
  723.          else
  724.          {
  725.            exceptionlogext = null;
  726.          }
  727.  
  728.          partnerurl = context.getPropertyAsString(PROP_PARTNERURL);
  729.          mqakurl = context.getPropertyAsString(PROP_MQAKURL);
  730.          epicurl = context.getPropertyAsString(PROP_EPICURL);
  731.          adaptmessages = context.getPropertyAsBoolean(PROP_ADAPTMESSAGES);
  732.          recvpollrate = context.getPropertyAsInt(PROP_RECVPOLLRATE);
  733.  
  734.          if (context.isPropertyBound(PROP_MSGBODYCATEGORY))
  735.          {
  736.            msgbodycategory = context.getPropertyAsString(PROP_MSGBODYCATEGORY);
  737.          }
  738.          else
  739.          {
  740.            msgbodycategory = "DEFAULT";
  741.          }
  742.          if(_DEBUG)
  743.          {
  744.                 System.out.println("========== loadAdapterProperties =========\n  explicitcommit="+explicitcommit+
  745.                                 "\n  destinationcomponent="+destinationcomponent+
  746.                                 "\n  protocolandversion="+protocolandversion+
  747.                                 "\n  gatewaycomponent="+gatewaycomponent+
  748.                                 "\n  internalappid="+internalappid+
  749.                                 "\n  msgbodycategory="+msgbodycategory+
  750.                                 "\n  adaptmessages="+adaptmessages+
  751.                                 "\n  exceptionlogext="+exceptionlogext+
  752.                                 "\n  explicitcommit="+explicitcommit+
  753.                                 "\n  recvpollrate="+recvpollrate+
  754.                                 "\n  partnerurl="+partnerurl+
  755.                                 "\n  mqakurl="+mqakurl+
  756.                                 "\n  epicurl="+epicurl+
  757.                                 "\n==========================================");
  758.  
  759.          }
  760.    }
  761.  
  762.  
  763.    /**
  764.    * simply throws the <code>EndSystemNotAvailableException</code>.  Call
  765.    * this method when connection to the end system is lost.
  766.    *
  767.    * @throws EndSystemNotAvailableException always
  768.    */
  769.    private void endSystemNotAvailable()
  770.          throws EndSystemNotAvailableException {
  771.          throw new EndSystemNotAvailableException();
  772.    }
  773.  
  774.  
  775.    /**
  776.    * simply throws the <code>EndSystemNotAvailableException</code>.  Call
  777.    * this method when connection to the end system is lost.
  778.    *
  779.    * @throws EndSystemNotAvailableException always
  780.    * @param message message for the exception
  781.    */
  782.    private void endSystemNotAvailable(String message)
  783.          throws EndSystemNotAvailableException {
  784.          throw new EndSystemNotAvailableException(message);
  785.    }
  786.  
  787.  
  788.    /**
  789.    * simply throws the <code>EndSystemNotAvailableException</code>.  Call
  790.    * this method when connection to the end system is lost.
  791.    *
  792.    * @throws EndSystemNotAvailableException always
  793.    * @param t nested exception
  794.    */
  795.    private void endSystemNotAvailable(Throwable t)
  796.          throws EndSystemNotAvailableException {
  797.          throw new EndSystemNotAvailableException(t);
  798.    }
  799.  
  800.  
  801.    /**
  802.    * simply throws the <code>EndSystemNotAvailableException</code>.  Call
  803.    * this method when connection to the end system is lost.
  804.    *
  805.    * @throws EndSystemNotAvailableException always
  806.    * @param message message for the exception
  807.    * @param t nested exception
  808.    */
  809.    private void endSystemNotAvailable(String message, Throwable t)
  810.          throws EndSystemNotAvailableException {
  811.          throw new EndSystemNotAvailableException(message, t);
  812.    }
  813.  
  814.  
  815. /**
  816.    * If this method is multi-thread safe, you can remove the synchronized
  817.    * modifier to improve performance.
  818.    */
  819. protected void executeCommit(OperationContext context) throws ISException {
  820.         String input_var_processid;
  821.         String input_var_commitcontext;
  822.         //Element input_bo_commitcontext;
  823.         Element output_bo_opstatus;
  824.  
  825.         // load the inputs from the OperationContext
  826.         input_var_processid = context.getInputVariant(COMMIT_INPUT_PROCESSID);
  827.         input_var_commitcontext = context.getInputVariant(COMMIT_INPUT_COMMITCONTEXT);
  828.         //input_bo_commitcontext = context.getInputBOElement(COMMIT_INPUT_COMMITCONTEXT);
  829.         if (_DEBUG) {
  830.                 System.out.println(
  831.                         "========== executeCommit =========\n  input_var_processid="
  832.                                 + input_var_processid
  833.                                 + "\n  input_var_commitcontext="
  834.                                 + input_var_commitcontext);
  835.                 //System.out.println("========== executeCommit =========\n  input_var_processid="+input_var_processid+
  836.                 //         "\n  input_bo_commitcontext="+input_bo_commitcontext.toString(true));
  837.         }
  838.         // create the output Business Objects
  839.         output_bo_opstatus = context.createOutputBOElement(COMMIT_OUTPUT_OPSTATUS);
  840.         output_bo_opstatus.setData("result", "success");
  841.  
  842.         // add execute code here
  843.         try {
  844.                 helper.executeCommit(
  845.                         input_var_processid,
  846.                         input_var_commitcontext,
  847.                         output_bo_opstatus);
  848.                 //helper.executeCommit(input_var_processid,input_bo_commitcontext,output_bo_opstatus);
  849.         } catch (Exception e) {
  850.                 if (_DEBUG) {
  851.                         System.out.println(
  852.                                 "\n  Error during executeCommit: "+ e.getMessage());
  853.                         System.out.println(
  854.                                 "\n  An Exception has been logged onto Solution Manager, processId= "+ input_var_processid);
  855.                 }
  856.                 output_bo_opstatus.setData("result", "failed");
  857.         }
  858.         if (_DEBUG) {
  859.                 System.out.println(
  860.                         "\n  output_bo_opstatus="
  861.                                 + output_bo_opstatus.toString(true)
  862.                                 + "\n==========================================");
  863.         }
  864. }
  865.  
  866.    /**
  867.    * Remove Data Associated with the Public Process.
  868.    */
  869.    protected void executeDelProcessData(OperationContext context)
  870.          throws ISException {
  871.          String input_var_processid;
  872.  
  873.          // load the inputs from the OperationContext
  874.          input_var_processid = context.getInputVariant(DELPROCESSDATA_INPUT_PROCESSID);
  875.  
  876.  
  877.          if(_DEBUG)
  878.          {
  879.                 System.out.println("========== executeDelProcessData =========\n  input_var_processid="+input_var_processid);
  880.          }
  881.          // add execute code here
  882.          try{
  883.          helper.executeDelProcessData(input_var_processid);
  884.          } catch (Exception e) {
  885.                 if (_DEBUG) {
  886.                         System.out.println(
  887.                                 "\n  Error during executeDelProcessData: "+ e.getMessage());
  888.                         System.out.println(
  889.                                 "\n  An Exception has been logged onto Solution Manager, processId= "+ input_var_processid);
  890.                 }
  891.         }
  892.          if(_DEBUG)
  893.          {
  894.                 System.out.println("\n==========================================");
  895.          }
  896.    }
  897.  
  898. /**
  899.    * Get Data Associated with the Public Process.
  900.    */
  901. protected void executeGetProcessData(OperationContext context)
  902.         throws ISException {
  903.         String input_var_processid;
  904.         String output_var_bocorrelationid = new String();
  905.         String output_var_tradingpartner = new String();
  906.         ProcessDataInt pd;
  907.  
  908.         // load the inputs from the OperationContext
  909.         input_var_processid = context.getInputVariant(GETPROCESSDATA_INPUT_PROCESSID);
  910.         if (_DEBUG) {
  911.                 System.out.println(
  912.                         "========== executeGetProcessData =========\n  input_var_processid="
  913.                                 + input_var_processid);
  914.         }
  915.         // add execute code here
  916.         try {
  917.                 pd = helper.executeGetProcessData(input_var_processid);
  918.                 // set the value of the output Variants
  919.                 output_var_bocorrelationid = pd.getBOCorrelationID();
  920.                 output_var_tradingpartner = pd.getTradingPartner();
  921.  
  922.                 // store the output Variants in the OperationContext
  923.                 context.setOutputVariant(
  924.                         GETPROCESSDATA_OUTPUT_BOCORRELATIONID,
  925.                         output_var_bocorrelationid);
  926.                 context.setOutputVariant(
  927.                         GETPROCESSDATA_OUTPUT_TRADINGPARTNER,
  928.                         output_var_tradingpartner);
  929.         } catch (Exception e) {
  930.                 if (_DEBUG) {
  931.                         System.out.println("\n  Error during executeGetProcessData: " + e.getMessage());
  932.                         System.out.println(
  933.                                 "\n  An Exception has been logged onto Solution Manager, processId= "
  934.                                         + input_var_processid);
  935.                 }
  936.  
  937.         }
  938.  
  939.         if (_DEBUG) {
  940.                 System.out.println(
  941.                         "\n  output_var_bocorrelationid="
  942.                                 + output_var_bocorrelationid
  943.                                 + "\n  output_var_tradingpartner="
  944.                                 + output_var_tradingpartner
  945.                                 + "\n==========================================");
  946.         }
  947. }
  948.  
  949.    /**
  950.    * Get the value of the PublicProcessID.
  951.    */
  952.    protected void executeGetPublicProcessID(OperationContext context)
  953.          throws ISException {
  954.          String output_var_publicprocessid = null;
  955.          Element output_bo_opstatus;
  956.  
  957.          if(_DEBUG)
  958.          {
  959.                 System.out.println("========== executeGetPublicProcessID =========");
  960.          }
  961.          // create the output Business Objects
  962.          output_bo_opstatus = context.createOutputBOElement(GETPUBLICPROCESSID_OUTPUT_OPSTATUS);
  963.          output_bo_opstatus.setData("result","success");
  964.  
  965.  
  966.  
  967.          // set the value of the output Variants
  968.          try{
  969.          output_var_publicprocessid = helper.executeGetPublicProcessID(context.getExecutionID().getPrivateProcessID(),output_bo_opstatus);
  970.          } catch (Exception e) {
  971.                 if (_DEBUG) {
  972.                         System.out.println(
  973.                                 "\n  Error during executeGetPublicProcessID: "+ e.getMessage());
  974.                 }
  975.                 output_bo_opstatus.setData("result", "failed");
  976.         }
  977.  
  978.  
  979.          // store the output Variants in the OperationContext
  980.          context.setOutputVariant(GETPUBLICPROCESSID_OUTPUT_PUBLICPROCESSID, output_var_publicprocessid);
  981.          if(_DEBUG)
  982.          {
  983.                 System.out.println("\n  output_var_publicprocessid="+output_var_publicprocessid+
  984.                                 "\n  output_bo_opstatus="+output_bo_opstatus.toString(true)+
  985.                                 "\n==========================================");
  986.          }
  987.    }
  988.  
  989.    /**
  990.    * If this method is multi-thread safe, you can remove the synchronized
  991.    * modifier to improve performance.
  992.    */
  993.    protected void executeRecvBO(OperationContext context)
  994.          throws ISException {
  995.          String input_var_processid;
  996.          String input_var_msgid;
  997.          String input_var_peekonly;
  998.          Element input_bo_msgfilter;
  999.          Element output_bo_msghdr;
  1000.          Element output_bo_msgbo;
  1001.          String output_var_commitcontext = null;
  1002.          //Element output_bo_commitcontext;
  1003.          Element output_bo_opstatus;
  1004.          boolean peekonly = false;
  1005.  
  1006.          // load the inputs from the OperationContext
  1007.          input_var_processid = context.getInputVariant(RECVBO_INPUT_PROCESSID);
  1008.          input_var_msgid = context.getInputVariant(RECVBO_INPUT_MSGID);
  1009.          input_var_peekonly = context.getInputVariant(RECVXMLMSG_INPUT_PEEKONLY);
  1010.          if(input_var_peekonly != null)
  1011.          {
  1012.                  peekonly = (input_var_peekonly.compareToIgnoreCase("yes") == 0) ||
  1013.                           (input_var_peekonly.compareToIgnoreCase("true") == 0) ||
  1014.                           (input_var_peekonly.compareToIgnoreCase("1") == 0);
  1015.          }
  1016.          try
  1017.          {
  1018.             input_bo_msgfilter = context.getInputBOElement(RECVBO_INPUT_MSGFILTER);
  1019.          }
  1020.          catch(Exception e)
  1021.          {
  1022.                 input_bo_msgfilter = null;
  1023.          }
  1024.          if(_DEBUG)
  1025.          {
  1026.                 System.out.println("========== executeRecvBO =========\n  input_var_processid="+input_var_processid+
  1027.                                 "\n  input_var_msgid="+input_var_msgid);
  1028.                 if(input_bo_msgfilter == null)
  1029.                 {
  1030.                    System.out.println("  input_bo_msgfilter=null");
  1031.                 }
  1032.                 else
  1033.                 {
  1034.                    System.out.println("  input_bo_msgfilter="+input_bo_msgfilter.toString(true));
  1035.                 }
  1036.          }
  1037.          // create the output Business Objects
  1038.          output_bo_msghdr = context.createOutputBOElement(RECVBO_OUTPUT_MSGHDR);
  1039.          output_bo_msgbo = context.createOutputBOElement(RECVBO_OUTPUT_MSGBO);
  1040.          //output_bo_commitcontext = context.createOutputBOElement(RECVBO_OUTPUT_COMMITCONTEXT);
  1041.          output_bo_opstatus = context.createOutputBOElement(RECVBO_OUTPUT_OPSTATUS);
  1042.          output_bo_opstatus.setData("result","success");
  1043.  
  1044.          // add execute code here
  1045.          try
  1046.          {
  1047.                 StringReader msgXML;
  1048.                 ProcessDataInt pd = helper.executeRecvMsg(input_var_processid,input_var_msgid,peekonly,input_bo_msgfilter,output_bo_msghdr,output_bo_opstatus);
  1049.  
  1050.                 if( (pd.getMsgXML() == null) && (recvpollrate > 0) )
  1051.                 {
  1052.                    context.requestRetry(recvpollrate);
  1053.                if(_DEBUG)
  1054.                {
  1055.                       System.out.println("\n  WAITING FOR MESSAGE"+
  1056.                                                  "\n==========================================");
  1057.                }
  1058.                 }
  1059.                 else
  1060.                 {
  1061.                    msgXML = new StringReader(pd.getMsgXML());
  1062.                    output_var_commitcontext = pd.getCommitContext();
  1063.                    //msgXML = new StringReader(helper.executeRecvMsg(input_var_processid,input_var_msgid,peekonly,input_bo_msgfilter,output_bo_msghdr,output_bo_commitcontext,output_bo_opstatus));
  1064.                    output_bo_msgbo.getBusinessObject().fromStream(msgXML);
  1065.  
  1066.                // store the output Variants in the OperationContext
  1067.                context.setOutputVariant(RECVBO_OUTPUT_COMMITCONTEXT, output_var_commitcontext);
  1068.                if(_DEBUG)
  1069.                {
  1070.                       System.out.println("\n  output_bo_msghdr="+output_bo_msghdr.toString(true)+
  1071.                                                  "\n  output_bo_msgbo="+output_bo_msgbo.toString(true)+
  1072.                                                  "\n  output_var_commitcontext="+output_var_commitcontext+
  1073.                                                  //"\n  output_bo_commitcontext="+output_bo_commitcontext.toString(true)+
  1074.                                                  "\n  output_bo_opstatus="+output_bo_opstatus.toString(true)+
  1075.                                                  "\n==========================================");
  1076.                }
  1077.                 }
  1078.          }
  1079.          catch(ISException e)
  1080.          {
  1081.                 throw e;
  1082.          }
  1083.          catch(Exception e)
  1084.          {
  1085.                 throw new ISException("executeRecvBO received exception: " + e.toString());
  1086.          }
  1087.    }
  1088.  
  1089.    /**
  1090.    * If this method is multi-thread safe, you can remove the synchronized
  1091.    * modifier to improve performance.
  1092.    */
  1093.    protected void executeSendBO(OperationContext context)
  1094.          throws ISException {
  1095.          String input_var_processid;
  1096.          Element input_bo_msghdr;
  1097.          Element input_bo_msgbo;
  1098.          String output_var_commitcontext = null;
  1099.          //Element output_bo_commitcontext;
  1100.          Element output_bo_opstatus;
  1101.  
  1102.          // load the inputs from the OperationContext
  1103.          input_var_processid = context.getInputVariant(SENDBO_INPUT_PROCESSID);
  1104.          input_bo_msghdr = context.getInputBOElement(SENDBO_INPUT_MSGHDR);
  1105.          input_bo_msgbo = context.getInputBOElement(SENDBO_INPUT_MSGBO);
  1106.          if(_DEBUG)
  1107.          {
  1108.                 System.out.println("========== executeSendBO =========\n  input_var_processid="+input_var_processid+
  1109.                                 "\n  input_bo_msghdr="+input_bo_msghdr.toString(true)+
  1110.                                 "\n  input_bo_msgbo="+input_bo_msgbo.toString(true));
  1111.          }
  1112.          // create the output Business Objects
  1113.          //output_bo_commitcontext = context.createOutputBOElement(SENDBO_OUTPUT_COMMITCONTEXT);
  1114.          output_bo_opstatus = context.createOutputBOElement(SENDBO_OUTPUT_OPSTATUS);
  1115.          output_bo_opstatus.setData("result","success");
  1116.  
  1117.          // add execute code here
  1118.          try
  1119.          {
  1120.                 StringWriter msgXML = new StringWriter();
  1121.  
  1122.                 input_bo_msgbo.getBusinessObject().toStream(msgXML);
  1123.                 output_var_commitcontext = helper.executeSendMsg(input_var_processid,input_bo_msghdr,msgXML.toString(),output_bo_opstatus,context.getExecutionID().getDisplayName());
  1124.                 //helper.executeSendMsg(input_var_processid,input_bo_msghdr,msgXML.toString(),output_bo_commitcontext,output_bo_opstatus,context.getExecutionID().getDisplayName());
  1125.          }
  1126.          catch(ISException e)
  1127.          {
  1128.                 throw e;
  1129.          }
  1130.          catch(Exception e)
  1131.          {
  1132.                 throw new ISException("executeSendBO received exception: " + e.toString());
  1133.          }
  1134.  
  1135.          // store the output Variants in the OperationContext
  1136.          context.setOutputVariant(SENDBO_OUTPUT_COMMITCONTEXT, output_var_commitcontext);
  1137.          if(_DEBUG)
  1138.          {
  1139.                 System.out.println("\n  output_var_commitcontext="+output_var_commitcontext+
  1140.                 //System.out.println("\n  output_bo_commitcontext="+output_bo_commitcontext.toString(true)+
  1141.                                 "\n  output_bo_opstatus="+output_bo_opstatus.toString(true)+
  1142.                                 "\n==========================================");
  1143.          }
  1144.    }
  1145.  
  1146.    /**
  1147.    * Set Data Associated with the Public Process.
  1148.    */
  1149.    protected void executeSetProcessData(OperationContext context)
  1150.          throws ISException {
  1151.          String input_var_processid;
  1152.          String input_var_bocorrelationid;
  1153.          String input_var_tradingpartner;
  1154.          ProcessData pd;
  1155.  
  1156.          // load the inputs from the OperationContext
  1157.          input_var_processid = context.getInputVariant(SETPROCESSDATA_INPUT_PROCESSID);
  1158.          input_var_bocorrelationid = context.getInputVariant(SETPROCESSDATA_INPUT_BOCORRELATIONID);
  1159.          input_var_tradingpartner = context.getInputVariant(SETPROCESSDATA_INPUT_TRADINGPARTNER);
  1160.          if(_DEBUG)
  1161.          {
  1162.                 System.out.println("========== executeSetProcessData =========\n  input_var_processid="+input_var_processid+
  1163.                                 "\n  input_var_bocorrelationid="+input_var_bocorrelationid+
  1164.                                 "\n  input_var_tradingpartner="+input_var_tradingpartner);
  1165.          }
  1166.          pd = new ProcessData(input_var_bocorrelationid,input_var_tradingpartner);
  1167.          // add execute code here
  1168.          helper.executeSetProcessData(input_var_processid,pd);
  1169.          if(_DEBUG)
  1170.          {
  1171.                 System.out.println("\n==========================================");
  1172.          }
  1173.    }
  1174.  
  1175. /**
  1176.         * If this method is multi-thread safe, you can remove the synchronized
  1177.         * modifier to improve performance.
  1178.         */
  1179. protected synchronized void executeLogException(OperationContext context)
  1180.         throws ISException {
  1181.         String input_var_subcomponent;
  1182.         String input_var_processid;
  1183.         String input_var_logmessage;
  1184.         String input_var_exceptionid;
  1185.         String input_var_processname;
  1186.         String input_var_extdata;
  1187.         Element output_bo_opstatus;
  1188.  
  1189.         // load the inputs from the OperationContext
  1190.         input_var_processid = context.getInputVariant(LOGEXCEPTION_INPUT_PROCESSID);
  1191.         input_var_subcomponent =
  1192.                 context.getInputVariant(LOGEXCEPTION_INPUT_SUBCOMPONENT);
  1193.         input_var_logmessage = context.getInputVariant(LOGEXCEPTION_INPUT_LOGMESSAGE);
  1194.         input_var_exceptionid = context.getInputVariant(LOGEXCEPTION_INPUT_EXCEPTIONID);
  1195.         input_var_processname = context.getInputVariant(LOGEXCEPTION_INPUT_PROCESSNAME);
  1196.         input_var_extdata = context.getInputVariant(LOGEXCEPTION_INPUT_EXTDATA);
  1197.         // create the output Business Objects
  1198.         output_bo_opstatus = context.createOutputBOElement(SENDXMLMSG_OUTPUT_OPSTATUS);
  1199.         output_bo_opstatus.setData("result", "success");
  1200.         if (_DEBUG) {
  1201.                 System.out.println(
  1202.                         "========== executeSendBO =========\n  input_var_processid="
  1203.                                 + input_var_processid
  1204.                                 + "\n  input_var_subcomponent="
  1205.                                 + input_var_subcomponent
  1206.                                 + "\n  input_var_logmessage="
  1207.                                 + input_var_logmessage
  1208.                                 + "\n  input_var_exceptionid="
  1209.                                 + input_var_exceptionid
  1210.                                 + "\n  input_var_processname="
  1211.                                 + input_var_processname
  1212.                                 + "\n  input_var_extdata="
  1213.                                 + input_var_extdata);
  1214.         }
  1215.  
  1216.         // add execute code here
  1217.         try {
  1218.                 helper.executeLogException(
  1219.                         input_var_processid,
  1220.                         input_var_subcomponent,
  1221.                         input_var_logmessage,
  1222.                         input_var_exceptionid,
  1223.                         input_var_processname,
  1224.                         input_var_extdata,
  1225.                         output_bo_opstatus);
  1226.         } catch (Exception e) {
  1227.                 if (_DEBUG) {
  1228.                         System.out.println(
  1229.                                 "\n  Error during executeLogException: " + e.getMessage());
  1230.                 }
  1231.                 output_bo_opstatus.setData("result", "failed");
  1232.         }
  1233.         if (_DEBUG) {
  1234.                 System.out.println("\n==========================================");
  1235.         }
  1236. }
  1237.  
  1238.         /**
  1239.          * Exception logging extension class name.  (Must implement the
  1240.          * MQAOExceptionLogExt)
  1241.          */
  1242.         protected String exceptionlogext;
  1243.         protected static final String LOGEXCEPTION_INPUT_EXTDATA = "ExtData";
  1244.         protected static final String PROP_EXCEPTIONLOGEXT = "ExceptionLogExt";
  1245.         protected static final String PROP_RECVPOLLRATE = "RecvPollRate";
  1246.         /**
  1247.          * Poll rate for receiving of messages.  Set to 0 for asynchronous message
  1248.          * reception - only works with PAM.
  1249.          */
  1250.         protected int recvpollrate;
  1251. /**
  1252.    * If this method is multi-thread safe, you can remove the synchronized
  1253.    * modifier to improve performance.
  1254.    */
  1255. protected void executeAuditLog(OperationContext context) throws ISException {
  1256.         String input_var_audit_content;
  1257.  
  1258.         //Element input_bo_commitcontext;
  1259.         Element output_bo_opstatus;
  1260.  
  1261.         // create the output Business Objects
  1262.         output_bo_opstatus = context.createOutputBOElement(AUDIT_OUTPUT_OPSTATUS);
  1263.  
  1264.         // load the inputs from the OperationContext
  1265.         input_var_audit_content = context.getInputVariant(AUDIT_LOG_CONTENT);
  1266.  
  1267.         if (_DEBUG) {
  1268.                 System.out.println(
  1269.                         "========== executeAuditLog =========\n  input_var_audit_content= "
  1270.                                 + input_var_audit_content);
  1271.  
  1272.         }
  1273.  
  1274.         //callding helper method to do audit logging
  1275.         helper.executeAuditLog(input_var_audit_content, output_bo_opstatus);
  1276.  
  1277.         if (_DEBUG) {
  1278.                 System.out.println(
  1279.                         "\n  output_bo_opstatus="
  1280.                                 + output_bo_opstatus.toString(true)
  1281.                                 + "\n==========================================");
  1282.         }
  1283. }
  1284. protected void executeBuyerAuthentication(OperationContext context)
  1285.         throws ISException {
  1286.         String input_var_buyerId;
  1287.  
  1288.         //Element input_bo_commitcontext;
  1289.         Element output_bo_opstatus;
  1290.  
  1291.         // load the inputs from the OperationContext
  1292.         input_var_buyerId = context.getInputVariant(BUYER_IDENTIFIER);
  1293.  
  1294.         if (_DEBUG) {
  1295.                 System.out.println(
  1296.                         "========== executeBuyerAuthentication =========\n  input_variant_buyer_identifier="
  1297.                                 + input_var_buyerId);
  1298.  
  1299.         }
  1300.  
  1301.         String base = "o=b2bgateway";
  1302.         String filter ="ePICTPId="+input_var_buyerId;
  1303.                 // create the output Business Objects
  1304.         output_bo_opstatus = context.createOutputBOElement(BUYER_AUTH_OUTPUT_OPSTATUS);
  1305.  
  1306.         helper.executeBuyerAuthentication(base, filter, output_bo_opstatus);
  1307.  
  1308.         if (_DEBUG) {
  1309.                 System.out.println(
  1310.                         "\n  output_bo_opstatus="
  1311.                                 + output_bo_opstatus.toString(true)
  1312.                                 + "\n==========================================");
  1313.         }
  1314. }
  1315. protected void executeEncryptPCardNumber(OperationContext context)
  1316.         throws ISException {
  1317.         if (_DEBUG) {
  1318.                 System.out.println("===============================");
  1319.                 System.out.println("Start executeEncryptPCardNumber \n");
  1320.         }
  1321.         String inputNumber = (String) context.getInput(PCARDNUM);
  1322.         Element output_bo_opstatus =
  1323.                 context.createOutputBOElement(ENCRYPT_OUTPUT_OPSTATUS);
  1324.  
  1325.         String outputNumber =
  1326.                 helper.executeEncryptPCard(inputNumber, output_bo_opstatus);
  1327.  
  1328.         context.setOutputVariant(CRPTONUM, outputNumber);
  1329.         if (_DEBUG) {
  1330.                 System.out.println(
  1331.                         "\n  outputNumber="
  1332.                                 + outputNumber
  1333.                                 + "\n  output_bo_opstatus="
  1334.                                 + output_bo_opstatus.toString(true)
  1335.                                 + "\n==========================================");
  1336.         }
  1337. }
  1338. private void executeReadProperties(OperationContext context) throws ISException{
  1339.          if(_DEBUG)
  1340.          {
  1341.                 System.out.println("========== executeReadProperties =========\n");
  1342.  
  1343.          }
  1344.          String processId = (String) context.getInput(PROCESS_ID);
  1345.          String baseFileName = (String) context.getInput(PROPERTY_FILENAME);
  1346.          String language = (String) context.getInput(LANG);
  1347.          String cntryCode = (String) context.getInput(COUNTRY_CODE);
  1348.          String respStatusId = (String) context.getInput(RESPONSE_STATUS);
  1349.  
  1350.         Vector resp = helper.executeReadResponseProperties(processId, baseFileName, language, cntryCode, respStatusId);
  1351.         if(resp != null){
  1352.  
  1353.         context.setOutputVariant(RESPONSE_CODE, (String)resp.elementAt(0));
  1354.         context.setOutputVariant(RESPONSE_TEXT,  (String)resp.elementAt(1));
  1355.         context.setOutputVariant(RESPONSE_DATA,  (String)resp.elementAt(2));
  1356.  
  1357.         }
  1358.         else{
  1359.         context.setOutputVariant(RESPONSE_CODE, "");
  1360.         context.setOutputVariant(RESPONSE_TEXT, "");
  1361.         context.setOutputVariant(RESPONSE_DATA, "");
  1362.  
  1363.                 }
  1364.  
  1365.          if(_DEBUG)
  1366.          {
  1367.                 System.out.println(resp.toString());
  1368.                 System.out.println("========== executeReadProperties =========\n");
  1369.          }
  1370.  
  1371. }
  1372.  
  1373.                                                                            /**
  1374.  * Insert the method's description here.
  1375.  * Creation date: (3/4/2002 10:45:11 AM)
  1376.  */
  1377. public void executeCardCheck(OperationContext context) throws ISException{
  1378.          Boolean isValid = Boolean.FALSE;
  1379.          if(_DEBUG)
  1380.          {
  1381.                 System.out.println("========= start executeCardCheck ================ \n");
  1382.          }
  1383.                 String cardNumber = (String) context.getInput(CARD_NUMBER);
  1384.                 if(cardNumber.length() > 0)
  1385.                 {
  1386.                         isValid = new Boolean(helper.executeCardCheck(cardNumber));
  1387.                         context.setOutputVariant(IS_CARD_VALID, isValid.toString());
  1388.                 }
  1389.  
  1390.          if(_DEBUG)
  1391.          {
  1392.                 System.out.println("========= end executeCardCheck ================ \n");
  1393.          }
  1394.  
  1395. }
  1396.    /* If this method is multi-thread safe, you can remove the synchronized
  1397.    * modifier to improve performance.
  1398.    */
  1399. protected void executeGetAdminUserEmailAddr(OperationContext context)
  1400.         throws ISException {
  1401.  
  1402.         //Element input_bo_commitcontext;
  1403.         Element output_bo_opstatus;
  1404.         // create the output Business Objects
  1405.         output_bo_opstatus = context.createOutputBOElement(ADMIN_EMAIL_OUTPUT_OPSTATUS);
  1406.  
  1407.         //output email address variant
  1408.         String output_email_addr = null;
  1409.  
  1410.         if (_DEBUG) {
  1411.                 System.out.println("========== executeGetAdminUserEmailAddr =========\n ");
  1412.  
  1413.         }
  1414.         String dn= "cn=Admin,ou=SystemAdministration,o=b2bgateway";
  1415.         String attrid = "mail";
  1416.  
  1417.         //calling helper method to retrieve the email address
  1418.         output_email_addr = helper.executeGetAdminUserEmailAddr(dn, attrid, output_bo_opstatus);
  1419.  
  1420.  
  1421.         context.setOutputVariant(ADMIN_EMAIL_ADDR, output_email_addr);
  1422.  
  1423.         if (_DEBUG) {
  1424.                 System.out.println(
  1425.                         "\n  output_bo_opstatus="
  1426.                                 + output_bo_opstatus.toString(true)
  1427.                                 + "\n output_email_addr= "
  1428.                                 + output_email_addr
  1429.                                 + "\n==========================================");
  1430.         }
  1431. }
  1432.         protected static final String ADMIN_EMAIL_OUTPUT_OPSTATUS = "OPStatus"; protected static final String AUDIT_OUTPUT_OPSTATUS = "OPStatus";       protected static final String BUYER_AUTH_OUTPUT_OPSTATUS = "OPStatus";  protected static final String ENCRYPT_OUTPUT_OPSTATUS = "OPStatus";   protected static final String MAILSERVER = "mailserver";   protected static final String PAM_CFG_PROPERTIES = "PAMConfig";   protected static final String PROCESS_ID = "ProcessID";   protected static final String SEND_MAIL_TYPE = "MessageType";   // "Send Mail" constants
  1433.    protected static final String SENDMAIL ="sendMail";/**
  1434.  * This method will send e-mail based on the message type.
  1435.  * Creation date: (3/6/2002 10:23:38 AM)
  1436.  * @param msgType java.lang.String
  1437.  */
  1438.  
  1439.  
  1440. public void executeSendMail(OperationContext context) throws ISException
  1441. {
  1442.         if(_DEBUG)
  1443.          {
  1444.                 System.out.println("========== executeSendMail =========\n");
  1445.          }
  1446.  
  1447.          //Element input_bo_commitcontext;
  1448.          Element output_bo_opstatus;
  1449.          String errorCode = "";
  1450.  
  1451.          String recipients = "";
  1452.          String sender = "";
  1453.          String subject = "";
  1454.          String msgText = "";
  1455.          java.util.ResourceBundle bundle;
  1456.  
  1457.          boolean sendResult = false;
  1458.  
  1459.          // retrieve type from context
  1460.          String msgType = (String) context.getInput(SEND_MAIL_TYPE);
  1461.          String processId = (String) context.getInput(PROCESS_ID);
  1462.  
  1463.          try{
  1464.  
  1465.                 // get property information
  1466.                 bundle = ResourceBundle.getBundle(PAM_CFG_PROPERTIES);
  1467.                 String mailserver = bundle.getString(MAILSERVER);
  1468.                 if(msgType.equalsIgnoreCase("LDAP_FAIL"))
  1469.                 {
  1470.                         // retrieve info from properties file
  1471.                         recipients = bundle.getString("LDAP_FAIL_ADMIN_LIST");
  1472.                         subject = bundle.getString("LDAP_FAIL_SUBJECT");
  1473.                         msgText = bundle.getString("LDAP_FAIL_TEXT");
  1474.                         sender = bundle.getString("sender");
  1475.  
  1476.                         // send the mail and record the results
  1477.                         sendResult = helper.executeSendMail(processId, mailserver, recipients, sender, subject, msgText);
  1478.                         errorCode = (sendResult) ? "success" : "fail";
  1479.                 }
  1480.         }catch(Exception e){
  1481.                 errorCode = "fail";
  1482.         }
  1483.  
  1484.          // create the output Business Objects
  1485.          output_bo_opstatus = context.createOutputBOElement(COMMIT_OUTPUT_OPSTATUS);
  1486.          output_bo_opstatus.setData("result",errorCode);
  1487.  
  1488.         if(_DEBUG)
  1489.          {
  1490.                 System.out.println("========== executeSendMail =========\n");
  1491.          }
  1492. }/**
  1493.  * Insert the method's description here.
  1494.  * Creation date: (3/13/2002 1:29:52 PM)
  1495.  * @param context com.extricity.adapter.api.OperationContext
  1496.  */
  1497. protected void executeSendXMLMsgWithCardSuffix(OperationContext context)
  1498.         throws ISException {
  1499.  
  1500.         String input_var_processid;
  1501.         Element input_bo_msghdr;
  1502.         String input_var_msgxml;
  1503.         String input_cardnum = null;
  1504.         String output_var_commitcontext = null;
  1505.         //Element output_bo_commitcontext;
  1506.         Element output_bo_opstatus;
  1507.  
  1508.         // load the inputs from the OperationContext
  1509.         input_var_processid = context.getInputVariant(SENDXMLMSG_INPUT_PROCESSID);
  1510.         input_bo_msghdr = context.getInputBOElement(SENDXMLMSG_INPUT_MSGHDR);
  1511.         input_var_msgxml = context.getInputVariant(SENDXMLMSG_INPUT_MSGXML);
  1512.         input_cardnum = context.getInputVariant(SENDXMLMSG_INPUT_CARDNUM);
  1513.  
  1514.         int i = input_var_msgxml.indexOf("</Payment>");
  1515.         String pre = input_var_msgxml.substring(0, i + 10);
  1516.         String post = input_var_msgxml.substring(i + 10);
  1517.         String middle =
  1518.                 SENDXML_EXTRINSIC_OPEN
  1519.                         + input_cardnum.substring(input_cardnum.length() - 4, input_cardnum.length())
  1520.                         + SENDXML_EXTRINSIC_CLOSE;
  1521.         String new_msgxml = pre + middle + post;
  1522.  
  1523.         input_var_msgxml = new_msgxml;
  1524.  
  1525.         if (_DEBUG) {
  1526.                 System.out.println(
  1527.                         "========== executeSendXMLMsgWithCardSuffix =========\n  input_var_processid="
  1528.                                 + input_var_processid
  1529.                                 + "\n  input_bo_msghdr="
  1530.                                 + input_bo_msghdr.toString(true)
  1531.                                 + "\n  input_var_msgxml="
  1532.                                 + input_var_msgxml);
  1533.         }
  1534.         // create the output Business Objects
  1535.         //output_bo_commitcontext = context.createOutputBOElement(SENDXMLMSG_OUTPUT_COMMITCONTEXT);
  1536.         output_bo_opstatus = context.createOutputBOElement(SENDXMLMSG_OUTPUT_OPSTATUS);
  1537.         output_bo_opstatus.setData("result", "success");
  1538.  
  1539.         // add execute code here
  1540.         try {
  1541.                 output_var_commitcontext =
  1542.                         helper.executeSendMsg(
  1543.                                 input_var_processid,
  1544.                                 input_bo_msghdr,
  1545.                                 input_var_msgxml,
  1546.                                 output_bo_opstatus,
  1547.                                 context.getExecutionID().getDisplayName());
  1548.                 //helper.executeSendMsg(input_var_processid,input_bo_msghdr,input_var_msgxml,output_bo_commitcontext,output_bo_opstatus,context.getExecutionID().getDisplayName());
  1549.         } catch (Exception e) {
  1550.                 if (_DEBUG) {
  1551.                         System.out.println("\n  Error during executeSendXMLMsgWithCardSuffix: " + e.getMessage());
  1552.                         System.out.println(
  1553.                                 "\n  An Exception has been logged onto Solution Manager, processId= "
  1554.                                         + input_var_processid);
  1555.                 }
  1556.                 output_bo_opstatus.setData("result", "failed");
  1557.         }
  1558.  
  1559.         // store the output Variants in the OperationContext
  1560.         context.setOutputVariant(
  1561.                 SENDXMLMSG_OUTPUT_COMMITCONTEXT,
  1562.                 output_var_commitcontext);
  1563.         if (_DEBUG) {
  1564.                 System.out.println("\n  output_var_commitcontext=" + output_var_commitcontext +
  1565.                 //System.out.println("\n  output_bo_commitcontext="+output_bo_commitcontext.toString(true)+
  1566.                 "\n  output_bo_opstatus="
  1567.                         + output_bo_opstatus.toString(true)
  1568.                         + "\n==========================================");
  1569.         }
  1570. }}
  1571.