📄 accountaccessbean.java
字号:
package com.ebusiness.ebank.ejb.sessionbean;/** * <p>Title: </p> * <p>Description: Stateless Session Bean for accessing account information data. * This class acts like a facade, and all of the account data access activities * must go through this session facade. It will first perform security check * to see if the user has permission to do the requested works. * If the security check fails, it will throw BusinessException to the caller. * If the security check succeeds, it will then dispatch the data access * request to the corresponding DAO/entity beans to do the concrete works. * * This class is also the place to audit all of the eBank activities</p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: eBusiness Inc., All right reserved</p> * @author unascribed * @version 1.0 */import java.util.List;import java.util.Collection;import java.util.Iterator;import java.util.Date;import java.rmi.RemoteException;import javax.ejb.SessionBean;import javax.ejb.SessionContext;import javax.ejb.EJBException;import javax.ejb.CreateException;import javax.ejb.FinderException;import java.sql.Timestamp;import org.apache.log4j.Logger;import org.apache.log4j.MDC;import com.ebusiness.ebank.bean.*;import com.ebusiness.ebank.ejb.entitybean.*;import com.ebusiness.ebank.criteria.SearchCriteria;import com.ebusiness.ebank.criteria.StatementSearchCriteria;import com.ebusiness.ebank.servicedelegate.ServiceLocator;import com.ebusiness.ebank.servicedelegate.ServiceLocatorException;import com.ebusiness.ebank.servicedelegate.WebServiceDelegate;import com.ebusiness.ebank.servicedelegate.JMSDelegate;import com.ebusiness.ebank.exception.SystemException;import com.ebusiness.ebank.exception.BusinessException;import com.ebusiness.ebank.util.Constants;import com.ebusiness.ebank.util.FieldHelper;import com.ebusiness.ebank.exception.ErrorMessages;import com.ebusiness.ebank.security.UserProfile;import com.ebusiness.ebank.security.UserContainer;import com.ebusiness.ebank.security.Functions;import com.ebusiness.ebank.log.AuditLogger;import com.ebusiness.ebank.dao.FastLaneSearchDAO;public class AccountAccessBean implements SessionBean{ private SessionContext ctx; private Logger log = Logger.getLogger(this.getClass()); private ChequingAccountLocalHome cheqHome; private SavingAccountLocalHome savingHome; private StatementLocalHome stmtHome; //business methods /** * @Description: View the Account by it's objectId and account type * @return: The AccountValue bean */ public AccountValue viewAccountByOID(long oid, String accountType) throws SystemException, BusinessException { AuditLogger audit = new AuditLogger(this.log, this.ctx.getCallerPrincipal().getName(), "VIEW", accountType + " Account"); UserProfile profile = null; AccountValue aValue = null; try { profile = UserContainer.getUserProfile(ctx); //get user profile if (profile.isUserRestrictedOnFunction(Functions.ACCOUNT_VIEW)) //check access throw new BusinessException(ErrorMessages.NO_VIEW_AUTHORIZED); if (Constants.CHEQUING_ACCOUNT.equals(accountType)) { ChequingAccountLocal account = cheqHome.findByPrimaryKey(new Long(oid)); aValue = account.getValueObject(); } else if (Constants.SAVING_ACCOUNT.equals(accountType)) { SavingAccountLocal account = savingHome.findByPrimaryKey(new Long(oid)); aValue = account.getValueObject(); } else if (Constants.VISA_ACCOUNT.equals(accountType)) { aValue = WebServiceDelegate.viewVisaAccountByOID(oid); if (aValue == null) throw new BusinessException(ErrorMessages.NO_RECORD_FOUND); } } catch (BusinessException be) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + be.getMessage()); throw be; } catch (FinderException fe) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + fe.getMessage()); throw new BusinessException(ErrorMessages.NO_RECORD_FOUND); } catch (Exception e) //any other exceptions { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + e.getMessage()); throw new SystemException(e); } finally { audit.log("Object ID = " + oid); } return aValue; } /** * @Description: View the Account by accountNo and account type * @return: The AccountValue bean */ public AccountValue viewAccountByAccountNo(String accountNo, String accountType) throws SystemException, BusinessException { AuditLogger audit = new AuditLogger(this.log, this.ctx.getCallerPrincipal().getName(), "VIEW", accountType + " Account"); UserProfile profile = null; AccountValue aValue = null; try { profile = UserContainer.getUserProfile(ctx); //get user profile if (profile.isUserRestrictedOnFunction(Functions.ACCOUNT_VIEW)) //check access throw new BusinessException(ErrorMessages.NO_VIEW_AUTHORIZED); if (Constants.CHEQUING_ACCOUNT.equals(accountType)) { ChequingAccountLocal account = cheqHome.findByAccountNo(accountNo); aValue = account.getValueObject(); } else if (Constants.SAVING_ACCOUNT.equals(accountType)) { SavingAccountLocal account = savingHome.findByAccountNo(accountNo); aValue = account.getValueObject(); } else if (Constants.VISA_ACCOUNT.equals(accountType)) { aValue = WebServiceDelegate.viewVisaByAccountNo(accountNo); if (aValue == null) throw new BusinessException(ErrorMessages.NO_RECORD_FOUND); } } catch (BusinessException be) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + be.getMessage()); throw be; } catch (FinderException fe) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + fe.getMessage()); throw new BusinessException(ErrorMessages.NO_RECORD_FOUND); } catch (Exception e) //any exceptions { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + e.getMessage()); throw new SystemException(e); } finally { audit.log("Account No = " + accountNo); } return aValue; } /** * @Description: View the Account by it's objectId and account type * @return: The AccountValue bean */ public AccountValue viewAccountByCardID(String cardID, String accountType) throws SystemException, BusinessException { AuditLogger audit = new AuditLogger(this.log, this.ctx.getCallerPrincipal().getName(), "VIEW", accountType + " Account"); UserProfile profile = null; AccountValue aValue = null; try { profile = UserContainer.getUserProfile(ctx); //get user profile if (profile.isUserRestrictedOnFunction(Functions.ACCOUNT_VIEW)) //check access throw new BusinessException(ErrorMessages.NO_VIEW_AUTHORIZED); if (Constants.CHEQUING_ACCOUNT.equals(accountType)) { ChequingAccountLocal account = cheqHome.findByClientCardID(cardID); aValue = account.getValueObject(); } else if (Constants.SAVING_ACCOUNT.equals(accountType)) { SavingAccountLocal account = savingHome.findByClientCardID(cardID); aValue = account.getValueObject(); } else if (Constants.VISA_ACCOUNT.equals(accountType)) { aValue = WebServiceDelegate.viewVisaByCardID(cardID); if (aValue == null) throw new BusinessException(ErrorMessages.NO_RECORD_FOUND); } } catch (BusinessException be) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + be.getMessage()); throw be; } catch (FinderException fe) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + fe.getMessage()); throw new BusinessException(ErrorMessages.NO_RECORD_FOUND); } catch (Exception e) //any exceptions { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + e.getMessage()); throw new SystemException(e); } finally { audit.log("ClientCArdID = " + cardID); } return aValue; } /** * @Description: Update the specified AccountValue * @return: The updated AccountValue bean */ public AccountValue updateAccount(AccountValue value) throws SystemException, BusinessException { AccountValue newValue = null; AuditLogger audit = new AuditLogger(this.log, this.ctx.getCallerPrincipal().getName(), "UPDATE", value.getValueType()); UserProfile profile = null; try { profile = UserContainer.getUserProfile(ctx); //get user profile if (profile.isUserRestrictedOnFunction(Functions.ACCOUNT_UPDATE)) //check access throw new BusinessException(ErrorMessages.NO_UPDATE_AUTHORIZED); if (value instanceof ChequingAccountLocal) { ChequingAccountLocal account = cheqHome.findByAccountNo(value.getAccountNo()); newValue = account.update((ChequingAccountValue)value); } else if (value instanceof SavingAccountLocal) { SavingAccountLocal account = savingHome.findByAccountNo(value.getAccountNo()); newValue = account.update((SavingAccountValue)value); } } catch (BusinessException be) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + be.getMessage()); throw be; } catch (Exception e) //any exceptions { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + e.getMessage()); throw new SystemException(e); } finally { audit.log(value.toString()); } return newValue;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -