No announcement yet.
  • Filter
  • Time
Clear All
new posts

  • How to subclass RESTHandler, process requests and return error messages to API users?

    Hi Isomorphic,

    weeks becoming 1.5 years, but I finally started with my RESTHandler-subclass, hitting some roadblocks (using latest 6.1p).
    I had a look at your RESTHandler.processRequest() implementation.
    For now, I was using a request like in the example, but amended two fields:
    I did @override handleDSRequest() and checked the username and token there, then did setUserId() and setUserRoles() on the RPCManager.
    Here the first problem arises:
    If the user does not exists, the token does not match, etc... I return new DSResponse.setFailure("Some useful errormessage").

    handleDSRequest() is called by your processRequest()-implementation for every request in the call.
    Returning setFailure() makes the processRequest() stop the transactions and returns only -1 or -10 as status and no status message.
    <?xml version="1.0" ?>
    While I realize that I probably should do the check on the user not in the request, but before though querystring parameters, I do have some problems here, the biggest being "How do I show an error message to the developer using my API". Is it correct that the message from DSResponse.setFailure("Some useful message") is not displayed in the response sent to the browser?

    If I do the users check not in handleDSRequest(), but before in processRequest() or even doPost(), how do I set username and roles?
    If a request fails because of declarative security (e.g. missing role), how do I display this error message?
    I think I know this problem from the normal application and IDACall, where the error messages for queues (not single requests!) are also not displayed, but I might be wrong here.

    Do you suggest overriding handleDSRequest() or processRequest()? I'd very much prefer handleDSRequest(), if I can solve the issues above.

    Also I had a look at your processRequest() implementation (using JD Eclipse) and tried to @override it with just the same code in my Subclass. This fails, as many needed constants are private and not protected. Is this correct?
    Do you have the same minimal override-pseudocode processRequest() you offer for IDACall here in the docs?

    It are many questions, but aggregated as 1st pointers these would suffice:
    1. Is it OK that error messages from setFailure() are not displayed. If so, how to communicate to the API-user?
    2. @Override handleDSRequest() or processRequest()?
    3. If override processRequest(), how exactly? Perhaps you can add pseudocode for this in the docs like you do for IDACall.
    Thank you & Best regards

  • #2
    We are considering some improvements in this area to make subclassing RESTHandler more straightforward and easy to understand. We will post back here in the next couple of days.

    Isomorphic Software Support


    • #3
      Hi Isomorphic,

      that is great to hear! Will this also cover the error-message topic?

      Thanks a lot,


      • #4
        Hi Isomorphic,

        this will go into 6.1p, correct?

        Best regards