svn commit: r1066563 - in /ofbiz/trunk/framework/service: config/ServiceErrorUiLabels.xml src/org/ofbiz/service/engine/EntityAutoEngine.java src/org/ofbiz/service/test/ServiceEngineTestServices.java src/org/ofbiz/service/test/XmlRpcTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1066563 - in /ofbiz/trunk/framework/service: config/ServiceErrorUiLabels.xml src/org/ofbiz/service/engine/EntityAutoEngine.java src/org/ofbiz/service/test/ServiceEngineTestServices.java src/org/ofbiz/service/test/XmlRpcTests.java

mrisaliti
Author: mrisaliti
Date: Wed Feb  2 18:17:46 2011
New Revision: 1066563

URL: http://svn.apache.org/viewvc?rev=1066563&view=rev
Log:
Internationalization of return messages of java services of service component (OFBIZ-4091)

Modified:
    ofbiz/trunk/framework/service/config/ServiceErrorUiLabels.xml
    ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java

Modified: ofbiz/trunk/framework/service/config/ServiceErrorUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/config/ServiceErrorUiLabels.xml?rev=1066563&r1=1066562&r2=1066563&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/config/ServiceErrorUiLabels.xml (original)
+++ ofbiz/trunk/framework/service/config/ServiceErrorUiLabels.xml Wed Feb  2 18:17:46 2011
@@ -91,4 +91,108 @@
         <value xml:lang="zh">无法取消任务重试</value>
         <value xml:lang="zh_TW">無法取消工作重試</value>
     </property>
+    <property key="ServiceEntityAutoOperation">
+        <value xml:lang="en">Error doing entity-auto operation for entity ${entityName} in service ${serviceName}: ${errorString}</value>
+        <value xml:lang="it">Errore mentre faceva l'operazione entity-auto per l'entità ${entityName} nel servizio ${serviceName}: ${errorString}</value>
+    </property>
+    <property key="ServiceParameterValueNotValid">
+        <value xml:lang="en">The ID value in the parameter ${parameterName} was not valid: ${errorDetails}</value>
+        <value xml:lang="it">Il valore ID nel parametro ${parameterName} non è valido: ${errorDetails}</value>
+    </property>
+    <property key="ServiceTestDeadLockError">
+        <value xml:lang="en">Error running deadlock test services: ${errorString}</value>
+        <value xml:lang="it">Errore durante il test del servizio deadlock: ${errorString}</value>
+    </property>
+    <property key="ServiceTestDeadLockRetry">
+        <value xml:lang="en">Error(s) running sub-services in testServiceDeadLockRetry</value>
+        <value xml:lang="it">Errore(i) durante l'esecuzione dei sotto-servizi in testServiceDeadLockRetry</value>
+    </property>
+    <property key="ServiceTestDeadLockThreadA">
+        <value xml:lang="en">Error running testServiceDeadLockRetryThreadA: ${errorString}</value>
+        <value xml:lang="it">Errore durante l'esecuzione di testServiceDeadLockRetryThreadA: ${errorString}</value>
+    </property>
+    <property key="ServiceTestDeadLockThreadB">
+        <value xml:lang="en">Error running testServiceDeadLockRetryThreadB: ${errorString}</value>
+        <value xml:lang="it">Errore durante l'esecuzione di testServiceDeadLockRetryThreadB: ${errorString}</value>
+    </property>
+    <property key="ServiceTestEntityEngineError">
+        <value xml:lang="en">Entity Engine Exception: ${errorString}</value>
+        <value xml:lang="it">Eccezione Entity Engine: ${errorString}</value>
+    </property>
+    <property key="ServiceTestEntityEngineExceptionThreadA">
+        <value xml:lang="en">Entity Engine Exception running dead lock test thread A: ${errorString}</value>
+        <value xml:lang="it">Eccezione Entity Engine durante l'esecuzione del test dead lock thread A: ${errorString}</value>
+    </property>
+    <property key="ServiceTestEntityEngineExceptionThreadB">
+        <value xml:lang="en">Entity Engine Exception running dead lock test thread B: ${errorString}</value>
+        <value xml:lang="it">Eccezione Entity Engine durante l'esecuzione del test dead lock thread B: ${errorString}</value>
+    </property>
+    <property key="ServiceTestEntityEngineWaitInterruptedExceptionThreadA">
+        <value xml:lang="en">Entity Engine Exception running dead lock test thread A: ${errorString}</value>
+        <value xml:lang="it">Eccezione Entity Engine durante l'esecuzione del test dead lock thread A: ${errorString}</value>
+    </property>
+    <property key="ServiceTestEntityEngineWaitInterruptedExceptionThreadB">
+        <value xml:lang="en">Entity Engine Exception running dead lock test thread B: ${errorString}</value>
+        <value xml:lang="it">Eccezione Entity Engine durante l'esecuzione del test dead lock thread B: ${errorString}</value>
+    </property>
+    <property key="ServiceTestLockWaitTimeoutRetry">
+        <value xml:lang="en">Error(s) running sub-services in testServiceLockWaitTimeoutRetry</value>
+        <value xml:lang="it">Errore(i) durante l'esecuzione dei sotto-servizi in testServiceLockWaitTimeoutRetry</value>
+    </property>
+    <property key="ServiceTestLockWaitTimeoutRetryGrabber">
+        <value xml:lang="en">Entity Engine Exception running lock wait timeout test Grabber thread: ${errorString}</value>
+        <value xml:lang="it">Eccezione Entity Engine durante l'esecuzione del lock wait timeout test Grabber thread: ${errorString}</value>
+    </property>
+    <property key="ServiceTestLockWaitTimeoutRetryWaiter">
+        <value xml:lang="en">Entity Engine Exception running lock wait timeout test Grabber thread: ${errorString}</value>
+        <value xml:lang="it">Eccezione Entity Engine durante l'esecuzione del lock wait timeout test Grabber thread: ${errorString}</value>
+    </property>
+    <property key="ServiceTestLockInterruptedExceptionRetryGrabber">
+        <value xml:lang="en">Wait Interrupted Exception running lock wait timeout test Grabber thread: ${errorString}</value>
+        <value xml:lang="it">Eccezione Wait Interrupted Exception durante l'esecuzione del lock wait timeout test Grabber thread: ${errorString}</value>
+    </property>
+    <property key="ServiceTestLockInterruptedExceptionRetryWaiter">
+        <value xml:lang="en">Wait Interrupted Exception running lock wait timeout test Waiter thread: ${errorString}</value>
+        <value xml:lang="it">Eccezione Wait Interrupted Exception durante l'esecuzione del lock wait timeout test Waiter thread: ${errorString}</value>
+    </property>
+    <property key="ServiceTestLockWaitTimeoutRetryCantRecoverWaiter">
+        <value xml:lang="en">Error running testServiceLockWaitTimeoutRetryCantRecoverWaiter</value>
+        <value xml:lang="it">Errore durante l'esecuzione di testServiceLockWaitTimeoutRetryCantRecoverWaiter</value>
+    </property>
+    <property key="ServiceTestOwnTxError">
+        <value xml:lang="en">Error running sub-service with own tx: ${errorString}</value>
+        <value xml:lang="it">Errore durante l'esecuzione del sotto-servizio con proprie transazione: ${errorString}</value>
+    </property>
+    <property key="ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper">
+        <value xml:lang="en">Error running ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper</value>
+        <value xml:lang="it">Errore durante l'esecuzione di ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper</value>
+    </property>
+    <property key="ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParent">
+        <value xml:lang="en">Error running sub-service in testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent</value>
+        <value xml:lang="it">Errore durante l'esecuzione di testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent</value>
+    </property>
+    <property key="ServiceTestRollback">
+        <value xml:lang="en">Intentional rollback to test global-rollback</value>
+        <value xml:lang="it">Rollback intenzionale per testare il global-rollback</value>
+    </property>
+    <property key="ServiceTestSubServiceError">
+        <value xml:lang="en">Error calling sub-service, it should return an error but not throw an exception, so something went wrong: ${errorString}</value>
+        <value xml:lang="it">Errore durante l'esecuzione del sotto-servizio, dovrebbe restituire un'errore ma non generare un'eccezione, così qualcosa è andato male: ${errorString}</value>
+    </property>
+    <property key="ServiceTestXmlRpcCalculationOK">
+        <value xml:lang="en">adding integer 125 to 365 yields </value>
+        <value xml:lang="it">aggiungere intero 125 a 365 yields </value>
+    </property>
+    <property key="ServiceTestXmlRpcCalculationKO">
+        <value xml:lang="en">calcul is wrong ! Why ?</value>
+        <value xml:lang="it">calcolo è errato ! Perchè ?</value>
+    </property>
+    <property key="ServiceTestXmlRpcMissingParameters">
+        <value xml:lang="en">missing parameters</value>
+        <value xml:lang="it">parametri mancanti</value>
+    </property>
+    <property key="ServiceValueNotFound">
+        <value xml:lang="en">Value not found, cannot update</value>
+        <value xml:lang="it">Valore non troavato, non è possibile aggiornare</value>
+    </property>
 </resource>

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java?rev=1066563&r1=1066562&r2=1066563&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java Wed Feb  2 18:17:46 2011
@@ -27,6 +27,7 @@ import javolution.util.FastMap;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericValue;
@@ -46,6 +47,7 @@ import org.ofbiz.service.ServiceUtil;
 public final class EntityAutoEngine extends GenericAsyncEngine {
 
     public static final String module = EntityAutoEngine.class.getName();
+    public static final String resource = "ServiceErrorUiLabels";
 
     public EntityAutoEngine(ServiceDispatcher dispatcher) {
         super(dispatcher);
@@ -66,7 +68,7 @@ public final class EntityAutoEngine exte
     public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> parameters) throws GenericServiceException {
         // static java service methods should be: public Map<String, Object> methodName(DispatchContext dctx, Map<String, Object> context)
         DispatchContext dctx = dispatcher.getLocalContext(localName);
-
+        Locale locale = (Locale) parameters.get("locale");
         Map<String, Object> localContext = FastMap.newInstance();
         localContext.put("parameters", parameters);
         Map<String, Object> result = ServiceUtil.returnSuccess();
@@ -175,7 +177,7 @@ public final class EntityAutoEngine exte
                         if (pkValue instanceof String) {
                             StringBuffer errorDetails = new StringBuffer();
                             if (!UtilValidate.isValidDatabaseId((String) pkValue, errorDetails)) {
-                                return ServiceUtil.returnError("The ID value in the parameter [" + singlePkModelParam.name + "] was not valid: " + errorDetails);
+                                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceParameterValueNotValid", UtilMisc.toMap("parameterName", singlePkModelParam.name,"errorDetails", errorDetails), locale));
                             }
                         }
                     }
@@ -248,7 +250,7 @@ public final class EntityAutoEngine exte
 
                 GenericValue lookedUpValue = PrimaryKeyFinder.runFind(modelEntity, parameters, dctx.getDelegator(), false, true, null, null);
                 if (lookedUpValue == null) {
-                    return ServiceUtil.returnError("Value not found, cannot update");
+                    return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceValueNotFound", locale));
                 }
 
                 localContext.put("lookedUpValue", lookedUpValue);
@@ -293,7 +295,7 @@ public final class EntityAutoEngine exte
                         GenericValue statusValidChange = dctx.getDelegator().findOne("StatusValidChange", true, "statusId", lookedUpStatusId, "statusIdTo", parameterStatusId);
                         if (statusValidChange == null) {
                             // uh-oh, no valid change...
-                            return ServiceUtil.returnError(UtilProperties.getMessage("CommonUiLabels", "CommonErrorNoStatusValidChange", localContext, (Locale) parameters.get("locale")));
+                            return ServiceUtil.returnError(UtilProperties.getMessage("CommonUiLabels", "CommonErrorNoStatusValidChange", localContext, locale));
                         }
                     }
                 }
@@ -321,9 +323,8 @@ public final class EntityAutoEngine exte
                 }
             }
         } catch (GeneralException e) {
-            String errMsg = "Error doing entity-auto operation for entity [" + modelEntity.getEntityName() + "] in service [" + modelService.name + "]: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Error doing entity-auto operation for entity [" + modelEntity.getEntityName() + "] in service [" + modelService.name + "]: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceEntityAutoOperation", UtilMisc.toMap("entityName", modelEntity.getEntityName(), "serviceName", modelService.name,"errorString", e.toString()), locale));
         }
 
         return result;

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java?rev=1066563&r1=1066562&r2=1066563&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java Wed Feb  2 18:17:46 2011
@@ -19,11 +19,14 @@
 package org.ofbiz.service.test;
 
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javolution.util.FastList;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
@@ -37,8 +40,10 @@ import org.ofbiz.service.ServiceUtil;
 public class ServiceEngineTestServices {
 
     public static final String module = ServiceEngineTestServices.class.getName();
+    public static final String resource = "ServiceErrorUiLabels";
 
     public static Map<String, Object> testServiceDeadLockRetry(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Locale locale = (Locale) context.get("locale");
         LocalDispatcher dispatcher = dctx.getDispatcher();
         try {
             // NOTE using persist=false so that the lock retry will have to fix the problem instead of the job poller picking it up again
@@ -49,18 +54,17 @@ public class ServiceEngineTestServices {
             Map<String, Object> threadBResult = threadBWaiter.waitForResult();
             List<Object> errorList = FastList.newInstance();
             if (ServiceUtil.isError(threadAResult)) {
-                errorList.add("Error running testServiceDeadLockRetryThreadA: " + ServiceUtil.getErrorMessage(threadAResult));
+                errorList.add(UtilProperties.getMessage(resource, "ServiceTestDeadLockThreadA", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(threadAResult)), locale));
             }
             if (ServiceUtil.isError(threadBResult)) {
-                errorList.add("Error running testServiceDeadLockRetryThreadB: " + ServiceUtil.getErrorMessage(threadBResult));
+                errorList.add(UtilProperties.getMessage(resource, "ServiceTestDeadLockThreadB", UtilMisc.toMap("errorString", ServiceUtil.getErrorMessage(threadBResult)), locale));
             }
             if (errorList.size() > 0) {
-                return ServiceUtil.returnError("Error(s) running sub-services in testServiceDeadLockRetry", errorList, null, null);
+                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestDeadLockRetry", locale), errorList, null, null);
             }
         } catch (Exception e) {
-            String errMsg = "Error running deadlock test services: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Error running deadlock test services: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestDeadLockError", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
@@ -68,7 +72,7 @@ public class ServiceEngineTestServices {
 
     public static Map<String, Object> testServiceDeadLockRetryThreadA(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
-
+        Locale locale = (Locale) context.get("locale");
         try {
             // grab entity SVCLRT_A by changing, then wait, then find and change SVCLRT_B
             GenericValue testingTypeA = delegator.findOne("TestingType", false, "testingTypeId", "SVCLRT_A");
@@ -89,20 +93,18 @@ public class ServiceEngineTestServices {
             testingTypeAOnly.set("description", "New description for SVCLRT_AONLY; this is only changed by thread A so if it doesn't match something happened to thread A!");
             testingTypeAOnly.store();
         } catch (GenericEntityException e) {
-            String errMsg = "Entity Engine Exception running dead lock test thread A: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Entity Engine Exception running dead lock test thread A: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineExceptionThreadA", UtilMisc.toMap("errorString", e.toString()), locale));
         } catch (InterruptedException e) {
-            String errMsg = "Wait Interrupted Exception running dead lock test thread A: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Wait Interrupted Exception running dead lock test thread A: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineWaitInterruptedExceptionThreadA", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
     }
     public static Map<String, Object> testServiceDeadLockRetryThreadB(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
-
+        Locale locale = (Locale) context.get("locale");
         try {
             // grab entity SVCLRT_B by changing, then wait, then change SVCLRT_A
             GenericValue testingTypeB = delegator.findOne("TestingType", false, "testingTypeId", "SVCLRT_B");
@@ -123,13 +125,11 @@ public class ServiceEngineTestServices {
             testingTypeAOnly.set("description", "New description for SVCLRT_BONLY; this is only changed by thread B so if it doesn't match something happened to thread B!");
             testingTypeAOnly.store();
         } catch (GenericEntityException e) {
-            String errMsg = "Entity Engine Exception running dead lock test thread B: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Entity Engine Exception running dead lock test thread B: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineExceptionThreadB", UtilMisc.toMap("errorString", e.toString()), locale));
         } catch (InterruptedException e) {
-            String errMsg = "Wait Interrupted Exception running dead lock test thread B: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Wait Interrupted Exception running dead lock test thread B: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineWaitInterruptedExceptionThreadB", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
@@ -139,6 +139,7 @@ public class ServiceEngineTestServices {
 
     public static Map<String, Object> testServiceLockWaitTimeoutRetry(DispatchContext dctx, Map<String, ? extends Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
+        Locale locale = (Locale) context.get("locale");
         try {
             // NOTE using persist=false so that the lock retry will have to fix the problem instead of the job poller picking it up again
             GenericResultWaiter grabberWaiter = dispatcher.runAsyncWait("testServiceLockWaitTimeoutRetryGrabber", null, false);
@@ -154,19 +155,18 @@ public class ServiceEngineTestServices {
                 errorList.add("Error running testServiceLockWaitTimeoutRetryWaiter: " + ServiceUtil.getErrorMessage(waiterResult));
             }
             if (errorList.size() > 0) {
-                return ServiceUtil.returnError("Error(s) running sub-services in testServiceLockWaitTimeoutRetry", errorList, null, null);
+                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockWaitTimeoutRetry", locale), errorList, null, null);
             }
         } catch (Exception e) {
-            String errMsg = "Error running deadlock test services: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Error running deadlock test services: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestDeadLockError", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
     }
     public static Map<String, Object> testServiceLockWaitTimeoutRetryGrabber(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
-
+        Locale locale = (Locale) context.get("locale");
         try {
             // grab entity SVCLWTRT by changing, then wait a LONG time, ie more than the wait timeout
             GenericValue testingType = delegator.findOne("TestingType", false, "testingTypeId", "SVCLWTRT");
@@ -179,20 +179,18 @@ public class ServiceEngineTestServices {
             // (tx timeout 6s on this the Grabber and 2s on the Waiter): wait 4 seconds because timeout on this
             Thread.sleep(4 * 1000);
         } catch (GenericEntityException e) {
-            String errMsg = "Entity Engine Exception running lock wait timeout test Grabber thread: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Entity Engine Exception running lock wait timeout test Grabber thread: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockWaitTimeoutRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale));
         } catch (InterruptedException e) {
-            String errMsg = "Wait Interrupted Exception running lock wait timeout test Grabber thread: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Wait Interrupted Exception running lock wait timeout test Grabber thread: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockInterruptedExceptionRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
     }
     public static Map<String, Object> testServiceLockWaitTimeoutRetryWaiter(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
-
+        Locale locale = (Locale) context.get("locale");
         try {
             // wait for a small amount of time to make sure the grabber does it's thing first
             Thread.sleep(100);
@@ -206,13 +204,11 @@ public class ServiceEngineTestServices {
 
             Debug.logInfo("In testServiceLockWaitTimeoutRetryWaiter successfully updated SVCLWTRT", module);
         } catch (GenericEntityException e) {
-            String errMsg = "Entity Engine Exception running lock wait timeout test Waiter thread: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Entity Engine Exception running lock wait timeout test Waiter thread: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockWaitTimeoutRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale));
         } catch (InterruptedException e) {
-            String errMsg = "Wait Interrupted Exception running lock wait timeout test Waiter thread: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Wait Interrupted Exception running lock wait timeout test Waiter thread: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockInterruptedExceptionRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
@@ -239,6 +235,7 @@ public class ServiceEngineTestServices {
     public static Map<String, Object> testServiceLockWaitTimeoutRetryCantRecover(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
+        Locale locale = (Locale) context.get("locale");
         try {
             // grab entity SVCLWTRTCR by changing, then wait a LONG time, ie more than the wait timeout
             GenericValue testingType = delegator.findOne("TestingType", false, "testingTypeId", "SVCLWTRTCR");
@@ -249,7 +246,7 @@ public class ServiceEngineTestServices {
             // timeout is 5 seconds so it is longer than the tx timeout for this service, so will fail quickly; with this transaction keeping a lock on the record and that one trying to get it, bam we cause the error
             Map<String, Object> waiterResult = dispatcher.runSync("testServiceLockWaitTimeoutRetryCantRecoverWaiter", null, 5, true);
             if (ServiceUtil.isError(waiterResult)) {
-                return ServiceUtil.returnError("Error running testServiceLockWaitTimeoutRetryCantRecoverWaiter", null, null, waiterResult);
+                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockWaitTimeoutRetryCantRecoverWaiter", locale), null, null, waiterResult);
             }
 
             Debug.logInfo("In testServiceLockWaitTimeoutRetryCantRecover (grabber) successfully finished running sub-service in own transaction", module);
@@ -257,16 +254,15 @@ public class ServiceEngineTestServices {
             String errMsg = "Error running deadlock test services: " + e.toString();
             Debug.logError(e, errMsg, module);
         } catch (GenericEntityException e) {
-            String errMsg = "Entity Engine Exception running lock wait timeout test main/Grabber thread: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Entity Engine Exception running lock wait timeout test main/Grabber thread: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockInterruptedExceptionRetryGrabber", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
     }
     public static Map<String, Object> testServiceLockWaitTimeoutRetryCantRecoverWaiter(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
-
+        Locale locale = (Locale) context.get("locale");
         try {
             Debug.logInfo("In testServiceLockWaitTimeoutRetryCantRecoverWaiter updating SVCLWTRTCR", module);
 
@@ -277,9 +273,8 @@ public class ServiceEngineTestServices {
 
             Debug.logInfo("In testServiceLockWaitTimeoutRetryCantRecoverWaiter successfully updated SVCLWTRTCR", module);
         } catch (GenericEntityException e) {
-            String errMsg = "Entity Engine Exception running lock wait timeout test Waiter thread: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Entity Engine Exception running lock wait timeout test Waiter thread: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestLockInterruptedExceptionRetryWaiter", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
@@ -289,10 +284,11 @@ public class ServiceEngineTestServices {
 
     public static Map<String, Object> testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper(DispatchContext dctx, Map<String, ? extends Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
+        Locale locale = (Locale) context.get("locale");
         try {
             Map<String, Object> resultMap = dispatcher.runSync("testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent", null, 60, true);
             if (ServiceUtil.isError(resultMap)) {
-                return ServiceUtil.returnError("Error running main test service in testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper", null, null, resultMap);
+                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper", locale), null, null, resultMap);
             }
         } catch (GenericServiceException e) {
             String errMsg = "This is the expected error running sub-service with own tx after the parent has set rollback only, logging and ignoring: " + e.toString();
@@ -304,6 +300,7 @@ public class ServiceEngineTestServices {
     public static Map<String, Object> testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
+        Locale locale = (Locale) context.get("locale");
         try {
             // change the SVC_SRBO value first to test that the rollback really does revert/reset
             GenericValue testingType = delegator.findOne("TestingType", false, "testingTypeId", "SVC_SRBO");
@@ -314,12 +311,11 @@ public class ServiceEngineTestServices {
 
             Map<String, Object> resultMap = dispatcher.runSync("testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentSubService", null, 60, true);
             if (ServiceUtil.isError(resultMap)) {
-                return ServiceUtil.returnError("Error running sub-service in testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent", null, null, resultMap);
+                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParent", locale), null, null, resultMap);
             }
         } catch (Exception e) {
-            String errMsg = "Error running sub-service with own tx: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Error running sub-service with own tx: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestOwnTxError", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
@@ -334,13 +330,13 @@ public class ServiceEngineTestServices {
 
     public static Map<String, Object> testServiceEcaGlobalEventExec(DispatchContext dctx, Map<String, ? extends Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
+        Locale locale = (Locale) context.get("locale");
         try {
             // this will return an error, but we'll ignore the result
             dispatcher.runSync("testServiceEcaGlobalEventExecToRollback", null, 60, true);
         } catch (GenericServiceException e) {
-            String errMsg = "Error calling sub-service, it should return an error but not throw an exception, so something went wrong: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Error calling sub-service, it should return an error but not throw an exception, so something went wrong: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestSubServiceError", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         // this service doesn't actually have to do anything, just a placeholder for ECA rules, this one should commit
@@ -348,34 +344,33 @@ public class ServiceEngineTestServices {
     }
     public static Map<String, Object> testServiceEcaGlobalEventExecOnCommit(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
-
+        Locale locale = (Locale) context.get("locale");
         try {
             GenericValue testingType = delegator.findOne("TestingType", false, "testingTypeId", "SVC_SECAGC");
             testingType.set("description", "New description for SVC_SECAGC, what it should be after the global-commit test");
             testingType.store();
         } catch (GenericEntityException e) {
-            String errMsg = "Entity Engine Exception: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Entity Engine Exception: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineError", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();
     }
     public static Map<String, Object> testServiceEcaGlobalEventExecToRollback(DispatchContext dctx, Map<String, ? extends Object> context) {
         // this service doesn't actually have to do anything, just a placeholder for ECA rules, this one should rollback
-        return ServiceUtil.returnError("Intentional rollback to test global-rollback");
+        Locale locale = (Locale) context.get("locale");
+        return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestRollback", locale));
     }
     public static Map<String, Object> testServiceEcaGlobalEventExecOnRollback(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
-
+        Locale locale = (Locale) context.get("locale");
         try {
             GenericValue testingType = delegator.findOne("TestingType", false, "testingTypeId", "SVC_SECAGR");
             testingType.set("description", "New description for SVC_SECAGR, what it should be after the global-rollback test");
             testingType.store();
         } catch (GenericEntityException e) {
-            String errMsg = "Entity Engine Exception: " + e.toString();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Entity Engine Exception: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestEntityEngineError", UtilMisc.toMap("errorString", e.toString()), locale));
         }
 
         return ServiceUtil.returnSuccess();

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java?rev=1066563&r1=1066562&r2=1066563&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/test/XmlRpcTests.java Wed Feb  2 18:17:46 2011
@@ -19,10 +19,12 @@
 
 package org.ofbiz.service.test;
 
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.xmlrpc.client.XmlRpcClient;
 import org.ofbiz.base.util.UtilGenerics;
+import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
@@ -34,6 +36,7 @@ import org.ofbiz.service.ServiceUtil;
 public class XmlRpcTests extends AbstractXmlRpcTestCase {
 
     public static final String module = XmlRpcTests.class.getName();
+    public static final String resource = "ServiceErrorUiLabels";
     public static final String url = "http://localhost:8080/webtools/control/xmlrpc";
 
     public XmlRpcTests(String name) {
@@ -55,11 +58,12 @@ public class XmlRpcTests extends Abstrac
      * Service to receive information from xml-rpc call
      */
     public static Map<String, Object> testXmlRpcAdd(DispatchContext dctx, Map<String, ?> context) {
+        Locale locale = (Locale) context.get("locale");
         Map<String, Object> response = ServiceUtil.returnSuccess();
         Integer num1 = (Integer) context.get("num1");
         Integer num2 = (Integer) context.get("num2");
         if (UtilValidate.isEmpty(num1) || UtilValidate.isEmpty(num2)) {
-            return ServiceUtil.returnError("missing parameters");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestXmlRpcMissingParameters", locale));
         }
         Integer res = num1 + num2;
         response.put("resulting", res);
@@ -70,6 +74,7 @@ public class XmlRpcTests extends Abstrac
      * Service to send information to xml-rpc service
      */    
     public static Map<String, Object> testXmlRpcClientAdd(DispatchContext dctx, Map<String, ?> context) {
+        Locale locale = (Locale) context.get("locale");
         Map<String, Object> result = null;
         Integer num1 = 125;
         Integer num2 = 365;
@@ -85,9 +90,9 @@ public class XmlRpcTests extends Abstrac
         if (ServiceUtil.isError(result)) return result;
         Integer res = (Integer) result.get("resulting");
         if (res == (num1 + num2)) {
-            result = ServiceUtil.returnSuccess("adding integer 125 to 365 yields " + res);
+            result = ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "ServiceTestXmlRpcCalculationOK", locale) + res);
         } else {
-            result = ServiceUtil.returnError("calcul is wrong ! Why ?");
+            result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "ServiceTestXmlRpcCalculationKO", locale));
         }
         return result;
     }