EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
SiteLoader loader = new SiteLoader(site, userId);
loader.load();
em.flush();
SiteProfileClass siteProfileClass = new SiteProfileClass();
siteProfileClass.setSiteProfileClassName("English");
siteProfileClass.setSiteProfileClassNativeName("English");
siteProfileClass.setSite(site);
Language language = LanguageDAO.loadByLanguageName("English");
siteProfileClass.setLanguage(language);
siteProfileClass.setSystemRecord(Constants.VALUE_YES);
siteProfileClass.setRecUpdateBy(userId);
siteProfileClass.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
siteProfileClass.setRecCreateBy(userId);
siteProfileClass.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(siteProfileClass);
site.setSiteProfileClassDefault(siteProfileClass);
SiteCurrencyClass siteCurrencyClass = new SiteCurrencyClass();
Currency currency = CurrencyDAO.loadByCurrencyCode(site.getSiteId(), "USD");
siteCurrencyClass.setCurrency(currency);
siteCurrencyClass.setCurrencyLocaleCountry("US");
siteCurrencyClass.setCurrencyLocaleLanguage("en");
siteCurrencyClass.setSite(site);
siteCurrencyClass.setSiteCurrencyClassName("USD");
siteCurrencyClass.setSystemRecord(Constants.VALUE_YES);
siteCurrencyClass.setRecUpdateBy(userId);
siteCurrencyClass.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
siteCurrencyClass.setRecCreateBy(userId);
siteCurrencyClass.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(siteCurrencyClass);
site.setSiteCurrencyClassDefault(siteCurrencyClass);
Category category = new Category();
category.setCatNaturalKey("");
category.setSeqNum(0);
category.setPublished(Constants.VALUE_YES);
category.setSite(site);
category.setCatId(null);
category.setRecUpdateBy(userId);
category.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
category.setRecCreateBy(userId);
category.setRecCreateDatetime(new Date(System.currentTimeMillis()));
category.setMenus(null);
CategoryLanguage categoryLanguage = new CategoryLanguage();
categoryLanguage.setCatTitle("Home");
categoryLanguage.setCatShortTitle("Home");
categoryLanguage.setCatDesc("");
categoryLanguage.setRecUpdateBy(userId);
categoryLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
categoryLanguage.setRecCreateBy(userId);
categoryLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
categoryLanguage.setSiteProfileClass(siteProfileClass);
categoryLanguage.setCategory(category);
category.setCategoryLanguage(categoryLanguage);
em.persist(categoryLanguage);
category.setCategoryLanguages(null);
em.persist(category);
CustomerClass customerClass = new CustomerClass();
customerClass.setCustClassName(Constants.CUSTOMER_CLASS_REGULAR);
customerClass.setSystemRecord(Constants.VALUE_YES);
customerClass.setRecUpdateBy(userId);
customerClass.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
customerClass.setRecCreateBy(userId);
customerClass.setRecCreateDatetime(new Date(System.currentTimeMillis()));
customerClass.setSite(site);
em.persist(customerClass);
ProductClass productClass = new ProductClass();
productClass.setProductClassName(Constants.PRODUCT_CLASS_REGULAR);
productClass.setSystemRecord(Constants.VALUE_YES);
productClass.setRecUpdateBy(userId);
productClass.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
productClass.setRecCreateBy(userId);
productClass.setRecCreateDatetime(new Date(System.currentTimeMillis()));
productClass.setSite(site);
em.persist(productClass);
ShippingType shippingType = new ShippingType();
shippingType.setShippingTypeName(Constants.SHIPPING_TYPE_REGULAR);
shippingType.setSystemRecord(Constants.VALUE_YES);
shippingType.setRecUpdateBy(userId);
shippingType.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
shippingType.setRecCreateBy(userId);
shippingType.setRecCreateDatetime(new Date(System.currentTimeMillis()));
shippingType.setSite(site);
em.persist(shippingType);
CustomAttribute customAttribute = new CustomAttribute();
customAttribute.setCustomAttribDataTypeCode(Constants.CUSTOM_ATTRIBUTE_DATA_TYPE_CURRENCY);
customAttribute.setCustomAttribTypeCode(Constants.CUSTOM_ATTRIBUTE_TYPE_USER_SELECT_DROPDOWN);
customAttribute.setCustomAttribName("Price");
customAttribute.setItemCompare(Constants.VALUE_NO);
customAttribute.setSystemRecord(Constants.VALUE_YES);
customAttribute.setRecUpdateBy(userId);
customAttribute.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
customAttribute.setRecCreateBy(userId);
customAttribute.setRecCreateDatetime(new Date(System.currentTimeMillis()));
customAttribute.setSite(site);
CustomAttributeLanguage customAttributeLanguage = new CustomAttributeLanguage();
customAttributeLanguage.setCustomAttribDesc("Price");
customAttributeLanguage.setRecUpdateBy(userId);
customAttributeLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
customAttributeLanguage.setRecCreateBy(userId);
customAttributeLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
customAttributeLanguage.setCustomAttribute(customAttribute);
customAttributeLanguage.setSiteProfileClass(siteProfileClass);
customAttribute.setCustomAttributeLanguage(customAttributeLanguage);
em.persist(customAttributeLanguage);
em.persist(customAttribute);
String prefix = getNextPrefix();
SiteDomain siteDomain = new SiteDomain();
SiteDomainLanguage siteDomainLanguage = new SiteDomainLanguage();
siteDomainLanguage.setSiteName("localhost");
siteDomainLanguage.setRecUpdateBy(userId);
siteDomainLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
siteDomainLanguage.setRecCreateBy(userId);
siteDomainLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
SiteDomainParamBean siteDomainParamBean = new SiteDomainParamBean();
siteDomainLanguage.setSiteDomainParam(Utility.joxMarshall("SiteDomainParamBean", siteDomainParamBean));
siteDomainLanguage.setSiteProfileClass(siteProfileClass);
em.persist(siteDomainLanguage);
siteDomain.getSiteDomainLanguages().add(siteDomainLanguage);
siteDomain.setSiteDomainLanguage(siteDomainLanguage);
siteProfileClass.setSiteDomain(siteDomain);
siteDomain.setSiteDomainName("localhost");
siteDomain.setSiteDomainPrefix(prefix);
siteDomain.setSitePublicPortNum("");
if (request.getServerPort() != 80) {