Do you use “Rest Services Setup tool” in Essentials to setup a new mount (e.g, “/api”) for resource bundle documents, creating a custom JAX-RS class like the author did [1]?
Or are you using the Generic Content REST API explained in [2]?
Actually the both (the two references) can be set up through Rest Services Setup tool. Is your REST API endpoint is from (a) Plain JAX-RS or (b) Generic Content REST API?
If you’re not sure, you can copy and paste the json output to show the structure (not data) here. Then we will know which one you’re using.
OK. You are using “Content REST API” as it shows the same structure as shown in [1].
It provides neither the feature to set “Last-Modified” header nor dynamic resolution of the value.
According to its technical design document [2], it uses “RestApiPipeline”. So, I think it is technically possible to inject a custom valve to determine and set any extra response headers to the pipeline. See [3] for detail.
I don’t know the detail on how Content REST API is implemented and whether or not it’s supposed to set the requestContext’s content bean. It doesn’t look implemented to support that.
You can perhaps read the UUID from the URI by HstRequestContext#getServletRequest().getRequestURI which probably returns something like /site/api/documents/31336ce3-1236-41ee-a2bb-ae0912104937. Then you can get the document’s UUID from there.
Now, read the document node by HstRequestContext#getSession().getNodeByIdentifier() (e.g. getSession.getNodeByIdentifier("31336ce3-1236-41ee-a2bb-ae0912104937")), and reads its property somehow like org.hippoecm.repository.util.JcrUtils#getDateProperty(Node node, String propNameOfTheNode, Calendar defaultDate).
Hello everyone. I have one question a bit off the topic. The last modified date and published date are actually present in document info.
Does somebody know how to add these values to the RESOURCE API response?