Thierry,
In the 2.1 source link you provided, I see that I can make
ClientResource not give an error by overriding doError, but I will not
be able to get the response.
The use case to get the representation from an error status response is
to get additional information about the error.
So even if I do this:
class MyClientResource extends ClientResource {
protected void doError(Status status) { }
}
I still get a null representation returned from handle:
protected Representation handle(Method method, Representation entity,
ClientInfo clientInfo) {
Representation result =null;
// Prepare the request by cloning the prototype request
Request request =new Request(getRequest());
request.setMethod(method);
request.setEntity(entity);
request.setClientInfo(clientInfo);
// Actually handle the call
Response response = handle(request);
if (response.getStatus().isError()) {
doError(response.getStatus());
}else {
result = (response ==null) ?null : response.getEntity();
}
return result;
}
I can think of a couple ways to change the API of ClientResource. You
may have other ideas, but here are mine:
1. an instance variable:
if (this.throwErrors&& response.getStatus().isError()) { ...
2. more parameters and a returned value from doError
if (response.getStatus().isError()) {
return doError(method, entity, clientInfo, response);
} ...
Is there something I should be using instead of ClientResource, or is
this just an oversight?
Thank you,
Leigh.
On 02/16/2011 06:54 AM, Thierry Boileau wrote:
> Hello Leigh,
>
> you're right, these Java access modifiers moved from "private" to
> "protected" in the current trunk (2.1 release) on the 7th of december
> 2010.
> you can have a look here for more details about this update
> http://restlet.tigris.org/source/browse/restlet/trunk/modules/org.restlet/src/org/restlet/resource/ClientResource.java?revision=7211&view=markup
>
> <http://restlet.tigris.org/source/browse/restlet/trunk/modules/org.restlet/src/org/restlet/resource/ClientResource.java?revision=7211&view=markup>.
> I think that Jerome did not update the 2.0 branch in order to keep the
> API intact, so I'm not sure he's enclined to change that.
>
> Do you mind waiting the 2.1 release (planned for the second quarter of
> 2011 http://www.restlet.org/about/roadmap)? As a workaround, you can
> still override the ClientResource code and adapt the current behaviour
>
> Best regards,
> Thierry Boileau
>
> I'd like to make a ClientResource.get call and get back the status, no
> matter what it is.
> The lowest level in ClientResource prohibits this:
>
> private Representation handle(Method method, Representation entity,
> ClientInfo clientInfo) {
> ...
> // Actually handle the call
> Response response = handle(request);
>
> if (response.getStatus().isError()) {
> throw new ResourceException(response.getStatus());
> } else {
> result = (response == null) ? null : response.getEntity();
> }
>
> Since it's private I can't even override it.
>
> Am I missing something?
>
> Leigh.
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2704680
>
> <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2704680>
>
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2704852