|
Author: mrisaliti
Date: Tue Jan 11 21:00:49 2011 New Revision: 1057865 URL: http://svn.apache.org/viewvc?rev=1057865&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/content/ContentServices.java Modified: ofbiz/trunk/applications/content/config/ContentUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/config/ContentUiLabels.xml?rev=1057865&r1=1057864&r2=1057865&view=diff ============================================================================== --- ofbiz/trunk/applications/content/config/ContentUiLabels.xml (original) +++ ofbiz/trunk/applications/content/config/ContentUiLabels.xml Tue Jan 11 21:00:49 2011 @@ -69,6 +69,22 @@ <value xml:lang="zh">å å®¹å ³è</value> <value xml:lang="zh_TW">å §å®¹éè¯</value> </property> + <property key="ContentAssocDeactivatingError"> + <value xml:lang="en">Error in deactivating ContentAssoc. Entity is null.</value> + <value xml:lang="it">Errore nella disattivazione dell'entità ContentAssoc che è nulla.</value> + </property> + <property key="ContentAssocNotFound"> + <value xml:lang="en">No association found for contentId ${activeContentId} and contentIdTo ${contentIdTo} and contentAssocTypeId ${contentAssocTypeId} and fromDate ${fromDate}</value> + <value xml:lang="it">Nessuna associazione trovata per il contenuto ${activeContentId} e il contenuto a ${contentIdTo} e il tipo associazione contenuto ${contentAssocTypeId} e dalla data ${fromDate}</value> + </property> + <property key="ContentAssocRetrievingError"> + <value xml:lang="en">Error in retrieving Content: ${errorString}</value> + <value xml:lang="it">Errore nel ricavare ContentAsssoc entity: ${errorString}</value> + </property> + <property key="ContentAssocUpdateError"> + <value xml:lang="en">Error in updating ContentAssoc. Entity is null.</value> + <value xml:lang="it">Errore nell'aggiornamento dell'entità ContentAssoc che è nulla.</value> + </property> <property key="ContentAssociation"> <value xml:lang="ar">إرتباط</value> <value xml:lang="da">Association</value> @@ -694,6 +710,10 @@ <value xml:lang="en">Error converting document: ${errorString}</value> <value xml:lang="it">Errore durante la conversione del documento: ${errorString}</value> </property> + <property key="ContentCreateContentAssocMethodError"> + <value xml:lang="en">Not 2 out of ContentId/To/From</value> + <value xml:lang="it">Necessari 2 dei tre parametri ContentId/To/From necessari</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> @@ -1432,7 +1452,7 @@ </property> <property key="ContentNoContentFound"> <value xml:lang="en">Content record not found for ID ${contentId}</value> - <value xml:lang="it">Contenuto non trovato per ID ${contentId}</value> + <value xml:lang="it">Contenuto non trovato ${contentId}</value> </property> <property key="ContentNoContentFilePassed"> <value xml:lang="en">No file content passed for: ${fileName}</value> @@ -1725,6 +1745,10 @@ <value xml:lang="zh">æåå°æç»</value> <value xml:lang="zh_TW">æåå°æçµ</value> </property> + <property key="ContentStatusUpdateError"> + <value xml:lang="en">Problem updating content Status: ${errorString}</value> + <value xml:lang="it">Problema durante l'aggiornamento dello stato del contenuto: ${errorString}</value> + </property> <property key="ContentSubContent"> <value xml:lang="ar">Ù ØØªÙÙ ØªØØªÙ</value> <value xml:lang="da">Underindhold</value> @@ -2391,6 +2415,10 @@ <value xml:lang="zh">ä½ æ²¡ææµè§æ¬é¡µé¢çæéã(éè¦å ·å¤"CONTENTMGR_VIEW"æ"CONTENTMGR_ADMIN")</value> <value xml:lang="zh_TW">ä½ æ²æç覽æ¬é é¢çæ¬éã(éè¦å ·å"CONTENTMGR_VIEW"æ"CONTENTMGR_ADMIN")</value> </property> + <property key="ContentVisitedSet"> + <value xml:lang="en">visitedSet already contains: </value> + <value xml:lang="it">visitedSet contiene già : </value> + </property> <property key="ContentWebSite"> <value xml:lang="ar">Ù ÙÙØ¹ اÙÙÙØ¨</value> <value xml:lang="da">Webside</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=1057865&r1=1057864&r2=1057865&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 21:00:49 2011 @@ -21,7 +21,6 @@ package org.ofbiz.content; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.sql.Timestamp; -import com.ibm.icu.util.Calendar; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -35,11 +34,11 @@ import javolution.util.FastMap; import javolution.util.FastSet; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.StringUtil; 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; import org.ofbiz.content.content.ContentServices; import org.ofbiz.content.content.ContentWorker; @@ -61,6 +60,8 @@ import org.ofbiz.service.ModelService; import org.ofbiz.service.ServiceAuthException; import org.ofbiz.service.ServiceUtil; +import com.ibm.icu.util.Calendar; + /** * ContentManagementServices Class */ @@ -835,7 +836,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); @@ -982,12 +983,14 @@ Debug.logInfo("updateSiteRoles, serviceC String contentId = (String)context.get("contentId"); GenericValue userLogin = (GenericValue)context.get("userLogin"); String userLoginId = userLogin.getString("userLoginId"); + Locale locale = (Locale) context.get("locale"); //int seqNum = 9999; try { GenericValue content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); if (content == null) { Debug.logError("content was null", module); - return ServiceUtil.returnError("content was null"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFound", UtilMisc.toMap("contentId", ""), locale)); } String dataResourceId = content.getString("dataResourceId"); //String contentTypeIdTo = content.getString("contentTypeId"); @@ -1125,10 +1128,10 @@ Debug.logInfo("updateSiteRoles, serviceC * (it could be DOCUMENT or OUTLINE_NODE) then it will get changed to SUBPAGE_NODE.` */ public static Map<String, Object> updatePageType(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException{ - Delegator delegator = dctx.getDelegator(); Map<String, Object> context = UtilMisc.makeMapWritable(rcontext); Map results = FastMap.newInstance(); + Locale locale = (Locale) context.get("locale"); Set visitedSet = (Set)context.get("visitedSet"); if (visitedSet == null) { visitedSet = FastSet.newInstance(); @@ -1143,8 +1146,10 @@ Debug.logInfo("updateSiteRoles, serviceC GenericValue thisContent = null; try { thisContent = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); - if (thisContent == null) - return ServiceUtil.returnError("No entity found for id=" + contentId); + if (thisContent == null) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale)); + } thisContent.set("contentTypeId", contentTypeId); thisContent.store(); List kids = ContentWorker.getAssociatedContent(thisContent, "from", UtilMisc.toList("SUB_CONTENT"), null, null, null); @@ -1166,10 +1171,10 @@ Debug.logInfo("updateSiteRoles, serviceC } public static Map<String, Object> resetToOutlineMode(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException{ - Delegator delegator = dctx.getDelegator(); Map<String, Object> context = UtilMisc.makeMapWritable(rcontext); Map results = FastMap.newInstance(); + Locale locale = (Locale) context.get("locale"); Set visitedSet = (Set)context.get("visitedSet"); if (visitedSet == null) { visitedSet = FastSet.newInstance(); @@ -1183,8 +1188,10 @@ Debug.logInfo("updateSiteRoles, serviceC GenericValue thisContent = null; try { thisContent = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); - if (thisContent == null) - return ServiceUtil.returnError("No entity found for id=" + contentId); + if (thisContent == null) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale)); + } thisContent.set("contentTypeId", "OUTLINE_NODE"); thisContent.store(); List kids = ContentWorker.getAssociatedContent(thisContent, "from", UtilMisc.toList("SUB_CONTENT"), null, null, null); @@ -1366,21 +1373,22 @@ Debug.logInfo("updateSiteRoles, serviceC public static Map<String, Object> initContentChildCounts(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{ Map result = FastMap.newInstance(); + Locale locale = (Locale) context.get("locale"); + GenericValue content = (GenericValue)context.get("content"); + if (content == null) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFound", UtilMisc.toMap("contentId", ""), locale)); + } + Long leafCount = (Long)content.get("childLeafCount"); + if (leafCount == null) { + content.set("childLeafCount", Long.valueOf(0)); + } + Long branchCount = (Long)content.get("childBranchCount"); + if (branchCount == null) { + content.set("childBranchCount", Long.valueOf(0)); + } - GenericValue content = (GenericValue)context.get("content"); - if (content == null) { - return ServiceUtil.returnError("No Content found."); - } - Long leafCount = (Long)content.get("childLeafCount"); - if (leafCount == null) { - content.set("childLeafCount", Long.valueOf(0)); - } - Long branchCount = (Long)content.get("childBranchCount"); - if (branchCount == null) { - content.set("childBranchCount", Long.valueOf(0)); - } - - //content.store(); + //content.store(); return result; } @@ -1388,52 +1396,54 @@ Debug.logInfo("updateSiteRoles, serviceC public static Map<String, Object> incrementContentChildStats(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{ Map result = FastMap.newInstance(); Delegator delegator = dctx.getDelegator(); + Locale locale = (Locale) context.get("locale"); + String contentId = (String)context.get("contentId"); + String contentAssocTypeId = (String)context.get("contentAssocTypeId"); - String contentId = (String)context.get("contentId"); - String contentAssocTypeId = (String)context.get("contentAssocTypeId"); - - try { - GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentId)); - if (content == null) { - return ServiceUtil.returnError("No Content found."); - } - Long leafCount = (Long)content.get("childLeafCount"); - if (leafCount == null) { - leafCount = Long.valueOf(0); - } - int changeLeafCount = leafCount.intValue() + 1; - int changeBranchCount = 1; - - ContentManagementWorker.updateStatsBottomUp(delegator, contentId, UtilMisc.toList(contentAssocTypeId), changeBranchCount, changeLeafCount); - } catch (GenericEntityException e) { - return ServiceUtil.returnError(e.toString()); + try { + GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentId)); + if (content == null) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale)); } + Long leafCount = (Long)content.get("childLeafCount"); + if (leafCount == null) { + leafCount = Long.valueOf(0); + } + int changeLeafCount = leafCount.intValue() + 1; + int changeBranchCount = 1; + + ContentManagementWorker.updateStatsBottomUp(delegator, contentId, UtilMisc.toList(contentAssocTypeId), changeBranchCount, changeLeafCount); + } catch (GenericEntityException e) { + return ServiceUtil.returnError(e.toString()); + } return result; } public static Map<String, Object> decrementContentChildStats(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{ Map result = FastMap.newInstance(); Delegator delegator = dctx.getDelegator(); + Locale locale = (Locale) context.get("locale"); + String contentId = (String)context.get("contentId"); + String contentAssocTypeId = (String)context.get("contentAssocTypeId"); - String contentId = (String)context.get("contentId"); - String contentAssocTypeId = (String)context.get("contentAssocTypeId"); - - try { - GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentId)); - if (content == null) { - return ServiceUtil.returnError("No Content found."); - } - Long leafCount = (Long)content.get("childLeafCount"); - if (leafCount == null) { - leafCount = Long.valueOf(0); - } - int changeLeafCount = -1 * leafCount.intValue() - 1; - int changeBranchCount = -1; - - ContentManagementWorker.updateStatsBottomUp(delegator, contentId, UtilMisc.toList(contentAssocTypeId), changeBranchCount, changeLeafCount); - } catch (GenericEntityException e) { - return ServiceUtil.returnError(e.toString()); + try { + GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentId)); + if (content == null) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale)); } + Long leafCount = (Long)content.get("childLeafCount"); + if (leafCount == null) { + leafCount = Long.valueOf(0); + } + int changeLeafCount = -1 * leafCount.intValue() - 1; + int changeBranchCount = -1; + + ContentManagementWorker.updateStatsBottomUp(delegator, contentId, UtilMisc.toList(contentAssocTypeId), changeBranchCount, changeLeafCount); + } catch (GenericEntityException e) { + return ServiceUtil.returnError(e.toString()); + } return result; } @@ -1453,7 +1463,7 @@ Debug.logInfo("updateSiteRoles, serviceC try { ContentManagementWorker.updateStatsTopDown(delegator, contentId, typeList); } catch (GenericEntityException e) { - return ServiceUtil.returnError(e.toString()); + return ServiceUtil.returnError(e.toString()); } return result; } @@ -1636,14 +1646,15 @@ Debug.logInfo("updateSiteRoles, serviceC } public static Map<String, Object> followNodeChildren(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{ - Map result = null; Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Security security = dctx.getSecurity(); GenericValue userLogin = (GenericValue)context.get("userLogin"); + Locale locale = (Locale) context.get("locale"); if (!security.hasEntityPermission("CONTENTMGR", "_ADMIN", userLogin)) { - return ServiceUtil.returnError("Permission denied."); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentPermissionNotGranted", locale)); } String contentId = (String)context.get("contentId"); String serviceName = (String)context.get("serviceName"); @@ -1670,10 +1681,10 @@ Debug.logInfo("updateSiteRoles, serviceC } public static Map followNodeChildrenMethod(GenericValue content, LocalDispatcher dispatcher, String serviceName, Map context) throws GenericEntityException, GenericServiceException { - Map result = null; String contentId = content.getString("contentId"); List contentAssocTypeIdList = (List)context.get("contentAssocTypeIdList"); + Locale locale = (Locale) context.get("locale"); Set visitedSet = (Set)context.get("visitedSet"); if (visitedSet == null) { visitedSet = FastSet.newInstance(); @@ -1681,7 +1692,8 @@ Debug.logInfo("updateSiteRoles, serviceC } else { if (visitedSet.contains(contentId)) { Debug.logWarning("visitedSet already contains:" + contentId, module); - return ServiceUtil.returnError("visitedSet already contains:" + contentId); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentVisitedSet", locale) + contentId); } else { visitedSet.add(contentId); } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java?rev=1057865&r1=1057864&r2=1057865&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServices.java Tue Jan 11 21:00:49 2011 @@ -38,6 +38,7 @@ import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilHttp; 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; @@ -58,6 +59,7 @@ import org.ofbiz.service.ServiceUtil; public class ContentServices { public static final String module = ContentServices.class.getName(); + public static final String resource = "ContentUiLabels"; /** * findRelatedContent Finds the related @@ -70,6 +72,7 @@ public class ContentServices { String fromDate = (String) context.get("fromDate"); String thruDate = (String) context.get("thruDate"); String toFrom = (String) context.get("toFrom"); + Locale locale = (Locale) context.get("locale"); if (toFrom == null) { toFrom = "TO"; } else { @@ -84,7 +87,9 @@ public class ContentServices { try { contentList = ContentWorker.getAssociatedContent(currentContent, toFrom, assocTypes, contentTypes, fromDate, thruDate); } catch (GenericEntityException e) { - return ServiceUtil.returnError("Error getting associated content: " + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentAssocRetrievingError", + UtilMisc.toMap("errorString", e.toString()), locale)); } if (targetOperations == null || targetOperations.isEmpty()) { @@ -107,7 +112,8 @@ public class ContentServices { permResults = dispatcher.runSync("checkContentPermission", serviceInMap); } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); - return ServiceUtil.returnError("Problem checking permissions"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentPermissionNotGranted", locale)); } String permissionStatus = (String) permResults.get("permissionStatus"); @@ -169,6 +175,7 @@ public class ContentServices { public static Map<String, Object> traverseContent(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); Map results = FastMap.newInstance(); + Locale locale = (Locale) context.get("locale"); String contentId = (String) context.get("contentId"); String direction = (String) context.get("direction"); @@ -186,8 +193,9 @@ public class ContentServices { try { content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); } catch (GenericEntityException e) { - System.out.println("Entity Error:" + e.getMessage()); - return ServiceUtil.returnError("Error in retrieving Content. " + e.getMessage()); + Debug.logError(e, "Entity Error:" + e.getMessage(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale)); } String fromDateStr = (String) context.get("fromDateStr"); @@ -351,6 +359,7 @@ public class ContentServices { List contentPurposeList = ContentWorker.prepContentPurposeList(context); context.put("targetOperationList", targetOperationList); context.put("contentPurposeList", contentPurposeList); + Locale locale = (Locale) context.get("locale"); Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -370,7 +379,8 @@ public class ContentServices { contentIdCount++; if (contentIdCount < 2) { Debug.logError("Not 2 out of ContentId/To/From.", "ContentServices"); - return ServiceUtil.returnError("Not 2 out of ContentId/To/From"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentCreateContentAssocMethodError", locale)); } if (UtilValidate.isNotEmpty(contentIdFrom)) { @@ -521,7 +531,7 @@ public class ContentServices { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Map result = FastMap.newInstance(); - + context.put("entityOperation", "_UPDATE"); List targetOperationList = ContentWorker.prepTargetOperationList(context, "_UPDATE"); @@ -530,13 +540,14 @@ public class ContentServices { context.put("contentPurposeList", contentPurposeList); GenericValue content = null; - //Locale locale = (Locale) context.get("locale"); + Locale locale = (Locale) context.get("locale"); String contentId = (String) context.get("contentId"); try { content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); } catch (GenericEntityException e) { Debug.logWarning(e, module); - return ServiceUtil.returnError("content.update.read_failure" + e.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale)); } context.put("currentContent", content); @@ -555,7 +566,8 @@ public class ContentServices { dispatcher.runSync("setContentStatus", statusInMap); } catch (GenericServiceException e) { Debug.logError(e, "Problem updating content Status", "ContentServices"); - return ServiceUtil.returnError("Problem updating content Status: " + e); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentStatusUpdateError", UtilMisc.toMap("errorString", e), locale)); } } @@ -601,6 +613,7 @@ public class ContentServices { Map<String, Object> context = UtilMisc.makeMapWritable(rcontext); Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); + Locale locale = (Locale) context.get("locale"); Map result = FastMap.newInstance(); context.put("entityOperation", "_UPDATE"); @@ -622,11 +635,14 @@ public class ContentServices { try { contentAssoc = delegator.findByPrimaryKey("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", contentIdTo, "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate)); } catch (GenericEntityException e) { - System.out.println("Entity Error:" + e.getMessage()); - return ServiceUtil.returnError("Error in retrieving Content. " + e.getMessage()); + Debug.logError(e, "Entity Error:" + e.getMessage(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentAssocRetrievingError", + UtilMisc.toMap("errorString", e.getMessage()), locale)); } if (contentAssoc == null) { - return ServiceUtil.returnError("Error in updating ContentAssoc. Entity is null."); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentAssocUpdateError", locale)); } contentAssoc.put("contentAssocPredicateId", context.get("contentAssocPredicateId")); @@ -670,7 +686,8 @@ public class ContentServices { permResults = dispatcher.runSync("checkAssocPermission", serviceInMap); } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); - return ServiceUtil.returnError("Problem checking association permissions"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentPermissionNotGranted", locale)); } permissionStatus = (String) permResults.get("permissionStatus"); @@ -715,7 +732,7 @@ public class ContentServices { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Map result = FastMap.newInstance(); - + Locale locale = (Locale) context.get("locale"); context.put("entityOperation", "_UPDATE"); List targetOperationList = ContentWorker.prepTargetOperationList(context, "_UPDATE"); @@ -737,12 +754,15 @@ public class ContentServices { //contentAssoc = delegator.findByPrimaryKey("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", contentIdTo, "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate)); contentAssoc = delegator.findByPrimaryKey("ContentAssoc", pk); } catch (GenericEntityException e) { - System.out.println("Entity Error:" + e.getMessage()); - return ServiceUtil.returnError("Error in retrieving Content. " + e.getMessage()); + Debug.logError(e, "Entity Error:" + e.getMessage(), module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentAssocRetrievingError", + UtilMisc.toMap("errorString", e.getMessage()), locale)); } if (contentAssoc == null) { - return ServiceUtil.returnError("Error in deactivating ContentAssoc. Entity is null."); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentAssocDeactivatingError", locale)); } GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -767,7 +787,8 @@ public class ContentServices { permResults = dispatcher.runSync("checkAssocPermission", serviceInMap); } catch (GenericServiceException e) { Debug.logError(e, "Problem checking permissions", "ContentServices"); - return ServiceUtil.returnError("Problem checking association permissions"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentPermissionNotGranted", locale)); } permissionStatus = (String) permResults.get("permissionStatus"); @@ -796,6 +817,7 @@ public class ContentServices { String activeContentId = (String) context.get("activeContentId"); String contentId = (String) context.get("contentId"); Timestamp fromDate = (Timestamp) context.get("fromDate"); + Locale locale = (Locale) context.get("locale"); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); String sequenceNum = null; Map results = FastMap.newInstance(); @@ -805,8 +827,10 @@ public class ContentServices { if (fromDate != null) { activeAssoc = delegator.findByPrimaryKey("ContentAssoc", UtilMisc.toMap("contentId", activeContentId, "contentIdTo", contentIdTo, "fromDate", fromDate, "contentAssocTypeId", contentAssocTypeId)); if (activeAssoc == null) { - return ServiceUtil.returnError("No association found for contentId=" + activeContentId + " and contentIdTo=" + contentIdTo - + " and contentAssocTypeId=" + contentAssocTypeId + " and fromDate=" + fromDate); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ContentAssocNotFound", + UtilMisc.toMap("activeContentId", activeContentId, "contentIdTo", contentIdTo, + "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate), locale)); } sequenceNum = (String) activeAssoc.get("sequenceNum"); } |
| Free forum by Nabble | Edit this page |
