initSiteProfiles(form, site);
Item item = ItemDAO.load(site.getSiteId(), Format.getLong(form.getItemId()));
Item itemChild = ItemDAO.load(site.getSiteId(), Format.getLong(form.getItemChildId()));
JSONEscapeObject jsonResult = new JSONEscapeObject();
jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
Iterator<?> iterator = item.getChildren().iterator();
while (iterator.hasNext()) {
Item i = (Item) iterator.next();
if (i.getItemId().equals(itemChild.getItemId())) {
MessageResources resources = this.getResources(request);
jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
jsonResult.put("message", resources.getMessage("error.item.exist"));
streamWebService(response, jsonResult.toHtmlString());
return null;
}
}
item.getChildren().add(itemChild);
item.setRecUpdateBy(adminBean.getUser().getUserId());
item.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
em.persist(item);
CategorySearchUtil.itemPriceSearchUpdate(item, site, adminBean);
jsonResult.put("recUpdateBy", item.getRecUpdateBy());
jsonResult.put("recUpdateDatetime", Format.getFullDatetime(item.getRecUpdateDatetime()));
streamWebService(response, jsonResult.toHtmlString());
return null;
}