On 07/26/2010 04:01 AM, [email protected] wrote:
Author: jleroux
Date: Mon Jul 26 09:01:56 2010
New Revision: 979204

URL: http://svn.apache.org/viewvc?rev=979204&view=rev
Log:
A patch from Deyan Tsvetanov "Service SaveLabelsToXmlFile omits labels for new 
locales that did not exist prior to calling service" 
(https://issues.apache.org/jira/browse/OFBIZ-3869) - OFBIZ-3869

1) Use LabelManagerFactory and try to add labels for a locale that does not 
exist in the resource bundles - for example en_US.
2) Invoke the service SaveLabelsToXmlFile

Expected behavior: the resource bundle should contain the newly added locales
Experienced behavior: the resource bundle does not contain the labels for the 
newly added locales.

Modified:
     
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java

Modified: 
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java?rev=979204&r1=979203&r2=979204&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
 (original)
+++ 
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
 Mon Jul 26 09:01:56 2010
@@ -81,6 +81,11 @@ public class SaveLabelsToXmlFile {
                  Map<String, LabelInfo>  labels = factory.getLabels();
                  Set<String>  labelsList = factory.getLabelsList();
                  Set<String>  localesFound = factory.getLocalesFound();
+                for (String localeName : localeNames) {
+                    if (!localesFound.contains(localeName)) {
+                        localesFound.add(localeName);
+                   }
+                }

tabbing is bad.

Remove the contains() check, it's not needed.

Does factory.getLocalesFound() return a copy of the Set, or are you modifying the internal data structure? If so, the encapsulation is broken.

                  // Remove a Label
                  if (UtilValidate.isNotEmpty(removeLabel)) {
                      labels.remove(key + LabelManagerFactory.keySeparator + 
fileName);



Reply via email to