svn commit: r560136 - in /ofbiz/trunk/applications: order/config/ order/src/org/ofbiz/order/order/ order/webapp/ordermgr/order/ product/config/ product/servicedef/ product/src/org/ofbiz/product/product/ product/webapp/catalog/find/

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

svn commit: r560136 - in /ofbiz/trunk/applications: order/config/ order/src/org/ofbiz/order/order/ order/webapp/ordermgr/order/ product/config/ product/servicedef/ product/src/org/ofbiz/product/product/ product/webapp/catalog/find/

jacopoc
Author: jacopoc
Date: Fri Jul 27 01:00:56 2007
New Revision: 560136

URL: http://svn.apache.org/viewvc?view=rev&rev=560136
Log:
Applied patch by Marco Risaliti with some enhancements for the eBay integration, especially the OFBiz->eBay feed.

Modified:
    ofbiz/trunk/applications/order/config/OrderUiLabels.properties
    ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java
    ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml
    ofbiz/trunk/applications/product/config/ProductUiLabels.properties
    ofbiz/trunk/applications/product/config/ProductUiLabels_it.properties
    ofbiz/trunk/applications/product/servicedef/services.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java
    ofbiz/trunk/applications/product/webapp/catalog/find/ExportForms.xml

Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.properties?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderUiLabels.properties (original)
+++ ofbiz/trunk/applications/order/config/OrderUiLabels.properties Fri Jul 27 01:00:56 2007
@@ -378,6 +378,7 @@
 FormFieldTitle_sendTo=Send To
 FormFieldTitle_shipAfterDate=Ship After Date
 FormFieldTitle_shipByDate=Ship By Date
+FormFieldTitle_shippingService=Shipping Service
 FormFieldTitle_shippingServiceCost=Shipping Service Cost
 FormFieldTitle_shippedTime=Date/Time Shipment
 FormFieldTitle_shippingTotalAdditionalCost=Shipping Additional Costs

Modified: ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties (original)
+++ ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties Fri Jul 27 01:00:56 2007
@@ -984,6 +984,7 @@
 FormFieldTitle_shippedTime=Date/Ora Spedizione
 FormFieldTitle_errorMessage=Messaggio di Errore
 FormFieldTitle_paymentMethodUsed=Metodo Pagamento Scelto
+FormFieldTitle_shippingService=Metodo Spedizione Scelto
 FormFieldTitle_listingStatus=Stato dell'Asta
 FormFieldTitle_eBayPaymentStatus=Stato Pagamento su eBay
 FormFieldTitle_checkoutStatus=Stato Completamento Asta

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java Fri Jul 27 01:00:56 2007
@@ -49,7 +49,6 @@
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.order.shoppingcart.CheckOutHelper;
 import org.ofbiz.order.shoppingcart.ShoppingCart;
-import org.ofbiz.party.contact.ContactMechWorker;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -129,6 +128,7 @@
             order.put("productId", (String) context.get("productId"));
             order.put("quantityPurchased", (String) context.get("quantityPurchased"));
             order.put("transactionPrice", (String) context.get("transactionPrice"));
+            order.put("shippingService", (String) context.get("shippingService"));
             order.put("shippingServiceCost", (String) context.get("shippingServiceCost"));
             order.put("shippingTotalAdditionalCost", (String) context.get("shippingTotalAdditionalCost"));
             order.put("amountPaid", (String) context.get("amountPaid"));
@@ -241,8 +241,11 @@
     
     private static Map 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);
+        }
+        
         HttpURLConnection connection = (HttpURLConnection)(new URL(postItemsUrl)).openConnection();
-      
         connection.setDoInput(true);
         connection.setDoOutput(true);
         connection.setRequestMethod("POST");
@@ -261,15 +264,22 @@
         int responseCode = connection.getResponseCode();
         InputStream inputStream = null;
         Map result = FastMap.newInstance();
+        String response = null;
+        
         if (responseCode == HttpURLConnection.HTTP_CREATED ||
             responseCode == HttpURLConnection.HTTP_OK) {
             inputStream = connection.getInputStream();
-            String response = toString(inputStream);
+            response = toString(inputStream);
             result = ServiceUtil.returnSuccess(response);
         } else {
             inputStream = connection.getErrorStream();
             result = ServiceUtil.returnFailure(toString(inputStream));
         }
+        
+        if (Debug.verboseOn()) {
+            Debug.logVerbose("Response of " + callName + " From eBay:\n" + response, module);
+        }
+        
         return result;
     }
     
@@ -831,12 +841,11 @@
                 cart.setShipToCustomerPartyId(partyId);
                 cart.setEndUserCustomerPartyId(partyId);
                 
-                cart.setCarrierPartyId("_NA_");
                 cart.setShippingContactMechId(contactMechId);
-                
-                //TODO handle shipment method type
-                cart.setShipmentMethodTypeId("NO_SHIPPING");
                 cart.setMaySplit(Boolean.FALSE);
+                
+                setShipmentMethodType(cart, (String) parameters.get("shippingService"));
+                
                 cart.makeAllShipGroupInfos();
 
                 // create the order
@@ -1141,4 +1150,49 @@
         }
         return dateOut;
     }
+    
+    private static void setShipmentMethodType(ShoppingCart cart, String shippingService) {
+        String partyId = "_NA_";
+        String shipmentMethodTypeId = "NO_SHIPPING";
+        
+        if (shippingService != null) {
+            if ("USPSPriority".equals(shippingService)) {
+                partyId = "USPS";
+                shipmentMethodTypeId = "PRIORITY";
+            } else if ("UPSGround".equals(shippingService)) {
+                partyId = "UPS";
+                shipmentMethodTypeId = "GROUND";
+            } else if ("UPS3rdDay".equals(shippingService)) {
+                partyId = "UPS";
+                shipmentMethodTypeId = "3DAY";
+            } else if ("UPS2ndDay".equals(shippingService)) {
+                partyId = "UPS";
+                shipmentMethodTypeId = "2DAY";
+            } else if ("UPS2ndDay".equals(shippingService)) {
+                partyId = "UPS";
+                shipmentMethodTypeId = "2DAY";
+            } else if ("USPSExpressMailInternational".equals(shippingService)) {
+                partyId = "USPS";
+                shipmentMethodTypeId = "INT_EXPRESS";
+            } else if ("UPSNextDay".equals(shippingService)) {
+                partyId = "UPS";
+                shipmentMethodTypeId = "1DAY_SAVER";
+            } else if ("UPSNextDayAir".equals(shippingService)) {
+                partyId = "UPS";
+                shipmentMethodTypeId = "1DAY";
+            } else if ("ShippingMethodStandard".equals(shippingService)) {
+                partyId = "UPS";
+                shipmentMethodTypeId = "GROUND";
+            } else if ("StandardInternational".equals(shippingService)) {
+                partyId = "USPS";
+                shipmentMethodTypeId = "INT_EXPRESS";
+            } else if ("LocalDelivery".equals(shippingService)) {
+                partyId = "_NA_";
+                shipmentMethodTypeId = "PICK_UP";
+            }
+        }        
+        
+        cart.setCarrierPartyId(partyId);
+        cart.setShipmentMethodTypeId(shipmentMethodTypeId);    
+    }    
 }

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml Fri Jul 27 01:00:56 2007
@@ -150,6 +150,7 @@
         <field name="paidTime"><display/></field>
         <field name="shippedTime"><display/></field>
         <field name="paymentMethodUsed"><display/></field>
+        <field name="shippingService"><display/></field>
         <field name="listingStatus"><display/></field>
         <field name="eBayPaymentStatus"><display/></field>
         <field name="checkoutStatus"><display/></field>

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Fri Jul 27 01:00:56 2007
@@ -1880,3 +1880,21 @@
 FormFieldTitle_webSiteUrl=Web Site Url
 FormFieldTitle_trackingCodeId=Tracking Code Id
 FormFieldTitle_actionType=Action Type
+FormFieldTitle_geoCode=Country
+FormFieldTitle_location=Location
+FormFieldTitle_ebayCategory=eBay Category
+FormFieldTitle_paymentMethodsAccepted=Payment Methods Accepted
+FormFieldTitle_paymentPayPal=PayPal
+FormFieldTitle_paymentVisaMC=Visa/Mastercard
+FormFieldTitle_paymentAmEx=American Express
+FormFieldTitle_paymentDiscover=Discover card
+FormFieldTitle_paymentCCAccepted=Credit card
+FormFieldTitle_paymentCashInPerson=Cash-in-person
+FormFieldTitle_paymentCashOnPickup=Payment on delivery
+FormFieldTitle_paymentCOD=Cash on delivery
+FormFieldTitle_paymentCODPrePayDelivery=Cash On Delivery After Paid
+FormFieldTitle_paymentMOCC=Money order/cashiers check
+FormFieldTitle_paymentMoneyXferAccepted=Direct transfer of money
+FormFieldTitle_paymentPersonalCheck=Personal check
+FormFieldTitle_listingDuration=Listing Duration
+FormFieldTitle_startPrice=Start Price
\ No newline at end of file

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels_it.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels_it.properties?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels_it.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels_it.properties Fri Jul 27 01:00:56 2007
@@ -1863,3 +1863,21 @@
 FormFieldTitle_webSiteUrl=Url Sito Web
 FormFieldTitle_trackingCodeId=Codice Tracciatura
 FormFieldTitle_actionType=Tipo Azione
+FormFieldTitle_geoCode=Paese
+FormFieldTitle_location=Localit\u00e0
+FormFieldTitle_ebayCategory=Categoria eBay
+FormFieldTitle_paymentMethodsAccepted=Metodi di Pagamento Accettati
+FormFieldTitle_paymentPayPal=PayPal
+FormFieldTitle_paymentVisaMC=Visa/Mastercard
+FormFieldTitle_paymentAmEx=American Express
+FormFieldTitle_paymentDiscover=Discover
+FormFieldTitle_paymentCCAccepted=Carta di Credito
+FormFieldTitle_paymentCashInPerson=Contanti di Persona
+FormFieldTitle_paymentCashOnPickup=Pagamento alla Consegna
+FormFieldTitle_paymentCOD=Contanti alla consegna
+FormFieldTitle_paymentCODPrePayDelivery=Contanti alla Consegna Dopo Aver Pagato
+FormFieldTitle_paymentMOCC=Ordini di Soldi/Assegni al cassiere
+FormFieldTitle_paymentMoneyXferAccepted=Trasferimento Diretto di Soldi
+FormFieldTitle_paymentPersonalCheck=Assegno Personale
+FormFieldTitle_listingDuration=Durata Asta
+FormFieldTitle_startPrice=Prezzo di Partenza
\ No newline at end of file

Modified: ofbiz/trunk/applications/product/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services.xml?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services.xml Fri Jul 27 01:00:56 2007
@@ -1130,8 +1130,24 @@
              location="org.ofbiz.product.product.ProductsExportToEbay" invoke="exportToEbay" auth="true">
         <description>Export products to eBay</description>
         <attribute type="List" mode="IN" name="selectResult" optional="false"/>
-        <attribute type="String" mode="IN" name="webSiteUrl" optional="false"/>
-        <attribute type="String" mode="IN" name="imageUrl" optional="false"/>
-        <attribute type="String" mode="IN" name="trackingCodeId" optional="true"/>
+        <attribute type="String" mode="IN" name="country" optional="false"/>
+        <attribute type="String" mode="IN" name="location" optional="false"/>
+        <attribute type="String" mode="IN" name="ebayCategory" optional="false"/>
+        <attribute type="String" mode="IN" name="paymentPayPal" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentVisaMC" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentAmEx" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentDiscover" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentCCAccepted" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentCashInPerson" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentCashOnPickup" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentCOD" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentCODPrePayDelivery" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentMOCC" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentMoneyXferAccepted" optional="true"/>
+        <attribute type="String" mode="IN" name="paymentPersonalCheck" optional="true"/>
+        <attribute type="String" mode="IN" name="payPalEmail" optional="true"/>
+        <attribute type="String" mode="IN" name="listingDuration" optional="false"/>
+        <attribute type="String" mode="IN" name="startPrice" optional="false"/>
+        <attribute type="String" mode="IN" name="quantity" optional="false"/>
     </service>
 </services>

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java Fri Jul 27 01:00:56 2007
@@ -19,27 +19,20 @@
 package org.ofbiz.product.product;
 
 import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
-import java.sql.Timestamp;
 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.FastMap;
-
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
 import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
@@ -48,7 +41,6 @@
 import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -57,8 +49,7 @@
     
     private static final String resource = "ProductUiLabels";
     private static final String module = ProductsExportToEbay.class.getName();
-    private static final String xmlHeader = "<?xml version=\'1.0\' encoding='UTF-8'?>\n";
-
+    
     public static Map exportToEbay(DispatchContext dctx, Map context) {
         Locale locale = (Locale) context.get("locale");
         try {
@@ -76,30 +67,27 @@
             // get the Token
             String token = UtilProperties.getPropertyValue(configString, "productsExport.eBay.token");
             
-            // get the Rest Token
-            String restToken = UtilProperties.getPropertyValue(configString, "productsExport.eBay.restToken");
+            // get the Compatibility Level
+            String compatibilityLevel = UtilProperties.getPropertyValue(configString, "productsExport.eBay.compatibilityLevel");
+            
+            // get the Site ID
+            String siteID = UtilProperties.getPropertyValue(configString, "productsExport.eBay.siteID");
             
             // get the xmlGatewayUri
             String xmlGatewayUri = UtilProperties.getPropertyValue(configString, "productsExport.eBay.xmlGatewayUri");
-            
+            
             StringBuffer dataItemsXml = new StringBuffer();
             
-            if (!ServiceUtil.isFailure(buildSellerTransactionsXml(context, dataItemsXml, token))) {
-                Map result = postItem(xmlGatewayUri, dataItemsXml, devID, appID, certID, "GetSellerTransactions");
+            /*
+            String itemId = "";
+            if (!ServiceUtil.isFailure(buildAddTransactionConfirmationItemRequest(context, dataItemsXml, token,  itemId))) {
+                Map result = postItem(xmlGatewayUri, dataItemsXml, devID, appID, certID, "AddTransactionConfirmationItem");
                 Debug.logInfo(result.toString(), module);
-                /*
-                if (ServiceUtil.isFailure(result)) {
-                        return ServiceUtil.returnFailure(ServiceUtil.getErrorMessage(result));
-                } else {
-                    Debug.logError("Error during authentication to eBay Account", module);
-                    return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToeBay.errorDuringAuthenticationToeBay", locale));
-                }
-                */  
             }
+            */
             
-            dataItemsXml.replace(0, dataItemsXml.length(), "");
             if (!ServiceUtil.isFailure(buildDataItemsXml(dctx, context, dataItemsXml, token))) {
-                Map result = postItem(xmlGatewayUri, dataItemsXml, devID, appID, certID, "AddItem");
+                Map result = postItem(xmlGatewayUri, dataItemsXml, devID, appID, certID, "AddItem", compatibilityLevel, siteID);
                 if (ServiceUtil.isFailure(result)) {
                         return ServiceUtil.returnFailure(ServiceUtil.getErrorMessage(result));
                 } else {
@@ -114,6 +102,11 @@
         return ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "productsExportToEbay.productItemsSentCorrecltyToEbay", locale));
     }
   
+    private static void appendRequesterCredentials(Element elem, Document doc, String token) {
+        Element requesterCredentialsElem = UtilXml.addChildElement(elem, "RequesterCredentials", doc);
+        UtilXml.addChildElementValue(requesterCredentialsElem, "eBayAuthToken", token, doc);
+    }
+    
     private static String toString(InputStream inputStream) throws IOException {
         String string;
         StringBuilder outputBuilder = new StringBuilder();
@@ -126,18 +119,22 @@
         return outputBuilder.toString();
     }
     
-    private static Map postItem(String postItemsUrl, StringBuffer dataItems, String devID, String appID, String certID, String callName) throws IOException {
+    private static Map 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);
+        }
+        
         HttpURLConnection connection = (HttpURLConnection)(new URL(postItemsUrl)).openConnection();
-      
         connection.setDoInput(true);
         connection.setDoOutput(true);
         connection.setRequestMethod("POST");
-        connection.setRequestProperty("X-EBAY-API-COMPATIBILITY-LEVEL", "517");
+        connection.setRequestProperty("X-EBAY-API-COMPATIBILITY-LEVEL", compatibilityLevel);
         connection.setRequestProperty("X-EBAY-API-DEV-NAME", devID);
         connection.setRequestProperty("X-EBAY-API-APP-NAME", appID);
         connection.setRequestProperty("X-EBAY-API-CERT-NAME", certID);
         connection.setRequestProperty("X-EBAY-API-CALL-NAME", callName);
-        connection.setRequestProperty("X-EBAY-API-SITEID", "0");
+        connection.setRequestProperty("X-EBAY-API-SITEID", siteID);
         connection.setRequestProperty("Content-Type", "text/xml");
         
         OutputStream outputStream = connection.getOutputStream();
@@ -147,166 +144,190 @@
         int responseCode = connection.getResponseCode();
         InputStream inputStream;
         Map result = FastMap.newInstance();
-        if (responseCode == HttpURLConnection.HTTP_CREATED) {
-            inputStream = connection.getInputStream();
-            result = ServiceUtil.returnSuccess(toString(inputStream));
-            Debug.logInfo(toString(inputStream), module);
-        } else if (responseCode == HttpURLConnection.HTTP_OK) {
+        String response = null;
+        
+        if (responseCode == HttpURLConnection.HTTP_CREATED ||
+            responseCode == HttpURLConnection.HTTP_OK) {
             inputStream = connection.getInputStream();
-            result = ServiceUtil.returnFailure(toString(inputStream));
+            response = toString(inputStream);
+            result = ServiceUtil.returnSuccess(response);
         } else {
             inputStream = connection.getErrorStream();
-            result = ServiceUtil.returnFailure(toString(inputStream));
+            response = toString(inputStream);
+            result = ServiceUtil.returnFailure(response);
+        }
+        
+        if (Debug.verboseOn()) {
+            Debug.logVerbose("Response of " + callName + " From eBay:\n" + response, module);
         }
+        
         return result;
     }
     
     private static Map buildDataItemsXml(DispatchContext dctx, Map context, StringBuffer dataItemsXml, String token) {
         Locale locale = (Locale)context.get("locale");
         try {
-             GenericDelegator delegator = dctx.getDelegator();
-             LocalDispatcher dispatcher = dctx.getDispatcher();
-             List selectResult = (List)context.get("selectResult");
-             String webSiteUrl = (String)context.get("webSiteUrl");
-             String imageUrl = (String)context.get("imageUrl");
-             String trackingCodeId = (String)context.get("trackingCodeId");
-            
-             // Get the list of products to be exported to eBay
-             List productsList  = delegator.findByCondition("Product", new EntityExpr("productId", EntityOperator.IN, selectResult), null, null);
+            GenericDelegator delegator = dctx.getDelegator();
+            List selectResult = (List)context.get("selectResult");
             
-             // Get the tracking code
-             if (UtilValidate.isEmpty(trackingCodeId) || "_NA_".equals(trackingCodeId)) {
-                 trackingCodeId = "";
-             } else {
-                 trackingCodeId = "?atc=" + trackingCodeId;
-             }
+            // Get the list of products to be exported to eBay
+            List productsList  = delegator.findByCondition("Product", new EntityExpr("productId", EntityOperator.IN, selectResult), null, null);
             
-             try {
-                 Document itemDocument = UtilXml.makeEmptyXmlDocument("AddItemRequest");
-                 Element itemRequestElem = itemDocument.getDocumentElement();
-                 itemRequestElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents");
+            try {
+                Document itemDocument = UtilXml.makeEmptyXmlDocument("AddItemRequest");
+                Element itemRequestElem = itemDocument.getDocumentElement();
+                itemRequestElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents");
                 
-                 dataItemsXml.append(xmlHeader);
+                appendRequesterCredentials(itemRequestElem, itemDocument, token);
                 
-                 // Iterate the product list getting all the relevant data
-                 Iterator productsListItr = productsList.iterator();
-                 while(productsListItr.hasNext()) {
-                     GenericValue prod = (GenericValue)productsListItr.next();
-                     String link = webSiteUrl + "/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
-                     String title = parseText(prod.getString("productName"));
-                     String description = parseText(prod.getString("description"));
-                     String image_link = "";
-                     if (UtilValidate.isNotEmpty(prod.getString("largeImageUrl"))) {
-                         image_link = imageUrl + prod.getString("largeImageUrl");
-                     }
+                // Iterate the product list getting all the relevant data
+                Iterator productsListItr = productsList.iterator();
+                while(productsListItr.hasNext()) {
+                    GenericValue prod = (GenericValue)productsListItr.next();
+                    String title = parseText(prod.getString("productName"));
+                    String description = parseText(prod.getString("description"));
                     
-                     Element requesterCredentialsElem = UtilXml.addChildElement(itemRequestElem, "RequesterCredentials", itemDocument);
-                     UtilXml.addChildElementValue(requesterCredentialsElem, "eBayAuthToken", token, itemDocument);
+                    Element itemElem = UtilXml.addChildElement(itemRequestElem, "Item", itemDocument);
+                    UtilXml.addChildElementValue(itemElem, "Country", (String)context.get("country"), itemDocument);
+                    UtilXml.addChildElementValue(itemElem, "Location", (String)context.get("location"), itemDocument);
+                    UtilXml.addChildElementValue(itemElem, "Currency", "USD", itemDocument);
+                    UtilXml.addChildElementValue(itemElem, "SKU", prod.getString("productId"), itemDocument);
+                    UtilXml.addChildElementValue(itemElem, "Title", title, itemDocument);
+                    UtilXml.addChildElementValue(itemElem, "Description", description, itemDocument);
+                    UtilXml.addChildElementValue(itemElem, "ListingDuration", (String)context.get("listingDuration"), itemDocument);
+                    UtilXml.addChildElementValue(itemElem, "Quantity", (String)context.get("quantity"), itemDocument);
                     
-                     Element itemElem = UtilXml.addChildElement(itemRequestElem, "Item", itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "Country", "US", itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "Location", "New York", itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "Currency", "USD", itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "SKU", prod.getString("productId"), itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "Title", title, itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "Description", title, itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "ListingDuration", "Days_1", itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "Quantity", "3", itemDocument);
-                     UtilXml.addChildElementValue(itemElem, "PaymentMethods", "AmEx", itemDocument);
+                    setPaymentMethodAccepted(itemDocument, itemElem, context);
                     
-                     Element primaryCatElem = UtilXml.addChildElement(itemElem, "PrimaryCategory", itemDocument);
-                     UtilXml.addChildElementValue(primaryCatElem, "CategoryID", "20118", itemDocument);
+                    Element primaryCatElem = UtilXml.addChildElement(itemElem, "PrimaryCategory", itemDocument);
+                    UtilXml.addChildElementValue(primaryCatElem, "CategoryID", (String)context.get("ebayCategory"), itemDocument);
                     
-                     Element startPriceElem = UtilXml.addChildElementValue(itemElem, "StartPrice", "1.00", itemDocument);
-                     startPriceElem.setAttribute("currencyID", "USD");
-                 }
-                 OutputStream os = new ByteArrayOutputStream();
-                 OutputFormat format = new OutputFormat();
-                 format.setOmitDocumentType(true);
-                 format.setOmitXMLDeclaration(true);
-                 format.setIndenting(false);
-                 XMLSerializer serializer = new XMLSerializer(os, format);
-                 serializer.asDOMSerializer();
-                 serializer.serialize(itemDocument.getDocumentElement());
+                    Element startPriceElem = UtilXml.addChildElementValue(itemElem, "StartPrice", (String)context.get("startPrice"), itemDocument);
+                    startPriceElem.setAttribute("currencyID", "USD");
+                }
                 
-                 dataItemsXml.append(os.toString());
-             } catch (Exception e) {
-                 Debug.logError("Exception during building data items to eBay", module);
-                  return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.exceptionDuringBuildingDataItemsToEbay", locale));
-             }
-         } catch (Exception e) {
+                dataItemsXml.append(UtilXml.writeXmlDocument(itemDocument));
+            } catch (Exception e) {
+                Debug.logError("Exception during building data items to eBay", module);
+                return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.exceptionDuringBuildingDataItemsToEbay", locale));
+            }
+        } catch (Exception e) {
             Debug.logError("Exception during building data items to eBay", module);
             return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.exceptionDuringBuildingDataItemsToEbay", locale));
-         }
-         return ServiceUtil.returnSuccess();
+        }
+        return ServiceUtil.returnSuccess();
     }
     
     private static Map buildCategoriesXml(Map context, StringBuffer dataItemsXml, String token) {
         Locale locale = (Locale)context.get("locale");
         try {
-             Document itemRequest = UtilXml.makeEmptyXmlDocument("GetCategoriesRequest");
-             Element itemRequestElem = itemRequest.getDocumentElement();
-             itemRequestElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents");
-            
-             dataItemsXml.append(xmlHeader);
-             Element requesterCredentialsElem = UtilXml.addChildElement(itemRequestElem, "RequesterCredentials", itemRequest);
-             UtilXml.addChildElementValue(requesterCredentialsElem, "eBayAuthToken", token, itemRequest);
-            
-             UtilXml.addChildElementValue(itemRequestElem, "DetailLevel", "ReturnAll", itemRequest);
-             UtilXml.addChildElementValue(itemRequestElem, "CategorySiteID", "0", itemRequest);
-             UtilXml.addChildElementValue(itemRequestElem, "LevelLimit", "2", itemRequest);
-             UtilXml.addChildElementValue(itemRequestElem, "ViewAllNodes", "false", itemRequest);
-            
-             OutputStream os = new ByteArrayOutputStream();
-             OutputFormat format = new OutputFormat();
-             format.setOmitDocumentType(true);
-             format.setOmitXMLDeclaration(true);
-             format.setIndenting(false);
-             XMLSerializer serializer = new XMLSerializer(os, format);
-             serializer.asDOMSerializer();
-             serializer.serialize(itemRequest.getDocumentElement());
+            Document itemRequest = UtilXml.makeEmptyXmlDocument("GetCategoriesRequest");
+            Element itemRequestElem = itemRequest.getDocumentElement();
+            itemRequestElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents");
+            
+            appendRequesterCredentials(itemRequestElem, itemRequest, token);
+            
+            UtilXml.addChildElementValue(itemRequestElem, "DetailLevel", "ReturnAll", itemRequest);
+            UtilXml.addChildElementValue(itemRequestElem, "CategorySiteID", "0", itemRequest);
+            UtilXml.addChildElementValue(itemRequestElem, "LevelLimit", "2", itemRequest);
+            UtilXml.addChildElementValue(itemRequestElem, "ViewAllNodes", "false", itemRequest);
             
-             dataItemsXml.append(os.toString());
-         } catch (Exception e) {
-             Debug.logError("Exception during building data items to eBay", module);
-              return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.exceptionDuringBuildingDataItemsToEbay", locale));
-         }
-         return ServiceUtil.returnSuccess();
+            dataItemsXml.append(UtilXml.writeXmlDocument(itemRequest));
+        } catch (Exception e) {
+            Debug.logError("Exception during building data items to eBay", module);
+            return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.exceptionDuringBuildingDataItemsToEbay", locale));
+        }
+        return ServiceUtil.returnSuccess();
     }
     
-    private static Map buildSellerTransactionsXml(Map context, StringBuffer dataItemsXml, String token) {
+    private static Map buildAddTransactionConfirmationItemRequest(Map context, StringBuffer dataItemsXml, String token, String itemId) {
         Locale locale = (Locale)context.get("locale");
         try {
-             Document transDoc = UtilXml.makeEmptyXmlDocument("GetSellerTransactionsRequest");
-             Element transElem = transDoc.getDocumentElement();
-             transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents");
-            
-             dataItemsXml.append(xmlHeader);
-            
-             Element requesterCredentialsElem = UtilXml.addChildElement(transElem, "RequesterCredentials", transDoc);
-             UtilXml.addChildElementValue(requesterCredentialsElem, "eBayAuthToken", token, transDoc);
-             Timestamp end = new Timestamp(System.currentTimeMillis());
-             Timestamp start = UtilDateTime.getDayEnd(end, -1);
-            
-             UtilXml.addChildElementValue(transElem, "DetailLevel", "ReturnAll", transDoc);
-             UtilXml.addChildElementValue(transElem, "ModTimeFrom", start.toString(), transDoc);
-             UtilXml.addChildElementValue(transElem, "ModTimeTo", end.toString(), transDoc);
-            
-             OutputStream os = new ByteArrayOutputStream();
-             OutputFormat format = new OutputFormat();
-             format.setOmitDocumentType(true);
-             format.setOmitXMLDeclaration(true);
-             format.setIndenting(false);
-             XMLSerializer serializer = new XMLSerializer(os, format);
-             serializer.asDOMSerializer();
-             serializer.serialize(transDoc.getDocumentElement());
-            
-             dataItemsXml.append(os.toString());
-         } catch (Exception e) {
-             Debug.logError("Exception during building data items to eBay", module);
-              return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.exceptionDuringBuildingDataItemsToEbay", locale));
-         }
-         return ServiceUtil.returnSuccess();
+            Document transDoc = UtilXml.makeEmptyXmlDocument("AddTransactionConfirmationItemRequest");
+            Element transElem = transDoc.getDocumentElement();
+            transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents");
+            
+            appendRequesterCredentials(transElem, transDoc, token);
+            
+            UtilXml.addChildElementValue(transElem, "ItemID", itemId, transDoc);
+            UtilXml.addChildElementValue(transElem, "ListingDuration", "Days_1", transDoc);
+            Element negotiatePriceElem = UtilXml.addChildElementValue(transElem, "NegotiatedPrice", "50.00", transDoc);
+            negotiatePriceElem.setAttribute("currencyID", "USD");
+            UtilXml.addChildElementValue(transElem, "RecipientRelationType", "1", transDoc);
+            UtilXml.addChildElementValue(transElem, "RecipientUserID", "buyer_anytime", transDoc);
+            
+            dataItemsXml.append(UtilXml.writeXmlDocument(transDoc));
+            Debug.logInfo(dataItemsXml.toString(), module);
+        } catch (Exception e) {
+            Debug.logError("Exception during building AddTransactionConfirmationItemRequest eBay", module);
+            return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.exceptionDuringBuildingAddTransactionConfirmationItemRequestToEbay", locale));
+        }
+        return ServiceUtil.returnSuccess();
+    }
+    
+    private static void setPaymentMethodAccepted(Document itemDocument, Element itemElem, Map context) {
+        String payPal = (String)context.get("paymentPayPal");
+        String visaMC = (String)context.get("paymentVisaMC");
+        String amEx = (String)context.get("paymentAmEx");
+        String discover = (String)context.get("paymentDiscover");
+        String ccAccepted = (String)context.get("paymentCCAccepted");
+        String cashInPerson = (String)context.get("paymentCashInPerson");
+        String cashOnPickup = (String)context.get("paymentCashOnPickup");
+        String cod = (String)context.get("paymentCOD");
+        String codPrePayDelivery = (String)context.get("paymentCODPrePayDelivery");
+        String mocc = (String)context.get("paymentMOCC");
+        String moneyXferAccepted = (String)context.get("paymentMoneyXferAccepted");
+        String personalCheck = (String)context.get("paymentPersonalCheck");
+        
+        // PayPal
+        if (UtilValidate.isNotEmpty(payPal) && "Y".equals(payPal)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "PayPal", itemDocument);
+            UtilXml.addChildElementValue(itemElem, "PayPalEmailAddress", (String)context.get("payPalEmail"), itemDocument);
+        }
+        // Visa/Master Card
+        if (UtilValidate.isNotEmpty(visaMC) && "Y".equals(visaMC)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "VisaMC", itemDocument);
+        }
+        // American Express
+        if (UtilValidate.isNotEmpty(amEx) && "Y".equals(amEx)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "AmEx", itemDocument);
+        }
+        // Discover
+        if (UtilValidate.isNotEmpty(discover) && "Y".equals(discover)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "Discover", itemDocument);
+        }
+        // Credit Card Accepted
+        if (UtilValidate.isNotEmpty(ccAccepted) && "Y".equals(ccAccepted)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "CCAccepted", itemDocument);
+        }
+        // Cash In Person
+        if (UtilValidate.isNotEmpty(cashInPerson) && "Y".equals(cashInPerson)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "CashInPerson", itemDocument);
+        }
+        // Cash on Pickup
+        if (UtilValidate.isNotEmpty(cashOnPickup) && "Y".equals(cashOnPickup)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "CashOnPickup", itemDocument);
+        }
+        // Cash on Delivery
+        if (UtilValidate.isNotEmpty(cod) && "Y".equals(cod)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "COD", itemDocument);
+        }
+        // Cash On Delivery After Paid
+        if (UtilValidate.isNotEmpty(codPrePayDelivery) && "Y".equals(codPrePayDelivery)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "CODPrePayDelivery", itemDocument);
+        }
+        // Money order/cashiers check
+        if (UtilValidate.isNotEmpty(mocc) && "Y".equals(mocc)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "MOCC", itemDocument);
+        }
+        // Direct transfer of money
+        if (UtilValidate.isNotEmpty(moneyXferAccepted) && "Y".equals(moneyXferAccepted)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "MoneyXferAccepted", itemDocument);
+        }
+        // Personal Check
+        if (UtilValidate.isNotEmpty(personalCheck) && "Y".equals(personalCheck)) {
+            UtilXml.addChildElementValue(itemElem, "PaymentMethods", "PersonalCheck", itemDocument);
+        }
     }
     
     private static String parseText(String text) {

Modified: ofbiz/trunk/applications/product/webapp/catalog/find/ExportForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/find/ExportForms.xml?view=diff&rev=560136&r1=560135&r2=560136
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/find/ExportForms.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/find/ExportForms.xml Fri Jul 27 01:00:56 2007
@@ -54,16 +54,42 @@
     </form>
     <form name="ProductsExportToEbay" type="single" target="PostProductsToEbay">
         <field name="selectResult"><hidden/></field>
-        <field name="webSiteUrl"><text size="50" maxlength="250"/></field>
-        <field name="imageUrl"><text size="50" maxlength="250"/></field>
-        <field name="trackingCodeId" widget-style="selectBox">
-            <drop-down no-current-selected-key="_NA_">
-                <option key="_NA_" description="${uiLabelMap.ProductExportNoTrackingRequested}"/>
-                <entity-options entity-name="TrackingCode" description="${description}">
-                    <entity-order-by field-name="description"/>
+        <field name="country" widget-style="selectBox">
+            <drop-down no-current-selected-key="US">
+                <entity-options key-field-name="geoCode" entity-name="Geo" description="${geoName}">
+                    <entity-order-by field-name="geoName"/>
                 </entity-options>
             </drop-down>
         </field>
+        <field name="location"><text size="50" maxlength="50"/></field>
+        <field name="ebayCategory" widget-style="selectBox">
+            <drop-down>
+                <option key="20118" description="Test category (not yet implemented)"/>
+            </drop-down>
+        </field>
+        <field name="listingDuration" widget-style="selectBox">
+            <drop-down>
+                <option key="Days_1" description="1 ${uiLabelMap.CommonDay}"/>
+                <option key="Days_3" description="3 ${uiLabelMap.CommonDays}"/>
+                <option key="Days_7" description="7 ${uiLabelMap.CommonDays}"/>
+            </drop-down>
+        </field>
+        <field name="startPrice"><text size="12" maxlength="12" default-value="1.00"/></field>
+        <field name="quantity"><text size="12" maxlength="12" default-value="1"/></field>
+        <field name="paymentMethodAccepted"><display also-hidden="true"/></field>
+        <field name="paymentPayPal" position="1"><check all-checked="true"/></field>
+        <field name="paymentVisaMC" position="2"><check all-checked="true"/></field>
+        <field name="paymentAmEx" position="3"><check all-checked="true"/></field>
+        <field name="paymentDiscover" position="4"><check all-checked="true"/></field>
+        <field name="paymentMOCC" position="1"><check all-checked="true"/></field>
+        <field name="paymentPersonalCheck" position="2"><check all-checked="true"/></field>
+        <field name="paymentCCAccepted" position="3"><check all-checked="false"/></field>
+        <field name="paymentCashInPerson" position="4"><check all-checked="false"/></field>
+        <field name="paymentCashOnPickup" position="1"><check all-checked="false"/></field>
+        <field name="paymentCOD" position="2"><check all-checked="false"/></field>
+        <field name="paymentCODPrePayDelivery" position="3"><check all-checked="false"/></field>
+        <field name="paymentMoneyXferAccepted" position="4"><check all-checked="false"/></field>
+        <field name="payPalEmail"><text size="50" maxlength="50"/></field>
         <field name="submitButton" title="${uiLabelMap.ProductExportToeBay}"><submit button-type="button"/></field>
     </form>
 </forms>