Is there a way to know the verb (GET, POST, PUT, DELETE) inside the execute method of AbstractWebScript? Does WebScriptRequest know anything about whether the call is a GET, or a PUT, or a POST, or a DELETE?
I can always create another web script (one for PUT, another for POST etc.).
I can also differentiate between the verbs, if the URI is different for PUT, GET etc.
But I was wondering if the WebScriptRequest has a way to determine the verb type (whether it is GET, POST, PUT, DELETE).
Yes, you technically can get the verb from the description, which holds the method the web script was defined for. Since each web script inherently is associated to a single verb based on the bean name, you will typically only need to check the verb if you re-use the same implementation class for different web scripts, e.g. to build a dispatcher-like web script.
The web script request itself does not contain that information, though you could technically retrieve it from there as well via the reference to the HttpServletRequest - but that would require you to cast the request to one of the specific implementation classes and it is not guaranteed you will get the one implementation class that will allow you to access the servlet request.
1. We cannot get the verb (e.g. GET, POST etc.) from WebScriptRequest because, we cannot cast the WebScriptRequest to HttpRequest (it will throw runtime error).
2. None of the methods of WebScript request return the verb.
3. The header does not include the verb (which is obvious, but wanted to state it).
Is there anything that I put in descriptor, which will possibly return the verb from the WebScriptRequest, inside the execute method ?
My descriptor (xxxx.post.desc.xml loks like):
<webscript>
<shortname></shortname>
<description>??? Can I put anything here</description>
<url>/example/aNumber</url>
<format default="json">extension</format>
<transaction>required</transaction>
<authentication runas="admin">none</authentication>
</webscript>
The WebScriptRequest sure does provide that information: request.getServiceMatch().getWebScript().getDescription().getMethod().
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.