HttpServletResponse response)
throws Throwable {
createEmptySecureTemplateInfo(request);
String siteId = ContentAction.getContentBean(request).getContentSessionKey().getSiteId();
MyAccountPaymentActionForm form = (MyAccountPaymentActionForm) actionForm;
init(request, form);
ActionMessages messages = validate(form);
if (messages.size() > 0) {
initSearchInfo(form, siteId);
saveMessages(request, messages);
ActionForward actionForward = actionMapping.findForward("error");
return actionForward;
}
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
Customer customer = CustomerDAO.load(siteId, getCustomer(request).getCustId());
CustomerCreditCard customerCreditCard = null;
Iterator<?> iterator = customer.getCustCreditCards().iterator();
boolean found = false;
if (iterator.hasNext()) {
found = true;
customerCreditCard = (CustomerCreditCard) iterator.next();
customerCreditCard.setRecCreateBy(Constants.USERNAME_SYSTEM);
customerCreditCard.setRecCreateDatetime(new Date(System.currentTimeMillis()));
}
else {
customerCreditCard = new CustomerCreditCard();
customerCreditCard.setRecUpdateBy(Constants.USERNAME_SYSTEM);
customerCreditCard.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
customerCreditCard.setRecCreateBy(Constants.USERNAME_SYSTEM);
customerCreditCard.setRecCreateDatetime(new Date(System.currentTimeMillis()));
}
customerCreditCard.setCustCreditCardFullName(form.getCustCreditCardFullName());
customerCreditCard.setCustCreditCardNum(AESEncoder.getInstance().encode(form.getCustCreditCardNum()));
customerCreditCard.setCustCreditCardExpiryMonth(form.getCustCreditCardExpiryMonth());
customerCreditCard.setCustCreditCardExpiryYear(form.getCustCreditCardExpiryYear());
customerCreditCard.setCustCreditCardVerNum(form.getCustCreditCardVerNum());
String creditCardId = form.getCreditCardId();
CreditCard creditCard = (CreditCard) em.find(CreditCard.class, Format.getLong(creditCardId));
customerCreditCard.setCreditCard(creditCard);
if (customerCreditCard.getCustCreditCardId() == null) {
em.persist(customerCreditCard);
}