svn commit: r561963 - in /ofbiz/trunk/applications/product: config/ servicedef/ src/org/ofbiz/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: r561963 - in /ofbiz/trunk/applications/product: config/ servicedef/ src/org/ofbiz/product/product/ webapp/catalog/find/

jacopoc
Author: jacopoc
Date: Wed Aug  1 14:33:07 2007
New Revision: 561963

URL: http://svn.apache.org/viewvc?view=rev&rev=561963
Log:
Misc improvements to the Google Base integration.

Modified:
    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/ProductSearchEvents.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToGoogle.java
    ofbiz/trunk/applications/product/webapp/catalog/find/ExportForms.xml

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=561963&r1=561962&r2=561963
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Wed Aug  1 14:33:07 2007
@@ -562,6 +562,7 @@
 ProductExportDeactivated=Deactivated
 ProductExportPublish=Publish
 ProductExportPublishDraft=Publish Draft
+ProductExportTestMode=(Yes=Validate the xml document request to Google Base, No=Send the xml document request to Google Base)
 ProductExportToGoogle=Export To Google Base
 ProductExportNoTrackingRequested=Not Requested
 ProductFacilities=Facilities
@@ -1897,4 +1898,5 @@
 FormFieldTitle_paymentMoneyXferAccepted=Direct transfer of money
 FormFieldTitle_paymentPersonalCheck=Personal check
 FormFieldTitle_listingDuration=Listing Duration
-FormFieldTitle_startPrice=Start Price
\ No newline at end of file
+FormFieldTitle_startPrice=Start Price
+FormFieldTitle_testMode=Test mode
\ 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=561963&r1=561962&r2=561963
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels_it.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels_it.properties Wed Aug  1 14:33:07 2007
@@ -557,6 +557,7 @@
 ProductExportDeactivated=Disattiva
 ProductExportPublish=Pubblica
 ProductExportPublishDraft=Pubblica come Bozza
+ProductExportTestMode=(Si=Valida la richiesta del documento xml su Google Base, No=Invia la richiesta del documento xml a Google Base)
 ProductExportToGoogle=Esportazione Su Google Base
 ProductExportNoTrackingRequested=Non Richiesto
 ProductFacilities=Stabilimenti
@@ -1880,4 +1881,5 @@
 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
+FormFieldTitle_startPrice=Prezzo di Partenza
+FormFieldTitle_testMode=In Modo Test
\ 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=561963&r1=561962&r2=561963
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services.xml Wed Aug  1 14:33:07 2007
@@ -1124,6 +1124,7 @@
         <attribute type="String" mode="IN" name="imageUrl" optional="false"/>
         <attribute type="String" mode="IN" name="actionType" optional="false"/>
         <attribute type="String" mode="IN" name="statusId" optional="false"/>
+        <attribute type="String" mode="IN" name="testMode" optional="false"/>
         <attribute type="String" mode="IN" name="trackingCodeId" optional="true"/>
     </service>
     <service name="exportToEbay" engine="java"

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java?view=diff&rev=561963&r1=561962&r2=561963
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java Wed Aug  1 14:33:07 2007
@@ -486,6 +486,7 @@
                 String imageUrl = (String) request.getParameter("imageUrl");
                 String actionType = (String) request.getParameter("actionType");
                 String statusId = (String) request.getParameter("statusId");
+                String testMode = (String) request.getParameter("testMode");
                 String trackingCodeId = (String) request.getParameter("trackingCodeId");
                 
                 // Export all or selected products to Google Base
@@ -495,7 +496,8 @@
                                                "imageUrl", imageUrl,
                                                "actionType", actionType,
                                                "statusId", statusId,
-                                               "trackingCodeId", trackingCodeId);
+                                               "testMode", testMode);
+                    inMap.put("trackingCodeId", trackingCodeId);
                     inMap.put("userLogin", userLogin);
                     Map exportResult = dispatcher.runSync("exportToGoogle", inMap);
                     if (ServiceUtil.isError(exportResult)) {
@@ -503,7 +505,9 @@
                         Debug.logError(errMsg, module);
                         request.setAttribute("_ERROR_MESSAGE_", errMsg);
                         return "error";
-                    }
+                    } else {
+                        request.setAttribute("_SUCCESS_MESSAGE_", exportResult.get("successMessage"));
+                    }
                 } catch (GenericServiceException e) {
                     errMsg = UtilProperties.getMessage(resource, "productsearchevents.exceptionCallingExportToGoogle", locale);
                     Debug.logError(e, errMsg, module);

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToGoogle.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToGoogle.java?view=diff&rev=561963&r1=561962&r2=561963
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToGoogle.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToGoogle.java Wed Aug  1 14:33:07 2007
@@ -81,7 +81,7 @@
             if (!ServiceUtil.isFailure(result)) {
                 String token = authenticate(authenticationUrl, accountEmail, accountPassword);
                 if (token != null) {    
-                    result = postItem(token, postItemsUrl, developerKey, dataItemsXml, locale);
+                    result = postItem(token, postItemsUrl, developerKey, dataItemsXml, locale, (String)context.get("testMode"));
                     String msg = ServiceUtil.getErrorMessage(result);
                     if (msg != null && msg.length() > 0) {
                         return ServiceUtil.returnFailure(msg);
@@ -183,9 +183,19 @@
         return outputBuilder.toString();
     }
     
-    private static Map postItem(String token, String postItemsUrl, String developerKey, StringBuffer dataItems, Locale locale) throws IOException {
+    private static Map postItem(String token, String postItemsUrl, String developerKey, StringBuffer dataItems,
+                                Locale locale, String testMode) throws IOException {
+        if (Debug.verboseOn()) {
+            Debug.logVerbose("Request To Google Base :\n" + dataItems.toString(), module);
+        }
+        
         HttpURLConnection connection = (HttpURLConnection)(new URL(postItemsUrl)).openConnection();
-      
+        
+        // Test Mode Yes (add the dry-run=true)
+        if (UtilValidate.isNotEmpty(testMode) && "Y".equals(testMode)) {
+            connection.setRequestProperty("dry-run", "true");
+        }
+        
         connection.setDoInput(true);
         connection.setDoOutput(true);
         connection.setRequestMethod("POST");
@@ -200,21 +210,27 @@
         int responseCode = connection.getResponseCode();
         InputStream inputStream;
         Map result = FastMap.newInstance();
+        String response = "";
         if (responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_OK) {
             inputStream = connection.getInputStream();
-            String response = toString(inputStream);
+            response = toString(inputStream);
             if (response != null && response.length() > 0) {
                 result = readResponseFromGoogle(response, locale);
                 String msg = ServiceUtil.getErrorMessage(result);
                 if (msg != null && msg.length() > 0) {
-                    return ServiceUtil.returnFailure(msg);
+                    result = ServiceUtil.returnFailure(msg);
                 } else {
-                    return ServiceUtil.returnSuccess();
+                    result = ServiceUtil.returnSuccess();
                 }
             }
         } else {
             inputStream = connection.getErrorStream();
-            result = ServiceUtil.returnFailure(toString(inputStream));
+            response = toString(inputStream);
+            result = ServiceUtil.returnFailure(response);
+        }
+        
+        if (Debug.verboseOn()) {
+            Debug.logVerbose("Response From Google Base :\n" + response, module);
         }
         return result;
     }

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=561963&r1=561962&r2=561963
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/find/ExportForms.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/find/ExportForms.xml Wed Aug  1 14:33:07 2007
@@ -28,9 +28,7 @@
             <drop-down no-current-selected-key="insert">
                 <option key="insert" description="${uiLabelMap.CommonInsert}"/>
                 <option key="update" description="${uiLabelMap.CommonUpdate}"/>
-                <!-- for the moment delete action type is not allowed
                 <option key="delete" description="${uiLabelMap.CommonDelete}"/>
-                -->
             </drop-down>
         </field>
         <field name="statusId">
@@ -40,6 +38,12 @@
                 -->
                 <option key="draft" description="${uiLabelMap.ProductExportPublishDraft}"/>
                 <option key="publish" description="${uiLabelMap.ProductExportPublish}"/>
+            </drop-down>
+        </field>
+        <field name="testMode" tooltip="${uiLabelMap.ProductExportTestMode}">
+            <drop-down no-current-selected-key="N">
+                <option key="N" description="${uiLabelMap.CommonNo}"/>
+                <option key="Y" description="${uiLabelMap.CommonYes}"/>
             </drop-down>
         </field>
         <field name="trackingCodeId">