Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
Delegator delegator = dctx.getDelegator();
Map<String,Object> result = FastMap.newInstance();
GetSellingManagerInventoryRequestType req = new GetSellingManagerInventoryRequestType();
GetSellingManagerInventoryResponseType resp = null;
if (context.get("productStoreId") != null) {
GetSellingManagerInventoryCall call = new GetSellingManagerInventoryCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
try {
SellingManagerProductType[] returnedSellingManagerProductType = null;
resp = (GetSellingManagerInventoryResponseType)call.execute(req);
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedSellingManagerProductType = resp.getSellingManagerProduct();
//result = ServiceUtil.returnSuccess("load store data success..");
for (int i = 0; i < returnedSellingManagerProductType.length; i++) {
SellingManagerProductDetailsType prodDetailType = returnedSellingManagerProductType[i].getSellingManagerProductDetails();
int qty = prodDetailType.getQuantityAvailable();
if (qty == 0) {
SellingManagerTemplateDetailsArrayType sellingTempArr = returnedSellingManagerProductType[i].getSellingManagerTemplateDetailsArray();
SellingManagerTemplateDetailsType[] selllingTempType = null;
if (UtilValidate.isNotEmpty(sellingTempArr)) {
selllingTempType = sellingTempArr.getSellingManagerTemplateDetails();
}
if (selllingTempType.length > 0) {
for (int j = 0; j < selllingTempType.length; j++) {
Long longTemplete = Long.parseLong(selllingTempType[j].getSaleTemplateID());
DeleteSellingManagerTemplateCall tcall = new DeleteSellingManagerTemplateCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
DeleteSellingManagerTemplateRequestType treq = new DeleteSellingManagerTemplateRequestType();
DeleteSellingManagerTemplateResponseType tresp = null;
treq.setSaleTemplateID(longTemplete);
tresp = (DeleteSellingManagerTemplateResponseType) tcall.execute(treq);
if (tresp != null && "SUCCESS".equals(tresp.getAck().toString())) {
result = ServiceUtil.returnSuccess();
} else {
EbayStoreHelper.createErrorLogMessage(userLogin, dctx.getDispatcher(), context.get("productStoreId").toString(), tresp.getAck().toString(), "Delete selling manager template : autoBlockItemsOutOfStock", tresp.getErrors(0).getLongMessage());
}
}
}
}
}
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
} else {
EbayStoreHelper.createErrorLogMessage(userLogin, dctx.getDispatcher(), context.get("productStoreId").toString(), resp.getAck().toString(), "Get selling manager inventory : autoBlockItemsOutOfStock", resp.getErrors(0).getLongMessage());
}
result = ServiceUtil.returnSuccess();
} catch (ApiException e) {
e.printStackTrace();
} catch (SdkSoapException e) {