You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2009/09/08 12:28:55 UTC
svn commit: r812437 - in
/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay: EbayHelper.java
ProductsExportToEbay.java
Author: ashish
Date: Tue Sep 8 10:28:55 2009
New Revision: 812437
URL: http://svn.apache.org/viewvc?rev=812437&view=rev
Log:
Moving a method that prepares EbayConfigurations to Helper class - These configuration settings can be used by few methods / services present inside ImportOrdersFromEbay.java. Will reduce the duplicate code.
Added:
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java (with props)
Modified:
ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
Added: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java?rev=812437&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java (added)
+++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java Tue Sep 8 10:28:55 2009
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+package org.ofbiz.ebay;
+
+import java.util.Map;
+
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+
+public class EbayHelper {
+ private static final String configFileName = "ebayExport.properties";
+ private static final String module = EbayHelper.class.getName();
+
+ public static Map<String, Object> buildEbayConfig(Map<String, Object> context, GenericDelegator delegator) {
+ Map<String, Object> buildEbayConfigContext = FastMap.newInstance();
+ String productStoreId = (String) context.get("productStoreId");
+ if (UtilValidate.isNotEmpty(productStoreId)) {
+ GenericValue eBayConfig = null;
+ try {
+ eBayConfig = delegator.findOne("EbayConfig", false, UtilMisc.toMap("productStoreId", productStoreId));
+ } catch (GenericEntityException e) {
+ Debug.logError("Unable to find value for EbayConfig", module);
+ e.printStackTrace();
+ }
+ if (UtilValidate.isNotEmpty(eBayConfig)) {
+ buildEbayConfigContext.put("devID", eBayConfig.getString("devId"));
+ buildEbayConfigContext.put("appID", eBayConfig.getString("appId"));
+ buildEbayConfigContext.put("certID", eBayConfig.getString("certId"));
+ buildEbayConfigContext.put("token", eBayConfig.getString("token"));
+ buildEbayConfigContext.put("compatibilityLevel", eBayConfig.getString("compatibilityLevel"));
+ buildEbayConfigContext.put("siteID", eBayConfig.getString("siteId"));
+ buildEbayConfigContext.put("xmlGatewayUri", eBayConfig.getString("xmlGatewayUri"));
+ }
+ } else {
+ buildEbayConfigContext.put("devID", UtilProperties.getPropertyValue(configFileName, "eBayExport.devID"));
+ buildEbayConfigContext.put("appID", UtilProperties.getPropertyValue(configFileName, "eBayExport.appID"));
+ buildEbayConfigContext.put("certID", UtilProperties.getPropertyValue(configFileName, "eBayExport.certID"));
+ buildEbayConfigContext.put("token", UtilProperties.getPropertyValue(configFileName, "eBayExport.token"));
+ buildEbayConfigContext.put("compatibilityLevel", UtilProperties.getPropertyValue(configFileName, "eBayExport.compatibilityLevel"));
+ buildEbayConfigContext.put("siteID", UtilProperties.getPropertyValue(configFileName, "eBayExport.siteID"));
+ buildEbayConfigContext.put("xmlGatewayUri", UtilProperties.getPropertyValue(configFileName, "eBayExport.xmlGatewayUri"));
+ }
+ return buildEbayConfigContext;
+ }
+}
\ No newline at end of file
Propchange: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=812437&r1=812436&r2=812437&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java (original)
+++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java Tue Sep 8 10:28:55 2009
@@ -66,7 +66,7 @@
GenericDelegator delegator = dctx.getDelegator();
Map result = null;
try {
- Map<String, Object> eBayConfigResult = buildEbayConfig(context, delegator);
+ Map<String, Object> eBayConfigResult = EbayHelper.buildEbayConfig(context, delegator);
StringBuffer dataItemsXml = new StringBuffer();
Map resultMap = buildDataItemsXml(dctx, context, dataItemsXml, eBayConfigResult.get("token").toString());
if (!ServiceUtil.isFailure(resultMap)) {
@@ -473,7 +473,7 @@
Map result = null;
try {
- Map<String, Object> eBayConfigResult = buildEbayConfig(context, delegator);
+ Map<String, Object> eBayConfigResult = EbayHelper.buildEbayConfig(context, delegator);
String categoryParent = "";
String levelLimit = "";
if (categoryCode != null) {
@@ -553,38 +553,6 @@
return results;
}
- private static Map<String, Object> buildEbayConfig(Map<String, Object> context, GenericDelegator delegator) {
- Map<String, Object> buildEbayConfigContext = FastMap.newInstance();
- String productStoreId = (String) context.get("productStoreId");
- if (UtilValidate.isNotEmpty(productStoreId)) {
- GenericValue eBayConfig = null;
- try {
- eBayConfig = delegator.findOne("EbayConfig", false, UtilMisc.toMap("productStoreId", productStoreId));
- } catch (GenericEntityException e) {
- Debug.logError("Unable to find value for EbayConfig", module);
- e.printStackTrace();
- }
- if (UtilValidate.isNotEmpty(eBayConfig)) {
- buildEbayConfigContext.put("devID", eBayConfig.getString("devId"));
- buildEbayConfigContext.put("appID", eBayConfig.getString("appId"));
- buildEbayConfigContext.put("certID", eBayConfig.getString("certId"));
- buildEbayConfigContext.put("token", eBayConfig.getString("token"));
- buildEbayConfigContext.put("compatibilityLevel", eBayConfig.getString("compatibilityLevel"));
- buildEbayConfigContext.put("siteID", eBayConfig.getString("siteId"));
- buildEbayConfigContext.put("xmlGatewayUri", eBayConfig.getString("xmlGatewayUri"));
- }
- } else {
- buildEbayConfigContext.put("devID", UtilProperties.getPropertyValue(configFileName, "eBayExport.devID"));
- buildEbayConfigContext.put("appID", UtilProperties.getPropertyValue(configFileName, "eBayExport.appID"));
- buildEbayConfigContext.put("certID", UtilProperties.getPropertyValue(configFileName, "eBayExport.certID"));
- buildEbayConfigContext.put("token", UtilProperties.getPropertyValue(configFileName, "eBayExport.token"));
- buildEbayConfigContext.put("compatibilityLevel", UtilProperties.getPropertyValue(configFileName, "eBayExport.compatibilityLevel"));
- buildEbayConfigContext.put("siteID", UtilProperties.getPropertyValue(configFileName, "eBayExport.siteID"));
- buildEbayConfigContext.put("xmlGatewayUri", UtilProperties.getPropertyValue(configFileName, "eBayExport.xmlGatewayUri"));
- }
- return buildEbayConfigContext;
- }
-
private static Map exportToEbayResponse(String msg) {
Map result = FastMap.newInstance();
try {