[MGNLREST-265] Support resolve links in richTextField via NodeWriter Created: 10/Aug/20 Updated: 09/Jan/24 |
|
| Status: | Open |
| Project: | Magnolia REST Framework |
| Component/s: | delivery |
| Affects Version/s: | 2.2.1 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Viet Nguyen | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | 622 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mgnl-6.2.2 |
||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| 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)
|
||||
| Testcase included: |
Yes
|
||||
| Release notes required: |
Yes
|
||||
| Documentation update required: |
Yes
|
||||
| Team: | |||||
| Description |
reproduce steps1. create a text component
form:
properties:
text:
label: Text
$type: richTextField
2. 3. The response is: "main": { "@name": "main", "@path": "/demo-content/main", "@id": "ceecf6c7-8a5c-48e1-a5d8-2dda9e5a0dfe", "@nodeType": "mgnl:area", "0": { "@name": "0", "@path": "/demo-content/main/0", "@id": "86c4e0a6-159d-4911-b589-4f6e2888e15c", "@nodeType": "mgnl:component", "text": "<p><a href=\"${link:{uuid:{943d6ee7-f6a5-4be0-9fb9-415b59b95523},repository:{website},path:{/demo-content/inhlatsseite}}}\">test</a></p>\n", "mgnl:template": "test:components/text", "@nodes": [] }, "@nodes": ["0"] } expected resultI would expect a real page link. actual resultdescribed above implementation notesThe functionality I added is from the ContentMap. For freemarker, the links ware resolved there. Customer notesPossible Solution: private String getValueString(Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.BINARY: return getBinaryString(value); case PropertyType.DECIMAL: return String.valueOf(value.getDecimal()); case PropertyType.NAME: case PropertyType.URI: case PropertyType.DATE: return value.getString(); default: return getStringValue(value); } } public String getStringValue(final Value value) { String result = PropertyUtil.getValueString(value); if (LinkUtil.UUID_PATTERN.matcher(result).find()) { try { result = info.magnolia.link.LinkUtil.convertLinksFromUUIDPattern(result); } catch (LinkException e) { LOGGER.warn("Failed to parse links with from {}", result, e); } } return result; } |