[MGNLREST-290] When targetting root and depth=0, only return root nodes Created: 20/Nov/20  Updated: 12/Apr/22

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

Type: Improvement Priority: Neutral
Reporter: Jonathan Ayala Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
duplicate
is duplicated by MGNLREST-356 Issue with depth definition parameter... 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)
Epic Link: Support

 Description   

Update

This is by design, but the design is admitteadly not what one expects.

You can acheive the expected using the @nodes directive. so for the following examples, use:

http://localhost:8080/magnoliaAuthor/.rest/customEndpoint/@nodes

When you supply no parameters, then the endpoint uses the "Query Nodes" method -this returns all nodes that are specified in the config, not just the children of the current path. Users often expect that it will use the "Read Node" method.

See the documentation for more details:

https://docs.magnolia-cms.com/product-docs/6.2/Developing/API/Delivery-API.html#_methods

KEEPING THIS TICKET As something to consider in a future version of the endpoint.

Steps to reproduce

  1.  In a demo bundle, create a custom endpoint with following definition
    class: info.magnolia.rest.delivery.jcr.v2.JcrDeliveryEndpointDefinition
    workspace: website
    includeSystemProperties: false
    depth: 0
    nodeTypes:
      - mgnl:page
    childNodeTypes:
      - mgnl:page
  1.  Call it without indicating the path, i.e. http://localhost:8080/magnoliaAuthor/.rest/customEndpoint/
  2. Call it indicating a path, e.g. http://localhost:8080/magnoliaAuthor/.rest/customEndpoint/travel

 

See good analysis in linked ticket:

https://jira.magnolia-cms.com/browse/MGNLREST-356

 

Expected results

Since depth is 0, we should only retrieve /travel and /sportstation pages

Actual results

We get 10 pages regardless the depth in they are located:
/sportstation/about
/sportstation
/sportstation/tour
/travel/book-tour
/travel/book-tour/meal
/travel/about/careers/customer-experience-agent
/travel/about/careers/marketing-associate
/travel/book-tour/review
/travel/meta/search-results
/travel/members

Workaround

Use @nodes parameter - see: https://docs.magnolia-cms.com/product-docs/6.2/Developing/API/Delivery-API.html#_methods

Development notes

The returned pages are the result of the execution of the following query in info.magnolia.rest.delivery.jcr.v2.JcrDeliveryEndpoint.queryNodes(String, String, Long, Long) method:

SELECT t.* FROM [nt:base] AS t WHERE t.[jcr:primaryType] = 'mgnl:page'

When indicating a path, info.magnolia.rest.delivery.jcr.v2.JcrDeliveryEndpoint.readNode(String) is executed instead which applies the depth value to the children of the given node as expected.


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