Document Detail Resource
The document detail resource returns the details of a single published document. You must provide the UUID of the document's handle. This UUID must reference a published document that is a descendant of the configured mount path.
After you run the REST setup tool and add the generic resources with default settings, the resource is available at:
http://localhost:8080/site/api/documents/{uuid}
This page includes an example response and notes about the response format.
The document detail resource provides three main features:
- Link rewriting
- Rendering output using the Content Model
- Attribute selection for document properties
Link Rewriting
The resource rewrites all links in the document content according to these rules:
- Links to images and assets are rewritten to use the binaries servlet. If a specific image variant is selected in the link picker, the response includes a link to that variant. Otherwise, the default variant is used.
- If the document is available over the same mount, the response includes a link to that resource.
- If the document is exposed over a mount that is not a Content REST API (such as a standard web channel), the response includes a link to the page rendering that document.
- If the link is broken or the document is not exposed over any mount, the response includes a broken link.
Note: If the document is exposed over a different mount using the Content REST API, the resource does not generate a cross-mount link. Cross-mount linking to mounts without a sitemap is not supported.
Rendering Output Using the Content Model
The document detail resource uses the Content Model to determine which properties to include in the response. Only properties defined in the Content Model are rendered. The Content REST API queries the Content Type Service to retrieve the Content Model.
All certified plugins are verified to register the required properties. If you use custom plugins and notice missing content in the API response, verify that your plugins register all properties used by your document types.
Document Attribute Selection
By default, the response includes all attributes (JCR properties) of the document. You can limit the response to specific attributes by using the _attributes query parameter.
For example:
This request returns only the myproject:title and myproject:content attributes. All other attributes are excluded. This filter applies to all attributes defined in the document type and to the workflow-related attributes: pubState, pubwfCreationDate, pubwfLastModificationDate, and pubwfPublicationDate.
Known Limitations
If your project has undergone several content model upgrades, you may need to run Groovy scripts to ensure consistent API output. For example, if you add a non-mandatory property P, documents published before P was introduced will not include the property, while newer documents will include it with an empty value. To standardize this, run a Groovy script to add property P with an empty value to older documents.
Binary properties are not included in the response. Use image sets or assets for binary content.
Example
The following example shows the response for the document "The gastropoda news," which is included as part of the "News" feature in Essentials. The document has been edited to include a link and an image in the Content property.
{ id: "aeda2bcd-b21d-4ead-a2e6-c64a2ca051c8", name: "the-gastropoda-news", displayName: "The gastropoda news", type: "myproject:newsdocument", locale: "en", pubState: "published", pubwfCreationDate: "2013-11-12T12:50:00.000+01:00", pubwfLastModificationDate: "2016-02-01T11:36:32.598+01:00", pubwfPublicationDate: "2016-02-01T11:36:34.780+01:00", items: { "myproject:source": "", "myproject:location": "Liverpool", "myproject:title": "The gastropoda news", "myproject:author": "Alfred Anonymous", "myproject:date": "2016-02-01T10:58:00.000+01:00", "myproject:introduction": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum", "myproject:content": { type: "hippostd:html", content: "<p><a data-hippo-link=\"the-medusa-news\">Lorem</a> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p> <p><img data-hippo-link=\"animal-2883_640.jpg\" /></p> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </p> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </p>", links: { "the-medusa-news": { type: "local", id: "c580ac64-3874-4717-a6d9-e5ad72080abe", url: "http://localhost:8080/site/api/documents/c580ac64-3874-4717-a6d9-e5ad72080abe" }, "animal-2883_640.jpg": { type: "binary", url: "http://localhost:8080/site/binaries/content/gallery/myproject/samples/animal-2883_640.jpg" } } }, "myproject:image": { type: "hippogallerypicker:imagelink", link: { type: "binary", url: "http://localhost:8080/site/binaries/content/gallery/myproject/samples/snail-193611_640.jpg" } } } }
Note:
Links within rich text fields use the data-hippo-link attribute to associate the HTML element with the corresponding link details in the links object.