[MGNLREST-264] JcrReferenceResolver should check for WebContext when resolving links Created: 07/Aug/20 Updated: 20/Oct/20 Resolved: 06/Oct/20 |
|
| Status: | Closed |
| Project: | Magnolia REST Framework |
| Component/s: | delivery |
| Affects Version/s: | 2.2.1 |
| Fix Version/s: | 2.2.3 |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Richard Gange | Assignee: | Sang Ngo Huu |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | maintenance | ||
| Remaining Estimate: | 0d | ||
| Time Spent: | 2d 3h | ||
| Original Estimate: | Not Specified | ||
| 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)
|
||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||
| Epic Link: | Support | ||||
| Sprint: | Maintenance 27 | ||||
| Story Points: | 2 | ||||
| Description |
|
It was pointed out that JcrReferenceResolver always creates absolute links when it could create internal links if we checked for a WebContext. This is similar to what is done in AssetReferenceResolver. The proposal is to wrap the link creation with a conditional statement to check the type of context.
Context currentContext = MgnlContext.getInstance();
if (currentContext instanceof SystemContext) {
Context originalContext = ((SystemContext) currentContext).getOriginalContext();
if (originalContext instanceof WebContext) {
MgnlContext.setInstance(originalContext);
}
}
String link = LinkUtil.createLink(node);
if (!currentContext.equals(MgnlContext.getInstance())) {
MgnlContext.setInstance(currentContext);
}
|
| Comments |
| Comment by Richard Gange [ 17/Aug/20 ] |
|
See comment
|
| Comment by Richard Gange [ 17/Aug/20 ] |
|
This is in fact the case:
|