Author: jleroux
Date: Sat May 15 21:11:02 2010
New Revision: 944720
URL: http://svn.apache.org/viewvc?rev=944720&view=rev
Log:
A patch from Bob Morley "Resolve java warnings exposed in Eclipse (ebay part of
OFBIZ-3100)" https://issues.apache.org/jira/browse/OFBIZ-3600 - OFBIZ-3600
Bob's comment: three ebay related files along with CheckoutHelper in
application/orders whose createOrder now returns a more complete Map<String,
Object> instead of a non-generic Map.
Actually CheckoutHelper was already containing Bob's change but there are
still a lot of warning, I began to work on them and also in CheckOutEvents, but
I finally gave up...
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java?rev=944720&r1=944719&r2=944720&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartEventListener.java
Sat May 15 21:11:02 2010
@@ -18,7 +18,6 @@
*******************************************************************************/
package org.ofbiz.order.shoppingcart;
-import java.math.BigDecimal;
import java.util.Iterator;
import javax.servlet.http.HttpSession;
@@ -27,12 +26,12 @@ import javax.servlet.http.HttpSessionLis
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.webapp.stats.VisitHandler;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.transaction.TransactionUtil;
+import org.ofbiz.webapp.stats.VisitHandler;
/**
* HttpSessionListener that saves information about abandoned carts
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.java?rev=944720&r1=944719&r2=944720&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CartItemModifyException.java
Sat May 15 21:11:02 2010
@@ -23,6 +23,7 @@ import org.ofbiz.base.util.GeneralExcept
/**
* Exception
*/
+...@suppresswarnings("serial")
public class CartItemModifyException extends GeneralException {
public CartItemModifyException() {
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=944720&r1=944719&r2=944720&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
Sat May 15 21:11:02 2010
@@ -19,7 +19,6 @@
package org.ofbiz.order.shoppingcart;
import java.math.BigDecimal;
-import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -30,7 +29,16 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import org.ofbiz.base.util.*;
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.GeneralRuntimeException;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -46,8 +54,6 @@ import org.ofbiz.service.ModelService;
import org.ofbiz.service.ServiceUtil;
import org.ofbiz.webapp.stats.VisitHandler;
-import javolution.util.FastMap;
-
/**
* Events used for processing checkout and orders.
*/
@@ -108,22 +114,22 @@ public class CheckOutEvents {
String partyTaxId = request.getParameter("partyTaxId");
String isExempt = request.getParameter("isExempt");
- List errorMessages = new ArrayList();
- Map errorMaps = new HashMap();
+ List<String> errorMessages = new ArrayList<String>();
+ Map<String, Object> errorMaps = new HashMap<String, Object>();
for (int shipGroupIndex = 0; shipGroupIndex <
cart.getShipGroupSize(); shipGroupIndex++) {
// set the shipping method
if (shippingContactMechId == null) {
shippingContactMechId = (String)
request.getAttribute("contactMechId"); // FIXME
}
String supplierPartyId = (String)
request.getAttribute(shipGroupIndex + "_supplierPartyId");
- Map callResult =
checkOutHelper.finalizeOrderEntryShip(shipGroupIndex, shippingContactMechId,
supplierPartyId);
+ Map<String, ? extends Object> callResult =
checkOutHelper.finalizeOrderEntryShip(shipGroupIndex, shippingContactMechId,
supplierPartyId);
ServiceUtil.addErrors(errorMessages, errorMaps, callResult);
}
// if taxAuthPartyGeoIds is not empty drop that into the database
if (UtilValidate.isNotEmpty(taxAuthPartyGeoIds)) {
try {
- Map createCustomerTaxAuthInfoResult =
dispatcher.runSync("createCustomerTaxAuthInfo",
+ Map<String, ? extends Object>
createCustomerTaxAuthInfoResult =
dispatcher.runSync("createCustomerTaxAuthInfo",
UtilMisc.<String, Object>toMap("partyId",
cart.getPartyId(), "taxAuthPartyGeoIds", taxAuthPartyGeoIds, "partyTaxId",
partyTaxId, "isExempt", isExempt, "userLogin", userLogin));
ServiceUtil.getMessages(request,
createCustomerTaxAuthInfoResult, null);
if (ServiceUtil.isError(createCustomerTaxAuthInfoResult)) {
@@ -136,7 +142,7 @@ public class CheckOutEvents {
}
}
- Map callResult =
checkOutHelper.setCheckOutShippingAddress(shippingContactMechId);
+ Map<String, ? extends Object> callResult =
checkOutHelper.setCheckOutShippingAddress(shippingContactMechId);
ServiceUtil.getMessages(request, callResult, null);
if (!(ServiceUtil.isError(callResult))) {
@@ -154,7 +160,7 @@ public class CheckOutEvents {
String internalCode = request.getParameter("internalCode");
String shipBeforeDate = request.getParameter("shipBeforeDate");
String shipAfterDate = request.getParameter("shipAfterDate");
- Map callResult = ServiceUtil.returnSuccess();
+ Map<String, ? extends Object> callResult =
ServiceUtil.returnSuccess();
for (int shipGroupIndex = 0; shipGroupIndex <
cart.getShipGroupSize(); shipGroupIndex++) {
callResult =
checkOutHelper.finalizeOrderEntryOptions(shipGroupIndex, shippingMethod,
shippingInstructions, maySplit, giftMessage, isGift, internalCode,
shipBeforeDate, shipAfterDate, orderAdditionalEmails);
@@ -771,9 +777,9 @@ public class CheckOutEvents {
//
====================================================================================
if (mode != null && (mode.equals("ship") || mode.equals("options"))) {
- Map callResult = ServiceUtil.returnSuccess();
- List errorMessages = new ArrayList();
- Map errorMaps = new HashMap();
+ Map<String, Object> callResult = ServiceUtil.returnSuccess();
+ List<String> errorMessages = new ArrayList<String>();
+ Map<String, Object> errorMaps = new HashMap<String, Object>();
for (int shipGroupIndex = 0; shipGroupIndex <
cart.getShipGroupSize(); shipGroupIndex++) {
// set the shipping method
if (mode != null && mode.equals("ship")) {
@@ -823,7 +829,7 @@ public class CheckOutEvents {
//See whether we need to return an error or not
callResult = ServiceUtil.returnSuccess();
if (errorMessages.size() > 0) {
- callResult.put(ModelService.ERROR_MESSAGE_LIST, errorMessages);
+ callResult.put(ModelService.ERROR_MESSAGE_LIST,
errorMessages);
callResult.put(ModelService.RESPONSE_MESSAGE,
ModelService.RESPOND_ERROR);
}
if (errorMaps.size() > 0) {
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=944720&r1=944719&r2=944720&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
Sat May 15 21:11:02 2010
@@ -20,8 +20,6 @@ package org.ofbiz.order.shoppingcart;
import java.math.BigDecimal;
import java.sql.Timestamp;
-import java.text.DecimalFormat;
-import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -47,7 +45,6 @@ import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityConditionList;
import org.ofbiz.entity.condition.EntityExpr;
-import org.ofbiz.entity.condition.EntityFieldValue;
import org.ofbiz.entity.condition.EntityFunction;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.util.EntityUtil;
@@ -87,9 +84,9 @@ public class CheckOutHelper {
this.cart = cart;
}
- public Map setCheckOutShippingAddress(String shippingContactMechId) {
+ public Map<String, Object> setCheckOutShippingAddress(String
shippingContactMechId) {
List errorMessages = new ArrayList();
- Map result;
+ Map<String, Object> result;
String errMsg = null;
if (UtilValidate.isNotEmpty(this.cart)) {
@@ -1292,8 +1289,8 @@ public class CheckOutHelper {
* @return A Map conforming to the OFBiz Service conventions containing
* any error messages
*/
- public Map finalizeOrderEntryShip(int shipGroupIndex, String
shippingContactMechId, String supplierPartyId) {
- Map result;
+ public Map<String, Object> finalizeOrderEntryShip(int shipGroupIndex,
String shippingContactMechId, String supplierPartyId) {
+ Map<String, Object> result;
String errMsg=null;
//Verify the field is valid
if (UtilValidate.isNotEmpty(shippingContactMechId)) {
@@ -1324,20 +1321,20 @@ public class CheckOutHelper {
* @return A Map conforming to the OFBiz Service conventions containing
* any error messages
*/
- public Map finalizeOrderEntryOptions(int shipGroupIndex, String
shippingMethod, String shippingInstructions, String maySplit,
+ public Map<String, Object> finalizeOrderEntryOptions(int shipGroupIndex,
String shippingMethod, String shippingInstructions, String maySplit,
String giftMessage, String isGift, String internalCode, String
shipBeforeDate, String shipAfterDate, String orderAdditionalEmails) {
this.cart.setOrderAdditionalEmails(orderAdditionalEmails);
return finalizeOrderEntryOptions(shipGroupIndex, shippingMethod,
shippingInstructions, maySplit, giftMessage, isGift, internalCode,
shipBeforeDate, shipAfterDate, null, null);
}
- public Map finalizeOrderEntryOptions(int shipGroupIndex, String
shippingMethod, String shippingInstructions, String maySplit,
+ public Map<String, Object> finalizeOrderEntryOptions(int shipGroupIndex,
String shippingMethod, String shippingInstructions, String maySplit,
String giftMessage, String isGift, String internalCode, String
shipBeforeDate, String shipAfterDate, String internalOrderNotes, String
shippingNotes, BigDecimal shipEstimate) {
this.cart.setItemShipGroupEstimate(shipEstimate, shipGroupIndex);
return finalizeOrderEntryOptions(shipGroupIndex, shippingMethod,
shippingInstructions, maySplit, giftMessage, isGift, internalCode,
shipBeforeDate, shipAfterDate, internalOrderNotes, shippingNotes);
}
- public Map finalizeOrderEntryOptions(int shipGroupIndex, String
shippingMethod, String shippingInstructions, String maySplit,
+ public Map<String, Object> finalizeOrderEntryOptions(int shipGroupIndex,
String shippingMethod, String shippingInstructions, String maySplit,
String giftMessage, String isGift, String internalCode, String
shipBeforeDate, String shipAfterDate, String internalOrderNotes, String
shippingNotes) {
-
- Map result = ServiceUtil.returnSuccess();
+
+ Map<String, Object> result = ServiceUtil.returnSuccess();
String errMsg=null;
//Verify the shipping method is valid
Modified:
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java?rev=944720&r1=944719&r2=944720&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
(original)
+++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
Sat May 15 21:11:02 2010
@@ -33,6 +33,7 @@ import javolution.util.FastMap;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
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;
@@ -123,7 +124,7 @@ public class EbayOrderServices {
Locale locale = (Locale) context.get("locale");
Map<String, Object> result = FastMap.newInstance();
String externalId = (String) context.get("externalId");
- List orderList = (List) context.get("orderList");
+ List<Map<String, Object>> orderList =
UtilGenerics.checkList(context.get("orderList"));
try {
if (UtilValidate.isNotEmpty(orderList)) {
Iterator<Map<String, Object>> orderListIter =
orderList.iterator();
@@ -1037,7 +1038,7 @@ public class EbayOrderServices {
return
ServiceUtil.returnFailure(UtilProperties.getMessage(resource,
"ordersImportFromEbay.paymentIsStillNotReceived", locale));
}
- List orderItemList = (List) context.get("orderItemList");
+ List<Map<String, Object>> orderItemList =
UtilGenerics.checkList(context.get("orderItemList"));
Iterator<Map<String, Object>> orderItemIter =
orderItemList.iterator();
while (orderItemIter.hasNext()) {
Map<String, Object> orderItem = (Map<String, Object>)
orderItemIter.next();
@@ -1049,7 +1050,7 @@ public class EbayOrderServices {
cart.setBillFromVendorPartyId(payToPartyId);
}
// Apply shipping costs as order adjustment
- Map shippingServiceSelectedCtx = (Map)
context.get("shippingServiceSelectedCtx");
+ Map<String, Object> shippingServiceSelectedCtx =
UtilGenerics.checkMap(context.get("shippingServiceSelectedCtx"));
String shippingCost = (String)
shippingServiceSelectedCtx.get("shippingServiceCost");
if (UtilValidate.isNotEmpty(shippingCost)) {
@@ -1073,7 +1074,7 @@ public class EbayOrderServices {
}
}
// Apply sales tax as order adjustment
- Map shippingDetailsCtx = (Map) context.get("shippingDetailsCtx");
+ Map<String, Object> shippingDetailsCtx =
UtilGenerics.checkMap(context.get("shippingDetailsCtx"));
String salesTaxAmount = (String)
shippingDetailsCtx.get("salesTaxAmount");
String salesTaxPercent = (String)
shippingDetailsCtx.get("salesTaxPercent");
if (UtilValidate.isNotEmpty(salesTaxAmount)) {
@@ -1096,7 +1097,7 @@ public class EbayOrderServices {
String partyId = null;
String contactMechId = null;
- Map shippingAddressCtx = (Map)
context.get("shippingAddressCtx");
+ Map<String, Object> shippingAddressCtx =
UtilGenerics.checkMap(context.get("shippingAddressCtx"));
if (UtilValidate.isNotEmpty(shippingAddressCtx)) {
String buyerName = (String)
shippingAddressCtx.get("buyerName");
String firstName = (String) buyerName.substring(0,
buyerName.indexOf(" "));
@@ -1134,9 +1135,9 @@ public class EbayOrderServices {
contactMechId =
EbayHelper.setShippingAddressContactMech(dispatcher, delegator, party,
userLogin, shippingAddressCtx);
String emailBuyer = (String) context.get("emailBuyer");
if (!(emailBuyer.equals("") ||
emailBuyer.equalsIgnoreCase("Invalid Request"))) {
- String emailContactMech =
EbayHelper.setEmailContactMech(dispatcher, delegator, party, userLogin,
context);
+ EbayHelper.setEmailContactMech(dispatcher, delegator,
party, userLogin, context);
}
- String phoneContactMech =
EbayHelper.setPhoneContactMech(dispatcher, delegator, party, userLogin,
shippingAddressCtx);
+ EbayHelper.setPhoneContactMech(dispatcher, delegator,
party, userLogin, shippingAddressCtx);
}
// create party if none exists already
@@ -1151,7 +1152,7 @@ public class EbayOrderServices {
// create new party's contact information
if (UtilValidate.isEmpty(contactMechId)) {
- Map buyerCtx = (Map) context.get("buyerCtx");
+ Map<String, Object> buyerCtx =
UtilGenerics.checkMap(context.get("buyerCtx"));
String eiasTokenBuyer = null;
if (UtilValidate.isNotEmpty(buyerCtx)) {
eiasTokenBuyer = (String)
buyerCtx.get("eiasTokenBuyer");
@@ -1194,7 +1195,7 @@ public class EbayOrderServices {
Map<?, ?> orderCreate = checkout.createOrder(userLogin);
if ("error".equals(orderCreate.get("responseMessage"))) {
- List errorMessageList =
(List)orderCreate.get("errorMessageList");
+ List<String> errorMessageList =
UtilGenerics.checkList(orderCreate.get("errorMessageList"), String.class);
return ServiceUtil.returnError(errorMessageList);
}
String orderId = (String) orderCreate.get("orderId");
Modified:
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java?rev=944720&r1=944719&r2=944720&view=diff
==============================================================================
---
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
(original)
+++
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
Sat May 15 21:11:02 2010
@@ -21,7 +21,6 @@ package org.ofbiz.ebay;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -713,8 +712,6 @@ public class ImportOrdersFromEbay {
// set partyId to
String partyId = null;
String contactMechId = "";
- String emailContactMechId = null;
- String phoneContactMechId = null;
GenericValue partyAttribute = null;
if (UtilValidate.isNotEmpty(parameters.get("eiasTokenBuyer")))
{
partyAttribute =
EntityUtil.getFirst(delegator.findByAnd("PartyAttribute",
UtilMisc.toMap("attrValue", (String)parameters.get("eiasTokenBuyer"))));
@@ -729,9 +726,9 @@ public class ImportOrdersFromEbay {
contactMechId =
EbayHelper.setShippingAddressContactMech(dispatcher, delegator, party,
userLogin, parameters);
String emailBuyer = (String) parameters.get("emailBuyer");
if (!(emailBuyer.equals("") ||
emailBuyer.equalsIgnoreCase("Invalid Request"))) {
- String emailContactMech =
EbayHelper.setEmailContactMech(dispatcher, delegator, party, userLogin,
parameters);
+ EbayHelper.setEmailContactMech(dispatcher, delegator,
party, userLogin, parameters);
}
- String phoneContactMech =
EbayHelper.setPhoneContactMech(dispatcher, delegator, party, userLogin,
parameters);
+ EbayHelper.setPhoneContactMech(dispatcher, delegator,
party, userLogin, parameters);
}
// create party if none exists already
@@ -782,7 +779,7 @@ public class ImportOrdersFromEbay {
Debug.logInfo("Creating CheckOutHelper.", module);
CheckOutHelper checkout = new CheckOutHelper(dispatcher,
delegator, cart);
Debug.logInfo("Creating order.", module);
- Map orderCreate = checkout.createOrder(userLogin);
+ Map<String, Object> orderCreate =
checkout.createOrder(userLogin);
String orderId = (String)orderCreate.get("orderId");
Debug.logInfo("Created order with id: " + orderId, module);
Modified:
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java?rev=944720&r1=944719&r2=944720&view=diff
==============================================================================
---
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
(original)
+++
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
Sat May 15 21:11:02 2010
@@ -25,30 +25,26 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javolution.util.FastList;
import javolution.util.FastMap;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.entity.Delegator;
-import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ModelService;
import org.ofbiz.service.ServiceUtil;
import org.ofbiz.product.product.ProductContentWrapper;
@@ -65,20 +61,18 @@ public class ProductsExportToEbay {
private static List<String> productExportFailureMessageList =
FastList.newInstance();
- public static Map exportToEbay(DispatchContext dctx, Map context) {
+ public static Map<String, Object> exportToEbay(DispatchContext dctx,
Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
productExportSuccessMessageList.clear();
productExportFailureMessageList.clear();
Map<String, Object> result = FastMap.newInstance();
- Map response = null;
+ Map<String, Object> response = null;
try {
- List selectResult = (List)context.get("selectResult");
- List productsList = delegator.findList("Product",
EntityCondition.makeCondition("productId", EntityOperator.IN, selectResult),
null, null, null, false);
+ List<String> selectResult =
UtilGenerics.checkList(context.get("selectResult"), String.class);
+ List<GenericValue> productsList = delegator.findList("Product",
EntityCondition.makeCondition("productId", EntityOperator.IN, selectResult),
null, null, null, false);
if (UtilValidate.isNotEmpty(productsList)) {
- Iterator productsListIter = productsList.iterator();
- while (productsListIter.hasNext()) {
- GenericValue product = (GenericValue)
productsListIter.next();
+ for (GenericValue product : productsList) {
GenericValue startPriceValue =
EntityUtil.getFirst(EntityUtil.filterByDate(product.getRelatedByAnd("ProductPrice",
UtilMisc.toMap("productPricePurposeId", "EBAY", "productPriceTypeId",
"MINIMUM_PRICE"))));
if (UtilValidate.isEmpty(startPriceValue)) {
String startPriceMissingMsg = "Unable to find a
starting price for auction of product with id (" +
product.getString("productId") + "), So Ignoring the export of this product to
eBay.";
@@ -88,7 +82,7 @@ public class ProductsExportToEbay {
}
Map<String, Object> eBayConfigResult =
EbayHelper.buildEbayConfig(context, delegator);
StringBuffer dataItemsXml = new StringBuffer();
- Map resultMap = buildDataItemsXml(dctx, context,
dataItemsXml, eBayConfigResult.get("token").toString(), product);
+ Map<String, Object> resultMap = buildDataItemsXml(dctx,
context, dataItemsXml, eBayConfigResult.get("token").toString(), product);
if (!ServiceUtil.isFailure(resultMap)) {
response =
postItem(eBayConfigResult.get("xmlGatewayUri").toString(), dataItemsXml,
eBayConfigResult.get("devID").toString(),
eBayConfigResult.get("appID").toString(),
eBayConfigResult.get("certID").toString(), "AddItem",
eBayConfigResult.get("compatibilityLevel").toString(),
eBayConfigResult.get("siteID").toString());
if (ServiceUtil.isFailure(response)) {
@@ -134,7 +128,7 @@ public class ProductsExportToEbay {
return outputBuilder.toString();
}
- private static Map postItem(String postItemsUrl, StringBuffer dataItems,
String devID, String appID, String certID,
+ private static Map<String, Object> postItem(String postItemsUrl,
StringBuffer dataItems, String devID, String appID, String certID,
String callName, String compatibilityLevel,
String siteID) throws IOException {
if (Debug.verboseOn()) {
Debug.logVerbose("Request of " + callName + " To eBay:\n" +
dataItems.toString(), module);
@@ -156,7 +150,7 @@ public class ProductsExportToEbay {
outputStream.close();
int responseCode = connection.getResponseCode();
InputStream inputStream;
- Map result = FastMap.newInstance();
+ Map<String, Object> result = FastMap.newInstance();
String response = null;
if (responseCode == HttpURLConnection.HTTP_CREATED ||
@@ -177,12 +171,11 @@ public class ProductsExportToEbay {
return result;
}
- public static Map buildDataItemsXml(DispatchContext dctx, Map context,
StringBuffer dataItemsXml, String token, GenericValue prod) {
+ public static Map<String, Object> buildDataItemsXml(DispatchContext dctx,
Map<String, Object> context, StringBuffer dataItemsXml, String token,
GenericValue prod) {
Locale locale = (Locale)context.get("locale");
try {
Delegator delegator = dctx.getDelegator();
String webSiteUrl = (String)context.get("webSiteUrl");
- List selectResult = (List)context.get("selectResult");
StringUtil.SimpleEncoder encoder = StringUtil.getEncoder("xml");
@@ -328,7 +321,7 @@ public class ProductsExportToEbay {
return ServiceUtil.returnSuccess();
}
- private static Map buildCategoriesXml(Map context, StringBuffer
dataItemsXml, String token, String siteID, String categoryParent, String
levelLimit) {
+ private static Map<String, Object> buildCategoriesXml(Map<String, Object>
context, StringBuffer dataItemsXml, String token, String siteID, String
categoryParent, String levelLimit) {
Locale locale = (Locale)context.get("locale");
try {
Document itemRequest =
UtilXml.makeEmptyXmlDocument("GetCategoriesRequest");
@@ -359,7 +352,8 @@ public class ProductsExportToEbay {
return ServiceUtil.returnSuccess();
}
- private static Map buildSetTaxTableRequestXml(DispatchContext dctx, Map
context, StringBuffer setTaxTableRequestXml, String token) {
+ /*
+ private static Map<String, Object>
buildSetTaxTableRequestXml(DispatchContext dctx, Map<String, Object> context,
StringBuffer setTaxTableRequestXml, String token) {
Locale locale = (Locale)context.get("locale");
try {
Document taxRequestDocument =
UtilXml.makeEmptyXmlDocument("SetTaxTableRequest");
@@ -382,8 +376,10 @@ public class ProductsExportToEbay {
}
return ServiceUtil.returnSuccess();
}
+ */
- private static Map buildAddTransactionConfirmationItemRequest(Map context,
StringBuffer dataItemsXml, String token, String itemId) {
+ /*
+ private static Map<String, Object>
buildAddTransactionConfirmationItemRequest(Map<String, Object> context,
StringBuffer dataItemsXml, String token, String itemId) {
Locale locale = (Locale)context.get("locale");
try {
Document transDoc =
UtilXml.makeEmptyXmlDocument("AddTransactionConfirmationItemRequest");
@@ -407,8 +403,9 @@ public class ProductsExportToEbay {
}
return ServiceUtil.returnSuccess();
}
+ */
- private static void setPaymentMethodAccepted(Document itemDocument,
Element itemElem, Map context) {
+ private static void setPaymentMethodAccepted(Document itemDocument,
Element itemElem, Map<String, Object> context) {
String payPal = (String)context.get("paymentPayPal");
String payPalEmail = (String)context.get("payPalEmail");
String visaMC = (String)context.get("paymentVisaMC");
@@ -477,7 +474,7 @@ public class ProductsExportToEbay {
}
}
- private static void setMiscDetails(Document itemDocument, Element
itemElem, Map context, Delegator delegator) throws Exception {
+ private static void setMiscDetails(Document itemDocument, Element
itemElem, Map<String, Object> context, Delegator delegator) throws Exception {
String customXmlFromUI = (String) context.get("customXml");
String customXml = "";
if (UtilValidate.isNotEmpty(customXmlFromUI)) {
@@ -489,8 +486,7 @@ public class ProductsExportToEbay {
Document customXmlDoc = UtilXml.readXmlDocument(customXml);
if (UtilValidate.isNotEmpty(customXmlDoc)) {
Element customXmlElement = customXmlDoc.getDocumentElement();
- List<? extends Element> eBayElements =
UtilXml.childElementList(customXmlElement);
- for (Element eBayElement: eBayElements) {
+ for (Element eBayElement:
UtilXml.childElementList(customXmlElement)) {
Node importedElement =
itemElem.getOwnerDocument().importNode(eBayElement, true);
itemElem.appendChild(importedElement);
}
@@ -498,11 +494,11 @@ public class ProductsExportToEbay {
}
}
- public static Map getEbayCategories(DispatchContext dctx, Map context) {
+ public static Map<String, Object> getEbayCategories(DispatchContext dctx,
Map<String, Object> context) {
Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
String categoryCode = (String)context.get("categoryCode");
- Map result = null;
+ Map<String, Object> result = null;
try {
Map<String, Object> eBayConfigResult =
EbayHelper.buildEbayConfig(context, delegator);
@@ -523,7 +519,7 @@ public class ProductsExportToEbay {
StringBuffer dataItemsXml = new StringBuffer();
if (!ServiceUtil.isFailure(buildCategoriesXml(context,
dataItemsXml, eBayConfigResult.get("token").toString(),
eBayConfigResult.get("siteID").toString(), categoryParent, levelLimit))) {
- Map resultCat =
postItem(eBayConfigResult.get("xmlGatewayUri").toString(), dataItemsXml,
eBayConfigResult.get("devID").toString(),
eBayConfigResult.get("appID").toString(),
eBayConfigResult.get("certID").toString(), "GetCategories",
eBayConfigResult.get("compatibilityLevel").toString(),
eBayConfigResult.get("siteID").toString());
+ Map<String, Object> resultCat =
postItem(eBayConfigResult.get("xmlGatewayUri").toString(), dataItemsXml,
eBayConfigResult.get("devID").toString(),
eBayConfigResult.get("appID").toString(),
eBayConfigResult.get("certID").toString(), "GetCategories",
eBayConfigResult.get("compatibilityLevel").toString(),
eBayConfigResult.get("siteID").toString());
String successMessage =
(String)resultCat.get("successMessage");
if (successMessage != null) {
result = readEbayCategoriesResponse(successMessage,
locale);
@@ -538,35 +534,25 @@ public class ProductsExportToEbay {
return result;
}
- private static Map readEbayCategoriesResponse(String msg, Locale locale) {
- Map results = null;
- List categories = FastList.newInstance();
+ private static Map<String, Object> readEbayCategoriesResponse(String msg,
Locale locale) {
+ Map<String, Object> results = null;
+ List<Map<String, Object>> categories = FastList.newInstance();
try {
Document docResponse = UtilXml.readXmlDocument(msg, true);
Element elemResponse = docResponse.getDocumentElement();
String ack = UtilXml.childElementValue(elemResponse, "Ack",
"Failure");
if (ack != null && "Failure".equals(ack)) {
String errorMessage = "";
- List errorList = UtilXml.childElementList(elemResponse,
"Errors");
- Iterator errorElemIter = errorList.iterator();
- while (errorElemIter.hasNext()) {
- Element errorElement = (Element) errorElemIter.next();
+ for (Element errorElement :
UtilXml.childElementList(elemResponse, "Errors")) {
errorMessage = UtilXml.childElementValue(errorElement,
"ShortMessage", "");
}
return ServiceUtil.returnFailure(errorMessage);
} else {
// retrieve Category Array
- List categoryArray = UtilXml.childElementList(elemResponse,
"CategoryArray");
- Iterator categoryArrayElemIter = categoryArray.iterator();
- while (categoryArrayElemIter.hasNext()) {
- Element categoryArrayElement =
(Element)categoryArrayElemIter.next();
-
+ for (Element categoryArrayElement :
UtilXml.childElementList(elemResponse, "CategoryArray")) {
// retrieve Category
- List category =
UtilXml.childElementList(categoryArrayElement, "Category");
- Iterator categoryElemIter = category.iterator();
- while (categoryElemIter.hasNext()) {
- Map categ = FastMap.newInstance();
- Element categoryElement =
(Element)categoryElemIter.next();
+ for (Element categoryElement :
UtilXml.childElementList(categoryArrayElement, "Category")) {
+ Map<String, Object> categ = FastMap.newInstance();
String categoryCode =
("true".equalsIgnoreCase((UtilXml.childElementValue(categoryElement,
"LeafCategory", "").trim())) ? "Y" : "N") + "_" +
UtilXml.childElementValue(categoryElement, "CategoryID", "").trim() + "_" +
@@ -576,8 +562,8 @@ public class ProductsExportToEbay {
categories.add(categ);
}
}
- categories = UtilMisc.sortMaps(categories,
UtilMisc.toList("CategoryName"));
- results = UtilMisc.toMap("categories", categories);
+ categories =
UtilGenerics.cast(UtilMisc.sortMaps(UtilGenerics.<List<Map<Object,
Object>>>cast(categories), UtilMisc.toList("CategoryName")));
+ results = UtilMisc.toMap("categories", (Object) categories);
}
} catch (Exception e) {
return ServiceUtil.returnFailure();
@@ -585,18 +571,15 @@ public class ProductsExportToEbay {
return results;
}
- public static Map exportToEbayResponse(String msg, GenericValue product) {
- Map result = ServiceUtil.returnSuccess();
+ public static Map<String, Object> exportToEbayResponse(String msg,
GenericValue product) {
+ Map<String, Object> result = ServiceUtil.returnSuccess();
try {
Document docResponse = UtilXml.readXmlDocument(msg, true);
Element elemResponse = docResponse.getDocumentElement();
String ack = UtilXml.childElementValue(elemResponse, "Ack",
"Failure");
if (ack != null && "Failure".equals(ack)) {
String errorMessage = "";
- List errorList = UtilXml.childElementList(elemResponse,
"Errors");
- Iterator errorElemIter = errorList.iterator();
- while (errorElemIter.hasNext()) {
- Element errorElement = (Element) errorElemIter.next();
+ for (Element errorElement :
UtilXml.childElementList(elemResponse, "Errors")) {
errorMessage = UtilXml.childElementValue(errorElement,
"LongMessage");
}
productExportFailureMessageList.add(errorMessage);