Uploaded image for project: 'Magnolia REST Framework'
  1. Magnolia REST Framework
  2. MGNLREST-264

JcrReferenceResolver should check for WebContext when resolving links

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 2.2.3
    • 2.2.1
    • delivery

      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);
      }
      

        Acceptance criteria

              sang.ngo Sang Ngo Huu
              rgange Richard Gange
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 2d 3h
                    2d 3h