You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2009/09/03 11:55:14 UTC
svn commit: r810857 -
/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
Author: jacopoc
Date: Thu Sep 3 09:55:14 2009
New Revision: 810857
URL: http://svn.apache.org/viewvc?rev=810857&view=rev
Log:
Fix for issue happening after that Xalan jars have been added to the classpath: namespaces were added to each and every element.
Thanks to Ashish Vijaywargiya for the bug report and tests.
Modified:
ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java?rev=810857&r1=810856&r2=810857&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Thu Sep 3 09:55:14 2009
@@ -349,12 +349,11 @@
Document feedDocument = UtilXml.makeEmptyXmlDocument("feed");
Element feedElem = feedDocument.getDocumentElement();
- feedElem.setAttribute("xmlns", "http://www.w3.org/2005/Atom");
- feedElem.setAttribute("xmlns:openSearch", "http://a9.com/-/spec/opensearchrss/1.0/");
- feedElem.setAttribute("xmlns:g", "http://base.google.com/ns/1.0");
- feedElem.setAttribute("xmlns:gm", "http://base.google.com/ns-metadata/1.0");
- feedElem.setAttribute("xmlns:batch", "http://schemas.google.com/gdata/batch");
- feedElem.setAttribute("xmlns:app", "http://purl.org/atom/app#");
+ feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2005/Atom");
+ feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:gm", googleBaseMetadataUrl);
+ feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:g", googleBaseNSUrl);
+ feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:batch", googleBaseBatchUrl);
+ feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:app", googleBaseAppUrl);
// Iterate the product list getting all the relevant data
Iterator productsListItr = productsList.iterator();
@@ -369,8 +368,8 @@
Debug.logInfo("Price not found for product [" + prod.getString("productId")+ "]; product will not be exported.", module);
continue;
}
- // TODO: improve this (i.e. get the relative path from the properies file)
- String link = webSiteUrl + "/"+webSiteMountPoint+"/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
+ // TODO: improve this (i.e. get the relative path from the properties file)
+ String link = webSiteUrl + "/" + webSiteMountPoint + "/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
String title = UtilFormatOut.encodeXmlValue(prod.getString("productName"));
if (UtilValidate.isEmpty(title)) {
title = UtilFormatOut.encodeXmlValue(prod.getString("internalName"));
@@ -501,7 +500,7 @@
}
index++;
}
- //Debug.logInfo("The value of generated String is ======== " + UtilXml.writeXmlDocument(feedDocument), module);
+ //Debug.logInfo("The value of generated String is ========\n" + UtilXml.writeXmlDocument(feedDocument), module);
dataItemsXml.append(UtilXml.writeXmlDocument(feedDocument));
} catch (IOException e) {
return ServiceUtil.returnError("IO Error creating XML document for Google :" + e.getMessage());
Re: svn commit: r810857 - /ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
Posted by Ashish Vijaywargiya <as...@hotwaxmedia.com>.
Thank you so much Jacopo for taking care of this issue.
I have tested it once again on my machine - everything is working fine
for me now.
Here is the generated feed for two products after your changes.
<?xml version="1.0" encoding="UTF-8"?><feed
xmlns="http://www.w3.org/2005/Atom"
xmlns:app="http://purl.org/atom/app#"
xmlns:batch="http://schemas.google.com/gdata/batch"
xmlns:g="http://base.google.com/ns/1.0"
xmlns:gm="http://base.google.com/ns-metadata/1.0">
<entry>
<batch:operation type="insert"/>
<app:control>
<gm:publishing_priority>high</gm:publishing_priority>
</app:control>
<app:draft>yes</app:draft>
<title>Big Gizmo</title>
<content type="xhtml">Big Gizmo w/ Legs</content>
<g:id>http://demo.ofbiz.org/ecommerce/control/product/~product_id=GZ-8544</g:id>
<link
href="http://demo.ofbiz.org/ecommerce/control/product/~product_id=GZ-8544"
rel="alternate" type="text/html"/>
<g:item_type>products</g:item_type>
<g:product_type>long description of Gizmos</g:product_type>
<g:product_type>long description of Large Gizmos</g:product_type>
<g:product_type>Main Quick Add</g:product_type>
<g:product_type>Demo Default Search</g:product_type>
<g:product_type>Motor Vehicles</g:product_type>
<g:product_type>Test Cross Sell Category</g:product_type>
<g:price>269.990</g:price>
<g:currency>USD</g:currency>
<g:target_country>US</g:target_country>
<g:condition>new</g:condition>
<g:image_link>http://demo.ofbiz.org/images/products/large/blazer.png</g:image_link>
</entry>
<entry>
<batch:operation type="insert"/>
<app:control>
<gm:publishing_priority>high</gm:publishing_priority>
</app:control>
<app:draft>yes</app:draft>
<title>His/Her Gizmo</title>
<content type="xhtml">A set of his/her gizmos</content>
<g:id>http://demo.ofbiz.org/ecommerce/control/product/~product_id=GZ-9290</g:id>
<link
href="http://demo.ofbiz.org/ecommerce/control/product/~product_id=GZ-9290"
rel="alternate" type="text/html"/>
<g:item_type>products</g:item_type>
<g:product_type>long description of Gizmos</g:product_type>
<g:product_type>long description of Large Gizmos</g:product_type>
<g:product_type>Demo Default Search</g:product_type>
<g:product_type>Toys & Games</g:product_type>
<g:product_type>Test Cross Sell Category</g:product_type>
<g:price>97.990</g:price>
<g:currency>USD</g:currency>
<g:target_country>US</g:target_country>
<g:condition>new</g:condition>
<g:image_link>http://demo.ofbiz.org/images/products/large/green_burner.png</g:image_link>
</entry>
</feed>
--
Ashish
jacopoc@apache.org wrote:
> Author: jacopoc
> Date: Thu Sep 3 09:55:14 2009
> New Revision: 810857
>
> URL: http://svn.apache.org/viewvc?rev=810857&view=rev
> Log:
> Fix for issue happening after that Xalan jars have been added to the classpath: namespaces were added to each and every element.
> Thanks to Ashish Vijaywargiya for the bug report and tests.
>
>
> Modified:
> ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
>
> Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java?rev=810857&r1=810856&r2=810857&view=diff
> ==============================================================================
> --- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java (original)
> +++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Thu Sep 3 09:55:14 2009
> @@ -349,12 +349,11 @@
>
> Document feedDocument = UtilXml.makeEmptyXmlDocument("feed");
> Element feedElem = feedDocument.getDocumentElement();
> - feedElem.setAttribute("xmlns", "http://www.w3.org/2005/Atom");
> - feedElem.setAttribute("xmlns:openSearch", "http://a9.com/-/spec/opensearchrss/1.0/");
> - feedElem.setAttribute("xmlns:g", "http://base.google.com/ns/1.0");
> - feedElem.setAttribute("xmlns:gm", "http://base.google.com/ns-metadata/1.0");
> - feedElem.setAttribute("xmlns:batch", "http://schemas.google.com/gdata/batch");
> - feedElem.setAttribute("xmlns:app", "http://purl.org/atom/app#");
> + feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2005/Atom");
> + feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:gm", googleBaseMetadataUrl);
> + feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:g", googleBaseNSUrl);
> + feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:batch", googleBaseBatchUrl);
> + feedElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:app", googleBaseAppUrl);
>
> // Iterate the product list getting all the relevant data
> Iterator productsListItr = productsList.iterator();
> @@ -369,8 +368,8 @@
> Debug.logInfo("Price not found for product [" + prod.getString("productId")+ "]; product will not be exported.", module);
> continue;
> }
> - // TODO: improve this (i.e. get the relative path from the properies file)
> - String link = webSiteUrl + "/"+webSiteMountPoint+"/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
> + // TODO: improve this (i.e. get the relative path from the properties file)
> + String link = webSiteUrl + "/" + webSiteMountPoint + "/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
> String title = UtilFormatOut.encodeXmlValue(prod.getString("productName"));
> if (UtilValidate.isEmpty(title)) {
> title = UtilFormatOut.encodeXmlValue(prod.getString("internalName"));
> @@ -501,7 +500,7 @@
> }
> index++;
> }
> - //Debug.logInfo("The value of generated String is ======== " + UtilXml.writeXmlDocument(feedDocument), module);
> + //Debug.logInfo("The value of generated String is ========\n" + UtilXml.writeXmlDocument(feedDocument), module);
> dataItemsXml.append(UtilXml.writeXmlDocument(feedDocument));
> } catch (IOException e) {
> return ServiceUtil.returnError("IO Error creating XML document for Google :" + e.getMessage());
>
>
>