svn commit: r818714 - in /ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase: GoogleBaseSearchEvents.java ProductsExportToGoogle.java

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

svn commit: r818714 - in /ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase: GoogleBaseSearchEvents.java ProductsExportToGoogle.java

ashish-18
Author: ashish
Date: Fri Sep 25 04:29:10 2009
New Revision: 818714

URL: http://svn.apache.org/viewvc?rev=818714&view=rev
Log:
Encouraging use of Generics.

Modified:
    ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java
    ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.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=818714&r1=818713&r2=818714&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java Fri Sep 25 04:29:10 2009
@@ -94,7 +94,7 @@
 
                 // Export all or selected products to Google Base
                 try {
-                    Map inMap = UtilMisc.toMap("selectResult", productExportList,
+                    Map<String, Object> inMap = UtilMisc.toMap("selectResult", productExportList,
                                                "webSiteUrl", webSiteUrl,
                                                "imageUrl", imageUrl,
                                                "actionType", actionType,
@@ -105,9 +105,9 @@
                     inMap.put("trackingCodeId", trackingCodeId);
                     inMap.put("userLogin", userLogin);
                     inMap.put("productStoreId", productStoreId);
-                    Map exportResult = dispatcher.runSync("exportToGoogle", inMap);
+                    Map<String, Object> exportResult = dispatcher.runSync("exportToGoogle", inMap);
                     if (ServiceUtil.isError(exportResult)) {
-                        List errorMessages = (List)exportResult.get(ModelService.ERROR_MESSAGE_LIST);
+                        List errorMessages = (List) exportResult.get(ModelService.ERROR_MESSAGE_LIST);
                         if (UtilValidate.isNotEmpty(errorMessages)) {
                             request.setAttribute("_ERROR_MESSAGE_LIST_", errorMessages);
                         } else {
@@ -115,7 +115,7 @@
                         }
                         return "error";
                     } else if (ServiceUtil.isFailure(exportResult)) {
-                        List eventMessages = (List)exportResult.get(ModelService.ERROR_MESSAGE_LIST);
+                        List eventMessages = (List) exportResult.get(ModelService.ERROR_MESSAGE_LIST);
                         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=818714&r1=818713&r2=818714&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Fri Sep 25 04:29:10 2009
@@ -66,12 +66,12 @@
     private static final String googleBaseAppUrl = "http://purl.org/atom/app#";
     private static final String configString = "googleBaseExport.properties";
 
-    public static Map exportToGoogle(DispatchContext dctx, Map context) {
+    public static Map<String, Object> exportToGoogle(DispatchContext dctx, Map<String, Object> context) {
         Locale locale = (Locale) context.get("locale");
         GenericDelegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
 
-        Map result = null;
+        Map<String, Object> result = null;
         try {
             Map<String, Object> googleBaseConfigResult = buildGoogleBaseConfig(context, delegator);
             StringBuffer dataItemsXml = new StringBuffer();
@@ -94,7 +94,7 @@
         return result;
     }
 
-    public static Map exportProductCategoryToGoogle(DispatchContext dctx, Map context) {
+    public static Map<String, Object> exportProductCategoryToGoogle(DispatchContext dctx, Map<String, Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Locale locale = (Locale) context.get("locale");
         String productCategoryId = (String) context.get("productCategoryId");
@@ -109,7 +109,7 @@
         try {
             if (UtilValidate.isNotEmpty(productCategoryId)) {
                 List productsList = FastList.newInstance();
-                Map result = dispatcher.runSync("getProductCategoryMembers", UtilMisc.toMap("categoryId", productCategoryId));
+                Map<String, Object> result = dispatcher.runSync("getProductCategoryMembers", UtilMisc.toMap("categoryId", productCategoryId));
 
                 if (result.get("categoryMembers") != null) {
                     List productCategoryMembers = (List)result.get("categoryMembers");
@@ -137,7 +137,7 @@
                 if (productsList.size() == 0) {
                     return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToGoogle.noProductsAvailableInProductCategory", locale));
                 } else {
-                    Map paramIn = FastMap.newInstance();
+                    Map<String, Object> paramIn = FastMap.newInstance();
                     paramIn.put("selectResult", productsList);
                     paramIn.put("webSiteUrl", webSiteUrl);
                     paramIn.put("imageUrl", imageUrl);
@@ -270,7 +270,7 @@
 
         int responseCode = connection.getResponseCode();
         InputStream inputStream;
-        Map result = FastMap.newInstance();
+        Map<String, Object> result = FastMap.newInstance();
         String response = "";
         if (responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_OK) {
             inputStream = connection.getInputStream();
@@ -296,10 +296,10 @@
         return result;
     }
 
-    private static Map buildDataItemsXml(DispatchContext dctx, Map context, StringBuffer dataItemsXml) {
+    private static Map<String, Object> buildDataItemsXml(DispatchContext dctx, Map<String, Object> context, StringBuffer dataItemsXml) {
         Locale locale = (Locale)context.get("locale");
-        List newProductsInGoogle = FastList.newInstance();
-        List productsRemovedFromGoogle = FastList.newInstance();
+        List<Object> newProductsInGoogle = FastList.newInstance();
+        List<Object> productsRemovedFromGoogle = FastList.newInstance();
         try {
             GenericDelegator delegator = dctx.getDelegator();
             LocalDispatcher dispatcher = dctx.getDispatcher();
@@ -338,7 +338,7 @@
                 return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToGoogle.invalidCountryCode", locale));
             }
             // Get the list of products to be exported to Google Base
-            List productsList  = delegator.findList("Product", EntityCondition.makeCondition("productId", EntityOperator.IN, selectResult), null, null, null, false);
+            List<GenericValue> productsList  = delegator.findList("Product", EntityCondition.makeCondition("productId", EntityOperator.IN, selectResult), null, null, null, false);
 
             // Get the tracking code
             if (UtilValidate.isEmpty(trackingCodeId) || "_NA_".equals(trackingCodeId)) {
@@ -356,7 +356,7 @@
             feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:app", googleBaseAppUrl);
 
             // Iterate the product list getting all the relevant data
-            Iterator productsListItr = productsList.iterator();
+            Iterator<GenericValue> productsListItr = productsList.iterator();
             int index = 0;
             String itemActionType = null;
             GenericValue googleProduct;
@@ -443,7 +443,7 @@
                 
                 List<GenericValue> productCategoryMembers = delegator.findList("ProductCategoryMember", EntityCondition.makeCondition("productId", EntityOperator.EQUALS, prod.getString("productId")), null, UtilMisc.toList("productCategoryId"), null, false);
                 
-                Iterator productCategoryMembersIter = productCategoryMembers.iterator();
+                Iterator<GenericValue> productCategoryMembersIter = productCategoryMembers.iterator();
                 while (productCategoryMembersIter.hasNext()) {
                     GenericValue productCategoryMember = (GenericValue) productCategoryMembersIter.next();
                     GenericValue productCategory = productCategoryMember.getRelatedOne("ProductCategory");
@@ -508,7 +508,7 @@
             return ServiceUtil.returnError("Unable to read from product entity: "  + e.toString());
         }
 
-        Map result = ServiceUtil.returnSuccess();
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("newProductsInGoogle", newProductsInGoogle);
         result.put("productsRemovedFromGoogle", productsRemovedFromGoogle);
         Debug.log("======returning with result: " + result);
@@ -531,14 +531,14 @@
         return priceString;
     }
 
-    private static Map readResponseFromGoogle(String msg, List newProductsInGoogle, List productsRemovedFromGoogle, LocalDispatcher dispatcher, GenericDelegator delegator, Locale locale) {
+    private static Map<String, Object> readResponseFromGoogle(String msg, List<Object> newProductsInGoogle, List<Object> productsRemovedFromGoogle, LocalDispatcher dispatcher, GenericDelegator delegator, Locale locale) {
         List message = FastList.newInstance();
         // Debug.log("====get xml response from google: " + msg);
         try {
             Document docResponse = UtilXml.readXmlDocument(msg, true);
             Element elemResponse = docResponse.getDocumentElement();
-            List atomEntryList = UtilXml.childElementList(elemResponse, "atom:entry");
-            Iterator atomEntryElemIter = atomEntryList.iterator();
+            List<? extends Element> atomEntryList = UtilXml.childElementList(elemResponse, "atom:entry");
+            Iterator<? extends Element> atomEntryElemIter = atomEntryList.iterator();
             int index = 0;
             while (atomEntryElemIter.hasNext()) {
                 Element atomEntryElement = (Element)atomEntryElemIter.next();
@@ -564,8 +564,8 @@
                     }
                 }
                 String title = "Google response: " + UtilXml.childElementValue(atomEntryElement, "atom:title", "");
-                List batchStatusList = UtilXml.childElementList(atomEntryElement, "batch:status");
-                Iterator batchStatusEntryElemIter = batchStatusList.iterator();
+                List<? extends Element> batchStatusList = UtilXml.childElementList(atomEntryElement, "batch:status");
+                Iterator<? extends Element> batchStatusEntryElemIter = batchStatusList.iterator();
                 while (batchStatusEntryElemIter.hasNext()) {
                     Element batchStatusEntryElement = (Element)batchStatusEntryElemIter.next();
                     if (UtilValidate.isNotEmpty(batchStatusEntryElement.getAttribute("reason"))) {