request.setAttribute("_ERROR_MESSAGE_","Required productStoreId and selected products.");
return "error";
}
String productStoreId = (String) requestParams.get("productStoreId");
ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
//String webSiteUrl = (String) requestParams.get("webSiteUrl");
String webSiteUrl = "http://demo.ofbiz.org";
Map<String,Object> addItemObject = getAddItemListingObject(request, apiContext);
List<Map<String,Object>> itemObjs = null;
if (UtilValidate.isNotEmpty(addItemObject.get("itemListings"))) {
itemObjs = UtilGenerics.checkList(addItemObject.get("itemListings"));
} else {
itemObjs = FastList.newInstance();
}
if (UtilValidate.isNotEmpty(productIds)) {
try {
// check add new product obj ? to export
for (String productId : productIds) {
for (Map<String,Object> itObj : itemObjs) {
if (UtilValidate.isNotEmpty(itObj.get(productId.concat("_Obj")))) {
productIds.remove(productId);
}
}
}
Debug.logInfo("run in with productIds "+productIds, module);
for (String productId : productIds) {
AddItemCall addItemCall = new AddItemCall(apiContext);
ItemType item = new ItemType();
GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
item.setTitle(product.getString("internalName"));
item.setCurrency(CurrencyCodeType.USD);
String productDescription = "";
String description = product.getString("description");
String longDescription = product.getString("longDescription");
if (UtilValidate.isNotEmpty(description)) {
productDescription = description;
} else if (UtilValidate.isNotEmpty(longDescription)) {
productDescription = longDescription;
} else if (UtilValidate.isNotEmpty(product.getString("productName"))) {
productDescription = product.getString("productName");
}
item.setDescription(productDescription);
item.setSKU(product.getString("productId"));
item.setApplicationData(product.getString("productId"));
item.setCountry(CountryCodeType.US);
item.setQuantity(1);
String smallImage = product.getString("smallImageUrl");
String mediumImage = product.getString("mediumImageUrl");
String largeImage = product.getString("largeImageUrl");
String ebayImage = null;
if (UtilValidate.isNotEmpty(largeImage)) {
ebayImage = largeImage;
} else if (UtilValidate.isNotEmpty(mediumImage)) {
ebayImage = mediumImage;
} else if (UtilValidate.isNotEmpty(smallImage)) {
ebayImage = smallImage;
}
if (UtilValidate.isNotEmpty(ebayImage)) {
PictureDetailsType pic = new PictureDetailsType();
String pictureUrl = webSiteUrl + ebayImage;
String[] picURL = new String[1];
picURL[0] = pictureUrl;
//String[] picURL = {webSiteUrl + ebayImage};
//pic.setPictureURL(picURL);
pic.setPictureURL(picURL);
item.setPictureDetails(pic);
}
item.setCategoryMappingAllowed(true);
item.setSite(apiContext.getSite());
addItemCall.setSite(apiContext.getSite());
addItemCall.setItem(item);
addItemCall.setWarningLevel(WarningLevelCodeType.HIGH);
Map<String,Object> itemListing = null;
for (Map<String,Object> itemObj : itemObjs) {