Author: mrisaliti
Date: Tue Feb 1 19:27:13 2011 New Revision: 1066157 URL: http://svn.apache.org/viewvc?rev=1066157&view=rev Log: Internationalization of return messages of java services of common component (OFBIZ-4091) Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.xml ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/CommonUiLabels.xml?rev=1066157&r1=1066156&r2=1066157&view=diff ============================================================================== --- ofbiz/trunk/framework/common/config/CommonUiLabels.xml (original) +++ ofbiz/trunk/framework/common/config/CommonUiLabels.xml Tue Feb 1 19:27:13 2011 @@ -1152,6 +1152,22 @@ <value xml:lang="en">Captcha Code</value> <value xml:lang="pt_BR">Código Captcha</value> </property> + <property key="CommonCDyneAddressError"> + <value xml:lang="en">Got AddressError=true from CDyne ReturnCityState service; zipcode=${zipcode}</value> + <value xml:lang="it">Ottenuto AddressError=true dal servizio CDyne ReturnCityState; zipcode=${zipcode}</value> + </property> + <property key="CommonCDyneCallingError"> + <value xml:lang="en">Error calling CDyne service at URL ${serviceUrl}: ${errorString}</value> + <value xml:lang="it">Errore durante la chiamata del servizio CDyne dell'URL ${serviceUrl}: ${errorString})</value> + </property> + <property key="CommonCDyneParsingError"> + <value xml:lang="en">Error parsing XML result from CDyne service at URL ${serviceUrl}: ${errorString}</value> + <value xml:lang="it">Errore di parsing XML risposta dal servizio CDyne dell'URL ${serviceUrl}: ${errorString})</value> + </property> + <property key="CommonCDyneServiceError"> + <value xml:lang="en">Got ServiceError=true from CDyne ReturnCityState service; zipcode=${zipcode}</value> + <value xml:lang="it">Ottenuto ServiceError=true dal servizio CDyne ReturnCityState; zipcode=${zipcode}</value> + </property> <property key="CommonChange"> <value xml:lang="ar">تغÙÙر</value> <value xml:lang="de">Verändern</value> @@ -2397,6 +2413,58 @@ <value xml:lang="zh_CN">çµåé®ä»¶å¯ç </value> <value xml:lang="zh_TW">é»åéµä»¶å¯ç¢¼</value> </property> + <property key="CommonEmailSendAddressError"> + <value xml:lang="en">[ADDRERR] Address error when sending message to ${sendTo} from ${sendFrom} cc ${sendCc} bcc ${sendBcc} subject ${subject}</value> + <value xml:lang="it">[ADDRERR] Errore indirizzo durante l'invio del messaggio a ${sendTo} da ${sendFrom} cc ${sendCc} cn ${sendBcc} soggetto ${subject}</value> + </property> + <property key="CommonEmailSendConnectionError"> + <value xml:lang="en">[CON] Connection error when sending message to ${sendTo} from ${sendFrom} cc ${sendCc} bcc ${sendBcc} subject ${subject}</value> + <value xml:lang="it">[CON] Errore connessione durante l'invio del messaggio a ${sendTo} da ${sendFrom} cc ${sendCc} cn ${sendBcc} soggetto ${subject}</value> + </property> + <property key="CommonEmailDeliveryFailed"> + <value xml:lang="en">Delivery to the following recipient(s) failed:</value> + <value xml:lang="it">Consegna ai seguenti destinatario(i) fallita:</value> + </property> + <property key="CommonEmailDeliveryOriginalMessage"> + <value xml:lang="en">----- Original message -----</value> + <value xml:lang="it">----- messaggio originale -----</value> + </property> + <property key="CommonEmailSendError"> + <value xml:lang="en">Error send email: ${errorString}</value> + <value xml:lang="it">Errore invio email: ${errorString}</value> + </property> + <property key="CommonEmailSendGettingError"> + <value xml:lang="en">Error getting content: ${errorString}</value> + <value xml:lang="it">Errore nel ricavare contenuto: ${errorString}</value> + </property> + <property key="CommonEmailSendMalformedUrl"> + <value xml:lang="en">Malformed URL: ${bodyUrl}; error was: ${errorString}</value> + <value xml:lang="it">URL malformato : ${bodyUrl}; errore era: ${errorString}</value> + </property> + <property key="CommonEmailSendMissingParameterSendVia"> + <value xml:lang="en">Parameter sendVia is required when sendType is not mail.smtp.host</value> + <value xml:lang="it">Parametro sendVia è richiesto quando sendType non è mail.smtp.host</value> + </property> + <property key="CommonEmailSendIOException"> + <value xml:lang="en">IOException when creating message to ${sendTo} from ${sendFrom} cc ${sendCc} bcc ${sendBcc} subject ${subject}</value> + <value xml:lang="it">IOException durante la creazione del messaggio a ${sendTo} da ${sendFrom} cc ${sendCc} cn ${sendBcc} soggetto ${subject}</value> + </property> + <property key="CommonEmailSendMessagingException"> + <value xml:lang="en">MessagingException when creating message to ${sendTo} from ${sendFrom} cc ${sendCc} bcc ${sendBcc} subject ${subject}</value> + <value xml:lang="it">MessagingException durante la creazione del messaggio a ${sendTo} da ${sendFrom} cc ${sendCc} cn ${sendBcc} soggetto ${subject}</value> + </property> + <property key="CommonEmailSendRenderingScreenEmailError"> + <value xml:lang="en">Error rendering screen for email: ${errorString}</value> + <value xml:lang="it">Errore di visualizzazione videata per email: ${errorString}</value> + </property> + <property key="CommonEmailSendRenderingScreenPdfError"> + <value xml:lang="en">Error rendering PDF attachment for email: ${errorString}</value> + <value xml:lang="it">Errore di visualizzazione allegato PDF per email: ${errorString}</value> + </property> + <property key="CommonEmailSendUndeliveredMail"> + <value xml:lang="en">Undelivered Mail Returned to Sender</value> + <value xml:lang="it">Mail non consegnabile restituita a colui che l'ha inviata</value> + </property> <property key="CommonEmailShouldBeSpecified"> <value xml:lang="en">PartyId or Email Address (sendTo) should be specified!</value> <value xml:lang="it">Id soggetto o indirizzo e-mail (inviare a) deve essere specificato!</value> @@ -3000,6 +3068,18 @@ <value xml:lang="zh_CN">æ¥æ¾ææ</value> <value xml:lang="zh_TW">æ¥è©¢å ¨é¨</value> </property> + <property key="CommonFindErrorPreparingConditions"> + <value xml:lang="en">Error preparing conditions: ${errorString}</value> + <value xml:lang="it">Errore duranta la preparazione delle condizioni di ricerca: ${errorString}</value> + </property> + <property key="CommonFindErrorRetrieveIterator"> + <value xml:lang="en">Error finding iterator: ${errorString}</value> + <value xml:lang="it">Errore duranta la ricerca, iterator non restituito: ${errorString}</value> + </property> + <property key="CommonFindErrorRunning"> + <value xml:lang="en">Error running Find on the ${entityName} entity: ${errorString}</value> + <value xml:lang="it">Errore duranta la ricerca sull'entità ${entityName}: ${errorString}</value> + </property> <property key="CommonFinishDate"> <value xml:lang="ar">تارÙØ®/ÙÙت اÙÙÙاÙØ©</value> <value xml:lang="de">Abschluss Datum/Uhrzeit</value> @@ -3360,6 +3440,30 @@ <value xml:lang="zh_CN">èµ·å§æ¥æåæ¶é´</value> <value xml:lang="zh_TW">éå§æ¥æ æé</value> </property> + <property key="CommonFtpConnectionRefused"> + <value xml:lang="en">connection refused</value> + <value xml:lang="it">connessione rifiutata</value> + </property> + <property key="CommonFtpFileCannotBeOpen"> + <value xml:lang="en">ERROR: Could not open local file</value> + <value xml:lang="it">ERRORE: Non è possibile aprire il file locale</value> + </property> + <property key="CommonFtpFileNotSentSuccesfully"> + <value xml:lang="en">File not sent succesfully: ${replyString}</value> + <value xml:lang="it">File non inviato con successo: ${replyString}</value> + </property> + <property key="CommonFtpLoginFailure"> + <value xml:lang="en">Login failed (${username}, ${password})</value> + <value xml:lang="it">Login fallito (${username}, ${password})</value> + </property> + <property key="CommonFtpProblemWithTransfer"> + <value xml:lang="en">Problem with FTP transfer: ${errorString}</value> + <value xml:lang="it">Problema durante il trasferimento FTP: ${errorString}</value> + </property> + <property key="CommonFtpSiteCommandFailed"> + <value xml:lang="en">SITE command ${command} failed: ${replyString}</value> + <value xml:lang="it">Comando sito ${command} fallito: ${replyString}</value> + </property> <property key="CommonGenericPermissionError"> <value xml:lang="de">Sicherheitsfehler: Um ${resourceDescription} auszuführen, müssen Sie eine der folgenden Berechtigungen besitzen: ${primaryPermission}_${mainAction}, ${primaryPermission}_ADMIN${altPermissionList}</value> <value xml:lang="en">Security Error: To run ${resourceDescription} you must have the one of the following permissions: ${primaryPermission}_${mainAction}, ${primaryPermission}_ADMIN${altPermissionList}</value> @@ -5413,6 +5517,30 @@ <value xml:lang="hi_IN">निरà¥à¤¦à¤¿à¤·à¥à¤ नहà¥à¤ </value> <value xml:lang="pt_BR">Não AtribuÃdo</value> </property> + <property key="CommonNotifyEmailDeliveryError"> + <value xml:lang="en">Email delivery error, see error log</value> + <value xml:lang="it">Email delivery error, see error log</value> + </property> + <property key="CommonNotifyEmailInvalidBody"> + <value xml:lang="en">Invalid email body; null is not allowed</value> + <value xml:lang="it">Corpo email invalido; null non è consentito</value> + </property> + <property key="CommonNotifyEmailMessageBodyGeneratedSuccessfully"> + <value xml:lang="en">Message body generated successfully</value> + <value xml:lang="it">Corpo messaggio generato con successo</value> + </property> + <property key="CommonNotifyEmailProblemFindingTemplate"> + <value xml:lang="en">Problem finding template; see logs</value> + <value xml:lang="it">Problema nella ricerca del template; controllare i logs</value> + </property> + <property key="CommonNotifyEmailProblemProcessingTemplate"> + <value xml:lang="en">Template processing problem, see error logs</value> + <value xml:lang="it">Problema nell'esecuzione del template; controllare gli errori nei logs</value> + </property> + <property key="CommonNotifyEmailProblemReadingTemplate"> + <value xml:lang="en">Template reading problem, see error logs</value> + <value xml:lang="it">Problema nella lettura del template; controllare gli errori nei logs</value> + </property> <property key="CommonNotModifRecreat"> <value xml:lang="de">kann nur mit Neuanlage geändert werden</value> <value xml:lang="en">cannot change without re-creating</value> @@ -7915,6 +8043,10 @@ <value xml:lang="zh_CN">ç¶æåå²</value> <value xml:lang="zh_TW">çæ æ·å²è¨é</value> </property> + <property key="CommonStatusMandatory"> + <value xml:lang="en">Parameter statusTypeIds can not be null and must contain at least one element</value> + <value xml:lang="it">Parametro statusTypeIds non può essere nullo e deve contenere almeno un'elemento</value> + </property> <property key="CommonStatustoComplete"> <value xml:lang="en">Status to 'complete'</value> <value xml:lang="es">Poner estado a 'terminado'</value> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java?rev=1066157&r1=1066156&r2=1066157&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CdyneServices.java Tue Feb 1 19:27:13 2011 @@ -19,6 +19,7 @@ package org.ofbiz.common; import java.io.IOException; +import java.util.Locale; import java.util.Map; import javax.xml.parsers.ParserConfigurationException; @@ -26,6 +27,7 @@ import javax.xml.parsers.ParserConfigura import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.HttpClient; import org.ofbiz.base.util.HttpClientException; +import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilXml; import org.ofbiz.service.DispatchContext; @@ -40,7 +42,7 @@ import org.xml.sax.SAXException; public class CdyneServices { public final static String module = CdyneServices.class.getName(); - + public static final String resource = "CommonUiLabels"; public final static String licenseKey = UtilProperties.getPropertyValue("cdyne", "LicenseKey", "0"); /** @@ -51,7 +53,7 @@ public class CdyneServices { */ public static Map<String, Object> cdyneReturnCityState(DispatchContext dctx, Map<String, ?> context) { String zipcode = (String) context.get("zipcode"); - + Locale locale = (Locale) context.get("locale"); String serviceUrl = "http://ws.cdyne.com/psaddress/addresslookup.asmx/ReturnCityState?zipcode=" + zipcode + "&LicenseKey=" + licenseKey; try { String httpResponse = HttpClient.getUrlContent(serviceUrl); @@ -63,29 +65,25 @@ public class CdyneServices { populateCdyneAddress(addressRootElement, response); if ("true".equals(response.get("ServiceError"))) { - return ServiceUtil.returnError("Got ServiceError=true from CDyne ReturnCityState service; zipcode=" + zipcode); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneServiceError", UtilMisc.toMap("zipcode", zipcode), locale)); } if ("true".equals(response.get("AddressError"))) { - return ServiceUtil.returnError("Got AddressError=true from CDyne ReturnCityState service; zipcode=" + zipcode); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneAddressError", UtilMisc.toMap("zipcode", zipcode), locale)); } return response; } catch (HttpClientException e) { - String errMsg = "Error calling CDyne service at URL [" + serviceUrl + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error calling CDyne service at URL [" + serviceUrl + "]: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneCallingError", UtilMisc.toMap("serviceUrl", serviceUrl, "errorString", e.toString()), locale)); } catch (SAXException e) { - String errMsg = "Error parsing XML result from CDyne service at URL [" + serviceUrl + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error parsing XML result from CDyne service at URL [" + serviceUrl + "]: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneParsingError", UtilMisc.toMap("serviceUrl", serviceUrl, "errorString", e.toString()), locale)); } catch (ParserConfigurationException e) { - String errMsg = "Error parsing XML result from CDyne service at URL [" + serviceUrl + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error parsing XML result from CDyne service at URL [" + serviceUrl + "]: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneParsingError", UtilMisc.toMap("serviceUrl", serviceUrl, "errorString", e.toString()), locale)); } catch (IOException e) { - String errMsg = "Error parsing XML result from CDyne service at URL [" + serviceUrl + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error parsing XML result from CDyne service at URL [" + serviceUrl + "]: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonCDyneParsingError", UtilMisc.toMap("serviceUrl", serviceUrl, "errorString", e.toString()), locale)); } } Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java?rev=1066157&r1=1066156&r2=1066157&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java Tue Feb 1 19:27:13 2011 @@ -24,6 +24,7 @@ import static org.ofbiz.base.util.UtilGe import java.sql.Timestamp; import java.util.Collection; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -65,7 +66,7 @@ import org.ofbiz.service.ServiceUtil; public class FindServices { public static final String module = FindServices.class.getName(); - + public static final String resource = "CommonUiLabels"; public static Map<String, EntityComparisonOperator<?, ?>> entityOperators; static { @@ -457,6 +458,7 @@ public class FindServices { String distinct = (String) context.get("distinct"); List<String> fieldList = UtilGenerics.<String>checkList(context.get("fieldList")); GenericValue userLogin = (GenericValue) context.get("userLogin"); + Locale locale = (Locale) context.get("locale"); if (UtilValidate.isEmpty(noConditionFind)) { // try finding in inputFields Map noConditionFind = (String) inputFields.get("noConditionFind"); @@ -488,7 +490,7 @@ public class FindServices { "filterByDateValue", filterByDateValue, "userLogin", userLogin, "locale", context.get("locale"), "timeZone", context.get("timeZone"))); } catch (GenericServiceException gse) { - return ServiceUtil.returnError("Error preparing conditions: " + gse.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFindErrorPreparingConditions", UtilMisc.toMap("errorString", gse.getMessage()), locale)); } EntityConditionList exprList = (EntityConditionList)prepareResult.get("entityConditionList"); List<String> orderByList = checkList(prepareResult.get("orderByList"), String.class); @@ -501,7 +503,7 @@ public class FindServices { "locale", context.get("locale"), "timeZone", context.get("timeZone"), "maxRows", maxRows)); } catch (GenericServiceException gse) { - return ServiceUtil.returnError("Error finding iterator: " + gse.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFindErrorRetrieveIterator", UtilMisc.toMap("errorString", gse.getMessage()), locale)); } if (executeResult.get("listIt") == null) { @@ -597,6 +599,7 @@ public class FindServices { boolean noConditionFind = "Y".equals(context.get("noConditionFind")); boolean distinct = "Y".equals(context.get("distinct")); List<String> fieldList = UtilGenerics.checkList(context.get("fieldList")); + Locale locale = (Locale) context.get("locale"); Set<String> fieldSet = null; if (fieldList != null) { fieldSet = UtilMisc.makeSetWritable(fieldList); @@ -614,7 +617,7 @@ public class FindServices { listSize = listIt.getResultsSizeAfterPartialList(); } } catch (GenericEntityException e) { - return ServiceUtil.returnError("Error running Find on the [" + entityName + "] entity: " + e.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFindErrorRunning", UtilMisc.toMap("entityName", entityName, "errorString", e.getMessage()), locale)); } Map<String, Object> results = ServiceUtil.returnSuccess(); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java?rev=1066157&r1=1066156&r2=1066157&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java Tue Feb 1 19:27:13 2011 @@ -24,12 +24,15 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; +import java.util.Locale; import java.util.Map; import javolution.util.FastList; import org.ofbiz.base.util.Debug; import static org.ofbiz.base.util.UtilGenerics.checkList; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.ServiceUtil; @@ -44,8 +47,9 @@ import org.apache.commons.net.ftp.FTPRep public class FtpServices { public final static String module = FtpServices.class.getName(); - + public static final String resource = "CommonUiLabels"; public static Map<String, Object> putFile(DispatchContext dctx, Map<String, ?> context) { + Locale locale = (Locale) context.get("locale"); Debug.logInfo("[putFile] starting...", module); InputStream localFile = null; @@ -53,7 +57,7 @@ public class FtpServices { localFile = new FileInputStream((String) context.get("localFilename")); } catch (IOException ioe) { Debug.logError(ioe, "[putFile] Problem opening local file", module); - return ServiceUtil.returnError("ERROR: Could not open local file"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFtpFileCannotBeOpen", locale)); } List<String> errorList = FastList.newInstance(); @@ -64,14 +68,14 @@ public class FtpServices { ftp.connect((String) context.get("hostname")); if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { Debug.logInfo("[putFile] Server refused connection", module); - errorList.add("connection refused"); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpConnectionRefused", locale)); } else { String username = (String) context.get("username"); String password = (String) context.get("password"); Debug.logInfo("[putFile] logging in: username=" + username + ", password=" + password, module); if (!ftp.login(username, password)) { Debug.logInfo("[putFile] login failed", module); - errorList.add("Login failed (" + username + ", " + password + ")"); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpLoginFailure", UtilMisc.toMap("username", username, "password", password), locale)); } else { Boolean binaryTransfer = (Boolean) context.get("binaryTransfer"); boolean binary = (binaryTransfer == null) ? false : binaryTransfer.booleanValue(); @@ -84,7 +88,7 @@ public class FtpServices { Debug.logInfo("[putFile] storing local file remotely as: " + context.get("remoteFilename"), module); if (!ftp.storeFile((String) context.get("remoteFilename"), localFile)) { Debug.logInfo("[putFile] store was unsuccessful", module); - errorList.add("File not sent succesfully: " + ftp.getReplyString()); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpFileNotSentSuccesfully", UtilMisc.toMap("replyString", ftp.getReplyString()), locale)); } else { Debug.logInfo("[putFile] store was successful", module); List<String> siteCommands = checkList(context.get("siteCommands"), String.class); @@ -92,7 +96,7 @@ public class FtpServices { for (String command: siteCommands) { Debug.logInfo("[putFile] sending SITE command: " + command, module); if (!ftp.sendSiteCommand(command)) { - errorList.add("SITE command (" + command + ") failed: " + ftp.getReplyString()); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpSiteCommandFailed", UtilMisc.toMap("command", command, "replyString", ftp.getReplyString()), locale)); } } } @@ -102,7 +106,7 @@ public class FtpServices { } } catch (IOException ioe) { Debug.log(ioe, "[putFile] caught exception: " + ioe.getMessage(), module); - errorList.add("Problem with FTP transfer: " + ioe.getMessage()); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpProblemWithTransfer", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); } finally { if (ftp.isConnected()) { try { @@ -130,7 +134,7 @@ public class FtpServices { } public static Map<String, Object> getFile(DispatchContext dctx, Map<String, ?> context) { - + Locale locale = (Locale) context.get("locale"); String localFilename = (String) context.get("localFilename"); OutputStream localFile = null; @@ -138,7 +142,7 @@ public class FtpServices { localFile = new FileOutputStream(localFilename); } catch (IOException ioe) { Debug.logError(ioe, "[getFile] Problem opening local file", module); - return ServiceUtil.returnError("ERROR: Could not open local file"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonFtpFileCannotBeOpen", locale)); } List<String> errorList = FastList.newInstance(); @@ -147,13 +151,13 @@ public class FtpServices { try { ftp.connect((String) context.get("hostname")); if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { - errorList.add("Server refused connection"); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpConnectionRefused", locale)); } else { String username = (String) context.get("username"); String password = (String) context.get("password"); if (!ftp.login(username, password)) { - errorList.add("Login failed (" + username + ", " + password + ")"); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpLoginFailure", UtilMisc.toMap("username", username, "password", password), locale)); } else { Boolean binaryTransfer = (Boolean) context.get("binaryTransfer"); boolean binary = (binaryTransfer == null) ? false : binaryTransfer.booleanValue(); @@ -164,13 +168,13 @@ public class FtpServices { if (passive) { ftp.enterLocalPassiveMode(); } if (!ftp.retrieveFile((String) context.get("remoteFilename"), localFile)) { - errorList.add("File not received succesfully: " + ftp.getReplyString()); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpFileNotSentSuccesfully", UtilMisc.toMap("replyString", ftp.getReplyString()), locale)); } } ftp.logout(); } } catch (IOException ioe) { - errorList.add("Problem with FTP transfer: " + ioe.getMessage()); + errorList.add(UtilProperties.getMessage(resource, "CommonFtpProblemWithTransfer", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); } finally { if (ftp.isConnected()) { try { Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java?rev=1066157&r1=1066156&r2=1066157&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java Tue Feb 1 19:27:13 2011 @@ -89,6 +89,7 @@ public class EmailServices { protected static final HtmlScreenRenderer htmlScreenRenderer = new HtmlScreenRenderer(); protected static final FoScreenRenderer foScreenRenderer = new FoScreenRenderer(); + public static final String resource = "CommonUiLabels"; /** * Basic JavaMail Service @@ -99,6 +100,7 @@ public class EmailServices { public static Map<String, Object> sendMail(DispatchContext ctx, Map<String, ? extends Object> context) { String communicationEventId = (String) context.get("communicationEventId"); String orderId = (String) context.get("orderId"); + Locale locale = (Locale) context.get("locale"); if (communicationEventId != null) { Debug.logInfo("SendMail Running, for communicationEventId : " + communicationEventId, module); } @@ -187,7 +189,7 @@ public class EmailServices { sendPartial = UtilProperties.propertyValueEqualsIgnoreCase("general.properties", "mail.smtp.sendpartial", "true") ? true : false; } } else if (sendVia == null) { - return ServiceUtil.returnError("Parameter sendVia is required when sendType is not mail.smtp.host"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMissingParameterSendVia", locale)); } if (contentType == null) { @@ -286,15 +288,13 @@ public class EmailServices { mail.saveChanges(); } } catch (MessagingException e) { - String errMsg = "MessagingException when creating message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]"; - Debug.logError(e, errMsg, module); + Debug.logError(e, "MessagingException when creating message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]", module); Debug.logError("Email message that could not be created to [" + sendTo + "] had context: " + context, module); - return ServiceUtil.returnError(errMsg); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMessagingException", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); } catch (IOException e) { - String errMsg = "IOExcepton when creating message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]"; - Debug.logError(e, errMsg, module); + Debug.logError(e, "IOExcepton when creating message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]", module); Debug.logError("Email message that could not be created to [" + sendTo + "] had context: " + context, module); - return ServiceUtil.returnError(errMsg); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendIOException", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); } // check to see if sending mail is enabled @@ -321,14 +321,13 @@ public class EmailServices { trans.close(); } catch (SendFailedException e) { // message code prefix may be used by calling services to determine the cause of the failure - String errMsg = "[ADDRERR] Address error when sending message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]"; - Debug.logError(e, errMsg, module); + Debug.logError(e, "[ADDRERR] Address error when sending message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]", module); List<SMTPAddressFailedException> failedAddresses = FastList.newInstance(); Exception nestedException = null; while ((nestedException = e.getNextException()) != null && nestedException instanceof MessagingException) { if (nestedException instanceof SMTPAddressFailedException) { SMTPAddressFailedException safe = (SMTPAddressFailedException) nestedException; - Debug.logError("Failed to send message to [" + safe.getAddress() + "], return code [" + safe.getReturnCode() + "], return message [" + safe.getMessage() + "]", errMsg); + Debug.logError("Failed to send message to [" + safe.getAddress() + "], return code [" + safe.getReturnCode() + "], return message [" + safe.getMessage() + "]", module); failedAddresses.add(safe); break; } @@ -344,14 +343,13 @@ public class EmailServices { Debug.logError(e1, module); } } else { - return ServiceUtil.returnError(errMsg); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendAddressError", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); } } catch (MessagingException e) { // message code prefix may be used by calling services to determine the cause of the failure - String errMsg = "[CON] Connection error when sending message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]"; - Debug.logError(e, errMsg, module); + Debug.logError(e, "[CON] Connection error when sending message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]", module); Debug.logError("Email message that could not be sent to [" + sendTo + "] had context: " + context, module); - return ServiceUtil.returnError(errMsg); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendConnectionError", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale)); } return results; } @@ -367,7 +365,7 @@ public class EmailServices { Map<String, Object> sendMailContext = UtilMisc.makeMapWritable(rcontext); String bodyUrl = (String) sendMailContext.remove("bodyUrl"); Map<String, Object> bodyUrlParameters = UtilGenerics.checkMap(sendMailContext.remove("bodyUrlParameters")); - + Locale locale = (Locale) rcontext.get("locale"); LocalDispatcher dispatcher = ctx.getDispatcher(); URL url = null; @@ -376,7 +374,7 @@ public class EmailServices { url = new URL(bodyUrl); } catch (MalformedURLException e) { Debug.logWarning(e, module); - return ServiceUtil.returnError("Malformed URL: " + bodyUrl + "; error was: " + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMalformedUrl", UtilMisc.toMap("bodyUrl", bodyUrl, "errorString", e.toString()), locale)); } HttpClient httpClient = new HttpClient(url, bodyUrlParameters); @@ -386,7 +384,7 @@ public class EmailServices { body = httpClient.post(); } catch (HttpClientException e) { Debug.logWarning(e, module); - return ServiceUtil.returnError("Error getting content: " + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendGettingError", UtilMisc.toMap("errorString", e.toString()), locale)); } sendMailContext.put("body", body); @@ -460,21 +458,17 @@ public class EmailServices { try { screens.render(bodyScreenUri); } catch (GeneralException e) { - String errMsg = "Error rendering screen for email: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error rendering screen for email: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenEmailError", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (IOException e) { - String errMsg = "Error rendering screen for email: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error rendering screen for email: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenEmailError", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (SAXException e) { - String errMsg = "Error rendering screen for email: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error rendering screen for email: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenEmailError", UtilMisc.toMap("errorString", e.toString()), locale)); } catch (ParserConfigurationException e) { - String errMsg = "Error rendering screen for email: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error rendering screen for email: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenEmailError", UtilMisc.toMap("errorString", e.toString()), locale)); } } @@ -494,7 +488,7 @@ public class EmailServices { String xslfoAttachScreenLocation = xslfoAttachScreenLocationList.get(i); String attachmentName = "Details.pdf"; if (UtilValidate.isNotEmpty(attachmentNameList) && attachmentNameList.size() >= i) { - attachmentName = attachmentNameList.get(i); + attachmentName = attachmentNameList.get(i); } isMultiPart = true; // start processing fo pdf attachment @@ -534,25 +528,20 @@ public class EmailServices { // store in the list of maps for sendmail.... bodyParts.add(UtilMisc.<String, Object>toMap("content", baos.toByteArray(), "type", "application/pdf", "filename", attachmentName)); } catch (GeneralException ge) { - String errMsg = "Error rendering PDF attachment for email: " + ge.toString(); - Debug.logError(ge, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(ge, "Error rendering PDF attachment for email: " + ge.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenPdfError", UtilMisc.toMap("errorString", ge.toString()), locale)); } catch (IOException ie) { - String errMsg = "Error rendering PDF attachment for email: " + ie.toString(); - Debug.logError(ie, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(ie, "Error rendering PDF attachment for email: " + ie.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenPdfError", UtilMisc.toMap("errorString", ie.toString()), locale)); } catch (FOPException fe) { - String errMsg = "Error rendering PDF attachment for email: " + fe.toString(); - Debug.logError(fe, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(fe, "Error rendering PDF attachment for email: " + fe.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenPdfError", UtilMisc.toMap("errorString", fe.toString()), locale)); } catch (SAXException se) { - String errMsg = "Error rendering PDF attachment for email: " + se.toString(); - Debug.logError(se, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(se, "Error rendering PDF attachment for email: " + se.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenPdfError", UtilMisc.toMap("errorString", se.toString()), locale)); } catch (ParserConfigurationException pe) { - String errMsg = "Error rendering PDF attachment for email: " + pe.toString(); - Debug.logError(pe, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(pe, "Error rendering PDF attachment for email: " + pe.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendRenderingScreenPdfError", UtilMisc.toMap("errorString", pe.toString()), locale)); } serviceContext.put("bodyParts", bodyParts); @@ -600,9 +589,8 @@ public class EmailServices { sendMailResult = dispatcher.runSync("sendMail", serviceContext); } } catch (Exception e) { - String errMsg = "Error send email :" + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error send email:" + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendError", UtilMisc.toMap("errorString", e.toString()), locale)); } if (ServiceUtil.isError(sendMailResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(sendMailResult)); @@ -622,21 +610,24 @@ public class EmailServices { } public static void sendFailureNotification(DispatchContext dctx, Map<String, ? extends Object> context, MimeMessage message, List<SMTPAddressFailedException> failures) { + Locale locale = (Locale) context.get("locale"); Map<String, Object> newContext = FastMap.newInstance(); newContext.put("userLogin", context.get("userLogin")); newContext.put("sendFailureNotification", false); newContext.put("sendFrom", context.get("sendFrom")); newContext.put("sendTo", context.get("sendFrom")); - newContext.put("subject", "Undelivered Mail Returned to Sender"); + newContext.put("subject", UtilProperties.getMessage(resource, "CommonEmailSendUndeliveredMail", locale)); StringBuilder sb = new StringBuilder(); - sb.append("Delivery to the following recipient(s) failed:\n\n"); + sb.append(UtilProperties.getMessage(resource, "CommonEmailDeliveryFailed", locale)); + sb.append("/n/n"); for (SMTPAddressFailedException failure : failures) { sb.append(failure.getAddress()); sb.append(": "); sb.append(failure.getMessage()); sb.append("/n/n"); } - sb.append("----- Original message -----/n/n"); + sb.append(UtilProperties.getMessage(resource, "CommonEmailDeliveryOriginalMessage", locale)); + sb.append("/n/n"); List<Map<String, Object>> bodyParts = FastList.newInstance(); bodyParts.add(UtilMisc.<String, Object>toMap("content", sb.toString(), "type", "text/plain")); Map<String, Object> bodyPart = FastMap.newInstance(); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java?rev=1066157&r1=1066156&r2=1066157&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java Tue Feb 1 19:27:13 2011 @@ -24,6 +24,7 @@ import java.io.Writer; import java.net.InetAddress; import java.net.URL; import java.net.UnknownHostException; +import java.util.Locale; import java.util.Map; import javolution.util.FastMap; @@ -100,6 +101,7 @@ import freemarker.template.TemplateExcep public class NotificationServices { public static final String module = NotificationServices.class.getName(); + public static final String resource = "CommonUiLabels"; /** * This will use the {@link #prepareNotification(DispatchContext, Map) prepareNotification(DispatchContext, Map)} @@ -119,6 +121,7 @@ public class NotificationServices { */ public static Map<String, Object> sendNotification(DispatchContext ctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = ctx.getDispatcher(); + Locale locale = (Locale) context.get("locale"); Map<String, Object> result = null; try { @@ -158,11 +161,11 @@ public class NotificationServices { result = dispatcher.runSync("sendMail", emailContext); } else { Debug.logError("Invalid email body; null is not allowed", module); - result = ServiceUtil.returnError("Invalid email body; null is not allowed"); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailInvalidBody", locale)); } } catch (GenericServiceException serviceException) { Debug.logError(serviceException, "Error sending email", module); - result = ServiceUtil.returnError("Email delivery error, see error log"); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailDeliveryError", locale)); } return result; @@ -188,7 +191,7 @@ public class NotificationServices { String templateName = (String) context.get("templateName"); Map<String, Object> templateData = UtilGenerics.checkMap(context.get("templateData")); String webSiteId = (String) context.get("webSiteId"); - + Locale locale = (Locale) context.get("locale"); Map<String, Object> result = null; if (templateData == null) { templateData = FastMap.newInstance(); @@ -203,7 +206,7 @@ public class NotificationServices { if (templateUrl == null) { Debug.logError("Problem getting the template URL: " + templateName + " not found", module); - return ServiceUtil.returnError("Problem finding template; see logs"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailProblemFindingTemplate", locale)); } // process the template with the given data and write @@ -215,14 +218,14 @@ public class NotificationServices { String notificationBody = writer.toString(); // generate the successfull reponse - result = ServiceUtil.returnSuccess("Message body generated successfully"); + result = ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "CommonNotifyEmailMessageBodyGeneratedSuccessfully", locale)); result.put("body", notificationBody); } catch (IOException ie) { Debug.logError(ie, "Problems reading template", module); - result = ServiceUtil.returnError("Template reading problem, see error logs"); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailProblemReadingTemplate", locale)); } catch (TemplateException te) { Debug.logError(te, "Problems processing template", module); - result = ServiceUtil.returnError("Template processing problem, see error log"); + result = ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonNotifyEmailProblemProcessingTemplate", locale)); } return result; Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java?rev=1066157&r1=1066156&r2=1066157&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java Tue Feb 1 19:27:13 2011 @@ -19,12 +19,14 @@ package org.ofbiz.common.status; import java.util.List; +import java.util.Locale; import java.util.Map; import javolution.util.FastList; import javolution.util.FastMap; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import static org.ofbiz.base.util.UtilGenerics.checkList; @@ -41,12 +43,14 @@ import org.ofbiz.service.ServiceUtil; public class StatusServices { public static final String module = StatusServices.class.getName(); + public static final String resource = "CommonUiLabels"; public static Map<String, Object> getStatusItems(DispatchContext ctx, Map<String, ?> context) { Delegator delegator = ctx.getDelegator(); List<String> statusTypes = checkList(context.get("statusTypeIds"), String.class); + Locale locale = (Locale) context.get("locale"); if (UtilValidate.isEmpty(statusTypes)) { - return ServiceUtil.returnError("Parameter statusTypeIds can not be null and must contain at least one element"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonStatusMandatory", locale)); } List<GenericValue> statusItems = FastList.newInstance(); |
Free forum by Nabble | Edit this page |