javahttpisis

Apache ISIS: Set HTTP-Response


I have the following situation:
When someone calls my Restful-Service Apache the Apache isis code is predifened accordingly to the request. If you miss some parameters you will get a 400 - Bad Request. Otherwise when all parameters are given you will usually get a 200 - OK. But sometimes I want to response a 201 - Created or 202 - Accepted.
I didn't find a solution for this problem in the Apache ISIS documentation, and I didn't find a code example in the www.

So could anyone help me here?

Thanks

Edit:
I found this url https://github.com/apache/isis/blob/master/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java. There static methods from the Responses class is used to create some 2xx statuses, but only 200 - OK and 204 - No Content could be created within this class. For all other non-2xx status codes a RestfulObjectsApplicationException is thrown.
Is this the right way to respond http codes to the caller? And how can i respond for example a 202 status code?


Solution

  • The long and short of it is that Apache Isis implements the Restful Objects spec, and the latter doesn't define these status codes. So there is currently no way to return a 202.

    I think that 202 might make sense for a background command, ie one that is annotated to run in the background using @Action(commandExecuteIn=BACKGROUND.

    What semantics do you see that 202 should represent?

    Meantime, I've raised a JIRA ticket to capture this conversation.

    Thx Dan