You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Adam Heath <do...@brainfood.com> on 2010/07/26 18:14:36 UTC

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

On 07/26/2010 04:01 AM, jleroux@apache.org 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);
>
>


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

Posted by Jacques Le Roux <ja...@les7arts.com>.
From: "Adam Heath" <do...@brainfood.com>
> On 07/26/2010 04:01 AM, jleroux@apache.org 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);
>>
>>
>