How to get child elements that is not deleted using nuxeo rest endpoint?

180 Views Asked by At

When I call http://localhost:8080/nuxeo/api/v1/id/bad6cbc5-b75f-4373-981f-6908cec66779?enrichers.document=children endpoint it returns all child elements include deleted elements. But I need to get only active elements and I think I should add isTrashed=false query to endpoint. But http://localhost:8080/nuxeo/api/v1/id/bad6cbc5-b75f-4373-981f-6908cec66779?enrichers.document=children&isTrashed=false does not any effect. How can I get only active child elemets from nuxeo server using rest api?

1

There are 1 best solutions below

2
cgrim On

/nuxeo/api/v1/id endpoint with children enricher does not support this kind of filtering.

I see two options:

  1. Implement own enricher which will support filtering of trashed documents. children enricher is implemented by org.nuxeo.ecm.core.io.marshallers.json.enrichers.ChildrenJsonEnricher class so you can inspire there how to do that.
  2. Use different end point with page provider which supports filtering of trashed documents: /nuxeo/api/v1/search/pp/advanced_document_content/execute?&ecm_parentId=bad6cbc5-b75f-4373-981f-6908cec66779&ecm_trashed=false

Benefits of the second option:

  • paging - simply add currentPageIndex=0&offset=0&pageSize=20 to the query
  • properties - you can define what properties do you need by adding of header: properties:dublincore,common,uid,file
  • enrichers - it means that you can use enrichers for each child and receive for example permission or thumbnail URL for each child. To do that add this header: enrichers-document: thumbnail, permissions

Example curl call:

curl -X GET -u Administrator:Administrator \
 -H "properties:dublincore,common,uid,file" \
 -H "enrichers-document: thumbnail, permissions" \
 "http://localhost:8080/nuxeo/api/v1/search/pp/advanced_document_content/execute?&ecm_parentId=bad6cbc5-b75f-4373-981f-6908cec66779&ecm_trashed=false" | jq