Re: Mime type filtering.

2009-02-06 Thread Dave Pawson
Thanks Rob, Rhett.

2009/2/6 Rob Heittman :
> Hi Dave!  (Shout out from fop-dev back in the day)
>
> If you are using the Accept: header in your client
Yes, thats the criterion I'm using.


> ... and using the Restlet
> Resource model on the server ... just write your responding code in your
> override of represent(Variant variant).
>
> if(variant.getMediaType().equals([the MediaType you speak])){
>   // do stuff;
> } else {
>   // return the error status;
> }

I'm guessing this is where I'd need to handle the 406?
Or use Rhetts idea and extend resource.

OK, It's doable. I need to study the API a bit more.


>
> I just spotted this example blog that does pretty much what you want:
> http://www.2048bits.com/2008/06/creating-simple-web-service-with.html

Thanks for that, looks good.

I couldn't find much in http://tomcat.apache.org/tomcat-6.0-doc/api/index.html
to help me get the header so I'll move this work over to restlets.

regards



-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

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


Re: Mime type filtering.

2009-02-06 Thread Rhett Sutphin
Hi,

On Feb 6, 2009, at 2:55 PM, Rob Heittman wrote:
> If you are using the Accept: header in your client ... and using the  
> Restlet Resource model on the server ... just write your responding  
> code in your override of represent(Variant variant).
>
> if(variant.getMediaType().equals([the MediaType you speak])){
>   // do stuff;
> } else {
>   // return the error status;
> }


What Rob's saying will work for sure.  You don't even have to handle  
the 406 yourself -- if you extend Resource and override  
represent(Variant), Restlet will automatically send the 406 if the  
represent method returns null.

Rhett

On Feb 6, 2009, at 2:55 PM, Rob Heittman wrote:

> Hi Dave!  (Shout out from fop-dev back in the day)
>
> If you are using the Accept: header in your client ... and using the  
> Restlet Resource model on the server ... just write your responding  
> code in your override of represent(Variant variant).
>
> if(variant.getMediaType().equals([the MediaType you speak])){
>   // do stuff;
> } else {
>   // return the error status;
> }
>
> I just spotted this example blog that does pretty much what you  
> want: http://www.2048bits.com/2008/06/creating-simple-web-service-with.html
>
> On Fri, Feb 6, 2009 at 6:42 AM, Dave Pawson   
> wrote:
> I want to do a GET, specifying that I can accept application/xml+atom
> as a mime type.
>
> At the server end; Unless this is specified (in the header I think -
> my knowledge of http isn't very strong)
> I want the server to reject the GET (error code 406 seems right). Even
> if no mime type is specified,
> I will still refuse the GET.
>

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


Re: Mime type filtering.

2009-02-06 Thread Rob Heittman
Hi Dave!  (Shout out from fop-dev back in the day)

If you are using the Accept: header in your client ... and using the Restlet
Resource model on the server ... just write your responding code in your
override of represent(Variant variant).

if(variant.getMediaType().equals([the MediaType you speak])){
  // do stuff;
} else {
  // return the error status;
}

I just spotted this example blog that does pretty much what you want:
http://www.2048bits.com/2008/06/creating-simple-web-service-with.html

On Fri, Feb 6, 2009 at 6:42 AM, Dave Pawson  wrote:

> I want to do a GET, specifying that I can accept application/xml+atom
> as a mime type.
>
> At the server end; Unless this is specified (in the header I think -
> my knowledge of http isn't very strong)
> I want the server to reject the GET (error code 406 seems right). Even
> if no mime type is specified,
> I will still refuse the GET.
>

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

Mime type filtering.

2009-02-06 Thread Dave Pawson
Requirement:

I'm setting up a private service, using restlets under Tomcat.
No browser interaction, just a data endpoint for my own use (and to
learn a little more about restlets).

I want to do a GET, specifying that I can accept application/xml+atom
as a mime type.

At the server end; Unless this is specified (in the header I think -
my knowledge of http isn't very strong)
I want the server to reject the GET (error code 406 seems right). Even
if no mime type is specified,
I will still refuse the GET.



Jerome pointed me to  extension to MIME type mappings:
http://www.restlet.org/documentation/snapshot/api/org/restlet/service/MetadataService.html


Is this the best way to do this kind of filtering please?
Or use a Tomcat filter?


regards



-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

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