Return-Path: Delivered-To: apmail-ofbiz-commits-archive@www.apache.org Received: (qmail 31798 invoked from network); 2 Feb 2011 18:18:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Feb 2011 18:18:17 -0000 Received: (qmail 80874 invoked by uid 500); 2 Feb 2011 18:18:17 -0000 Delivered-To: apmail-ofbiz-commits-archive@ofbiz.apache.org Received: (qmail 80728 invoked by uid 500); 2 Feb 2011 18:18:15 -0000 Mailing-List: contact commits-help@ofbiz.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ofbiz.apache.org Delivered-To: mailing list commits@ofbiz.apache.org Received: (qmail 80720 invoked by uid 99); 2 Feb 2011 18:18:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Feb 2011 18:18:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_FRT_POSSIBLE X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Feb 2011 18:18:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C739723889E9; Wed, 2 Feb 2011 18:17:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: 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 Date: Wed, 02 Feb 2011 18:17:46 -0000 To: commits@ofbiz.apache.org From: mrisaliti@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110202181746.C739723889E9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ 无法取消任务重试 無法取消工作重試 + + Error doing entity-auto operation for entity ${entityName} in service ${serviceName}: ${errorString} + Errore mentre faceva l'operazione entity-auto per l'entità ${entityName} nel servizio ${serviceName}: ${errorString} + + + The ID value in the parameter ${parameterName} was not valid: ${errorDetails} + Il valore ID nel parametro ${parameterName} non è valido: ${errorDetails} + + + Error running deadlock test services: ${errorString} + Errore durante il test del servizio deadlock: ${errorString} + + + Error(s) running sub-services in testServiceDeadLockRetry + Errore(i) durante l'esecuzione dei sotto-servizi in testServiceDeadLockRetry + + + Error running testServiceDeadLockRetryThreadA: ${errorString} + Errore durante l'esecuzione di testServiceDeadLockRetryThreadA: ${errorString} + + + Error running testServiceDeadLockRetryThreadB: ${errorString} + Errore durante l'esecuzione di testServiceDeadLockRetryThreadB: ${errorString} + + + Entity Engine Exception: ${errorString} + Eccezione Entity Engine: ${errorString} + + + Entity Engine Exception running dead lock test thread A: ${errorString} + Eccezione Entity Engine durante l'esecuzione del test dead lock thread A: ${errorString} + + + Entity Engine Exception running dead lock test thread B: ${errorString} + Eccezione Entity Engine durante l'esecuzione del test dead lock thread B: ${errorString} + + + Entity Engine Exception running dead lock test thread A: ${errorString} + Eccezione Entity Engine durante l'esecuzione del test dead lock thread A: ${errorString} + + + Entity Engine Exception running dead lock test thread B: ${errorString} + Eccezione Entity Engine durante l'esecuzione del test dead lock thread B: ${errorString} + + + Error(s) running sub-services in testServiceLockWaitTimeoutRetry + Errore(i) durante l'esecuzione dei sotto-servizi in testServiceLockWaitTimeoutRetry + + + Entity Engine Exception running lock wait timeout test Grabber thread: ${errorString} + Eccezione Entity Engine durante l'esecuzione del lock wait timeout test Grabber thread: ${errorString} + + + Entity Engine Exception running lock wait timeout test Grabber thread: ${errorString} + Eccezione Entity Engine durante l'esecuzione del lock wait timeout test Grabber thread: ${errorString} + + + Wait Interrupted Exception running lock wait timeout test Grabber thread: ${errorString} + Eccezione Wait Interrupted Exception durante l'esecuzione del lock wait timeout test Grabber thread: ${errorString} + + + Wait Interrupted Exception running lock wait timeout test Waiter thread: ${errorString} + Eccezione Wait Interrupted Exception durante l'esecuzione del lock wait timeout test Waiter thread: ${errorString} + + + Error running testServiceLockWaitTimeoutRetryCantRecoverWaiter + Errore durante l'esecuzione di testServiceLockWaitTimeoutRetryCantRecoverWaiter + + + Error running sub-service with own tx: ${errorString} + Errore durante l'esecuzione del sotto-servizio con proprie transazione: ${errorString} + + + Error running ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper + Errore durante l'esecuzione di ServiceTestOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper + + + Error running sub-service in testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent + Errore durante l'esecuzione di testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent + + + Intentional rollback to test global-rollback + Rollback intenzionale per testare il global-rollback + + + Error calling sub-service, it should return an error but not throw an exception, so something went wrong: ${errorString} + Errore durante l'esecuzione del sotto-servizio, dovrebbe restituire un'errore ma non generare un'eccezione, così qualcosa è andato male: ${errorString} + + + adding integer 125 to 365 yields + aggiungere intero 125 a 365 yields + + + calcul is wrong ! Why ? + calcolo è errato ! Perchè ? + + + missing parameters + parametri mancanti + + + Value not found, cannot update + Valore non troavato, non è possibile aggiornare + 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 runSync(String localName, ModelService modelService, Map parameters) throws GenericServiceException { // static java service methods should be: public Map methodName(DispatchContext dctx, Map context) DispatchContext dctx = dispatcher.getLocalContext(localName); - + Locale locale = (Locale) parameters.get("locale"); Map localContext = FastMap.newInstance(); localContext.put("parameters", parameters); Map 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 testServiceDeadLockRetry(DispatchContext dctx, Map 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 threadBResult = threadBWaiter.waitForResult(); List 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 testServiceDeadLockRetryThreadA(DispatchContext dctx, Map 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 testServiceDeadLockRetryThreadB(DispatchContext dctx, Map 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 testServiceLockWaitTimeoutRetry(DispatchContext dctx, Map 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 testServiceLockWaitTimeoutRetryGrabber(DispatchContext dctx, Map 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 testServiceLockWaitTimeoutRetryWaiter(DispatchContext dctx, Map 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 testServiceLockWaitTimeoutRetryCantRecover(DispatchContext dctx, Map 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 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 testServiceLockWaitTimeoutRetryCantRecoverWaiter(DispatchContext dctx, Map 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 testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentErrorCatchWrapper(DispatchContext dctx, Map context) { LocalDispatcher dispatcher = dctx.getDispatcher(); + Locale locale = (Locale) context.get("locale"); try { Map 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 testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent(DispatchContext dctx, Map 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 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 testServiceEcaGlobalEventExec(DispatchContext dctx, Map 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 testServiceEcaGlobalEventExecOnCommit(DispatchContext dctx, Map 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 testServiceEcaGlobalEventExecToRollback(DispatchContext dctx, Map 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 testServiceEcaGlobalEventExecOnRollback(DispatchContext dctx, Map 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 testXmlRpcAdd(DispatchContext dctx, Map context) { + Locale locale = (Locale) context.get("locale"); Map 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 testXmlRpcClientAdd(DispatchContext dctx, Map context) { + Locale locale = (Locale) context.get("locale"); Map 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; }