/**
 * Copyright (c) 2010 Penril Datability (M) Sdn Bhd All rights reserved.
 *
 * This software is copyrighted. Under the copyright laws, this software
 * may not be copied, in whole or in part, without prior written consent
 * of Penril Datability (M) Sdn Bhd or its assignees. This software is
 * provided under the terms of a license between Penril Datability (M)
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
 * license.
 */
package my.com.kfh.enterprise.services.ib104_fundtransfer.ibft;

import my.com.kfh.enterprise.services.IBEnterpriseServicesWorkspace;
import my.com.kfh.enterprise.services.common.CommonConstants;
import my.com.kfh.error.exception.IBGenericException;
import my.com.kfh.error.exception.IBServiceException;
import my.com.kfh.error.handler.CommonErrorCode;
import my.com.kfh.error.handler.IBErrorHandler;
import my.com.kfh.web.utils.DataValidator;
import my.com.kfh.web.utils.IBDynaBean;
import my.com.kfh.web.utils.IBDynaBeanManager;
import my.com.kfh.web.utils.IBLogger;
import my.com.kfh.web.utils.IBSessionObjects;
import my.com.kfh.web.utils.IBTimer;
import my.com.kfh.web.utils.constant.ServiceInfo;

/**
 * <pre>
 * PROGRAMMER:Nor Shuhaida Subri
 * CHANGE-NO:
 * TASK-NO:
 * DATE CREATED: Oct 27, 2010
 * TAG AS:
 * REASON(S):
 * MODIFICATION:
 * </pre>
 */

/**
 * <Class description>
 */
public class IBIBFTMaintEditConfirmServices extends IBEnterpriseServicesWorkspace {
	
	private static Class<IBIBFTMaintEditConfirmServices> c_oClass = IBIBFTMaintEditConfirmServices.class;
	private static String VIEWBEAN = "ibftMaintenanceView";

	public IBIBFTMaintEditConfirmServices(IBSessionObjects m_oIBSessionObjects) {
		super(m_oIBSessionObjects);
	}
	
	/**
	 * Sets transfer details to view-bean for display.
	 *
	 * @throws IBGenericException
	 */
	public void verifyInput () throws IBGenericException
	{
		String m_sMethodName = "verifyInput";
		IBTimer m_oTimer = IBLogger.logBSFNMethodEnteringMessage (c_oClass, m_sMethodName);

		IBDynaBean m_oViewBean = null;
		try
		{
			m_oViewBean = (IBDynaBean) getIBDynaBean ().get (VIEWBEAN);
			if (m_oViewBean == null)
			{
				m_oViewBean = IBDynaBeanManager.createIBDynaBean (VIEWBEAN, getIBDynaBean ().getActionMapping ());
			}
			
			m_oViewBean.set (IBFTConstants.BENE_NAME, (String) m_oViewBean.get (IBFTConstants.BENE_NAME));
			m_oViewBean.set (IBFTConstants.BENE_NICK_NAME_DIS, DataValidator.isEmptyString ((String) getIBDynaBean ().get (IBFTConstants.BENE_NICK_NAME))?"-":(String) getIBDynaBean ().get (IBFTConstants.BENE_NICK_NAME));
			m_oViewBean.set (IBFTConstants.EMAIL_DIS, DataValidator.isEmptyString ((String) getIBDynaBean ().get (IBFTConstants.EMAIL))?"-":(String) getIBDynaBean ().get (IBFTConstants.EMAIL));

			getIBDynaBean ().set (VIEWBEAN, m_oViewBean);
			IBDynaBean m_oServiceInfoBean = (IBDynaBean) m_oViewBean.get (ServiceInfo.SERVICE_INFO_BEAN);
			if (((Boolean) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_TAC_REQUIRED)).booleanValue ())
			{
				IBDynaBean m_oSMSViewBean = (IBDynaBean) getIBSessionObjects().getHttpSessionAttrObject(CommonConstants.SMS_VIEW_BEAN);
				String beneName = (String) m_oViewBean.get (IBFTConstants.BENE_NAME);
				if(!DataValidator.isEmptyString(beneName)){
					m_oSMSViewBean.set(CommonConstants.BENE_NAME, beneName.length()>25?beneName.substring(0, 25):beneName);
				}
				
				getIBSessionObjects().setHttpSessionAttrObject(CommonConstants.SMS_VIEW_BEAN, m_oSMSViewBean);
			}
		}
		catch (Exception e)
		{
			if (e instanceof IBGenericException)
			{
				throw (IBGenericException) e;
			}
			throw IBErrorHandler.createServiceException(
					IBServiceException.GENERAL_SERVICE_ERROR, true,
					new String[] {CommonErrorCode.GENERIC_CODE, "", "", "", IBErrorHandler.generateErrorMessage(e)}, c_oClass);
		}

		IBLogger.logBSFNMethodLeavingMessage (c_oClass, m_sMethodName, m_oTimer);
	}

}
