Author: jacopoc
Date: Fri Aug 28 11:07:35 2009 New Revision: 808848 URL: http://svn.apache.org/viewvc?rev=808848&view=rev Log: Added ability to define starting prices for eBay auctions in the ProductPrice entity. Misc cleanups to the export service. Added: ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml (with props) Modified: ofbiz/trunk/specialpurpose/ebay/ofbiz-component.xml ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java Added: ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml?rev=808848&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml (added) +++ ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml Fri Aug 28 11:07:35 2009 @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<entity-engine-xml> + <ProductPricePurpose productPricePurposeId="EBAY" description="eBay Auction"/> +</entity-engine-xml> Propchange: ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/specialpurpose/ebay/ofbiz-component.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/ofbiz-component.xml?rev=808848&r1=808847&r2=808848&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/ofbiz-component.xml (original) +++ ofbiz/trunk/specialpurpose/ebay/ofbiz-component.xml Fri Aug 28 11:07:35 2009 @@ -26,6 +26,7 @@ <classpath type="jar" location="build/lib/*"/> <entity-resource type="data" reader-name="seed" loader="main" location="data/EbaySecurityData.xml"/> + <entity-resource type="data" reader-name="seed" loader="main" location="data/EbayTypeData.xml"/> <service-resource type="model" loader="main" location="servicedef/services.xml"/> <service-resource type="eca" loader="main" location="servicedef/secas.xml"/> Modified: ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml?rev=808848&r1=808847&r2=808848&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml (original) +++ ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml Fri Aug 28 11:07:35 2009 @@ -46,8 +46,8 @@ <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"/> + <attribute type="String" mode="IN" name="startPrice" optional="true"/> + <attribute type="String" mode="IN" name="quantity" optional="true"/> </service> <service name="getEbayCategories" engine="java" location="org.ofbiz.ebay.ProductsExportToEbay" invoke="getEbayCategories" auth="true"> 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=808848&r1=808847&r2=808848&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java (original) +++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java Fri Aug 28 11:07:35 2009 @@ -44,6 +44,7 @@ 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.ServiceUtil; import org.w3c.dom.Document; @@ -93,13 +94,14 @@ } */ - if (!ServiceUtil.isFailure(buildDataItemsXml(dctx, context, dataItemsXml, token))) { + Map resultMap = buildDataItemsXml(dctx, context, dataItemsXml, token); + if (!ServiceUtil.isFailure(resultMap)) { result = postItem(xmlGatewayUri, dataItemsXml, devID, appID, certID, "AddItem", compatibilityLevel, siteID); if (ServiceUtil.isFailure(result)) { return ServiceUtil.returnFailure(ServiceUtil.getErrorMessage(result)); } } else { - return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.exceptionInExportToEbay", locale)); + return ServiceUtil.returnFailure(ServiceUtil.getErrorMessage(resultMap)); } } catch (Exception e) { Debug.logError("Exception in exportToEbay " + e, module); @@ -137,7 +139,6 @@ 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); @@ -199,7 +200,18 @@ String title = parseText(prod.getString("internalName")); String description = parseText(prod.getString("internalName")); String qnt = (String)context.get("quantity"); - + if (UtilValidate.isEmpty(qnt)) { + qnt = "1"; + } + String startPrice = (String)context.get("startPrice"); + if (UtilValidate.isEmpty(startPrice)) { + GenericValue startPriceValue = EntityUtil.getFirst(EntityUtil.filterByDate(prod.getRelatedByAnd("ProductPrice", UtilMisc.toMap("productPricePurposeId", "EBAY", "productPriceTypeId", "MINIMUM_PRICE")))); + if (UtilValidate.isNotEmpty(startPriceValue)) { + startPrice = startPriceValue.getString("price"); + } else { + return ServiceUtil.returnFailure("Unable to find a starting price for auction of product with id [" + prod.getString("productId") + "]"); + } + } 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); @@ -230,7 +242,7 @@ Element primaryCatElem = UtilXml.addChildElement(itemElem, "PrimaryCategory", itemDocument); UtilXml.addChildElementValue(primaryCatElem, "CategoryID", categoryParent, itemDocument); - Element startPriceElem = UtilXml.addChildElementValue(itemElem, "StartPrice", (String)context.get("startPrice"), itemDocument); + Element startPriceElem = UtilXml.addChildElementValue(itemElem, "StartPrice", startPrice, itemDocument); startPriceElem.setAttribute("currencyID", "USD"); } |
Free forum by Nabble | Edit this page |