|
Author: mrisaliti
Date: Tue Jan 11 19:57:04 2011 New Revision: 1057831 URL: http://svn.apache.org/viewvc?rev=1057831&view=rev Log: Internationalization of ServiceUtil.returnSuccess, ServiceUtil.returnFailure, ServiceUtil.returnError (OFBIZ-4091) Modified: ofbiz/trunk/applications/content/config/ContentUiLabels.xml ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchServices.java Modified: ofbiz/trunk/applications/content/config/ContentUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/config/ContentUiLabels.xml?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/config/ContentUiLabels.xml (original) +++ ofbiz/trunk/applications/content/config/ContentUiLabels.xml Tue Jan 11 19:57:04 2011 @@ -224,9 +224,13 @@ <value xml:lang="zh">æµè§</value> <value xml:lang="zh_TW">ç覽</value> </property> - <property key="ContentCannotChangeStatus"> - <value xml:lang="en">Cannot change from ${content.statusId} to ${parameters.statusId}</value> - <value xml:lang="it">Non è possibile cambiare lo stato da ${content.statusId} a ${parameters.statusId}</value> + <property key="ContentCannotFindContextFileWithEmptyContextRoot"> + <value xml:lang="en">Cannot find CONTEXT_FILE with an empty context root!</value> + <value xml:lang="it">Non è possibile trovare il CONTEXT_FILE con un contesto principale vuoto!</value> + </property> + <property key="ContentCannotProcessBothCharacterAndBinaryFile"> + <value xml:lang="en">Cannot process both character and binary data in the same file</value> + <value xml:lang="it">Non è possibile processare i dati di entrambi i file binari e carattere</value> </property> <property key="ContentCMS"> <value xml:lang="ar">CMS</value> @@ -308,6 +312,10 @@ <value xml:lang="zh">å符é</value> <value xml:lang="zh_TW">å符é</value> </property> + <property key="ContentClearAssociatedRenderCacheError"> + <value xml:lang="en">Unable to clear associated render cache with dataResourceId ${dataResourceId}</value> + <value xml:lang="it">Non è possibile pulire la cache associata alla risorsa dati ${dataResourceId}</value> + </property> <property key="ContentClip"> <value xml:lang="da">Klip</value> <value xml:lang="en">Clip</value> @@ -606,6 +614,18 @@ <value xml:lang="zh">å 容</value> <value xml:lang="zh_TW">å §å®¹</value> </property> + <property key="ContentContentCreatingError"> + <value xml:lang="en">Error creating content in ${serviceName}</value> + <value xml:lang="it">Errore durante la creazione del contenuto in ${serviceName}</value> + </property> + <property key="ContentContentNoAccessToUploadImage"> + <value xml:lang="en">no access to upload image</value> + <value xml:lang="it">nessun accesso per caricare l'immagine</value> + </property> + <property key="ContentContentUpdatingError"> + <value xml:lang="en">Error updating content in ${serviceName}</value> + <value xml:lang="it">Errore durante l'aggiornamento del contenuto in ${serviceName}</value> + </property> <property key="ContentContentManager"> <value xml:lang="ar">تطبÙ٠تسÙÙØ± اÙÙ ØØªÙÙ</value> <value xml:lang="da">Indholdsadministrator</value> @@ -648,6 +668,14 @@ <value xml:lang="zh">å 容设置</value> <value xml:lang="zh_TW">å §å®¹è¨ç½®</value> </property> + <property key="ContentContentToOrFromIsNull"> + <value xml:lang="en">contentTo ${contentTo}/From ${contentFrom} is null.</value> + <value xml:lang="it">Contenuto a ${contentTo}/da ${contentFrom} è nullo.</value> + </property> + <property key="ContentContentToOrFromErrorRetriving"> + <value xml:lang="en">Error in retrieving content To or From.</value> + <value xml:lang="it">Errore nel ricavare il contenuto a o da.</value> + </property> <property key="ContentContentsAssociatedToDataResource"> <value xml:lang="da">Indholdselementer tilknyttet til denne data ressource</value> <value xml:lang="de">Inhaltseinträge zugeordnet zu dieser Datenressource</value> @@ -662,6 +690,10 @@ <value xml:lang="en">Content Id or Upload file is missing.</value> <value xml:lang="it">Id contenuto o file da caricare è mancante.</value> </property> + <property key="ContentConvertingDocumentError"> + <value xml:lang="en">Error converting document: ${errorString}</value> + <value xml:lang="it">Errore durante la conversione del documento: ${errorString}</value> + </property> <property key="ContentCreateDateInvalidFormat"> <value xml:lang="en">Created Date is not a valid Timestamp input format.</value> <value xml:lang="it">Data creazione non è nel formato valido.</value> @@ -1115,6 +1147,10 @@ <value xml:lang="en">fromDate not a valid date format</value> <value xml:lang="it">Data dal non è nel formato valido.</value> </property> + <property key="ContentCannotGenerateBlogRssFeed"> + <value xml:lang="en">Not able to generate RSS feed for content: ${contentId}</value> + <value xml:lang="it">Non è possibile generare il feed RSS per il contenuto: ${contentId}</value> + </property> <property key="ContentGIF"> <value xml:lang="da">GIF</value> <value xml:lang="en">GIF</value> @@ -1227,6 +1263,10 @@ <value xml:lang="zh">为è¾å ¥çæ è¯å»ºç«ç´¢å¼</value> <value xml:lang="zh_TW">çºè¼¸å ¥çID建ç«ç´¢å¼</value> </property> + <property key="ContentIndexingTreeError"> + <value xml:lang="en">Error indexing tree: ${errorString}</value> + <value xml:lang="it">Errore di indicizzazione albero: ${errorString}</value> + </property> <property key="ContentJPEG"> <value xml:lang="da">JPEG</value> <value xml:lang="en">JPEG</value> @@ -1266,6 +1306,10 @@ <value xml:lang="zh">ååºèªå»ºæ¨¡æ¿</value> <value xml:lang="zh_TW">ååºèªå»ºç¯æ¬</value> </property> + <property key="ContentLocalFileDoesNotPointToAbsoluteLocation"> + <value xml:lang="en">DataResource LOCAL_FILE does not point to an absolute location</value> + <value xml:lang="it">La risorda dati LOCAL_FILE non punta ad una posizione assoluta</value> + </property> <property key="ContentMSWord"> <value xml:lang="da">MS Word</value> <value xml:lang="en">MS Word</value> @@ -1390,6 +1434,10 @@ <value xml:lang="en">Content record not found for ID ${contentId}</value> <value xml:lang="it">Contenuto non trovato per ID ${contentId}</value> </property> + <property key="ContentNoContentFilePassed"> + <value xml:lang="en">No file content passed for: ${fileName}</value> + <value xml:lang="it">Nessun file contenuto passato per: ${fileName}</value> + </property> <property key="ContentNoQuestionsSurveyFound"> <value xml:lang="en">No questions found for survey ID: ${survey.surveyId}</value> <value xml:lang="it">Nessuna domanda sondaggio trovata con ID: ${surveyLookup.surveyId}</value> @@ -1499,6 +1547,18 @@ <value xml:lang="en">Permission not granted.</value> <value xml:lang="it">Permesso non abilitato.</value> </property> + <property key="ContentPrinterNotAvailable"> + <value xml:lang="en">No printer available</value> + <value xml:lang="it">Nessuna stampante disponibile</value> + </property> + <property key="ContentPrinterNotFound"> + <value xml:lang="en">No printer found with name: ${printerName}</value> + <value xml:lang="it">Nessuna stampante trovate con il nome: ${printerName}</value> + </property> + <property key="ContentPrinterNotSupportDocFlavorFormat"> + <value xml:lang="en">DocFlavor ${psInFormat} not supported by printer: ${printerName}</value> + <value xml:lang="it">Il formato Doc Flavor ${psInFormat} non è supportato dalla stampante: ${printerName}</value> + </property> <property key="ContentPlainText"> <value xml:lang="da">Klartekst</value> <value xml:lang="en">Plain Text</value> @@ -1559,6 +1619,10 @@ <value xml:lang="zh">éå½åæä»¶å¤¹</value> <value xml:lang="zh_TW">éå½åæä»¶å¤¾</value> </property> + <property key="ContentRenderingError"> + <value xml:lang="en">Error rendering ${contentType}: ${errorString}</value> + <value xml:lang="it">Errore di rendering ${contentType}: ${errorString}</value> + </property> <property key="ContentRequiredField"> <value xml:lang="en">Required field ${requiredField} is missing in simple method call ${resourceDescription}</value> <value xml:lang="it">Campo ${requiredField} è richiesto ed è mancante nella chiamata a ${resourceDescription}</value> @@ -2264,6 +2328,22 @@ <value xml:lang="zh">ç±»å屿§</value> <value xml:lang="zh_TW">é¡å屬æ§</value> </property> + <property key="ContentUnableObtainReferenceToFile"> + <value xml:lang="en">Unable to obtain a reference to file ${objectInfo}</value> + <value xml:lang="it">Non è possibile ottenere un riferimento al file ${objectInfo}</value> + </property> + <property key="ContentUnableToOpenFileForWriting"> + <value xml:lang="en">Unable to open file for writing: ${fileName}</value> + <value xml:lang="it">Non è possibile aprire il file in scrittura: ${fileName}</value> + </property> + <property key="ContentUnableWriteBinaryDataToFile"> + <value xml:lang="en">Unable to write binary data to: ${fileName}</value> + <value xml:lang="it">Non è possibile scrivere i dati binari in: ${fileName}</value> + </property> + <property key="ContentUnableWriteCharacterDataToFile"> + <value xml:lang="en">Unable to write character data to: ${fileName}</value> + <value xml:lang="it">Non è possibile scrivere i dati carattere in: ${fileName}</value> + </property> <property key="ContentUpdatePermissionError"> <value xml:lang="ar">You do not have permission to view this page. ("CONTENTMGR_UPDATE" or "CONTENTMGR_ADMIN" needed)</value> <value xml:lang="da">Du har ikke tilladelse til at se denne side. ("CONTENTMGR_UPDATE" eller "CONTENTMGR_ADMIN" krævet)</value> Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java Tue Jan 11 19:57:04 2011 @@ -24,6 +24,7 @@ import java.sql.Timestamp; import com.ibm.icu.util.Calendar; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -36,6 +37,7 @@ import javolution.util.FastSet; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.cache.UtilCache; @@ -65,6 +67,7 @@ import org.ofbiz.service.ServiceUtil; public class ContentManagementServices { public static final String module = ContentManagementServices.class.getName(); + public static final String resource = "ContentUiLabels"; /** * getSubContent @@ -165,6 +168,7 @@ public class ContentManagementServices { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Map<String, Object> context = UtilMisc.makeMapWritable(rcontext); + Locale locale = (Locale) context.get("locale"); Debug.logInfo("=========== type:" + (String)context.get("dataresourceTypeId") , module); // Knowing why a request fails permission check is one of the more difficult @@ -315,7 +319,9 @@ public class ContentManagementServices { Debug.logInfo("In persistContentAndAssoc calling updateContent with content: " + contentContext, module); Map thisResult = dispatcher.runSync("updateContent", contentContext); if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) { - return ServiceUtil.returnError("Error updating content (updateContent) in persistContentAndAssoc", null, null, thisResult); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentContentUpdatingError", + UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale), null, null, thisResult); } //Map thisResult = ContentServices.updateContentMethod(dctx, context); } else { @@ -329,7 +335,9 @@ public class ContentManagementServices { Debug.logInfo("In persistContentAndAssoc calling createContent with content: " + contentContext, module); Map thisResult = dispatcher.runSync("createContent", contentContext); if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) { - return ServiceUtil.returnError("Error creating content (createContent) in persistContentAndAssoc", null, null, thisResult); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentContentCreatingError", + UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale), null, null, thisResult); } //Map thisResult = ContentServices.createContentMethod(dctx, context); @@ -526,7 +534,7 @@ public class ContentManagementServices { // for now, will assume that any error is due to non-existence - ignore //return ServiceUtil.returnError(e.toString()); try { -Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); + Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); //Timestamp thruDate = UtilDateTime.nowTimestamp(); //serviceContext.put("thruDate", thruDate); //serviceContext.put("fromDate", fromDate); @@ -556,6 +564,7 @@ Debug.logInfo("updateSiteRoles, serviceC //Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); //String contentId = (String)context.get("contentId"); + Locale locale = (Locale) context.get("locale"); Map result = FastMap.newInstance(); try { //GenericValue content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); @@ -567,7 +576,8 @@ Debug.logInfo("updateSiteRoles, serviceC result = persistDataResourceAndDataMethod(dctx, context); } else { - return ServiceUtil.returnError("no access to upload image"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentContentNoAccessToUploadImage", locale)); } } catch (GenericServiceException e) { Debug.logError(e, e.toString(), module); @@ -678,8 +688,6 @@ Debug.logInfo("updateSiteRoles, serviceC if (UtilValidate.isNotEmpty(errorMsg)) { return ServiceUtil.returnError(errorMsg); } - } else { - //return ServiceUtil.returnError("'byteBuffer' empty when trying to create database image."); } } else if (dataResourceTypeId.equals("SHORT_TEXT")) { } else if (dataResourceTypeId.startsWith("SURVEY")) { @@ -738,8 +746,6 @@ Debug.logInfo("updateSiteRoles, serviceC if (UtilValidate.isNotEmpty(errorMsg)) { return ServiceUtil.returnError(errorMsg); } -// } else { -// return ServiceUtil.returnError("'byteBuffer' empty when trying to create database image."); } } else if (dataResourceTypeId.equals("SHORT_TEXT")) { } else if (dataResourceTypeId.startsWith("SURVEY")) { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java Tue Jan 11 19:57:04 2011 @@ -31,6 +31,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.content.content.ContentWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; @@ -53,6 +54,7 @@ import com.sun.syndication.feed.synd.Syn public class BlogRssServices { public static final String module = BlogRssServices.class.getName(); + public static final String resource = "ContentUiLabels"; public static final String mimeTypeId = "text/html"; public static final String mapKey = "SUMMARY"; @@ -79,7 +81,9 @@ public class BlogRssServices { } if (content == null) { - return ServiceUtil.returnError("Not able to generate RSS feed for content: " + contentId); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentCannotGenerateBlogRssFeed", + UtilMisc.toMap("contentId", contentId), locale)); } // create the feed Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java Tue Jan 11 19:57:04 2011 @@ -19,6 +19,7 @@ package org.ofbiz.content.content; import java.util.List; +import java.util.Locale; import java.util.Map; import javolution.util.FastList; @@ -27,6 +28,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; @@ -48,7 +50,7 @@ import org.ofbiz.service.LocalDispatcher public class ContentPermissionServices { public static final String module = ContentPermissionServices.class.getName(); - + public static final String resource = "ContentUiLabels"; public ContentPermissionServices() {} @@ -258,7 +260,6 @@ public class ContentPermissionServices { } public static Map<String, Object> checkAssocPermission(DispatchContext dctx, Map<String, ? extends Object> context) { - Map results = FastMap.newInstance(); Security security = dctx.getSecurity(); Delegator delegator = dctx.getDelegator(); @@ -268,6 +269,7 @@ public class ContentPermissionServices { String contentIdTo = (String) context.get("contentIdTo"); GenericValue userLogin = (GenericValue) context.get("userLogin"); String entityAction = (String) context.get("entityOperation"); + Locale locale = (Locale) context.get("locale"); if (entityAction == null) entityAction = "_ADMIN"; List roleIds = null; String permissionStatus = null; @@ -278,10 +280,13 @@ public class ContentPermissionServices { contentTo = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentIdTo)); contentFrom = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentIdFrom)); } catch (GenericEntityException e) { - return ServiceUtil.returnError("Error in retrieving content To or From. " + e.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentContentToOrFromErrorRetriving", locale)); } if (contentTo == null || contentFrom == null) { - return ServiceUtil.returnError("contentTo[" + contentTo + "]/From[" + contentFrom + "] is null. "); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentContentToOrFromIsNull", + UtilMisc.toMap("contentTo", contentTo, "contentFrom", contentFrom), locale)); } Map resultsMap = null; boolean isMatch = false; Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java Tue Jan 11 19:57:04 2011 @@ -38,6 +38,7 @@ 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.Delegator; import org.ofbiz.entity.GenericEntityException; @@ -53,16 +54,19 @@ import org.ofbiz.service.ServiceUtil; public class DataServices { public static final String module = DataServices.class.getName(); + public static final String resource = "ContentUiLabels"; public static Map<String, Object> clearAssociatedRenderCache(DispatchContext dctx, Map<String, Object> context) { Delegator delegator = dctx.getDelegator(); String dataResourceId = (String) context.get("dataResourceId"); + Locale locale = (Locale) context.get("locale"); try { DataResourceWorker.clearAssociatedRenderCache(delegator, dataResourceId); } catch (GeneralException e) { - String errMsg = "Unable to clear associated render cache with dataResourceId=" + dataResourceId; - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Unable to clear associated render cache with dataResourceId=" + dataResourceId, module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentClearAssociatedRenderCacheError", + UtilMisc.toMap("dataResourceId", dataResourceId), locale)); } return ServiceUtil.returnSuccess(); } @@ -198,6 +202,7 @@ public class DataServices { String objectInfo = (String) context.get("objectInfo"); ByteBuffer binData = (ByteBuffer) context.get("binData"); String textData = (String) context.get("textData"); + Locale locale = (Locale) context.get("locale"); // a few place holders String prefix = ""; @@ -205,7 +210,8 @@ public class DataServices { // extended validation for binary/character data if (UtilValidate.isNotEmpty(textData) && binData != null) { - return ServiceUtil.returnError("Cannot process both character and binary data in the same file"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentCannotProcessBothCharacterAndBinaryFile", locale)); } // obtain a reference to the file @@ -213,7 +219,8 @@ public class DataServices { if (UtilValidate.isEmpty(dataResourceTypeId) || dataResourceTypeId.equals("LOCAL_FILE") || dataResourceTypeId.equals("LOCAL_FILE_BIN")) { file = new File(objectInfo); if (!file.isAbsolute()) { - return ServiceUtil.returnError("DataResource LOCAL_FILE does not point to an absolute location"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentLocalFileDoesNotPointToAbsoluteLocation", locale)); } } else if (dataResourceTypeId.equals("OFBIZ_FILE") || dataResourceTypeId.equals("OFBIZ_FILE_BIN")) { prefix = System.getProperty("ofbiz.home"); @@ -224,7 +231,8 @@ public class DataServices { } else if (dataResourceTypeId.equals("CONTEXT_FILE") || dataResourceTypeId.equals("CONTEXT_FILE_BIN")) { prefix = (String) context.get("rootDir"); if (UtilValidate.isEmpty(prefix)) { - return ServiceUtil.returnError("Cannot find CONTEXT_FILE with an empty context root!"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentCannotFindContextFileWithEmptyContextRoot", locale)); } if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { sep = "/"; @@ -232,7 +240,9 @@ public class DataServices { file = new File(prefix + sep + objectInfo); } if (file == null) { - return ServiceUtil.returnError("Unable to obtain a reference to file - " + objectInfo); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentUnableObtainReferenceToFile", + UtilMisc.toMap("objectInfo", objectInfo), locale)); } // write the data to the file @@ -243,7 +253,9 @@ public class DataServices { out.close(); } catch (IOException e) { Debug.logWarning(e, module); - return ServiceUtil.returnError("Unable to write character data to: " + file.getAbsolutePath()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentUnableWriteCharacterDataToFile", + UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); } } else if (binData != null) { try { @@ -252,13 +264,19 @@ public class DataServices { out.close(); } catch (FileNotFoundException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to open file for writing: " + file.getAbsolutePath()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentUnableToOpenFileForWriting", + UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); } catch (IOException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to write binary data to: " + file.getAbsolutePath()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentUnableWriteBinaryDataToFile", + UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); } } else { - return ServiceUtil.returnError("No file content passed for: " + file.getAbsolutePath()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFilePassed", + UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); } Map result = ServiceUtil.returnSuccess(); @@ -295,35 +313,36 @@ public class DataServices { } public static Map<String, Object> updateDataResourceMethod(DispatchContext dctx, Map<String, ? extends Object> context) { - Map result = FastMap.newInstance(); Delegator delegator = dctx.getDelegator(); GenericValue dataResource = null; - //Locale locale = (Locale) context.get("locale"); - GenericValue userLogin = (GenericValue) context.get("userLogin"); - String userLoginId = (String) userLogin.get("userLoginId"); - String lastModifiedByUserLogin = userLoginId; - Timestamp lastModifiedDate = UtilDateTime.nowTimestamp(); + Locale locale = (Locale) context.get("locale"); + GenericValue userLogin = (GenericValue) context.get("userLogin"); + String userLoginId = (String) userLogin.get("userLoginId"); + String lastModifiedByUserLogin = userLoginId; + Timestamp lastModifiedDate = UtilDateTime.nowTimestamp(); - // If textData exists, then create DataResource and return dataResourceId - String dataResourceId = (String) context.get("dataResourceId"); - try { - dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); - } catch (GenericEntityException e) { - Debug.logWarning(e, module); - return ServiceUtil.returnError("dataResource.update.read_failure" + e.getMessage()); - } + // If textData exists, then create DataResource and return dataResourceId + String dataResourceId = (String) context.get("dataResourceId"); + try { + dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentDataResourceNotFound", + UtilMisc.toMap("parameters.dataResourceId", dataResourceId), locale)); + } - dataResource.setNonPKFields(context); - dataResource.put("lastModifiedByUserLogin", lastModifiedByUserLogin); - dataResource.put("lastModifiedDate", lastModifiedDate); + dataResource.setNonPKFields(context); + dataResource.put("lastModifiedByUserLogin", lastModifiedByUserLogin); + dataResource.put("lastModifiedDate", lastModifiedDate); - try { - dataResource.store(); - } catch (GenericEntityException e) { - Debug.logError(e, module); - return ServiceUtil.returnError(e.getMessage()); - } + try { + dataResource.store(); + } catch (GenericEntityException e) { + Debug.logError(e, module); + return ServiceUtil.returnError(e.getMessage()); + } result.put("dataResource", dataResource); return result; @@ -348,7 +367,7 @@ public class DataServices { Map result = FastMap.newInstance(); Delegator delegator = dctx.getDelegator(); GenericValue electronicText = null; - //Locale locale = (Locale) context.get("locale"); + Locale locale = (Locale) context.get("locale"); String dataResourceId = (String) context.get("dataResourceId"); result.put("dataResourceId",dataResourceId); String contentId = (String) context.get("contentId"); @@ -374,7 +393,8 @@ public class DataServices { } } catch (GenericEntityException e) { Debug.logWarning(e, module); - return ServiceUtil.returnError("electronicText.update.read_failure" + e.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentElectronicTextNotFound", locale) + " " + e.getMessage()); } return result; @@ -396,42 +416,42 @@ public class DataServices { public static Map<String, Object> updateFileMethod(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException { Map result = FastMap.newInstance(); //GenericValue fileText = null; - //Locale locale = (Locale) context.get("locale"); - //String dataResourceId = (String) dataResource.get("dataResourceId"); - String dataResourceTypeId = (String) context.get("dataResourceTypeId"); - String objectInfo = (String) context.get("objectInfo"); - String textData = (String) context.get("textData"); - ByteBuffer binData = (ByteBuffer) context.get("binData"); - String prefix = ""; - File file = null; - String fileName = ""; - String sep = ""; - try { - if (UtilValidate.isEmpty(dataResourceTypeId) || dataResourceTypeId.startsWith("LOCAL_FILE")) { - fileName = prefix + sep + objectInfo; - file = new File(fileName); - if (file == null) { - throw new GenericServiceException("File: " + fileName + " is null."); - } - if (!file.isAbsolute()) { - throw new GenericServiceException("File: " + fileName + " is not absolute."); - } - } else if (dataResourceTypeId.startsWith("OFBIZ_FILE")) { - prefix = System.getProperty("ofbiz.home"); - if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { - sep = "/"; - } - file = new File(prefix + sep + objectInfo); - } else if (dataResourceTypeId.startsWith("CONTEXT_FILE")) { - prefix = (String) context.get("rootDir"); - if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { - sep = "/"; - } - file = new File(prefix + sep + objectInfo); - } + Locale locale = (Locale) context.get("locale"); + //String dataResourceId = (String) dataResource.get("dataResourceId"); + String dataResourceTypeId = (String) context.get("dataResourceTypeId"); + String objectInfo = (String) context.get("objectInfo"); + String textData = (String) context.get("textData"); + ByteBuffer binData = (ByteBuffer) context.get("binData"); + String prefix = ""; + File file = null; + String fileName = ""; + String sep = ""; + try { + if (UtilValidate.isEmpty(dataResourceTypeId) || dataResourceTypeId.startsWith("LOCAL_FILE")) { + fileName = prefix + sep + objectInfo; + file = new File(fileName); if (file == null) { - throw new IOException("File: " + file + " is null"); + throw new GenericServiceException("File: " + fileName + " is null."); + } + if (!file.isAbsolute()) { + throw new GenericServiceException("File: " + fileName + " is not absolute."); } + } else if (dataResourceTypeId.startsWith("OFBIZ_FILE")) { + prefix = System.getProperty("ofbiz.home"); + if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { + sep = "/"; + } + file = new File(prefix + sep + objectInfo); + } else if (dataResourceTypeId.startsWith("CONTEXT_FILE")) { + prefix = (String) context.get("rootDir"); + if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { + sep = "/"; + } + file = new File(prefix + sep + objectInfo); + } + if (file == null) { + throw new IOException("File: " + file + " is null"); + } // write the data to the file if (UtilValidate.isNotEmpty(textData)) { @@ -441,7 +461,9 @@ public class DataServices { out.close(); } catch (IOException e) { Debug.logWarning(e, module); - return ServiceUtil.returnError("Unable to write character data to: " + file.getAbsolutePath()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentUnableWriteCharacterDataToFile", + UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); } } else if (binData != null) { try { @@ -450,19 +472,25 @@ public class DataServices { out.close(); } catch (FileNotFoundException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to open file for writing: " + file.getAbsolutePath()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentUnableToOpenFileForWriting", + UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); } catch (IOException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Unable to write binary data to: " + file.getAbsolutePath()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentUnableWriteBinaryDataToFile", + UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); } } else { - return ServiceUtil.returnError("No file content passed for: " + file.getAbsolutePath()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFilePassed", + UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); } - } catch (IOException e) { - Debug.logWarning(e, module); - throw new GenericServiceException(e.getMessage()); - } + } catch (IOException e) { + Debug.logWarning(e, module); + throw new GenericServiceException(e.getMessage()); + } return result; } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java Tue Jan 11 19:57:04 2011 @@ -68,10 +68,12 @@ public class LayoutWorker { } if (lst.size() == 0) { - String errMsg = UtilProperties.getMessage(LayoutWorker.err_resource, "layoutEvents.no_files_uploaded", locale); + String errMsg = UtilProperties.getMessage(err_resource, + "layoutEvents.no_files_uploaded", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); //Debug.logWarning("[DataEvents.uploadImage] No files uploaded", module); - return ServiceUtil.returnError("No files uploaded."); + return ServiceUtil.returnError(UtilProperties.getMessage(err_resource, + "layoutEvents.no_files_uploaded", locale)); } @@ -94,7 +96,7 @@ public class LayoutWorker { } if (imageFi == null) { - String errMsg = UtilProperties.getMessage(LayoutWorker.err_resource, + String errMsg = UtilProperties.getMessage(err_resource, "layoutEvents.image_null", UtilMisc.toMap("imageFi", imageFi), locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); //Debug.logWarning("[DataEvents.uploadImage] imageFi(" + imageFi + ") is null", module); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java Tue Jan 11 19:57:04 2011 @@ -365,7 +365,9 @@ public class OpenOfficeServices { return results; } catch (Exception e) { Debug.logError(e, "Error in OpenOffice operation: ", module); - return ServiceUtil.returnError("Error converting document: " + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentConvertingDocumentError", + UtilMisc.toMap("errorString", e.toString()), locale)); } } } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java Tue Jan 11 19:57:04 2011 @@ -49,6 +49,7 @@ import javax.xml.transform.stream.Stream import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.collections.MapStack; @@ -73,6 +74,7 @@ public class OutputServices { protected static final FoScreenRenderer foScreenRenderer = new FoScreenRenderer(); protected static final FoFormRenderer foFormRenderer = new FoFormRenderer(); + public static final String resource = "ContentUiLabels"; public static Map<String, Object> sendPrintFromScreen(DispatchContext dctx, Map<String, ? extends Object> serviceContext) { @@ -147,11 +149,14 @@ public class OutputServices { printer = printServices[0]; Debug.logInfo("Using printer: " + printer.getName(), module); if (!printer.isDocFlavorSupported(psInFormat)) { - return ServiceUtil.returnError("DocFlavor [" + psInFormat + "] not supported by printer: " + printer.getName()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentPrinterNotSupportDocFlavorFormat", + UtilMisc.toMap("psInFormat", psInFormat, "printerName", printer.getName()), locale)); } } if (printer == null) { - return ServiceUtil.returnError("No printer found with name: " + printerName); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentPrinterNotFound", UtilMisc.toMap("printerName", printerName), locale)); } } else { @@ -164,7 +169,8 @@ public class OutputServices { } if (printer == null) { - return ServiceUtil.returnError("No printer available"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentPrinterNotAvailable", locale)); } @@ -181,9 +187,10 @@ public class OutputServices { } catch (Exception e) { - String errMsg = "Error rendering [" + contentType + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error rendering [" + contentType + "]: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentRenderingError", + UtilMisc.toMap("contentType", contentType, "errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -248,9 +255,10 @@ public class OutputServices { fos.close(); } catch (Exception e) { - String errMsg = "Error rendering [" + contentType + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); + Debug.logError(e, "Error rendering [" + contentType + "]: " + e.toString(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentRenderingError", + UtilMisc.toMap("contentType", contentType, "errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchServices.java?rev=1057831&r1=1057830&r2=1057831&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchServices.java Tue Jan 11 19:57:04 2011 @@ -20,12 +20,15 @@ package org.ofbiz.content.search; import java.util.Date; 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.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.entity.Delegator; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.ServiceUtil; @@ -38,14 +41,15 @@ import org.ofbiz.service.LocalDispatcher public class SearchServices { public static final String module = SearchServices.class.getName(); + public static final String resource = "ContentUiLabels"; public static Map<String, Object> indexTree(DispatchContext dctx, Map<String, ? extends Object> context) { Date start = new Date(); LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); - String siteId = (String) context.get("contentId"); String path = (String) context.get("path"); + Locale locale = (Locale) context.get("locale"); if (path == null) { path = SearchWorker.getIndexPath(path); } @@ -61,7 +65,8 @@ public class SearchServices { results = SearchWorker.indexTree(dispatcher, delegator, siteId, envContext, path); } catch (Exception e) { Debug.logError(e, module); - return ServiceUtil.returnError("Error indexing tree: " + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentIndexingTreeError", UtilMisc.toMap("errorString", e.toString()), locale)); } Date end = new Date(); if (Debug.infoOn()) Debug.logInfo("in indexTree, results:" + results, module); |
| Free forum by Nabble | Edit this page |
