Hi Jerome,

> Good points. You got the post method right, it could just be simpler:
> 
>  post(...) {
>      [..]
>      ImageResource image = new ImageResource(...);
> 
> getResponse().setEntity(image.getRepresentation(image.getPreferredVariant())
> );
>  }

I thought this wouldn't work because the image knows nothing about the request,
 so the getPreferredVariant won't know the client has requested am image/png
variant.
But, resding your response, I realized that I  it is might just be a matter of
 creating the appropriate Image constructor:

public Image(Context, context, Request request, 
             Response response,<other parameters>){
  super(context,request,response);
  // initialize the  resource from <other parameters>
  [...]
 }

In Collection.post I would then do:

Representation post(...){

  // Create the resource
  [...]
  // return a representation of the newly created resource
  Image image = new Image(getContext(),getRequest(),getResponse(),
                          <other parameters>);
  getResponse().setEntity(image.getRepresentation(image.getPreferredVariant());
}


I hope we can declare that one horse dead for good...

Thanks,

-Vincent.

Reply via email to