RE: Re: can not return description in put

2011-06-16 Thread Bram van der Waaij
Hi,

The put method is being called, so overriding is working i assume. Overriding 
the put (representation, variant) is not working, then the put call is not 
handled. Which i can understand because i do not use negotiation and therefore 
this version of the put method should not be called. 
I tried the apache http client library to call my server. That shows that het 
get acutually returns in the http statusline the reasonphrase i have set. By 
switching to the put, the reasonphrase replaces my msg with the default 
description of the status code. At least now i know for sure that it is the 
server which is not sending the correct reasonphrase. 

Still leaves the problem of how to pass my msg to the client from a put

I do not use the annotations, because i want to have more control over the 
processing flow. Mixing the two unfortunately does not work. It produces an 
internal server error ;-)

Any other ideas?

Bram

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2767335


RE: Re: can not return description in put

2011-06-15 Thread Bram van der Waaij
Nop, unfortunately both options produce the same result. 
The clientresource.getStatus().getDescription() call on a Get returns my 
message from the setStatus at the server

The clientresource.getStatus().getDescription() call on a Put returns the 
description of the status error code (400 - Bad request) instead of my message.

Any further ideas how to fix this?

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2766233


RE: Re: can not return description in put

2011-06-15 Thread gonzajg
Maybe restlet is using the other put method
@Override
protected Representation put(Representation representation, Variant
variant) throws ResourceException

try overriding that one.

I use anotations in resources like:

@Get
public Representation getResource(){
}

@Put
public void putResource(){
}

etc.

So I really don't know if overriding put methods work.

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/can-not-return-description-in-put-tp6474740p6479427.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2766259


can not return description in put

2011-06-14 Thread Bram van der Waaij
Hello list,

Can you explain to me how to return a description with a client_error status in 
a PUT handler? Things are working in the GET handler, but for some reason i can 
not get it working in the put.
In the client the error_code is available, but my description Payload is not 
in JSON format is not. The description from the GET is available.

public class MyServerResource extends ServerResource {

@Override
protected Representation get() {
Representation representation = null;
MediaType returnMediaType = getPreferredMediaType();
if (MediaType.APPLICATION_JSON.equals(returnMediaType)) {
representation = getCSV();
} else {
setStatus(Status.CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE,
Can only support application/json);
}

return representation;
}


@Override
protected Representation put(Representation representation) {
// check if the requested mediatype is application/json
if 
(MediaType.APPLICATION_JSON.equals(representation.getMediaType())) {
JsonRepresentation jsonRepresentation = new 
JsonRepresentation(representation);
if (jsonRepresentation == null) {
setStatus(Status.CLIENT_ERROR_BAD_REQUEST, 
Payload is not in JSON format);
} else {
// other stuff
}
}
return null;
}
}

This e-mail and its contents are subject to the DISCLAIMER at 
http://www.tno.nl/emaildisclaimer

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2765366

Re: can not return description in put

2011-06-14 Thread gonzajg
Hi Bram,

try:

getResponse().setStatus(status);

or 

Response.getCurrent().setStatus(status);

hope it helps!

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/can-not-return-description-in-put-tp6474740p6475166.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2765427