svn commit: r932855 - in /ofbiz/trunk/specialpurpose: googlebase/src/org/ofbiz/googlebase/ googlecheckout/src/org/ofbiz/googlecheckout/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r932855 - in /ofbiz/trunk/specialpurpose: googlebase/src/org/ofbiz/googlebase/ googlecheckout/src/org/ofbiz/googlecheckout/

jleroux@apache.org
Author: jleroux
Date: Sun Apr 11 09:06:03 2010
New Revision: 932855

URL: http://svn.apache.org/viewvc?rev=932855&view=rev
Log:
A patch from Bob Morley "Resolve java warnings exposed in Eclipse (googlebase & googlecheckout part of OFBIZ-3100)" https://issues.apache.org/jira/browse/OFBIZ-3597 - OFBIZ-3597

I just replaced a few tabs


Modified:
    ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java
    ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
    ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java
    ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java

Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java?rev=932855&r1=932854&r2=932855&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java Sun Apr 11 09:06:03 2010
@@ -18,7 +18,6 @@
  *******************************************************************************/
 package org.ofbiz.googlebase;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -26,8 +25,11 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import javolution.util.FastList;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
@@ -54,7 +56,7 @@ public class GoogleBaseSearchEvents {
         Locale locale = UtilHttp.getLocale(request);
         GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
         String selectResult = (String) request.getParameter("selectResult");
-        List productExportList = new ArrayList();
+        List<String> productExportList = FastList.newInstance();
         String errMsg = null;
 
         try {
@@ -107,7 +109,7 @@ public class GoogleBaseSearchEvents {
                     inMap.put("productStoreId", productStoreId);
                     Map<String, Object> exportResult = dispatcher.runSync("exportToGoogle", inMap);
                     if (ServiceUtil.isError(exportResult)) {
-                        List errorMessages = (List) exportResult.get(ModelService.ERROR_MESSAGE_LIST);
+                        List<String> errorMessages = UtilGenerics.checkList(exportResult.get(ModelService.ERROR_MESSAGE_LIST), String.class);
                         if (UtilValidate.isNotEmpty(errorMessages)) {
                             request.setAttribute("_ERROR_MESSAGE_LIST_", errorMessages);
                         } else {
@@ -115,7 +117,7 @@ public class GoogleBaseSearchEvents {
                         }
                         return "error";
                     } else if (ServiceUtil.isFailure(exportResult)) {
-                        List eventMessages = (List) exportResult.get(ModelService.ERROR_MESSAGE_LIST);
+                        List<String> eventMessages = UtilGenerics.checkList(exportResult.get(ModelService.ERROR_MESSAGE_LIST), String.class);
                         if (UtilValidate.isNotEmpty(eventMessages)) {
                             request.setAttribute("_EVENT_MESSAGE_LIST_", eventMessages);
                         } else {

Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java?rev=932855&r1=932854&r2=932855&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Sun Apr 11 09:06:03 2010
@@ -38,6 +38,7 @@ import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilFormatOut;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
@@ -80,7 +81,10 @@ public class ProductsExportToGoogle {
             if (!ServiceUtil.isFailure(result) && UtilValidate.isNotEmpty(googleBaseConfigResult)) {
                 String token = authenticate(googleBaseConfigResult.get("authenticationUrl").toString(), googleBaseConfigResult.get("accountEmail").toString(), googleBaseConfigResult.get("accountPassword").toString());
                 if (token != null) {
-                    result = postItem(token, googleBaseConfigResult.get("postItemsUrl").toString(), googleBaseConfigResult.get("developerKey").toString(), dataItemsXml, locale, (String)context.get("testMode"), (List)result.get("newProductsInGoogle"), (List)result.get("productsRemovedFromGoogle"), dispatcher, delegator);
+                    List<String> newProductsInGoogle = UtilGenerics.checkList(result.get("newProductsInGoogle"), String.class);
+                    List<String> productsRemovedFromGoogle = UtilGenerics.checkList(result.get("productsRemovedFromGoogle"), String.class);
+                    result = postItem(token, googleBaseConfigResult.get("postItemsUrl").toString(), googleBaseConfigResult.get("developerKey").toString(), dataItemsXml,
+                            locale, (String)context.get("testMode"), newProductsInGoogle, productsRemovedFromGoogle, dispatcher, delegator);
                 } else {
                     Debug.logError("Error during authentication to Google Account", module);
                     return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToGoogle.errorDuringAuthenticationToGoogle", locale));
@@ -108,19 +112,15 @@ public class ProductsExportToGoogle {
 
         try {
             if (UtilValidate.isNotEmpty(productCategoryId)) {
-                List productsList = FastList.newInstance();
+                List<String> productsList = FastList.newInstance();
                 Map<String, Object> result = dispatcher.runSync("getProductCategoryMembers", UtilMisc.toMap("categoryId", productCategoryId));
 
                 if (result.get("categoryMembers") != null) {
-                    List productCategoryMembers = (List)result.get("categoryMembers");
+                    List<GenericValue> productCategoryMembers = UtilGenerics.checkList(result.get("categoryMembers"), GenericValue.class);
                     if (productCategoryMembers != null) {
-                        Iterator i = productCategoryMembers.iterator();
-                        while (i.hasNext()) {
-                            GenericValue prodCatMemb = (GenericValue) i.next();
-
+                        for (GenericValue prodCatMemb : productCategoryMembers) {
                             if (prodCatMemb != null) {
                                 String productId = prodCatMemb.getString("productId");
-
                                 if (productId != null) {
                                     GenericValue prod = prodCatMemb.getRelatedOne("Product");
                                     Timestamp salesDiscontinuationDate = prod.getTimestamp("salesDiscontinuationDate");
@@ -244,8 +244,9 @@ public class ProductsExportToGoogle {
         return outputBuilder.toString();
     }
 
-    private static Map postItem(String token, String postItemsUrl, String developerKey, StringBuffer dataItems,
-                                Locale locale, String testMode, List newProductsInGoogle, List productsRemovedFromGoogle, LocalDispatcher dispatcher, Delegator delegator) throws IOException {
+    private static Map<String, Object> postItem(String token, String postItemsUrl, String developerKey, StringBuffer dataItems,
+                                Locale locale, String testMode, List<String> newProductsInGoogle, List<String> productsRemovedFromGoogle,
+                                LocalDispatcher dispatcher, Delegator delegator) throws IOException {
         if (Debug.verboseOn()) {
             Debug.logVerbose("Request To Google Base :\n" + dataItems.toString(), module);
         }
@@ -279,7 +280,7 @@ public class ProductsExportToGoogle {
                 result = readResponseFromGoogle(response, newProductsInGoogle, productsRemovedFromGoogle, dispatcher, delegator, locale);
                 //String msg = ServiceUtil.getErrorMessage(result);
                 if (ServiceUtil.isError(result)) {
-                    result = ServiceUtil.returnFailure((List)result.get(ModelService.ERROR_MESSAGE_LIST));
+                    result = ServiceUtil.returnFailure(UtilGenerics.checkList(result.get(ModelService.ERROR_MESSAGE_LIST)));
                 } else {
                     result = ServiceUtil.returnSuccess();
                 }
@@ -298,14 +299,13 @@ public class ProductsExportToGoogle {
 
     private static Map<String, Object> buildDataItemsXml(DispatchContext dctx, Map<String, Object> context, StringBuffer dataItemsXml) {
         Locale locale = (Locale)context.get("locale");
-        List<Object> newProductsInGoogle = FastList.newInstance();
-        List<Object> productsRemovedFromGoogle = FastList.newInstance();
+        List<String> newProductsInGoogle = FastList.newInstance();
+        List<String> productsRemovedFromGoogle = FastList.newInstance();
         try {
             Delegator delegator = dctx.getDelegator();
             LocalDispatcher dispatcher = dctx.getDispatcher();
-            List selectResult = (List)context.get("selectResult");
+            List<String> selectResult = UtilGenerics.checkList(context.get("selectResult"), String.class);
             String webSiteUrl = (String)context.get("webSiteUrl");
-            String imageUrl = (String)context.get("imageUrl");
             String actionType = (String)context.get("actionType");
             String statusId = (String)context.get("statusId");
             String trackingCodeId = (String)context.get("trackingCodeId");
@@ -524,7 +524,6 @@ public class ProductsExportToGoogle {
         try {
             map = dispatcher.runSync("calculateProductPrice", UtilMisc.toMap("product", product));
             boolean validPriceFound = ((Boolean)map.get("validPriceFound")).booleanValue();
-            boolean isSale = ((Boolean)map.get("isSale")).booleanValue();
             if (validPriceFound) {
                 priceString = map.get("price").toString();
             }
@@ -534,8 +533,9 @@ public class ProductsExportToGoogle {
         return priceString;
     }
 
-    private static Map<String, Object> readResponseFromGoogle(String msg, List<Object> newProductsInGoogle, List<Object> productsRemovedFromGoogle, LocalDispatcher dispatcher, Delegator delegator, Locale locale) {
-        List message = FastList.newInstance();
+    private static Map<String, Object> readResponseFromGoogle(String msg, List<String> newProductsInGoogle, List<String> productsRemovedFromGoogle,
+            LocalDispatcher dispatcher, Delegator delegator, Locale locale) {
+        List<String> message = FastList.newInstance();
         // Debug.log("====get xml response from google: " + msg);
         try {
             Document docResponse = UtilXml.readXmlDocument(msg, true);
@@ -561,7 +561,7 @@ public class ProductsExportToGoogle {
                 if (UtilValidate.isNotEmpty(id) && productsRemovedFromGoogle.get(index) != null) {
                     String productId = (String)productsRemovedFromGoogle.get(index);
                     try {
-                        int count = delegator.removeByAnd("GoodIdentification", UtilMisc.toMap("goodIdentificationTypeId", "GOOGLE_ID", "productId", productId));
+                        delegator.removeByAnd("GoodIdentification", UtilMisc.toMap("goodIdentificationTypeId", "GOOGLE_ID", "productId", productId));
                     } catch (GenericEntityException gee) {
                         Debug.logError("Unable to remove Google id for product [" + productId + "]: " + gee.getMessage(), module);
                     }

Modified: ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java?rev=932855&r1=932854&r2=932855&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java (original)
+++ ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleCheckoutHelper.java Sun Apr 11 09:06:03 2010
@@ -29,6 +29,7 @@ import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
@@ -230,7 +231,6 @@ public class GoogleCheckoutHelper {
         return; // the notification will be accepted
     }
 
-    @SuppressWarnings("unchecked")
     public void createOrder(NewOrderNotification info, String productStoreId, Locale locale) throws GeneralException {
         // get the google order number
         String externalId = info.getGoogleOrderNumber();
@@ -300,7 +300,7 @@ public class GoogleCheckoutHelper {
         }
 
         // set the order items
-        Collection<Item> items = info.getShoppingCart().getItems();
+        Collection<Item> items = UtilGenerics.checkCollection(info.getShoppingCart().getItems());
         for (Item item : items) {
             try {
                 addItem(cart, item, prodCatalogId, 0);
@@ -327,13 +327,13 @@ public class GoogleCheckoutHelper {
 
         // validate the payment methods
         CheckOutHelper coh = new CheckOutHelper(dispatcher, delegator, cart);
-        Map validateResp = coh.validatePaymentMethods();
+        Map<String, Object> validateResp = coh.validatePaymentMethods();
         if (ServiceUtil.isError(validateResp)) {
             throw new GeneralException(ServiceUtil.getErrorMessage(validateResp));
         }
 
         // create the order & process payments
-        Map createResp = coh.createOrder(system);
+        Map<String, Object> createResp = coh.createOrder(system);
         String orderId = cart.getOrderId();
         if (ServiceUtil.isError(createResp)) {
             throw new GeneralException(ServiceUtil.getErrorMessage(createResp));
@@ -376,7 +376,6 @@ public class GoogleCheckoutHelper {
         cart.setItemShipGroupQty(cartItem, qty, groupIdx);
     }
 
-    @SuppressWarnings("unchecked")
     protected void addAdjustments(ShoppingCart cart, OrderAdjustment adjustment) {
         // handle shipping
         Shipping shipping = adjustment.getShipping();
@@ -394,7 +393,7 @@ public class GoogleCheckoutHelper {
         cart.addAdjustment(taxAdj);
 
         // handle promotions
-        Collection<MerchantCodes> merchantCodes = adjustment.getMerchantCodes();
+        Collection<MerchantCodes> merchantCodes = UtilGenerics.checkCollection(adjustment.getMerchantCodes());
         for (MerchantCodes codes : merchantCodes) {
             GenericValue promoAdj = delegator.makeValue("OrderAdjustment", FastMap.newInstance());
             promoAdj.set("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT");

Modified: ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java?rev=932855&r1=932854&r2=932855&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java (original)
+++ ofbiz/trunk/specialpurpose/googlecheckout/src/org/ofbiz/googlecheckout/GoogleRequestServices.java Sun Apr 11 09:06:03 2010
@@ -66,7 +66,6 @@ public class GoogleRequestServices {
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
     private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
 
-    @SuppressWarnings("unchecked")
     public static Map<String, Object> sendShoppingCartRequest(DispatchContext dctx, Map<String, ? extends Object> context) {
         ShoppingCart cart = (ShoppingCart) context.get("shoppingCart");
         String productStoreId = cart.getProductStoreId();