[MGNLREST-310] Delivery endpoint API does not update the path for links in richTextFiled when assets are moved Created: 26/May/21  Updated: 03/Jun/21  Resolved: 02/Jun/21

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

Type: Bug Priority: Medium
Reporter: Bartosz Staryga Assignee: Oanh Thai Hoang
Resolution: Won't Fix Votes: 1
Labels: VN-Analysis, maintenance
Remaining Estimate: 0d
Time Spent: 0.25d
Original Estimate: Not Specified

Attachments: Zip Archive test.zip    
Issue Links:
Relates
relates to MGNLREST-196 Convert returned links into public links Closed
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: Maintenance 61
Story Points: 1

 Description   

Steps to reproduce

  1.  Start Magnolia
  2.  Upload asset via Assets App inside some folder e.g. test
  3. Create a new page with provided LM e.g. test
  4. In rich text filed link the asset
  5. Call endpoint for newly created page: http://localhost:8080/magnoliaAuthor/.rest/delivery/pages/test
  6. See that link in rich text is: <a href=\"${link:{uuid: {d784c4c4-c0cb-479b-a56b-ee2933b9657c}

    ,repository:

    {dam}

    ,path:

    {/test/Screenshot-2021-05-26-at-08.41.png}

    }}\">Screenshot-2021-05-26-at-08.41.png</a>
    So path is: /test/Screenshot-2021-05-26-at-08.41.png

  7. Go to Asset App and move the asset to different place
  8. Call again endpoint http://localhost:8080/magnoliaAuthor/.rest/delivery/pages/test
  9. Returned path in REST is still /test/Screenshot-2021-05-26-at-08.41.png

Expected results

The path returned in ${link...} should be updated to the new placement of the asset

Actual results

The old path is returned

Workaround

Development notes



 Comments   
Comment by Bartosz Staryga [ 26/May/21 ]

The same behaviour happens when linking pages and page is moved.

Comment by Oanh Thai Hoang [ 02/Jun/21 ]

Hi bstaryga, cc fgrilli, just wanna ask is this config work for you

 

In rest delivery, magnolia has one feature to get correct link from reference asset. See https://docs.magnolia-cms.com/product-docs/Developing/API/REST-API/Delivery-endpoint-API/Delivery-endpoint-API-v2/Resolving-references-with-the-delivery-endpoint.html#_resolving_asset_links_in_rich_text_fields

 

Here is example config based on your pages.yaml restenpoint in "test" light dev.

class: info.magnolia.rest.delivery.jcr.v2.JcrDeliveryEndpointDefinition
workspace: website
limit: 100
depth: 10
nodeTypes:
  - mgnl:page
childNodeTypes:
  - mgnl:area
  - mgnl:component
references:
  - name: referenceWithRichText
    propertyName: image
    referenceResolver:
      class: info.magnolia.rest.reference.link.RichTextLinkResolverDefinition

Output before

"image":"<p><a href=\"${link:{uuid:{92f38185-67f6-4d96-884b-b632a1edd942},repository:{dam},path:{/Screen-Shot-2021-06-02-at-09.18.png}}}\">Screen-Shot-2021-06-02-at-09.18.png</a></p>\n"

 Output after resolver config

"image":"<p><a href=\"http://localhost:8080/dam/jcr:92f38185-67f6-4d96-884b-b632a1edd942/Screen%20Shot%202021-06-02%20at%2009.18.png\">Screen-Shot-2021-06-02-at-09.18.png</a></p>\n"

So you have the real asset link here: *http://localhost:8080/dam/jcr:92f38185-67f6-4d96-884b-b632a1edd942/Screen%20Shot%202021-06-02%20at%2009.18.png*

 

Comment by Bartosz Staryga [ 02/Jun/21 ]

oanh.thai it actually might do the trick I passed it on, will let you know when I hear back.
I frankly did not know this resolver was there. Did not see it in docs earlier. Since which version it's there?

Comment by Oanh Thai Hoang [ 02/Jun/21 ]

Hi bstaryga. Glad to hear it actually works for you. That new resolver has been introduced since Rest 2.2.3 and released with Magnolia 6.2.4. More details in https://jira.magnolia-cms.com/browse/MGNLREST-196

 

Since that resolver can help to resolve real link for pages and dam as well so I guess I can close this ticket as won't fix. Feel free to reopen it again if you have any idea. Thank you

 

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