[MAGNOLIA-8381] Link conversion logic should be moved elsewhere Created: 18/Apr/22  Updated: 09/Nov/22  Resolved: 09/Nov/22

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Jonathan Ayala Assignee: Sang Ngo Huu
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
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)
Date of First Response:
Epic Link: Nucleus Quality Maintenance
Team: Nucleus

 Description   

info.magnolia.jcr.util.ContentMap.getNodeProperty(String) method contains a conversion logic for those values matching an UUID pattern:

info.magnolia.jcr.util.ContentMap (221)
else if (LinkUtil.UUID_PATTERN.matcher(prop.getString()).find()) {
                    try {
                        return info.magnolia.link.LinkUtil.convertLinksFromUUIDPattern(prop.getString());
                    } catch (LinkException e) {
                        log.warn("Failed to parse links with from {}", prop.getName(), e);
                    }
}

It would be good to separate this specific logic to another class whose purpose would be link management instead of having it in ContentMap.

When JcrAssetProvider is customized/extended, it results in a wrong links as info.magnolia.jcr.util.ContentMap.getNodeProperty(String) method contains a conversion logic for those values matching an UUID pattern. Therefore, it will be needed moving this conversion logic outside info.magnolia.jcr.util.ContentMap or configurable so it can be disabled.



 Comments   
Comment by Roman Kovařík [ 12/Oct/22 ]

The link generation should be customisable already: 

  1. Provide a custom LinkTransformerManager https://demo.magnolia-cms.com/.magnolia/admincentral#app:configuration:browser;/server/rendering/linkManagement@class:treeview:
  2. Override info.magnolia.multisite.MultiSiteLinkTransformerManager#getAbsolute
  3. Return a custom CrossSiteAbsolutePathTransformer
  4. Override its prefixLink() method
Comment by Roman Kovařík [ 19/Oct/22 ]

dmaslanka Could we check the above with support/customer?

Comment by Roman Kovařík [ 19/Oct/22 ]

As explained in the previous comment, the conversion logic is not implemented directly in ContentMap, LinkUtil is just delegating to customisable transformer interfaces.

Comment by Roman Kovařík [ 09/Nov/22 ]

Closing this as won't do:

  • The logic is located in the class since Magnolia 4.5 when was the class introduced (that's more then 10 years back) and haven't caused any issues so far.
  • We might question the separation of logic:
  • As mention in a previous comment, the link generation should be already customisable.
Generated at Mon Feb 12 04:32:14 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.