package com.gpc.tams.comm.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Map; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.*; import com.gpc.client.common.ClientApplicationContext; import com.gpc.common.BOPISLogger; import java.util.regex.*; import com.gpc.common.Constants; import com.gpc.common.Profile; import com.gpc.common.exception.ApplicationException; import com.gpc.common.util.StringUtils; import com.gpc.common.util.azure.monitor.AzureLogger; import com.gpc.common.util.azure.monitor.AzureMonitorFeedLogRecord; import com.gpc.common.util.azure.monitor.LogType; import com.gpc.tams.comm.io.fields.output.formatter.BigDecimalFormatter; import com.gpc.valueobjects.customer.CustomerVO; import com.gpc.common.util.BooleanParser; import com.gpc.server.util.ConversionToVO; import com.gpc.valueobjects.catalog.VehicleVO; import com.gpc.valueobjects.common.AddressVO; import com.gpc.valueobjects.customer.*; import com.gpc.valueobjects.customer.db.CustomerBlanketPo; import com.gpc.valueobjects.customer.db.CustomerBlanketPoKey; import com.gpc.valueobjects.customer.db.TaxTableBracket; import com.gpc.valueobjects.customer.db.TaxTableBracketKey; import com.gpc.valueobjects.employee.EmployeeVO; import com.gpc.valueobjects.invoice.InvoiceDeliveryVO; import com.gpc.valueobjects.invoice.InvoiceVO; import com.gpc.valueobjects.invoice.TransportInvoiceInfoVO; import com.gpc.valueobjects.invoice.line.*; import com.gpc.valueobjects.message.MessageBaseVO; import com.gpc.valueobjects.ordering.BuyoutItemVO; import com.gpc.valueobjects.ordering.salesorder.SalesOrderDeliveryAddressVO; import com.gpc.valueobjects.ordering.salesorder.SalesOrderRecipientAddressVO; import com.gpc.valueobjects.price.PricesOutVO; import com.gpc.valueobjects.profile.InvoicingProfileVO; import com.gpc.valueobjects.profile.TenderTypeProfileVO; import com.gpc.valueobjects.tax.TaxInfoVO; import com.gpc.valueobjects.tax.TaxTableVO; import org.apache.commons.httpclient.NameValuePair; import com.gpc.common.util.LockableBoolean; import com.gpc.valueobjects.common.IDValuePairVO; import com.gpc.valueobjects.message.MessagePartVO; import com.gpc.valueobjects.message.MessageTextVO; import com.gpc.valueobjects.message.PhoneRoomStoreMessagesVO; import com.gpc.valueobjects.ordering.salesorder.SalesOrderVO; import com.gpc.valueobjects.profile.InventoryProfileVO; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.log4j.Logger; import com.gpc.valueobjects.invoice.SavedInvoiceQuoteVO; import javax.swing.*; public class TaapRouter { protected static final Logger logger = Logger.getLogger(TaapRouter.class); public static final String LOCATION = "location"; public static final String SALES_ORDER_ID = "salesOrderId"; public static final String REASON_CODE = "reasonCode"; public static final String INVOICE_TOTAL = "invoiceTotal"; public static final String NUMBER_OF_LINES = "numberOfLines"; public static final String REF_ORDER_STATUS = "refOrderStatusId"; public static final String INVOICED_BY_EMPID = "empId"; public static final String EMP_ID = "id"; public static final String SALESORDERVO_IPADDRESS = "salesorderIPAddress"; public static final String SAVED_INVOICEID = "invoiceId"; public static final String TYPE ="type"; public static final String DATEPARAM="date"; public static final String CUSTID="custId"; public static final String LANG="lang"; public static final String REF_ORDER_TYPE = "refOrderSubTypeId"; //phone room messages changes public static final String EMP_NUM = "employeeNum"; public static final String LOC = "loc"; public static final String PASSWORD = "password"; public static final String IP_ADDRESS = "currentStoreIp"; public static final String STORE_NUM = "currentStoreNum"; public static final String STORE_NAME = "storeName"; public static final String SERVING_STORE_IP_ADDRESS = "servingStoreIPAddress"; public static final String REF_TENDER_TYPE_ID = "refTenderTypeID"; //remote store message acknowledge changes public static final String ACK_EMP_NUM = "employeeNum"; public static final String MESSAGE_HEADER_ID = "messageHeaderId"; public static final String CUSTOMERNUM = "custNum"; public static final String EMPNUM = "empNum"; public static final String PARTNUM = "partNum"; public static final String LINEABBR = "lineAbbr"; public static final String MESSAGE_HEADER = "messageHeaderID"; public static final String LATEST = "latest"; protected static final int TAAP_SERVLET_PORT = 18080; private static final String TAAP_NOTIFY_NOL_WAR_NAME = "/taap/notificationmanagement"; private static final String TAAP_NOTIFY_NOL_ORDER_UPDATE_URI = "/notifyNolOrderUpdate"; private static final String TAAP_NOTIFY_NOL_ORDER_CANCEL_URI = "/notifyNolOrderCancel"; private static final String TAAP_NOTIFY_NOL_ORDER_PICKUP_URI = "/notifyNolOrderPickup"; private static final String TAAP_NOL_ORDER_PAYMENT_VALIDATION_URI = "/nolOrderPaymentValidation"; private static final String TAAP_NOTIFY_INTERSTORE_ACKNOWLEDGEMENT_URI= "/notifyInterstoreOrderAcknowledgement"; private static final String TAAP_NOTIFY_NOL_ORDER_UPDATE_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOTIFY_NOL_ORDER_UPDATE_URI; private static final String TAAP_NOTIFY_NOL_ORDER_CANCEL_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOTIFY_NOL_ORDER_CANCEL_URI; private static final String TAAP_NOTIFY_NOL_ORDER_PICKUP_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOTIFY_NOL_ORDER_PICKUP_URI; private static final String TAAP_NOL_ORDER_PAYMENT_VALIDATION_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOL_ORDER_PAYMENT_VALIDATION_URI; private static final String TAAP_NOTIFY_INTERSTORE_ACKNOWLEDGEMENT_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOTIFY_INTERSTORE_ACKNOWLEDGEMENT_URI; protected static String ipAddress = null; protected static String protocol = null; private static final int TAAP_HTTPS_MESSAGES_SERVLET_PORT = 18080; private static final String TAAP_MESSAGES_WAR_NAME = "/taap/messagemanagement"; private static final String TAAP_MESSAGE_RETRIEVAL_URI = "/retrieveStoreMessages"; private static final String TAAP_MESSAGE_ACKNOWLEDGE_URI = "/updateStoreMessagesHeader"; private static final String TAAP_SALESORDER_REFORDEESTATUS_URI = "/getRefOrderStatus"; private static final String TAAP_UPDATE_REFORDEESTATUS_URI = "/updateRefOrderStatus"; private static final String TAAP_MESSAGE_SPECIAL_ORDERED_URI = "/isMessageSpecialOrdered"; private static final String TAAP_SALES_ORDERED_DETAILS_URI = "/retrieveSalesOrderDetailsBySOId"; private static final String TAAP_MESSAGE_ALREADY_INVOICED_URI = "/isMessageInvoiced"; private static final String TAAP_UPDATE_INVOICEDBY_URI = "/updateInvoicedByEmpId"; private static final String TAAP_SPECIAL_ORDERED_PROCESSED_BY_URI = "/isSplOrderProcessedBy"; private static final String TAAP_EMPLOYEE_NUMBER_URI = "/retrieveEmployeeNum"; private static final String TAAP_EMPLOYEE_DETAIL_URI = "/retrieveEmployeeDetails"; private static final String TAAP_RESET_INVOICEDBY_URI = "/resetInvoicedByEmpID"; private static final String TAAP_INVENTORY_PROFILE_URI = "/inventoryProfile"; private static final String TAAP_UPDATE_SPECIAL_ORDER_BY_EMP_ID_URI = "/updateSplOrderedByEmpId"; private static final String TAAP_UNACKNOWLEDGE_COUNT_CHECK_URI = "/unAcknolwedgedMsgCountExit"; private static final String TAAP_MESSAGE_RETRIEVAL_BY_ID_URI = "/retrieveStoreMessagesById"; private static final String TAAP_SALESORDER_DELIVERYADDRESS_URI = "/retrieveSalesOrderDeliveryAddress"; private static final String TAAP_SALESORDER_RECIPIENTADDRESS_URI = "/retrieveSalesOrderRecipientAddressBySalesOrderId"; private static final String TAAP_UPDATE_MSGHEADER_URI = "/updateMessageHeader"; private static final String TAAP_UPDATE_MSGPART_URI = "/updateMessagePart"; private static final String TAPP_FIND_MSG_HDR_URI ="/retrieveMessageHeaderId"; private static final String TAAP_UPDATE_REF_ORDER_TYPE_URI = "/updateRefOrderType"; private static final String TAAP_MESSAGE_RETRIEVAL_BY_ID_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_MESSAGE_RETRIEVAL_BY_ID_URI; private static final String TAAP_EMPLOYEE_NUMBER_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_EMPLOYEE_NUMBER_URI; private static final String TAAP_EMPLOYEE_DETAILS_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_EMPLOYEE_DETAIL_URI; private static final String TAAP_UPDATE_SPECIAL_ORDER_BY_EMP_ID_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_UPDATE_SPECIAL_ORDER_BY_EMP_ID_URI; private static final String TAAP_UNACKNOWLEDGE_COUNT_CHECK_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_UNACKNOWLEDGE_COUNT_CHECK_URI; private static final String TAAP_MESSAGE_ALREADY_INVOICED_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_MESSAGE_ALREADY_INVOICED_URI; private static final String TAAP_SALES_ORDERED_DETAILS_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_SALES_ORDERED_DETAILS_URI; private static final String TAAP_MESSAGE_RETRIEVAL_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_MESSAGE_RETRIEVAL_URI; private static final String TAAP_MESSAGE_ACKNOWLEDGE_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_MESSAGE_ACKNOWLEDGE_URI; private static final String TAAP_SALESORDER_REFORDEESTATUS_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_SALESORDER_REFORDEESTATUS_URI; private static final String TAAP_UPDATE_REFORDERSTATUS_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_UPDATE_REFORDEESTATUS_URI; private static final String TAAP_UPDATE_INVOICEDBY_URL = TAAP_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_UPDATE_INVOICEDBY_URI; private static final String TAAP_RESET_INVOICEDBY_URL = TAAP_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_RESET_INVOICEDBY_URI; private static final String TAAP_INVENTORY_PROFILE_URL = TAAP_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_INVENTORY_PROFILE_URI; private static final String TAAP_SPECIAL_ORDERED_PROCESSED_BY_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_SPECIAL_ORDERED_PROCESSED_BY_URI; private static final String TAAP_MESSAGE_SPECIAL_ORDERED_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_MESSAGE_SPECIAL_ORDERED_URI; private static final String TAAP_SALESORDER_DELIVERYADDRESS_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_SALESORDER_DELIVERYADDRESS_URI; private static final String TAAP_SALESORDER_RECIPIENTADDRESS_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_SALESORDER_RECIPIENTADDRESS_URI; private static final String TAAP_UPDATE_MSGHEADER_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_UPDATE_MSGHEADER_URI; private static final String TAAP_UPDATE_MSGPART_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_UPDATE_MSGPART_URI; private static final String TAAP_FIND_MESSAGE_HEDER_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAPP_FIND_MSG_HDR_URI; private static final String TAAP_UPDATE_REF_ORDER_TYPE_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_UPDATE_REF_ORDER_TYPE_URI; private Map messageCategory; public Map getMessageCategory() { Map messageCategorymap = new HashMap(); messageCategorymap.put(1,"JOEI"); messageCategorymap.put(2,"Interstore"); messageCategorymap.put(3,"Integration messages"); messageCategorymap.put(4,"PROLink"); messageCategorymap.put(5,"NAPA Online"); messageCategorymap.put(6,"Direct Shipment Messages"); messageCategorymap.put(7,"Returns"); return messageCategorymap; } protected String getProtocol() { if (protocol == null) { ipAddress = System.getProperty("jboss.bind.address"); protocol = "http://"+ipAddress+":"; } return protocol; } protected void appendQueryParam( StringBuffer query, String name, String value ) { if ((value != null) && (value.length() > 0)) { query.append( URLEncoder.encode( name ) ); query.append( "=" ); query.append( URLEncoder.encode( value ) ); } } private void appendIntQueryParam( StringBuffer query, String name, Integer value ) { if ((value != null)) { query.append( URLEncoder.encode( name ) ); query.append( "=" ); query.append( value); } } public void notifyNolOrderUpdate(Map params) { BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "notifyNolOrderUpdate() starts"); String result = ""; URL notifyBopisOrderDeleteRequest = null; BufferedReader br = null; protocol = getProtocol(); try { final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, SALES_ORDER_ID, (String) params.get(SALES_ORDER_ID)); query.append("&"); appendQueryParam( query, LOCATION, (String) params.get(LOCATION)); notifyBopisOrderDeleteRequest = new URL(protocol + TAAP_NOTIFY_NOL_ORDER_UPDATE_URL + "?" + query.toString()); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.INFO, "notifyNolOrderUpdate: Calling: " + notifyBopisOrderDeleteRequest); br = new BufferedReader(new InputStreamReader(notifyBopisOrderDeleteRequest.openStream())); result = br.readLine(); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.INFO, "TAAP Query Result: [" + result + "]"); } catch (Throwable e) { logger.error("Error while notifying nol order ", e); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))) .errorBOPISLog("Error while notifying nol order ", new Exception(e)); } finally { if (br != null) { try { br.close(); } catch (IOException ex) { } } } BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "notifyNolOrderUpdate() ends"); } public boolean notifyNolOrderCancel(Map params) { BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "notifyNolOrderCancel() starts"); String result = ""; boolean notifySuccess = false; URL notifyNolOrderCancelRequest = null; BufferedReader br = null; if(!params.containsKey(SERVING_STORE_IP_ADDRESS)){ protocol = getProtocol(); }else{ //Means this is call center flow and ip address should be or serving store protocol = "http://"+(String) params.get(SERVING_STORE_IP_ADDRESS)+":"; } try { final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, SALES_ORDER_ID, (String) params.get(SALES_ORDER_ID)); query.append("&"); appendQueryParam( query, REASON_CODE, (String) params.get(REASON_CODE)); query.append("&"); appendQueryParam( query, LOCATION, (String) params.get(LOCATION)); notifyNolOrderCancelRequest = new URL(protocol + TAAP_NOTIFY_NOL_ORDER_CANCEL_URL + "?" + query.toString()); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.INFO, "notifyNolOrderCancelRequest: Calling: " + notifyNolOrderCancelRequest); br = new BufferedReader(new InputStreamReader(notifyNolOrderCancelRequest.openStream())); result = br.readLine(); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.INFO, "TAAP Query Result: [" + result + "]"); if(result.equalsIgnoreCase("true")){ notifySuccess = true; return notifySuccess; } } catch (Throwable e) { logger.error("Error while notifying NOL order cancel ", e); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))) .errorBOPISLog("Error while notifying NOL order cancel ", new Exception(e)); } finally { if (br != null) { try { br.close(); } catch (IOException ex) { } } protocol =null; } BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "notifyNolOrderCancel() ends"); return notifySuccess; } public boolean notifyNolOrderPickup(Map params) { BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "notifyNolOrderPickup() starts"); String result = ""; boolean notifySuccess = false; URL notifyNolOrderPickupRequest = null; BufferedReader br = null; protocol = getProtocol(); try { final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, SALES_ORDER_ID, (String) params.get(SALES_ORDER_ID)); query.append("&"); appendQueryParam( query, LOCATION, (String) params.get(LOCATION)); notifyNolOrderPickupRequest = new URL(protocol + TAAP_NOTIFY_NOL_ORDER_PICKUP_URL + "?" + query.toString()); logger.debug("notifyNolOrderPickup: Calling: " + notifyNolOrderPickupRequest); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.INFO, "notifyNolOrderPickup: Calling: " + notifyNolOrderPickupRequest); br = new BufferedReader(new InputStreamReader(notifyNolOrderPickupRequest.openStream())); result = br.readLine(); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.INFO, "TAAP Query Result: [" + result + "]"); if(result.equalsIgnoreCase("true")){ notifySuccess = true; return notifySuccess; } } catch (Throwable e) { logger.error("Error while notifying bopis order pickup ", e); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))) .errorBOPISLog("Error while notifying bopis order pickup ", new Exception(e)); } finally { if (br != null) { try { br.close(); } catch (IOException ex) { } } } BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "notifyNolOrderPickup() ends"); return notifySuccess; } public String nolOrderPaymentValidation(Map params) { BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "nolOrderPaymentValidation() starts"); String result = ""; URL nolOrderPaymentValidation = null; BufferedReader br = null; protocol = getProtocol(); try { final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, INVOICE_TOTAL, (String) params.get(INVOICE_TOTAL)); query.append("&"); appendQueryParam( query, SALES_ORDER_ID, (String) params.get(SALES_ORDER_ID)); query.append("&"); appendQueryParam( query, NUMBER_OF_LINES, (String) params.get(NUMBER_OF_LINES)); query.append("&"); appendQueryParam( query, LOCATION, (String) params.get(LOCATION)); nolOrderPaymentValidation = new URL(protocol + TAAP_NOL_ORDER_PAYMENT_VALIDATION_URL + "?" + query.toString()); logger.debug("nolOrderPaymentValidation: Calling: " + nolOrderPaymentValidation); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))) .addBOPISLog(Constants.INFO, "nolOrderPaymentValidation: Calling: " + nolOrderPaymentValidation); br = new BufferedReader(new InputStreamReader(nolOrderPaymentValidation.openStream())); result = br.readLine(); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))) .addBOPISLog(Constants.INFO, "TAAP Query Result: [" + result + "]"); return result; } catch (Throwable e) { logger.error("Error while notifying bopis order pickup ", e); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))) .errorBOPISLog("Error while notifying bopis order payment validation", new Exception(e)); } finally { if (br != null) { try { br.close(); } catch (IOException ex) { } } } BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "nolOrderPaymentValidation() ends"); return result; } public boolean notifyInterstoreOrderAcknowledgement(Map params) { BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "notifyInterstoreOrderAcknowledgement() starts"); String result = ""; boolean notifySuccess = false; URL notifyNolOrderPickupRequest = null; BufferedReader br = null; if(params.containsKey(SALESORDERVO_IPADDRESS)){ String servingstoreIP = (String) params.get(SALESORDERVO_IPADDRESS); protocol = "http://"+servingstoreIP+":"; }else{ protocol = getProtocol(); } try { final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, SALES_ORDER_ID, (String) params.get(SALES_ORDER_ID)); query.append("&"); appendQueryParam( query, LOCATION, (String) params.get(LOCATION)); notifyNolOrderPickupRequest = new URL(protocol + TAAP_NOTIFY_INTERSTORE_ACKNOWLEDGEMENT_URL + "?" + query.toString()); logger.warn("notifyNolOrderPickup: Calling: " + notifyNolOrderPickupRequest); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.INFO, "notifyNolOrderPickup: Calling: " + notifyNolOrderPickupRequest); br = new BufferedReader(new InputStreamReader(notifyNolOrderPickupRequest.openStream())); result = br.readLine(); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.INFO, "TAAP Query Result: [" + result + "]"); if(result.equalsIgnoreCase("true")){ notifySuccess = true; return notifySuccess; } } catch (Throwable e) { logger.error("Error while notifying interstore order acknowledgement", e); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))) .errorBOPISLog("Error while notifying interstore order acknowledgement", new Exception(e)); } finally { if (br != null) { try { br.close(); } catch (IOException ex) { } } } BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) params.get(LOCATION))).addBOPISLog(Constants.DEBUG, "notifyInterstoreOrderAcknowledgement() ends"); return notifySuccess; } //phoneroom messages changes below public List retrieveServingStoreMessage(Map retrieveMessagesParams) throws IOException { // List result = null; BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) retrieveMessagesParams.get(LOC))).addBOPISLog(Constants.DEBUG, "retrieveServingStoreMessage() starts"); String result=""; BufferedReader br = null; String retrieveServingStoreMessagesURL = null; HttpMethod taapRequest = null; byte[] responseBody; Map messageCategorymap = getMessageCategory(); List phoneRoomMessagesVOList = new ArrayList(); String servingStoreIP = (String) retrieveMessagesParams.get(SERVING_STORE_IP_ADDRESS); protocol="http://"+servingStoreIP+":"; int statusCode; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, IP_ADDRESS, (String) retrieveMessagesParams.get(IP_ADDRESS)); query.append("&"); appendQueryParam( query, STORE_NUM, (String) retrieveMessagesParams.get(STORE_NUM)); query.append("&"); appendQueryParam( query, EMP_NUM, (String) retrieveMessagesParams.get(EMP_NUM)); query.append("&"); appendQueryParam( query, PASSWORD, (String) retrieveMessagesParams.get(PASSWORD)); query.append("&"); appendQueryParam( query, LOC, (String) retrieveMessagesParams.get(LOC)); query.append("&"); appendQueryParam( query, LANG, (String) retrieveMessagesParams.get(LANG)); query.append("&"); appendQueryParam( query, LATEST, (String) retrieveMessagesParams.get(LATEST)); retrieveServingStoreMessagesURL = protocol + TAAP_MESSAGE_RETRIEVAL_URL + "?" + query.toString(); logger.warn("retrieveServingStoreMessagesURL " + retrieveServingStoreMessagesURL); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) retrieveMessagesParams.get(LOC))).addBOPISLog(Constants.INFO, "retrieveServingStoreMessagesURL " + retrieveServingStoreMessagesURL); HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(retrieveServingStoreMessagesURL); try { long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making retrieveServingStoreMessage remote call",query.toString(),servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) retrieveMessagesParams.get(LOC))) .addBOPISLog(Constants.INFO, "result from server is " + result); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("MessageHeader")){ JSONArray jsonArray = jsonObject.getJSONArray("MessageHeader"); Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { JSONObject json = JSONObject.fromObject(itr2.next()); int id = 0; String messageType =null, loc =null, ref_communication_type = null, logon_date = null,logoff_date =null, customerNumber = null; if(json.containsKey("Id")) id = json.getInt("Id"); if(json.containsKey("MessageType")) messageType = json.getString("MessageType"); if(json.containsKey("Loc")) loc = json.getString("Loc"); if(json.containsKey("Ref_communication_type_id")) ref_communication_type = json.getString("Ref_communication_type_id"); if(json.containsKey("LogonDate")) logon_date = json.getString("LogonDate"); if(json.containsKey("LogoffDate")) logoff_date = json.getString("LogoffDate"); if(json.containsKey("CustomerNumber")){ customerNumber=json.getString("CustomerNumber"); } Integer salesOrderID = null; if(json.containsKey("SalesOrderID")) salesOrderID = json.getInt("SalesOrderID"); Integer ref_comm_id =null; if(ref_communication_type!=null){ ref_comm_id= Integer.valueOf(ref_communication_type); ref_communication_type = messageCategorymap.get(ref_comm_id); } List messageTextVOList = new ArrayList<>(); if(json.containsKey("MessageText")){ JSONArray messageTextVOJSONArray = json.getJSONArray("MessageText"); long conMillSec = System.currentTimeMillis(); messageTextVOList= convertJSONToMessageTextVO(messageTextVOJSONArray); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToMessageTextVO ends",servingStoreIP,messageTextVOJSONArray.toString(), convDuration); } CustomerVO customerVO = null; Map customerParams = new HashMap(); customerParams.put(TaapRouter.SERVING_STORE_IP_ADDRESS, "" + servingStoreIP); customerParams.put(TaapRouter.CUSTOMERNUM, "" + customerNumber); customerParams.put(TaapRouter.TYPE, "" + "N"); customerParams.put(TaapRouter.CUSTID, "" + "1"); customerParams.put(TaapRouter.LANG, "" + "EN"); customerParams.put(TaapRouter.LOC, "" + loc); customerVO = getCustomerDetailInfoByID(customerParams); List messagePartVO = null; if(json.containsKey("MessagePart")){ JSONArray messagePartVOJSONObject = json.getJSONArray("MessagePart"); long conMillSec = System.currentTimeMillis(); messagePartVO= convertJSONTOMessagePartVO(messagePartVOJSONObject,servingStoreIP, customerVO.getID()); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONTOMessagePartVO ends",servingStoreIP,messagePartVOJSONObject.toString(), convDuration); } SalesOrderVO salesOrderVO = null; if(json.containsKey("SalesOrderVO")){ JSONObject salesOrderVOJson = json.getJSONObject("SalesOrderVO"); if(!salesOrderVOJson.isNullObject()) { long conMillSec = System.currentTimeMillis(); salesOrderVO = convertJSONSalesOrderTOVO(salesOrderVOJson); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds - conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONSalesOrderTOVO ends", servingStoreIP, salesOrderVOJson.toString(), convDuration); } } PhoneRoomStoreMessagesVO phoneRoomStoreMessagesVO = new PhoneRoomStoreMessagesVO(); phoneRoomStoreMessagesVO.setMessage_id(id); phoneRoomStoreMessagesVO.setMessageType(messageType); phoneRoomStoreMessagesVO.setLoc(loc); phoneRoomStoreMessagesVO.setRefCommunicationTypeID(ref_comm_id); phoneRoomStoreMessagesVO.setRef_communication_type(ref_communication_type); phoneRoomStoreMessagesVO.setLogoffDate(logoff_date); phoneRoomStoreMessagesVO.setLogonDate(logon_date); phoneRoomStoreMessagesVO.setStoreNum((String) retrieveMessagesParams.get(STORE_NUM)); phoneRoomStoreMessagesVO.setStoreName((String) retrieveMessagesParams.get(STORE_NAME)); phoneRoomStoreMessagesVO.setSalesOrderVO(salesOrderVO); phoneRoomStoreMessagesVO.setMessageTextVO(messageTextVOList); phoneRoomStoreMessagesVO.setMessagePartVO(messagePartVO); phoneRoomStoreMessagesVO.setCustomerNumber(customerNumber); phoneRoomStoreMessagesVO.setCustomerVO(customerVO); phoneRoomStoreMessagesVO.setSalesOrderID(salesOrderID); if(json.containsKey("AcknowledgedByEmployeeId") && json.getString("AcknowledgedByEmployeeId")!=null){ phoneRoomStoreMessagesVO.setAcknowledgedByEmpID(json.getInt("AcknowledgedByEmployeeId")); } if(json.containsKey("AcknowledgedDate") && json.getString("AcknowledgedDate")!=null){ phoneRoomStoreMessagesVO.setAcknowledgedDate(ConvertStringToDate(json.getString("AcknowledgedDate"))); } if((phoneRoomStoreMessagesVO.getMessagePartVO()==null && phoneRoomStoreMessagesVO.getAcknowledgedByEmpID()!=null)) { continue; }else{ phoneRoomMessagesVOList.add(phoneRoomStoreMessagesVO); } } } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) retrieveMessagesParams.get(LOC))) .errorBOPISLog("Server encountered an http error while authenticating ", new Exception(String.valueOf(taapRequest.getStatusLine()))); // throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); // throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } BOPISLogger.getInstance().setStoreProfile(Integer.parseInt((String) retrieveMessagesParams.get(LOC))).addBOPISLog(Constants.DEBUG, "retrieveServingStoreMessage() ends"); return phoneRoomMessagesVOList; } private FulfillmentVO convertJSONFulFilmentTOVO(JSONObject jsonObj) { FulfillmentVO vo = new FulfillmentVO(); if(jsonObj.containsKey("Id") && jsonObj.getString("Id")!=null){vo.setId(jsonObj.getInt( "Id"));} if(jsonObj.containsKey("Loc") && jsonObj.getString("Loc")!=null){vo.setLoc(jsonObj.getInt( "Loc"));} if(jsonObj.containsKey("SalesOrderId") && jsonObj.getString("SalesOrderId")!=null){vo.setSalesOrderId(jsonObj.getInt( "SalesOrderId"));} if(jsonObj.containsKey("PurchaseOrderNumber") && jsonObj.getString("PurchaseOrderNumber")!=null){vo.setPurchaseOrderNumber(jsonObj.getString( "PurchaseOrderNumber"));} if(jsonObj.containsKey("ShippingOptions") && jsonObj.getString("ShippingOptions")!=null){vo.setShippingOptions(jsonObj.getString( "ShippingOptions"));} if(jsonObj.containsKey("RefShippingOptionId") && jsonObj.getString("RefShippingOptionId")!=null){vo.setRefShippingOptionId(jsonObj.getInt( "RefShippingOptionId"));} if(jsonObj.containsKey("ShippingCarrier") && jsonObj.getString("ShippingCarrier")!=null){vo.setShippingCarrier(jsonObj.getString( "ShippingCarrier"));} if(jsonObj.containsKey("ShippingCOde") && jsonObj.getString("ShippingCOde")!=null){vo.setShippingCOde(jsonObj.getString( "ShippingCOde"));} if(jsonObj.containsKey("ShippingCost") && jsonObj.getString("ShippingCost")!=null){vo.setShippingCost(convertStringToBigDecimal(jsonObj.getString( "ShippingCost")));} if(jsonObj.containsKey("ModifiedByEmployeeId") && jsonObj.getString("ModifiedByEmployeeId")!=null){vo.setModifiedByEmployeeId(jsonObj.getInt( "ModifiedByEmployeeId"));} return vo; } public SalesOrderVO convertJSONSalesOrderTOVO(JSONObject obj) { SalesOrderVO salesOrderVO =null; if(!obj.isNullObject()){ salesOrderVO= new SalesOrderVO(); if (obj.containsKey("Id") && obj.getString("Id") != null) { salesOrderVO.setId(obj.getInt("Id")); } if(obj.containsKey("Location") && obj.getString("Location")!=null) { salesOrderVO.setLoc(obj.getInt("Location")); } if(obj.containsKey("StoreNumber")){ salesOrderVO.setStoreNumber(obj.getString("StoreNumber")); } if(obj.containsKey("OrderNumber") && obj.getString("OrderNumber")!=null) { salesOrderVO.setOrderNumber(obj.getInt("OrderNumber")); } if(obj.containsKey("ExternalOrderNumber")) { salesOrderVO.setExternalOrderNumber(obj.getString("ExternalOrderNumber")); } if(obj.containsKey("CustomerId") && obj.getString("CustomerId")!=null) { salesOrderVO.setCustomerId(obj.getInt("CustomerId")); } if(obj.containsKey("LastModifiedDate") && obj.getString("LastModifiedDate")!=null){ salesOrderVO.setLastModifiedDate(Timestamp.valueOf(obj.getString("LastModifiedDate"))); } if(obj.containsKey("CartIdentifier")) { salesOrderVO.setExternalCartIdentifier(obj.getString("CartIdentifier")); } if(obj.containsKey("TransactionIdentifier")) { salesOrderVO.setExternalTransactionIdentifier(obj.getString("TransactionIdentifier")); } if(obj.containsKey("OrderDate")) { salesOrderVO.setOrderDate(Timestamp.valueOf(obj.getString("OrderDate"))); } if(obj.containsKey("RefOrderStatusId") && obj.getString("RefOrderStatusId")!=null) { salesOrderVO.setRefOrderStatusId(obj.getInt("RefOrderStatusId")); } if(obj.containsKey("RefOrderSubTypeId") && obj.getString("RefOrderSubTypeId")!=null) { salesOrderVO.setRefOrderSubTypeId(obj.getInt("RefOrderSubTypeId")); } if(obj.containsKey("RewardDiscount") && obj.getString("RewardDiscount")!=null) { salesOrderVO.setRewardDiscount(convertStringToBigDecimal(obj.getString("RewardDiscount"))); } if(obj.containsKey("TotalDiscount")&& obj.getString("TotalDiscount")!=null) { salesOrderVO.setTotalDiscount(convertStringToBigDecimal(obj.getString("TotalDiscount"))); } if(obj.containsKey("NolOrderNumber")) { salesOrderVO.setNolOrderNumber(obj.getString("NolOrderNumber")); } if(obj.containsKey("AnticipatedDeliveryDate") && obj.getString("AnticipatedDeliveryDate")!=null) { salesOrderVO.setAnticipatedDeliveryDate(obj.getLong("AnticipatedDeliveryDate")); } } return salesOrderVO; } private List convertJSONTOMessagePartVO(JSONArray messagePartVOJSONObjectArray, String remoteStoreIp, Integer custid) { List messagePartList = new ArrayList<>(); Iterator itr = messagePartVOJSONObjectArray.iterator(); while (itr.hasNext()) { JSONObject messagePartVOJSONObject = JSONObject.fromObject(itr.next()); MessagePartVO messagePartVO = new MessagePartVO(); if (messagePartVOJSONObject.containsKey("MessageHeaderId") && messagePartVOJSONObject.getString("MessageHeaderId")!=null) messagePartVO.setMessageHeaderID(messagePartVOJSONObject.getInt("MessageHeaderId")); if (messagePartVOJSONObject.containsKey("Sequence") && messagePartVOJSONObject.getString("Sequence")!=null) messagePartVO.setSequence((short) messagePartVOJSONObject.getInt("Sequence")); if (messagePartVOJSONObject.containsKey("Location") && messagePartVOJSONObject.getString("Location")!=null) messagePartVO.setLOC(messagePartVOJSONObject.getInt("Location")); if (messagePartVOJSONObject.containsKey("LineAbbrev")) messagePartVO.setLineAbbrev(messagePartVOJSONObject.getString("LineAbbrev")); if (messagePartVOJSONObject.containsKey("PartNumber")) messagePartVO.setPartNumber(messagePartVOJSONObject.getString("PartNumber")); if (messagePartVOJSONObject.containsKey("Description")) messagePartVO.setDescription(messagePartVOJSONObject.getString("Description")); if (messagePartVOJSONObject.containsKey("MessagePartStatus")) { IDValuePairVO idValuePairVO = new IDValuePairVO(); idValuePairVO.setValue(messagePartVOJSONObject.getString("MessagePartStatus")); messagePartVO.setMessagePartStatus(idValuePairVO); } if (messagePartVOJSONObject.containsKey("StockLocation")) messagePartVO.setStockLocation(messagePartVOJSONObject.getString("StockLocation")); if (messagePartVOJSONObject.containsKey("InvoiceQuantity") && messagePartVOJSONObject.getString("InvoiceQuantity")!=null) messagePartVO.setInvoiceQty(convertStringToBigDecimal(messagePartVOJSONObject.getString("InvoiceQuantity"))); if (messagePartVOJSONObject.containsKey("InvoiceNumber") && messagePartVOJSONObject.getString("InvoiceNumber")!=null) messagePartVO.setInvoiceNumber(Integer.valueOf((messagePartVOJSONObject.getInt("InvoiceNumber")))); if (messagePartVOJSONObject.containsKey("AvailableQty") && messagePartVOJSONObject.getString("AvailableQty")!=null) messagePartVO.setAvailableQty(convertStringToBigDecimal(messagePartVOJSONObject.getString("AvailableQty"))); if (messagePartVOJSONObject.containsKey("OrderQuantity") && messagePartVOJSONObject.getString("OrderQuantity")!=null){ messagePartVO.setOrderQty(convertStringToBigDecimal(messagePartVOJSONObject.getString("OrderQuantity"))); } if (messagePartVOJSONObject.containsKey("displayQuotedPrice") && messagePartVOJSONObject.getString("displayQuotedPrice")!=null){ messagePartVO.setDisplayQuotedPrice(convertStringToBigDecimal(messagePartVOJSONObject.getString("displayQuotedPrice"))); } if (messagePartVOJSONObject.containsKey("QuotedPrice") && messagePartVOJSONObject.getString("QuotedPrice")!=null){ String quotedPrice = messagePartVOJSONObject.get("QuotedPrice").toString(); BigDecimal qp = new BigDecimal((String) quotedPrice); qp.setScale(4); messagePartVO.setQuotedPrice(qp);} if (messagePartVOJSONObject.containsKey("ListPrice") && messagePartVOJSONObject.getString("ListPrice")!=null){ BigDecimal listPrice = new BigDecimal(messagePartVOJSONObject.get("ListPrice").toString()); listPrice.setScale(4); messagePartVO.setListPrice(listPrice);} if (messagePartVOJSONObject.containsKey("CorePrice") && messagePartVOJSONObject.getString("CorePrice")!=null){ BigDecimal corePrice = new BigDecimal(messagePartVOJSONObject.get("CorePrice").toString()); corePrice.setScale(4); messagePartVO.setCorePrice(corePrice);} String reportable = messagePartVOJSONObject.getString("Reportable"); if (reportable.equalsIgnoreCase("N")) messagePartVO.setReportable(false); else messagePartVO.setReportable(true); if (messagePartVOJSONObject.containsKey("RefInvoiceLineItemOriginId") && messagePartVOJSONObject.getString("RefInvoiceLineItemOriginId")!=null) messagePartVO.setRefInvoiceLineItemOriginId((byte) messagePartVOJSONObject.getInt("RefInvoiceLineItemOriginId")); if (messagePartVOJSONObject.containsKey("SpecialOrder")) messagePartVO.setSpecialOrder(messagePartVOJSONObject.getString("SpecialOrder")); if (messagePartVOJSONObject.containsKey("ProcessMethod")) messagePartVO.setProcessMethod(messagePartVOJSONObject.getString("ProcessMethod")); if (messagePartVOJSONObject.containsKey("VehicleModel")) messagePartVO.setVehicleModel(messagePartVOJSONObject.getString("VehicleModel")); if (messagePartVOJSONObject.containsKey("VehicleMake")) messagePartVO.setVehicleMake(messagePartVOJSONObject.getString("VehicleMake")); if (messagePartVOJSONObject.containsKey("ProductKit") && messagePartVOJSONObject.getString("ProductKit")!=null) messagePartVO.setProductKit(messagePartVOJSONObject.getBoolean("ProductKit")); if (messagePartVOJSONObject.containsKey("KitComponent") && messagePartVOJSONObject.getString("KitComponent")!=null) messagePartVO.setKitComponent(messagePartVOJSONObject.getBoolean("KitComponent")); /*if (messagePartVOJSONObject.containsKey("VehicleYear") && messagePartVOJSONObject.getString("VehicleYear")!=null) { Integer vehicleYear = messagePartVOJSONObject.getInt("VehicleYear"); messagePartVO.setVehicleYear(vehicleYear != 0 ? vehicleYear : null);}*/ //for getting pricesOutVo using messagePartVo details if(remoteStoreIp!=null && custid!=null){ PricesOutVO pricesOutVO = new PricesOutVO(); pricesOutVO= getPricesOutVO(messagePartVO,remoteStoreIp,custid); messagePartVO.setPrice(pricesOutVO); } messagePartList.add(messagePartVO); } return messagePartList; } public PricesOutVO getPricesOutVO(MessagePartVO messagePartVO,String remoteStoreIp,Integer custid) { PricesOutVO pricesOutVO = null; String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/priceout"; logger.debug("url = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", messagePartVO.getLOC().toString()), new NameValuePair("id", custid.toString()), new NameValuePair("line", messagePartVO.getLineAbbrev()), new NameValuePair("part", messagePartVO.getPartNumber()), new NameValuePair("qty", messagePartVO.getInvoiceQty().toString())}); PhoneRoomTaapRouter phoneRoomTaapRouter = new PhoneRoomTaapRouter(); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPricesOutVO remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] responseObj = httpGet.getResponseBody(); String result = new String(responseObj); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("pricesOutVO")){ JSONObject invJson = jsonObject.getJSONObject("pricesOutVO"); if(!invJson.isNullObject()){ long conMillSec = System.currentTimeMillis(); pricesOutVO=phoneRoomTaapRouter.convertJSONToPricesOutVO(invJson); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToPricesOutVO ends",remoteStoreIp,invJson.toString(), convDuration); return pricesOutVO; } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); // throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return pricesOutVO; } private List convertJSONToMessageTextVO(JSONArray messageTextVOJSONArray) { List messageTextVOList = new ArrayList(); Iterator itr = messageTextVOJSONArray.iterator(); while (itr.hasNext()) { JSONObject jsonObj = JSONObject.fromObject(itr.next()); MessageTextVO messageTextVO = new MessageTextVO(); if(jsonObj.containsKey("MessageHeaderId") && jsonObj.getString("MessageHeaderId")!=null) messageTextVO.setMessageHeaderID(jsonObj.getInt("MessageHeaderId")); if(jsonObj.containsKey("Sequence") && jsonObj.getString("Sequence")!=null) messageTextVO.setSequence((short) jsonObj.getInt("Sequence")); if(jsonObj.containsKey("Location") && jsonObj.getString("Location")!=null) messageTextVO.setLOC(jsonObj.getInt("Location")); if(jsonObj.containsKey("Text")){ messageTextVO.setText(jsonObj.getString("Text"));} if(jsonObj.containsKey("AttachedToMessagePartSequence") && jsonObj.getString("AttachedToMessagePartSequence")!=null){ messageTextVO.setAttachedToMessagePartSeq((short) jsonObj.getInt("AttachedToMessagePartSequence"));} messageTextVOList.add(messageTextVO); } return messageTextVOList; } public Boolean acknowledgeRemoteStoreMessage(Map acknowledgeMessageParams) throws IOException { String result=""; String acknowledgeMessagesURL = null; HttpMethod taapRequest = null; String servingStoreIP = (String) acknowledgeMessageParams.get(SERVING_STORE_IP_ADDRESS); protocol="http://"+servingStoreIP+":"; int statusCode; Boolean notifySuccess= false; byte[] responseBody; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, ACK_EMP_NUM, (String) acknowledgeMessageParams.get(ACK_EMP_NUM)); query.append("&"); appendQueryParam( query, MESSAGE_HEADER_ID, (String) acknowledgeMessageParams.get(MESSAGE_HEADER_ID)); acknowledgeMessagesURL = protocol + TAAP_MESSAGE_ACKNOWLEDGE_URL + "?" + query.toString(); logger.debug("acknowledgeMessagesURL " + acknowledgeMessagesURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(acknowledgeMessagesURL); try { logger.debug("Ackniowledge Messages: Calling: " + acknowledgeMessagesURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making acknowledgeRemoteStoreMessage remote call", query.toString(), servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result.equalsIgnoreCase("true")){ notifySuccess = true; return notifySuccess; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); //throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); // throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } return notifySuccess; } public SalesOrderVO getSalesOrderDetailsBySalesOrderId(Integer id, Integer loc, String ipAddress) throws IOException { String result = null; String salesOrderBySalesIdURL = null; HttpMethod taapRequest = null; protocol="http://"+ipAddress+":"; int statusCode; byte[] responseBody; SalesOrderVO salesOrderVO =null; final StringBuffer query = new StringBuffer( 20 ); appendIntQueryParam( query, SALES_ORDER_ID, id); query.append("&"); appendIntQueryParam( query, LOC, loc); salesOrderBySalesIdURL = protocol + TAAP_SALES_ORDERED_DETAILS_URL + "?" + query.toString(); logger.debug("salesOrderBySalesIdURL " + salesOrderBySalesIdURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(salesOrderBySalesIdURL); try { long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getSalesOrderDetailsBySalesOrderId remote call",query.toString(),ipAddress, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("ServingStoreSalesOrderDetails") && !jsonObject.isNullObject()){ JSONObject salesOrderJson = jsonObject.getJSONObject("ServingStoreSalesOrderDetails"); long conMillSec = System.currentTimeMillis(); salesOrderVO = convertJSONSalesOrderTOVO(salesOrderJson); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONSalesOrderTOVO ends",ipAddress,salesOrderJson.toString(), convDuration); return salesOrderVO; } } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); // throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); // throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } return salesOrderVO; } public int getSalesOrderRefOrderStatus(Map refOrderStatusParams) throws IOException { String result=""; String salesOrderRefOrderStatusURL = null; HttpMethod taapRequest = null; String servingStoreIP = (String) refOrderStatusParams.get(SERVING_STORE_IP_ADDRESS); protocol = "http://" + servingStoreIP + ":"; int statusCode; byte[] responseBody; Integer refOrderStatusId = 0; final StringBuffer query = new StringBuffer(20); appendQueryParam(query, SALES_ORDER_ID, (String) refOrderStatusParams.get(SALES_ORDER_ID)); query.append("&"); appendQueryParam(query, LOC, (String) refOrderStatusParams.get(LOC)); salesOrderRefOrderStatusURL = protocol + TAAP_SALESORDER_REFORDEESTATUS_URL + "?" + query.toString(); logger.warn("salesOrderRefOrderStatusURL " + salesOrderRefOrderStatusURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(salesOrderRefOrderStatusURL); try { logger.warn("Retrieve Messages: Calling: " + salesOrderRefOrderStatusURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getSalesOrderRefOrderStatus remote call",query.toString(),servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()) refOrderStatusId = Integer.valueOf(result); } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } return refOrderStatusId; } public void updateSalesOrderRefOrderStatus(Map updateRefOrderStatus) throws IOException { String updateRefOrderStatusURL = null; HttpMethod taapRequest = null; String servingStoreIP = (String) updateRefOrderStatus.get(SERVING_STORE_IP_ADDRESS); protocol = "http://" + servingStoreIP + ":"; int statusCode; final StringBuffer query = new StringBuffer(20); appendQueryParam(query, SALES_ORDER_ID, (String) updateRefOrderStatus.get(SALES_ORDER_ID)); query.append("&"); appendQueryParam(query, LOC, (String) updateRefOrderStatus.get(LOC)); query.append("&"); appendQueryParam(query, REF_ORDER_STATUS, (String) updateRefOrderStatus.get(REF_ORDER_STATUS)); updateRefOrderStatusURL = protocol + TAAP_UPDATE_REFORDERSTATUS_URL + "?" + query.toString(); logger.warn("updateRefOrderStatusURL " + updateRefOrderStatusURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(updateRefOrderStatusURL); try { logger.warn("TaapRouter: Calling: " + updateRefOrderStatusURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making updateSalesOrderRefOrderStatus remote call",query.toString(),servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } } public Integer isMessageSpecialOrdered(Map specialOrderedMessageParams) throws IOException { String result = null; String specialOrderedMessagesURL = null; HttpMethod taapRequest = null; String servingStoreIP = (String) specialOrderedMessageParams.get(SERVING_STORE_IP_ADDRESS); protocol="http://"+servingStoreIP+":"; int statusCode; Integer empId = null; byte[] responseBody; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, MESSAGE_HEADER, specialOrderedMessageParams.get(MESSAGE_HEADER_ID).toString()); specialOrderedMessagesURL = protocol + TAAP_MESSAGE_SPECIAL_ORDERED_URL + "?" + query.toString(); logger.debug("specialOrderedMessagesURL " + specialOrderedMessagesURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(specialOrderedMessagesURL); try { logger.debug("Special Ordered Messages: Calling: " + specialOrderedMessagesURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making isMessageSpecialOrdered remote call",query.toString(),servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()){ logger.info("result from server is " + Integer.parseInt(result)); empId = Integer.parseInt(result); return empId; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } return empId; } public Integer isSplOrderProcessedBy(Integer id, String loc, String ipAddress) { String result = null; String specialOrderedMessagesURL = null; HttpMethod taapRequest = null; protocol="http://"+ipAddress+":"; int statusCode; Integer empId=null; byte[] responseBody; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, MESSAGE_HEADER, id.toString()); query.append("&"); appendQueryParam( query, LOC, loc); specialOrderedMessagesURL = protocol + TAAP_SPECIAL_ORDERED_PROCESSED_BY_URL + "?" + query.toString(); logger.debug("specialOrderedMessagesURL " + specialOrderedMessagesURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(specialOrderedMessagesURL); try { logger.debug("Special Ordered Messages: Calling: " + specialOrderedMessagesURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making isSplOrderProcessedBy remote call",query.toString(),ipAddress, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()) { logger.info("result from server is " + Integer.parseInt(result)); empId = Integer.parseInt(result); return empId; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return empId; } public boolean isMessageAlreadyInvoiced(Map map) throws IOException { String result = null; String isMessageAlreadyInvoicedURL = null; HttpMethod taapRequest = null; boolean invoicedAlreadyFlag = false; protocol="http://"+map.get(SERVING_STORE_IP_ADDRESS)+":"; int statusCode; byte[] responseBody; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, MESSAGE_HEADER, map.get(MESSAGE_HEADER_ID).toString()); query.append("&"); appendQueryParam( query, LOC, map.get(LOC).toString()); isMessageAlreadyInvoicedURL = protocol + TAAP_MESSAGE_ALREADY_INVOICED_URL + "?" + query.toString(); logger.debug("isMessageAlreadyInvoiced " + isMessageAlreadyInvoicedURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(isMessageAlreadyInvoicedURL); try { logger.debug("Messages already invoiced : Calling: " + isMessageAlreadyInvoicedURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making isMessageAlreadyInvoiced remote call",query.toString(),map.get(SERVING_STORE_IP_ADDRESS).toString(), statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && result.equalsIgnoreCase("true")){ invoicedAlreadyFlag = true; return invoicedAlreadyFlag; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } return invoicedAlreadyFlag; } public String getEmployeeNum(Map map) throws IOException { String result = ""; String retrieveEmployeeNumberURL = null; HttpMethod taapRequest = null; protocol="http://"+map.get(SERVING_STORE_IP_ADDRESS)+":"; int statusCode; byte[] responseBody; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, EMP_ID, map.get(EMP_ID).toString()); query.append("&"); appendQueryParam( query, LOC, map.get(LOCATION).toString()); retrieveEmployeeNumberURL = protocol + TAAP_EMPLOYEE_NUMBER_URL + "?" + query.toString(); logger.debug("retrieveEmployeeNumberURL " + retrieveEmployeeNumberURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(retrieveEmployeeNumberURL); try { logger.debug("get employee number : Calling: " + retrieveEmployeeNumberURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getEmployeeNum remote call",query.toString(),map.get(SERVING_STORE_IP_ADDRESS).toString(), statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); return result; } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } } public String getEmployeeDetails(Map map) throws IOException { String result = ""; String retrieveEmployeeDetailsURL = null; HttpMethod taapRequest = null; protocol="http://"+map.get(SERVING_STORE_IP_ADDRESS)+":"; int statusCode; byte[] responseBody; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, EMP_ID, map.get(EMP_ID).toString()); query.append("&"); appendQueryParam( query, LOC, map.get(LOCATION).toString()); retrieveEmployeeDetailsURL = protocol + TAAP_EMPLOYEE_DETAILS_URL + "?" + query.toString(); logger.debug("retrieveEmployeeDetailsURL " + retrieveEmployeeDetailsURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(retrieveEmployeeDetailsURL); try { logger.debug("get employee details : Calling: " + retrieveEmployeeDetailsURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getEmployeeDetails remote call",query.toString(),map.get(SERVING_STORE_IP_ADDRESS).toString(), statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); return result; } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } } public boolean updateSpecialOrderByEmpId(Map map) throws IOException { String result = null; String updateSpecialOrderByEmpIdURL = null; HttpMethod taapRequest = null; protocol="http://"+map.get(SERVING_STORE_IP_ADDRESS)+":"; int statusCode; byte[] responseBody; boolean success = false; final StringBuffer query = new StringBuffer( 20 ); String emplId = "null"; if(map.get(INVOICED_BY_EMPID).equals("null")){ appendQueryParam(query, INVOICED_BY_EMPID, emplId); }else{ Integer empId = (Integer) map.get(INVOICED_BY_EMPID); appendQueryParam(query, INVOICED_BY_EMPID, empId.toString()); } query.append("&"); appendQueryParam( query, MESSAGE_HEADER,map.get(MESSAGE_HEADER).toString()); updateSpecialOrderByEmpIdURL = protocol + TAAP_UPDATE_SPECIAL_ORDER_BY_EMP_ID_URL + "?" + query.toString(); logger.debug("updateSpecialOrderByEmpIdURL " + updateSpecialOrderByEmpIdURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(updateSpecialOrderByEmpIdURL); try { logger.debug("updateSpecialOrderByEmpIdURL : Calling: " + updateSpecialOrderByEmpIdURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making updateSpecialOrderByEmpId remote call",query.toString(),map.get(SERVING_STORE_IP_ADDRESS).toString(), statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && result.equalsIgnoreCase("true")){ success = true; return success; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } return success; } public boolean unacknowledgeMessageExist(Map map) throws IOException { String result = null; String unacknowledgeMessageExistURL = null; HttpMethod taapRequest = null; protocol="http://"+map.get(SERVING_STORE_IP_ADDRESS)+":"; int statusCode; byte[] responseBody; boolean success = false; final StringBuffer query = new StringBuffer( 20 ); Integer empId = (Integer)map.get(EMP_ID); appendQueryParam( query, LOC, map.get(LOC).toString()); unacknowledgeMessageExistURL = protocol + TAAP_UNACKNOWLEDGE_COUNT_CHECK_URL + "?" + query.toString(); logger.debug("unacknowledgeMessageExistURL " + unacknowledgeMessageExistURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(unacknowledgeMessageExistURL); try { logger.debug("unacknowledgeMessageExistURL : Calling: " + unacknowledgeMessageExistURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making unacknowledgeMessageExist remote call",query.toString(),map.get(SERVING_STORE_IP_ADDRESS).toString(), statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && result.equalsIgnoreCase("true")){ success = true; return success; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return success; } public void resetInvoicedByEmpId(Map resetInvoicedByEmpParams) { String result=""; String resetInvoicedByEmpURL = null; HttpMethod taapRequest = null; String servingStoreIP = (String) resetInvoicedByEmpParams.get(SERVING_STORE_IP_ADDRESS); protocol = "http://" + servingStoreIP + ":"; int statusCode; byte[] responseBody; final StringBuffer query = new StringBuffer(20); appendQueryParam(query, MESSAGE_HEADER_ID, (String) resetInvoicedByEmpParams.get(MESSAGE_HEADER_ID)); resetInvoicedByEmpURL = protocol + TAAP_RESET_INVOICEDBY_URL + "?" + query.toString(); logger.warn("resetInvoicedByEmpURL " + resetInvoicedByEmpURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(resetInvoicedByEmpURL); try { logger.warn("TaapRouter: Calling: " + resetInvoicedByEmpURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making resetInvoicedByEmpId remote call",query.toString(),servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } } public void updateInvoicedByEmpId(Map updateInvoicedByEmpIDParams) { String result=""; String updateInvoicedByEmpIdURL = null; HttpMethod taapRequest = null; String servingStoreIP = (String) updateInvoicedByEmpIDParams.get(SERVING_STORE_IP_ADDRESS); protocol = "http://" + servingStoreIP + ":"; int statusCode; byte[] responseBody; boolean isInvoiced = false; final StringBuffer query = new StringBuffer(20); appendQueryParam(query, MESSAGE_HEADER_ID, (String) updateInvoicedByEmpIDParams.get(MESSAGE_HEADER_ID)); query.append("&"); appendQueryParam(query, INVOICED_BY_EMPID, (String) updateInvoicedByEmpIDParams.get(INVOICED_BY_EMPID)); updateInvoicedByEmpIdURL = protocol + TAAP_UPDATE_INVOICEDBY_URL + "?" + query.toString(); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(updateInvoicedByEmpIdURL); try { logger.warn("TaapRouter: Calling: " + updateInvoicedByEmpIdURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making updateInvoicedByEmpId remote call",query.toString(),servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && result.equalsIgnoreCase("true")){ isInvoiced = true; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }finally { taapRequest.releaseConnection(); } } public InventoryProfileVO getInventoryProfile(Map inventoryProfileParams){ String result=""; BufferedReader br = null; String getInventoryProfileURL = null; HttpMethod taapRequest = null; byte[] responseBody; Map messageCategorymap = getMessageCategory(); List phoneRoomMessagesVOList = new ArrayList(); String servingStoreIP = (String) inventoryProfileParams.get(SERVING_STORE_IP_ADDRESS); protocol="http://"+servingStoreIP+":"; int statusCode; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, LOC, (String) inventoryProfileParams.get(LOC)); getInventoryProfileURL = protocol + TAAP_INVENTORY_PROFILE_URL + "?" + query.toString(); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(getInventoryProfileURL); InventoryProfileVO inventoryProfileVO =null; try { logger.warn("Retrieve Messages: Calling: " + getInventoryProfileURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getInventoryProfile remote call",query.toString(),servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("Profile") && !jsonObject.getJSONObject("Profile").isNullObject()){ JSONObject json = jsonObject.getJSONObject("Profile"); inventoryProfileVO = new InventoryProfileVO(); long conMillSec = System.currentTimeMillis(); if(json.containsKey("Location") && json.getString("Location")!=null) inventoryProfileVO.setLocation(json.getInt("Location")); if(json.containsKey("AutoPostNapaOrderReceipts") && json.getString("AutoPostNapaOrderReceipts")!=null){ int autoPostNapaOrderReceiptsINT = json.getInt("AutoPostNapaOrderReceipts"); inventoryProfileVO.setAutoPostNAPAOrderReceipts((autoPostNapaOrderReceiptsINT==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("MainInventoryStoreNumber")) inventoryProfileVO.setMainInventoryStoreNumber(json.getString("MainInventoryStoreNumber")); if(json.containsKey("AllowTransmitOfOrdersToMainStore")&& json.getString("AllowTransmitOfOrdersToMainStore")!=null){ int allowTransmitOfOrdersInt = json.getInt("AllowTransmitOfOrdersToMainStore"); inventoryProfileVO.setAllowTransmitOfOrdersToMainStore((allowTransmitOfOrdersInt==1)?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(json.containsKey("BaseRefClassCode")) inventoryProfileVO.setBaseRefClassCD(json.getString("BaseRefClassCode")); if(json.containsKey("DefaultRefBinLabelTypeId") && json.getString("DefaultRefBinLabelTypeId")!=null) inventoryProfileVO.setDefaultRefBinLabelTypeID((byte) json.getInt("DefaultRefBinLabelTypeId")); if(json.containsKey("UpdatePartsWithCatalogDescriptions")){ int updatePartsWithCatalog = json.getInt("UpdatePartsWithCatalogDescriptions"); inventoryProfileVO.setUpdatePartsWithCatalogDescriptions((updatePartsWithCatalog==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("LockMiscCharges") && json.getString("LockMiscCharges")!=null){ int LockMiscCharges = json.getInt("LockMiscCharges"); inventoryProfileVO.setLockMiscellaneousCharges((LockMiscCharges==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("LastPurchaseOrderNumber") && json.getString("LastPurchaseOrderNumber")!=null) inventoryProfileVO.setLastPurchaseOrderNumber(json.getInt("LastPurchaseOrderNumber")); if(json.containsKey("KeepInventoryAdjustmentsDays") && json.getString("KeepInventoryAdjustmentsDays")!=null) inventoryProfileVO.setKeepInventoryAdjustmentsDays((short) json.getInt("KeepInventoryAdjustmentsDays")); if(json.containsKey("LastShipmentNumber") && json.getString("LastShipmentNumber")!=null) inventoryProfileVO.setLastShipmentNumber(json.getInt("LastShipmentNumber")); if(json.containsKey("KeepInventorySalesHistoryMonths") && json.getString("KeepInventorySalesHistoryMonths")!=null) inventoryProfileVO.setKeepInventorySalesHistoryMonths((byte) json.getInt("KeepInventorySalesHistoryMonths")); if(json.containsKey("KeepPurchaseOrdersMonths") && json.getString("KeepPurchaseOrdersMonths")!=null) inventoryProfileVO.setKeepPurchaseOrdersMonths((byte) json.getInt("KeepPurchaseOrdersMonths")); if(json.containsKey("KeepMiscInventoryMonths") && json.getString("LockMiscCharges")!=null) inventoryProfileVO.setKeepMiscInventoryMonths((byte) json.getInt("KeepMiscInventoryMonths")); if(json.containsKey("UseScoreForOrdering") && json.getString("UseScoreForOrdering")!=null){ int UseScoreForOrdering = json.getInt("UseScoreForOrdering"); inventoryProfileVO.setUseScoreForOrdering((UseScoreForOrdering==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("LoadBeginningBalancesToScore") && json.getString("LoadBeginningBalancesToScore")!=null) inventoryProfileVO.setLoadBeginningBalancesToScore(json.getString("LoadBeginningBalancesToScore")=="N"?false:true); if(json.containsKey("InvReviewIncludePartsFromDvd") && json.getString("InvReviewIncludePartsFromDvd")!=null){ int inReviewIncludePartsFromDVDInt = json.getInt("InvReviewIncludePartsFromDvd"); inventoryProfileVO.setInvReviewIncludePartsFromDVD((inReviewIncludePartsFromDVDInt==1)?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(json.containsKey("MaximumDaysOnOrder") && json.getString("MaximumDaysOnOrder")!=null) inventoryProfileVO.setMaximumDaysOnOrder((byte) json.getInt("MaximumDaysOnOrder")); if(json.containsKey("MaximumDaysOnBackorder") && json.getString("MaximumDaysOnBackorder")!=null) inventoryProfileVO.setMaximumDaysOnBackorder((byte) json.getInt("MaximumDaysOnBackorder")); if(json.containsKey("MaximumDaysOnFactoryOrder") && json.getString("MaximumDaysOnFactoryOrder")!=null) inventoryProfileVO.setMaximumDaysOnFactoryOrder((byte) json.getInt("MaximumDaysOnFactoryOrder")); if(json.containsKey("PhysInvAllowNewPartEntry") && json.getString("PhysInvAllowNewPartEntry")!=null){ int physInvAllowNewPartEntry = json.getInt("PhysInvAllowNewPartEntry"); inventoryProfileVO.setPhysInvAllowNewPartEntry((physInvAllowNewPartEntry==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("PhysInvEditByLocation") && json.getString("PhysInvEditByLocation")!=null){ int physInvEditByLocation = json.getInt("PhysInvEditByLocation"); inventoryProfileVO.setPhysInvEditByLocation((physInvEditByLocation==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("PhysInvUpdateLocations") && json.getString("PhysInvUpdateLocations")!=null){ int physInvUpdateLocations = json.getInt("PhysInvUpdateLocations"); inventoryProfileVO.setPhysInvUpdateLocations((physInvUpdateLocations==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("PhysInvDisplayRetailPrice") && json.getString("PhysInvDisplayRetailPrice")!=null){ int physInvDisplayRetailPrice = json.getInt("PhysInvDisplayRetailPrice"); inventoryProfileVO.setPhysInvDisplayRetailPrice((physInvDisplayRetailPrice==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("KeepPhysInvSummaryMonths")&& json.getString("KeepPhysInvSummaryMonths")!=null) inventoryProfileVO.setKeepPhysInvSummaryMonths((short) json.getInt("KeepPhysInvSummaryMonths")); if(json.containsKey("KeepPhysInvSessionDays") && json.getString("KeepPhysInvSessionDays")!=null) inventoryProfileVO.setKeepPhysInvSessionDays((short) json.getInt("KeepPhysInvSessionDays")); if(json.containsKey("NapaClassificationDcCode") && json.getString("NapaClassificationDcCode")!=null) inventoryProfileVO.setNapaClassificationDCCode((short) json.getInt("NapaClassificationDcCode")); if(json.containsKey("PartNumberLength") && json.getString("PartNumberLength")!=null) inventoryProfileVO.setPartNumberLength(json.getInt("PartNumberLength")); if(json.containsKey("DisableInClass24AndOutPolicy") && json.getString("DisableInClass24AndOutPolicy")!=null){ int disableInClass24AndOutPolicy = json.getInt("DisableInClass24AndOutPolicy"); inventoryProfileVO.setDisableInClass24AndOutPolicy((disableInClass24AndOutPolicy==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("LastModifiedDate") && json.getString("LastModifiedDate")!=null){ inventoryProfileVO.setLastModifiedDate(ConvertStringToDate(json.getString("LastModifiedDate"))); } if(json.containsKey("PrintBinLabelsAtEOD") && json.getString("PrintBinLabelsAtEOD")!=null){ int printBinLabelsAtEOD = json.getInt("PrintBinLabelsAtEOD"); inventoryProfileVO.setPrintBinLabelsAtEod((printBinLabelsAtEOD==1)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("IncludeInterstoreReceiptsWithShipment") && json.getString("IncludeInterstoreReceiptsWithShipment")!=null){ boolean includeInterstoreReceiptsWithShipment = json.getBoolean("IncludeInterstoreReceiptsWithShipment"); inventoryProfileVO.setIncludeInterstoreReceiptsWithShipment((includeInterstoreReceiptsWithShipment==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("DisableReceiveAll") && json.getString("DisableReceiveAll")!=null){ boolean disableReceiveAll = json.getBoolean("DisableReceiveAll"); inventoryProfileVO.setDisableReceiveAll((disableReceiveAll==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(json.containsKey("UseKeepFlag") && json.getString("UseKeepFlag")!=null){ boolean useKeepFlag = json.getBoolean("UseKeepFlag"); inventoryProfileVO.setDisableReceiveAll((useKeepFlag==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of inventoryProfileVO ends",servingStoreIP,inventoryProfileVO.toString(), convDuration); }}else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } }catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }finally { taapRequest.releaseConnection(); } return inventoryProfileVO; } public InvoicingProfileVO getInvoicingProfile(String remoteStoreIp) { String getInvoicingProfile = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/phoneroommessage"; logger.debug("getInvoicingProfile = " + getInvoicingProfile);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getInvoicingProfile); InvoicingProfileVO invoicingProfileVO =null; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getInvoicingProfile remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] invoicingProfileResponse = httpGet.getResponseBody(); String result = new String(invoicingProfileResponse); if(result!=null && result!="" && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("invoicingProfile") && !jsonObject.getJSONObject("invoicingProfile").isNullObject()) { JSONObject invProfileJSON = jsonObject.getJSONObject("invoicingProfile"); long conMillSec = System.currentTimeMillis(); invoicingProfileVO = convertInvProfileJSONtoVO(invProfileJSON); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertInvProfileJSONtoVO ends",remoteStoreIp,invProfileJSON.toString(), convDuration); } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return invoicingProfileVO; } private EmployeeVO convertEmployeeDetailsJSONtoVO(JSONObject empDetailsJSON) { EmployeeVO employee = new EmployeeVO(); if(empDetailsJSON.containsKey("ID")&& empDetailsJSON.getString("ID")!=null)employee.setID(empDetailsJSON.getInt("ID")); if(empDetailsJSON.containsKey("EmployeeNum")&& empDetailsJSON.getString("EmployeeNum")!=null)employee.setEmployeeNum(empDetailsJSON.getInt("EmployeeNum")); if(empDetailsJSON.containsKey("LastName")&& empDetailsJSON.getString("LastName")!=null)employee.setLastName(empDetailsJSON.getString("LastName")); if(empDetailsJSON.containsKey("FirstName")&& empDetailsJSON.getString("FirstName")!=null)employee.setFirstName(empDetailsJSON.getString("FirstName")); if(empDetailsJSON.containsKey("MiddleInitial")&& empDetailsJSON.getString("MiddleInitial")!=null)employee.setMiddleInitial(empDetailsJSON.getString("MiddleInitial")); if(empDetailsJSON.containsKey("RefLanguageCD")&& empDetailsJSON.getString("RefLanguageCD")!=null)employee.setRefLanguageCD(empDetailsJSON.getString("RefLanguageCD")); if(empDetailsJSON.containsKey("RefCountryCD")&& empDetailsJSON.getString("RefCountryCD")!=null)employee.setRefCountryCD(empDetailsJSON.getString("RefCountryCD")); if(empDetailsJSON.containsKey("ClockedIn")&& empDetailsJSON.getString("ClockedIn")!=null)employee.setClockedIn(empDetailsJSON.getString("ClockedIn")); if(empDetailsJSON.containsKey("InvoicingAllowed")&& empDetailsJSON.getString("InvoicingAllowed")!=null)employee.setInvoicingAllowed(empDetailsJSON.getString("InvoicingAllowed")); if(empDetailsJSON.containsKey("Password")&& empDetailsJSON.getString("Password")!=null)employee.setPassword(empDetailsJSON.getString("Password")); if(empDetailsJSON.containsKey("RefPayTypeID")&& empDetailsJSON.getString("RefPayTypeID")!=null)employee.setRefPayTypeID(empDetailsJSON.getInt("RefPayTypeID")); if(empDetailsJSON.containsKey("CustomerID")&& empDetailsJSON.getString("CustomerID")!=null)employee.setCustomerID(empDetailsJSON.getInt("CustomerID")); if(empDetailsJSON.containsKey("TerminationDate")&& empDetailsJSON.getString("TerminationDate")!=null)employee.setTerminationDate(convertStringToTimeStamp(empDetailsJSON.getString("TerminationDate"))); if(empDetailsJSON.containsKey("DispGrossProfitAndCost")&& empDetailsJSON.getString("DispGrossProfitAndCost")!=null)employee.setDisplayGrossProfitAndCost(empDetailsJSON.getString("DispGrossProfitAndCost")); if(empDetailsJSON.containsKey("RefCatalogPreferenceID")&& empDetailsJSON.getString("RefCatalogPreferenceID")!=null)employee.setRefCatalogPreference(empDetailsJSON.getInt("RefCatalogPreferenceID")); if(empDetailsJSON.containsKey("refPasswordStatus")&& empDetailsJSON.getString("refPasswordStatus")!=null)employee.setRefPasswordStatus(empDetailsJSON.getInt("refPasswordStatus")); if(empDetailsJSON.containsKey("passwordExpDate")&& empDetailsJSON.getString("passwordExpDate")!=null)employee.setPasswordExpDate((java.sql.Date) ConvertStringToDate2(empDetailsJSON.getString("passwordExpDate"))); if(empDetailsJSON.containsKey("allowChangeCatalogPreference")&& empDetailsJSON.getString("allowChangeCatalogPreference")!=null)employee.setAllowChangeCatalogPreference(empDetailsJSON.getString("allowChangeCatalogPreference")); if(empDetailsJSON.containsKey("employeeLdapId")&& empDetailsJSON.getString("employeeLdapId")!=null)employee.setEmployeeLdapId(empDetailsJSON.getString("employeeLdapId")); return employee; } private InvoicingProfileVO convertInvProfileJSONtoVO(JSONObject invProfileJSON) { InvoicingProfileVO invoicingProfileVO = new InvoicingProfileVO(); if(invProfileJSON.containsKey("location")) invoicingProfileVO.setLocation( invProfileJSON.getInt("location")); if(invProfileJSON.containsKey("defaultTaxTableID")) invoicingProfileVO.setDefaultTaxTableID((short) invProfileJSON.getInt("defaultTaxTableID")); if(invProfileJSON.containsKey("lastInvoiceNumberUsed")) invoicingProfileVO.setLastInvoiceNumberUsed( invProfileJSON.getInt("lastInvoiceNumberUsed")); if(invProfileJSON.containsKey("grossProfitPercent")) { String grossProfitPercent = invProfileJSON.get("grossProfitPercent").toString(); BigDecimal gpp = new BigDecimal((String) grossProfitPercent); gpp.setScale(4); invoicingProfileVO.setGrossProfitPercent(gpp);} if(invProfileJSON.containsKey("laborCostPercent")) { String laborCostPercent = invProfileJSON.get("laborCostPercent").toString(); BigDecimal lcp = new BigDecimal((String) laborCostPercent); lcp.setScale(4); invoicingProfileVO.setLaborCostPercent(lcp);} if(invProfileJSON.containsKey("lowCostVerifyPercent")) { String lowCostVerifyPercent = invProfileJSON.get("lowCostVerifyPercent").toString(); BigDecimal lcvp = new BigDecimal((String) lowCostVerifyPercent); lcvp.setScale(4); invoicingProfileVO.setLowCostVerifyPercent(lcvp);} if(invProfileJSON.containsKey("highCostVerifyPercent")) { String highCostVerifyPercent = invProfileJSON.get("highCostVerifyPercent").toString(); BigDecimal hcvp = new BigDecimal((String) highCostVerifyPercent); hcvp.setScale(4); invoicingProfileVO.setHighCostVerifyPercent(hcvp);} if(invProfileJSON.containsKey("costLaborItems")){ boolean costLaborItems = invProfileJSON.getBoolean("costLaborItems"); invoicingProfileVO.setCostLaborItems((costLaborItems==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("displayGPInCosting")){ boolean displayGPInCosting = invProfileJSON.getBoolean("displayGPInCosting"); invoicingProfileVO.setDisplayGPInCosting((displayGPInCosting==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("askForAmountTendered")){ boolean askForAmountTendered = invProfileJSON.getBoolean("askForAmountTendered"); invoicingProfileVO.setAskForAmountTendered((askForAmountTendered==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowInvoiceErase")){ boolean allowInvoiceErase = invProfileJSON.getBoolean("allowInvoiceErase"); invoicingProfileVO.setAllowInvoiceErase((allowInvoiceErase==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowChangeSalesman")){ boolean allowChangeSalesman = invProfileJSON.getBoolean("allowChangeSalesman"); invoicingProfileVO.setAllowChangeSalesman((allowChangeSalesman==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowCtrmanOverridePrice")){ boolean allowCtrmanOverridePrice = invProfileJSON.getBoolean("allowCtrmanOverridePrice"); invoicingProfileVO.setAllowCtrmanOverridePrice((allowCtrmanOverridePrice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("attentionEntryRequired")){ boolean attentionEntryRequired = invProfileJSON.getBoolean("attentionEntryRequired"); invoicingProfileVO.setAttentionEntryRequired((attentionEntryRequired==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useDefaultQtyOf1")){ boolean useDefaultQtyOf1 = invProfileJSON.getBoolean("useDefaultQtyOf1"); invoicingProfileVO.setUseDefaultQtyOf1((useDefaultQtyOf1==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("displayFractionalQtyWarning")){ boolean displayFractionalQtyWarning = invProfileJSON.getBoolean("displayFractionalQtyWarning"); invoicingProfileVO.setDisplayFractionalQtyWarning((displayFractionalQtyWarning==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowCtrmanSpecialOrder")){ boolean allowCtrmanSpecialOrder = invProfileJSON.getBoolean("allowCtrmanSpecialOrder"); invoicingProfileVO.setAllowCtrmanSpecialOrder((allowCtrmanSpecialOrder==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowCtrmanBackorder")){ boolean allowCtrmanBackorder = invProfileJSON.getBoolean("allowCtrmanBackorder"); invoicingProfileVO.setAllowCtrmanBackorder((allowCtrmanBackorder==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useTenderTypes")){ boolean useTenderTypes = invProfileJSON.getBoolean("useTenderTypes"); invoicingProfileVO.setUseTenderTypes((useTenderTypes==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowMultipleTenderTypes")){ boolean allowMultipleTenderTypes = invProfileJSON.getBoolean("allowMultipleTenderTypes"); invoicingProfileVO.setAllowMultipleTenderTypes((allowMultipleTenderTypes==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowInvoiceErase")){ boolean allowInvoiceErase = invProfileJSON.getBoolean("allowInvoiceErase"); invoicingProfileVO.setAllowInvoiceErase((allowInvoiceErase==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowInvoiceErase")){ boolean allowInvoiceErase = invProfileJSON.getBoolean("allowInvoiceErase"); invoicingProfileVO.setAllowInvoiceErase((allowInvoiceErase==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("printCatalogNotesOnInvoice")){ boolean printCatalogNotesOnInvoice = invProfileJSON.getBoolean("printCatalogNotesOnInvoice"); invoicingProfileVO.setPrintCatalogNotesOnInvoice((printCatalogNotesOnInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("printCreditCardInfoOnInvoice")){ boolean printCreditCardInfoOnInvoice = invProfileJSON.getBoolean("printCreditCardInfoOnInvoice"); invoicingProfileVO.setPrintCreditCardInfoOnInvoice((printCreditCardInfoOnInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("askForCreditCardInfo")){ boolean askForCreditCardInfo = invProfileJSON.getBoolean("askForCreditCardInfo"); invoicingProfileVO.setAskForCreditCardInfo((askForCreditCardInfo==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("askForCheckInfo")){ boolean askForCheckInfo = invProfileJSON.getBoolean("askForCheckInfo"); invoicingProfileVO.setAskForCheckInfo((askForCheckInfo==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("displayCodWarning")){ boolean displayCodWarning = invProfileJSON.getBoolean("displayCodWarning"); invoicingProfileVO.setDisplayCodWarning((displayCodWarning==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("enableCoreReturnLaw")){ boolean enableCoreReturnLaw = invProfileJSON.getBoolean("enableCoreReturnLaw"); invoicingProfileVO.setEnableCoreReturnLaw((enableCoreReturnLaw==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("enableValidateCertificate")){ boolean enableValidateCertificate = invProfileJSON.getBoolean("enableValidateCertificate"); invoicingProfileVO.setEnableValidateCertificate((enableValidateCertificate==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useCashierFunction")){ boolean useCashierFunction = invProfileJSON.getBoolean("useCashierFunction"); invoicingProfileVO.setUseCashierFunction((useCashierFunction==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("numberOfCashiersLoggedOn")) invoicingProfileVO.setNumberOfCashiersLoggedOn((short) invProfileJSON.getInt("numberOfCashiersLoggedOn")); if(invProfileJSON.containsKey("wlcCostFactor")){ String wlcCostFactor = invProfileJSON.get("wlcCostFactor").toString(); BigDecimal wlcf = new BigDecimal((String) wlcCostFactor); wlcf.setScale(4); invoicingProfileVO.setWLCCostFactor(wlcf); } if(invProfileJSON.containsKey("allowEmployeeClockedoutInvoice")){ boolean allowEmployeeClockedoutInvoice = invProfileJSON.getBoolean("allowEmployeeClockedoutInvoice"); invoicingProfileVO.setAllowEmployeeClockedoutInvoice((allowEmployeeClockedoutInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowEmployeeSelfInvoice")){ boolean allowEmployeeSelfInvoice = invProfileJSON.getBoolean("allowEmployeeSelfInvoice"); invoicingProfileVO.setAllowEmployeeSelfInvoice((allowEmployeeSelfInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useRads")){ boolean useRads = invProfileJSON.getBoolean("useRads"); invoicingProfileVO.setUseRads((useRads==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("nextRadsTransactionNumber")) invoicingProfileVO.setNextRadsTransactionNumber( invProfileJSON.getInt("nextRadsTransactionNumber")); if(invProfileJSON.containsKey("radsRefreshSeconds")) invoicingProfileVO.setRadsRefreshSeconds( invProfileJSON.getInt("radsRefreshSeconds")); if(invProfileJSON.containsKey("radsAlertMinutes")) invoicingProfileVO.setRadsAlertMinutes( invProfileJSON.getInt("radsAlertMinutes")); if(invProfileJSON.containsKey("printHazmatCodes")){ boolean printHazmatCodes = invProfileJSON.getBoolean("printHazmatCodes"); invoicingProfileVO.setPrintHazmatCodes((printHazmatCodes==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("printTaxExemptNum")){ boolean printTaxExemptNum = invProfileJSON.getBoolean("printTaxExemptNum"); invoicingProfileVO.setPrintTaxExemptNum((printTaxExemptNum==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useSaveInvoice")){ boolean useSaveInvoice = invProfileJSON.getBoolean("useSaveInvoice"); invoicingProfileVO.setUseSaveInvoice((useSaveInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("displaySavedInvoicesAlert")){ boolean displaySavedInvoicesAlert = invProfileJSON.getBoolean("displaySavedInvoicesAlert"); invoicingProfileVO.setDisplaySavedInvoicesAlert((displaySavedInvoicesAlert==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowPrintingSavedInvoices")){ boolean allowPrintingSavedInvoices = invProfileJSON.getBoolean("allowPrintingSavedInvoices"); invoicingProfileVO.setAllowPrintingSavedInvoices((allowPrintingSavedInvoices==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("updateWIPWithSavedInvoices")){ boolean updateWIPWithSavedInvoices = invProfileJSON.getBoolean("updateWIPWithSavedInvoices"); invoicingProfileVO.setUpdateWIPWithSavedInvoices((updateWIPWithSavedInvoices==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("printStoreGstNum")){ boolean printStoreGstNum = invProfileJSON.getBoolean("printStoreGstNum"); invoicingProfileVO.setPrintStoreGstNum((printStoreGstNum==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("generateSavedInvFromJOEI")){ boolean generateSavedInvFromJOEI = invProfileJSON.getBoolean("generateSavedInvFromJOEI"); invoicingProfileVO.setGenerateSavedInvFromJOEI((generateSavedInvFromJOEI==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("askForItemReturnInfo")){ boolean askForItemReturnInfo = invProfileJSON.getBoolean("askForItemReturnInfo"); invoicingProfileVO.setAskForItemReturnInfo((askForItemReturnInfo==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("askForItemReturnCustomerInfo")){ boolean askForItemReturnCustomerInfo = invProfileJSON.getBoolean("askForItemReturnCustomerInfo"); invoicingProfileVO.setAskForItemReturnCustomerInfo((askForItemReturnCustomerInfo==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("itemReturnRequiresMgrApproval")){ boolean itemReturnRequiresMgrApproval = invProfileJSON.getBoolean("itemReturnRequiresMgrApproval"); invoicingProfileVO.setItemReturnRequiresMgrApproval((itemReturnRequiresMgrApproval==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("displayLowSuggPrice")){ boolean displayLowSuggPrice = invProfileJSON.getBoolean("displayLowSuggPrice"); invoicingProfileVO.setDisplayLowSuggPrice((displayLowSuggPrice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("displayCustomPricing")){ boolean displayCustomPricing = invProfileJSON.getBoolean("displayCustomPricing"); invoicingProfileVO.setDisplayCustomPricing((displayCustomPricing==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowPolicyAdjustment")){ boolean allowPolicyAdjustment = invProfileJSON.getBoolean("allowPolicyAdjustment"); invoicingProfileVO.setAllowPolicyAdjustment((allowPolicyAdjustment==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowMiscAdjustment")){ boolean allowMiscAdjustment = invProfileJSON.getBoolean("allowMiscAdjustment"); invoicingProfileVO.setAllowMiscAdjustment((allowMiscAdjustment==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowMisFunction")){ boolean allowMisFunction = invProfileJSON.getBoolean("allowMisFunction"); invoicingProfileVO.setAllowMisFunction((allowMisFunction==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("printCoresPendingRptDuringInvCreation")){ boolean printCoresPendingRptDuringInvCreation = invProfileJSON.getBoolean("printCoresPendingRptDuringInvCreation"); invoicingProfileVO.setPrintCoresPendingRptDuringInvCreation((printCoresPendingRptDuringInvCreation==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("coreBankInUse")){ boolean coreBankInUse = invProfileJSON.getBoolean("coreBankInUse"); invoicingProfileVO.setCoreBankInUse((coreBankInUse==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("transmitCoreBankDataToADPCenter")){ boolean transmitCoreBankDataToADPCenter = invProfileJSON.getBoolean("transmitCoreBankDataToADPCenter"); invoicingProfileVO.setTransmitCoreBankDataToADPCenter((transmitCoreBankDataToADPCenter==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useTokenization")){ boolean useTokenization = invProfileJSON.getBoolean("useTokenization"); invoicingProfileVO.setUseTokenization((useTokenization==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useInvoiceCheckoutVersion")){ boolean useInvoiceCheckoutVersion = invProfileJSON.getBoolean("useInvoiceCheckoutVersion"); invoicingProfileVO.setInvoiceCheckoutVersion((useInvoiceCheckoutVersion==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowAutoAcknowledgeECommerceMessages")){ boolean allowAutoAcknowledgeECommerceMessages = invProfileJSON.getBoolean("allowAutoAcknowledgeECommerceMessages"); invoicingProfileVO.setAllowAutoAcknowledgeECommerceMessages((allowAutoAcknowledgeECommerceMessages==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowAutoAcknowledgeInterStoreMessages")){ boolean allowAutoAcknowledgeInterStoreMessages = invProfileJSON.getBoolean("allowAutoAcknowledgeInterStoreMessages"); invoicingProfileVO.setAllowAutoAcknowledgeInterStoreMessages((allowAutoAcknowledgeInterStoreMessages==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useECommercePullList")){ boolean useECommercePullList = invProfileJSON.getBoolean("useECommercePullList"); invoicingProfileVO.setUseECommercePullList((useECommercePullList==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useInterStorePullList")){ boolean useInterStorePullList = invProfileJSON.getBoolean("useInterStorePullList"); invoicingProfileVO.setUseInterStorePullList((useInterStorePullList==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("printCustomerMessageOnInvoice")){ boolean printCustomerMessageOnInvoice = invProfileJSON.getBoolean("printCustomerMessageOnInvoice"); invoicingProfileVO.setPrintCustomerMessageOnInvoice((printCustomerMessageOnInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowMultipleUsersForMessages")){ boolean allowMultipleUsersForMessages = invProfileJSON.getBoolean("allowMultipleUsersForMessages"); invoicingProfileVO.setAllowMultipleUsersForMessage((allowMultipleUsersForMessages==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useDCBalance")){ boolean useDCBalance = invProfileJSON.getBoolean("useDCBalance"); invoicingProfileVO.setUseDCBalance((useDCBalance==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useIntegratedPayments")){ boolean useIntegratedPayments = invProfileJSON.getBoolean("useIntegratedPayments"); invoicingProfileVO.setUseIntegratedPayments((useIntegratedPayments==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("keepInvoiceHistoryMonths")) invoicingProfileVO.setKeepInvoiceHistoryMonths((byte) invProfileJSON.getInt("keepInvoiceHistoryMonths")); if(invProfileJSON.containsKey("keepSavedInvoicesDays")) invoicingProfileVO.setKeepSavedInvoicesDays((short) invProfileJSON.getInt("keepSavedInvoicesDays")); if(invProfileJSON.containsKey("refDeliverySystemModeID")) invoicingProfileVO.setRefDeliverySystemModeID((byte) invProfileJSON.getInt("refDeliverySystemModeID")); if(invProfileJSON.containsKey("lastAuthReferenceNumberUsed")) invoicingProfileVO.setLastAuthReferenceNumberUsed( invProfileJSON.getInt("lastAuthReferenceNumberUsed")); if(invProfileJSON.containsKey("keepCustomerVehicleListMonths")) invoicingProfileVO.setKeepCustomerVehicleListMonths((byte) invProfileJSON.getInt("keepCustomerVehicleListMonths")); if(invProfileJSON.containsKey("defaultCustomerVehicleListQuantity")) invoicingProfileVO.setDefaultCustomerVehicleListQuantity((short) invProfileJSON.getInt("defaultCustomerVehicleListQuantity")); if(invProfileJSON.containsKey("lastModifiedDate") && invProfileJSON.getString("lastModifiedDate")!=null){ invoicingProfileVO.setLastModifiedDate(ConvertStringToDate(invProfileJSON.getString("lastModifiedDate"))); } if(invProfileJSON.containsKey("modifiedByEmployeeID")) invoicingProfileVO.setModifiedByEmployeeID( invProfileJSON.getInt("modifiedByEmployeeID")); if(invProfileJSON.containsKey("oldCatalogAvailable")) invoicingProfileVO.setOldCatalogAvailable((short) invProfileJSON.getInt("oldCatalogAvailable")); if(invProfileJSON.containsKey("newCatalogAvailable")) invoicingProfileVO.setNewCatalogAvailable((short) invProfileJSON.getInt("newCatalogAvailable")); if(invProfileJSON.containsKey("displayPOSPricingToCustomer")) invoicingProfileVO.setDisplayPOSPricingToCustomer( invProfileJSON.getString("displayPOSPricingToCustomer")); if(invProfileJSON.containsKey("costPassword")) invoicingProfileVO.setCostPassword( invProfileJSON.getString("costPassword")); if(invProfileJSON.containsKey("refCatalogPreferenceID")) invoicingProfileVO.setRefCatalogPreferenceID( invProfileJSON.getInt("refCatalogPreferenceID")); if(invProfileJSON.containsKey("eCommerceInvoiceTypeId")) invoicingProfileVO.setECommerceInvoiceTypeId( invProfileJSON.getInt("eCommerceInvoiceTypeId")); if(invProfileJSON.containsKey("eCommerceInvoicePrinterId")) invoicingProfileVO.setECommerceInvoicePrinterId( invProfileJSON.getInt("eCommerceInvoicePrinterId")); if(invProfileJSON.containsKey("interStoreInvoiceTypeId")) invoicingProfileVO.setInterStoreInvoiceTypeId( invProfileJSON.getInt("interStoreInvoiceTypeId")); if(invProfileJSON.containsKey("interStoreInvoicePrinterId")) invoicingProfileVO.setInterStoreInvoicePrinterId( invProfileJSON.getInt("interStoreInvoicePrinterId")); if(invProfileJSON.containsKey("eCommerceInvoiceEmployeeId")) invoicingProfileVO.setECommerceInvoiceEmployeeId( invProfileJSON.getInt("eCommerceInvoiceEmployeeId")); if(invProfileJSON.containsKey("interStoreInvoiceEmployeeId")) invoicingProfileVO.setInterStoreInvoiceEmployeeId( invProfileJSON.getInt("interStoreInvoiceEmployeeId")); if(invProfileJSON.containsKey("ipaPrimary")) invoicingProfileVO.setIpaPrimaryIpAddress( invProfileJSON.getString("ipaPrimary")); if(invProfileJSON.containsKey("ipaSecondary")) invoicingProfileVO.setIpaSecondaryIpAddress( invProfileJSON.getString("ipaSecondary")); if(invProfileJSON.containsKey("ipaTertiary")) invoicingProfileVO.setIpaTertiaryIpAddress( invProfileJSON.getString("ipaTertiary")); if(invProfileJSON.containsKey("pullListRefSortOptionId")) invoicingProfileVO.setPullListRefSortOptionId( invProfileJSON.getInt("pullListRefSortOptionId")); if(invProfileJSON.containsKey("requireDeliverySelection")){ boolean requireDeliverySelection = invProfileJSON.getBoolean("requireDeliverySelection"); invoicingProfileVO.setRequireDeliverySelection((requireDeliverySelection==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("printAuthorizedBuyerOnInvoice")){ boolean printAuthorizedBuyerOnInvoice = invProfileJSON.getBoolean("printAuthorizedBuyerOnInvoice"); invoicingProfileVO.setPrintAuthorizedBuyerOnInvoice((printAuthorizedBuyerOnInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("pricesUseStandardRounding")){ boolean pricesUseStandardRounding = invProfileJSON.getBoolean("pricesUseStandardRounding"); invoicingProfileVO.setPricesUseStandardRounding((pricesUseStandardRounding==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useChooseStoreDialog")){ boolean useChooseStoreDialog = invProfileJSON.getBoolean("useChooseStoreDialog"); invoicingProfileVO.setUseChooseStoreDialog((useChooseStoreDialog==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("printFulFilmentNote")){ boolean printFulFilmentNote = invProfileJSON.getBoolean("printFulFilmentNote"); invoicingProfileVO.setPrintFulFillmentNoteOnInvoice((printFulFilmentNote==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("dnsInvoice")){ boolean dnsInvoice = invProfileJSON.getBoolean("dnsInvoice"); invoicingProfileVO.setDnsInvoice((dnsInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("PrintDescription")){ boolean PrintDescription = invProfileJSON.getBoolean("PrintDescription"); invoicingProfileVO.setPrintDescription((PrintDescription==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("allowChangeSigCaptureForChargeReturns")){ boolean allowChangeSigCaptureForChargeReturns = invProfileJSON.getBoolean("allowChangeSigCaptureForChargeReturns"); invoicingProfileVO.setAllowChangeSigCaptureForChargeReturns((allowChangeSigCaptureForChargeReturns==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("disableVoidInvoice")){ boolean disableVoidInvoice = invProfileJSON.getBoolean("disableVoidInvoice"); invoicingProfileVO.setDisableVoidInvoice((disableVoidInvoice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("disableManagerOverride")){ boolean disableManagerOverride = invProfileJSON.getBoolean("disableManagerOverride"); invoicingProfileVO.setDisableManagerOverride((disableManagerOverride==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useLegacyDCEjoei")){ String uselegacydcejoei = invProfileJSON.getString("useLegacyDCEjoei"); invoicingProfileVO.setUseLegacyDCEjoei(uselegacydcejoei); } if(invProfileJSON.containsKey("defaultWIPAnswer")){ boolean defaultWIPAnswer = invProfileJSON.getBoolean("defaultWIPAnswer"); invoicingProfileVO.setdefaultWIPAnswer((defaultWIPAnswer==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("refElectronicInvoiceVendorId")){ invoicingProfileVO.setRefElectronicInvoiceVendorId(invProfileJSON.getInt("refElectronicInvoiceVendorId")); } if(invProfileJSON.containsKey("useSigPlus")){ String useSigPlus = invProfileJSON.getString("useSigPlus"); invoicingProfileVO.setUseSigPlus(useSigPlus); } if(invProfileJSON.containsKey("allowChangeSigCaptureForChargeSale")){ boolean allowChangeSigCaptureForChargeSale = invProfileJSON.getBoolean("allowChangeSigCaptureForChargeSale"); invoicingProfileVO.setAllowChangeSigCaptureForChargeSale((allowChangeSigCaptureForChargeSale==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("useCepdiV2")){ String useCepdiV2 = invProfileJSON.getString("useCepdiV2"); invoicingProfileVO.setUseCepdiV2(useCepdiV2); } if(invProfileJSON.containsKey("priceOverridePassword")) invoicingProfileVO.setPriceOverridePassword(invProfileJSON.getString("priceOverridePassword")); if(invProfileJSON.containsKey("useQuoteDays")){ boolean useQuoteDays = invProfileJSON.getBoolean("useQuoteDays"); invoicingProfileVO.setUseQuoteDays((useQuoteDays==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(invProfileJSON.containsKey("lockRetailPrice")){ boolean lockRetailPrice = invProfileJSON.getBoolean("lockRetailPrice"); invoicingProfileVO.setLockRetailPrice((lockRetailPrice==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } return invoicingProfileVO; } public PhoneRoomStoreMessagesVO retrieveServingStoreMessageById(Map retrieveMessagesParams) { String result=""; BufferedReader br = null; String retrieveServingStoreByIdMessagesURL = null; HttpMethod taapRequest = null; byte[] responseBody; Map messageCategorymap = getMessageCategory(); PhoneRoomStoreMessagesVO phoneRoomStoreMessagesVO = new PhoneRoomStoreMessagesVO(); String servingStoreIP = (String) retrieveMessagesParams.get(SERVING_STORE_IP_ADDRESS); protocol="http://"+servingStoreIP+":"; int statusCode; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, MESSAGE_HEADER, retrieveMessagesParams.get(MESSAGE_HEADER_ID).toString()); query.append("&"); appendQueryParam( query, LOC, retrieveMessagesParams.get(LOC).toString()); query.append("&"); appendQueryParam( query, LANG, retrieveMessagesParams.get(LANG).toString()); retrieveServingStoreByIdMessagesURL = protocol + TAAP_MESSAGE_RETRIEVAL_BY_ID_URL + "?" + query.toString(); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(retrieveServingStoreByIdMessagesURL); try { logger.warn("Retrieve Messages: Calling: " + retrieveServingStoreByIdMessagesURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making retrieveServingStoreMessageById remote call", query.toString(), servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); long conMillSec = System.currentTimeMillis(); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("MessageHeader")){ JSONArray jsonArray = jsonObject.getJSONArray("MessageHeader"); Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { JSONObject json = JSONObject.fromObject(itr2.next()); int id = 0; String messageType =null, loc =null, ref_communication_type = null, logon_date = null,logoff_date =null, customerNumber = null; if(json.containsKey("Id")) id = json.getInt("Id"); if(json.containsKey("MessageType")) messageType = json.getString("MessageType"); if(json.containsKey("Loc")) loc = json.getString("Loc"); if(json.containsKey("Ref_communication_type_id")) ref_communication_type = json.getString("Ref_communication_type_id"); if(json.containsKey("LogonDate")) logon_date = json.getString("LogonDate"); if(json.containsKey("LogoffDate")) logoff_date = json.getString("LogoffDate"); if(json.containsKey("CustomerNumber")){ customerNumber=json.getString("CustomerNumber"); } Integer salesOrderID = null; if(json.containsKey("SalesOrderID")) salesOrderID = json.getInt("SalesOrderID"); Integer mt = null; if(ref_communication_type!=null){ mt = Integer.valueOf(ref_communication_type); } List messageTextVOList = new ArrayList<>(); if(json.containsKey("MessageText")){ JSONArray messageTextVOJSONArray = json.getJSONArray("MessageText"); messageTextVOList= convertJSONToMessageTextVO(messageTextVOJSONArray); } CustomerVO customerVO = null; Map customerParams = new HashMap(); customerParams.put(TaapRouter.SERVING_STORE_IP_ADDRESS, "" + servingStoreIP); customerParams.put(TaapRouter.CUSTOMERNUM, "" + customerNumber); customerParams.put(TaapRouter.TYPE, "" + "N"); customerParams.put(TaapRouter.CUSTID, "" + "1"); customerParams.put(TaapRouter.LANG, "" + "EN"); customerParams.put(TaapRouter.LOC, "" + loc); customerVO = getCustomerDetailInfoByID(customerParams); List messagePartVO = new ArrayList<>(); if(json.containsKey("MessagePart")){ JSONArray messagePartVOJSONObject = json.getJSONArray("MessagePart"); messagePartVO= convertJSONTOMessagePartVO(messagePartVOJSONObject,servingStoreIP, customerVO.getID()); } if(json.containsKey("AcknowledgedByEmployeeId") && json.getString("AcknowledgedByEmployeeId")!=null){ phoneRoomStoreMessagesVO.setAcknowledgedByEmpID(json.getInt("AcknowledgedByEmployeeId")); } if(json.containsKey("AcknowledgedDate") && json.getString("AcknowledgedDate")!=null){ phoneRoomStoreMessagesVO.setAcknowledgedDate(ConvertStringToDate(json.getString("AcknowledgedDate"))); } SalesOrderVO salesOrderVO = null; if(json.containsKey("SalesOrderVO")){ JSONObject salesOrderVOJson = json.getJSONObject("SalesOrderVO"); if(!salesOrderVOJson.isNullObject()) salesOrderVO = convertJSONSalesOrderTOVO(salesOrderVOJson); } phoneRoomStoreMessagesVO.setSalesOrderVO(salesOrderVO); phoneRoomStoreMessagesVO.setMessage_id(id); phoneRoomStoreMessagesVO.setMessageType(messageType); phoneRoomStoreMessagesVO.setLoc(loc); phoneRoomStoreMessagesVO.setRefCommunicationTypeID(mt); phoneRoomStoreMessagesVO.setRef_communication_type(ref_communication_type); phoneRoomStoreMessagesVO.setLogoffDate(logoff_date); phoneRoomStoreMessagesVO.setLogonDate(logon_date); phoneRoomStoreMessagesVO.setStoreNum((String) retrieveMessagesParams.get(STORE_NUM)); phoneRoomStoreMessagesVO.setSalesOrderVO(salesOrderVO); if(messageTextVOList!=null) phoneRoomStoreMessagesVO.setMessageTextVO(messageTextVOList); if(messagePartVO!=null) phoneRoomStoreMessagesVO.setMessagePartVO(messagePartVO); phoneRoomStoreMessagesVO.setCustomerNumber(customerNumber); if(customerVO!=null) phoneRoomStoreMessagesVO.setCustomerVO(customerVO); phoneRoomStoreMessagesVO.setSalesOrderID(salesOrderID); return phoneRoomStoreMessagesVO; } } long conMillSecEnd = System.currentTimeMillis(); long convDuration = (conMillSecEnd-conMillSec); createAndLogConversionDataToAzure("Conversion of phoneRoomStoreMessagesVO ends",servingStoreIP,phoneRoomStoreMessagesVO.toString(), convDuration); } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return phoneRoomStoreMessagesVO; } public boolean arProfilePrintStatements(String remoteStoreIP) { Boolean isPrintStatements = false; String getARProfilePrintStatementsURL = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/phoneroomcod"; logger.debug("getARProfilePrintStatementsURL = " + getARProfilePrintStatementsURL);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getARProfilePrintStatementsURL); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making arProfilePrintStatements remote call","No Payload",remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] psResponse = httpGet.getResponseBody(); String result = new String(psResponse); if(result!=null && result!="" && !result.isEmpty()) { isPrintStatements = Boolean.valueOf(result); logger.warn("result from server is " + isPrintStatements); } }else{ logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return isPrintStatements.booleanValue(); } public EmployeeVO getEmployeeVODetails(Map employeeVOParams) { EmployeeVO employeeVO =null; String remoteStoreIp = (String) employeeVOParams.get(SERVING_STORE_IP_ADDRESS); String getEmployeeVOURL = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/phoneroomed"; logger.debug("getEmployeeVOURL = " + getEmployeeVOURL);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getEmployeeVOURL); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("empNum", (String) employeeVOParams.get(EMPNUM))}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getEmployeeVODetails remote call", httpGet.getQueryString(), remoteStoreIp, statusCode,callDuration); logger.debug("statusCode = " + statusCode); if (statusCode == HttpStatus.SC_OK) { final byte[] empVOResponse = httpGet.getResponseBody(); String result = new String(empVOResponse); if(result!=null && result!="" && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("employeeDetails") && !jsonObject.getJSONObject("employeeDetails").isNullObject()){ JSONObject employeeJSON = jsonObject.getJSONObject("employeeDetails"); long conMillSec = System.currentTimeMillis(); employeeVO = convertEmployeeDetailsJSONtoVO(employeeJSON); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertEmployeeDetailsJSONtoVO ",remoteStoreIp,employeeJSON.toString(), convDuration); }} }else{ logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return employeeVO; } public SalesOrderDeliveryAddressVO retrieveSalesOrderDeliveryAddress(String remoteStoreIP, Integer id) { SalesOrderDeliveryAddressVO salesOrderDeliveryAddressVO =null; String result=""; String salesOrderDeliveryAddressURL = null; HttpMethod taapRequest = null; protocol = "http://" + remoteStoreIP + ":"; int statusCode; byte[] responseBody; final StringBuffer query = new StringBuffer(20); appendQueryParam(query, SALES_ORDER_ID, String.valueOf(id)); salesOrderDeliveryAddressURL = protocol + TAAP_SALESORDER_DELIVERYADDRESS_URL + "?" + query.toString(); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(salesOrderDeliveryAddressURL); try { logger.warn("Retrieve Messages: Calling: " + salesOrderDeliveryAddressURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making retrieveSalesOrderDeliveryAddress remote call", query.toString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("PRSalesODAdd") && !jsonObject.getJSONObject("PRSalesODAdd").isNullObject()){ JSONObject jsonObj = jsonObject.getJSONObject("PRSalesODAdd"); long conMillSec = System.currentTimeMillis(); salesOrderDeliveryAddressVO = convertJsonToSODeliveryAddrVO(jsonObj); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJsonToSODeliveryAddrVO ends",remoteStoreIP,jsonObj.toString(), convDuration); }} } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); } } catch (IOException e) { e.printStackTrace(); } catch(Exception e){ e.printStackTrace(); logger.error("exception::"+e); }finally { taapRequest.releaseConnection(); } return salesOrderDeliveryAddressVO; } public List retrieveSalesOrderRecipientAddressBySalesOrderId(String remoteStoreIP, Integer salesOrderId) { List salesOrderRecipientAddressVOList = new ArrayList<>(); String result=""; String salesOrderRecipientAddressURL = null; HttpMethod taapRequest = null; protocol = "http://" + remoteStoreIP + ":"; int statusCode; byte[] responseBody; final StringBuffer query = new StringBuffer(20); appendQueryParam(query, SALES_ORDER_ID, String.valueOf(salesOrderId)); salesOrderRecipientAddressURL = protocol + TAAP_SALESORDER_RECIPIENTADDRESS_URL + "?" + query.toString(); logger.warn("salesOrderRecipientAddressURL " + salesOrderRecipientAddressURL); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(salesOrderRecipientAddressURL); try { logger.warn("Retrieve Messages: Calling: " + salesOrderRecipientAddressURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making retrieveSalesOrderRecipientAddressBySalesOrderId remote call", query.toString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); long conMillSec = System.currentTimeMillis(); if(jsonObject.containsKey("PrSalesODRAddList") && !jsonObject.getJSONArray("PrSalesODRAddList").isEmpty()) { JSONArray jsonArray = jsonObject.getJSONArray("PrSalesODRAddList"); Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { JSONObject json = JSONObject.fromObject(itr2.next()); SalesOrderRecipientAddressVO salesOrderRecipientAddressVO = new SalesOrderRecipientAddressVO(); if (json.containsKey("Id") && json.getString("Id")!=null) salesOrderRecipientAddressVO.setId(json.getInt("Id")); if (json.containsKey("SalesOrderId") && json.getString("SalesOrderId")!=null) salesOrderRecipientAddressVO.setSalesOrderId(json.getInt("SalesOrderId")); if (json.containsKey("FirstName")) salesOrderRecipientAddressVO.setFirstName(json.getString("FirstName")); if (json.containsKey("MiddleName")) salesOrderRecipientAddressVO.setMiddleName(json.getString("MiddleName")); if (json.containsKey("LastName")) salesOrderRecipientAddressVO.setLastName(json.getString("LastName")); if (json.containsKey("FullName")) salesOrderRecipientAddressVO.setFullName(json.getString("FullName")); if (json.containsKey("Address1")) salesOrderRecipientAddressVO.setAddress1(json.getString("Address1")); if (json.containsKey("Address2")) salesOrderRecipientAddressVO.setAddress2(json.getString("Address2")); if (json.containsKey("City")) salesOrderRecipientAddressVO.setCity(json.getString("City")); if (json.containsKey("RefStateCd")) salesOrderRecipientAddressVO.setRefStateCd(json.getString("RefStateCd")); if (json.containsKey("PostalCode")) salesOrderRecipientAddressVO.setPostalCode(json.getString("PostalCode")); if (json.containsKey("RefCountryCd")) salesOrderRecipientAddressVO.setRefCountryCd(json.getString("RefCountryCd")); if (json.containsKey("PhoneType")) salesOrderRecipientAddressVO.setPhoneType(json.getString("PhoneType")); if (json.containsKey("Phone")) salesOrderRecipientAddressVO.setPhone(json.getString("Phone")); if (json.containsKey("EmailAddress")) salesOrderRecipientAddressVO.setEmailAddress(json.getString("EmailAddress")); salesOrderRecipientAddressVOList.add(salesOrderRecipientAddressVO); } } long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of salesOrderRecipientAddressVO ends",remoteStoreIP,salesOrderRecipientAddressVOList.toString(), convDuration); } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }finally { taapRequest.releaseConnection(); } return salesOrderRecipientAddressVOList; } private SalesOrderDeliveryAddressVO convertJsonToSODeliveryAddrVO(JSONObject jsonObj) { SalesOrderDeliveryAddressVO salesOrderDeliveryAddressVO = new SalesOrderDeliveryAddressVO(); if(jsonObj.containsKey("id")) salesOrderDeliveryAddressVO.setId(jsonObj.getInt("id")); if(jsonObj.containsKey("salesOrderId")) salesOrderDeliveryAddressVO.setSalesOrderId(jsonObj.getInt("salesOrderId")); if(jsonObj.containsKey("name")) salesOrderDeliveryAddressVO.setName(jsonObj.getString("name")); if(jsonObj.containsKey("firstName")) salesOrderDeliveryAddressVO.setFirstName(jsonObj.getString("firstName")); if(jsonObj.containsKey("middleName")) salesOrderDeliveryAddressVO.setMiddleName(jsonObj.getString("middleName")); if(jsonObj.containsKey("lastName")) salesOrderDeliveryAddressVO.setLastName(jsonObj.getString("lastName")); if(jsonObj.containsKey("fullName")) salesOrderDeliveryAddressVO.setFullName(jsonObj.getString("fullName")); if(jsonObj.containsKey("addressLine1")) salesOrderDeliveryAddressVO.setAddressLine1(jsonObj.getString("addressLine1")); if(jsonObj.containsKey("addressLine2")) salesOrderDeliveryAddressVO.setAddressLine2(jsonObj.getString("addressLine2")); if(jsonObj.containsKey("city")) salesOrderDeliveryAddressVO.setCity(jsonObj.getString("city")); if(jsonObj.containsKey("county")) salesOrderDeliveryAddressVO.setCounty(jsonObj.getString("county")); if(jsonObj.containsKey("refStateCd")) salesOrderDeliveryAddressVO.setRefStateCd(jsonObj.getString("refStateCd")); if(jsonObj.containsKey("postalCode")) salesOrderDeliveryAddressVO.setPostalCode(jsonObj.getString("postalCode")); if(jsonObj.containsKey("refCountrycd")) salesOrderDeliveryAddressVO.setRefCountryCd(jsonObj.getString("refCountrycd")); if(jsonObj.containsKey("phoneType")) salesOrderDeliveryAddressVO.setPhoneType(jsonObj.getString("phoneType")); if(jsonObj.containsKey("phone")) salesOrderDeliveryAddressVO.setPhone(jsonObj.getString("phone")); if(jsonObj.containsKey("emailAddress")) salesOrderDeliveryAddressVO.setEmailAddress(jsonObj.getString("emailAddress")); return salesOrderDeliveryAddressVO; } public InvoiceVO recallOrRefreshSavedInvoice(Map params) { InvoiceVO invoiceVO =null; String recallSavedInvoiceURL = "http://" + params.get(SERVING_STORE_IP_ADDRESS) + ":8080/TAMSII/Servlets/phoneroommsg"; logger.debug("recallSavedInvoiceURL = " + recallSavedInvoiceURL); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(recallSavedInvoiceURL); List values = new ArrayList(); values.add(new NameValuePair("invoiceId", (String) params.get(SAVED_INVOICEID))); values.add(new NameValuePair("loc", (String) params.get(LOC))); if(params.containsKey(TYPE)) values.add(new NameValuePair("type", (String) params.get(TYPE))); else values.add(new NameValuePair("type", "recall")); if(params.containsKey(DATEPARAM)) values.add(new NameValuePair("date", (String) params.get(DATEPARAM))); else values.add(new NameValuePair("date", (String) "date")); NameValuePair[] nvp = values.toArray(new NameValuePair[0]); httpGet.setQueryString(nvp); ConversionToVO conversionToVO = new ConversionToVO(); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getTaxTable remote call",httpGet.getQueryString(),params.get(SERVING_STORE_IP_ADDRESS).toString(), statusCode,callDuration); logger.debug("statusCode = " + statusCode); if (statusCode == HttpStatus.SC_OK) { final byte[] savedInvoiceResponse = httpGet.getResponseBody(); String result = new String(savedInvoiceResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject.containsKey("invoiceDetails") && !jsonObject.getJSONObject("invoiceDetails").isNullObject()) { //recallSavedInvoice long conMillSec = System.currentTimeMillis(); invoiceVO = conversionToVO.ConvertJSONToInvoiceVO(result); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of ConvertJSONToInvoiceVO ends",params.get(SERVING_STORE_IP_ADDRESS).toString(),result.toString(), convDuration); } else { //refreshsavedinvoice return invoiceVO; } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return invoiceVO; } public boolean updateMessageHeader(PhoneRoomStoreMessagesVO phoneRoomStoreMessagesVO,String remoteStoreIp){ boolean isUpdated = false; HttpMethod taapRequest = null; String servingStoreIP = remoteStoreIp; protocol="http://"+servingStoreIP+":"; int statusCode; Boolean notifySuccess= false; byte[] responseBody; String updateMessageHeaderURL = null; updateMessageHeaderURL = protocol + TAAP_UPDATE_MSGHEADER_URL; logger.debug("updateMessageHeaderURL " + updateMessageHeaderURL); HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(updateMessageHeaderURL); JSONObject jsonObject = new JSONObject(); jsonObject.put("id",phoneRoomStoreMessagesVO.getMessage_id()); jsonObject.put("loc",Integer.valueOf(phoneRoomStoreMessagesVO.getLoc())); jsonObject.put("refCommunicationTypeID",phoneRoomStoreMessagesVO.getRefCommunicationTypeID()); jsonObject.put("storeNumber",phoneRoomStoreMessagesVO.getStoreNum()); jsonObject.put("logOnDate",phoneRoomStoreMessagesVO.getLogonDate()); jsonObject.put("logOffDate",phoneRoomStoreMessagesVO.getLogoffDate()); jsonObject.put("acknowledgedByEmpID",phoneRoomStoreMessagesVO.getAcknowledgedByEmpID()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String strDate = dateFormat.format(phoneRoomStoreMessagesVO.getAcknowledgedDate()); jsonObject.put("acknowledgedDate",strDate); jsonObject.put("messageType",phoneRoomStoreMessagesVO.getMessageType()); jsonObject.put("customerNumber",phoneRoomStoreMessagesVO.getCustomerNumber()); jsonObject.put("savedInvoiceId",phoneRoomStoreMessagesVO.getSavedInvoiceId()); StringRequestEntity reqEntity = null; String json_string = jsonObject.toString(); try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("updateMessageHeaderURL Calling: " + updateMessageHeaderURL); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making updateMessageHeader remote call",json_string,servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); String result = new String(responseBody); if(result!=null && result!="" && result.equalsIgnoreCase("true")){ notifySuccess = true; return notifySuccess; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return isUpdated; } public boolean updateMessagePart(MessagePartVO messagePartVO,String remoteStoreIp){ boolean isUpdated = false; HttpMethod taapRequest = null; String servingStoreIP = remoteStoreIp; protocol="http://"+servingStoreIP+":"; int statusCode; Boolean notifySuccess= false; byte[] responseBody; String updateMessagePartURL = null; updateMessagePartURL = protocol + TAAP_UPDATE_MSGPART_URL; logger.debug("updateMessagePartURL " + updateMessagePartURL); HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(updateMessagePartURL); JSONObject jsonObject = new JSONObject(); jsonObject.put("messageHeaderId",messagePartVO.getMessageHeaderID()); jsonObject.put("sequence",messagePartVO.getSequence()); jsonObject.put("location",messagePartVO.getLOC()); jsonObject.put("lineAbbrev",messagePartVO.getLineAbbrev()); jsonObject.put("partNumber",messagePartVO.getPartNumber()); jsonObject.put("orderQuantity",messagePartVO.getOrderQty().doubleValue()); if (messagePartVO.getMessagePartStatus() != null && messagePartVO.getMessagePartStatus().getID() != null) { jsonObject.put("refMessagePartStatusCd",messagePartVO.getMessagePartStatus().getID().toString());} else jsonObject.put("refMessagePartStatusCd",null); if(messagePartVO.getInvoiceQty()!=null) jsonObject.put("invoiceQuantity",messagePartVO.getInvoiceQty().doubleValue()); else jsonObject.put("invoiceQuantity",null); if(messagePartVO.getInvoiceNumber()!=null) jsonObject.put("invoiceNumber",messagePartVO.getInvoiceNumber().intValue()); else jsonObject.put("invoiceNumber",null); if(messagePartVO.getQuotedPrice()!=null)jsonObject.put("quotedPrice",messagePartVO.getQuotedPrice().doubleValue()); else jsonObject.put("quotedPrice",null); if(messagePartVO.getListPrice()!=null)jsonObject.put("listPrice",messagePartVO.getListPrice().doubleValue()); else jsonObject.put("listPrice",null); jsonObject.put("corePrice",messagePartVO.getCorePrice().doubleValue()); jsonObject.put("reportable", BooleanParser.parseString("Y", "N", messagePartVO.isReportable())); if (messagePartVO.getProcessMethod() != null) {jsonObject.put("processMethod",messagePartVO.getProcessMethod());} else jsonObject.put("processMethod",null); if(messagePartVO.getProcessedByEmployeeID()!=null) jsonObject.put("processedByEmployeeId",messagePartVO.getProcessedByEmployeeID().intValue()); else jsonObject.put("processedByEmployeeId",null); if(messagePartVO.getProcessedDate()!=null){ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String strDate = dateFormat.format(messagePartVO.getProcessedDate()); jsonObject.put("processedDate",strDate); }else jsonObject.put("processedDate",null); StringRequestEntity reqEntity = null; String json_string = jsonObject.toString(); try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("updateMessagePartURL Calling: " + updateMessagePartURL); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making updateMessagePart remote call",json_string,servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); String result = new String(responseBody); if(result!=null && result!="" && result.equalsIgnoreCase("true")){ notifySuccess = true; return notifySuccess; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return isUpdated; } public CustomerVO getCustomerDetailInfoByID(Map params) { CustomerVO customerVO =null; String remoteStoreIp = (String) params.get(SERVING_STORE_IP_ADDRESS); String getCustomerVOURL = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/phoneroomcd"; logger.debug("getCustomerVOURL = " + getCustomerVOURL);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getCustomerVOURL); String type = (String) params.get(TYPE); String custId = (type=="RS"?(String)params.get(CUSTID):"1"); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("custNum", (String) params.get(CUSTOMERNUM)), new NameValuePair("lang", (String) params.get(LANG)), new NameValuePair("loc", (String) params.get(LOC)), new NameValuePair("type", type), new NameValuePair("custId",custId) }); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getCustomerDetailInfoByID remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); logger.debug("statusCode = " + statusCode); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject.containsKey("customerDetails") && !jsonObject.getJSONObject("customerDetails").isNullObject()) { JSONObject customerJSON = jsonObject.getJSONObject("customerDetails"); long conMillSec = System.currentTimeMillis(); customerVO = convertjsonToCustomerVO(customerJSON); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertjsonToCustomerVO",remoteStoreIp,customerJSON.toString(), convDuration); return customerVO; } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return customerVO; } public boolean doesPartExistInInvOrDVD(Map paramsMap){ Boolean isExist = false; String remoteStoreIp = (String) paramsMap.get(SERVING_STORE_IP_ADDRESS); String checkPartExistURL = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/phoneroomck"; logger.debug("checkPartExistURL = " + checkPartExistURL);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(checkPartExistURL); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("custNum", (String) paramsMap.get(CUSTOMERNUM)), new NameValuePair("partNum", (String) paramsMap.get(PARTNUM)), new NameValuePair("lineAbbr", (String) paramsMap.get(LINEABBR)) }); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making doesPartExistInInvOrDVD remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); logger.debug("statusCode = " + statusCode); if (statusCode == HttpStatus.SC_OK) { final byte[] checkExistResponse = httpGet.getResponseBody(); String result = new String(checkExistResponse); if(result!=null && result!="" && !result.isEmpty()) { isExist = Boolean.valueOf(result); return isExist; } } }catch(Exception e){ logger.error(e); } return isExist; } public CustomerVO convertjsonToCustomerVO(JSONObject customerVOJson){ CustomerVO customerVO = new CustomerVO(); if(customerVOJson.containsKey("id") && customerVOJson.getString("id")!=null){customerVO.setID(customerVOJson.getInt("id"));} if(customerVOJson.containsKey("loc") && customerVOJson.getString("loc")!=null){customerVO.setLOC(customerVOJson.getInt("loc"));} if(customerVOJson.containsKey("customerTypeCD")){customerVO.setCustomerTypeCD(customerVOJson.getString("customerTypeCD"));} if(customerVOJson.containsKey("customerNumber") && customerVOJson.getString("customerNumber")!=null){customerVO.setCustomerNumber(customerVOJson.getInt("customerNumber"));} if(customerVOJson.containsKey("name")){customerVO.setName(customerVOJson.getString("name"));} if(customerVOJson.containsKey("alphaKey")){customerVO.setAlphaKey(customerVOJson.getString("alphaKey"));} if(customerVOJson.containsKey("phone")){customerVO.setPhone(customerVOJson.getString("phone"));} if(customerVOJson.containsKey("extension")){customerVO.setExtension(customerVOJson.getString("extension"));} if(customerVOJson.containsKey("addressLine1")){customerVO.setAddrLine1(customerVOJson.getString("addressLine1"));} if(customerVOJson.containsKey("address2")){customerVO.setAddress2(customerVOJson.getString("address2"));} if(customerVOJson.containsKey("address3")){customerVO.setAddress3(customerVOJson.getString("address3"));} if(customerVOJson.containsKey("address4")){customerVO.setAddress4(customerVOJson.getString("address4"));} if(customerVOJson.containsKey("city")){customerVO.setCity(customerVOJson.getString("city"));} if(customerVOJson.containsKey("state")){customerVO.setState(customerVOJson.getString("state"));} if(customerVOJson.containsKey("postalCode")){customerVO.setPostalCode(customerVOJson.getString("postalCode"));} if(customerVOJson.containsKey("countryCD")){customerVO.setCountryCD(customerVOJson.getString("countryCD"));} if(customerVOJson.containsKey("faxNumber")){customerVO.setFaxNumber(customerVOJson.getString("faxNumber"));} if(customerVOJson.containsKey("refLanguageCD")){customerVO.setRefLanguageCD(customerVOJson.getString("refLanguageCD"));} if(customerVOJson.containsKey("refNAPACustomerCategoryID") && customerVOJson.getString("refNAPACustomerCategoryID")!=null){customerVO.setREFNAPACustomerCategoryID((byte) customerVOJson.getInt("refNAPACustomerCategoryID"));} if(customerVOJson.containsKey("salesmanEmployeeID") && customerVOJson.getString("salesmanEmployeeID")!=null){customerVO.setSalesmanEmployeeID(customerVOJson.getInt("salesmanEmployeeID"));} if(customerVOJson.containsKey("salesmanEmployeeNumber") && customerVOJson.getString("salesmanEmployeeNumber")!=null){customerVO.setSalesmanEmployeeNumber(Integer.valueOf(customerVOJson.getString("salesmanEmployeeNumber")));} if(customerVOJson.containsKey("deliveredTaxTableID") && customerVOJson.getString("deliveredTaxTableID")!=null){customerVO.setDeliveredTaxTableID((short) customerVOJson.getInt("deliveredTaxTableID"));} if(customerVOJson.containsKey("defaultTaxTableID")&& customerVOJson.getString("defaultTaxTableID")!=null){customerVO.setDefaultTaxTableID((short) customerVOJson.getInt("defaultTaxTableID"));} if(customerVOJson.containsKey("secondaryTaxTableID")&& customerVOJson.getString("secondaryTaxTableID")!=null){customerVO.setSecondaryTaxTableID((short)customerVOJson.getInt("secondaryTaxTableID"));} if(customerVOJson.containsKey("salesIDNum")){customerVO.setSalesIDNum(customerVOJson.getString("salesIDNum"));} if(customerVOJson.containsKey("customerNoteID")&& customerVOJson.getString("customerNoteID")!=null){customerVO.setCustomerNoteID((short)customerVOJson.getInt("customerNoteID"));} if(customerVOJson.containsKey("customerNote")){customerVO.setCustomerNote(customerVOJson.getString("customerNote"));} if(customerVOJson.containsKey("refNoteHandlingID")&& customerVOJson.getString("refNoteHandlingID")!=null){customerVO.setREFNoteHandlingID((byte) customerVOJson.getInt("refNoteHandlingID"));} if(customerVOJson.containsKey("billTypeCode")){customerVO.setBillTypeCode(customerVOJson.getString("billTypeCode"));} if(customerVOJson.containsKey("billType")){customerVO.setBillType(customerVOJson.getString("billType"));} if(customerVOJson.containsKey("minAmtForPO") && customerVOJson.getString("minAmtForPO")!=null){customerVO.setMinAmtForPO(customerVOJson.getInt("minAmtForPO"));} if(customerVOJson.containsKey("backOrderAllowed") && customerVOJson.getString("backOrderAllowed")!=null){customerVO.setBackOrderAllowed(customerVOJson.getBoolean("backOrderAllowed"));} if(customerVOJson.containsKey("customerVehicleListQuantity") && customerVOJson.getString("customerVehicleListQuantity")!=null){customerVO.setCustomerVehicleListQuantity((short)customerVOJson.getInt("customerVehicleListQuantity"));} if(customerVOJson.containsKey("specialOrderAllowed") && customerVOJson.getString("specialOrderAllowed")!=null){customerVO.setSpecialOrderAllowed(customerVOJson.getBoolean("specialOrderAllowed"));} if(customerVOJson.containsKey("printBalanceOnInvoice") && customerVOJson.getString("printBalanceOnInvoice")!=null){customerVO.setPrintBalanceOnInvoice(customerVOJson.getBoolean("printBalanceOnInvoice"));} if(customerVOJson.containsKey("allowEmployeeEraseCore") && customerVOJson.getString("allowEmployeeEraseCore")!=null){customerVO.setAllowEmployeeEraseCore(customerVOJson.getBoolean("allowEmployeeEraseCore"));} if(customerVOJson.containsKey("accountActive") && customerVOJson.getString("accountActive")!=null){customerVO.setAccountActive(customerVOJson.getBoolean("accountActive"));} if(customerVOJson.containsKey("authorizedBuyersOnly") && customerVOJson.getString("authorizedBuyersOnly")!=null){customerVO.setAuthorizedBuyersOnly(customerVOJson.getBoolean("authorizedBuyersOnly"));} if(customerVOJson.containsKey("miscInvDiscountRefOptionCD")){customerVO.setMiscInvDiscountRefOptionCD(customerVOJson.getString("miscInvDiscountRefOptionCD"));} if(customerVOJson.containsKey("miscInvDiscPercent") && customerVOJson.getString("miscInvDiscPercent")!=null){customerVO.setMiscInvDiscPercent((short) customerVOJson.getInt("miscInvDiscPercent"));} if(customerVOJson.containsKey("checkForMiscChgExemptions")&& customerVOJson.getString("checkForMiscChgExemptions")!=null){customerVO.setMiscChgExempt(customerVOJson.getBoolean("checkForMiscChgExemptions"));} if(customerVOJson.containsKey("hasSavedInvoice")&& customerVOJson.getString("hasSavedInvoice")!=null){customerVO.setSavedInvoice(customerVOJson.getBoolean("hasSavedInvoice"));} if(customerVOJson.containsKey("hasPendingPO")&& customerVOJson.getString("hasPendingPO")!=null){customerVO.setPendingPO(customerVOJson.getBoolean("hasPendingPO"));} if(customerVOJson.containsKey("usualRefPriceSheetCD")){customerVO.setUsualRefPriceSheetCD(customerVOJson.getString("usualRefPriceSheetCD"));} if(customerVOJson.containsKey("usualPriceMarkupPercent")&& customerVOJson.getString("usualPriceMarkupPercent")!=null){customerVO.setUsualPriceMarkupPercent((short) customerVOJson.getInt("usualPriceMarkupPercent"));} if(customerVOJson.containsKey("usualPriceRefCurrencyRoundingCD")){customerVO.setUsualPriceRefCurrencyRoundingCD(customerVOJson.getString("usualPriceRefCurrencyRoundingCD"));} if(customerVOJson.containsKey("extraInvCopies")&& customerVOJson.getString("extraInvCopies")!=null){customerVO.setExtraInvCopies((byte) customerVOJson.getInt("extraInvCopies"));} if(customerVOJson.containsKey("taxStatusPrimaryRefOptionCD")){customerVO.setTaxStatusPrimaryRefOptionCD(customerVOJson.getString("taxStatusPrimaryRefOptionCD"));} if(customerVOJson.containsKey("taxStatusPrimaryCodeDescription")){customerVO.setTaxStatusPrimaryCodeDescription(customerVOJson.getString("taxStatusPrimaryCodeDescription"));} if(customerVOJson.containsKey("taxExemptNumberPrimary")){customerVO.setTaxExemptNumberPrimary(customerVOJson.getString("taxExemptNumberPrimary"));} if(customerVOJson.containsKey("taxExemptPrimaryExpDate")){ Date TaxExemptPrimaryExpDate = ConvertStringToDate(customerVOJson.getString("taxExemptPrimaryExpDate")); customerVO.setTaxExemptPrimaryExpDate(TaxExemptPrimaryExpDate);} if(customerVOJson.containsKey("primaryTaxTableVO") && !customerVOJson.getJSONObject("primaryTaxTableVO").isNullObject()){ customerVO.setPrimaryTaxTable(convertJSONToTaxTableVo(customerVOJson.getJSONObject("primaryTaxTableVO"))); } if(customerVOJson.containsKey("taxStatusSecondaryRefOptionCD")){customerVO.setTaxStatusSecondaryRefOptionCD(customerVOJson.getString("taxStatusSecondaryRefOptionCD"));} if(customerVOJson.containsKey("taxStatusSecondaryCodeDescription")){customerVO.setTaxStatusSecondaryCodeDescription(customerVOJson.getString("taxStatusSecondaryCodeDescription"));} if(customerVOJson.containsKey("taxExemptNumberSecondary")){customerVO.setTaxExemptNumberSecondary(customerVOJson.getString("taxExemptNumberSecondary"));} if(customerVOJson.containsKey("taxExemptSecondaryExpDate")){customerVO.setTaxExemptSecondaryExpDate(ConvertStringToDate(customerVOJson.getString("taxExemptSecondaryExpDate")));} if(customerVOJson.containsKey("secondaryTaxTableVO") && !customerVOJson.getJSONObject("secondaryTaxTableVO").isNullObject()){customerVO.setSecondaryTaxTable(convertJSONToTaxTableVo(customerVOJson.getJSONObject("secondaryTaxTableVO")));} if(customerVOJson.containsKey("alternateCoreCustomerID")&& customerVOJson.getString("alternateCoreCustomerID")!=null){customerVO.setAlternateCoreCustomerID(customerVOJson.getInt("alternateCoreCustomerID"));} if(customerVOJson.containsKey("alternateCoreCustomerTax") && !customerVOJson.getJSONObject("alternateCoreCustomerTax").isNullObject()){ JSONObject obj = customerVOJson.getJSONObject("alternateCoreCustomerTax"); TaxInfoVO tiv =null; if(obj!=null && !obj.isNullObject()){ tiv= new TaxInfoVO(); if(obj.containsKey("taxExemptPrimaryExpDate")) tiv.setTaxExemptPrimaryExpDate(ConvertStringToDate(obj.getString("taxExemptPrimaryExpDate"))); if(obj.containsKey("taxExemptSecondaryExpDate")) tiv.setTaxExemptSecondaryExpDate(ConvertStringToDate(obj.getString("taxExemptSecondaryExpDate"))); if(obj.containsKey("taxStatusPrimaryRefOptionCD")) tiv.setTaxStatusPrimaryRefOptionCD(obj.getString("taxStatusPrimaryRefOptionCD")); if(obj.containsKey("taxStatusSecondaryRefOptionCD")) tiv.setTaxStatusSecondaryRefOptionCD(obj.getString("taxStatusSecondaryRefOptionCD")); if(obj.containsKey("coreSalesTaxStatusPrimaryRefOptionCd")) tiv.setCoreSalesTaxStatusPrimaryRefOptionCd(obj.getString("coreSalesTaxStatusPrimaryRefOptionCd")); if(obj.containsKey("coreSalesTaxStatusSecondaryRefOptionCd")) tiv.setCoreSalesTaxStatusSecondaryRefOptionCd(obj.getString("coreSalesTaxStatusSecondaryRefOptionCd")); if(obj.containsKey("coreReturnsTaxStatusPrimaryRefOptionCd")) tiv.setCoreReturnsTaxStatusPrimaryRefOptionCd(obj.getString("coreReturnsTaxStatusPrimaryRefOptionCd")); if(obj.containsKey("coreReturnsTaxStatusSecondaryRefOptionCd")) tiv.setCoreReturnsTaxStatusSecondaryRefOptionCd(obj.getString("coreReturnsTaxStatusSecondaryRefOptionCd")); } customerVO.setAlternateCoreCustomerTax(tiv);} if(customerVOJson.containsKey("customerStatementAddressVO") && !customerVOJson.getJSONObject("customerStatementAddressVO").isNullObject()){ JSONObject jObj = customerVOJson.getJSONObject("customerStatementAddressVO"); CustomerStatementAddressVO cust = null; if(jObj!=null && !jObj.isNullObject()){ cust =new CustomerStatementAddressVO(); if(jObj.containsKey("name")){cust.setName(jObj.getString("name"));} if(jObj.containsKey("address")){ JSONObject addr = jObj.getJSONObject("address"); AddressVO aVo = null; if(addr!=null && !addr.isNullObject()){ aVo =new AddressVO(); if(addr.containsKey("address1")){aVo.setAddress1(addr.getString("address1"));} if(addr.containsKey("address2")){aVo.setAddress2(addr.getString("address2"));} if(addr.containsKey("address3")){aVo.setAddress3(addr.getString("address3"));} if(addr.containsKey("address4")){aVo.setAddress4(addr.getString("address4"));} if(addr.containsKey("city")){aVo.setCity(addr.getString("city"));} if(addr.containsKey("stateCD")){aVo.setStateCD(addr.getString("stateCD"));} if(addr.containsKey("postalCode")){aVo.setPostalCode(addr.getString("postalCode"));} if(addr.containsKey("countryCD")){aVo.setCountryCD(addr.getString("countryCD"));} if(addr.containsKey("extension")){aVo.setExtension(addr.getString("extension"));} if(addr.containsKey("phone")){aVo.setPhone(addr.getString("phone"));} } cust.setAddress(aVo);} } customerVO.setCustomerStatementAddressVO(cust);} if(customerVOJson.containsKey("customerBlanketPOs")) { JSONArray jsonArray = customerVOJson.getJSONArray("customerBlanketPOs"); Vector v = null; if(!jsonArray.isEmpty()){ v= new Vector(); CustomerBlanketPo customerBlanketPo = new CustomerBlanketPo(); Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if(j.containsKey("key"))customerBlanketPo.setKey((CustomerBlanketPoKey) j.get("key")); if(j.containsKey("customerId") && j.getString("customerId")!=null)customerBlanketPo.setCustomerId( j.getInt("customerId")); if(j.containsKey("blanketPoNum"))customerBlanketPo.setBlanketPoNum( j.getString("blanketPoNum")); if(j.containsKey("beginDate") && j.getString("beginDate")!=null)customerBlanketPo.setBeginDate(ConvertStringToDate(j.getString("beginDate"))); if(j.containsKey("loc") && j.getString("loc")!=null)customerBlanketPo.setLoc( j.getInt("loc")); if(j.containsKey("endDate") && j.getString("endDate")!=null)customerBlanketPo.setEndDate( ConvertStringToDate(j.getString("endDate"))); if(j.containsKey("lastModifiedDate") && j.getString("lastModifiedDate")!=null)customerBlanketPo.setLastModifiedDate(ConvertStringToDate( j.getString("taxTableId"))); if(j.containsKey("maximumAmountAllowed") && j.getString("maximumAmountAllowed")!=null)customerBlanketPo.setMaximumAmountAllowed( convertStringToBigDecimal(j.getString("maximumAmountAllowed"))); if(j.containsKey("modifiedByEmployeeId") && j.getString("modifiedByEmployeeId")!=null)customerBlanketPo.setModifiedByEmployeeId( j.getInt("modifiedByEmployeeId")); v.add(customerBlanketPo); } } customerVO.setCustomerBlanketPOs(v); } if(customerVOJson.containsKey("customerARVO") && !customerVOJson.getJSONObject("customerARVO").isNullObject()){ JSONObject jsonObject = customerVOJson.getJSONObject("customerARVO"); CustomerARVO customerARVO = new CustomerARVO(); if(jsonObject!=null && !jsonObject.isEmpty()){ if(jsonObject.containsKey("id") && jsonObject.getString("id")!=null){customerARVO.setId(jsonObject.getInt("id"));} if(jsonObject.containsKey("text")){customerARVO.setText(jsonObject.getString("text"));} if(jsonObject.containsKey("creditLimit") && jsonObject.getString("creditLimit")!=null){customerARVO.setCreditLimit(jsonObject.getInt("creditLimit"));} if(jsonObject.containsKey("currentBal")){customerARVO.setCurrentBal(convertStringToBigDecimal(jsonObject.getString("currentBal")));} if(jsonObject.containsKey("badDebtAcct") && jsonObject.getString("badDebtAcct")!=null){customerARVO.setBadDebtAcct(jsonObject.getBoolean("badDebtAcct"));} } customerVO.setCustomerARVO(customerARVO);} if(customerVOJson.containsKey("customerDeliveryVO")){ JSONObject jo = customerVOJson.getJSONObject("customerDeliveryVO"); CustomerDeliveryVO customerDeliverVO =null; if(jo!=null && !jo.isNullObject()){ customerDeliverVO = new CustomerDeliveryVO(); if(jo.containsKey("customerID") && jo.getString("customerID")!=null){customerDeliverVO.setCustomerID(jo.getInt("customerID"));} if(jo.containsKey("id") && jo.getString("id")!=null){customerDeliverVO.setId(jo.getInt("id"));} if(jo.containsKey("version") && jo.getString("version")!=null){customerDeliverVO.setVersion(jo.getInt("version"));} if(jo.containsKey("externalIdentifier")){customerDeliverVO.setExternalIdentifier(jo.getString("externalIdentifier"));} if(jo.containsKey("loc") && jo.getString("loc")!=null){customerDeliverVO.setLOC(jo.getInt("loc"));} if(jo.containsKey("deliveryRefOptionCD")){customerDeliverVO.setDeliveryRefOptionCD(jo.getString("deliveryRefOptionCD"));} if(jo.containsKey("deliveryOptionDescripion")){customerDeliverVO.setDeliveryOptionDescripion(jo.getString("deliveryOptionDescripion"));} if(jo.containsKey("deliveryRouteCD")){customerDeliverVO.setDeliveryRouteCD(jo.getString("deliveryRouteCD"));} if(jo.containsKey("deliveryPriorityID") && jo.getString("deliveryPriorityID")!=null){customerDeliverVO.setDeliveryPriorityID((byte) jo.getInt("deliveryPriorityID"));} if(jo.containsKey("travelTimeCustomer") && jo.getString("travelTimeCustomer")!=null){customerDeliverVO.setTravelTimeCustomer((short) jo.getInt("travelTimeCustomer"));} if(jo.containsKey("distanceToCustomer") && jo.getString("distanceToCustomer")!=null){customerDeliverVO.setDistanceToCustomer((short) jo.getInt("distanceToCustomer"));} if(jo.containsKey("directions")){customerDeliverVO.setDirections(jo.getString("directions"));} if(jo.containsKey("minAmtFreeDelivery") && jo.getString("minAmtFreeDelivery")!=null){customerDeliverVO.setMinAmtFreeDelivery(convertStringToBigDecimal(jo.getString("minAmtFreeDelivery")));} if(jo.containsKey("deliveryCharge") && jo.getString("deliveryCharge")!=null){customerDeliverVO.setDeliveryCharge(convertStringToBigDecimal(jo.getString("deliveryCharge")));} } customerVO.setCustomerDeliveryVO(customerDeliverVO);} if(customerVOJson.containsKey("miscChargeExemptions")){ //customerVO.setMiscChargeExemptions(customerVOJson.get("miscChargeExemptions")!=null?(Vector) customerVOJson.get("miscChargeExemptions"):null); customerVO.setMiscChargeExemptions(null);} if(customerVOJson.containsKey("customerPUGPList")){ JSONArray jsonArray = customerVOJson.getJSONArray("customerPUGPList"); Vector v = null; if(!jsonArray.isEmpty()){ v= new Vector(); CustomerPUGPVO customerPUGPVO =null; Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { customerPUGPVO= new CustomerPUGPVO(); JSONObject j = JSONObject.fromObject(itr2.next()); if(j.containsKey("customerID")&& j.getString("customerID")!=null)customerPUGPVO.setCustomerID( j.getInt("customerID")); if(j.containsKey("amountBegin") && j.getString("amountBegin")!=null)customerPUGPVO.setAmountBegin(convertStringToBigDecimal(j.getString("amountBegin"))); if(j.containsKey("amountEnd"))customerPUGPVO.setAmountEnd( convertStringToBigDecimal(j.getString("amountEnd"))); if(j.containsKey("ID") && j.getString("ID")!=null)customerPUGPVO.setID(j.getInt("ID")); if(j.containsKey("LOC") && j.getString("LOC")!=null)customerPUGPVO.setLOC( j.getInt("LOC")); if(j.containsKey("percent") && j.getString("percent")!=null)customerPUGPVO.setPercent( convertStringToBigDecimal(j.getString("percent"))); if(j.containsKey("refCurrencyRoundingCD") && j.getString("refCurrencyRoundingCD")!=null)customerPUGPVO.setRefCurrencyRoundingCD( j.getString("taxTableId")); if(j.containsKey("id") && j.getString("id")!=null)customerPUGPVO.setId(j.getInt("id")); v.add(customerPUGPVO); } } customerVO.setCustomerPUGPList(v); } if(customerVOJson.containsKey("customerPurchaseCardList")){ JSONArray jsonArray = customerVOJson.getJSONArray("customerPurchaseCardList"); Vector v = null; customerVO.setCustomerPurchaseCardList(v); } if(customerVOJson.containsKey("authorizedBuyers")){ JSONArray jsonArray = customerVOJson.getJSONArray("authorizedBuyers"); Vector v = new Vector(); if(!jsonArray.isEmpty()){ Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if(!j.isNullObject()){ if(j.containsKey("ID") && j.containsKey("value")){ IDValuePairVO idValuePairVO = new IDValuePairVO(j.getString("ID"),j.getString("value")); v.add(idValuePairVO); } } } } customerVO.setAuthorizedBuyers(v); } if(customerVOJson.containsKey("lastModifiedDate")){customerVO.setLastModifiedDate(convertStringToTimeStamp(customerVOJson.getString("lastModifiedDate")));} if(customerVOJson.containsKey("modifiedByEmployeeID") && customerVOJson.getString("modifiedByEmployeeID")!=null){customerVO.setModifiedByEmployeeID(customerVOJson.getInt("modifiedByEmployeeID"));} if(customerVOJson.containsKey("ipAddress")){customerVO.setIPAddress(customerVOJson.getString("ipAddress"));} if(customerVOJson.containsKey("transmitJSASales")){customerVO.setTransmitJSASales(customerVOJson.getString("transmitJSASales"));} if(customerVOJson.containsKey("transmitNationalSales")){customerVO.setTransmitNationalSales(customerVOJson.getString("transmitNationalSales"));} if(customerVOJson.containsKey("printCatalogNotesOnInvoice") && customerVOJson.getString("printCatalogNotesOnInvoice")!=null){customerVO.setPrintCatalogNotesOnInvoice(customerVOJson.getBoolean("printCatalogNotesOnInvoice"));} if(customerVOJson.containsKey("vehiclesExist") && customerVOJson.getString("vehiclesExist")!=null){customerVO.setVehiclesExist(customerVOJson.getBoolean("vehiclesExist"));} if(customerVOJson.containsKey("typicallyPresentDuringInvoicing") && customerVOJson.getString("typicallyPresentDuringInvoicing")!=null){customerVO.setTypicallyPresentDuringInvoicing(customerVOJson.getBoolean("typicallyPresentDuringInvoicing"));} if(customerVOJson.containsKey("servingStore")){customerVO.setServingStore(customerVOJson.getString("servingStore"));} if(customerVOJson.containsKey("priorityPlus")){ Boolean pp = customerVOJson.getBoolean("priorityPlus"); customerVO.setPriorityPlus(pp==true?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(customerVOJson.containsKey("dnsCustomer")){ boolean b = customerVOJson.getBoolean("dnsCustomer"); customerVO.setDnsCustomer((b==true)?LockableBoolean.TRUE:LockableBoolean.FALSE); } if(customerVOJson.containsKey("primaryTaxNumber")){customerVO.setPrimaryTaxNumber(customerVOJson.getString("primaryTaxNumber"));} if(customerVOJson.containsKey("secondaryTaxNumber")){customerVO.setSecondaryTaxNumber(customerVOJson.getString("secondaryTaxNumber"));} if(customerVOJson.containsKey("ibsAccount") && customerVOJson.getString("ibsAccount")!=null){customerVO.setIbsAccount(customerVOJson.getBoolean("ibsAccount"));} if(customerVOJson.containsKey("emailAddress")){customerVO.setEmailAddress(customerVOJson.getString("emailAddress"));} if(customerVOJson.containsKey("encodedName")){customerVO.setEncodedName(customerVOJson.getString("encodedName"));} if(customerVOJson.containsKey("directShipEligible") && customerVOJson.getString("directShipEligible")!=null){customerVO.setDirectShipEligible(customerVOJson.getBoolean("directShipEligible"));} if(customerVOJson.containsKey("defaultRefElectronicInvoiceTypeCd")){customerVO.setDefaultRefElectronicInvoiceTypeCd(customerVOJson.getString("defaultRefElectronicInvoiceTypeCd"));} if(customerVOJson.containsKey("allowOnlyCoreSales") && customerVOJson.getString("allowOnlyCoreSales")!=null){customerVO.setAllowOnlyCoreSales(customerVOJson.getBoolean("allowOnlyCoreSales"));} if(customerVOJson.containsKey("cfdiName")){customerVO.setCfdiName(customerVOJson.getString("cfdiName"));} if(customerVOJson.containsKey("einvoiceEmailAddress")){customerVO.setEinvoiceEmailAddress(customerVOJson.getString("einvoiceEmailAddress"));} if(customerVOJson.containsKey("cepdiCorporationType")){customerVO.setCepdiCorporationType(customerVOJson.getString("cepdiCorporationType"));} if(customerVOJson.containsKey("priceLocked") && customerVOJson.getString("priceLocked")!=null){customerVO.setPriceLocked(customerVOJson.getInt("priceLocked"));} return customerVO; } private Timestamp convertStringToTimeStamp(String date) { Timestamp timestamp = null; if(date!=null){ timestamp = Timestamp.valueOf(date); } return timestamp; } private TaxTableVO convertJSONToTaxTableVo(JSONObject primaryTaxTablejson) { TaxTableVO taxTableVO = null; if(primaryTaxTablejson!=null && !primaryTaxTablejson.isNullObject()){ taxTableVO = new TaxTableVO(); if(primaryTaxTablejson.containsKey("id") && primaryTaxTablejson.getString("id")!=null) taxTableVO.setID((short) primaryTaxTablejson.getInt("id")); if(primaryTaxTablejson.containsKey("maximumTaxBracket") && primaryTaxTablejson.getString("maximumTaxBracket")!=null) taxTableVO.setMaximumTaxBracket(primaryTaxTablejson.getInt("maximumTaxBracket")); if(primaryTaxTablejson.containsKey("validateCoreReturnTaxNumber") && primaryTaxTablejson.getString("validateCoreReturnTaxNumber")!=null) taxTableVO.setValidateCoreReturnTaxNumber(primaryTaxTablejson.getBoolean("validateCoreReturnTaxNumber")); if(primaryTaxTablejson.containsKey("salesTaxPercent")) taxTableVO.setSalesTaxPercent(convertStringToBigDecimal(primaryTaxTablejson.getString("salesTaxPercent"))); if(primaryTaxTablejson.containsKey("secondaryTaxTableID") && primaryTaxTablejson.getString("secondaryTaxTableID")!=null) taxTableVO.setSecondaryTaxTableID((short) primaryTaxTablejson.getInt("secondaryTaxTableID")); if(primaryTaxTablejson.containsKey("loc") && primaryTaxTablejson.getString("id")!=null) taxTableVO.setLOC(primaryTaxTablejson.getInt("loc")); if(primaryTaxTablejson.containsKey("maxTaxAmtCharged")) taxTableVO.setMaxTaxAmtCharged(convertStringToBigDecimal(primaryTaxTablejson.getString("maxTaxAmtCharged"))); if(primaryTaxTablejson.containsKey("refTaxMethodCD")) taxTableVO.setRefTaxMethodCD(primaryTaxTablejson.getString("refTaxMethodCD")); if(primaryTaxTablejson.containsKey("taxLABRefOptionCD")) taxTableVO.setTaxLABRefOptionCD(primaryTaxTablejson.getString("taxLABRefOptionCD")); if(primaryTaxTablejson.containsKey("taxTelRefOptionCD")) taxTableVO.setTaxTelRefOptionCD(primaryTaxTablejson.getString("taxTelRefOptionCD")); if(primaryTaxTablejson.containsKey("taxFrtRefOptionCD")) taxTableVO.setTaxFrtRefOptionCD(primaryTaxTablejson.getString("taxFrtRefOptionCD")); if(primaryTaxTablejson.containsKey("taxCORSalesRefOptionCD")) taxTableVO.setTaxCORSalesRefOptionCD(primaryTaxTablejson.getString("taxCORSalesRefOptionCD")); if(primaryTaxTablejson.containsKey("taxCORReturnsRefOptionCD")) taxTableVO.setTaxCORReturnsRefOptionCD(primaryTaxTablejson.getString("taxCORReturnsRefOptionCD")); if(primaryTaxTablejson.containsKey("taxENVRefOptionCD")) taxTableVO.setTaxENVRefOptionCD(primaryTaxTablejson.getString("taxENVRefOptionCD")); if(primaryTaxTablejson.containsKey("taxOTHRefOptionCD")) taxTableVO.setTaxOTHRefOptionCD(primaryTaxTablejson.getString("taxOTHRefOptionCD")); if(primaryTaxTablejson.containsKey("taxMISRefOptionCD")) taxTableVO.setTaxMISRefOptionCD(primaryTaxTablejson.getString("taxMISRefOptionCD")); if(primaryTaxTablejson.containsKey("taxServiceChargesRefOptionCD")) taxTableVO.setTaxServiceChargesRefOptionCD(primaryTaxTablejson.getString("taxServiceChargesRefOptionCD")); if(primaryTaxTablejson.containsKey("taxFederalEXCChgRefOptionCD")) taxTableVO.setTaxFederalEXCChgRefOptionCD(primaryTaxTablejson.getString("taxFederalEXCChgRefOptionCD")); if(primaryTaxTablejson.containsKey("taxDelRefOptionCD")) taxTableVO.setTaxDelRefOptionCD(primaryTaxTablejson.getString("taxDelRefOptionCD")); if(primaryTaxTablejson.containsKey("taxWLCRefOptionCD")) taxTableVO.setTaxWLCRefOptionCD(primaryTaxTablejson.getString("taxWLCRefOptionCD")); if(primaryTaxTablejson.containsKey("taxTableBracket")){ JSONArray jsonArray = primaryTaxTablejson.getJSONArray("taxTableBracket"); Vector v = null; if(!jsonArray.isEmpty()){ v= new Vector(); TaxTableBracket taxTableBracket =null; Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); taxTableBracket= new TaxTableBracket(); if(j.containsKey("key"))taxTableBracket.setKey((TaxTableBracketKey) j.get("key")); if(j.containsKey("loc") && j.getString("loc")!=null)taxTableBracket.setLoc( j.getInt("loc")); if(j.containsKey("taxableSaleAmount"))taxTableBracket.setTaxableSaleAmount( convertStringToBigDecimal(j.getString("taxableSaleAmount"))); if(j.containsKey("taxTableId") && j.getString("taxTableId")!=null)taxTableBracket.setTaxTableId( j.getInt("taxTableId")); if(j.containsKey("taxCharged"))taxTableBracket.setTaxCharged( convertStringToBigDecimal(j.getString("taxCharged"))); v.add(taxTableBracket); } } taxTableVO.setTaxtableBracket(v); } if(primaryTaxTablejson.containsKey("taxLoyaltyRedemptions")) taxTableVO.setTaxLoyaltyRedemptions(primaryTaxTablejson.getString("taxLoyaltyRedemptions")); if(primaryTaxTablejson.containsKey("taxBagRefOptionCD")) taxTableVO.setTaxBagRefOptionCD(primaryTaxTablejson.getString("taxBagRefOptionCD")); if(primaryTaxTablejson.containsKey("description")) taxTableVO.setDescription(primaryTaxTablejson.getString("description"));} return taxTableVO; } private Date ConvertStringToDate(String taxExemptPrimaryExpDate) { String format= "yyyy-MM-dd hh:mm:ss"; try{ SimpleDateFormat df = new SimpleDateFormat(format); return new java.sql.Date(df.parse(taxExemptPrimaryExpDate).getTime()); } catch (Exception e){ return null; } } private Date ConvertStringToDate2(String taxExemptPrimaryExpDate) { String format= "yyyy-MM-dd"; try{ SimpleDateFormat df = new SimpleDateFormat(format); return new java.sql.Date(df.parse(taxExemptPrimaryExpDate).getTime()); } catch (Exception e){ return null; } } private BigDecimal convertStringToBigDecimal(String s){ BigDecimal bigDecimalValue = new BigDecimal((String) s); bigDecimalValue.setScale(4); return bigDecimalValue; } public Integer saveInvoice(InvoiceVO invoiceContent,String remoteStoreIp) { HttpMethod taapRequest = null; protocol="http://"+remoteStoreIp+":"; int statusCode; Integer invoiceID = null; byte[] responseBody; String saveInvoiceURL = null; saveInvoiceURL = protocol + "8080/TAMSII/Servlets/prsaveinvoice"; logger.debug("saveInvoiceURL " + saveInvoiceURL); HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(saveInvoiceURL); JSONObject jsonObject = new JSONObject(); long conMillSec1 = System.currentTimeMillis(); jsonObject.put("invoiceDetails",ConversionToVO.convertInvoiceVOToJson(invoiceContent)); long conMillSecEnd1 = System.currentTimeMillis(); long convDuration1 = (conMillSecEnd1-conMillSec1); createAndLogConversionDataToAzure("Conversion of convertInvoiceVOToJson ends",remoteStoreIp,invoiceContent.toString(), convDuration1); StringRequestEntity reqEntity = null; String json_string = jsonObject.toString(); try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("saveInvoiceURL Calling: " + saveInvoiceURL); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making saveInvoice remote call",json_string,remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); String result = new String(responseBody); invoiceID = Integer.parseInt(result); } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return invoiceID; } public Integer findMessageHeaderBySalesOrderId(Integer id, Integer loc, String ipAddress) { String result = null; String specialOrderedMessagesURL = null; HttpMethod taapRequest = null; protocol="http://"+ipAddress+":"; int statusCode; Integer empId=null; byte[] responseBody; final StringBuffer query = new StringBuffer( 20 ); appendQueryParam( query, EMP_ID, id.toString()); query.append("&"); appendQueryParam( query, LOC, loc.toString()); specialOrderedMessagesURL = protocol + TAAP_FIND_MESSAGE_HEDER_URL + "?" + query.toString(); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(specialOrderedMessagesURL); try { logger.debug("Special Ordered Messages: Calling: " + specialOrderedMessagesURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making findMessageHeaderBySalesOrderId remote call", query.toString(), ipAddress, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()) { logger.info("result from server is " + Integer.parseInt(result)); empId = Integer.parseInt(result); return empId; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return empId; } public void updateSalesOrderRefOrderType(Map updateRefOrderType) throws IOException { String updateRefOrderTypeURL = null; HttpMethod taapRequest = null; String servingStoreIP = (String) updateRefOrderType.get(SERVING_STORE_IP_ADDRESS); protocol = "http://" + servingStoreIP + ":"; int statusCode; final StringBuffer query = new StringBuffer(20); appendQueryParam(query, SALES_ORDER_ID, (String) updateRefOrderType.get(SALES_ORDER_ID)); query.append("&"); appendQueryParam(query, LOC, (String) updateRefOrderType.get(LOC)); updateRefOrderTypeURL = protocol + TAAP_UPDATE_REF_ORDER_TYPE_URL + "?" + query.toString(); HttpClient httpClient = new HttpClient(); taapRequest = new GetMethod(updateRefOrderTypeURL); try { logger.warn("TaapRouter: Calling: " + updateRefOrderTypeURL); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making updateSalesOrderRefOrderType remote call", query.toString(), servingStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); throw new IOException(e.getMessage()); } finally { taapRequest.releaseConnection(); } } public TenderTypeProfileVO getTenderTypeProfile(String remoteStoreIp, int refTenderTypeID) { String getTenderTypeProfileURL = null; String getTenderTypeProfile = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/tendertypeprofile"; logger.debug("getTenderTypeProfile = " + getTenderTypeProfile); final StringBuffer query = new StringBuffer(20); appendQueryParam(query, REF_TENDER_TYPE_ID, String.valueOf(refTenderTypeID)); getTenderTypeProfileURL = getTenderTypeProfile + "?" + query.toString(); logger.warn("getTenderTypeProfileAddressURL " + getTenderTypeProfileURL); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getTenderTypeProfileURL); TenderTypeProfileVO tenderTypeProfileVO =null; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getTenderTypeProfile remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); logger.debug("statusCode = " + statusCode); if (statusCode == HttpStatus.SC_OK) { final byte[] tenderTypeProfileResponse = httpGet.getResponseBody(); String result = new String(tenderTypeProfileResponse); if(result!=null && result!="" && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("tenderTypeProfile") && !jsonObject.getJSONObject("tenderTypeProfile").isNullObject()) { JSONObject tenderTypeProfileJSON = jsonObject.getJSONObject("tenderTypeProfile"); long conMillSec = System.currentTimeMillis(); tenderTypeProfileVO = convertTenderTypeProfileJSONtoVO(tenderTypeProfileJSON); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertTenderTypeProfileJSONtoVO ends",remoteStoreIp,tenderTypeProfileJSON.toString(), convDuration); } } }else{ logger.error("Server encountered an http error while getting tenderType Profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting tenderType Profile"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting tenderType Profile"); } catch (Exception exception) { logger.error("Exception occured while getting tenderType Profile"); } finally { httpGet.releaseConnection(); } return tenderTypeProfileVO; } private TenderTypeProfileVO convertTenderTypeProfileJSONtoVO(JSONObject tenderTypeProfileJSON) { TenderTypeProfileVO tenderTypeProfileVO = new TenderTypeProfileVO(); if (tenderTypeProfileJSON.containsKey("refTenderTypeID")) tenderTypeProfileVO.setRefTenderTypeID((byte) tenderTypeProfileJSON.getInt("refTenderTypeID")); if (tenderTypeProfileJSON.containsKey("location")) tenderTypeProfileVO.setLocation(tenderTypeProfileJSON.getInt("location")); if (tenderTypeProfileJSON.containsKey("tenderTypeAccepted")) tenderTypeProfileVO.setTenderTypeAccepted((byte) tenderTypeProfileJSON.getInt("tenderTypeAccepted")); if(tenderTypeProfileJSON.containsKey("lastModifiedDate") && tenderTypeProfileJSON.getString("lastModifiedDate")!=null){ tenderTypeProfileVO.setLastModifiedDate(ConvertStringToDate(tenderTypeProfileJSON.getString("lastModifiedDate"))); } if (tenderTypeProfileJSON.containsKey("modifiedByEmployeeID")) tenderTypeProfileVO.setModifiedByEmployeeID(tenderTypeProfileJSON.getInt("modifiedByEmployeeID")); if(tenderTypeProfileJSON.containsKey("sellMinValue")) { String sellMinValue = tenderTypeProfileJSON.get("sellMinValue").toString(); BigDecimal sMinValue = new BigDecimal((String) sellMinValue); sMinValue.setScale(4); tenderTypeProfileVO.setSellMinValue(sMinValue); } if(tenderTypeProfileJSON.containsKey("sellMaxValue")) { String sellMaxValue = tenderTypeProfileJSON.get("sellMaxValue").toString(); BigDecimal sMaxValue = new BigDecimal((String) sellMaxValue); sMaxValue.setScale(4); tenderTypeProfileVO.setSellMaxValue(sMaxValue); } if(tenderTypeProfileJSON.containsKey("reloadMinValue")) { String reloadMinValue = tenderTypeProfileJSON.get("reloadMinValue").toString(); BigDecimal rMinValue = new BigDecimal((String) reloadMinValue); rMinValue.setScale(4); tenderTypeProfileVO.setReloadMinValue(rMinValue); } if(tenderTypeProfileJSON.containsKey("reloadMaxValue")) { String reloadMaxValue = tenderTypeProfileJSON.get("reloadMaxValue").toString(); BigDecimal rMaxValue = new BigDecimal((String) reloadMaxValue); rMaxValue.setScale(4); tenderTypeProfileVO.setReloadMaxValue(rMaxValue); } if (tenderTypeProfileJSON.containsKey("roaTenderTypeAccepted")) tenderTypeProfileVO.setRoaTenderTypeAccepted((byte) tenderTypeProfileJSON.getInt("roaTenderTypeAccepted")); return tenderTypeProfileVO; } public void deleteSavedInvoice(InvoiceVO invoiceVO, Boolean isDeleted, String remoteStoreIP) { HttpMethod taapRequest = null; protocol="http://"+remoteStoreIP+":"; int statusCode; Integer invoiceID = null; byte[] responseBody; String deleteSavedInvoiceURL = null; deleteSavedInvoiceURL = protocol + "8080/TAMSII/Servlets/prDeleteSavedInvoice"; logger.debug("deleteSavedInvoiceURL: " + deleteSavedInvoiceURL); HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(deleteSavedInvoiceURL); taapRequest.setQueryString(new NameValuePair[] { new NameValuePair("isDeleted", isDeleted.toString()) }); JSONObject jsonObject = new JSONObject(); long conMillSec = System.currentTimeMillis(); jsonObject.put("invoiceDetails",ConversionToVO.convertInvoiceVOToJson(invoiceVO)); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertInvoiceVOToJson ends",remoteStoreIP,invoiceVO.toString(), convDuration); StringRequestEntity reqEntity = null; String json_string = jsonObject.toString(); try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("Exception occured while deleting saved invoice "+e.getMessage()); } try { logger.debug("deletesavedInvoice url Calling: " + deleteSavedInvoiceURL); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making deleteSavedInvoice remote call",json_string,remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); } } catch (IOException e) { logger.error("Exception occured while deleting saved invoice "+e.getMessage()); } catch (Exception e) { logger.error("Exception occured while deleting saved invoice "+e.getMessage()); } finally { taapRequest.releaseConnection(); } } //Method to nvoke save iinvoice quote servlet call public SavedInvoiceQuoteVO saveInvoiceQuote(SavedInvoiceQuoteVO saveInvoiceQuote, String remoteStoreIp , Integer loc) throws IOException { HttpMethod taapRequest = null; protocol="http://"+remoteStoreIp+":"; int statusCode; SavedInvoiceQuoteVO invoiceQuote = null; byte[] responseBody; String saveInvoiceQuoteURL = null; saveInvoiceQuoteURL = protocol + "8080/TAMSII/Servlets/prsaveinvoicequote"; logger.debug("saveInvoiceQuoteURL " + saveInvoiceQuoteURL); HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(saveInvoiceQuoteURL); JSONObject jsonObject = new JSONObject(); long conMillSec = System.currentTimeMillis(); jsonObject.put("invoiceQuoteDetails",ConversionToVO.convertSavedInvoiceQuoteToJson(saveInvoiceQuote)); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertSavedInvoiceQuoteToJson ",remoteStoreIp,saveInvoiceQuote.toString(), convDuration); StringRequestEntity reqEntity = null; String json_string = jsonObject.toString(); try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("saveInvoiceQuoteURL Calling: " + saveInvoiceQuoteURL); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making saveInvoiceQuote remote call",json_string,remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { logger.error("Save Invoice Quote is success"); responseBody = taapRequest.getResponseBody(); String result = new String(responseBody); if(result!=null && result!="" && !result.isEmpty()) { JSONObject resultJson = JSONObject.fromObject(result); if (resultJson.containsKey("invoiceQuoteDetails") && !resultJson.getJSONObject("invoiceQuoteDetails").isNullObject()) { //savedInvoiceQuote long conMillSec1 = System.currentTimeMillis(); invoiceQuote = ConversionToVO.convertJsonToSavedInvoiceQuoteVO(resultJson); long conMillSecEnd1 = System.currentTimeMillis(); long conDuration1 = (conMillSecEnd1-conMillSec1); createAndLogConversionDataToAzure("Conversion of convertJsonToSavedInvoiceQuoteVO 1 ",remoteStoreIp,resultJson.toString(), conDuration1); } } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { logger.error("Exception occured while saving quote saved invoice "+e.getMessage()); } catch (Exception e) { logger.error("Exception occured while saving quote saved invoice "+e.getMessage()); } finally { taapRequest.releaseConnection(); } return invoiceQuote; } //Method to call Update Saved invoice servlet public void updateSavedInvoice(InvoiceVO invoiceVO, Integer currentUser, String remoteStoreIP) { HttpMethod taapRequest = null; protocol="http://"+remoteStoreIP+":"; int statusCode; String updateSavedInvoiceURL = null; updateSavedInvoiceURL = protocol + "8080/TAMSII/Servlets/prUpdateSavedInvoice"; logger.debug("updateSavedInvoiceURL: " + updateSavedInvoiceURL); HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(updateSavedInvoiceURL); taapRequest.setQueryString(new NameValuePair[] { new NameValuePair("currentUser", currentUser.toString()) }); JSONObject jsonObject = new JSONObject(); long conMillSec = System.currentTimeMillis(); jsonObject.put("invoiceDetails",ConversionToVO.convertInvoiceVOToJson(invoiceVO)); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertInvoiceVOToJson ends",remoteStoreIP,invoiceVO.toString(), convDuration); StringRequestEntity reqEntity = null; String json_string = jsonObject.toString(); try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("Exception occured while update saved invoice "+e.getMessage()); } try { logger.debug("updateSavedInvoice url Calling: " + updateSavedInvoiceURL); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making updateSavedInvoice remote call",json_string,remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); } } catch (IOException e) { logger.error("Exception occured while updating saved invoice "+e.getMessage()); } catch (Exception e) { logger.error("Exception occured while updating saved invoice "+e.getMessage()); } finally { taapRequest.releaseConnection(); } } //Method to fetch saved invoice quote details from remote store public SavedInvoiceQuoteVO getSavedQuoteInvoiceDetails(Integer savedInvoiceId, Integer loc, String remoteStoreIP) { protocol="http://"+remoteStoreIP+":"; String getSavedInvoiceQuoteURL = protocol + "8080/TAMSII/Servlets/getSavedQuoteInvoice"; logger.debug("getSavedInvoiceQuoteURL: " + getSavedInvoiceQuoteURL); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getSavedInvoiceQuoteURL); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("savedInvoiceId", savedInvoiceId.toString()), new NameValuePair("loc", loc.toString()) }); SavedInvoiceQuoteVO savedInvoiceQuoteVO =null; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getSavedQuoteInvoiceDetails remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); logger.debug("statusCode = " + statusCode); if (statusCode == HttpStatus.SC_OK) { final byte[] quoteVOResponse = httpGet.getResponseBody(); String result = new String(quoteVOResponse); if(result!=null && result!="" && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("invoiceQuoteDetails") && !jsonObject.getJSONObject("invoiceQuoteDetails").isNullObject()) { long conMillSec = System.currentTimeMillis(); savedInvoiceQuoteVO = ConversionToVO.convertJsonToSavedInvoiceQuoteVO(jsonObject); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJsonToSavedInvoiceQuoteVO ends",remoteStoreIP,jsonObject.toString(), convDuration); JSONObject jo = jsonObject.getJSONObject("invoiceQuoteDetails"); if (jo.containsKey("quotePrintDate")) { savedInvoiceQuoteVO.setQuotePrintDate(ConvertStringToDate2(jo.getString("quotePrintDate"))); } if (jo.containsKey("lastModifiedDate")) { savedInvoiceQuoteVO.setLastModifiedDate(ConvertStringToDate2(jo.getString("lastModifiedDate"))); } } } }else{ logger.error("Server encountered an http error while getting saved quote response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting saved quote"+httpConnection.getMessage()); } catch (IOException ioException) { logger.error("I/O Exception occured while getting saved quote"+ioException.getMessage()); } catch (Exception exception) { logger.error("Exception occured while getting saved quote"+exception.getMessage()); } finally { httpGet.releaseConnection(); } return savedInvoiceQuoteVO; } public void createAndLogDataToAzure(String message, String payload, String ipAddress, int code, long duration){ logger.warn("Inside createAndLogDataToAzure method :"); Object callCenterFlag = new LaunchDarklyRouter().retreiveFeatureFlagValue("TAMS_LOG_CALLCENTER_REMOTECALL_LOOKUP_USAGE", Boolean.class); Boolean callCenterMetricsEnabled = (callCenterFlag != null && ((String) callCenterFlag).equalsIgnoreCase("true")); if(callCenterMetricsEnabled.booleanValue()) { JSONObject object = new JSONObject(); object.put("RemoteCallPayload", payload); object.put("CallDuration", duration); SwingUtilities.invokeLater(() -> { try { ClientApplicationContext.getClientApplicationContext().getInvoiceDAO().sendMetricsToAzure(message, LogType.Status.REMOTECALL, object.toString(), ipAddress, code, LogType.Feature.CallCenterRemoteCall, ClientApplicationContext.getClientApplicationContext().getLocation()); } catch (ApplicationException e) { logger.error("Unable to write to Azure Log: Encountered Application Exception " + e.getMessage()); } }); } else { logger.warn("Logging is not enabled for Call Center Remote Calls "); } } public void createAndLogConversionDataToAzure(String message, String ipaddress, String payload, long duration) { logger.warn("Inside createAndLogConversionDataToAzure method :"); Object callCenterFlag = new LaunchDarklyRouter().retreiveFeatureFlagValue("TAMS_LOG_CALLCENTER_REMOTECALL_LOOKUP_USAGE", Boolean.class); Boolean callCenterMetricsEnabled = (callCenterFlag != null && ((String) callCenterFlag).equalsIgnoreCase("true")); if(callCenterMetricsEnabled.booleanValue()) { JSONObject object = new JSONObject(); object.put("ConversionPayload", payload); object.put("ConversionDuration", duration); SwingUtilities.invokeLater(() -> { try { ClientApplicationContext.getClientApplicationContext().getInvoiceDAO().sendMetricsToAzure(message, LogType.Status.CONVERSION, object.toString(), ipaddress, 0, LogType.Feature.RemoteCallConversion, ClientApplicationContext.getClientApplicationContext().getLocation()); } catch (ApplicationException e) { logger.error("Unable to write to Azure Log: Encountered Application Exception " + e.getMessage()); } }); } else { logger.warn("Logging is not enabled for Call Center Remote Calls "); } } }