Site site = new Site();
if (!insertMode) {
site = SiteDAO.load(form.getSiteId());
}
SiteParamBean siteParamBean = new SiteParamBean();
if (!Format.isNullOrEmpty(site.getSiteParam())) {
siteParamBean = (SiteParamBean) Utility.joxUnMarshall(SiteParamBean.class, site.getSiteParam());
}
form.setMailSmtpPort(form.getMailSmtpPort().trim());
ActionMessages errors = validate(form, siteParamBean);
if (errors.size() != 0) {
form.setMailSmtpPassword("");
form.setCaptchaPrivateKey("");
form.setCaptchaPublicKey("");
initListInfo(form);
saveMessages(request, errors);
return mapping.findForward("error");
}
site.setSiteDesc(form.getSiteDesc());
if (!insertMode) {
site.setShareInventory(form.isShareInventory() ? Constants.VALUE_YES : Constants.VALUE_NO);
site.setManageInventory(form.isManageInventory() ? Constants.VALUE_YES : Constants.VALUE_NO);
site.setSingleCheckout(form.isSingleCheckout() ? Constants.VALUE_YES : Constants.VALUE_NO);
site.setListingPageSize(Format.getInt(form.getListingPageSize()));
site.setMailSmtpHost(form.getMailSmtpHost());
site.setMailSmtpPort(form.getMailSmtpPort());
site.setMailSmtpAccount(form.getMailSmtpAccount());
if (!Format.isNullOrEmpty(form.getMailSmtpPassword())) {
site.setMailSmtpPassword(AESEncoder.getInstance().encode(form.getMailSmtpPassword()));
}
if (form.getMailSmtpPassword().equals(" ")) {
site.setMailSmtpPassword(AESEncoder.getInstance().encode(""));
}
}
site.setActive(form.isActive() ? Constants.VALUE_YES : Constants.VALUE_NO);
siteParamBean.setEnableCaptcha(form.isEnableCaptcha() ? String.valueOf(Constants.VALUE_YES) : String.valueOf(Constants.VALUE_NO));
if (!Format.isNullOrEmpty(form.getCaptchaPrivateKey())) {
siteParamBean.setCaptchaPrivateKey(AESEncoder.getInstance().encode(form.getCaptchaPrivateKey()));
}
if (!Format.isNullOrEmpty(form.getCaptchaPublicKey())) {
siteParamBean.setCaptchaPublicKey(AESEncoder.getInstance().encode(form.getCaptchaPublicKey()));
}
if (!form.isEnableCaptcha()) {
siteParamBean.setCaptchaPrivateKey("");
siteParamBean.setCaptchaPublicKey("");
}
site.setSiteParam(Utility.joxMarshall("SiteParamBean", siteParamBean));
site.setRecUpdateBy(adminBean.getUser().getUserId());
site.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
if (insertMode) {