Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

TeamModelledRestService - Set status code for response

Hello,

Is there a way I can set the status of the HTTP response object which is returned when I am implementing services which use ITeamModelledRestService interface ?

Thanks
- Vibha

0 votes



3 answers

Permanent link
Is there a way I can set the status of the HTTP response object which
is returned when I am implementing services which use
ITeamModelledRestService interface ?

You can throw an exception:

ItemNotFoundException -> 404 Not found
IllegalArgumentException -> 400 Bad Request
StaleDataException -> 409 Conflict
TeamRepositoryException -> 500 Internal Server Error
....

Which status code would you like to set?

Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
It could be either 404, 409 or 500 depending on the exception caught in service implementation code.

0 votes


Permanent link
It could be either 404, 409 or 500 depending on the exception caught
in service implementation code.

So you could just declare your methods in ITeamModelledRestService with
'throws TeamRepositoryException' and either don't catch the exceptions
if they are already either ItemNotFoundException (404),
StaleDataException (409) or TeamRepositoryException (500 or depending on
the actual subclass).

If you are catching other exceptions, you can throw one of the above to
get the corresponding HTTP status code.

HTH,
Patrick
Jazz Work Item Team

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Oct 21 '08, 2:21 a.m.

Question was seen: 5,452 times

Last updated: Oct 21 '08, 2:21 a.m.

Confirmation Cancel Confirm