📄 accountaccessbean.java
字号:
else if (fromAccount instanceof SavingAccountValue) { SavingAccountLocal account = savingHome.findByAccountNo(fromAccount.getAccountNo());//lock Saving Account for update account.withdrawal(amount); //withdrawal the money from the Saving account sValue = buildStatement(fromAccount); sValue.setDescription("Transfer money from"); sValue.setWithdrawal(amount); sValue.setBalance(account.getBalance()); //set new balance to the StatementValue stmtHome.create(sValue); //Insert a new record to statement table } else if (fromAccount instanceof VisaAccountValue) //send withdrawal request to JMS server { sValue = buildStatement(fromAccount); sValue.setDescription("Transfer money from"); sValue.setWithdrawal(amount); JMSDelegate.sendPayment(sValue); } else throw new BusinessException(ErrorMessages.WITHDRAWAL_RESTRICTED); //deposit money to toAccount if (toAccount instanceof ChequingAccountValue) { ChequingAccountLocal account = cheqHome.findByAccountNo(toAccount.getAccountNo());//lock Chequing Account for update account.deposit(amount); //deposit the money to the Chequing account sValue = buildStatement(toAccount); sValue.setDescription("Transfer money to"); sValue.setDeposit(amount); sValue.setBalance(account.getBalance()); //set new balance to the StatementValue stmtHome.create(sValue); //Insert a new record to statement table } else if (toAccount instanceof SavingAccountValue) { SavingAccountLocal account = savingHome.findByAccountNo(toAccount.getAccountNo());//lock Saving Account for update account.deposit(amount); //deposit the money to the Saving account sValue = buildStatement(toAccount); sValue.setDescription("Transfer money to"); sValue.setDeposit(amount); sValue.setBalance(account.getBalance()); //set new balance to the StatementValue stmtHome.create(sValue); //Insert a new record to statement table } else if (toAccount instanceof VisaAccountValue) //send money to JMS server { sValue = this.buildStatement(toAccount); sValue.setDescription("Transfer money to"); sValue.setDeposit(amount); JMSDelegate.sendPayment(sValue); } //get refreshed account valuelist vList = this.searchAccount(fromAccount.getClientCardID()); } catch(BusinessException be) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + be.getMessage()); throw be; } catch(SystemException se) { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + se.getMessage()); throw se; } catch(Exception e) //any other exceptions { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + e.getMessage()); throw new SystemException(e); } finally { audit.log("From account: " + fromAccount.getAccountNo() + " To account: " + toAccount.getAccountNo()); } return vList; } /** * @Description: Use fast lane to search multiple records based on the specified criteria. * For Visa statement search, call epayment WebServices * @return: ValueList that contains a full list of value beans. */ public ValueList search(SearchCriteria criteria) throws SystemException, BusinessException { AuditLogger audit = new AuditLogger(this.log, this.ctx.getCallerPrincipal().getName(), "SEARCH", criteria.getCriteriaType()); UserProfile profile = null; ValueList vList = null; try { profile = UserContainer.getUserProfile(ctx); //get user profile if (profile.isUserRestrictedOnFunction(criteria.getCriteriaType() + ".View")) //check access throw new BusinessException(ErrorMessages.NO_VIEW_AUTHORIZED); boolean viewVisa = false; if (criteria instanceof StatementSearchCriteria) { StatementSearchCriteria sCriteria = (StatementSearchCriteria)criteria; if (Constants.VISA_ACCOUNT.equals(sCriteria.getAccountType())) { viewVisa = true; vList = WebServiceDelegate.viewVisaStatement(sCriteria.getAccountNo()); //call webservices } } if (!viewVisa) { FastLaneSearchDAO dao = this.getSearchDAO(criteria.getCriteriaType(), profile); vList = dao.search(criteria); } } catch (BusinessException be) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + be.getMessage()); throw be; } catch(SystemException se) { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + se.getMessage()); throw se; } catch (Exception e) //any other exceptions { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + e.getMessage()); throw new SystemException(e); } finally { audit.log(criteria.toString()); } return vList; } /** * @Description: Delete Account data. Used by Bank Clerk only * @param: AccountValue * @return: */ public void deleteAccount(AccountValue value) throws SystemException, BusinessException { AuditLogger audit = new AuditLogger(this.log, this.ctx.getCallerPrincipal().getName(), "DELETE", value.getValueType()); UserProfile profile = null; try { profile = UserContainer.getUserProfile(ctx); //get user profile if (profile.isUserRestrictedOnFunction(value.getValueType() + ".Delete")) //check access throw new BusinessException(ErrorMessages.NO_DELETE_AUTHORIZED); if (value instanceof ChequingAccountValue) { cheqHome.findByAccountNo(value.getAccountNo()).remove(); } else if (value instanceof SavingAccountValue) { savingHome.findByAccountNo(value.getAccountNo()).remove(); } else throw new BusinessException(ErrorMessages.NO_DELETE_AUTHORIZED); } catch (BusinessException be) { audit.setStatus("FAILED"); audit.setFailedReason("BusinessException: " + be.getMessage()); throw be; } catch(SystemException se) { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + se.getMessage()); throw se; } catch (Exception e) //any other exceptions { audit.setStatus("FAILED"); audit.setFailedReason("SystemException: " + e.getMessage()); throw new SystemException(e); } finally { audit.log(value.toString()); } }/* private boolean isAccountExist(long oid) throws SystemException, BusinessException { try { if (accountHome.findByPrimaryKey(new Long(oid)) != null); return true; } catch (FinderException fe) { throw new BusinessException(ErrorMessages.NO_CARDHOLDER_FOUND); } } */ /** * @Description: Construct a FastLaneSearchDAO object based on the criteria type * @param: String - value type * @return: FastLaneDAO object */ private FastLaneSearchDAO getSearchDAO(String criteriaType, UserProfile profile) throws SystemException { FastLaneSearchDAO dao = null; try { dao = (FastLaneSearchDAO)Class.forName("com.ebusiness.ebank.dao." + criteriaType + "SearchDAO").newInstance(); dao.setUserProfile(profile); } catch (Exception e) { MDC.put(Constants.USER_ID, profile.getUserID()); log.fatal(e.getMessage(), e); throw new SystemException(e); } return dao; } private StatementValue buildStatement(AccountValue aValue) { StatementValue sValue = new StatementValue(); sValue.setAccountNo(aValue.getAccountNo()); sValue.setAccountType(aValue.getAccountType()); sValue.setClientCardNo(aValue.getClientCardID()); //sValue.setDescription("Transfer money from"); //sValue.setDeposit(amount); sValue.setBankingDate(new Timestamp(new Date().getTime())); return sValue; } // The following public methods are EJB container callback methods. /*** * Stateless session bean is pooled and this method will be called * only when a new instance is created and is added to the pool. * So it can be empty or used to initialize some common variables */ public void ejbCreate() { try { cheqHome = (ChequingAccountLocalHome) ServiceLocator.getInstance(). getLocalHome(Constants.CHEQUING_ACCOUNT_LOCALHOME); savingHome = (SavingAccountLocalHome) ServiceLocator.getInstance(). getLocalHome(Constants.SAVING_ACCOUNT_LOCALHOME); stmtHome = (StatementLocalHome) ServiceLocator.getInstance(). getLocalHome(Constants.STATEMENT_LOCALHOME); } catch (ServiceLocatorException sle) { log.fatal(sle.getMessage(), sle); } log.info("ejbCreate called"); } public void ejbActivate() {} //This method will never be called for stateless bean public void ejbRemove() { //Will be called only when the instance is removed from the pool log.info("ejbRemove called"); } public void ejbPassivate() {} //This method will never be called for stateless bean /** * This method will be called each time before a business method is called. So in business method, * We can use SessionContext object to get information like Caller Principal. * * To use it in business method, we must have an instance variable to hold the reference * * Please note, ctx.getCallerPrincipal() is not allowed in this method. It must be called * through business methods */ public void setSessionContext(SessionContext ctx) { log.debug("setSessionContext called"); this.ctx = ctx; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -