[MGNLPN-205] Isocode for England is GB not UK Created: 27/Mar/15  Updated: 29/May/17  Resolved: 24/Nov/15

Status: Closed
Project: Magnolia Personalization
Component/s: Preview App
Affects Version/s: 1.1
Fix Version/s: 1.2.3

Type: Bug Priority: Minor
Reporter: Tomáš Gregovský Assignee: Philip Mundt
Resolution: Fixed Votes: 0
Labels: support
Remaining Estimate: 0d
Time Spent: 2d 5.25h
Original Estimate: 2d

Attachments: PNG File country_ruleField_options_gb.png    
Issue Links:
Relates
relates to MGNLPN-388 Segment "Europe, Middle East & Africa... Open
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Sprint: Basel 20
Story Points: 5

 Description   

In page "preview as visitor" when added new trait: country and selected "united kingdom" then traitProvider.get().getTrait(Country.class).getCountryIsoCode() return "UK" but this is not correct one by http://en.wikipedia.org/wiki/ISO_3166-1 , it should be GB.

thank you



 Comments   
Comment by Ngoc Nguyenthanh [ 26/Oct/15 ]

Root cause:

  • info.magnolia.personalization.trait.TraitCollector provide ability to get trait provided by info.magnolia.personalization.geoip.CountryDetectorFilter. And traits come from predefined list in Config: /modules/personalization-traits/traits/country

Solution: Fix wrong values
Change value from uk to gb in config:

  • /modules/personalization-traits/traits/country/valueField/options/uk@value
  • /modules/personalization-traits/traits/country/ruleField/options/uk@value
  • File changes:
    + Bootstrap file: magnolia-personalization-traits/src/main/resources/mgnl-bootstrap/personalization-traits/config.modules.personalization-traits.traits.country.xml. Change bootstrap file with new values
    + Add task change values when upgrade from version 1.1 in info.magnolia.personalization.setup.PersonalizationTraitsModuleVersionHandler
    + Add test cases in info.magnolia.personalization.setup.PersonalizationTraitsModuleVersionHandlerTest in order to check values when updateFrom11 and fresh installation.

Impact:

  • Need write an task to search and update old value in website workspace due to personalization module integrated with Pages app.
  • Custom modules integrated with personalization module???
Comment by Ngoc Nguyenthanh [ 26/Oct/15 ]

mgeljic Please have a look and approve for my solution above. Thanks in advance.

Comment by Ngoc Nguyenthanh [ 26/Oct/15 ]

An idea comes to my mind:
As we can see, even with developers, easy to get mistakes and painful when work with information of countries. I would suggest we need to create new module provide quite common utilities related to country for convenience .
New module:

  • Allow manage countries information follow by ISO. Shipped with predefined country list follow ISO 3166, ISO 639
    + Mapping basic Country information: short name, full-name, country codes (2, 3 letters) , language codes (2, 3 letters)
    + Some additional information: capital, populations, areas, administrative regions of the country, postcode, etc
  • UI enhancements:
    + Country App: manage country information
    + Country field: Provide ability to select one or many countries from a specified country list.
    + Country component: summaries information of a country
  • API supports:
    + Detect country by IP (info.magnolia.personalization.geoip.CountryDetectorFilter)
    + Query country information by country code, name, and so on.
Comment by Mikaël Geljić [ 27/Oct/15 ]

Hey ngoc.nguyenthanh,

I approve what you propose in your first comment. Just two additions:

  • while changing valueField & ruleField's "uk" option value, please also rename those option nodes to "gb" (more consistent).
  • Similarly to updating page variants (in website workspace), segments (in segments workspace) also need to be updated.
    • For the website update, you might want to use a query-task looking for nodes with the mgnl:variant mixin node-type.

Regarding your idea; Java itself covers locales, languages and countries pretty well. See Locale.getISOCountries() for an example.

As a future idea, I would rather reconsider country options for trait rules/values being a *configured* set. Since there are about 250 countries in there, we would have to make sure UX doesn't suffer from it. Anyway, it's beyond current ticket and sprint

Comment by Ngoc Nguyenthanh [ 28/Oct/15 ]

Hi mgeljic
Cool, I will go ahead with the solution.

Regard to my idea Locale.getISOCountries() is cover the code only. It's not all about my idea. Anyway, it's just a feature idea. So great if we can provide this convenience for users.

Comment by Ngoc Nguyenthanh [ 30/Oct/15 ]

I fixed by:

  • Change bootstrap files
  • Add new task info.magnolia.personalization.setup.UpdateCountryCodeTask to search & replace old country code.
  • Add update task for info.magnolia.personalization.setup.PersonalizationTraitsModuleVersionHandler
  • Add & Update unit tests for new task and version handler.

You can check by query in workspace 'website' & 'segments' with query after upgrade or install fresh installation

select * from [mgnl:contentNode] where [mgnl:contentNode].class = 'info.magnolia.personalization.geoip.CountryVoter' and [mgnl:contentNode].value = 'uk'

Note: I don't want to use 'traitId' to check due to it have just added from 1.2.1

Comment by Philip Mundt [ 04/Nov/15 ]

Task actually fails because it tries to update nodes in versionStorage too:

2015-11-04 11:42:06,209 ERROR gnolia.personalization.setup.UpdateCountryCodeTask: Cannot update country code for node node /jcr:system/jcr:versionStorage/f8/56/6f/f8566f8d-936e-405e-be3d-b30d32ce2a94/1.1/jcr:frozenNode/mgnl:ruleSet/voters/voter0
javax.jcr.nodetype.ConstraintViolationException: Unable to perform operation. Node is protected.
	at org.apache.jackrabbit.core.ItemValidator.checkCondition(ItemValidator.java:276)
	at org.apache.jackrabbit.core.ItemValidator.checkModify(ItemValidator.java:248)
	at org.apache.jackrabbit.core.PropertyImpl.checkSetValue(PropertyImpl.java:278)
	at org.apache.jackrabbit.core.PropertyImpl.setValue(PropertyImpl.java:726)
	at org.apache.jackrabbit.core.NodeImpl$SetPropertyOperation.perform(NodeImpl.java:2058)
	at org.apache.jackrabbit.core.NodeImpl$SetPropertyOperation.perform(NodeImpl.java:2002)
	at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216)
	at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1924)
	at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1894)
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.setProperty(DelegateNodeWrapper.java:392)
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.setProperty(ContentDecoratorNodeWrapper.java:254)
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.setProperty(DelegateNodeWrapper.java:392)
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.setProperty(ContentDecoratorNodeWrapper.java:254)
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.setProperty(DelegateNodeWrapper.java:392)
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.setProperty(ContentDecoratorNodeWrapper.java:254)
	at info.magnolia.jcr.wrapper.MgnlPropertySettingNodeWrapper.setProperty(MgnlPropertySettingNodeWrapper.java:146)
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.setProperty(DelegateNodeWrapper.java:392)
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.setProperty(ContentDecoratorNodeWrapper.java:254)
	at info.magnolia.audit.MgnlAuditLoggingContentDecoratorNodeWrapper.setProperty(MgnlAuditLoggingContentDecoratorNodeWrapper.java:140)
	at info.magnolia.personalization.setup.UpdateCountryCodeTask.operateOnNode(UpdateCountryCodeTask.java:67)
	at info.magnolia.module.delta.NodeVisitorTask$1.visit(NodeVisitorTask.java:74)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:651)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.jcr.util.NodeUtil.visit(NodeUtil.java:653)
	at info.magnolia.module.delta.NodeVisitorTask.doExecute(NodeVisitorTask.java:82)
	at info.magnolia.module.delta.AbstractRepositoryTask.execute(AbstractRepositoryTask.java:57)
	at info.magnolia.module.ModuleManagerImpl.applyDeltas(ModuleManagerImpl.java:523)
	at info.magnolia.module.ModuleManagerImpl.installOrUpdateModule(ModuleManagerImpl.java:505)
	at info.magnolia.module.ModuleManagerImpl$1.doExec(ModuleManagerImpl.java:286)
	at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:421)
	at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:418)
	at info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:392)
	at info.magnolia.module.ModuleManagerImpl.performInstallOrUpdate(ModuleManagerImpl.java:280)
	at info.magnolia.module.ui.ModuleManagerWebUI$2.run(ModuleManagerWebUI.java:123)
	at java.lang.Thread.run(Thread.java:745)
Comment by Philip Mundt [ 17/Nov/15 ]
  • Trait values for personas are not adjusted – rendering them useless if they use uk trait value
  • message.properties /resources/mgnl-i18n/module-personalization-traits-messages_en.properties file key for uk has to be renamed to gb
    see
  • valueField has hardcoded labels, so this requires an additional update task
Comment by Tomáš Gregovský [ 30/Sep/16 ]

this fix is applied only for magnolia 5.4, since on 5.3.13 there is personalization-trait version only 1.1.4 ... just few days ago we had country:UK relevant issue on corporate website and after some deeper investigation brings us back to this issue which I thought was solved already ... luckily we will migrate to 5.4. soon but I guess there is more 5.3 websites running

Generated at Mon Feb 12 06:35:20 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.