form.setCustPassword1("");
ActionForward actionForward = actionMapping.findForward("error");
return actionForward;
}
ContentBean contentBean = getContentBean(request);
Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
Long defaultSiteDomainId = contentBean.getSiteDomain().getSite().getSiteDomainDefault().getSiteDomainId();
char singleCheckout = contentBean.getSiteDomain().getSite().getSingleCheckout();
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
String sql = "from Customer customer " +
"where customer.siteDomain.siteDomainId = :siteDomainId " +
"and custEmail = :custEmail";
Query query = em.createQuery(sql);
if (singleCheckout == Constants.VALUE_YES) {
query.setParameter("siteDomainId", defaultSiteDomainId);
}
else {
query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
}
query.setParameter("custEmail", form.getCustEmail1());
if (query.getResultList().size() > 0) {
messages.add("custEmail1", new ActionMessage("content.error.email.duplicate"));
}
sql = "from Customer customer " +
"where customer.siteDomain.siteDomainId = :siteDomainId " +
"and custPublicName = :custPublicName";
query = em.createQuery(sql);
if (singleCheckout == Constants.VALUE_YES) {
query.setParameter("siteDomainId", defaultSiteDomainId);
}
else {
query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
}
query.setParameter("custPublicName", form.getCustPublicName());
if (query.getResultList().size() > 0) {
messages.add("custPublicName", new ActionMessage("content.error.publicName.duplicate"));
}
if (messages.size() > 0) {
saveMessages(request, messages);
ActionForward actionForward = actionMapping.findForward("error");
form.setCustPassword("");
form.setCustPassword1("");
return actionForward;
}
sql = "from CustomerClass customerClass where siteId = :siteId and customerClass.systemRecord = 'Y'";
query = em.createQuery(sql);
query.setParameter("siteId", site.getSiteId());
CustomerClass customerClass = (CustomerClass) query.getSingleResult();
Customer customer = new Customer();
customer.setSite(site);
if (singleCheckout == Constants.VALUE_YES) {
SiteDomain siteDomain = (SiteDomain) em.find(SiteDomain.class, defaultSiteDomainId);
customer.setSiteDomain(siteDomain);
}
else {
customer.setSiteDomain(contentBean.getSiteDomain());
}
customer.setCustPublicName(form.getCustPublicName());
customer.setCustEmail(form.getCustEmail1());
customer.setCustPassword(AESEncoder.getInstance().encode(form.getCustPassword()));
customer.setCustSource(Constants.CUSTOMER_SOURCE_REGISTER);