|
Author: mrisaliti
Date: Tue Jan 18 18:54:55 2011 New Revision: 1060536 URL: http://svn.apache.org/viewvc?rev=1060536&view=rev Log: Internationalization of ServiceUtil.returnSuccess, ServiceUtil.returnFailure, ServiceUtil.returnError (OFBIZ-4091) Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=1060536&r1=1060535&r2=1060536&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original) +++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Tue Jan 18 18:54:55 2011 @@ -9466,6 +9466,22 @@ <value xml:lang="hi_IN">निरà¤à¤¤à¤° à¤à¥à¤² (बà¤à¤¾à¤¯à¤¾ राशि)</value> <value xml:lang="zh_TW">å·è¡åè¨ (æªæ¸ )</value> </property> + <property key="AccountingSagePayPaymentAuthorisationException"> + <value xml:lang="en">Exception in calling SagePayPaymentAuthorisation: ${errorString}</value> + <value xml:lang="it">Eccezione durante la chiamata a SagePayPaymentAuthorisation: ${errorString}</value> + </property> + <property key="AccountingSagePayPaymentRefundException"> + <value xml:lang="en">Exception in calling SagePayPaymentRefund: ${errorString}</value> + <value xml:lang="it">Eccezione durante la chiamata a SagePayPaymentRefund: ${errorString}</value> + </property> + <property key="AccountingSagePayPaymentReleaseException"> + <value xml:lang="en">Exception in calling SagePayPaymentRelease: ${errorString}</value> + <value xml:lang="it">Eccezione durante la chiamata a SagePayPaymentRelease: ${errorString}</value> + </property> + <property key="AccountingSagePayPaymentVoidException"> + <value xml:lang="en">Exception in calling SagePayPaymentVoid: ${errorString}</value> + <value xml:lang="it">Eccezione durante la chiamata a SagePayPaymentVoid: ${errorString}</value> + </property> <property key="AccountingSalesInvoiceToRevenue"> <value xml:lang="de">Zuweisungen von Einkaufsrechnungsarten zu Ertragskonten</value> <value xml:lang="en">Sales Invoice type to Revenue GL Account Number assignment list</value> @@ -10573,6 +10589,102 @@ <value xml:lang="zh">ä½¿ç¨æ£å表达å¼éªè¯æ ·å¼</value> <value xml:lang="zh_TW">ä½¿ç¨æ£åéç®å¼é©è¨¼æ¨£å¼</value> </property> + <property key="AccountingValueLinkGiftCardActivated"> + <value xml:lang="en">Activation of physical card complete.</value> + <value xml:lang="it">Attivazione della carta completata.</value> + </property> + <property key="AccountingValueLinkCannotStoreWorkingKey"> + <value xml:lang="en">Unable to store updated keys</value> + <value xml:lang="it">Non è possibile registrare chiavi aggiornate</value> + </property> + <property key="AccountingValueLinkCannotUpdateWorkingKey"> + <value xml:lang="en">Unable to update MWK</value> + <value xml:lang="it">Non è possibile aggiornare MWK</value> + </property> + <property key="AccountingValueLinkFeatureTypeRequested"> + <value xml:lang="en">Required feature type TYPE not found for product: ${productId}</value> + <value xml:lang="it">Richiesta tipo caratteristica TIPO non trovata per il prodotto: ${productId}</value> + </property> + <property key="AccountingValueLinkPinDisabled"> + <value xml:lang="en">PIN disabled.</value> + <value xml:lang="it">PIN disabilitato.</value> + </property> + <property key="AccountingValueLinkPromoCodeInvalid"> + <value xml:lang="en">Invalid promo code set on idCode field of feature type TYPE</value> + <value xml:lang="it">Codice promozione invalido imposta sul campo idCode del tipo caratteristica TIPO</value> + </property> + <property key="AccountingValueLinkReceivedEmptyResponse"> + <value xml:lang="en">Received back an empty response from ValueLink</value> + <value xml:lang="it">Ricevuta indietro una risposta vuota da ValueLink</value> + </property> + <property key="AccountingValueLinkThisTransactionIsNotSupported"> + <value xml:lang="en">This transaction is not supported by ValueLink</value> + <value xml:lang="it">Questa transazione non è supportata da ValueLink</value> + </property> + <property key="AccountingValueLinkTransactionFailed"> + <value xml:lang="en">Transaction failed with response code: ${responseCode}</value> + <value xml:lang="it">Transazione fallita con codice risposta: ${responseCode}</value> + </property> + <property key="AccountingValueLinkTransactionNotValid"> + <value xml:lang="en">Not a valid 0704 transaction</value> + <value xml:lang="it">Transazione 0704 non valida</value> + </property> + <property key="AccountingValueLinkUnableToActivateGiftCard"> + <value xml:lang="en">Unable to activate gift card</value> + <value xml:lang="it">Non è possibile attivare la carta regalo</value> + </property> + <property key="AccountingValueLinkUnableToCallBalanceInquiry"> + <value xml:lang="en">Unable to call balance inquire</value> + <value xml:lang="it">Non è possibile eseguire l'interrogazione bilancio</value> + </property> + <property key="AccountingValueLinkUnableToCallHistoryInquiry"> + <value xml:lang="en">Unable to call history inquire</value> + <value xml:lang="it">Non è possibile eseguire l'interrogazione dello storico</value> + </property> + <property key="AccountingValueLinkUnableToDisablePin"> + <value xml:lang="en">Unable to call disble pin</value> + <value xml:lang="it">Non è possibile eseguire la disabilitazione del pin</value> + </property> + <property key="AccountingValueLinkUnableToGetFeatureType"> + <value xml:lang="en">Unable to get the required feature type TYPE from Product</value> + <value xml:lang="it">Non è possibile ottenete il tipo caratteristica TIPO richiesto da prodotto</value> + </property> + <property key="AccountingValueLinkUnableToLinkGiftCard"> + <value xml:lang="en">Unable to link gift card(s)</value> + <value xml:lang="it">Non è possibile legare la carta(e) regalo</value> + </property> + <property key="AccountingValueLinkUnableToReleaseGiftCard"> + <value xml:lang="en">Attempt to release GiftCard payment failed; not a valid GiftCard record</value> + <value xml:lang="it">Tentativo di rilascio pagamento carta regalo fallito; non c'è un record GiftCard valido</value> + </property> + <property key="AccountingValueLinkUnableToReloadGiftCard"> + <value xml:lang="en">Unable to reload gift card</value> + <value xml:lang="it">Non è possibile ricaricare la carta regalo</value> + </property> + <property key="AccountingValueLinkUnableToReloadGiftCardFailed"> + <value xml:lang="en">Gift Card Reload Failed: Processing Error; charges will be refunded</value> + <value xml:lang="it">Fallita ricarica carta regalo: errore durante autorizzazione; l'importo verrà rimborsato</value> + </property> + <property key="AccountingValueLinkUnableToRedeemGiftCard"> + <value xml:lang="en">Unable to redeem gift card</value> + <value xml:lang="it">Non è possibile ritirare la carta regalo</value> + </property> + <property key="AccountingValueLinkUnableToRedeemGiftCardFailure"> + <value xml:lang="en">Redeem service failed</value> + <value xml:lang="it">Fallito servizio di ritiro</value> + </property> + <property key="AccountingValueLinkUnableToRefundGiftCard"> + <value xml:lang="en">Unable to refund gift card</value> + <value xml:lang="it">Non è possibile rimborsare la carta regalo</value> + </property> + <property key="AccountingValueLinkUnableToRefundGiftCardMaxBalanceExceeded"> + <value xml:lang="en">Gift Card Reload Failed: Max Balance Exceeded; charges will be refunded</value> + <value xml:lang="it">Fallita ricarica carta regalo: bilancio massimo oltrepassato; l'importo verrà rimborsato</value> + </property> + <property key="AccountingValueLinkUnableToRefundGiftCardFailure"> + <value xml:lang="en">Refund service failed</value> + <value xml:lang="it">Servizio rimborso fallito</value> + </property> <property key="AccountingVarianceReasonGlAccounts"> <value xml:lang="en">Variance Reason Gl Accounts</value> <value xml:lang="fr">Motif de la divergence du Grand Livre général</value> Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java?rev=1060536&r1=1060535&r2=1060536&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java Tue Jan 18 18:54:55 2011 @@ -50,7 +50,6 @@ public class SagePayPaymentServices { public final static String resource = "AccountingUiLabels"; private static Map<String, String> buildCustomerBillingInfo(Map<String, Object> context) { - Debug.logInfo("SagePay - Entered buildCustomerBillingInfo", module); Debug.logInfo("SagePay buildCustomerBillingInfo context : " + context, module); @@ -154,11 +153,11 @@ public class SagePayPaymentServices { Debug.logInfo("SagePay - Entered ccAuth", module); Debug.logInfo("SagePay ccAuth context : " + context, module); Map<String, Object> response = null; - - String orderId = (String) context.get("orderId"); + Locale locale = (Locale) context.get("locale"); GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); - if (null == orderPaymentPreference) { - response = ServiceUtil.returnError("OrderPaymentPreference for order : " + orderId + " is null : " + orderPaymentPreference); + if (orderPaymentPreference == null) { + response = ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingProblemGettingOrderPaymentPreferences", locale)); } else { response = processCardAuthorisationPayment(dctx, context); } @@ -169,10 +168,9 @@ public class SagePayPaymentServices { private static Map<String, Object> processCardAuthorisationPayment(DispatchContext ctx, Map<String, Object> context) { - Map<String, Object> result = ServiceUtil.returnSuccess(); LocalDispatcher dispatcher = ctx.getDispatcher(); - + Locale locale = (Locale) context.get("locale"); Map<String, String> billingInfo = buildCustomerBillingInfo(context); String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); @@ -231,7 +229,9 @@ public class SagePayPaymentServices { } } catch(GenericServiceException e) { Debug.logError(e, "Error in calling SagePayPaymentAuthentication", module); - result = ServiceUtil.returnError("Exception in calling SagePayPaymentRegistration : " + e.getMessage()); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingSagePayPaymentAuthorisationException", + UtilMisc.toMap("errorString", e.getMessage()), locale)); } return result; } @@ -239,7 +239,6 @@ public class SagePayPaymentServices { public static Map<String, Object> ccCapture(DispatchContext ctx, Map<String, Object> context) { Debug.logInfo("SagePay - Entered ccCapture", module); Debug.logInfo("SagePay ccCapture context : " + context, module); - GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference); context.put("authTransaction", authTransaction); @@ -251,12 +250,10 @@ public class SagePayPaymentServices { return response; } - private static Map<String, Object> processCardCapturePayment(DispatchContext ctx, Map<String, Object> context) { - Map<String, Object> result = ServiceUtil.returnSuccess(); LocalDispatcher dispatcher = ctx.getDispatcher(); - + Locale locale = (Locale) context.get("locale"); String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); GenericValue authTransaction = (GenericValue) context.get("authTransaction"); BigDecimal amount = (BigDecimal) context.get("captureAmount"); @@ -289,12 +286,13 @@ public class SagePayPaymentServices { } } catch(GenericServiceException e) { Debug.logError(e, "Error in calling SagePayPaymentAuthorisation", module); - result = ServiceUtil.returnError("Exception in calling SagePayPaymentRegistration : " + e.getMessage()); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingSagePayPaymentAuthorisationException", + UtilMisc.toMap("errorString", e.getMessage()), locale)); } return result; } - public static Map<String, Object> ccRefund(DispatchContext ctx, Map<String, Object> context) { Debug.logInfo("SagePay - Entered ccRefund", module); Debug.logInfo("SagePay ccRefund context : " + context, module); @@ -361,10 +359,9 @@ public class SagePayPaymentServices { } private static Map<String, Object> processCardRefundPayment(DispatchContext ctx, Map<String, Object> context) { - Map<String, Object> result = ServiceUtil.returnSuccess(); LocalDispatcher dispatcher = ctx.getDispatcher(); - + Locale locale = (Locale) context.get("locale"); String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); GenericValue captureTransaction = (GenericValue) context.get("captureTransaction"); BigDecimal amount = (BigDecimal) context.get("refundAmount"); @@ -404,24 +401,24 @@ public class SagePayPaymentServices { } catch(GenericServiceException e) { Debug.logError(e, "Error in calling SagePayPaymentRefund", module); - result = ServiceUtil.returnError("Exception in calling SagePayPaymentRefund : " + e.getMessage()); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingSagePayPaymentRefundException", + UtilMisc.toMap("errorString", e.getMessage()), locale)); } return result; } private static Map<String, Object> processCardVoidPayment(DispatchContext ctx, Map<String, Object> context) { - Map<String, Object> result = ServiceUtil.returnSuccess(); LocalDispatcher dispatcher = ctx.getDispatcher(); - + Locale locale = (Locale) context.get("locale"); String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); GenericValue captureTransaction = (GenericValue) context.get("captureTransaction"); BigDecimal amount = (BigDecimal) context.get("refundAmount"); String orderId = (String) captureTransaction.get("altReference"); try { - Map<String, Object> paymentResult = dispatcher.runSync("SagePayPaymentVoid", UtilMisc.toMap( "paymentGatewayConfigId", paymentGatewayConfigId, @@ -453,21 +450,23 @@ public class SagePayPaymentServices { } catch(GenericServiceException e) { Debug.logError(e, "Error in calling SagePayPaymentVoid", module); - result = ServiceUtil.returnError("Exception in calling SagePayPaymentVoid : " + e.getMessage()); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingSagePayPaymentVoidException", + UtilMisc.toMap("errorString", e.getMessage()), locale)); } return result; } public static Map<String, Object> ccRelease(DispatchContext ctx, Map<String, Object> context) { - Debug.logInfo("SagePay - Entered ccRelease", module); Debug.logInfo("SagePay ccRelease context : " + context, module); - + Locale locale = (Locale) context.get("locale"); GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference); if (authTransaction == null) { - return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot Release"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale)); } context.put("authTransaction", authTransaction); @@ -477,9 +476,8 @@ public class SagePayPaymentServices { } private static Map<String, Object> processCardReleasePayment(DispatchContext ctx, Map<String, Object> context) { - Map<String, Object> result = ServiceUtil.returnSuccess(); - + Locale locale = (Locale) context.get("locale"); LocalDispatcher dispatcher = ctx.getDispatcher(); String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); @@ -490,7 +488,6 @@ public class SagePayPaymentServices { String refNum = (String) authTransaction.get("referenceNum"); try { - Map<String, Object> paymentResult = dispatcher.runSync("SagePayPaymentRelease", UtilMisc.toMap( "paymentGatewayConfigId", paymentGatewayConfigId, @@ -517,7 +514,9 @@ public class SagePayPaymentServices { } catch(GenericServiceException e) { Debug.logError(e, "Error in calling SagePayPaymentRelease", module); - result = ServiceUtil.returnError("Exception in calling SagePayPaymentRefund : " + e.getMessage()); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingSagePayPaymentReleaseException", + UtilMisc.toMap("errorString", e.getMessage()), locale)); } return result; Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java?rev=1060536&r1=1060535&r2=1060536&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java Tue Jan 18 18:54:55 2011 @@ -56,6 +56,9 @@ import org.ofbiz.service.ServiceXaWrappe public class ValueLinkServices { public static final String module = ValueLinkServices.class.getName(); + public final static String resource = "AccountingUiLabels"; + public final static String resourceError = "AccountingErrorUiLabels"; + public final static String resourceOrder = "OrderUiLabels"; // generate/display new public/private/kek keys public static Map<String, Object> createKeys(DispatchContext dctx, Map<String, Object> context) { @@ -132,6 +135,7 @@ public class ValueLinkServices { Delegator delegator = dctx.getDelegator(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Properties props = getProperties(context); + Locale locale = (Locale) context.get("locale"); // get an api instance ValueLinkApi vl = ValueLinkApi.getInstance(delegator, props); @@ -163,7 +167,8 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to update MWK"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkCannotUpdateWorkingKey", locale)); } Debug.log("Response : " + response, module); @@ -181,15 +186,19 @@ public class ValueLinkServices { vlKeys.store(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to store updated keys; the keys were changed with ValueLink : " + vlKeys, module); - return ServiceUtil.returnError("Unable to store updated keys"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkCannotStoreWorkingKey", locale)); } vl.reload(); return ServiceUtil.returnSuccess(); } else { - return ServiceUtil.returnError("Transaction failed with response code : " + responseCode); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkTransactionFailed", + UtilMisc.toMap("responseCode", responseCode), locale)); } } else { - return ServiceUtil.returnError("Recevied back an empty response"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -203,6 +212,7 @@ public class ValueLinkServices { String orderId = (String) context.get("orderId"); String partyId = (String) context.get("partyId"); BigDecimal amount = (BigDecimal) context.get("amount"); + Locale locale = (Locale) context.get("locale"); // override interface for void/rollback String iFace = (String) context.get("Interface"); @@ -243,7 +253,8 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to activate gift card"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToActivateGiftCard", locale)); } if (response != null) { @@ -266,7 +277,8 @@ public class ValueLinkServices { Debug.log("Activate Result : " + result, module); return result; } else { - return ServiceUtil.returnError("Empty response returned from ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -278,6 +290,7 @@ public class ValueLinkServices { String physicalCard = (String) context.get("physicalCard"); String physicalPin = (String) context.get("physicalPin"); String partyId = (String) context.get("partyId"); + Locale locale = (Locale) context.get("locale"); // get an api instance ValueLinkApi vl = ValueLinkApi.getInstance(delegator, props); @@ -299,12 +312,15 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to link gift card(s)"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToLinkGiftCard", locale)); } if (response != null) { String responseCode = (String) response.get("responsecode"); - Map<String, Object> result = ServiceUtil.returnSuccess("Activation of physical card complete."); + Map<String, Object> result = ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, + "AccountingValueLinkGiftCardActivated", locale)); + if (responseCode.equals("00")) { result.put("processResult", Boolean.TRUE); @@ -320,7 +336,8 @@ public class ValueLinkServices { Debug.log("Link Result : " + result, module); return result; } else { - return ServiceUtil.returnError("Empty response returned from ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -332,6 +349,7 @@ public class ValueLinkServices { String orderId = (String) context.get("orderId"); String partyId = (String) context.get("partyId"); BigDecimal amount = (BigDecimal) context.get("amount"); + Locale locale = (Locale) context.get("locale"); // get an api instance ValueLinkApi vl = ValueLinkApi.getInstance(delegator, props); @@ -357,12 +375,14 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to call disble pin"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToDisablePin", locale)); } if (response != null) { String responseCode = (String) response.get("responsecode"); - Map<String, Object> result = ServiceUtil.returnSuccess("PIN disabled."); + Map<String, Object> result = ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, + "AccountingValueLinkPinDisabled", locale)); if (responseCode.equals("00")) { result.put("processResult", Boolean.TRUE); } else { @@ -376,7 +396,8 @@ public class ValueLinkServices { Debug.log("Disable Result : " + result, module); return result; } else { - return ServiceUtil.returnError("Empty response returned from ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -389,6 +410,7 @@ public class ValueLinkServices { String orderId = (String) context.get("orderId"); String partyId = (String) context.get("partyId"); BigDecimal amount = (BigDecimal) context.get("amount"); + Locale locale = (Locale) context.get("locale"); // override interface for void/rollback String iFace = (String) context.get("Interface"); @@ -421,7 +443,8 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to redeem gift card"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToRedeemGiftCard", locale)); } if (response != null) { @@ -443,7 +466,8 @@ public class ValueLinkServices { Debug.log("Redeem Result : " + result, module); return result; } else { - return ServiceUtil.returnError("Empty response returned from ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -456,6 +480,7 @@ public class ValueLinkServices { String orderId = (String) context.get("orderId"); String partyId = (String) context.get("partyId"); BigDecimal amount = (BigDecimal) context.get("amount"); + Locale locale = (Locale) context.get("locale"); // override interface for void/rollback String iFace = (String) context.get("Interface"); @@ -488,7 +513,8 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to reload gift card"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToReloadGiftCard", locale)); } if (response != null) { @@ -509,7 +535,8 @@ public class ValueLinkServices { Debug.log("Reload Result : " + result, module); return result; } else { - return ServiceUtil.returnError("Empty response returned from ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -521,6 +548,7 @@ public class ValueLinkServices { String currency = (String) context.get("currency"); String orderId = (String) context.get("orderId"); String partyId = (String) context.get("partyId"); + Locale locale = (Locale) context.get("locale"); // get an api instance ValueLinkApi vl = ValueLinkApi.getInstance(delegator, props); @@ -546,7 +574,8 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to call balance inquire"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToCallBalanceInquiry", locale)); } if (response != null) { @@ -565,7 +594,8 @@ public class ValueLinkServices { Debug.log("Balance Result : " + result, module); return result; } else { - return ServiceUtil.returnError("Empty response returned from ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -576,6 +606,7 @@ public class ValueLinkServices { String pin = (String) context.get("pin"); String orderId = (String) context.get("orderId"); String partyId = (String) context.get("partyId"); + Locale locale = (Locale) context.get("locale"); // get an api instance ValueLinkApi vl = ValueLinkApi.getInstance(delegator, props); @@ -600,7 +631,8 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to call history inquire"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToCallHistoryInquiry", locale)); } if (response != null) { @@ -620,7 +652,8 @@ public class ValueLinkServices { Debug.log("History Result : " + result, module); return result; } else { - return ServiceUtil.returnError("Empty response returned from ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -633,6 +666,7 @@ public class ValueLinkServices { String orderId = (String) context.get("orderId"); String partyId = (String) context.get("partyId"); BigDecimal amount = (BigDecimal) context.get("amount"); + Locale locale = (Locale) context.get("locale"); // override interface for void/rollback String iFace = (String) context.get("Interface"); @@ -665,7 +699,8 @@ public class ValueLinkServices { response = vl.send(request); } catch (HttpClientException e) { Debug.logError(e, "Problem communicating with VL"); - return ServiceUtil.returnError("Unable to refund gift card"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToRefundGiftCard", locale)); } if (response != null) { @@ -686,7 +721,8 @@ public class ValueLinkServices { Debug.log("Refund Result : " + result, module); return result; } else { - return ServiceUtil.returnError("Empty response returned from ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkReceivedEmptyResponse", locale)); } } @@ -712,11 +748,13 @@ public class ValueLinkServices { public static Map<String, Object> timeOutReversal(DispatchContext dctx, Map<String, Object> context) { String vlInterface = (String) context.get("Interface"); + Locale locale = (Locale) context.get("locale"); Debug.log("704 Interface : " + vlInterface, module); if (vlInterface != null) { if (vlInterface.startsWith("Activate")) { if (vlInterface.equals("Activate/Rollback")) { - return ServiceUtil.returnError("This transaction is not supported by ValueLink"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkThisTransactionIsNotSupported", locale)); } return activate(dctx, context); } else if (vlInterface.startsWith("Redeem")) { @@ -728,7 +766,8 @@ public class ValueLinkServices { } } - return ServiceUtil.returnError("Not a valid 0704 transaction"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkTransactionNotValid", locale)); } // 0704 Timeout Reversal (Supports - Activate/Void, Redeem, Redeem/Void, Reload, Reload/Void, Refund, Refund/Void) @@ -779,13 +818,13 @@ public class ValueLinkServices { public static Map<String, Object> giftCardProcessor(DispatchContext dctx, Map<String, Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + Locale locale = (Locale) context.get("locale"); GenericValue giftCard = (GenericValue) context.get("giftCard"); GenericValue party = (GenericValue) context.get("billToParty"); String paymentConfig = (String) context.get("paymentConfig"); String currency = (String) context.get("currency"); String orderId = (String) context.get("orderId"); - BigDecimal amount = (BigDecimal) context.get("processAmount"); + BigDecimal amount = (BigDecimal) context.get("processAmount"); // make sure we have a currency if (currency == null) { @@ -808,7 +847,8 @@ public class ValueLinkServices { redeemResult = dispatcher.runSync("redeemGiftCard", redeemCtx); } catch (GenericServiceException e) { Debug.logError(e, "Problem calling the redeem service", module); - return ServiceUtil.returnError("Redeem service failed"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToRedeemGiftCardFailure", locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -854,7 +894,7 @@ public class ValueLinkServices { public static Map<String, Object> giftCardRelease(DispatchContext dctx, Map<String, Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + Locale locale = (Locale) context.get("locale"); GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference"); String paymentConfig = (String) context.get("paymentConfig"); String currency = (String) context.get("currency"); @@ -869,11 +909,13 @@ public class ValueLinkServices { giftCard = paymentPref.getRelatedOne("GiftCard"); } catch (GenericEntityException e) { Debug.logError("Unable to get GiftCard from OrderPaymentPreference", module); - return ServiceUtil.returnError("Unable to locate GiftCard Information"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotLocateItFromOrderPaymentPreference", locale)); } if (giftCard == null) { - return ServiceUtil.returnError("Attempt to release GiftCard payment faild; not a valid GiftCard record"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToReleaseGiftCard", locale)); } // make sure we have a currency @@ -896,7 +938,8 @@ public class ValueLinkServices { redeemResult = dispatcher.runSync("voidRedeemGiftCard", redeemCtx); } catch (GenericServiceException e) { Debug.logError(e, "Problem calling the redeem service", module); - return ServiceUtil.returnError("Redeem service failed"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToRedeemGiftCardFailure", locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -915,7 +958,7 @@ public class ValueLinkServices { public static Map<String, Object> giftCardRefund(DispatchContext dctx, Map<String, Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + Locale locale = (Locale) context.get("locale"); GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference"); String paymentConfig = (String) context.get("paymentConfig"); String currency = (String) context.get("currency"); @@ -930,11 +973,13 @@ public class ValueLinkServices { giftCard = paymentPref.getRelatedOne("GiftCard"); } catch (GenericEntityException e) { Debug.logError("Unable to get GiftCard from OrderPaymentPreference", module); - return ServiceUtil.returnError("Unable to locate GiftCard Information"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotLocateItFromOrderPaymentPreference", locale)); } if (giftCard == null) { - return ServiceUtil.returnError("Attempt to release GiftCard payment faild; not a valid GiftCard record"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToReleaseGiftCard", locale)); } // make sure we have a currency @@ -957,7 +1002,8 @@ public class ValueLinkServices { redeemResult = dispatcher.runSync("refundGiftCard", refundCtx); } catch (GenericServiceException e) { Debug.logError(e, "Problem calling the refund service", module); - return ServiceUtil.returnError("Refund service failed"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToRefundGiftCardFailure", locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -992,7 +1038,8 @@ public class ValueLinkServices { orderHeader = orderItem.getRelatedOne("OrderHeader"); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get OrderHeader from OrderItem",module); - return ServiceUtil.returnError("Unable to get OrderHeader from OrderItem"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder, + "OrderOrderNotFound", UtilMisc.toMap("orderId", orderId), locale)); } // get the order read helper @@ -1012,7 +1059,8 @@ public class ValueLinkServices { productStoreId = orh.getProductStoreId(); } if (productStoreId == null) { - return ServiceUtil.returnError("Unable to process gift card purchase; no productStoreId on OrderHeader : " + orderId); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotProcess", locale)); } // payment config @@ -1022,7 +1070,9 @@ public class ValueLinkServices { paymentConfig = paymentSetting.getString("paymentPropertiesPath"); } if (paymentConfig == null) { - return ServiceUtil.returnError("Unable to get payment configuration file"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingFinAccountSetting", + UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", "GIFT_CARD"), locale)); } // party ID for tracking @@ -1044,7 +1094,8 @@ public class ValueLinkServices { Debug.logError("Unable to get Product from OrderItem", module); } if (product == null) { - return ServiceUtil.returnError("No product associated with OrderItem, cannot fulfill gift card"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotFulfill", locale)); } // get the productFeature type TYPE (VL promo code) @@ -1057,16 +1108,20 @@ public class ValueLinkServices { typeFeature = EntityUtil.getFirst(featureAppls); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to get the required feature type TYPE from Product"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToGetFeatureType", locale)); } if (typeFeature == null) { - return ServiceUtil.returnError("Required feature type TYPE not found for product : " + product.get("productId")); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkFeatureTypeRequested", + UtilMisc.toMap("productId", product.get("productId")), locale)); } // get the VL promo code String promoCode = typeFeature.getString("idCode"); if (UtilValidate.isEmpty(promoCode)) { - return ServiceUtil.returnError("Invalid promo code set on idCode field of feature type TYPE"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkPromoCodeInvalid", locale)); } // survey information @@ -1083,7 +1138,8 @@ public class ValueLinkServices { surveyResponse = EntityUtil.getFirst(responses); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to get survey response information; cannot fulfill gift card"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotFulfill", locale)); } // get the response answers @@ -1092,7 +1148,8 @@ public class ValueLinkServices { responseAnswers = surveyResponse.getRelated("SurveyResponseAnswer"); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to get survey response answers from survey response; cannot fulfill gift card"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotFulfillFromSurveyAnswers", locale)); } // make a map of answer info @@ -1106,7 +1163,8 @@ public class ValueLinkServices { question = answer.getRelatedOne("SurveyQuestion"); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to get survey question from answer"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotFulfillFromSurveyAnswers", locale)); } if (question != null) { String desc = question.getString("description"); @@ -1145,7 +1203,8 @@ public class ValueLinkServices { activateResult = dispatcher.runSync("activateGiftCard", activateCtx); } catch (GenericServiceException e) { Debug.logError(e, "Unable to activate gift card(s)", module); - return ServiceUtil.returnError("Problem running activation service"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToActivateGiftCard", locale)); } Boolean processResult = (Boolean) activateResult.get("processResult"); @@ -1185,11 +1244,14 @@ public class ValueLinkServices { dispatcher.runAsync("createGcFulFillmentRecord", vlFulFill, true); } catch (GenericServiceException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to store fulfillment info"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotStoreFulfillmentInfo", + UtilMisc.toMap("errorString", e.toString() ), locale)); } if (failure) { - return ServiceUtil.returnError("Activate Failed"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToActivateGiftCard", locale)); } // add some information to the answerMap for the email @@ -1245,7 +1307,9 @@ public class ValueLinkServices { } catch (GenericServiceException e) { Debug.logError(e, "Problem sending mail", module); // this is fatal; we will rollback and try again later - return ServiceUtil.returnError("Error sending Gift Card notice email: " + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotSendEmailNotice", + UtilMisc.toMap("errorString", e.toString()), locale)); } } } @@ -1270,7 +1334,8 @@ public class ValueLinkServices { orderHeader = orderItem.getRelatedOne("OrderHeader"); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get OrderHeader from OrderItem",module); - return ServiceUtil.returnError("Unable to get OrderHeader from OrderItem"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder, + "OrderOrderNotFound", UtilMisc.toMap("orderId", orderId), locale)); } // get the order read helper @@ -1290,7 +1355,9 @@ public class ValueLinkServices { productStoreId = orh.getProductStoreId(); } if (productStoreId == null) { - return ServiceUtil.returnError("Unable to process gift card reload; no productStoreId on OrderHeader : " + orderId); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotProcess", + UtilMisc.toMap("orderId", orderId), locale)); } // payment config @@ -1300,7 +1367,8 @@ public class ValueLinkServices { paymentConfig = paymentSetting.getString("paymentPropertiesPath"); } if (paymentConfig == null) { - return ServiceUtil.returnError("Unable to get payment configuration file"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotGetPaymentConfiguration", locale)); } // party ID for tracking @@ -1327,7 +1395,8 @@ public class ValueLinkServices { surveyResponse = EntityUtil.getFirst(responses); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to get survey response information; cannot fulfill gift card reload"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotFulfill", locale)); } // get the response answers @@ -1336,7 +1405,8 @@ public class ValueLinkServices { responseAnswers = surveyResponse.getRelated("SurveyResponseAnswer"); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to get survey response answers from survey response; cannot fulfill gift card reload"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotFulfillFromSurveyAnswers", locale)); } // make a map of answer info @@ -1350,7 +1420,8 @@ public class ValueLinkServices { question = answer.getRelatedOne("SurveyQuestion"); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to get survey question from answer"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotFulfillFromSurveyAnswers", locale)); } if (question != null) { String desc = question.getString("description"); @@ -1381,7 +1452,8 @@ public class ValueLinkServices { reloadResult = dispatcher.runSync("reloadGiftCard", reloadCtx); } catch (GenericServiceException e) { Debug.logError(e, "Unable to reload gift card", module); - return ServiceUtil.returnError("Problem running reload service"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToReloadGiftCard", locale)); } // create the fulfillment record @@ -1403,7 +1475,8 @@ public class ValueLinkServices { dispatcher.runAsync("createGcFulFillmentRecord", vlFulFill, true); } catch (GenericServiceException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to store fulfillment info"); + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "AccountingGiftCerticateNumberCannotStoreFulfillmentInfo", locale)); } Boolean processResult = (Boolean) reloadResult.get("processResult"); @@ -1425,10 +1498,12 @@ public class ValueLinkServices { } if ("17".equals(responseCode)) { Debug.logError("Error code : " + responseCode + " : Max Balance Exceeded", module); - return ServiceUtil.returnError("Gift Card Reload Failed : Max Balance Exceeded; charges will be refunded"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToRefundGiftCardMaxBalanceExceeded", locale)); } else { Debug.logError("Error code : " + responseCode + " : Processing Error", module); - return ServiceUtil.returnError("Gift Card Reload Failed : Processing Error; charges will be refunded"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingValueLinkUnableToReloadGiftCardFailed", locale)); } } @@ -1476,7 +1551,9 @@ public class ValueLinkServices { } catch (GenericServiceException e) { Debug.logError(e, "Problem sending mail", module); // this is fatal; we will rollback and try again later - return ServiceUtil.returnError("Error sending Gift Card notice email: " + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingGiftCerticateNumberCannotSendEmailNotice", + UtilMisc.toMap("errorString", e.toString()), locale)); } } |
| Free forum by Nabble | Edit this page |
