package com.stc.connector.snalu62.api; import com.stc.connector.logging.LogFactory; import com.stc.connector.logging.Logger; import com.stc.connector.snalu62.exception.SNAApplicationException; /* * This is a sample class to implement the interface SNACustomerHandshake. * It implements a simple Accept_Conversation scenario for windows platform. */ public class SNACustomerHandshakeImplSampleAccept implements SNACustomerHandshake { public static final String version = "cvs $Revision: 1.1.2.1.2.2 $ $Date: 2005/11/10 21:40:15 $"; private Logger logger = LogFactory.getLogger("STC.eWay.SNALU62. " + getClass().getName()); private String logMsg; /** * Constructor * */ public SNACustomerHandshakeImplSampleAccept() { super(); } /** * @see com.stc.connector.snalu62.api.SNACustomerHandshake#startConversation (com.stc.connector.snalu62.api.SNACPICCalls) */ public void startConversation(SNACPICCalls cpic) throws SNAApplicationException { try { //do whatever checking logics before/after the following CPIC call on your desires cpic.cmsltp(); //do whatever checking logics before/after the following CPIC call on your desires cpic.cmaccp(); if (!cpic.getConversationAttributes().returnCodeIs(0) && // 0: CM_OK !cpic.getConversationAttributes().returnCodeIs(35)) { //35: CM_OPERATION_INCOMPLETE logMsg = "SNACustomerHandshakeImplSampleAccept.startConversation(): The return code is <" + cpic.getConversationAttributes().getReturnCode() + ">."; logger.error(logMsg); throw new SNAApplicationException(logMsg); } if (cpic.getConversationAttributes().returnCodeIs(35)) { //35: CM_OPERATION_INCOMPLETE logger.info("SNACustomerHandshakeImplSampleAccept.startConversation(): About to call cmwait ..."); //do whatever checking logics before/after the following CPIC call on your desires cpic.cmwait(); } if (!cpic.getConversationAttributes().returnCodeIs(0) || !cpic.getConversationAttributes().convReturnCodeIs(0)) { // 0: CM_OK logMsg = "SNACustomerHandshakeImplSampleAccept.startConversation(): The return_Code is <" + cpic.getConversationAttributes().getReturnCode() + "> and the conversation_Return_Code is <" + cpic.getConversationAttributes().getConvReturnCode() + ">. SNA conversation is not established."; logger.error(logMsg); throw new SNAApplicationException(logMsg); } //do whatever other logics on your desires here //... } catch (Exception e) { logMsg = "SNACustomerHandshakeImplSampleAccept.startConversation(): Failed. Got exception [" + e.toString() + "]."; logger.error(logMsg, e); throw new SNAApplicationException(logMsg, e); } } } |