You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2011/02/08 21:15:49 UTC

svn commit: r1068548 [2/2] - /ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java?rev=1068548&r1=1068547&r2=1068548&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java Tue Feb  8 20:15:48 2011
@@ -35,13 +35,13 @@ import java.util.TreeMap;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
 
 import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
@@ -72,9 +72,9 @@ import com.ebay.sdk.call.GetSellingManag
 import com.ebay.sdk.call.GetSellingManagerSoldListingsCall;
 import com.ebay.sdk.call.GetUserCall;
 import com.ebay.sdk.call.LeaveFeedbackCall;
+import com.ebay.sdk.call.RelistItemCall;
 import com.ebay.sdk.call.RespondToBestOfferCall;
 import com.ebay.sdk.call.VerifyAddSecondChanceItemCall;
-import com.ebay.sdk.call.RelistItemCall;
 import com.ebay.soap.eBLBaseComponents.AddOrderRequestType;
 import com.ebay.soap.eBLBaseComponents.AddOrderResponseType;
 import com.ebay.soap.eBLBaseComponents.AmountType;
@@ -219,11 +219,10 @@ public class EbayStoreAutoPreferences {
     }
 
     public static String autoPrefLeaveFeedbackOptions(HttpServletRequest request, HttpServletResponse response) {
-        HttpSession session = request.getSession();
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         Locale locale = UtilHttp.getLocale(request);
-        Map paramMap = UtilHttp.getCombinedMap(request);
+        Map<String, Object> paramMap = UtilHttp.getCombinedMap(request);
 
         if (UtilValidate.isEmpty(paramMap.get("productStoreId"))) {
             request.setAttribute("_ERROR_MESSAGE_", "Required productStoreId for get api context to connect with ebay site.");
@@ -267,7 +266,7 @@ public class EbayStoreAutoPreferences {
                 return "error";
             }
 
-            Map context = UtilMisc.toMap("userLogin", userLogin, "serviceName", "autoPrefLeaveFeedbackOption");
+            Map<String, Object> context = UtilMisc.<String, Object>toMap("userLogin", userLogin, "serviceName", "autoPrefLeaveFeedbackOption");
             ebayProductStorePref = delegator.findByPrimaryKey("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_PIT_FB"));
             context.put("productStoreId", productStoreId);
             context.put("autoPrefEnumId", "EBAY_AUTO_PIT_FB");
@@ -310,9 +309,7 @@ public class EbayStoreAutoPreferences {
         String productStoreId = (String) context.get("productStoreId");
         String isAutoFeedbackReminder = "N";
         int afterDays = 0;
-        String isAlsoSendCopyToSeller = "N";
         GenericValue ebayProductStorePref = null;
-        List<String> list = FastList.newInstance();
         String dateTimeFormat = UtilDateTime.DATE_TIME_FORMAT;
         SimpleDateFormat formatter = new SimpleDateFormat(dateTimeFormat);
 
@@ -324,8 +321,7 @@ public class EbayStoreAutoPreferences {
                 // if isAutoPositiveFeedback is N that means not start this job run service
                 if ("Y".equals(isAutoFeedbackReminder) && jobId.equals(ebayProductStorePref.getString("autoPrefJobId"))) {
                     afterDays = Integer.parseInt(ebayProductStorePref.getString("condition1"));
-                    isAlsoSendCopyToSeller = ebayProductStorePref.getString("condition2");
-
+                    
                     // start getting sold item list from ebay follow your site
                     GetSellingManagerSoldListingsCall sellingManagerSoldListings = new GetSellingManagerSoldListingsCall(apiContext);
                     List<SellingManagerSoldOrderType> items = FastList.newInstance();
@@ -391,7 +387,6 @@ public class EbayStoreAutoPreferences {
     }
 
     public static Map<String, Object> automaticEbayRelistSoldItems(DispatchContext dctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = FastMap.newInstance();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
@@ -400,7 +395,6 @@ public class EbayStoreAutoPreferences {
             GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
             Map<String, Object> serviceMap = FastMap.newInstance();
             serviceMap.put("userLogin", userLogin);
-            List<GenericValue> stores = delegator.findByAnd("ProductStore", UtilMisc.toMap());
             //ProductStore
             List<GenericValue> productStores = delegator.findByAnd("EbayProductStorePref", UtilMisc.toMap("autoPrefJobId", jobId));
             if (productStores.size() != 0) {
@@ -414,16 +408,16 @@ public class EbayStoreAutoPreferences {
                 Timestamp nowTime = UtilDateTime.nowTimestamp();
                 if (nowTime.after(fromDate) && nowTime.before(thruDate)) {
                     serviceMap.put("productStoreId", productStoreId);
-                    Map eBayUserLogin = dispatcher.runSync("getEbayStoreUser", serviceMap);
+                    Map<String, Object> eBayUserLogin = dispatcher.runSync("getEbayStoreUser", serviceMap);
                     String eBayUserLoginId = (String) eBayUserLogin.get("userLoginId");
                     GenericValue party = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", eBayUserLoginId));
                     String partyId = party.getString("partyId");
                     //save sold items to OFbBiz product entity
-                    Map resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
-                    List soldItems = (List) resultService.get("soldItems");
+                    Map<String, Object> resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
+                    List<Map<String, Object>> soldItems = UtilGenerics.checkList(resultService.get("soldItems"));
                     if (soldItems.size() != 0) {
                         for (int itemCount = 0; itemCount < soldItems.size(); itemCount++) {
-                            Map soldItemMap = (Map) soldItems.get(itemCount);
+                            Map<String, Object> soldItemMap = soldItems.get(itemCount);
                             if (UtilValidate.isNotEmpty(soldItemMap.get("itemId"))) {
                                 GenericValue productCheck = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", soldItemMap.get("itemId")));
                                 if (productCheck == null) {
@@ -434,7 +428,7 @@ public class EbayStoreAutoPreferences {
                                     inMap.put("userLogin", userLogin);
                                     dispatcher.runSync("createProduct", inMap);
                                     // ProductRole (VENDOR)
-                                    List productRole = delegator.findByAnd("ProductRole", UtilMisc.toMap("partyId", partyId, "productId", soldItemMap.get("itemId"), "roleTypeId", "VENDOR"));
+                                    List<GenericValue> productRole = delegator.findByAnd("ProductRole", UtilMisc.toMap("partyId", partyId, "productId", soldItemMap.get("itemId"), "roleTypeId", "VENDOR"));
                                     if (productRole.size() == 0) {
                                         Map<String, Object> addRole = FastMap.newInstance();
                                         addRole.put("productId", soldItemMap.get("itemId"));
@@ -453,11 +447,11 @@ public class EbayStoreAutoPreferences {
                     serviceMap.put("userLogin", userLogin);
                     serviceMap.put("productStoreId", productStoreId);
                     resultService = dispatcher.runSync("getEbayActiveItems", serviceMap);
-                    List activeItems = (List) resultService.get("activeItems");
+                    List<Map<String, Object>> activeItems = UtilGenerics.checkList(resultService.get("activeItems"));
                     List<String> activeItemMaps = FastList.newInstance();
                     if (activeItems.size() != 0) {
                         for (int itemCount = 0; itemCount < activeItems.size(); itemCount++) {
-                            Map activeItemMap = (Map) activeItems.get(itemCount);
+                            Map<String, Object> activeItemMap = UtilGenerics.checkMap(activeItems.get(itemCount));
                             if (UtilValidate.isNotEmpty(activeItemMap.get("itemId"))) {
                                 activeItemMaps.add((String) activeItemMap.get("itemId"));
                             }
@@ -472,7 +466,7 @@ public class EbayStoreAutoPreferences {
                             productRoleIds.add(productId);
                         }
                     }
-                    List andExpr = FastList.newInstance();
+                    List<EntityCondition> andExpr = FastList.newInstance();
                     EntityCondition activeItemCond = EntityCondition.makeCondition("productId", EntityOperator.NOT_IN, activeItemMaps);
                     andExpr.add(activeItemCond);
                     EntityCondition productTypeCond = EntityCondition.makeCondition("productTypeId", EntityOperator.EQUALS, "EBAY_ITEM");
@@ -482,14 +476,9 @@ public class EbayStoreAutoPreferences {
                     EntityCondition productRole = EntityCondition.makeCondition("productId", EntityOperator.IN, productRoleIds);
                     andExpr.add(productRole);
                     EntityCondition andCond = EntityCondition.makeCondition(andExpr, EntityOperator.AND);
-                    List itemsToRelist = delegator.findList("Product", andCond, null, null, null, false);
+                    List<GenericValue> itemsToRelist = delegator.findList("Product", andCond, null, null, null, false);
                     if (itemsToRelist.size() != 0) {
                         //re-list sold items and not active
-                        Map<String, Object> inMap = FastMap.newInstance();
-                        inMap.put("productStoreId", productStoreId);
-                        inMap.put("userLogin", userLogin);
-                        Map<String, Object> resultUser = dispatcher.runSync("getEbayStoreUser", inMap);
-                        String userID = (String) resultUser.get("userLoginId");
                         ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
                         for (int itemRelist = 0; itemRelist < itemsToRelist.size(); itemRelist++) {
                             RelistItemCall relistItemCall = new RelistItemCall(apiContext);
@@ -513,7 +502,6 @@ public class EbayStoreAutoPreferences {
     }
 
     public static Map<String, Object> automaticEbayDisputeNotComplete(DispatchContext dctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = FastMap.newInstance();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
@@ -544,12 +532,12 @@ public class EbayStoreAutoPreferences {
                 Map<String, Object> serviceMap = FastMap.newInstance();
                 serviceMap.put("productStoreId", productStoreId);
                 serviceMap.put("userLogin", userLogin);
-                Map resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
-                List soldItems = (List) resultService.get("soldItems");
+                Map<String, Object> resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
+                List<Map<String, Object>> soldItems = UtilGenerics.checkList(resultService.get("soldItems"));
                 // check items to dispute
-                List<Map> itemsToDispute = FastList.newInstance();
+                List<Map<String, Object>> itemsToDispute = FastList.newInstance();
                 for (int itemCount = 0; itemCount < soldItems.size(); itemCount++) {
-                    Map item = (Map) soldItems.get(itemCount);
+                    Map<String, Object> item = UtilGenerics.checkMap(soldItems.get(itemCount));
                     String checkoutStatus = (String) item.get("checkoutStatus");
                     Date creationTime = (Date) item.get("creationTime");
                     Date paidTime = (Date) item.get("paidTime");
@@ -575,7 +563,6 @@ public class EbayStoreAutoPreferences {
                         api.setTransactionID((String) item.get("transactionId"));
                         api.setDisputeExplanation(disputeExplanation);
                         api.setDisputeReason(disputeReason);
-                        String id = api.addDispute();
                     }
                 }
             }
@@ -586,7 +573,6 @@ public class EbayStoreAutoPreferences {
     }
 
     public static Map<String, Object> automaticEbayDisputeNotPay(DispatchContext dctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = FastMap.newInstance();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
@@ -617,12 +603,12 @@ public class EbayStoreAutoPreferences {
                 Map<String, Object> serviceMap = FastMap.newInstance();
                 serviceMap.put("productStoreId", productStoreId);
                 serviceMap.put("userLogin", userLogin);
-                Map resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
-                List soldItems = (List) resultService.get("soldItems");
+                Map<String, Object> resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
+                List<Map<String, Object>> soldItems = UtilGenerics.checkList(resultService.get("soldItems"));
                 // check items to dispute
-                List<Map> itemsToDispute = FastList.newInstance();
+                List<Map<String, Object>> itemsToDispute = FastList.newInstance();
                 for (int itemCount = 0; itemCount < soldItems.size(); itemCount++) {
-                    Map item = (Map) soldItems.get(itemCount);
+                    Map<String, Object> item = UtilGenerics.checkMap(soldItems.get(itemCount));
                     String checkoutStatus = (String) item.get("checkoutStatus");
                     Date creationTime = (Date) item.get("creationTime");
                     Date paidTime = (Date) item.get("paidTime");
@@ -648,7 +634,6 @@ public class EbayStoreAutoPreferences {
                         api.setTransactionID((String) item.get("transactionId"));
                         api.setDisputeExplanation(disputeExplanation);
                         api.setDisputeReason(disputeReason);
-                        String id = api.addDispute();
                     }
                 }
             }
@@ -673,9 +658,7 @@ public class EbayStoreAutoPreferences {
         String productStoreId = (String) context.get("productStoreId");
 
         String isAutoSendEmail = "N";
-        String isAlsoSendCopyToSeller = "N";
         GenericValue ebayProductStorePref = null;
-        List<String> list = FastList.newInstance();
 
         try {
             ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
@@ -684,8 +667,6 @@ public class EbayStoreAutoPreferences {
                 isAutoSendEmail = ebayProductStorePref.getString("enabled");
                 // if isAutoPositiveFeedback is N that means not start this job run service
                 if ("Y".equals(isAutoSendEmail) && jobId.equals(ebayProductStorePref.getString("autoPrefJobId"))) {
-                    isAlsoSendCopyToSeller = ebayProductStorePref.getString("condition1");
-
                     // start getting sold item list from ebay follow your site
                     GetSellingManagerSoldListingsCall sellingManagerSoldListings = new GetSellingManagerSoldListingsCall(apiContext);
                     List<SellingManagerSoldOrderType> items = FastList.newInstance();
@@ -703,8 +684,6 @@ public class EbayStoreAutoPreferences {
                         }
 
                         // call service send email (get template follow productStoreId)
-                        GetUserCall getUserCall = new GetUserCall(apiContext);
-                        String sellerUser = getUserCall.getUser().getUserID();
                         for (SellingManagerSoldOrderType item : items) {
                             // call send
                             Map<String, Object> sendMap = FastMap.newInstance();
@@ -760,7 +739,7 @@ public class EbayStoreAutoPreferences {
 
                     Timestamp beginDate = UtilDateTime.toTimestamp("01/01/2001 00:00:00");
                     Long daysCount = Long.parseLong(ebayPref.get("condition1").toString());
-                    Hashtable h = new Hashtable();
+                    Hashtable<String, List<Map<String, Object>>> h = new Hashtable<String, List<Map<String, Object>>>();
 
                     for (int i = 0; i < soldOrderLength; i++) {
                         SellingManagerSoldOrderType sellingManagerSoldOrder = sellingManagerSoldOrders[i];
@@ -770,11 +749,11 @@ public class EbayStoreAutoPreferences {
                         mymap.put("group", "");
                         mymap.put("soldorder", sellingManagerSoldOrder);
                         if (h.size() > 0) {
-                            Enumeration enums = h.keys();
+                            Enumeration<String> enums = h.keys();
                             String key = "";
                             while (enums.hasMoreElements()) {
                                 key = (String) enums.nextElement();
-                                List<Map<String, Object>> tempList = (List<Map<String, Object>>) h.get(key);
+                                List<Map<String, Object>> tempList = h.get(key);
                                 if (key.equals(buyerId)) {
                                     key = buyerId;
                                     tempList.add(mymap);
@@ -792,11 +771,11 @@ public class EbayStoreAutoPreferences {
                         }
                     }
 
-                    Enumeration enums = h.keys();
+                    Enumeration<String> enums = h.keys();
                     while (enums.hasMoreElements()) {
                         int groupRunning = 0;
-                        String key = (String) enums.nextElement();
-                        List<Map<String, Object>> soldGroupList = (List<Map<String, Object>>) h.get(key);
+                        String key = enums.nextElement();
+                        List<Map<String, Object>> soldGroupList = h.get(key);
                         int maxItems = Integer.parseInt(ebayPref.get("condition2").toString());
 
                         if (soldGroupList.size() > 1) {
@@ -820,7 +799,7 @@ public class EbayStoreAutoPreferences {
                                 buyerPayment[0] = BuyerPaymentMethodCodeType.CASH_ON_PICKUP;
                                 order.setPaymentMethods(buyerPayment);
                                 TransactionArrayType transactionArr = new TransactionArrayType();
-                                List translist = FastList.newInstance();
+                                List<TransactionType> translist = FastList.newInstance();
 
                                 AmountType total = new AmountType();
                                 double totalAmt = 0.0;
@@ -937,10 +916,10 @@ public class EbayStoreAutoPreferences {
         try {
             GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
             Map<String, Object> resultSold =  dispatcher.runSync("getEbaySoldItems", UtilMisc.toMap("productStoreId", productStoreId, "userLogin", userLogin));
-            List soldItems = (List) resultSold.get("soldItems");
+            List<Map<String, Object>> soldItems = UtilGenerics.checkList(resultSold.get("soldItems"));
             if (soldItems.size() != 0) {
                 for (int i = 0; i < soldItems.size(); i++) {
-                    Map<String, Object> item = (Map<String, Object>) soldItems.get(i);
+                    Map<String, Object> item = soldItems.get(i);
                     Timestamp lastestTime = UtilDateTime.getDayStart(UtilDateTime.nowTimestamp(), 1);
                     Date creationDate = (Date) item.get("creationTime");
                     Timestamp creationTime = UtilDateTime.toTimestamp(creationDate);
@@ -952,7 +931,7 @@ public class EbayStoreAutoPreferences {
                         serviceMap.put("productStoreId", productStoreId);
                         serviceMap.put("itemId", item.get("itemId").toString());
                         Map<String, Object> resultBid =  dispatcher.runSync("getEbayAllBidders", serviceMap);
-                        List<Map> allBidders =  (List<Map>) resultBid.get("allBidders");
+                        List<Map<String, Object>> allBidders =  UtilGenerics.checkList(resultBid.get("allBidders"));
 
                         if (allBidders.size() != 0) {
                             // call to send email to bidder
@@ -1002,17 +981,16 @@ public class EbayStoreAutoPreferences {
         Map<String, Object> result = FastMap.newInstance();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
-        Locale locale = (Locale) context.get("locale");
         String productStoreId = (String) context.get("productStoreId");
 
         try {
             GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
             context.put("userLogin", userLogin);
             Map<String, Object> resultSold =  dispatcher.runSync("getEbaySoldItems", context);
-            List soldItems = (List) resultSold.get("soldItems");
+            List<Map<String, Object>> soldItems = UtilGenerics.checkList(resultSold.get("soldItems"));
             if (soldItems.size() != 0) {
                 for (int i = 0; i < soldItems.size(); i++) {
-                    Map<String, Object> item = (Map<String, Object>) soldItems.get(i);
+                    Map<String, Object> item = soldItems.get(i);
                     String shippedStatus = item.get("shippedStatus").toString();
                     Timestamp lastestTime = UtilDateTime.getDayStart(UtilDateTime.nowTimestamp(), 1);
                     Date shippedTime = (Date) item.get("shippedTime");
@@ -1129,7 +1107,7 @@ public class EbayStoreAutoPreferences {
             EntityCondition expression1 = EntityCondition.makeCondition("autoRelisting", EntityOperator.EQUALS, "Y");
             EntityCondition expression2 = EntityCondition.makeCondition("endDateTime", EntityOperator.LESS_THAN, UtilDateTime.nowTimestamp());
             EntityCondition expression3 = EntityCondition.makeCondition("itemId", EntityOperator.NOT_EQUAL, null);
-            List expressions = FastList.newInstance();
+            List<EntityCondition> expressions = FastList.newInstance();
             expressions.add(expression1);
             expressions.add(expression2);
             expressions.add(expression3);
@@ -1165,12 +1143,9 @@ public class EbayStoreAutoPreferences {
         return ServiceUtil.returnSuccess();
     }
     public static Map<String, Object> autoBestOffer(DispatchContext dctx, Map<String, ? extends Object> context) {
-        LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
         try {
-            GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
-            String jobId = (String) context.get("jobId");
             String productStoreId = (String) context.get("productStoreId");
             GenericValue ebayProductStorePref = delegator.findByPrimaryKey("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId, "autoPrefEnumId", "EBAY_AUTO_BEST_OFFER"));
             String parentPrefCondId = ebayProductStorePref.getString("parentPrefCondId");
@@ -1193,11 +1168,6 @@ public class EbayStoreAutoPreferences {
             BigDecimal lessThanPercentValue = new BigDecimal(lessValue);
             BigDecimal rejectPercentValue = new BigDecimal(lessThanValue);
 
-            Map<String, Object> inMap = FastMap.newInstance();
-            inMap.put("productStoreId", productStoreId);
-            inMap.put("userLogin", userLogin);
-            Map<String, Object> resultUser = dispatcher.runSync("getEbayStoreUser", inMap);
-            String userID = (String) resultUser.get("userLoginId");
             ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
             //GetMysbaySellingCall for get total page
             GetMyeBaySellingCall getTotalPage = new GetMyeBaySellingCall(apiContext);
@@ -1252,7 +1222,6 @@ public class EbayStoreAutoPreferences {
                     getItem.getItem(itemID);
                     String SKUItem = getItem.getSKU();
                     ItemType itemBestOffer = getItem.getReturnedItem();
-                    String sellerUserID = itemBestOffer.getSeller().getUserID();
                     BestOfferDetailsType bestOfferDetailsType = itemBestOffer.getBestOfferDetails();
                     int inventoryQuantityItem = item.getQuantityAvailable();  //Quantity of the item
                     int bestOfferCount = itemBestOffer.getBestOfferDetails().getBestOfferCount();

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCategoryFacade.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCategoryFacade.java?rev=1068548&r1=1068547&r2=1068548&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCategoryFacade.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCategoryFacade.java Tue Feb  8 20:15:48 2011
@@ -26,6 +26,7 @@ import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilGenerics;
 
 import com.ebay.sdk.ApiContext;
 import com.ebay.sdk.ApiException;
@@ -256,7 +257,7 @@ public class EbayStoreCategoryFacade {
                         temGroupList.add(templateGroup);
                     } else {
                         if (templateGroup.get("Templates") != null) {
-                            templateList = (List<Map<String,Object>>) templateGroup.get("Templates");
+                            templateList = UtilGenerics.checkList(templateGroup.get("Templates"));
                             templateList.add(template);
                         }
                     }
@@ -284,7 +285,7 @@ public class EbayStoreCategoryFacade {
         List<Map<String,Object>> themes = FastList.newInstance();
         for (Map<String,Object> temp : this.adItemTemplates) {
             if (temp.get("TemplateGroupId").equals(temGroupId)) {
-                themes = (List<Map<String,Object>>) temp.get("Templates");
+                themes = UtilGenerics.checkList(temp.get("Templates"));
                 break;
             }
         }

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCustomerService.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCustomerService.java?rev=1068548&r1=1068547&r2=1068548&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCustomerService.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreCustomerService.java Tue Feb  8 20:15:48 2011
@@ -29,7 +29,6 @@ import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
 
 import com.ebay.sdk.ApiContext;
@@ -49,7 +48,6 @@ public class EbayStoreCustomerService {
     private static final String resource = "EbayStoreUiLabels";
 
     public static Map<String, Object> listBestOfferIncludeMessage(DispatchContext dctx, Map<String, ? extends Object> context) {
-        LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
         if (UtilValidate.isEmpty(context.get("userId")) || UtilValidate.isEmpty(context.get("itemId"))) {
@@ -60,12 +58,6 @@ public class EbayStoreCustomerService {
             String itemId = (String) context.get("itemId");
             String bestOfferId = (String) context.get("bestOfferId");
             String productStoreId = (String) context.get("productStoreId");
-            GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
-            Map<String, Object> inMap = FastMap.newInstance();
-            inMap.put("productStoreId", productStoreId);
-            inMap.put("userLogin", userLogin);
-            Map<String, Object> resultUser = dispatcher.runSync("getEbayStoreUser", inMap);
-            String userID = (String) resultUser.get("userLoginId");
             ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
             DetailLevelCodeType[] detailLevel = new DetailLevelCodeType[] {
                     DetailLevelCodeType.RETURN_ALL,
@@ -106,7 +98,6 @@ public class EbayStoreCustomerService {
         return result;
     }
     public static Map<String, Object> updateContactStatus(DispatchContext dctx, Map<String, ? extends Object> context) {
-        LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
         if (UtilValidate.isEmpty(context.get("productStoreId")) || UtilValidate.isEmpty(context.get("userId")) || UtilValidate.isEmpty(context.get("itemId")) || UtilValidate.isEmpty(context.get("offerId")) || UtilValidate.isEmpty(context.get("contactSetting"))) {
@@ -123,12 +114,6 @@ public class EbayStoreCustomerService {
         String quantity = (String) context.get("quantity");
         Map <String, Object> result = FastMap.newInstance();
         try {
-            GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
-            Map<String, Object> inMap = FastMap.newInstance();
-            inMap.put("productStoreId", productStoreId);
-            inMap.put("userLogin", userLogin);
-            Map<String, Object> resultUser = dispatcher.runSync("getEbayStoreUser", inMap);
-            String userID = (String) resultUser.get("userLoginId");
             ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
             String[] bestOfferIDs = {offerId};
             RespondToBestOfferCall respondToBestOfferCall = new RespondToBestOfferCall(apiContext);

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java?rev=1068548&r1=1068547&r2=1068548&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java Tue Feb  8 20:15:48 2011
@@ -24,11 +24,9 @@ import java.math.BigDecimal;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -36,6 +34,7 @@ import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
@@ -54,7 +53,6 @@ import org.ofbiz.service.ServiceUtil;
 import org.ofbiz.service.calendar.RecurrenceInfo;
 import org.ofbiz.service.calendar.RecurrenceInfoException;
 import org.ofbiz.service.config.ServiceConfigUtil;
-import org.ofbiz.service.job.JobManager;
 
 import com.ebay.sdk.ApiAccount;
 import com.ebay.sdk.ApiContext;
@@ -95,7 +93,6 @@ import com.ebay.soap.eBLBaseComponents.V
 import com.ibm.icu.text.SimpleDateFormat;
 
 public class EbayStoreHelper {
-    private static final String configFileName = "ebayStore.properties";
     private static final String module = EbayStoreHelper.class.getName();
     public static final String resource = "EbayStoreUiLabels";
 
@@ -353,7 +350,6 @@ public class EbayStoreHelper {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Delegator delegator = dctx.getDelegator();
-        Locale locale = (Locale) context.get("locale");
         String productStoreId = (String) context.get("productStoreId");
         String autoPrefEnumId = (String) context.get("autoPrefEnumId");
         try {
@@ -375,7 +371,7 @@ public class EbayStoreHelper {
         return result;
     }
 
-    public static void mappedPaymentMethods(Map requestParams, String itemPkCateId, Map<String,Object> addItemObject, ItemType item, HashMap attributeMapList) {
+    public static void mappedPaymentMethods(Map<String,Object> requestParams, String itemPkCateId, Map<String,Object> addItemObject, ItemType item, HashMap<String, Object> attributeMapList) {
         String refName = "itemCateFacade_"+itemPkCateId;
         if (UtilValidate.isNotEmpty(addItemObject) && UtilValidate.isNotEmpty(requestParams)) {
             EbayStoreCategoryFacade cf = (EbayStoreCategoryFacade) addItemObject.get(refName);
@@ -403,7 +399,7 @@ public class EbayStoreHelper {
         }
     }
 
-    public static void mappedShippingLocations(Map requestParams, ItemType item, ApiContext apiContext, HttpServletRequest request, HashMap attributeMapList) {
+    public static void mappedShippingLocations(Map<String, Object> requestParams, ItemType item, ApiContext apiContext, HttpServletRequest request, HashMap<String, Object> attributeMapList) {
         try {
             if (UtilValidate.isNotEmpty(requestParams)) {
                 EbayStoreSiteFacade sf = EbayEvents.getSiteFacade(apiContext, request);
@@ -434,7 +430,7 @@ public class EbayStoreHelper {
         Map<String,Object> result = FastMap.newInstance();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
-        Map<String, Object> itemObject = (Map<String, Object>) context.get("itemObject");
+        Map<String, Object> itemObject = UtilGenerics.checkMap(context.get("itemObject"));
         String productListingId = itemObject.get("productListingId").toString();
         AddItemCall addItemCall = (AddItemCall) itemObject.get("addItemCall");
         AddItemRequestType req = new AddItemRequestType();
@@ -468,12 +464,8 @@ public class EbayStoreHelper {
     }
 
     public static Map<String, Object> setEbayProductListingAttribute(DispatchContext dctx, Map<String, Object> context) {
-        Map<String, Object>result = FastMap.newInstance();
-        LocalDispatcher dispatcher = dctx.getDispatcher();
-        GenericValue userLogin = (GenericValue) context.get("userLogin");
         Delegator delegator = dctx.getDelegator();
-        Locale locale = (Locale) context.get("locale");
-        HashMap attributeMapList = (HashMap) context.get("attributeMapList");
+        HashMap<String, Object> attributeMapList = UtilGenerics.cast(context.get("attributeMapList"));
         String productListingId = (String) context.get("productListingId");
         try {
            List<GenericValue> attributeToClears = delegator.findByAnd("EbayProductListingAttribute", UtilMisc.toMap("productListingId", productListingId));
@@ -483,16 +475,12 @@ public class EbayStoreHelper {
                  valueToClear.remove();
               }
            }
-           Set attributeSet = attributeMapList.entrySet();
-           Iterator itr = attributeSet.iterator();
-           while (itr.hasNext()) {
-             Map.Entry attrMap = (Map.Entry) itr.next();
-
-             if (UtilValidate.isNotEmpty(attrMap.getKey())) {
-                 GenericValue ebayProductListingAttribute = delegator.makeValue("EbayProductListingAttribute");
+           for (Map.Entry<String,Object> entry : attributeMapList.entrySet()) {
+              if (UtilValidate.isNotEmpty(entry.getKey())) {
+                  GenericValue ebayProductListingAttribute = delegator.makeValue("EbayProductListingAttribute");
                   ebayProductListingAttribute.set("productListingId", productListingId);
-                  ebayProductListingAttribute.set("attrName", attrMap.getKey().toString());
-                  ebayProductListingAttribute.set("attrValue", attrMap.getValue().toString());
+                  ebayProductListingAttribute.set("attrName", entry.getKey().toString());
+                  ebayProductListingAttribute.set("attrValue", entry.getValue().toString());
                   ebayProductListingAttribute.create();
               }
            }

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOptions.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOptions.java?rev=1068548&r1=1068547&r2=1068548&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOptions.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOptions.java Tue Feb  8 20:15:48 2011
@@ -72,7 +72,7 @@ public class EbayStoreOptions {
         StoreThemeArrayType returnedBasicThemeArray = null;
 
         try {
-            Map paramMap = UtilHttp.getCombinedMap(request);
+            Map<String, Object> paramMap = UtilHttp.getCombinedMap(request);
             if (paramMap.get("productStoreId") != null) {
                 String themeId = (String)paramMap.get("themeId");
 
@@ -169,7 +169,7 @@ public class EbayStoreOptions {
     }
 
     public static String retrieveItemTemplateByTemplateGroupId(HttpServletRequest request,HttpServletResponse response) {
-        Map paramMap = UtilHttp.getCombinedMap(request);
+        Map<String, Object> paramMap = UtilHttp.getCombinedMap(request);
         try {
             if (paramMap.get("productStoreId") != null) {
                 String temGroupId = (String)paramMap.get("templateGroupId");
@@ -194,7 +194,7 @@ public class EbayStoreOptions {
     public static String retrieveEbayCategoryByParent(HttpServletRequest request, HttpServletResponse response) {
         List<CategoryType> results = FastList.newInstance();
         try {
-            Map paramMap = UtilHttp.getCombinedMap(request);
+            Map<String, Object> paramMap = UtilHttp.getCombinedMap(request);
             if (paramMap.get("productStoreId") != null) {
                 String ebayCategoryId = (String)paramMap.get("ebayCategoryId");
                 // when change category should be remove old category from session

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java?rev=1068548&r1=1068547&r2=1068548&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java Tue Feb  8 20:15:48 2011
@@ -58,10 +58,7 @@ public class EbayStoreOrder {
 
     public static Map<String, Object> EbayStoreImportTransaction(DispatchContext dctx, Map<String, Object> context) {
         Map<String, Object> result = FastMap.newInstance();
-        Delegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
-        Locale locale = (Locale) context.get("locale");
-        GenericValue userLogin = (GenericValue) context.get("userLogin");
         try {
             if ("Complete".equals(context.get("checkoutStatus").toString()) && "NOT_IMPORT".equals(context.get("importStatus").toString())) {
                 if (UtilValidate.isEmpty(context.get("shippingAddressStreet1"))) {
@@ -77,11 +74,8 @@ public class EbayStoreOrder {
         return result;
     }
     public static Map<String, Object> EbayStoreImportOrder(DispatchContext dctx, Map<String, Object> context) {
-        Delegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
-        Locale locale = (Locale) context.get("locale");
-        GenericValue userLogin = (GenericValue) context.get("userLogin");
-        Map result = FastMap.newInstance();
+        Map<String, Object> result = FastMap.newInstance();
         if (UtilValidate.isEmpty(context.get("orderId"))) {
             try {
                 result = dispatcher.runSync("EbayStoreCreateOrderShoppingCart", context);
@@ -162,10 +156,7 @@ public class EbayStoreOrder {
                 }
             }
 
-            String paidTime = null;
-            if (UtilValidate.isNotEmpty(context.get("paidTime"))) {
-                paidTime = context.get("paidTime").toString();
-            } else {
+            if (UtilValidate.isEmpty(context.get("paidTime"))) {
                 return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.paymentIsStillNotReceived", locale));
             }
 
@@ -528,11 +519,6 @@ public class EbayStoreOrder {
             String orderId = (String) orderCreate.get("orderId");
             Debug.logInfo("Created order with id: " + orderId, module);
 
-            if (UtilValidate.isNotEmpty(orderId)) {
-                String orderCreatedMsg = "Order created successfully with ID (" + orderId + ") & eBay Order ID associated with this order is (" + externalId + ").";
-                //orderImportSuccessMessageList.add(orderCreatedMsg);
-            }
-
             // approve the order
             if (UtilValidate.isNotEmpty(orderId)) {
                 Debug.logInfo("Approving order with id: " + orderId, module);
@@ -545,6 +531,7 @@ public class EbayStoreOrder {
                     EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId);
                     Debug.logInfo("Payment created.", module);
                 }
+                result = ServiceUtil.returnFailure("Order created successfully with ID (" + orderId + ") & eBay Order ID associated with this order is (" + externalId + ").");
             }
         } catch (Exception e) {
             result = ServiceUtil.returnFailure(e.getMessage());
@@ -556,8 +543,7 @@ public class EbayStoreOrder {
         String productId = orderItem.get("productId").toString();
         GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
         if (UtilValidate.isEmpty(product)) {
-            String productMissingMsg = "The product having ID (" + productId + ") is misssing in the system.";
-            //orderImportFailureMessageList.add(productMissingMsg);
+            Debug.log("The product having ID (" + productId + ") is misssing in the system.", module);
         }
         BigDecimal qty = new BigDecimal(orderItem.get("quantity").toString());
         String itemPrice = orderItem.get("transactionPrice").toString();