Re: svn commit: r979204 - /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java

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

Re: svn commit: r979204 - /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java

Adam Heath-2
On 07/26/2010 04:01 AM, [hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r979204 - /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java

Jacques Le Roux
Administrator
From: "Adam Heath" <[hidden email]>

> On 07/26/2010 04:01 AM, [hidden email] 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.

Right I did not spot the 5th line miss 2 spaces before the bracket, anyway issue gone with the 2d remark

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

Yes uneeded indeed

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

I fixed it all at r979430

Thanks

Jacques

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