📄 cardholderaccessbean.java
字号:
package com.ebusiness.ebank.ejb.sessionbean;
/**
* <p>Title: </p>
* <p>Description: Stateless Session Bean for accessing cardholder personal information (CPI) data.
* This class acts like a facade, and all of the CPI 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 org.apache.log4j.Logger;
import org.apache.log4j.MDC;
import com.ebusiness.ebank.bean.*;
import com.ebusiness.ebank.ejb.entitybean.*;
import com.ebusiness.ebank.servicedelegate.ServiceLocator;
import com.ebusiness.ebank.servicedelegate.ServiceLocatorException;
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.log.AuditLogger;
public class CardholderAccessBean
implements SessionBean {
private SessionContext ctx;
private Logger log = Logger.getLogger(this.getClass());
private ClientCardLocalHome clientCardHome;
private CardholderLocalHome cardholderHome;
private AddressLocalHome addressHome;
//business methods
/**
* @Description: Insert a new cardhoder record and its associated addresses records
* to eBank database. This method allows anyone ba able to register online
* @param: CardholderValue
* @return:
*/
public void register(CardholderValue value) throws SystemException,
BusinessException {
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"REGISTER", "Cardholder");
Value newValue = null;
//UserProfile profile = null;
try {
cardholderHome.create(value);
}
catch (Exception e) { //any other exceptions
audit.setStatus("FAILED");
audit.setFailedReason("SystemException: " + e.getMessage());
throw new SystemException(e);
}
finally {
audit.log(value.toString());
}
}
/**
* @Description: Change password for the cardholder's debit card
* @return: ClientCardValue
*/
public ClientCardValue changePW(ClientCardValue value) throws SystemException,
BusinessException {
ClientCardValue newValue;
String str = "Password";
if (value.isChangeWebPW())
str = "WebPassword";
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"CHANGE", str);
//UserProfile profile = null;
try {
if (!value.getPassword().equals(value.getInputPassword()))
throw new BusinessException(ErrorMessages.WRONG_PASSWORD);
if (FieldHelper.isEmpty(value.getNewPassword()))
throw new BusinessException(ErrorMessages.MISSING_NEWPASSWORD);
if (value.getPassword().equals(value.getNewPassword()))
throw new BusinessException(ErrorMessages.PASSWORD_DUPLICATE);
if (!value.getNewPassword().equals(value.getConfirmPassword()))
throw new BusinessException(ErrorMessages.PASSWORD_NOT_MATCH);
ClientCardLocal clientCard = clientCardHome.findByCardID(value.
getClientCardID(), value.getPassword());
newValue = clientCard.ChangePW(value.getNewPassword(), value.isChangeWebPW());
}
catch (BusinessException be) {
audit.setStatus("FAILED");
audit.setFailedReason("BusinessException: " + be.getMessage());
throw be;
}
catch (Exception e) { //any other exceptions
audit.setStatus("FAILED");
audit.setFailedReason("SystemException: " + e.getMessage());
throw new SystemException(e);
}
finally {
audit.log(value.toString());
}
return newValue;
}
/**
* @Description: Reset password for the cardholder's web login
* @return:
*/
public ClientCardValue resetWebPW(ClientCardValue value) throws SystemException, BusinessException {
ClientCardValue newValue;
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"RESET", "WebPassword");
//UserProfile profile = null;
try {
ClientCardLocal clientCard = clientCardHome.findByCardID(value.
getClientCardID());
newValue = clientCard.ChangePW("password", true);
}
catch (Exception e) { //any other exceptions
audit.setStatus("FAILED");
audit.setFailedReason("SystemException: " + e.getMessage());
throw new SystemException(e);
}
finally {
audit.log(value.toString());
}
return newValue;
}
/**
* @Description: View cardholder data. This method is for Bank stuff only
* @return: CardholderValue
*/
public ClientCardValue viewClientCardByCardholderOID(long oid) throws SystemException, BusinessException {
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"VIEW", "ClientCard");
//UserProfile profile = null;
ClientCardValue cValue = null;
try {
ClientCardLocal card = clientCardHome.findByCardholderOID(new Long(oid));
cValue = card.getValueObject();
}
catch (FinderException fe)
{
audit.setStatus("FAILED");
audit.setFailedReason("BusinessException: " + fe.getMessage());
throw new BusinessException(ErrorMessages.NO_CLIENTCARD_FOUND);
}
catch (Exception e) { //any exceptions
audit.setStatus("FAILED");
audit.setFailedReason("SystemException: " + e.getMessage());
throw new SystemException(e);
}
finally {
audit.log("Object ID = " + oid);
}
return cValue;
}
/**
* @Description: Insert a new record for cardholder table
* @param: CardholderValue
* @return: CardholderValue
*/
public ClientCardValue createClientCard(ClientCardValue value) throws SystemException, BusinessException {
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"INSERT", "ClientCard");
ClientCardValue newValue = null;
//UserProfile profile = null;
try {
if (this.isCardholderExist(value.getCardholderOID()))
{
newValue = clientCardHome.create(value).getValueObject();
//update the cardholder status to APPROVED once the ClientCard has been issued
cardholderHome.findByPrimaryKey(new Long(value.getCardholderOID())).updateStatus(CardholderValue.APPROVED);
}
}
catch (BusinessException be)
{
audit.setStatus("FAILED");
audit.setFailedReason("BusinessException: " + be.getMessage());
throw be;
}
catch (Exception e) { //any other exceptions
audit.setStatus("FAILED");
audit.setFailedReason("SystemException: " + e.getMessage());
throw new SystemException(e);
}
finally {
audit.log(value.toString());
}
return newValue;
}
/**
* @Description: Update cardholder data
* @param: CardholderValue
* @return: CardholderValue
*/
public ClientCardValue updateClientCard(ClientCardValue value) throws SystemException, BusinessException {
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"UPDATE", "ClientCard");
//UserProfile profile = null;
ClientCardValue newValue = null; ;
try {
ClientCardLocal clientCard = clientCardHome.findByPrimaryKey(new Long(value.getCardholderOID()));
newValue = clientCard.update(value);
}
catch (FinderException fe)
{
audit.setStatus("FAILED");
audit.setFailedReason("BusinessException: " + ErrorMessages.NO_CARDHOLDER_FOUND);
throw new BusinessException(ErrorMessages.NO_CARDHOLDER_FOUND);
}
catch (Exception e) { //any other exceptions
audit.setStatus("FAILED");
audit.setFailedReason("SystemException: " + e.getMessage());
throw new SystemException(e);
}
finally {
audit.log(value.toString());
}
return newValue;
}
/**
* @Description: View cardholder data. This method is for Bank stuff only
* @return: CardholderValue
*/
public CardholderValue viewCardholderByOID(long oid) throws SystemException, BusinessException {
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"VIEW", "Cardholder");
//UserProfile profile = null;
CardholderValue chValue = null;
try {
CardholderLocal cardholder = cardholderHome.findByPrimaryKey(new Long(oid));
chValue = cardholder.getValueObject();
}
catch (Exception e) { //any exceptions
audit.setStatus("FAILED");
audit.setFailedReason("SystemException: " + e.getMessage());
throw new SystemException(e);
}
finally {
audit.log("Object ID = " + oid);
}
return chValue;
}
/**
* @Description: View cardholder data. This method is for Client
* @return: CardholderValue
*/
public CardholderValue viewCardholder(ClientCardValue value) throws SystemException, BusinessException {
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"VIEW", "Cardholder");
//UserProfile profile = null;
CardholderValue chValue = null;
try {
CardholderLocal cardholder = cardholderHome.findByPrimaryKey(new Long(value.
getCardholderOID()));
chValue = cardholder.getValueObject();
}
catch (Exception e) { //any exceptions
audit.setStatus("FAILED");
audit.setFailedReason("SystemException: " + e.getMessage());
throw new SystemException(e);
}
finally {
audit.log(value.toString());
}
return chValue;
}
/**
* @Description: Search a list of cardholders that satisfied with
* the passed value in the specified cardholder value.
* If there is a value in SIN, it will use it for the
* search. Otherwise it will use the cardholder's names
* and DOB etc. for the search
* @return: CardholderValue
*/
public ValueList searchCardholder(CardholderValue value) throws SystemException, BusinessException
{
AuditLogger audit = new AuditLogger(this.log,
this.ctx.getCallerPrincipal().getName(),
"SEARCH", "Cardholder");
//UserProfile profile = null;
ValueList values = new ValueList();
CardholderValue chValue;
CardholderLocal cardholder;
ClientCardLocal clientCard;
try
{
if (!FieldHelper.isEmpty(value.getClientCardID()) )
{
clientCard = clientCardHome.findByCardID(value.getClientCardID());
cardholder = cardholderHome.findByPrimaryKey(new Long(clientCard.getCardholderOID()));
chValue = cardholder.getValueObject();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -