Author: mrisaliti
Date: Tue Jan 18 19:55:41 2011
New Revision: 1060552
URL: http://svn.apache.org/viewvc?rev=1060552&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/securepay/SecurePayPaymentServices.java
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java
Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=1060552&r1=1060551&r2=1060552&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original)
+++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Tue Jan
18 19:55:41 2011
@@ -9522,6 +9522,14 @@
<value xml:lang="zh">å¡çå®å
¨ç </value>
<value xml:lang="zh_TW">å¡çå®å
¨ç¢¼</value>
</property>
+ <property key="AccountingSecurityPayPaymentWasNotSent">
+ <value xml:lang="en">Payment was not sent to server.</value>
+ <value xml:lang="it">Pagamento non è stato inviato al server.</value>
+ </property>
+ <property key="AccountingSecurityPayNotProperlyConfigurated">
+ <value xml:lang="en">ERROR: Getting SecurePay property
configuration</value>
+ <value xml:lang="it">ERRORE: Ricavando la configurazione di
SecurePay</value>
+ </property>
<property key="AccountingSelectAction">
<value xml:lang="en">Select Action</value>
<value xml:lang="hi_IN">à¤à¤¾à¤°à¥à¤¯ à¤à¥à¤¨à¥à¤</value>
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java?rev=1060552&r1=1060551&r2=1060552&view=diff
==============================================================================
---
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java
(original)
+++
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java
Tue Jan 18 19:55:41 2011
@@ -19,14 +19,13 @@
package org.ofbiz.accounting.thirdparty.securepay;
import java.math.BigDecimal;
-import java.sql.Timestamp;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import org.ofbiz.accounting.payment.PaymentGatewayServices;
import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
@@ -36,22 +35,24 @@ import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
-
import securepay.jxa.api.Payment;
import securepay.jxa.api.Txn;
public class SecurePayPaymentServices {
public static final String module =
SecurePayPaymentServices.class.getName();
+ public final static String resource = "AccountingUiLabels";
public static Map<String, Object> doAuth(DispatchContext dctx, Map<String,
Object> context) {
+ Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
String orderId = (String) context.get("orderId");
BigDecimal processAmount = (BigDecimal) context.get("processAmount");
// generate the request/properties
Properties props = buildScProperties(context, delegator);
if (props == null) {
- return ServiceUtil.returnError("ERROR: Getting SecurePay property
configuration");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayNotProperlyConfigurated", locale));
}
String merchantId = props.getProperty("merchantID");
@@ -103,7 +104,8 @@ public class SecurePayPaymentServices {
Map<String, Object> result = ServiceUtil.returnSuccess();
if (UtilValidate.isEmpty(processed)) {
- return ServiceUtil.returnError("Payment was not sent to server.");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1) {
Txn resp = payment.getTxn(0);
@@ -129,6 +131,7 @@ public class SecurePayPaymentServices {
}
public static Map<String, Object> doCapture(DispatchContext dctx,
Map<String, Object> context) {
+ Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
GenericValue orderPaymentPreference = (GenericValue)
context.get("orderPaymentPreference");
GenericValue authTransaction = (GenericValue) context.get("authTrans");
@@ -136,12 +139,14 @@ public class SecurePayPaymentServices {
authTransaction =
PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
}
if (authTransaction == null) {
- return ServiceUtil.returnError("No authorization transaction found
for the OrderPaymentPreference; cannot Capture");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+
"AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
}
Properties props = buildScProperties(context, delegator);
if (props == null) {
- return ServiceUtil.returnError("ERROR: Getting SecurePay property
configuration");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayNotProperlyConfigurated", locale));
}
String merchantId = props.getProperty("merchantID");
@@ -181,7 +186,8 @@ public class SecurePayPaymentServices {
Map<String, Object> result = ServiceUtil.returnSuccess();
if (UtilValidate.isEmpty(processed)) {
- return ServiceUtil.returnError("Payment was not sent to server.");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1){
Txn resp = payment.getTxn(0);
@@ -204,6 +210,7 @@ public class SecurePayPaymentServices {
}
public static Map<String, Object> doVoid(DispatchContext dctx, Map<String,
Object> context) {
+ Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
GenericValue orderPaymentPreference = (GenericValue)
context.get("orderPaymentPreference");
GenericValue authTransaction = (GenericValue) context.get("authTrans");
@@ -211,12 +218,14 @@ public class SecurePayPaymentServices {
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));
}
Properties props = buildScProperties(context, delegator);
if (props == null) {
- return ServiceUtil.returnError("ERROR: Getting SecurePay property
configuration");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayNotProperlyConfigurated", locale));
}
String merchantId = props.getProperty("merchantID");
@@ -256,7 +265,8 @@ public class SecurePayPaymentServices {
Map<String, Object> result = ServiceUtil.returnSuccess();
if (UtilValidate.isEmpty(processed)) {
- return ServiceUtil.returnError("Payment was not sent to server.");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1){
Txn resp = payment.getTxn(0);
@@ -279,11 +289,13 @@ public class SecurePayPaymentServices {
}
public static Map<String, Object> doRefund(DispatchContext dctx,
Map<String, Object> context) {
+ Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
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 refund");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+
"AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
}
List<GenericValue> paymentGatewayResponse = null;
@@ -303,7 +315,8 @@ public class SecurePayPaymentServices {
Properties props = buildScProperties(context, delegator);
if (props == null) {
- return ServiceUtil.returnError("ERROR: Getting SecurePay property
configuration");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayNotProperlyConfigurated", locale));
}
String merchantId = props.getProperty("merchantID");
@@ -343,7 +356,8 @@ public class SecurePayPaymentServices {
Map<String, Object> result = ServiceUtil.returnSuccess();
if (UtilValidate.isEmpty(processed)) {
- return ServiceUtil.returnError("Payment was not sent to server.");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1){
Txn resp = payment.getTxn(0);
@@ -366,11 +380,13 @@ public class SecurePayPaymentServices {
}
public static Map<String, Object> doCredit(DispatchContext dctx,
Map<String, Object> context) {
+ Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
// generate the request/properties
Properties props = buildScProperties(context, delegator);
if (props == null) {
- return ServiceUtil.returnError("ERROR: Getting SecurePay property
configuration");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayNotProperlyConfigurated", locale));
}
String merchantId = props.getProperty("merchantID");
@@ -419,7 +435,8 @@ public class SecurePayPaymentServices {
Map<String, Object> result = ServiceUtil.returnSuccess();
if (UtilValidate.isEmpty(processed)) {
- return ServiceUtil.returnError("Payment was not sent to server.");
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ "AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1) {
Txn resp = payment.getTxn(0);
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java?rev=1060552&r1=1060551&r2=1060552&view=diff
==============================================================================
---
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java
(original)
+++
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java
Tue Jan 18 19:55:41 2011
@@ -28,7 +28,6 @@ import junit.framework.TestCase;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.ModelService;
@@ -51,8 +50,8 @@ public class SecurePayServiceTest extend
protected BigDecimal creditAmount = null;
protected String configFile = null;
protected GenericValue orderPaymentPreference = null;
- protected List orderItems = null;
- protected Map orderItemMap = null;
+ protected List<Object> orderItems = null;
+ protected Map<String, Object> orderItemMap = null;
protected GenericValue billToParty = null;
protected String paymentGatewayConfigId = null;
protected BigDecimal refundAmount = null;
@@ -84,7 +83,7 @@ public class SecurePayServiceTest extend
"city","The customer city",
"stateProvinceGeoId", "NLD",
"postalCode","12345"));
- orderItemMap = UtilMisc.toMap(
+ orderItemMap = UtilMisc.<String, Object>toMap(
"orderId", "Demo1002",
"orderItemSeqId", "00001",
"orderItemTypeId", "PRODUCT_ORDER_ITEM",
@@ -94,7 +93,7 @@ public class SecurePayServiceTest extend
"unitPrice", new BigDecimal("59.00"),
"statusId" ,"ITEM_COMPLETED"
);
- orderItems = UtilMisc.toList(orderItemMap);
+ orderItems = UtilMisc.<Object>toList(orderItemMap);
billToParty = delegator.makeValue("Party" , UtilMisc.toMap("partyId",
"DemoCustomer"));
paymentGatewayConfigId = "SECUREPAY_CONFIG";
refundAmount = new BigDecimal("100.08");
@@ -114,7 +113,7 @@ public class SecurePayServiceTest extend
public void testAuth() throws Exception{
Debug.logInfo("=====[testAuth] starting....", module);
try {
- Map serviceInput = UtilMisc.toMap(
+ Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap(
"paymentConfig", configFile,
"billToParty", billToParty,
"billToEmail", emailAddr,
@@ -129,7 +128,7 @@ public class SecurePayServiceTest extend
serviceInput.put("processAmount", new BigDecimal("100.08"));
// run the service
- Map result = dispatcher.runSync("ofbScAuthorize",serviceInput);
+ Map<String, Object> result =
dispatcher.runSync("ofbScAuthorize",serviceInput);
// verify the results
String responseMessage = (String)
result.get(ModelService.RESPONSE_MESSAGE);
@@ -166,7 +165,7 @@ public class SecurePayServiceTest extend
Debug.logInfo("=====[testdoCapture] starting....", module);
GenericValue paymentGatewayResponse =
delegator.findOne("PaymentGatewayResponse",
UtilMisc.toMap("paymentGatewayResponseId", "testOrder1000_01"), false);
try {
- Map serviceInput = UtilMisc.toMap(
+ Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap(
"paymentConfig", configFile,
"orderPaymentPreference", orderPaymentPreference,
"authTrans", paymentGatewayResponse
@@ -174,7 +173,7 @@ public class SecurePayServiceTest extend
serviceInput.put("captureAmount", refundAmount);
// run the service
- Map result = dispatcher.runSync("ofbScCapture",serviceInput);
+ Map<String, Object> result =
dispatcher.runSync("ofbScCapture",serviceInput);
// verify the results
String responseMessage = (String)
result.get(ModelService.RESPONSE_MESSAGE);
@@ -200,13 +199,13 @@ public class SecurePayServiceTest extend
public void testdoRefund() throws Exception {
Debug.logInfo("=====[testdoRefund] starting....", module);
try {
- Map serviceInput = UtilMisc.toMap(
+ Map<String, Object> serviceInput = UtilMisc.toMap(
"paymentConfig", configFile,
"orderPaymentPreference", orderPaymentPreference
);
serviceInput.put("refundAmount", refundAmount);
// run the service
- Map result = dispatcher.runSync("ofbScRefund",serviceInput);
+ Map<String, Object> result = dispatcher.runSync("ofbScRefund",
serviceInput);
// verify the results
String responseMessage = (String)
result.get(ModelService.RESPONSE_MESSAGE);
@@ -228,7 +227,7 @@ public class SecurePayServiceTest extend
public void testdoCredit() throws Exception{
Debug.logInfo("=====[testdoCredit] starting....", module);
try {
- Map serviceInput = UtilMisc.toMap(
+ Map<String, Object> serviceInput = UtilMisc.toMap(
"paymentConfig", configFile,
"billToParty", billToParty,
"billToEmail", emailAddr,
@@ -240,7 +239,7 @@ public class SecurePayServiceTest extend
);
serviceInput.put("creditAmount", creditAmount);
// run the service
- Map result = dispatcher.runSync("ofbScCCCredit",serviceInput);
+ Map<String, Object> result =
dispatcher.runSync("ofbScCCCredit",serviceInput);
// verify the results
String responseMessage = (String)
result.get(ModelService.RESPONSE_MESSAGE);
Debug.logInfo("[testdoCredit] responseMessage: " +
responseMessage, module);