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

When targetting root and depth=0, only return root nodes

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Neutral
    • None
    • 2.2.4
    • None
    • None

    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.

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                Unassigned Unassigned
                jayala Jonathan Ayala
                Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:

                  Checklists

                    Task DoD