This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git The following commit(s) were added to refs/heads/trunk by this push: new 78801df Improved: Updated case indentation to 0 for all switch statements in plugins component. Also done formatting changes as per checkstyle best practices. (OFBIZ-11904) new 4b88493 Merge branch 'trunk' of https://gitbox.apache.org/repos/asf/ofbiz-plugins into trunk 78801df is described below commit 78801df4539f3d53d031e40697717315630529f1 Author: Suraj Khurana <[hidden email]> AuthorDate: Sat Jul 25 13:48:25 2020 +0530 Improved: Updated case indentation to 0 for all switch statements in plugins component. Also done formatting changes as per checkstyle best practices. (OFBIZ-11904) --- .../org/apache/ofbiz/ebay/EbayOrderServices.java | 377 ++++++++++++--------- .../apache/ofbiz/ebay/ImportOrdersFromEbay.java | 153 +++++---- .../org/apache/ofbiz/ebaystore/EbayEvents.java | 4 +- .../java/org/apache/ofbiz/ebaystore/EbayStore.java | 8 +- .../apache/ofbiz/ebaystore/EbayStoreHelper.java | 2 +- .../apache/ofbiz/ebaystore/EbayStoreOptions.java | 2 +- .../org/apache/ofbiz/ebaystore/EbayStoreOrder.java | 2 +- .../ofbiz/content/search/ProductDocument.java | 9 +- .../ofbiz/passport/user/GitHubAuthenticator.java | 40 +-- .../org/apache/ofbiz/htmlreport/HtmlReport.java | 366 ++++++++++---------- .../ofbiz/htmlreport/util/ReportEncoder.java | 46 +-- .../ofbiz/htmlreport/util/ReportStringUtil.java | 100 +++--- .../apache/ofbiz/pricat/AbstractPricatParser.java | 34 +- .../ofbiz/pricat/sample/SamplePricatParser.java | 12 +- .../java/org/apache/ofbiz/solr/ProductUtil.java | 68 ++-- .../org/apache/ofbiz/solr/SolrProductSearch.java | 57 ++-- .../main/java/org/apache/ofbiz/solr/SolrUtil.java | 2 +- .../java/org/apache/ofbiz/webpos/WebPosEvents.java | 2 +- 18 files changed, 688 insertions(+), 596 deletions(-) diff --git a/ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java b/ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java index 2b1cfa5..07402e0 100644 --- a/ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java +++ b/ebay/src/main/java/org/apache/ofbiz/ebay/EbayOrderServices.java @@ -84,14 +84,18 @@ public class EbayOrderServices { try { Map<String, Object> eBayConfigResult = EbayHelper.buildEbayConfig(context, delegator); if (UtilValidate.isEmpty(eBayConfigResult)) { - String eBayConfigErrorMsg = UtilProperties.getMessage(RESOURCE, "EbayConfigurationSettingsAreMissingForConnectingToEbayServer", locale); + String eBayConfigErrorMsg = UtilProperties.getMessage(RESOURCE, "EbayConfigurationSettingsAreMissingForConnectingToEbayServer", + locale); return ServiceUtil.returnError(eBayConfigErrorMsg); } StringBuffer sellerTransactionsItemsXml = new StringBuffer(); - if (!ServiceUtil.isFailure(buildGetSellerTransactionsRequest(context, sellerTransactionsItemsXml, eBayConfigResult.get("token").toString()))) { - result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), sellerTransactionsItemsXml, eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), "GetSellerTransactions", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); - String getSellerTransactionSuccessMsg = (String) result.get(ModelService.SUCCESS_MESSAGE); + if (!ServiceUtil.isFailure(buildGetSellerTransactionsRequest(context, sellerTransactionsItemsXml, + eBayConfigResult.get("token").toString()))) { + result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), sellerTransactionsItemsXml, eBayConfigResult.get( + "devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), + "GetSellerTransactions", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); + String getSellerTransactionSuccessMsg = (String) result.get(ModelService.SUCCESS_MESSAGE); if (getSellerTransactionSuccessMsg != null) { isGetSellerTransactionsCall = true; result = checkOrders(delegator, dispatcher, locale, context, getSellerTransactionSuccessMsg); @@ -100,7 +104,9 @@ public class EbayOrderServices { StringBuffer getOrdersXml = new StringBuffer(); if (!ServiceUtil.isFailure(buildGetOrdersRequest(context, getOrdersXml, eBayConfigResult.get("token").toString()))) { - result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), getOrdersXml, eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), "GetOrders", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); + result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), getOrdersXml, + eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), + "GetOrders", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); String getOrdersSuccessMsg = (String) result.get(ModelService.SUCCESS_MESSAGE); if (getOrdersSuccessMsg != null) { isGetOrdersCall = true; @@ -110,7 +116,9 @@ public class EbayOrderServices { StringBuffer getMyeBaySellingXml = new StringBuffer(); if (!ServiceUtil.isFailure(buildGetMyeBaySellingRequest(context, getMyeBaySellingXml, eBayConfigResult.get("token").toString()))) { - result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), getMyeBaySellingXml, eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), "GetMyeBaySelling", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); + result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), getMyeBaySellingXml, + eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), + "GetMyeBaySelling", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); String getMyeBaySellingSuccessMsg = (String) result.get(ModelService.SUCCESS_MESSAGE); if (getMyeBaySellingSuccessMsg != null) { isGetMyeBaySellingCall = true; @@ -165,118 +173,129 @@ public class EbayOrderServices { String fromDate = (String) context.get("fromDate"); String thruDate = (String) context.get("thruDate"); try { - Document transDoc = UtilXml.makeEmptyXmlDocument("GetOrdersRequest"); - Element transElem = transDoc.getDocumentElement(); - transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); - UtilXml.addChildElementValue(transElem, "DetailLevel", "ReturnAll", transDoc); - - EbayHelper.appendRequesterCredentials(transElem, transDoc, token); - - if (UtilValidate.isNotEmpty(getSellerTransactionsContainingOrderList)) { - Element orderIdArrayElem = UtilXml.addChildElement(transElem, "OrderIDArray", transDoc); - Iterator<String> orderIdListIter = getSellerTransactionsContainingOrderList.iterator(); - while (orderIdListIter.hasNext()) { - String orderId = orderIdListIter.next(); - UtilXml.addChildElementValue(orderIdArrayElem, "OrderID", orderId, transDoc); - } - } else { - UtilXml.addChildElementValue(transElem, "OrderRole", "Seller", transDoc); - UtilXml.addChildElementValue(transElem, "OrderStatus", "Completed", transDoc); - - String fromDateOut = EbayHelper.convertDate(fromDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - if (fromDateOut != null) { - UtilXml.addChildElementValue(transElem, "CreateTimeFrom", fromDateOut, transDoc); - } else { - Debug.logError("Cannot convert from date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertFromDate", locale)); - } - fromDateOut = EbayHelper.convertDate(thruDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - if (fromDateOut != null) { - UtilXml.addChildElementValue(transElem, "CreateTimeTo", fromDateOut, transDoc); - } else { - Debug.logError("Cannot convert thru date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertThruDate", locale)); - } - } - //Debug.logInfo("The value of generated string is ======= " + UtilXml.writeXmlDocument(transDoc), MODULE); - dataItemsXml.append(UtilXml.writeXmlDocument(transDoc)); - } catch (Exception e) { - Debug.logError("Exception during building get seller transactions request", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionDuringBuildingGetSellerTransactionRequest", locale)); - } - return ServiceUtil.returnSuccess(); + Document transDoc = UtilXml.makeEmptyXmlDocument("GetOrdersRequest"); + Element transElem = transDoc.getDocumentElement(); + transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); + UtilXml.addChildElementValue(transElem, "DetailLevel", "ReturnAll", transDoc); + + EbayHelper.appendRequesterCredentials(transElem, transDoc, token); + + if (UtilValidate.isNotEmpty(getSellerTransactionsContainingOrderList)) { + Element orderIdArrayElem = UtilXml.addChildElement(transElem, "OrderIDArray", transDoc); + Iterator<String> orderIdListIter = getSellerTransactionsContainingOrderList.iterator(); + while (orderIdListIter.hasNext()) { + String orderId = orderIdListIter.next(); + UtilXml.addChildElementValue(orderIdArrayElem, "OrderID", orderId, transDoc); + } + } else { + UtilXml.addChildElementValue(transElem, "OrderRole", "Seller", transDoc); + UtilXml.addChildElementValue(transElem, "OrderStatus", "Completed", transDoc); + + String fromDateOut = EbayHelper.convertDate(fromDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + if (fromDateOut != null) { + UtilXml.addChildElementValue(transElem, "CreateTimeFrom", fromDateOut, transDoc); + } else { + Debug.logError("Cannot convert from date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", + MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertFromDate", locale)); + } + fromDateOut = EbayHelper.convertDate(thruDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + if (fromDateOut != null) { + UtilXml.addChildElementValue(transElem, "CreateTimeTo", fromDateOut, transDoc); + } else { + Debug.logError("Cannot convert thru date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", + MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertThruDate", locale)); + } + } + //Debug.logInfo("The value of generated string is ======= " + UtilXml.writeXmlDocument(transDoc), MODULE); + dataItemsXml.append(UtilXml.writeXmlDocument(transDoc)); + } catch (Exception e) { + Debug.logError("Exception during building get seller transactions request", MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay" + + ".exceptionDuringBuildingGetSellerTransactionRequest", locale)); + } + return ServiceUtil.returnSuccess(); } - private static Map<String, Object> buildGetSellerTransactionsRequest(Map<String, Object> context, StringBuffer sellerTransactionsItemsXml, String token) { + private static Map<String, Object> buildGetSellerTransactionsRequest(Map<String, Object> context, StringBuffer sellerTransactionsItemsXml, + String token) { Locale locale = (Locale) context.get("locale"); String fromDate = (String) context.get("fromDate"); String thruDate = (String) context.get("thruDate"); try { - Document transDoc = UtilXml.makeEmptyXmlDocument("GetSellerTransactionsRequest"); - Element transElem = transDoc.getDocumentElement(); - transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); - - EbayHelper.appendRequesterCredentials(transElem, transDoc, token); - UtilXml.addChildElementValue(transElem, "DetailLevel", "ReturnAll", transDoc); - UtilXml.addChildElementValue(transElem, "IncludeContainingOrder", "true", transDoc); - - String fromDateOut = EbayHelper.convertDate(fromDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - if (fromDateOut != null) { - UtilXml.addChildElementValue(transElem, "ModTimeFrom", fromDateOut, transDoc); - } else { - Debug.logError("Cannot convert from date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertFromDate", locale)); - } - - fromDateOut = EbayHelper.convertDate(thruDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - if (fromDateOut != null) { - UtilXml.addChildElementValue(transElem, "ModTimeTo", fromDateOut, transDoc); - } else { - Debug.logError("Cannot convert thru date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertThruDate", locale)); - } - //Debug.logInfo("The value of generated string is ======= " + UtilXml.writeXmlDocument(transDoc), MODULE); - sellerTransactionsItemsXml.append(UtilXml.writeXmlDocument(transDoc)); - } catch (Exception e) { - Debug.logError("Exception during building get seller transactions request", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionDuringBuildingGetSellerTransactionRequest", locale)); - } - return ServiceUtil.returnSuccess(); + Document transDoc = UtilXml.makeEmptyXmlDocument("GetSellerTransactionsRequest"); + Element transElem = transDoc.getDocumentElement(); + transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); + + EbayHelper.appendRequesterCredentials(transElem, transDoc, token); + UtilXml.addChildElementValue(transElem, "DetailLevel", "ReturnAll", transDoc); + UtilXml.addChildElementValue(transElem, "IncludeContainingOrder", "true", transDoc); + + String fromDateOut = EbayHelper.convertDate(fromDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + if (fromDateOut != null) { + UtilXml.addChildElementValue(transElem, "ModTimeFrom", fromDateOut, transDoc); + } else { + Debug.logError("Cannot convert from date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", + MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertFromDate", locale)); + } + + fromDateOut = EbayHelper.convertDate(thruDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + if (fromDateOut != null) { + UtilXml.addChildElementValue(transElem, "ModTimeTo", fromDateOut, transDoc); + } else { + Debug.logError("Cannot convert thru date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", + MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertThruDate", locale)); + } + //Debug.logInfo("The value of generated string is ======= " + UtilXml.writeXmlDocument(transDoc), MODULE); + sellerTransactionsItemsXml.append(UtilXml.writeXmlDocument(transDoc)); + } catch (Exception e) { + Debug.logError("Exception during building get seller transactions request", MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay" + + ".exceptionDuringBuildingGetSellerTransactionRequest", locale)); + } + return ServiceUtil.returnSuccess(); } private static Map<String, Object> buildGetMyeBaySellingRequest(Map<String, Object> context, StringBuffer getMyeBaySellingXml, String token) { Locale locale = (Locale) context.get("locale"); try { - Document transDoc = UtilXml.makeEmptyXmlDocument("GetMyeBaySellingRequest"); - Element transElem = transDoc.getDocumentElement(); - transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); - - EbayHelper.appendRequesterCredentials(transElem, transDoc, token); - - Element deletedFromSoldListElem = UtilXml.addChildElement(transElem, "DeletedFromSoldList", transDoc); - UtilXml.addChildElementValue(deletedFromSoldListElem, "Sort", "ItemID", transDoc); - //Debug.logInfo("The value of generated string is ======= " + UtilXml.writeXmlDocument(transDoc), MODULE); - getMyeBaySellingXml.append(UtilXml.writeXmlDocument(transDoc)); - } catch (Exception e) { - Debug.logError("Exception during building MyeBaySelling request", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionDuringBuildingMyeBaySellingRequest", locale)); - } - return ServiceUtil.returnSuccess(); + Document transDoc = UtilXml.makeEmptyXmlDocument("GetMyeBaySellingRequest"); + Element transElem = transDoc.getDocumentElement(); + transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); + + EbayHelper.appendRequesterCredentials(transElem, transDoc, token); + + Element deletedFromSoldListElem = UtilXml.addChildElement(transElem, "DeletedFromSoldList", transDoc); + UtilXml.addChildElementValue(deletedFromSoldListElem, "Sort", "ItemID", transDoc); + //Debug.logInfo("The value of generated string is ======= " + UtilXml.writeXmlDocument(transDoc), MODULE); + getMyeBaySellingXml.append(UtilXml.writeXmlDocument(transDoc)); + } catch (Exception e) { + Debug.logError("Exception during building MyeBaySelling request", MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionDuringBuildingMyeBaySellingRequest", + locale)); + } + return ServiceUtil.returnSuccess(); } - private static Map<String, Object> checkOrders(Delegator delegator, LocalDispatcher dispatcher, Locale locale, Map<String, Object> context, String responseMsg) { + private static Map<String, Object> checkOrders(Delegator delegator, LocalDispatcher dispatcher, Locale locale, Map<String, Object> context, + String responseMsg) { StringBuffer errorMessage = new StringBuffer(); Map<String, Object> result = new HashMap<>(); GenericValue userLogin = (GenericValue) context.get("userLogin"); if (isGetSellerTransactionsCall) { - List<Map<String, Object>> getSellerTransactionList = readGetSellerTransactionResponse(responseMsg, locale, (String) context.get("productStoreId"), delegator, dispatcher, errorMessage, userLogin); + List<Map<String, Object>> getSellerTransactionList = readGetSellerTransactionResponse(responseMsg, locale, (String) context.get( + "productStoreId"), delegator, dispatcher, errorMessage, userLogin); if (UtilValidate.isNotEmpty(getSellerTransactionList)) { orderList.addAll(getSellerTransactionList); } isGetSellerTransactionsCall = false; return ServiceUtil.returnSuccess(); } else if (isGetOrdersCall) { - List<Map<String, Object>> getOrdersList = readGetOrdersResponse(responseMsg, locale, (String) context.get("productStoreId"), delegator, dispatcher, errorMessage, userLogin); + List<Map<String, Object>> getOrdersList = readGetOrdersResponse(responseMsg, locale, (String) context.get("productStoreId"), delegator, + dispatcher, errorMessage, userLogin); if (UtilValidate.isNotEmpty(getOrdersList)) { orderList.addAll(getOrdersList); } @@ -284,14 +303,15 @@ public class EbayOrderServices { return ServiceUtil.returnSuccess(); } else if (isGetMyeBaySellingCall) { // for now fetching only deleted transaction & orders value from the sold list. - List<String> eBayDeletedOrdersAndTransactionList = readGetMyeBaySellingResponse(responseMsg, locale, (String) context.get("productStoreId"), delegator, dispatcher, errorMessage, userLogin); + List<String> eBayDeletedOrdersAndTransactionList = readGetMyeBaySellingResponse(responseMsg, locale, (String) context.get( + "productStoreId"), delegator, dispatcher, errorMessage, userLogin); if (UtilValidate.isNotEmpty(eBayDeletedOrdersAndTransactionList)) { Debug.logInfo("The value of getMyeBaySellingList" + eBayDeletedOrdersAndTransactionList, MODULE); Iterator<Map<String, Object>> orderListIter = orderList.iterator(); while (orderListIter.hasNext()) { Map<String, Object> orderCtx = orderListIter.next(); if (eBayDeletedOrdersAndTransactionList.contains(orderCtx.get("externalId"))) { - // Now finally exclude orders & transaction that has been deleted from sold list. + // Now finally exclude orders & transaction that has been deleted from sold list. orderList.remove(orderCtx); } } @@ -427,7 +447,8 @@ public class EbayOrderServices { //</GetOrdersResponse> - private static List<Map<String, Object>> readGetOrdersResponse(String responseMsg, Locale locale, String productStoreId, Delegator delegator, LocalDispatcher dispatcher, StringBuffer errorMessage, GenericValue userLogin) { + private static List<Map<String, Object>> readGetOrdersResponse(String responseMsg, Locale locale, String productStoreId, Delegator delegator, + LocalDispatcher dispatcher, StringBuffer errorMessage, GenericValue userLogin) { List<Map<String, Object>> fetchedOrders = new LinkedList<>(); try { Document docResponse = UtilXml.readXmlDocument(responseMsg, true); @@ -485,9 +506,11 @@ public class EbayOrderServices { shippingAddressCtx.put("shippingAddressStreet1", UtilXml.childElementValue(shippingAddressElement, "Street1")); shippingAddressCtx.put("shippingAddressStreet2", UtilXml.childElementValue(shippingAddressElement, "Street2")); shippingAddressCtx.put("shippingAddressCityName", UtilXml.childElementValue(shippingAddressElement, "CityName")); - shippingAddressCtx.put("shippingAddressStateOrProvince", UtilXml.childElementValue(shippingAddressElement, "StateOrProvince")); + shippingAddressCtx.put("shippingAddressStateOrProvince", UtilXml.childElementValue(shippingAddressElement, + "StateOrProvince")); shippingAddressCtx.put("shippingAddressCountry", UtilXml.childElementValue(shippingAddressElement, "Country")); - shippingAddressCtx.put("shippingAddressCountryName", UtilXml.childElementValue(shippingAddressElement, "CountryName")); + shippingAddressCtx.put("shippingAddressCountryName", UtilXml.childElementValue(shippingAddressElement, + "CountryName")); shippingAddressCtx.put("shippingAddressPhone", UtilXml.childElementValue(shippingAddressElement, "Phone")); shippingAddressCtx.put("shippingAddressPostalCode", UtilXml.childElementValue(shippingAddressElement, "PostalCode")); } @@ -504,8 +527,10 @@ public class EbayOrderServices { Iterator<? extends Element> shippingServiceSelectedElemIter = shippingServiceSelectedList.iterator(); while (shippingServiceSelectedElemIter.hasNext()) { Element shippingServiceSelectedElement = shippingServiceSelectedElemIter.next(); - shippingServiceSelectedCtx.put("shippingService", UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingService")); - shippingServiceSelectedCtx.put("shippingServiceCost", UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingServiceCost", "0")); + shippingServiceSelectedCtx.put("shippingService", UtilXml.childElementValue(shippingServiceSelectedElement, + "ShippingService")); + shippingServiceSelectedCtx.put("shippingServiceCost", UtilXml.childElementValue(shippingServiceSelectedElement, + "ShippingServiceCost", "0")); String insuranceCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingInsuranceCost", "0"); if (UtilValidate.isNotEmpty(insuranceCost)) { shippingServiceSelectedCtx.put("shippingTotalAdditionalCost", insuranceCost); @@ -526,7 +551,8 @@ public class EbayOrderServices { Element shippingDetailsElement = shippingDetailsElemIter.next(); shippingDetailsCtx.put("insuranceFee", UtilXml.childElementValue(shippingDetailsElement, "InsuranceFee", "0")); shippingDetailsCtx.put("insuranceOption", UtilXml.childElementValue(shippingDetailsElement, "InsuranceOption")); - shippingDetailsCtx.put("insuranceWanted", UtilXml.childElementValue(shippingDetailsElement, "InsuranceWanted", "false")); + shippingDetailsCtx.put("insuranceWanted", UtilXml.childElementValue(shippingDetailsElement, "InsuranceWanted", + "false")); // Retrieve sales Tax List<? extends Element> salesTaxList = UtilXml.childElementList(shippingDetailsElement, "SalesTax"); @@ -536,9 +562,10 @@ public class EbayOrderServices { shippingDetailsCtx.put("salesTaxAmount", UtilXml.childElementValue(salesTaxElement, "SalesTaxAmount", "0")); shippingDetailsCtx.put("salesTaxPercent", UtilXml.childElementValue(salesTaxElement, "SalesTaxPercent", "0")); shippingDetailsCtx.put("salesTaxState", UtilXml.childElementValue(salesTaxElement, "SalesTaxState", "0")); - shippingDetailsCtx.put("shippingIncludedInTax", UtilXml.childElementValue(salesTaxElement, "ShippingIncludedInTax", "false")); - } + shippingDetailsCtx.put("shippingIncludedInTax", UtilXml.childElementValue(salesTaxElement, + "ShippingIncludedInTax", "false")); } + } orderCtx.put("shippingDetailsCtx", shippingDetailsCtx); // Retrieve checkout status @@ -559,10 +586,14 @@ public class EbayOrderServices { Iterator<? extends Element> externalTransactionElemIter = externalTransactionList.iterator(); while (externalTransactionElemIter.hasNext()) { Element externalTransactionElement = externalTransactionElemIter.next(); - externalTransactionCtx.put("externalTransactionID", UtilXml.childElementValue(externalTransactionElement, "ExternalTransactionID")); - externalTransactionCtx.put("externalTransactionTime", UtilXml.childElementValue(externalTransactionElement, "ExternalTransactionTime")); - externalTransactionCtx.put("feeOrCreditAmount", UtilXml.childElementValue(externalTransactionElement, "FeeOrCreditAmount", "0")); - externalTransactionCtx.put("paymentOrRefundAmount", UtilXml.childElementValue(externalTransactionElement, "PaymentOrRefundAmount", "0")); + externalTransactionCtx.put("externalTransactionID", UtilXml.childElementValue(externalTransactionElement, + "ExternalTransactionID")); + externalTransactionCtx.put("externalTransactionTime", UtilXml.childElementValue(externalTransactionElement, + "ExternalTransactionTime")); + externalTransactionCtx.put("feeOrCreditAmount", UtilXml.childElementValue(externalTransactionElement, + "FeeOrCreditAmount", "0")); + externalTransactionCtx.put("paymentOrRefundAmount", UtilXml.childElementValue(externalTransactionElement, + "PaymentOrRefundAmount", "0")); } orderCtx.put("externalTransactionCtx", externalTransactionCtx); @@ -621,7 +652,7 @@ public class EbayOrderServices { } } } - //Debug.logInfo("The generated string is ======= " + fetchedOrders.toString(), MODULE); + //Debug.logInfo("The generated string is ======= " + fetchedOrders.toString(), MODULE); } else { List<? extends Element> errorList = UtilXml.childElementList(elemResponse, "Errors"); Iterator<? extends Element> errorElemIter = errorList.iterator(); @@ -636,7 +667,9 @@ public class EbayOrderServices { return fetchedOrders; } - private static List<Map<String, Object>> readGetSellerTransactionResponse(String responseMsg, Locale locale, String productStoreId, Delegator delegator, LocalDispatcher dispatcher, StringBuffer errorMessage, GenericValue userLogin) { + private static List<Map<String, Object>> readGetSellerTransactionResponse(String responseMsg, Locale locale, String productStoreId, + Delegator delegator, LocalDispatcher dispatcher, + StringBuffer errorMessage, GenericValue userLogin) { List<Map<String, Object>> fetchedOrders = new LinkedList<>(); try { Document docResponse = UtilXml.readXmlDocument(responseMsg, true); @@ -715,15 +748,24 @@ public class EbayOrderServices { while (shippingAddressElemIter.hasNext()) { Element shippingAddressElement = shippingAddressElemIter.next(); shippingAddressCtx.put("buyerName", UtilXml.childElementValue(shippingAddressElement, "Name", "")); - shippingAddressCtx.put("shippingAddressStreet", UtilXml.childElementValue(shippingAddressElement, "Street", "")); - shippingAddressCtx.put("shippingAddressStreet1", UtilXml.childElementValue(shippingAddressElement, "Street1", "")); - shippingAddressCtx.put("shippingAddressStreet2", UtilXml.childElementValue(shippingAddressElement, "Street2", "")); - shippingAddressCtx.put("shippingAddressCityName", UtilXml.childElementValue(shippingAddressElement, "CityName", "")); - shippingAddressCtx.put("shippingAddressStateOrProvince", UtilXml.childElementValue(shippingAddressElement, "StateOrProvince", "")); - shippingAddressCtx.put("shippingAddressCountry", UtilXml.childElementValue(shippingAddressElement, "Country", "")); - shippingAddressCtx.put("shippingAddressCountryName", UtilXml.childElementValue(shippingAddressElement, "CountryName", "")); - shippingAddressCtx.put("shippingAddressPhone", UtilXml.childElementValue(shippingAddressElement, "Phone", "")); - shippingAddressCtx.put("shippingAddressPostalCode", UtilXml.childElementValue(shippingAddressElement, "PostalCode", "")); + shippingAddressCtx.put("shippingAddressStreet", UtilXml.childElementValue(shippingAddressElement, "Street", + "")); + shippingAddressCtx.put("shippingAddressStreet1", UtilXml.childElementValue(shippingAddressElement, + "Street1", "")); + shippingAddressCtx.put("shippingAddressStreet2", UtilXml.childElementValue(shippingAddressElement, + "Street2", "")); + shippingAddressCtx.put("shippingAddressCityName", UtilXml.childElementValue(shippingAddressElement, + "CityName", "")); + shippingAddressCtx.put("shippingAddressStateOrProvince", UtilXml.childElementValue(shippingAddressElement, + "StateOrProvince", "")); + shippingAddressCtx.put("shippingAddressCountry", UtilXml.childElementValue(shippingAddressElement, + "Country", "")); + shippingAddressCtx.put("shippingAddressCountryName", UtilXml.childElementValue(shippingAddressElement, + "CountryName", "")); + shippingAddressCtx.put("shippingAddressPhone", UtilXml.childElementValue(shippingAddressElement, "Phone", + "")); + shippingAddressCtx.put("shippingAddressPostalCode", UtilXml.childElementValue(shippingAddressElement, + "PostalCode", "")); } } } @@ -736,11 +778,14 @@ public class EbayOrderServices { Iterator<? extends Element> shippingServiceSelectedElemIter = shippingServiceSelected.iterator(); while (shippingServiceSelectedElemIter.hasNext()) { Element shippingServiceSelectedElement = shippingServiceSelectedElemIter.next(); - shippingServiceSelectedCtx.put("shippingService", UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingService", "")); - shippingServiceSelectedCtx.put("shippingServiceCost", UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingServiceCost", "0")); + shippingServiceSelectedCtx.put("shippingService", UtilXml.childElementValue(shippingServiceSelectedElement, + "ShippingService", "")); + shippingServiceSelectedCtx.put("shippingServiceCost", UtilXml.childElementValue(shippingServiceSelectedElement, + "ShippingServiceCost", "0")); String incuranceCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingInsuranceCost", "0"); - String additionalCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingServiceAdditionalCost", "0"); + String additionalCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingServiceAdditionalCost", + "0"); String surchargeCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingSurcharge", "0"); double shippingInsuranceCost = 0; @@ -770,7 +815,8 @@ public class EbayOrderServices { Element shippingDetailsElement = shippingDetailsElemIter.next(); shippingDetailsCtx.put("insuranceFee", UtilXml.childElementValue(shippingDetailsElement, "InsuranceFee", "0")); shippingDetailsCtx.put("insuranceOption", UtilXml.childElementValue(shippingDetailsElement, "InsuranceOption", "")); - shippingDetailsCtx.put("insuranceWanted", UtilXml.childElementValue(shippingDetailsElement, "InsuranceWanted", "false")); + shippingDetailsCtx.put("insuranceWanted", UtilXml.childElementValue(shippingDetailsElement, "InsuranceWanted", + "false")); // retrieve sales Tax List<? extends Element> salesTax = UtilXml.childElementList(shippingDetailsElement, "SalesTax"); @@ -780,7 +826,8 @@ public class EbayOrderServices { shippingDetailsCtx.put("salesTaxAmount", UtilXml.childElementValue(salesTaxElement, "SalesTaxAmount", "0")); shippingDetailsCtx.put("salesTaxPercent", UtilXml.childElementValue(salesTaxElement, "SalesTaxPercent", "0")); shippingDetailsCtx.put("salesTaxState", UtilXml.childElementValue(salesTaxElement, "SalesTaxState", "0")); - shippingDetailsCtx.put("shippingIncludedInTax", UtilXml.childElementValue(salesTaxElement, "ShippingIncludedInTax", "false")); + shippingDetailsCtx.put("shippingIncludedInTax", UtilXml.childElementValue(salesTaxElement, + "ShippingIncludedInTax", "false")); } // retrieve tax table @@ -794,9 +841,12 @@ public class EbayOrderServices { while (taxJurisdictionElemIter.hasNext()) { Element taxJurisdictionElement = taxJurisdictionElemIter.next(); - shippingDetailsCtx.put("jurisdictionID", UtilXml.childElementValue(taxJurisdictionElement, "JurisdictionID", "")); - shippingDetailsCtx.put("jurisdictionSalesTaxPercent", UtilXml.childElementValue(taxJurisdictionElement, "SalesTaxPercent", "0")); - shippingDetailsCtx.put("jurisdictionShippingIncludedInTax", UtilXml.childElementValue(taxJurisdictionElement, "ShippingIncludedInTax", "0")); + shippingDetailsCtx.put("jurisdictionID", UtilXml.childElementValue(taxJurisdictionElement, + "JurisdictionID", "")); + shippingDetailsCtx.put("jurisdictionSalesTaxPercent", UtilXml.childElementValue(taxJurisdictionElement, + "SalesTaxPercent", "0")); + shippingDetailsCtx.put("jurisdictionShippingIncludedInTax", + UtilXml.childElementValue(taxJurisdictionElement, "ShippingIncludedInTax", "0")); } } } @@ -822,10 +872,14 @@ public class EbayOrderServices { Iterator<? extends Element> externalTransactionElemIter = externalTransaction.iterator(); while (externalTransactionElemIter.hasNext()) { Element externalTransactionElement = externalTransactionElemIter.next(); - externalTransactionCtx.put("externalTransactionID", UtilXml.childElementValue(externalTransactionElement, "ExternalTransactionID", "")); - externalTransactionCtx.put("externalTransactionTime", UtilXml.childElementValue(externalTransactionElement, "ExternalTransactionTime", "")); - externalTransactionCtx.put("feeOrCreditAmount", UtilXml.childElementValue(externalTransactionElement, "FeeOrCreditAmount", "0")); - externalTransactionCtx.put("paymentOrRefundAmount", UtilXml.childElementValue(externalTransactionElement, "PaymentOrRefundAmount", "0")); + externalTransactionCtx.put("externalTransactionID", UtilXml.childElementValue(externalTransactionElement, + "ExternalTransactionID", "")); + externalTransactionCtx.put("externalTransactionTime", UtilXml.childElementValue(externalTransactionElement, + "ExternalTransactionTime", "")); + externalTransactionCtx.put("feeOrCreditAmount", UtilXml.childElementValue(externalTransactionElement, + "FeeOrCreditAmount", "0")); + externalTransactionCtx.put("paymentOrRefundAmount", UtilXml.childElementValue(externalTransactionElement, + "PaymentOrRefundAmount", "0")); } orderCtx.put("externalTransactionCtx", externalTransactionCtx); @@ -848,7 +902,7 @@ public class EbayOrderServices { if (UtilValidate.isEmpty(productId)) { productId = UtilXml.childElementValue(itemElement, "ApplicationData", ""); if (UtilValidate.isEmpty(productId)) { - productId = EbayHelper.retrieveProductIdFromTitle(delegator, (String) orderItemCtx.get("title")); + productId = EbayHelper.retrieveProductIdFromTitle(delegator, (String) orderItemCtx.get("title")); } } orderItemCtx.put("productId", productId); @@ -888,7 +942,8 @@ public class EbayOrderServices { orderCtx.put("transactionPrice", UtilXml.childElementValue(transactionElement, "TransactionPrice", "0")); if (UtilValidate.isEmpty(shippingServiceSelectedCtx.get("shippingService").toString())) { - String shippingServiceMissingMsg = "Shipping Method is missing for eBay Order ID (" + orderCtx.get("externalId").toString() + ")"; + String shippingServiceMissingMsg = + "Shipping Method is missing for eBay Order ID (" + orderCtx.get("externalId").toString() + ")"; orderImportFailureMessageList.add(shippingServiceMissingMsg); } @@ -919,7 +974,8 @@ public class EbayOrderServices { return fetchedOrders; } - private static List<String> readGetMyeBaySellingResponse(String responseMsg, Locale locale, String productStoreId, Delegator delegator, LocalDispatcher dispatcher, StringBuffer errorMessage, GenericValue userLogin) { + private static List<String> readGetMyeBaySellingResponse(String responseMsg, Locale locale, String productStoreId, Delegator delegator, + LocalDispatcher dispatcher, StringBuffer errorMessage, GenericValue userLogin) { List<String> fetchDeletedOrdersAndTransactions = new LinkedList<>(); try { Document docResponse = UtilXml.readXmlDocument(responseMsg, true); @@ -984,7 +1040,8 @@ public class EbayOrderServices { return fetchDeletedOrdersAndTransactions; } - private static Map<String, Object> createShoppingCart(Delegator delegator, LocalDispatcher dispatcher, Locale locale, Map<String, Object> context, boolean create) { + private static Map<String, Object> createShoppingCart(Delegator delegator, LocalDispatcher dispatcher, Locale locale, + Map<String, Object> context, boolean create) { try { String productStoreId = (String) context.get("productStoreId"); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -1070,7 +1127,8 @@ public class EbayOrderServices { if (UtilValidate.isNotEmpty(shippingCost)) { double shippingAmount = Double.parseDouble(shippingCost); if (shippingAmount > 0) { - GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, shippingAmount, 0.0); + GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, + shippingAmount, 0.0); if (shippingAdjustment != null) { cart.addAdjustment(shippingAdjustment); } @@ -1081,7 +1139,8 @@ public class EbayOrderServices { if (UtilValidate.isNotEmpty(shippingTotalAdditionalCost)) { double shippingAdditionalCost = Double.parseDouble(shippingTotalAdditionalCost); if (shippingAdditionalCost > 0) { - GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost, 0.0); + GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, + null, shippingAdditionalCost, 0.0); if (shippingAdjustment != null) { cart.addAdjustment(shippingAdjustment); } @@ -1098,7 +1157,8 @@ public class EbayOrderServices { if (UtilValidate.isNotEmpty(salesTaxPercent)) { salesPercent = Double.parseDouble(salesTaxPercent); } - GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmountTotal, salesPercent); + GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, + salesTaxAmountTotal, salesPercent); if (salesTaxAdjustment != null) { cart.addAdjustment(salesTaxAdjustment); } @@ -1123,14 +1183,15 @@ public class EbayOrderServices { EbayHelper.correctCityStateCountry(dispatcher, shippingAddressCtx, city, state, country); List<GenericValue> shipInfo = - PartyWorker.findMatchingPersonPostalAddresses - (delegator, - shippingAddressCtx.get("shippingAddressStreet1").toString(), - (UtilValidate.isEmpty(shippingAddressCtx.get("shippingAddressStreet2")) ? null : shippingAddressCtx.get("shippingAddressStreet2").toString()), - shippingAddressCtx.get("city").toString(), - (UtilValidate.isEmpty(shippingAddressCtx.get("stateProvinceGeoId")) ? null : shippingAddressCtx.get("stateProvinceGeoId").toString()), - shippingAddressCtx.get("shippingAddressPostalCode").toString(), - null, shippingAddressCtx.get("countryGeoId").toString(), firstName, null, lastName); + PartyWorker.findMatchingPersonPostalAddresses(delegator, + shippingAddressCtx.get("shippingAddressStreet1").toString(),( + UtilValidate.isEmpty(shippingAddressCtx.get("shippingAddressStreet2")) ? null : shippingAddressCtx.get( + "shippingAddressStreet2").toString()), + shippingAddressCtx.get("city").toString(),( + UtilValidate.isEmpty(shippingAddressCtx.get("stateProvinceGeoId")) ? null : shippingAddressCtx.get( + "stateProvinceGeoId").toString()), + shippingAddressCtx.get("shippingAddressPostalCode").toString(), + null, shippingAddressCtx.get("countryGeoId").toString(), firstName, null, lastName); if (UtilValidate.isNotEmpty(shipInfo)) { GenericValue first = EntityUtil.getFirst(shipInfo); partyId = first.getString("partyId"); @@ -1222,7 +1283,8 @@ public class EbayOrderServices { Debug.logInfo("Created order with id: " + orderId, MODULE); if (UtilValidate.isNotEmpty(orderId)) { - String orderCreatedMsg = "Order created successfully with ID (" + orderId + ") & eBay Order ID associated with this order is (" + externalId + ")."; + String orderCreatedMsg = + "Order created successfully with ID (" + orderId + ") & eBay Order ID associated with this order is (" + externalId + ")."; orderImportSuccessMessageList.add(orderCreatedMsg); } @@ -1235,14 +1297,16 @@ public class EbayOrderServices { // create the payment from the preference if (approved) { Debug.logInfo("Creating payment for approved order.", MODULE); - EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId); + EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), + amountPaid, partyId); Debug.logInfo("Payment created.", MODULE); } } } } catch (Exception e) { Debug.logError("Exception in createShoppingCart: " + e.getMessage(), MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionInCreateShoppingCart", locale) + ": " + e.getMessage()); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionInCreateShoppingCart", locale) + ":" + + " " + e.getMessage()); } return ServiceUtil.returnSuccess(); } @@ -1250,10 +1314,10 @@ public class EbayOrderServices { // Made some changes transactionId removed. private static GenericValue externalOrderExists(Delegator delegator, String externalId) throws GenericEntityException { Debug.logInfo("Checking for existing externalId: " + externalId, MODULE); - EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("externalId", EntityComparisonOperator.EQUALS, externalId), EntityCondition.makeCondition("statusId", EntityComparisonOperator.NOT_EQUAL, "ORDER_CANCELLED")), EntityComparisonOperator.AND); - GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader") - .where(condition) - .cache(true).queryFirst(); + EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("externalId", + EntityComparisonOperator.EQUALS, externalId), EntityCondition.makeCondition("statusId", EntityComparisonOperator.NOT_EQUAL, + "ORDER_CANCELLED")), EntityComparisonOperator.AND); + GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where(condition).cache(true).queryFirst(); return orderHeader; } @@ -1290,7 +1354,8 @@ public class EbayOrderServices { BigDecimal newQuantity = previouslyAddedItemInCart.getQuantity().add(qty); previouslyAddedItemInCart.setQuantity(newQuantity, dispatcher, cart); } else { - int idx = cart.addItemToEnd(productId, null, qty, null, null, attrs, null, null, dispatcher, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE); + int idx = cart.addItemToEnd(productId, null, qty, null, null, attrs, null, null, dispatcher, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, + Boolean.TRUE); ShoppingCartItem cartItem = cart.findCartItem(idx); cartItem.setQuantity(qty, dispatcher, cart, true, false); // locate the price verify it matches the expected price @@ -1306,5 +1371,5 @@ public class EbayOrderServices { // assign the item to its ship group cart.setItemShipGroupQty(cartItem, qty, groupIdx); } - } + } } diff --git a/ebay/src/main/java/org/apache/ofbiz/ebay/ImportOrdersFromEbay.java b/ebay/src/main/java/org/apache/ofbiz/ebay/ImportOrdersFromEbay.java index 16859bd..35d379e 100755 --- a/ebay/src/main/java/org/apache/ofbiz/ebay/ImportOrdersFromEbay.java +++ b/ebay/src/main/java/org/apache/ofbiz/ebay/ImportOrdersFromEbay.java @@ -65,8 +65,11 @@ public class ImportOrdersFromEbay { Map<String, Object> eBayConfigResult = EbayHelper.buildEbayConfig(context, delegator); StringBuffer sellerTransactionsItemsXml = new StringBuffer(); - if (!ServiceUtil.isFailure(buildGetSellerTransactionsRequest(context, sellerTransactionsItemsXml, eBayConfigResult.get("token").toString()))) { - result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), sellerTransactionsItemsXml, eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), "GetSellerTransactions", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); + if (!ServiceUtil.isFailure(buildGetSellerTransactionsRequest(context, sellerTransactionsItemsXml, + eBayConfigResult.get("token").toString()))) { + result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), sellerTransactionsItemsXml, eBayConfigResult.get( + "devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), + "GetSellerTransactions", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); String success = (String) result.get(ModelService.SUCCESS_MESSAGE); if (success != null) { result = checkOrders(delegator, dispatcher, locale, context, success); @@ -74,7 +77,8 @@ public class ImportOrdersFromEbay { } } catch (Exception e) { Debug.logError("Exception in importOrdersSearchFromEbay " + e, MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionInImportOrdersSearchFromEbay", locale)); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionInImportOrdersSearchFromEbay", + locale)); } return result; @@ -143,7 +147,8 @@ public class ImportOrdersFromEbay { orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); if (orderHeader == null) { Debug.logError("Cannot find order with orderId [" + orderId + "]", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.errorRetrievingOrderFromOrderId", locale)); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.errorRetrievingOrderFromOrderId", + locale)); } if (!"EBAY_SALES_CHANNEL".equals(orderHeader.getString("salesChannelEnumId")) || orderHeader.getString("externalId") == null) { @@ -164,8 +169,11 @@ public class ImportOrdersFromEbay { StringBuffer completeSaleXml = new StringBuffer(); - if (!ServiceUtil.isFailure(buildCompleteSaleRequest(delegator, locale, externalId, transactionId, context, completeSaleXml, eBayConfigResult.get("token").toString()))) { - result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), completeSaleXml, eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), "CompleteSale", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); + if (!ServiceUtil.isFailure(buildCompleteSaleRequest(delegator, locale, externalId, transactionId, context, completeSaleXml, + eBayConfigResult.get("token").toString()))) { + result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), completeSaleXml, + eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), + "CompleteSale", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); String successMessage = (String) result.get("successMessage"); if (successMessage != null) { @@ -181,7 +189,8 @@ public class ImportOrdersFromEbay { return ServiceUtil.returnSuccess(); } - private static Map<String, Object> checkOrders(Delegator delegator, LocalDispatcher dispatcher, Locale locale, Map<String, Object> context, String response) { + private static Map<String, Object> checkOrders(Delegator delegator, LocalDispatcher dispatcher, Locale locale, Map<String, Object> context, + String response) { StringBuffer errorMessage = new StringBuffer(); List<Map<String, Object>> orders = readResponseFromEbay(response, locale, (String) context.get("productStoreId"), delegator, errorMessage); if (orders == null) { @@ -216,46 +225,51 @@ public class ImportOrdersFromEbay { String fromDate = (String) context.get("fromDate"); String thruDate = (String) context.get("thruDate"); try { - Document transDoc = UtilXml.makeEmptyXmlDocument("GetSellerTransactionsRequest"); - Element transElem = transDoc.getDocumentElement(); - transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); - - EbayHelper.appendRequesterCredentials(transElem, transDoc, token); - UtilXml.addChildElementValue(transElem, "DetailLevel", "ReturnAll", transDoc); - UtilXml.addChildElementValue(transElem, "IncludeContainingOrder", "true", transDoc); - - String fromDateOut = EbayHelper.convertDate(fromDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - if (fromDateOut != null) { - UtilXml.addChildElementValue(transElem, "ModTimeFrom", fromDateOut, transDoc); - } else { - Debug.logError("Cannot convert from date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertFromDate", locale)); - } - - - fromDateOut = EbayHelper.convertDate(thruDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - if (fromDateOut != null) { - UtilXml.addChildElementValue(transElem, "ModTimeTo", fromDateOut, transDoc); - } else { - Debug.logError("Cannot convert thru date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertThruDate", locale)); - } - //Debug.logInfo("The value of generated string is ======= " + UtilXml.writeXmlDocument(transDoc), MODULE); - dataItemsXml.append(UtilXml.writeXmlDocument(transDoc)); - } catch (Exception e) { - Debug.logError("Exception during building get seller transactions request", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionDuringBuildingGetSellerTransactionRequest", locale)); - } - return ServiceUtil.returnSuccess(); + Document transDoc = UtilXml.makeEmptyXmlDocument("GetSellerTransactionsRequest"); + Element transElem = transDoc.getDocumentElement(); + transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); + + EbayHelper.appendRequesterCredentials(transElem, transDoc, token); + UtilXml.addChildElementValue(transElem, "DetailLevel", "ReturnAll", transDoc); + UtilXml.addChildElementValue(transElem, "IncludeContainingOrder", "true", transDoc); + + String fromDateOut = EbayHelper.convertDate(fromDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + if (fromDateOut != null) { + UtilXml.addChildElementValue(transElem, "ModTimeFrom", fromDateOut, transDoc); + } else { + Debug.logError("Cannot convert from date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", + MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertFromDate", locale)); + } + + + fromDateOut = EbayHelper.convertDate(thruDate, "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + if (fromDateOut != null) { + UtilXml.addChildElementValue(transElem, "ModTimeTo", fromDateOut, transDoc); + } else { + Debug.logError("Cannot convert thru date from yyyy-MM-dd HH:mm:ss.SSS date format to yyyy-MM-dd'T'HH:mm:ss.SSS'Z' date format", + MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.cannotConvertThruDate", locale)); + } + //Debug.logInfo("The value of generated string is ======= " + UtilXml.writeXmlDocument(transDoc), MODULE); + dataItemsXml.append(UtilXml.writeXmlDocument(transDoc)); + } catch (Exception e) { + Debug.logError("Exception during building get seller transactions request", MODULE); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay" + + ".exceptionDuringBuildingGetSellerTransactionRequest", locale)); + } + return ServiceUtil.returnSuccess(); } - public static Map<String, Object> buildCompleteSaleRequest(Delegator delegator, Locale locale, String externalId, String transactionId, Map<String, Object> context, StringBuffer dataItemsXml, String token) { + public static Map<String, Object> buildCompleteSaleRequest(Delegator delegator, Locale locale, String externalId, String transactionId, + Map<String, Object> context, StringBuffer dataItemsXml, String token) { String paid = (String) context.get("paid"); String shipped = (String) context.get("shipped"); try { if (externalId == null) { - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.errorDuringBuildItemAndTransactionIdFromExternalId", locale)); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay" + + ".errorDuringBuildItemAndTransactionIdFromExternalId", locale)); } Document transDoc = UtilXml.makeEmptyXmlDocument("CompleteSaleRequest"); @@ -308,7 +322,8 @@ public class ImportOrdersFromEbay { dataItemsXml.append(UtilXml.writeXmlDocument(transDoc)); } catch (Exception e) { Debug.logError("Exception during building complete sale request", MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionDuringBuildingCompleteSaleRequest", locale)); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionDuringBuildingCompleteSaleRequest", + locale)); } return ServiceUtil.returnSuccess(); } @@ -334,7 +349,8 @@ public class ImportOrdersFromEbay { return ServiceUtil.returnSuccess(); } - private static List<Map<String, Object>> readResponseFromEbay(String msg, Locale locale, String productStoreId, Delegator delegator, StringBuffer errorMessage) { + private static List<Map<String, Object>> readResponseFromEbay(String msg, Locale locale, String productStoreId, Delegator delegator, + StringBuffer errorMessage) { List<Map<String, Object>> orders = null; try { Document docResponse = UtilXml.readXmlDocument(msg, true); @@ -399,7 +415,8 @@ public class ImportOrdersFromEbay { order.put("shippingAddressStreet1", UtilXml.childElementValue(shippingAddressElement, "Street1", "")); order.put("shippingAddressStreet2", UtilXml.childElementValue(shippingAddressElement, "Street2", "")); order.put("shippingAddressCityName", UtilXml.childElementValue(shippingAddressElement, "CityName", "")); - order.put("shippingAddressStateOrProvince", UtilXml.childElementValue(shippingAddressElement, "StateOrProvince", "")); + order.put("shippingAddressStateOrProvince", UtilXml.childElementValue(shippingAddressElement, + "StateOrProvince", "")); order.put("shippingAddressCountry", UtilXml.childElementValue(shippingAddressElement, "Country", "")); order.put("shippingAddressCountryName", UtilXml.childElementValue(shippingAddressElement, "CountryName", "")); order.put("shippingAddressPhone", UtilXml.childElementValue(shippingAddressElement, "Phone", "")); @@ -441,7 +458,8 @@ public class ImportOrdersFromEbay { order.put("jurisdictionID", UtilXml.childElementValue(taxJurisdictionElement, "JurisdictionID", "")); order.put("jurisdictionSalesTaxPercent", UtilXml.childElementValue(taxJurisdictionElement, "SalesTaxPercent", "0")); - order.put("jurisdictionShippingIncludedInTax", UtilXml.childElementValue(taxJurisdictionElement, "ShippingIncludedInTax", "0")); + order.put("jurisdictionShippingIncludedInTax", UtilXml.childElementValue(taxJurisdictionElement, + "ShippingIncludedInTax", "0")); } } } @@ -464,7 +482,7 @@ public class ImportOrdersFromEbay { if (UtilValidate.isEmpty(productId)) { productId = UtilXml.childElementValue(itemElement, "ApplicationData", ""); if (UtilValidate.isEmpty(productId)) { - productId = EbayHelper.retrieveProductIdFromTitle(delegator, (String) order.get("title")); + productId = EbayHelper.retrieveProductIdFromTitle(delegator, (String) order.get("title")); } } order.put("productId", productId); @@ -522,10 +540,12 @@ public class ImportOrdersFromEbay { Iterator<? extends Element> externalTransactionElemIter = externalTransaction.iterator(); while (externalTransactionElemIter.hasNext()) { Element externalTransactionElement = externalTransactionElemIter.next(); - order.put("externalTransactionID", UtilXml.childElementValue(externalTransactionElement, "ExternalTransactionID", "")); + order.put("externalTransactionID", UtilXml.childElementValue(externalTransactionElement, "ExternalTransactionID", + "")); order.put("externalTransactionTime", UtilXml.childElementValue(externalTransactionElement, "ExternalTransactionTime", "")); order.put("feeOrCreditAmount", UtilXml.childElementValue(externalTransactionElement, "FeeOrCreditAmount", "0")); - order.put("paymentOrRefundAmount", UtilXml.childElementValue(externalTransactionElement, "PaymentOrRefundAmount", "0")); + order.put("paymentOrRefundAmount", UtilXml.childElementValue(externalTransactionElement, "PaymentOrRefundAmount", + "0")); } // retrieve shipping service selected @@ -534,10 +554,12 @@ public class ImportOrdersFromEbay { while (shippingServiceSelectedElemIter.hasNext()) { Element shippingServiceSelectedElement = shippingServiceSelectedElemIter.next(); order.put("shippingService", UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingService", "")); - order.put("shippingServiceCost", UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingServiceCost", "0")); + order.put("shippingServiceCost", UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingServiceCost", + "0")); String incuranceCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingInsuranceCost", "0"); - String additionalCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingServiceAdditionalCost", "0"); + String additionalCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingServiceAdditionalCost", + "0"); String surchargeCost = UtilXml.childElementValue(shippingServiceSelectedElement, "ShippingSurcharge", "0"); double shippingInsuranceCost = 0; @@ -587,7 +609,8 @@ public class ImportOrdersFromEbay { return orders; } - private static Map<String, Object> createShoppingCart(Delegator delegator, LocalDispatcher dispatcher, Locale locale, Map<String, Object> parameters, boolean create) { + private static Map<String, Object> createShoppingCart(Delegator delegator, LocalDispatcher dispatcher, Locale locale, + Map<String, Object> parameters, boolean create) { try { String productStoreId = (String) parameters.get("productStoreId"); GenericValue userLogin = (GenericValue) parameters.get("userLogin"); @@ -683,7 +706,8 @@ public class ImportOrdersFromEbay { if (UtilValidate.isNotEmpty(shippingCost)) { double shippingAmount = Double.parseDouble(shippingCost); if (shippingAmount > 0) { - GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, shippingAmount, 0.0); + GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, + shippingAmount, 0.0); if (shippingAdjustment != null) { cart.addAdjustment(shippingAdjustment); } @@ -695,7 +719,8 @@ public class ImportOrdersFromEbay { if (UtilValidate.isNotEmpty(shippingTotalAdditionalCost)) { double shippingAdditionalCost = Double.parseDouble(shippingTotalAdditionalCost); if (shippingAdditionalCost > 0) { - GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost, 0.0); + GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, + null, shippingAdditionalCost, 0.0); if (shippingAdjustment != null) { cart.addAdjustment(shippingAdjustment); } @@ -712,7 +737,8 @@ public class ImportOrdersFromEbay { if (UtilValidate.isNotEmpty(salesTaxPercent)) { salesPercent = Double.parseDouble(salesTaxPercent); } - GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmountTotal, salesPercent); + GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, + salesTaxAmountTotal, salesPercent); if (salesTaxAdjustment != null) { cart.addAdjustment(salesTaxAdjustment); } @@ -727,7 +753,8 @@ public class ImportOrdersFromEbay { String contactMechId = ""; GenericValue partyAttribute = null; if (UtilValidate.isNotEmpty(parameters.get("eiasTokenBuyer"))) { - partyAttribute = EntityQuery.use(delegator).from("PartyAttribute").where("attrValue", parameters.get("eiasTokenBuyer")).queryFirst(); + partyAttribute = + EntityQuery.use(delegator).from("PartyAttribute").where("attrValue", parameters.get("eiasTokenBuyer")).queryFirst(); } // if we get a party, check its contact information. @@ -765,7 +792,8 @@ public class ImportOrdersFromEbay { Debug.logInfo("Creating new phone number for party: " + partyId, MODULE); EbayHelper.createPartyPhone(dispatcher, partyId, (String) parameters.get("shippingAddressPhone"), userLogin); Debug.logInfo("Creating association to eBay buyer for party: " + partyId, MODULE); - EbayHelper.createEbayCustomer(dispatcher, partyId, (String) parameters.get("ebayUserIdBuyer"), (String) parameters.get("eiasTokenBuyer"), userLogin); + EbayHelper.createEbayCustomer(dispatcher, partyId, (String) parameters.get("ebayUserIdBuyer"), (String) parameters.get( + "eiasTokenBuyer"), userLogin); String emailBuyer = (String) parameters.get("emailBuyer"); if (UtilValidate.isNotEmpty(emailBuyer) && !"Invalid Request".equalsIgnoreCase(emailBuyer)) { Debug.logInfo("Creating new email for party: " + partyId, MODULE); @@ -806,14 +834,16 @@ public class ImportOrdersFromEbay { // create the payment from the preference if (approved) { Debug.logInfo("Creating payment for approved order.", MODULE); - EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId); + EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), + amountPaid, partyId); Debug.logInfo("Payment created.", MODULE); } } } } catch (Exception e) { Debug.logError("Exception in createShoppingCart: " + e.getMessage(), MODULE); - return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionInCreateShoppingCart", locale) + ": " + e.getMessage()); + return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ordersImportFromEbay.exceptionInCreateShoppingCart", locale) + ":" + + " " + e.getMessage()); } return ServiceUtil.returnSuccess(); } @@ -821,11 +851,10 @@ public class ImportOrdersFromEbay { private static GenericValue externalOrderExists(Delegator delegator, String externalId) throws GenericEntityException { Debug.logInfo("Checking for existing externalId: " + externalId, MODULE); - EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("externalId", EntityComparisonOperator.EQUALS, externalId), EntityCondition.makeCondition("statusId", EntityComparisonOperator.NOT_EQUAL, "ORDER_CANCELLED")), EntityComparisonOperator.AND); - GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader") - .where(condition) - .cache(true) - .queryFirst(); + EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("externalId", + EntityComparisonOperator.EQUALS, externalId), EntityCondition.makeCondition("statusId", EntityComparisonOperator.NOT_EQUAL, + "ORDER_CANCELLED")), EntityComparisonOperator.AND); + GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where(condition).cache(true).queryFirst(); return orderHeader; } } diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayEvents.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayEvents.java index ab756e7..a8b1e1b 100644 --- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayEvents.java +++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayEvents.java @@ -714,7 +714,7 @@ public class EbayEvents { for (int i = 0; i < itemSpecificsSize; i++) { String name = nameSpecificList.get(i); String value = valueSpecificList.get(i); - String[] valueArray = new String[] { value }; + String[] valueArray = new String[] {value }; // set Name value list type. NameValueListType listType = new NameValueListType(); listType.setName(name); @@ -796,7 +796,7 @@ public class EbayEvents { shippingDetail.setShippingServiceOptions(shippingOptions); item.setShippingDetails(shippingDetail); attributeMapList.put("ShippingService", shippingService); - attributeMapList.put("ShippingServiceCost", ""+5.0); + attributeMapList.put("ShippingServiceCost", ""+ 5.0); attributeMapList.put("ShippingServiceCostCurrency", "USD"); attributeMapList.put("ShippingServicePriority", "1"); attributeMapList.put("ShippingType", "Flat"); diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java index 4d3aaa5..4f2b717 100644 --- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java +++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java @@ -864,7 +864,7 @@ public class EbayStore { } } } catch (GenericServiceException e) { - Debug.logError("error message"+e, MODULE); + Debug.logError("error message" + e.getMessage(), MODULE); } } @@ -1266,7 +1266,7 @@ public class EbayStore { String storeColorSchemeId = null; if (storeBasicTheme.indexOf("-") != -1) { storeThemeId = storeBasicTheme.substring(0, storeBasicTheme.indexOf("-")); - storeColorSchemeId = storeBasicTheme.substring(storeBasicTheme.indexOf("-")+1); + storeColorSchemeId = storeBasicTheme.substring(storeBasicTheme.indexOf("-") + 1); } if (storeColorSchemeId != null) storeColorScheme.setColorSchemeID(Integer.parseInt(storeColorSchemeId)); @@ -2517,9 +2517,9 @@ public class EbayStore { externalId = transaction.getTransactionID(); if ("0".equals(externalId)) { // this is a Chinese Auction: ItemID is used to uniquely identify the transaction - externalId = "EBS_"+itemId; + externalId = "EBS_" + itemId; } else { - externalId = "EBS_"+externalId; + externalId = "EBS_" + externalId; } if (UtilValidate.isNotEmpty(transaction.getCreatedDate())) { diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreHelper.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreHelper.java index 8046487..e947a5d 100644 --- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreHelper.java +++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreHelper.java @@ -711,7 +711,7 @@ public class EbayStoreHelper { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } } catch (Exception ex) { - Debug.logError("Error from create error log messages : "+ex.getMessage(), MODULE); + Debug.logError("Error from create error log messages : " + ex.getMessage(), MODULE); } } } diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreOptions.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreOptions.java index d713c7d..7b9b4d6 100644 --- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreOptions.java +++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreOptions.java @@ -80,7 +80,7 @@ public class EbayStoreOptions { StoreThemeType[] storeBasicTheme = returnedBasicThemeArray.getTheme(); int i = 0; - String colorSchemeId = themeId.substring(themeId.indexOf("-")+1); + String colorSchemeId = themeId.substring(themeId.indexOf("-") + 1); themeId = themeId.substring(0, themeId.indexOf("-")); Map<String, Object> storeColorSchemeMap = new HashMap<>(); diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreOrder.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreOrder.java index 04f992e..641f362 100644 --- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreOrder.java +++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStoreOrder.java @@ -422,7 +422,7 @@ public class EbayStoreOrder { if (UtilValidate.isNotEmpty(shippingAddressCtx)) { String buyerName = (String) shippingAddressCtx.get("buyerName"); String firstName = buyerName.substring(0, buyerName.indexOf(" ")); - String lastName = buyerName.substring(buyerName.indexOf(" ")+1); + String lastName = buyerName.substring(buyerName.indexOf(" ") + 1); String country = (String) shippingAddressCtx.get("shippingAddressCountry"); String state = (String) shippingAddressCtx.get("shippingAddressStateOrProvince"); diff --git a/lucene/src/main/java/org/apache/ofbiz/content/search/ProductDocument.java b/lucene/src/main/java/org/apache/ofbiz/content/search/ProductDocument.java index 2fb7cf8..5662b86 100644 --- a/lucene/src/main/java/org/apache/ofbiz/content/search/ProductDocument.java +++ b/lucene/src/main/java/org/apache/ofbiz/content/search/ProductDocument.java @@ -308,8 +308,7 @@ public class ProductDocument implements LuceneDocument { private static final EntityCondition THRU_DATE_ONLY_CONDITION = EntityCondition.makeCondition( EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, - EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp()) - ); + EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp())); private static List<GenericValue> filterByThruDate(List<GenericValue> values) { return EntityUtil.filterByCondition(values, THRU_DATE_ONLY_CONDITION); @@ -319,8 +318,7 @@ public class ProductDocument implements LuceneDocument { return EntityUtil.filterByCondition(values, EntityCondition.makeCondition( EntityCondition.makeCondition(thruDateName, EntityOperator.EQUALS, null), EntityOperator.OR, - EntityCondition.makeCondition(thruDateName, EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp()) - )); + EntityCondition.makeCondition(thruDateName, EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp()))); } private Timestamp populateCategoryData(Document doc, GenericValue product) throws GenericEntityException { @@ -377,8 +375,7 @@ public class ProductDocument implements LuceneDocument { doc.add(new StringField("productCategoryId", parentProductCategory.getString("productCategoryId"), Field.Store.NO)); nextReIndex = checkSetNextReIndex( this.getParentCategories(doc, parentProductCategory, indexedCategoryIds), - nextReIndex - ); + nextReIndex); } return nextReIndex; } diff --git a/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java b/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java index 3c32749..3dbf58f 100644 --- a/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java +++ b/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java @@ -389,29 +389,29 @@ public class GitHubAuthenticator implements Authenticator { httpGet.setHeader(PassportUtil.AUTHORIZATION_HEADER, tokenType + " " + accessToken); httpGet.setHeader(PassportUtil.ACCEPT_HEADER, "application/json"); CloseableHttpResponse getResponse = null; - try { - getResponse = jsonClient.execute(httpGet); + try { + getResponse = jsonClient.execute(httpGet); String responseString = new BasicResponseHandler().handleResponse(getResponse); - if (getResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { - // Debug.logInfo("Json Response from GitHub: " + responseString, MODULE); - userInfo = JSON.from(responseString); - } else { - String errMsg = UtilProperties.getMessage(RESOURCE, "GetOAuth2AccessTokenError", UtilMisc.toMap("error", responseString), locale); - throw new AuthenticatorException(errMsg); - } - } catch (ClientProtocolException e) { + if (getResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + // Debug.logInfo("Json Response from GitHub: " + responseString, MODULE); + userInfo = JSON.from(responseString); + } else { + String errMsg = UtilProperties.getMessage(RESOURCE, "GetOAuth2AccessTokenError", UtilMisc.toMap("error", responseString), locale); + throw new AuthenticatorException(errMsg); + } + } catch (ClientProtocolException e) { throw new AuthenticatorException(e.getMessage()); - } catch (IOException e) { + } catch (IOException e) { throw new AuthenticatorException(e.getMessage()); - } finally { - if (getResponse != null) { - try { - getResponse.close(); - } catch (IOException e) { - // do nothing - } - } - } + } finally { + if (getResponse != null) { + try { + getResponse.close(); + } catch (IOException e) { + // do nothing + } + } + } JSONToMap jsonMap = new JSONToMap(); Map<String, Object> userMap; try { diff --git a/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java b/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java index ed45a7f..04bd2e3 100644 --- a/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java +++ b/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java @@ -284,44 +284,44 @@ public class HtmlReport extends AbstractReport { StringBuffer buf = null; value = ReportStringUtil.escapeJavaScript(value); switch (format) { - case FORMAT_HEADLINE: - buf = new StringBuffer(); - buf.append("aH('"); - buf.append(value); - buf.append("'); "); - break; - case FORMAT_WARNING: - buf = new StringBuffer(); - buf.append("aW('"); - buf.append(value); - buf.append("'); "); - addWarning(value); - break; - case FORMAT_ERROR: - buf = new StringBuffer(); - buf.append("aE('"); - buf.append(value); - buf.append("'); "); - addError(value); - break; - case FORMAT_NOTE: - buf = new StringBuffer(); - buf.append("aN('"); - buf.append(value); - buf.append("'); "); - break; - case FORMAT_OK: - buf = new StringBuffer(); - buf.append("aO('"); - buf.append(value); - buf.append("'); "); - break; - case FORMAT_DEFAULT: - default: - buf = new StringBuffer(); - buf.append("a('"); - buf.append(value); - buf.append("'); "); + case FORMAT_HEADLINE: + buf = new StringBuffer(); + buf.append("aH('"); + buf.append(value); + buf.append("'); "); + break; + case FORMAT_WARNING: + buf = new StringBuffer(); + buf.append("aW('"); + buf.append(value); + buf.append("'); "); + addWarning(value); + break; + case FORMAT_ERROR: + buf = new StringBuffer(); + buf.append("aE('"); + buf.append(value); + buf.append("'); "); + addError(value); + break; + case FORMAT_NOTE: + buf = new StringBuffer(); + buf.append("aN('"); + buf.append(value); + buf.append("'); "); + break; + case FORMAT_OK: + buf = new StringBuffer(); + buf.append("aO('"); + buf.append(value); + buf.append("'); "); + break; + case FORMAT_DEFAULT: + default: + buf = new StringBuffer(); + buf.append("a('"); + buf.append(value); + buf.append("'); "); } if (value.trim().endsWith(getLineBreak())) { buf.append("aB(); "); @@ -329,41 +329,41 @@ public class HtmlReport extends AbstractReport { content.add(buf.toString()); switch (format) { - case FORMAT_HEADLINE: - buf = new StringBuffer(); - buf.append("<span class='head'>"); - buf.append(value); - buf.append("</span>"); - break; - case FORMAT_WARNING: - buf = new StringBuffer(); - buf.append("<span class='warn'>"); - buf.append(value); - buf.append("</span>"); - addWarning(value); - break; - case FORMAT_ERROR: - buf = new StringBuffer(); - buf.append("<span class='err'>"); - buf.append(value); - buf.append("</span>"); - addError(value); - break; - case FORMAT_NOTE: - buf = new StringBuffer(); - buf.append("<span class='note'>"); - buf.append(value); - buf.append("</span>"); - break; - case FORMAT_OK: - buf = new StringBuffer(); - buf.append("<span class='ok'>"); - buf.append(value); - buf.append("</span>"); - break; - case FORMAT_DEFAULT: - default: - buf = new StringBuffer(value); + case FORMAT_HEADLINE: + buf = new StringBuffer(); + buf.append("<span class='head'>"); + buf.append(value); + buf.append("</span>"); + break; + case FORMAT_WARNING: + buf = new StringBuffer(); + buf.append("<span class='warn'>"); + buf.append(value); + buf.append("</span>"); + addWarning(value); + break; + case FORMAT_ERROR: + buf = new StringBuffer(); + buf.append("<span class='err'>"); + buf.append(value); + buf.append("</span>"); + addError(value); + break; + case FORMAT_NOTE: + buf = new StringBuffer(); + buf.append("<span class='note'>"); + buf.append(value); + buf.append("</span>"); + break; + case FORMAT_OK: + buf = new StringBuffer(); + buf.append("<span class='ok'>"); + buf.append(value); + buf.append("</span>"); + break; + case FORMAT_DEFAULT: + default: + buf = new StringBuffer(value); } if (value.trim().endsWith(getLineBreak())) { buf.append("\n"); @@ -951,116 +951,116 @@ public class HtmlReport extends AbstractReport { protected void dialogButtonsHtml(StringBuffer result, int button, String attribute) { attribute = appendDelimiter(attribute); switch (button) { - case BUTTON_OK: - result.append("<input name=\"ok\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_OK", getLocale()) + "\""); - if (attribute.toLowerCase().indexOf("onclick") == -1) { - result.append(" type=\"submit\""); - } else { - result.append(" type=\"button\""); - } - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_CANCEL: - result.append("<input name=\"cancel\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_CANCEL", getLocale()) + "\""); - if (attribute.toLowerCase().indexOf("onclick") == -1) { - result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\""); - } - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_EDIT: - result.append("<input name=\"ok\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_EDIT", getLocale()) + "\""); - if (attribute.toLowerCase().indexOf("onclick") == -1) { - result.append(" type=\"submit\""); - } else { - result.append(" type=\"button\""); - } - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_DISCARD: - result.append("<input name=\"cancel\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_DISCARD", getLocale()) + "\""); - if (attribute.toLowerCase().indexOf("onclick") == -1) { - result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\""); - } - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_CLOSE: - result.append("<input name=\"close\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_CLOSE", getLocale()) + "\""); - if (attribute.toLowerCase().indexOf("onclick") == -1) { - result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\""); - } - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_ADVANCED: - result.append("<input name=\"advanced\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_ADVANCE", getLocale()) + "\""); - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_SET: - result.append("<input name=\"set\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_SET", getLocale()) + "\""); - if (attribute.toLowerCase().indexOf("onclick") == -1) { - result.append(" onclick=\"submitAction('" + DIALOG_SET + "', form);\""); - } - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_BACK: - result.append("<input name=\"set\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_BACK", getLocale()) + "\""); - if (attribute.toLowerCase().indexOf("onclick") == -1) { - result.append(" onclick=\"submitAction('" + DIALOG_BACK + "', form);\""); - } - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_CONTINUE: - result.append("<input name=\"set\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_CONTINUE", getLocale()) + "\""); - if (attribute.toLowerCase().indexOf("onclick") == -1) { - result.append(" onclick=\"submitAction('" + DIALOG_CONTINUE + "', form);\""); - } - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_DETAILS: - result.append("<input name=\"details\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_DETAIL", getLocale()) + "\""); - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - case BUTTON_DOWNLOAD: - result.append("<input name=\"download\" type=\"button\" value=\""); - result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_DOWNLOAD", getLocale()) + "\""); - result.append(" class=\"dialogbutton\""); - result.append(attribute); - result.append(">\n"); - break; - default: - // not a valid button code, just insert a warning in the HTML - result.append("<!-- invalid button code: "); - result.append(button); - result.append(" -->\n"); + case BUTTON_OK: + result.append("<input name=\"ok\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_OK", getLocale()) + "\""); + if (attribute.toLowerCase().indexOf("onclick") == -1) { + result.append(" type=\"submit\""); + } else { + result.append(" type=\"button\""); + } + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_CANCEL: + result.append("<input name=\"cancel\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_CANCEL", getLocale()) + "\""); + if (attribute.toLowerCase().indexOf("onclick") == -1) { + result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\""); + } + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_EDIT: + result.append("<input name=\"ok\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_EDIT", getLocale()) + "\""); + if (attribute.toLowerCase().indexOf("onclick") == -1) { + result.append(" type=\"submit\""); + } else { + result.append(" type=\"button\""); + } + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_DISCARD: + result.append("<input name=\"cancel\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_DISCARD", getLocale()) + "\""); + if (attribute.toLowerCase().indexOf("onclick") == -1) { + result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\""); + } + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_CLOSE: + result.append("<input name=\"close\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_CLOSE", getLocale()) + "\""); + if (attribute.toLowerCase().indexOf("onclick") == -1) { + result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\""); + } + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_ADVANCED: + result.append("<input name=\"advanced\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_ADVANCE", getLocale()) + "\""); + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_SET: + result.append("<input name=\"set\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_SET", getLocale()) + "\""); + if (attribute.toLowerCase().indexOf("onclick") == -1) { + result.append(" onclick=\"submitAction('" + DIALOG_SET + "', form);\""); + } + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_BACK: + result.append("<input name=\"set\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_BACK", getLocale()) + "\""); + if (attribute.toLowerCase().indexOf("onclick") == -1) { + result.append(" onclick=\"submitAction('" + DIALOG_BACK + "', form);\""); + } + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_CONTINUE: + result.append("<input name=\"set\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_CONTINUE", getLocale()) + "\""); + if (attribute.toLowerCase().indexOf("onclick") == -1) { + result.append(" onclick=\"submitAction('" + DIALOG_CONTINUE + "', form);\""); + } + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_DETAILS: + result.append("<input name=\"details\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_DETAIL", getLocale()) + "\""); + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + case BUTTON_DOWNLOAD: + result.append("<input name=\"download\" type=\"button\" value=\""); + result.append(UtilProperties.getMessage(RESOURCE, "DIALOG_BUTTON_DOWNLOAD", getLocale()) + "\""); + result.append(" class=\"dialogbutton\""); + result.append(attribute); + result.append(">\n"); + break; + default: + // not a valid button code, just insert a warning in the HTML + result.append("<!-- invalid button code: "); + result.append(button); + result.append(" -->\n"); } } diff --git a/pricat/src/main/java/org/apache/ofbiz/htmlreport/util/ReportEncoder.java b/pricat/src/main/java/org/apache/ofbiz/htmlreport/util/ReportEncoder.java index eb44bc6..ac50900 100644 --- a/pricat/src/main/java/org/apache/ofbiz/htmlreport/util/ReportEncoder.java +++ b/pricat/src/main/java/org/apache/ofbiz/htmlreport/util/ReportEncoder.java @@ -524,31 +524,31 @@ public final class ReportEncoder { for (int i = 0; i < source.length(); ++i) { char ch = source.charAt(i); switch (ch) { - case '<': - result.append("<"); - break; - case '>': - result.append(">"); - break; - case '&': - // don't escape already escaped international and special characters - if (!doubleEscape) { - int terminatorIndex = source.indexOf(";", i); - if (terminatorIndex > 0) { - if (source.substring(i + 1, terminatorIndex).matches("#[0-9]+")) { - result.append(ch); - break; - } + case '<': + result.append("<"); + break; + case '>': + result.append(">"); + break; + case '&': + // don't escape already escaped international and special characters + if (!doubleEscape) { + int terminatorIndex = source.indexOf(";", i); + if (terminatorIndex > 0) { + if (source.substring(i + 1, terminatorIndex).matches("#[0-9]+")) { + result.append(ch); + break; } } - // note that to other "break" in the above "if" block - result.append("&"); - break; - case '"': - result.append("""); - break; - default: - result.append(ch); + } + // note that to other "break" in the above "if" block + result.append("&"); + break; + case '"': + result.append("""); + break; + default: + result.append(ch); } } return new String(result); diff --git a/pricat/src/main/java/org/apache/ofbiz/htmlreport/util/ReportStringUtil.java b/pricat/src/main/java/org/apache/ofbiz/htmlreport/util/ReportStringUtil.java index b77ebce..b5b2c3d 100644 --- a/pricat/src/main/java/org/apache/ofbiz/htmlreport/util/ReportStringUtil.java +++ b/pricat/src/main/java/org/apache/ofbiz/htmlreport/util/ReportStringUtil.java @@ -53,8 +53,8 @@ public final class ReportStringUtil { /** Second constant. */ private static final long SECONDS = 1000; - /** - * Default constructor (empty), private because this class has only + /** + * Default constructor (empty), private because this class has only * static methods.<p> */ private ReportStringUtil() { @@ -148,53 +148,53 @@ public final class ReportStringUtil { for (int i = 0; i < source.length(); ++i) { char ch = source.charAt(i); switch (ch) { - case '\\': - result.append("\\\\"); - break; - case '/': - result.append("\\/"); - break; - case '$': - result.append("\\$"); - break; - case '^': - result.append("\\^"); - break; - case '.': - result.append("\\."); - break; - case '*': - result.append("\\*"); - break; - case '+': - result.append("\\+"); - break; - case '|': - result.append("\\|"); - break; - case '?': - result.append("\\?"); - break; - case '{': - result.append("\\{"); - break; - case '}': - result.append("\\}"); - break; - case '[': - result.append("\\["); - break; - case ']': - result.append("\\]"); - break; - case '(': - result.append("\\("); - break; - case ')': - result.append("\\)"); - break; - default: - result.append(ch); + case '\\': + result.append("\\\\"); + break; + case '/': + result.append("\\/"); + break; + case '$': + result.append("\\$"); + break; + case '^': + result.append("\\^"); + break; + case '.': + result.append("\\."); + break; + case '*': + result.append("\\*"); + break; + case '+': + result.append("\\+"); + break; + case '|': + result.append("\\|"); + break; + case '?': + result.append("\\?"); + break; + case '{': + result.append("\\{"); + break; + case '}': + result.append("\\}"); + break; + case '[': + result.append("\\["); + break; + case ']': + result.append("\\]"); + break; + case '(': + result.append("\\("); + break; + case ')': + result.append("\\)"); + break; + default: + result.append(ch); } } return new String(result); @@ -407,7 +407,7 @@ public final class ReportStringUtil { /** * Returns the java String literal for the given String. <p> - * This is the form of the String that had to be written into source code + * This is the form of the String that had to be written into source code * using the unicode escape sequence for special characters. <p> * Example: "�" would be transformed to "\\u00C4".<p> * @param s a string that may contain non-ascii characters diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java index 4b9ddd5..7bd1d9e 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java @@ -272,23 +272,23 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { CellType cellType = cell.getCellType(); newCell.setCellType(cellType); switch (cellType) { - case BOOLEAN: - newCell.setCellValue(cell.getBooleanCellValue()); - break; - case ERROR: - newCell.setCellErrorValue(cell.getErrorCellValue()); - break; - case FORMULA: - newCell.setCellFormula(cell.getCellFormula()); - break; - case NUMERIC: - newCell.setCellValue(cell.getNumericCellValue()); - break; - case STRING: - newCell.setCellValue(cell.getRichStringCellValue()); - break; - default: - newCell.setCellValue(formatter.formatCellValue(cell)); + case BOOLEAN: + newCell.setCellValue(cell.getBooleanCellValue()); + break; + case ERROR: + newCell.setCellErrorValue(cell.getErrorCellValue()); + break; + case FORMULA: + newCell.setCellFormula(cell.getCellFormula()); + break; + case NUMERIC: + newCell.setCellValue(cell.getNumericCellValue()); + break; + case STRING: + newCell.setCellValue(cell.getRichStringCellValue()); + break; + default: + newCell.setCellValue(formatter.formatCellValue(cell)); } if (cell.getCellComment() != null) { XSSFClientAnchor anchor = factory.createClientAnchor(); diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java index a657a6e..ded8c4f 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java @@ -241,9 +241,9 @@ public class SamplePricatParser extends AbstractPricatParser { return false; } switch (pricatFileVersion) { - case "V1.1": - default: - return parseCellContentsAndStoreV1_X(row, cellContents); + case "V1.1": + default: + return parseCellContentsAndStoreV1_X(row, cellContents); } } @@ -467,9 +467,9 @@ public class SamplePricatParser extends AbstractPricatParser { */ private static List<Object[]> genExcelHeaderNames(String version) { switch (version) { - case "V1.1": - default: - return genExcelHeaderNamesV1_1(); + case "V1.1": + default: + return genExcelHeaderNamesV1_1(); } } diff --git a/solr/src/main/java/org/apache/ofbiz/solr/ProductUtil.java b/solr/src/main/java/org/apache/ofbiz/solr/ProductUtil.java index 6cc6550..a16cfd8 100644 --- a/solr/src/main/java/org/apache/ofbiz/solr/ProductUtil.java +++ b/solr/src/main/java/org/apache/ofbiz/solr/ProductUtil.java @@ -68,17 +68,21 @@ public final class ProductUtil { if (productId != null) { dispatchContext.put("productId", productId); // if (product.get("sku") != null) dispatchContext.put("sku", product.get("sku")); - if (product.get("internalName") != null) + if (product.get("internalName") != null) { dispatchContext.put("internalName", product.get("internalName")); + } String smallImage = (String) product.get("smallImageUrl"); - if (smallImage != null) + if (smallImage != null) { dispatchContext.put("smallImage", smallImage); + } String mediumImage = (String) product.get("mediumImageUrl"); - if (mediumImage != null) + if (mediumImage != null) { dispatchContext.put("mediumImage", mediumImage); + } String largeImage = (String) product.get("largeImageUrl"); - if (largeImage != null) + if (largeImage != null) { dispatchContext.put("largeImage", largeImage); + } // if (product.get("productWeight") != null) dispatchContext.put("weight", ""); // Trying to set a correctand trail @@ -100,7 +104,7 @@ public final class ProductUtil { i++; } catMember.append(trailString); - String cm = i +"/"+ catMember.toString(); + String cm = i + "/" + catMember.toString(); if (!trails.contains(cm)) { //Debug.logInfo("cm : "+cm, MODULE); trails.add(cm); @@ -116,9 +120,11 @@ public final class ProductUtil { for (String trail : trails) { String productCategoryId = (trail.split("/").length > 0) ? trail.split("/")[1] : trail; List<String> catalogMembers = CategoryUtil.getCatalogIdsByCategoryId(delegator, productCategoryId); - for (String catalogMember : catalogMembers) - if (!catalogs.contains(catalogMember)) + for (String catalogMember : catalogMembers) { + if (!catalogs.contains(catalogMember)) { catalogs.add(catalogMember); + } + } } dispatchContext.put("catalog", catalogs); @@ -146,55 +152,67 @@ public final class ProductUtil { dispatchContext.put("inStock", inStock); Boolean isVirtual = ProductWorker.isVirtual(delegator, productId); - if (isVirtual) + if (isVirtual) { dispatchContext.put("isVirtual", isVirtual); + } Boolean isDigital = ProductWorker.isDigital(product); - if (isDigital) + if (isDigital) { dispatchContext.put("isDigital", isDigital); + } Boolean isPhysical = ProductWorker.isPhysical(product); - if (isPhysical) + if (isPhysical) { dispatchContext.put("isPhysical", isPhysical); + } Map<String, String> title = new HashMap<>(); String detitle = productContentDe.get("PRODUCT_NAME", "html").toString(); - if (detitle != null) + if (detitle != null) { title.put("de", detitle); - else if (product.get("productName") != null) + } else if (product.get("productName") != null) { title.put("de", (String) product.get("productName")); + } String entitle = productContentEn.get("PRODUCT_NAME", "html").toString(); - if (entitle != null) + if (entitle != null) { title.put("en", entitle); - else if (product.get("productName") != null) + } else if (product.get("productName") != null) { title.put("en", (String) product.get("productName")); + } String frtitle = productContentFr.get("PRODUCT_NAME", "html").toString(); - if (frtitle != null) + if (frtitle != null) { title.put("fr", frtitle); - else if (product.get("productName") != null) + } else if (product.get("productName") != null) { title.put("fr", (String) product.get("productName")); + } dispatchContext.put("title", title); Map<String, String> description = new HashMap<>(); String dedescription = productContentDe.get("DESCRIPTION", "html").toString(); - if (dedescription != null) + if (dedescription != null) { description.put("de", dedescription); + } String endescription = productContentEn.get("DESCRIPTION", "html").toString(); - if (endescription != null) + if (endescription != null) { description.put("en", endescription); + } String frdescription = productContentFr.get("DESCRIPTION", "html").toString(); - if (frdescription != null) + if (frdescription != null) { description.put("fr", frdescription); + } dispatchContext.put("description", description); Map<String, String> longDescription = new HashMap<>(); String delongDescription = productContentDe.get("LONG_DESCRIPTION", "html").toString(); - if (delongDescription != null) + if (delongDescription != null) { longDescription.put("de", delongDescription); + } String enlongDescription = productContentEn.get("LONG_DESCRIPTION", "html").toString(); - if (enlongDescription != null) + if (enlongDescription != null) { longDescription.put("en", enlongDescription); + } String frlongDescription = productContentFr.get("LONG_DESCRIPTION", "html").toString(); - if (frlongDescription != null) + if (frlongDescription != null) { longDescription.put("fr", frlongDescription); + } dispatchContext.put("longDescription", longDescription); // dispatchContext.put("comments", ""); @@ -204,11 +222,13 @@ public final class ProductUtil { if ("AGGREGATED".equals(product.getString("productTypeId"))) { ProductConfigWrapper configWrapper = new ProductConfigWrapper(delegator, dispatcher, productId, null, null, null, null, locale, userLogin); String listPrice = configWrapper.getTotalListPrice().setScale(2, RoundingMode.HALF_DOWN).toString(); - if (listPrice != null) + if (listPrice != null) { dispatchContext.put("listPrice", listPrice); + } String defaultPrice = configWrapper.getTotalListPrice().setScale(2, RoundingMode.HALF_DOWN).toString(); - if (defaultPrice != null) + if (defaultPrice != null) { dispatchContext.put("defaultPrice", defaultPrice); + } } else { Map<String, GenericValue> priceContext = UtilMisc.toMap("product", product); Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", priceContext); diff --git a/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java b/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java index cdace10..4ad50b5 100644 --- a/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java +++ b/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java @@ -145,13 +145,11 @@ public abstract class SolrProductSearch { final String statusStr = UtilProperties.getMessage(RESOURCE, "SolrDocumentForProductIdAddedToSolrIndex", UtilMisc.toMap("productId", context.get("productId")), locale); Debug.logInfo("Solr: " + statusStr, MODULE); result = ServiceUtil.returnSuccess(statusStr); - } - catch (MalformedURLException e) { + } catch (MalformedURLException e) { Debug.logError(e, e.getMessage(), MODULE); result = ServiceUtil.returnError(e.toString()); result.put("errorType", "urlError"); - } - catch (SolrServerException e) { + } catch (SolrServerException e) { if (e.getCause() != null && e.getCause() instanceof ConnectException) { final String statusStr = UtilProperties.getMessage(RESOURCE, "SolrFailureConnectingToSolrServerToCommitProductId", UtilMisc.toMap("productId", context.get("productId")), locale); @@ -168,18 +166,15 @@ public abstract class SolrProductSearch { result = ServiceUtil.returnError(e.toString()); result.put("errorType", "solrServerError"); } - } - catch (IOException e) { + } catch (IOException e) { Debug.logError(e, e.getMessage(), MODULE); result = ServiceUtil.returnError(e.toString()); result.put("errorType", "ioError"); - } - finally { + } finally { if (client != null) { try { client.close(); - } - catch (IOException e) { + } catch (IOException e) { // do nothing } } @@ -222,13 +217,11 @@ public abstract class SolrProductSearch { final String statusStr = UtilProperties.getMessage(RESOURCE, "SolrAddedDocumentsToSolrIndex", UtilMisc.toMap("fieldList", fieldList.size()), locale); Debug.logInfo("Solr: " + statusStr, MODULE); result = ServiceUtil.returnSuccess(statusStr); - } - catch (MalformedURLException e) { + } catch (MalformedURLException e) { Debug.logError(e, e.getMessage(), MODULE); result = ServiceUtil.returnError(e.toString()); result.put("errorType", "urlError"); - } - catch (SolrServerException e) { + } catch (SolrServerException e) { if (e.getCause() != null && e.getCause() instanceof ConnectException) { final String statusStr = UtilProperties.getMessage(RESOURCE, "SolrFailureConnectingToSolrServerToCommitProductList", UtilMisc.toMap("productId", context.get("productId")), locale); @@ -245,18 +238,15 @@ public abstract class SolrProductSearch { result = ServiceUtil.returnError(e.toString()); result.put("errorType", "solrServerError"); } - } - catch (IOException e) { + } catch (IOException e) { Debug.logError(e, e.getMessage(), MODULE); result = ServiceUtil.returnError(e.toString()); result.put("errorType", "ioError"); - } - finally { + } finally { if (client != null) { try { client.close(); - } - catch (IOException e) { + } catch (IOException e) { // do nothing } } @@ -358,17 +348,14 @@ public abstract class SolrProductSearch { QueryResponse rsp = client.query(solrQuery); result = ServiceUtil.returnSuccess(); result.put("queryResult", rsp); - } - catch (Exception e) { + } catch (Exception e) { Debug.logError(e, e.getMessage(), MODULE); result = ServiceUtil.returnError(e.toString()); - } - finally { + } finally { if (client != null) { try { client.close(); - } - catch (IOException e) { + } catch (IOException e) { // do nothing } } @@ -419,8 +406,7 @@ public abstract class SolrProductSearch { } else { result = ServiceUtil.returnFailure(); } - } - catch (Exception e) { + } catch (Exception e) { Debug.logError(e, e.getMessage(), MODULE); result = ServiceUtil.returnError(e.toString()); } @@ -505,8 +491,7 @@ public abstract class SolrProductSearch { result.put("viewSize", queryResult.getResults().size()); result.put("suggestions", suggestions); - } - catch (Exception e) { + } catch (Exception e) { Debug.logError(e, e.getMessage(), MODULE); result = ServiceUtil.returnError(e.toString()); } @@ -561,8 +546,7 @@ public abstract class SolrProductSearch { // Debug.logInfo("The returned map is this:" + result, MODULE); } } - } - catch (Exception e) { + } catch (Exception e) { result = ServiceUtil.returnError(e.toString()); result.put("numFound", (long) 0); } @@ -635,8 +619,7 @@ public abstract class SolrProductSearch { result.put("categories", catLevel); result.put("numFound", (long) 0); - } - catch (Exception e) { + } catch (Exception e) { result = ServiceUtil.returnError(e.toString()); result.put("numFound", (long) 0); } @@ -703,8 +686,7 @@ public abstract class SolrProductSearch { } catch (IOException | GenericServiceException e) { Debug.logError(e, e.getMessage(), MODULE); result = ServiceUtil.returnError(e.toString()); - } - catch (SolrServerException e) { + } catch (SolrServerException e) { if (e.getCause() != null && e.getCause() instanceof ConnectException) { final String statusStr = UtilProperties.getMessage(RESOURCE, "SolrFailureConnectingToSolrServerToRebuildIndex", locale); if (Boolean.TRUE.equals(treatConnectErrorNonFatal)) { @@ -722,8 +704,7 @@ public abstract class SolrProductSearch { if (client != null) { try { client.close(); - } - catch (IOException e) { + } catch (IOException e) { // do nothing } } diff --git a/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java b/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java index 7a9a013..ad9041e 100644 --- a/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java +++ b/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java @@ -121,7 +121,7 @@ public final class SolrUtil { Boolean ecaEnabled = null; String sysProp = System.getProperty("ofbiz.solr.eca.enabled"); if (UtilValidate.isNotEmpty(sysProp)) { - if ("true".equalsIgnoreCase(sysProp)) { + if ("true".equalsIgnoreCase(sysProp)) { ecaEnabled = Boolean.TRUE; } else if ("false".equalsIgnoreCase(sysProp)) { diff --git a/webpos/src/main/java/org/apache/ofbiz/webpos/WebPosEvents.java b/webpos/src/main/java/org/apache/ofbiz/webpos/WebPosEvents.java index 00284cf..8517ea4 100755 --- a/webpos/src/main/java/org/apache/ofbiz/webpos/WebPosEvents.java +++ b/webpos/src/main/java/org/apache/ofbiz/webpos/WebPosEvents.java @@ -51,7 +51,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class WebPosEvents { - public static String MODULE = WebPosEvents.class.getName(); + private static final String MODULE = WebPosEvents.class.getName(); public static String posLogin(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException { HttpSession session = request.getSession(true); |
Free forum by Nabble | Edit this page |