Hello Thierry,
Thanks for your answers. Is there a simple way on Restlet's side to
enforce us, lazy developers, to pass such params (actually a
Representation class) on annotated method handlers?
What happens if I use the signature you propose with DomRepresentation
as the entity parameter to the method handler, and a 'misbehaved'
client sends something that's not XML in the entity body of a request
for that method on that resource?
Shouldn't it be safer to do something like:
static final Variant APP_XML = new Variant(MediaType.APPLICATION_XML);
static final Variant TXT_XML = new Variant(MediaType.TEXT_XML);
@Propfind
public Representation propfind(Representation reqrep) throws ResourceException {
if (!reqrep.isCompatibleWith(APP_XML) && !reqrep.isCompatible(TXT_XML)) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST);
}
// else request entity looks fine, proceed.
}
I guess I'll have to add that 'boilerplate' code all over the place to
make the app more robust against experimentors/misbehaved users
attempts to 'test' it.
On Wed, Sep 8, 2010 at 5:53 AM, Thierry Boileau
<[email protected]> wrote:
> Hello Fabian,
>
>
>>So I guess I can just ommit the final DomRepresentation ... line.
> Actually, as you need to access the DOM nodes, you still have to wrap the
> given instance of InputRepresentation.
> And as you rely on the XML extension, which provides is own converter, I
> think you can try :
> public Representation propfind(DomRepresentation reqrep) throws
> ResourceException {
> }
>
>>Maybe the empty parameters signature is confusing the content negotiation
>>logic for the annotated method handler somehow?
> Yes, this is the point. When using annotations which rely on an entity, it's
> warmly recommended (and even mandatory) to have a parameter in the annotated
> java method.
>
> Best regards,
> Thierry Boileau
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2656741
>
--
Fabián Mandelbaum
IS Engineer
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2656800