svn commit: r1056700 - in /ofbiz/trunk/applications/product: config/ProductErrorUiLabels.xml src/org/ofbiz/product/category/CategoryServices.java

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

svn commit: r1056700 - in /ofbiz/trunk/applications/product: config/ProductErrorUiLabels.xml src/org/ofbiz/product/category/CategoryServices.java

mrisaliti
Author: mrisaliti
Date: Sat Jan  8 12:36:08 2011
New Revision: 1056700

URL: http://svn.apache.org/viewvc?rev=1056700&view=rev
Log:
Internationalization of ServiceUtil.returnSuccess, ServiceUtil.returnFailure, ServiceUtil.returnError (OFBIZ-4091)

Modified:
    ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java

Modified: ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml?rev=1056700&r1=1056699&r2=1056700&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml (original)
+++ ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml Sat Jan  8 12:36:08 2011
@@ -19,6 +19,22 @@
     under the License.
 -->
 <resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <property key="categoryservices.problems_reading_category_entity">
+        <value xml:lang="en">Problem reading product categories: ${errMessage}.</value>
+        <value xml:lang="it">Problemi leggendo categorie prodotto: ${errMessage}.</value>
+    </property>
+    <property key="categoryservices.error_find_next_products">
+        <value xml:lang="en">Error finding previous/next product info: ${errMessage}</value>
+        <value xml:lang="it">Errore nelle ricerca dei prodotti precedenti/successivi: ${errMessage}</value>
+    </property>
+    <property key="categoryservices.problems_getting_next_products">
+        <value xml:lang="en">Both Index and ProductID cannot be null.</value>
+        <value xml:lang="it">Entrambi indice e prodotto non possono essere vuoti.</value>
+    </property>
+    <property key="categoryservices.product_not_found">
+        <value xml:lang="en">Product not found in the current category.</value>
+        <value xml:lang="it">Prodotto non trovato nell'attuale categoria.</value>
+    </property>
     <property key="ScaleImage.error_occurs_during_writing">
         <value xml:lang="en">An error occurs during writing</value>
         <value xml:lang="fr">Une erreur est survenue lors de l'écriture</value>

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java?rev=1056700&r1=1056699&r2=1056700&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java Sat Jan  8 12:36:08 2011
@@ -20,6 +20,7 @@ package org.ofbiz.product.category;
 
 import java.sql.Timestamp;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javolution.util.FastList;
@@ -29,6 +30,7 @@ import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilGenerics;
 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;
@@ -49,10 +51,12 @@ import org.ofbiz.service.ServiceUtil;
 public class CategoryServices {
 
     public static final String module = CategoryServices.class.getName();
+    public static final String resourceError = "ProductErrorUiLabels";
 
     public static Map<String, Object> getCategoryMembers(DispatchContext dctx, Map<String, ? extends Object> context) {
         Delegator delegator = dctx.getDelegator();
         String categoryId = (String) context.get("categoryId");
+        Locale locale = (Locale) context.get("locale");
         GenericValue productCategory = null;
         List<GenericValue> members = null;
 
@@ -61,9 +65,10 @@ public class CategoryServices {
             members = EntityUtil.filterByDate(productCategory.getRelatedCache("ProductCategoryMember", null, UtilMisc.toList("sequenceNum")), true);
             if (Debug.verboseOn()) Debug.logVerbose("Category: " + productCategory + " Member Size: " + members.size() + " Members: " + members, module);
         } catch (GenericEntityException e) {
-            String errMsg = "Problem reading product categories: " + e.getMessage();
-            Debug.logError(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logError(e, "Problem reading product categories: " + e.getMessage(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+                    "categoryservices.problems_reading_category_entity",
+                    UtilMisc.toMap("errMessage", e.getMessage()), locale));
         }
         Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("category", productCategory);
@@ -79,9 +84,11 @@ public class CategoryServices {
         Integer index = (Integer) context.get("index");
         Timestamp introductionDateLimit = (Timestamp) context.get("introductionDateLimit");
         Timestamp releaseDateLimit = (Timestamp) context.get("releaseDateLimit");
-
+        Locale locale = (Locale) context.get("locale");
+        
         if (index == null && productId == null) {
-            return ServiceUtil.returnError("Both Index and ProductID cannot be null.");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+                    "categoryservices.problems_getting_next_products", locale));
         }
 
         List<String> orderByFields = UtilGenerics.checkList(context.get("orderByFields"));
@@ -94,9 +101,10 @@ public class CategoryServices {
             productCategory = delegator.findByPrimaryKeyCache("ProductCategory", UtilMisc.toMap("productCategoryId", categoryId));
             productCategoryMembers = delegator.findByAndCache(entityName, UtilMisc.toMap("productCategoryId", categoryId), orderByFields);
         } catch (GenericEntityException e) {
-            String errMsg = "Error finding previous/next product info: " + e.toString();
-            Debug.logInfo(e, errMsg, module);
-            return ServiceUtil.returnError(errMsg);
+            Debug.logInfo(e, "Error finding previous/next product info: " + e.toString(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+                    "categoryservices.error_find_next_products",
+                    UtilMisc.toMap("errMessage", e.getMessage()), locale));
         }
         if (activeOnly) {
             productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, true);
@@ -124,7 +132,8 @@ public class CategoryServices {
 
         if (index == null) {
             // this is not going to be an error condition because we don't want it to be so critical, ie rolling back the transaction and such
-            return ServiceUtil.returnSuccess("Product not found in the current category.");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+                    "categoryservices.product_not_found", locale));
         }
 
         Map<String, Object> result = ServiceUtil.returnSuccess();