Re: method not found 405 on multipart/form-data post?

2010-10-01 Thread Jonathan Hall
Hi Keith,

Glad you found a temp fix. I'm not sure what the problem is, the 
boundary should be fine. I tested it here with a multipart message and 
it works as expected (and shows the boundary info).

Just to be sure, you are adding the extension to the current Application 
in use?
I am using a 2.1 snapshot, and running Restlet directly, not within a 
servlet, and using the Jetty connector.

In my Application subclass, I simply have:
getMetadataService().addExtension(multipart, 
MediaType.MULTIPART_FORM_DATA,true);

and in my resource:
@Post(multipart)
 public Representation blah(Representation entity) throws 
ResourceException { ... }

To check that your contexts application is using the multipart 
extension, you could try in your resource:

getApplication().getMetadataService().getMediaType(multipart);

which should return multipart/form-data


Jon

On 28/09/10 18:00, Keith Irwin wrote:
 Jonathan--

 That didn't work. I think it's because the Content-Type comes across
 as a unique string each time a request as made. For example:

multipart/form-data; boundary=6068cb2e3a84
multipart/form-data; boundary=eb944e1f8467

 So, I did something similar to the following (in Scala):

val app = new WebApp()
val multi = MediaType.register(multipart/*, file upload)
app.getMetadataService().addExtension(multipart, multi, true)

 in hopes that the wildcard would pick things up. But, alas, it didn't.
 The only thing that works for me is to override the post method and
 then do something like:

if (entity.getMediaType().toString().contains(multipart)) {
  // do parsing here
}

 All of which means that I'm not stuck. Is there some way to
 characterize the media type such that it'll pick up the content-types
 (above) as sent by clients?

 Keith

 On Tue, Sep 28, 2010 at 1:29 AM, Jonathan Halljonrh...@gmail.com  wrote:

 Hi Keith,

 This is all set in org.restlet.service.MetadataService.

 form is a  MediaType.APPLICATION_WWW_FORM , which explains why the
 multipart is returning a 405.
 A multipart (MediaType.MULTIPART_FORM_DATA ) request doesn't seem to
 be in the MetadataService, so you could add your own.

   From your Application: getMetadataService().addExtension(multipart,
 MediaType.MULTIPART_FORM_DATA, true);

 then you can do:

 @Post(multipart)
 ...

 Hope this helps,

 Jon

 On 28/09/10 02:30, Keith Irwin wrote:
  

 On Mon, Sep 27, 2010 at 5:03 PM, Keith Irwinkeith.ir...@gmail.com
 mailto:keith.ir...@gmail.com  wrote:

  Folks--

  Using restlets 2.1 snapshot

  I have a method defined like this:

@Post(form)
public Representation accept(Representation r) {
   ...
}

  When I use the following command line to test:

 curl -v -d foo=bar http://localhost:9000/my/route

  everything works just fine. I'm getting a representation of type
  application/x-www-form-urlencoded, which is what I'd expect.

  However, if I do the following:

curl -v -F foo=bar http://localhost:9000/my/route

  which sends the data as multipart/form-data, I get a 405, Method
  Not Allowed response.


 When I override the post method in my ServerResource subclass and
 print out the media type of the entity, I get the following:

 multipart/form-data; boundary=e5eac570d03e

 rather than just plain old: multipart/form-data, which is what I'd
 expect based on the value of the MediaType.MULTIPART_FORM_DATA object.

 Not sure if this might be the problem.

 Keith


  If I do NOT use the @Post(form), no matter what I do I get the 405.

  I've got the fileupload extensions installed. Is there something
  I'm missing? What token should I include in the @Post annotation?
   multipartform doesn't seem to work.

  Should I downgrade to 2.0?

  Keith



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


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


Re: method not found 405 on multipart/form-data post?

2010-09-28 Thread Jonathan Hall
Hi Keith,

This is all set in org.restlet.service.MetadataService.

form is a  MediaType.APPLICATION_WWW_FORM , which explains why the 
multipart is returning a 405.
A multipart (MediaType.MULTIPART_FORM_DATA ) request doesn't seem to 
be in the MetadataService, so you could add your own.

 From your Application: getMetadataService().addExtension(multipart, 
MediaType.MULTIPART_FORM_DATA, true);

then you can do:

@Post(multipart)
...

Hope this helps,

Jon

On 28/09/10 02:30, Keith Irwin wrote:


 On Mon, Sep 27, 2010 at 5:03 PM, Keith Irwin keith.ir...@gmail.com 
 mailto:keith.ir...@gmail.com wrote:

 Folks--

 Using restlets 2.1 snapshot

 I have a method defined like this:

   @Post(form)
   public Representation accept(Representation r) {
  ...
   }

 When I use the following command line to test:

curl -v -d foo=bar http://localhost:9000/my/route

 everything works just fine. I'm getting a representation of type
 application/x-www-form-urlencoded, which is what I'd expect.

 However, if I do the following:

   curl -v -F foo=bar http://localhost:9000/my/route

 which sends the data as multipart/form-data, I get a 405, Method
 Not Allowed response.


 When I override the post method in my ServerResource subclass and 
 print out the media type of the entity, I get the following:

 multipart/form-data; boundary=e5eac570d03e

 rather than just plain old: multipart/form-data, which is what I'd 
 expect based on the value of the MediaType.MULTIPART_FORM_DATA object.

 Not sure if this might be the problem.

 Keith


 If I do NOT use the @Post(form), no matter what I do I get the 405.

 I've got the fileupload extensions installed. Is there something
 I'm missing? What token should I include in the @Post annotation?
  multipartform doesn't seem to work.

 Should I downgrade to 2.0?

 Keith



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


Re: Restlet Framework 2.0.1released

2010-09-13 Thread Jonathan Hall
Same issue here.

On 09/09/10 15:24, Tal Liron wrote:
 Just a quick note on changed behavior I noticed in 2.0.1 --

 If you throw a ResourceException that has a cause, the cause is now sent
 to the status service for processing into a new status. If you don't
 have explicit support for this, you'll likely get a 500 error, thus
 overriding whatever status you set in the ResourceException (say, 404).
 I'm not sure if this a regression or intended new behavior... but it did
 break a few of my applications.

 -Tal

 On 09/08/2010 12:30 PM, Thierry Boileau wrote:

 Hello all,

 The version 2.0.1 of the Restlet framework has been released and can
 be downloaded at this uri: http://www.restlet.org/downloads/.
 The list of bugs fixed and changes is available here:
 http://www.restlet.org/documentation/2.0/jse/changes.

 We would like to thank all the people who contributed to this release.

 Best regards,
 Thierry Boileau
  
 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2657215


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


Deprecated Request.getEntityAsForm()

2010-09-10 Thread Jonathan Hall
Hi,

I was wondering the reason why Request.getEntityAsForm() is now deprecated?

I realise you can use getQuery() in a resource, but what about Filters, 
where that method doesn't exist.
I can use new Form(getRequest().getEntity()), but it seems a step 
backward for such a common usecase.

Jon

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


Re: 405 on unsupported media type

2010-08-27 Thread Jonathan Hall
I believe that's a  415.

Jon

On 27/08/10 19:33, Avi Flax wrote:
 Hi all,

 I'm using 2.0 jse. I've got a method that has this signature:

 @Post(form)
 public Representation accept(Form form) throws ResourceException {

 Everything generally works fine, but when I send a request with an
 unsupported Content-Type — text/plain, say — the service returns 405
 Method Not Allowed. This seems a little off to me — the method I sent
 was POST, which IS allowed. What's not supported is the content type.
 I'd prefer the Status Code in this situation to be 400 Bad Request,
 and for the default error message to explain that the supplied
 representation is not a supported Content Type. I think that'd be more
 semantically correct.

 Does this make sense? I personally would like to see this change made.

 Thanks,
 Avi

 Avi Flax » Partner » Arc90 » http://arc90.com
 Kindling: Innovation through Collaboration » http://kindlingapp.com

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


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


Re: Accepted media type quality is always 1.0

2010-07-27 Thread Jonathan Hall
I've just upgraded to the latest snapshot and getVariants() is showing 
empty for anything but the internal connector.
Related?

http://restlet.tigris.org/issues/show_bug.cgi?id=1156

On 26/07/10 06:54, Christian Bauer wrote:
 It works with the built-in server connector but fails with the Simple
 connector. I've added simple-4.1.20.jar and org.restlet.ext.simple.jar from
 Restlet 2.2.0 and then always received quality level 1.0.



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


Re: Many representation handling in a resource

2010-01-07 Thread Jonathan Hall
http://wiki.restlet.org/developers/172-restlet/226-restlet.html

Xavier M. wrote:
 Hello,
 I would like to know if there is an exampel where in the same resource 
 we can find for instance several @get methods with different kinds of 
 representations.
 If so, we could provide for the same resource a @get method matching 
 object represention, another one for xml, and finaly one for json. 
 Interesting for interoperability or scalability.
 regards
 Xavier

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


Re: MIME Accept Type filter

2009-12-16 Thread Jonathan Hall
FYI I filed this bug to jQuery over a year ago 
http://dev.jquery.com/ticket/3408

jon


Thierry Boileau wrote:
 Hi Andrzej

 could you use the dataType argument instead of the beforeSend one?

 $.ajax({type: 'GET',
 url: myUrl,
 success: onAjaxSuccess,
 error: onAjaxError,
 cache: false,
 dataType: xml);


 Best regards,
 Thierry Boileau

   
 Thierry,

 1) Our JQuery Ajax call:

 $.ajax({
  type: 'GET',
  url: myUrl,
  success: onAjaxSuccess,
  error: onAjaxError,
 cache: false,
 beforeSend :
 function(xhr){xhr.setRequestHeader('Accept','application/xml')}
  });

 Will generate Accept header of  */*, application/xml. We want
 application/xml.

 2) Our Restlet 1.1.5
  
 @Override
 public Restlet createRoot() {
  // Create a router Restlet.
  Router router = new Router(getContext());
  
  // Attach our routers.
  router.attach(/test, HelloWorldResource.class);
  router.attach(/file/status, FileStatusResource.class);

  return router;
  }


 public FileStatusResource(Context context, Request request, Response
 response) {
  super(context, request, response);
  
  // Read URI query strings.
  Form form = request.getOriginalRef().getQueryAsForm();
  if (form != null) {
  setUser(form.getFirstValue(user, isIgnoreCase()));
  setOriginalUri(form.getFirstValue(originalUri, 
 isIgnoreCase()));
  setAction(form.getFirstValue(action, isIgnoreCase()));
  }
  
  // Variants that our resource generates.
  getVariants().add(new Variant(MediaType.APPLICATION_JSON));
  getVariants().add(new Variant(MediaType.APPLICATION_XML));
  
  }

 @Override
 public Representation represent(Variant variant) throws ResourceException {
  Representation representation = null;
  
  // Validate request
  if (StringUtils.isBlank(getUser())) {
  log.debug(GET FileStatusResource bad user. );
  representation = representError(variant, new 
 ErrorMessage());
  
 getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
  return representation;
  }
  
  representation = representGet(this,variant);
  return representation;
  }

 public final Representation representGet(CoralReefResource crr, Variant
 variant)
  throws ResourceException {
  Representation representation = null;

 log.debug(HTTP GET for :  + variant.getMediaType().getName());
 ...




 Thierry Boileau wrote:
   
 
 Hello Andrzej,

 I wonder if the source cause if your issue is out there.
 Could you tell us how are built your resources? How do you send the 
 request using jquery?

 Best regards,
 Thierry Boileau

 
   
 Our Restlet resource server APPLICATION_JSON and APPLICATION_XML. A
 JQuery
 client, sets the Accept Type to */*, application/xml. So the Restlet
 negotiates that APPLICATION_JSON should be returned as expected. However,
 we
 want APPLICATION_XML to be served. The problem is that we are unable to
 remove the */* as the first Accept type in JQuery. JQuery seems to tack
 on
 the */* as an Accept Type to every request we send.

 Is there an elegant way in Restlet to filter the */* values, e.g. ALL
 or
 APPLICATION_ALL? We can certainly get the Accept Headers in Restlet and
 re-arrange the Accept list ourselves to override the Restlet
 negotiation.
 We are thinking of filtering, after Restlet negotiation, based on the
 User-Agent header for this particular JQuery client, so as not to break
 the Restlet behaviour for other clients (which is what we expect.)

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


 
   
 

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


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


TunnelService - additional tunnel for quirky browser accept headers

2009-12-15 Thread Jonathan Hall
I wish to propose another tunnel which is a bit more practical in 
dealing with browser Accept header quirks.

At present, browsers implement the accept header oddly.

to quote Jon Blower's recent email to the list:

Firefox 3: Accept header is
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8.
Hence text/html is used, as expected.

Chrome 0.2.149.30: Accept header is
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5.
 So Chrome prefers application/xml to text/html and hence gets an XML
representation by default.  Seems odd.

IE7: Accept header does not include text/html, image/png or
application/xml (!!) but does include */* (yuck) so IE gets the
variant that happens to be first in the Resource's list.  With the
above code this just happens to be text/html.  So conneg doesn't
really happen here at all.

The current way of dealing with this is to use the User Agent (ua) 
string and then 'fix-up' the accepted media.

However, we have unknown browsers, or companies who change the ua string 
of known browsers, or future versions that change the ua string, 
different ua strings for different os, etc. This is hard to maintain and 
leaves us open to serving incorrect representations to our users. - 
which happens with chrome at the moment.

An alternative I suggest would be to ignore the accept header and 
provide html unless the person sending the request has gone to lengths 
to send something specific. At lengths could mean where the accept 
header did not contain any mention of html or xhtml at all. Then they 
would be shown the representation they requested in the accept headers.

This could be wrapped up in a tunnel like setUserAgentTunnel() and be 
off by default. It would be an 'either or' to have this or the User 
Agent Tunnel on.

Any thoughts or opinions?

Jon

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


Re: Does Restlet support this kind of functionality?

2009-08-20 Thread Jonathan Hall
Hi,

I haven't used them but I believe these are known as matrix uris and 
they are supported.

See the Reference class and Form class.

http://restlet.tigris.org/issues/show_bug.cgi?id=227 has more info on it.


jon

Johnson wrote:
 hi,

 in the Restful Web Service book, one feature was mentioned e.g.

 one url is like  /Earth/24.9195/17.821, the author of the book thought it 
 doesn't make sense. the correct format should be /Earth/24.9195,17.821 or 
 /Earth/24.9195;17.821

 now suppose I defined a url like /someurl/{one},{two}, then the request url 
 is /someurl/1,2, can I get the value seperately with restlet.

 Thanks and Regards,

 Johnson

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


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


Re: Confusion with filter

2009-06-12 Thread Jonathan Hall
You should be returning securityFilter  not the router. Then the 
securityFilter does it's thing and moves onto the next restlet chain 
(router)

jon

Marc Lerma wrote:
 I'm also confused about the use of filters. I'm trying to apply a security 
 filter in order to check whether the user is authenticated before accessing 
 the resources, but it seems to me that it's never being applied. I've tried 
 to debug the code and the filter is never called before handling a resource. 

 Here is the code:


 @Override
 public synchronized Restlet createRoot() {
 
   
   
   //Crea un router en el cual se registran las URIs y los recursos 
 asociados a cada una

   Router router = new Router(getContext());
   
   router.attachDefault(RESTLoginResource.class);
   router.attach(/login, RESTLoginResource.class);
   router.attach(/{userName}, UserResource.class);


 Filter securityFilter = new Filter(getContext()){
   public int beforeHandle(Request request, Response response){
 
 SessionManager sm =
 
 com.isoco.iwf.webapp.common.Application.getSingleInstance().getSessionManager();
   
 
 if(sm.getLogged(BaseResource.getHttpServletRequest(request))!=null){
   log.info(User is authenticated);
   return Filter.CONTINUE;
 }
 else
 {
   log.info(user must be authenticated );
   return Filter.STOP;
 }
   
 
 
   }
 };
   
   securityFilter.setNext(router);
 
 return router;
 }


 shouldn't the filter be executed before getting to each registered resource ? 


 thanks for your help!

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


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


Re: Last-Modified Header

2009-06-10 Thread Jonathan Hall
Hi Sherif,

For custom headers whatever name you give,  entity.modificationDate,  
will be used.

However, what you probably meant to do is use setModificationDate(new 
Date()) on the entity/response representation. ie. 
representation.setModificationDate(new Date());

Jon

Sherif Ahmed wrote:
 I've been trying to add Last-Modified Header via the following code in a 
 Filter afterHandle method

 Form responseHeaders = (Form) 
 response.getAttributes().get(org.restlet.http.headers);   
 
 if (responseHeaders == null)   
 {   
   responseHeaders = new Form();   
   response.getAttributes().put(org.restlet.http.headers, 
 responseHeaders);   
 }   
 responseHeaders.add(entity.modificationDate, Sun, 06 Nov 2005 14:59:42 
 GMT);  


 However the header in the HTTP Response is not Last-Modified as I would 
 have expected, rather a custom header

 entity.modificationDate: Sun, 06 Nov 2005 14:59:42 GMT

 Quick response would be much appreciated

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


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


Re: Multiple content types

2009-06-08 Thread Jonathan Hall
Hi Sherif,

.js is javascript
.json is json :0)

There is no need to add js or json to the MetadataService as it comes 
with a bunch of common ones already.
Remove that line, and try

http://localhost:8080/firstStepsServlet/Hello.json (Notice the JSON)


Jon

Sherif wrote:

 Thanks Jonathan..

 1. Here’s what I did to support lets say “.js” as an extension to 
 indicate JSON as the content type

 *public* *class* FirstStepsApplication *extends* Application {

 /**

 * Creates a root Restlet that will receive all incoming calls.

 */

 @Override

 *public* Restlet createRoot() {

 // Create a router Restlet that routes each call to a

 // new instance of HelloWorldResource.

 Router router = *new* Router(getContext());

 // Defines only one route

 router.attachDefault(HelloWorldResource.*class*);

 *this*.getTunnelService().setExtensionsTunnel(*true*);

 *this*.getTunnelService().setEncodingParameter(output);

 *this*.getMetadataService().addExtension(js, *new* 
 Metadata(MediaType./APPLICATION_JSON/.getName(), 
 MediaType./APPLICATION_JSON/.getDescription()), *true* );

 *return* router;

 }

 }

 *public* *class* HelloWorldResource *extends* Resource {

 *public* HelloWorldResource(Context context, Request request, Response 
 response) {

 *super*(context, request, response);

 // This representation has only one type of representation.

 getVariants().add(*new* Variant(MediaType./TEXT_PLAIN/));

 getVariants().add(*new* Variant(MediaType./APPLICATION_JSON/));

 }

 /**

 * Returns a full representation for a given variant.

 */

 @Override

 *public* Representation represent(Variant variant) *throws* 
 ResourceException {

 Representation representation = *null*;

 *if*(variant.getMediaType() == MediaType./APPLICATION_JSON/){

 representation = *new* JsonRepresentation(Hello World);

 }*else* *if* ( variant.getMediaType() == MediaType./TEXT_PLAIN/){

 representation = *new* StringRepresentation(

 hello, world, MediaType./TEXT_PLAIN/);

 }

 *return* representation;

 }

 }

 However when I call the service using the following URL 
 http://localhost:8080/firstStepsServlet/Hello.js the Variant type in 
 the HelloWorldResource is of MediaType.TEXT_PLAIN

 Thanks for Your help

 *From:* Jonathan Hall (via Nabble) 
 [mailto:ml-user+125526-1692215...@... 
 http://n2.nabble.com/user/SendEmail.jtp?type=nodenode=3043073i=0]
 *Sent:* Friday, June 05, 2009 1:29 PM
 *To:* Sherif
 *Subject:* Re: Multiple content types

 Have a look at
 http://www.restlet.org/documentation/2.0/api/org/restlet/service/TunnelService.html

 getTunnelService().setExtensionsTunnel(true);

 Jon

 Sherif wrote:
  I realize RESTLet supports multiple encodings based on the Accept 
 Encoding
  headers. Does Restlet also have a way to allow encodings based on 
 URI patter
  e.g. http://mystores/items/1000.json or something like that ?
 

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

 

 This email is a reply to your post @ 
 http://n2.nabble.com/Multiple-content-types-tp3031817p3031841.html
 You can reply by email or by visting the link above.


 
 View this message in context: RE: Multiple content types 
 http://n2.nabble.com/Multiple-content-types-tp3031817p3043073.html
 Sent from the Restlet Discuss mailing list archive 
 http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com.

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


Re: Google AppEngine and Restlet

2009-04-10 Thread Jonathan Hall
This came up today on the GAE list, you may want to chime in when the 
adapation is done so people get the latest information:

http://groups.google.com/group/google-appengine-java/browse_thread/thread/f601350cd8f4d385/c8dc407d77e5562d?lnk=gstq=rest#c8dc407d77e5562d

...

You can also run Restlets on GAE with a little workaround:

Replace initialization of ServletLogger instance with java.util.Logger

in these 2 source files:
   - com.noelios.restlet.ext.servlet.ServletContextAdapter
   - com.noelios.restlet.ext.servlet.ServletConverter

Now add the Restlet servlet to your deployment descriptor and you
should be good to go.
 !-- Restlet adapter --
  servlet
servlet-nameRestletServlet/servlet-name
servlet-classcom.noelios.restlet.ext.servlet.ServerServlet/
servlet-class
  /servlet

  servlet-mapping
servlet-nameRestletServlet/servlet-name
url-pattern/store/feeds/*/url-pattern
  /servlet-mapping:

-Anirudh



Jerome Louvel wrote:
 Hi all,

 When using third-party libraries with GAE SDK, you have to be careful
 because those libraries are not verified against the available Java classes
 (white list). Therefore, it will work locally but break at deployment time!

 Hint: an adaptation of Restlet for GAE is underway. Stay tuned ;)
  
 Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com
  

 -Message d'origine-
 De : Lars Heuer [mailto:he...@semagia.com] 
 Envoyé : vendredi 10 avril 2009 12:32
 À : discuss@restlet.tigris.org
 Objet : Re: Google AppEngine and Restlet

 [...]
   
 Just out of curiosity: Has someone tried Google AppEngine [1] together 
 with Restlet (Servlet connector)?
 

 I ran a few toy applications against the Google AppEngine SDK and discovered
 no problems so far.

 Best regards,
 Lars
 --
 http://www.semagia.com

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

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



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


Re: Restlet 1.2 M2 released

2009-04-02 Thread Jonathan Hall
Really need that full annotation syntax working to test it out ;0)

Regarding that, it does seem odd to have  @Get(xml)  but use 
MediaType.TEXT_XML in the code.

@Get(TEXT_XML) ? Shame you can't have @Get(MediaType.TEXT_HTML). I 
don't know.



Jerome Louvel wrote:
 Hi Jonathan,

 We would be quite happy to get your feed-back, positive or not :)
  
 Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com
  

 -Message d'origine-
 De : Jonathan Hall [mailto:jonrh...@gmail.com] 
 Envoyé : mercredi 1 avril 2009 18:08
 À : discuss@restlet.tigris.org
 Objet : Re: Restlet 1.2 M2 released

 Excellent! I'm looking forward to seeing if the new Resource API simplifies
 development.


 Jerome Louvel wrote:
   
 Hi all,
  
 The second 1.2 milestone is out! 
  
 A complete coverage is available in our blog:
 http://blog.noelios.com/2009/04/01/restlet-12-m2-released/ 
 http://blog.noelios.com/2009/01/23/restlet-12-m2-released/
  
 Best regards,
 Jérôme Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org 
 http://www.restlet.org/
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
 http://www.noelios.com/
 

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

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



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


Re: Restlet 1.2 M2 released

2009-04-01 Thread Jonathan Hall
Excellent! I'm looking forward to seeing if the new Resource API 
simplifies development.


Jerome Louvel wrote:
 Hi all,
  
 The second 1.2 milestone is out! 
  
 A complete coverage is available in our blog:
 http://blog.noelios.com/2009/04/01/restlet-12-m2-released/ 
 http://blog.noelios.com/2009/01/23/restlet-12-m2-released/
  
 Best regards,
 Jérôme Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org 
 http://www.restlet.org/
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
 http://www.noelios.com/

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


Re: which is better way for web application using RESTlet?

2008-11-18 Thread Jonathan Hall
Hi Jerome, I think I came across badly. I wasn't referring to Restlets, 
but OSGi in general.


The main issues (it was a few months back) were that lot of libraries 
don't come with bundles and a large percentage of the time it wasn't as 
simple as running Bnd them. Freemarker wouldn't work (I believe, though 
not sure, spring dm gets it to work by doing some tricks and using 
servlets) and a few classloader issues with other libraries. Tool 
support is lacking, which is to be expected (springs eclipse tool was 
very buggy). To start to get anywhere I started working with the 
spring-dm stuff, which helped and has some nice features, but you end up 
tying more and more of your app with springs OSGi custom tags and way of 
doing things, which meant I couldn't run it outside of spring dm server. 
That and a lot of bugs made me give up playing for a while until it 
matures a bit more. I believe the next OSGi draft will include some of 
the headway springsource has made, so things should get better. Other 
people might have better luck or find their applications are a better fit :)


Jon


Jerome Louvel wrote:

Hi guys,
 
We definitely have OSGi in our radar. We would like to explore better 
integration in the future. It would be nice to be able to easily 
deploy Restlet applications in Spring dm Server.
 
There is even a design discussion started related to better 
Restlet-OSGi integration:
http://wiki.restlet.org/developers/172-restlet/124-restlet.html?branch=docs-1_1language=en 
http://wiki.restlet.org/developers/172-restlet/124-restlet.html?branch=docs-1_1language=en
 
This is related to this RFE: Improve support for OSGi

http://restlet.tigris.org/issues/show_bug.cgi?id=83
 
Best regards,

Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org 
http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/



*De :* Rob Heittman [mailto:[EMAIL PROTECTED]
*Envoyé :* vendredi 14 novembre 2008 17:38
*À :* discuss@restlet.tigris.org
*Objet :* Re: which is better way for web application using RESTlet?

I concur, Restlet on OSGi is interesting to play with ... maybe a 
candidate for a research-oriented project, or something with a very 
future forward vision.  I don't think it's a serious option for 
production work right now ... I'd stick with either the Servlet or 
Standalone modes for production applications.  I have been able to do 
some cool stuff with Restlet under Eclipse OSGi though -- nice to be 
able to swap plugins around the Restlet bits.


On Fri, Nov 14, 2008 at 11:14 AM, Jonathan Hall [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


re OSGi,
I found that I had to battle with the infancy of running in an
OSGi environment far more than being productive. I'd consider
waiting until things stabilise a bit more. Mileage varies of
course. If you do consider that route, S2AP (might have rebranded)
from the spring folks helped a little, but added complexities and
other issues. At this moment in time, it is not something I could
consider using. It would be interesting to hear others thoughts
and opinions.

Jon






Re: which is better way for web application using RESTlet?

2008-11-14 Thread Jonathan Hall

re OSGi,
I found that I had to battle with the infancy of running in an OSGi 
environment far more than being productive. I'd consider waiting until 
things stabilise a bit more. Mileage varies of course. If you do 
consider that route, S2AP (might have rebranded) from the spring folks 
helped a little, but added complexities and other issues. At this moment 
in time, it is not something I could consider using. It would be 
interesting to hear others thoughts and opinions.


Jon

Rob Heittman wrote:

It depends on what you are trying to build with Restlet.

If you need something that a JEE container provides (e.g. lifecycle 
services, deploy/undeploy applications, integration with existing 
Servlet code), or are required to run in an existing JEE container for 
business reasons, then you should use the ServerServlet approach.


If you don't need any of the JEE container features and aren't using 
any Servlet API, it is good to have the ability to run Restlet in 
standalone mode (start Component from main) with your choice of 
connector.  This is excellent for lightweight embedded systems, and 
also for any legacy-free new application which is designed totally 
around Restlet and doesn't need any JEE baggage.


There is also at least one other really interesting option, which is 
to run Restlet as an OSGi service within an OSGi framework.  This 
shares some properties/advantages of both the JEE and Standalone 
approach, and introduces other neat possibilities.  Some of us (at 
least Hendy and I that I know of) have played with Restlet on OSGi a lot.


- Rob

On Fri, Nov 14, 2008 at 8:47 AM, Gan123 [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



Hi,

   i am new to restlet, started exploring. i found we can
access an
application mapped to ServerServlet in a web application, as well
we can
create a application where we use restlet client to create a
client and use
main to start application.

in the first approach we are using the web server, where as the second
approach we use restlet webcontainer for our application launch.. am i
right?

if not clarify me, as tell me which way is suggested and best

Thanks in advance
--
View this message in context:

http://n2.nabble.com/which-is-better-way-for-web-application-using-RESTlet--tp1498498p1498498.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.






EJB 3

2008-10-18 Thread Jonathan Hall

Hi,

I'm evaluating my current stack and am interested using EJB3. Naturally, 
I still want to use restlet :). If anyone is doing this, I'd be grateful 
if you shared your setup and any issues you've run across.


thanks,
Jon


Re: bad experience with restlets

2008-09-19 Thread Jonathan Hall

Some thoughts on the docs.

The wiki's menu is a mass of expanded links and most are todos with 
noway of knowing, without clicking every single one, that they have content.

It is truly awful to navigate.
Should developer notes really be kept on the wiki? eg 
http://wiki.restlet.org/docs_1.1/g1/43-restlet/124-restlet.html


How about:
Moving the restlet.org documentation to the wiki.
Unpublishing/removing anything that does not have content.
Removing all developer notes.
Make the wiki nav start contracted.
Expand the quickstart (15 mins) tutorials to cover a lot more common 
containers.
Remove the need to register to comment, use a simpler technique to stop 
comment spam (jroller style?)


Jon



Rob Heittman wrote:
But I do think many people will find Restlet more approachable when 
the documentation and examples catch up with the platform and reach a 
certain level of polish.  Especially people coming from the Spring 
universe, which is so rich in these areas.


On Fri, Sep 19, 2008 at 5:19 AM, Jerome Louvel 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


I wish I could have had a look at it earlier, but 3 days to fix it
is not that bad, isn't it? :-)





Re: Guice and 1.1m5

2008-08-14 Thread Jonathan Hall

Maybe down to: Important Context Changes dated 29/07/2008


- the Context instance given to an application (or any Restlet 
actually) will be the one effectively used. If parameters are set, they 
will be directly and permanently accessible. If none is given, a null 
context will be returned by getContext(), no default context will be 
returned anymore.


Tim Peierls wrote:

Chris,

I managed to get some slightly less limited connectivity out here in 
the Maine woods.


When you do discover what changes between m4 and m5 caused 
Context.getContext() to return null in m5, I think it might be a good 
idea to change FinderFactoryModule so that subclasses can override the 
default ProviderRequest, ProviderResponse, and ProviderContext 
definitions.


I won't be back to full connectivity until the 21st, but you could 
make this change in your local code by creating three protected 
methods in FinderFactoryModule and moving the new Provider... code 
in the configure() method to these new methods. I'll give the example 
for Context:


   // in configure()
   bind(Context.class)
.toProvider(newContextProvider());

// new method in FinderFactoryModule
protected ProviderContext newContextProvider() {
return new ProviderContext() {
public Context get() { return Context.getCurrent(); }
});
}

Then whenever you need a non-standard Context provider, you can say:

FinderFactoryModule ffm = new FinderFactoryModule() {
protected ProviderContext newContextProvider() {
return ...; // your non-standard Context provision code here
}
};

This doesn't answer the most important question -- why does 
Context.getContext() return null -- but it might give you a workaround.


--tim


On Wed, Aug 13, 2008 at 4:54 PM, Chris Lee [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Hey guys, I followed Tim Peierls' excellent tutorial on using
Guice in Restlets
(found at
http://tembrel.blogspot.com/2008/07/resource-dependency-injection-in.html)
and
found that, while it works quite well with 1.1m4, it does not work
with 1.1m5.

The error seems to be in the Guice Provider for the Context class;
it relies on
Context.getCurrent() which is returning null when called from
within the custom
Finder. I have downloaded the source for m4 and m5, and am looking
into writing
a patch for Tim's code to let it work with m5, but I am not
optimistic if I
cannot get the current context from within the Finder.

If I get it to work, I will post the results here and on Tim's
blog, but I was
hoping someone here (Tim suggested Jerome) might be able to give
me some advice
on the matter.

Thanks!

Chris Lee






Any OSGi + Restlet examples?

2008-05-20 Thread Jonathan Hall

Can anyone tell me the state of OSGi in Restlet?
I've not used OSGi before but I am interested in having a fiddle. I 
notice 1.1M4 says there is greater support, but I don't have a clue how 
to start. I'd be grateful for any examples, tutorials or a push in the 
right direction.


Jon


Re: Context param with Directory in Spring

2008-03-15 Thread Jonathan Hall

Oh right I didn't realise, I found it after a little bit of hunting:

util:property-path id=appContext path=application.context/ 


cheers,
Jon

Jerome Louvel wrote:

Hi Jonathan,

I think there is a way in Spring to inject a property of a bean
(application.context), but I can't remember how. 


Are there Spring experts reading?

Best regards,
Jerome  

  

-Message d'origine-
De : Jonathan Hall [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 14 mars 2008 21:09

À : discuss@restlet.tigris.org
Objet : Context param with Directory in Spring

Hi,

I'm trying to serve static files using Directory in a Spring 
way, but I have a problem when it comes to the Context param.


In http://restlet.tigris.org/issues/show_bug.cgi?id=334 Jerome wrote:

Directory and other classes needing a Context param in 
constructor should also
accept a parent Restlet as well, directly in the API to 
workaround the inability

of Spring to inject a child property taken from another bean.

This was never implemented, was there another solution found? 
I've tried searching but had no luck.


At the minute I have it working but extending Directory with:

public SpringDirectory( Restlet restlet, String rootUri )
{
super( restlet.getContext(), rootUri );
}

and using the spring config:

bean class=com.blah.SpringDirectory
constructor-arg index=0 ref=application/
constructor-arg index=1 value=clap://thread/static/
/bean

Any help appreciated,

jon






  




Re: Context param with Directory in Spring

2008-03-14 Thread Jonathan Hall

Sorry, I forgot to say I use the maven 1.1 snapshot

Jonathan Hall wrote:

Hi,

I'm trying to serve static files using Directory in a Spring way, but 
I have a problem when it comes to the Context param.


In http://restlet.tigris.org/issues/show_bug.cgi?id=334 Jerome wrote:

Directory and other classes needing a Context param in constructor 
should also
accept a parent Restlet as well, directly in the API to workaround the 
inability

of Spring to inject a child property taken from another bean.

This was never implemented, was there another solution found? I've 
tried searching but had no luck.


At the minute I have it working but extending Directory with:

public SpringDirectory( Restlet restlet, String rootUri )
{
   super( restlet.getContext(), rootUri );
}

and using the spring config:

bean class=com.blah.SpringDirectory
   constructor-arg index=0 ref=application/
   constructor-arg index=1 value=clap://thread/static/
/bean

Any help appreciated,

jon







Re: Request for an Object

2008-03-14 Thread Jonathan Hall

Hi Justin,

If I understand you, you want to return html,text and an object for a 
resource?

Simplest form

public class MyResource extends Resource {
   public MyResource(Context context, Request request, Response response) {
   super(context, request, response);
   getVariants().add(new Variant(MediaType.APPLICATION_JAVA_OBJECT));
getVariants().add(new Variant(MediaType.TEXT_PLAIN));
getVariants().add(new Variant(MediaType.TEXT_HTML));

   }

   @Override
   public Representation getRepresentation(Variant variant) {
   Representation rep = null;
   if (MediaType.TEXT_PLAIN.equals(variant.getMediaType())) {
rep = StringRep...  
   }
   else if (MediaType.TEXT_HTML.equals(variant.getMediaType())) {
rep = Freemarker... 
   }
   else if 
(MediaType.APPLICATION_JAVA_OBJECT.equals(variant.getMediaType())) {
rep = ObjectRepresenation( YOUR_SERIALIZED_OBJECT );
   }
 
 return rep;

   }
}

Your client sending:
Accept: application/x-java-serialized-object

works fine on 1.1 snapshot, sorry I dont have a test setup for 1.0.8.


jon

Dustin N. Jenkins wrote:

Hi all,

This could be a REST understanding problem in general.  I'm using JDK 
1.5.10 with Restlet 1.0.8.


I have a resource that accepts GET requests for a User.  The HTML 
representation will return a FreeMarker page, and the Text version 
will just return a String representation of the User.  Simple and lovely.


I also want to be able to ask for the User object too, and I think 
that the ObjectRepresentation class is used for that.  How do I 
specify that from the Resource though?  I thought of narrowing down 
the ClientInfo's accepted MediaTypes to just 
'x-java-serialized-object' and checking for that in the 
getRepresentation() method of the Resource, but it won't accept 
requests with just that MediaType to choose from.


Any ideas of how to just return the Object?  It seems like just 
another representation, but I don't think I should have to create 
another Resource as it's essentially doing the same thing as the HTML 
and Textual representations are doing.


Thanks,
Dustin







Re: Confused with locale

2008-03-13 Thread Jonathan Hall

Ah that's great Thierry, thanks for responding so timely and informative.

Excellent news that you will be looking into it, good i18n support seems 
to be towards the top of the list for web frameworks.

I'll keep an eye on the RFE.

cheers,
jon

Thierry Boileau wrote:

Hello Jonathan,

thanks for your precisions, we have a better understanding of your need.
The problem is that a variant has been designed to contain the
metadata of one representation. If a variant has a list of Languages,
it means that the representation contains the listed languages not
that the representation may be translated in one of the listed
languages... Thus, in your case, you are still required to define the
exhaustive list of supported variants...
We fully agree that this mechanism must be improved and have created
an RFE (http://restlet.tigris.org/issues/show_bug.cgi?id=462).

best regards,
Thierry Boileau

On Wed, Mar 12, 2008 at 6:54 PM, Jonathan Hall [EMAIL PROTECTED] wrote:
  

Thanks for the reply Thierry.

 Ah I see, you can only have one language per variant.

 I was in a different mindset adding multiple languages per variant.

 So, with one language per variant am I correct in thinking that if I
 wished to support 6 languages and 3 mediatypes (json,xml,html) that I
 would have to add 18 variants?
 If so, this approach does not seem to scale well.

 I initially thought it would work like:
 A match would occur for the mediatype and if the language was in the
 variants language list.
 Then provide a method like getPreferredLanguage().


 Variant variant = new Variant(MediaType.TEXT_PLAIN);
 variant.getLanguages().add(Language.ENGLISH);

variant.getLanguages().add(Language.FRENCH);
 ...
 (or more likely have a single ListLanguage and variant.setLanguages(list))
 getVariants().add(variant);




 if (MediaType.TEXT_PLAIN.equals(variant.getMediaType())) {
  if (Language.FRENCH.equals(variant.getPreferredLanguage())) {

 rep = new StringRepresentation(Je parle français.);
   } else {
   ...
 }

 For my real usage to grab a ResourceBundle, I would just use
 variant.getPreferredLanguage() and push it to the freemarker template.

 What do you think about this approach?

 jon




 Thierry Boileau wrote:
  Hi Jonathan,
 
  I'm not sure to clearly understand what you say.
  The framework actually includes a content negotiation algorithm which
  is in charge to compare the clients preferences (media-type and
  languages only) on one side with the list of supported variants
  declared by the resource on the other side and to determine the
  preferred variant [1]. Once the choice is done, the framework calls
  the Resource#represent(Variant) method (instead of deprecated
  getRepresentation(Variant)...) which is the place where you decide
  to generate the representation according to the variant passed as
  parameter.
  In this case, the variant contains only one Language metadata
  (Language.FRENCH or Language.ENGLISH) which allows to make the tests
  with the contains method.
 
  I hope I answer your question.
 
  best regards,
  Thierry Boileau
 
  [1] see com.noelios.restlet.Engine#getPreferredVariant(ClientInfo,
  ListVariant, Language)
 
 
  On Wed, Mar 12, 2008 at 2:28 PM, Jonathan Hall [EMAIL PROTECTED] wrote:
 
  Hi Thierry,
 
   Say I had the client send multiple languages:
 
Accept-Language: en-gb,fr;q=0.7,en;q=0.3
 
   If using a variant with multiple languages, the code given wouldn't
   satisfy the clients preference, since it is using .contains(...). It
   would return the language depending on the control code.
 
   To return the correct preference, the client language preference/weights
   should be compared to the variants languages and a best match found.
 
   I can't find a method like this, I think it sounds like a useful
   addition to the framework, do you?
 
   (btw I'm testing with 1.1-SNAPSHOT and 1.1-M2)
 
   jon
 
 
 
   Thierry Boileau wrote:
Hello Jon,
   
here is the code of a sample resource declaring 2 variants with the
same media-type and distinct languages.
I've tested it against release 1.1m2.
   
best regards,
Thierry Boileau
   
*
import org.restlet.Context;
import org.restlet.data.Language;
import org.restlet.data.MediaType;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.Representation;
import org.restlet.resource.Resource;
import org.restlet.resource.StringRepresentation;
import org.restlet.resource.Variant;
   
public class MyResource extends Resource {
public MyResource(Context context, Request request, Response 
response) {
super(context, request, response);
// Defines two text_plain variants
Variant variant = new Variant(MediaType.TEXT_PLAIN);
variant.getLanguages().add(Language.ENGLISH);
getVariants().add(variant);
variant = new Variant(MediaType.TEXT_PLAIN

Re: Confused with locale

2008-03-12 Thread Jonathan Hall

Hi Thierry,

Say I had the client send multiple languages:

 Accept-Language: en-gb,fr;q=0.7,en;q=0.3

If using a variant with multiple languages, the code given wouldn't 
satisfy the clients preference, since it is using .contains(...). It 
would return the language depending on the control code.


To return the correct preference, the client language preference/weights 
should be compared to the variants languages and a best match found.


I can't find a method like this, I think it sounds like a useful 
addition to the framework, do you?


(btw I'm testing with 1.1-SNAPSHOT and 1.1-M2)

jon

Thierry Boileau wrote:

Hello Jon,

here is the code of a sample resource declaring 2 variants with the
same media-type and distinct languages.
I've tested it against release 1.1m2.

best regards,
Thierry Boileau

*
import org.restlet.Context;
import org.restlet.data.Language;
import org.restlet.data.MediaType;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.Representation;
import org.restlet.resource.Resource;
import org.restlet.resource.StringRepresentation;
import org.restlet.resource.Variant;

public class MyResource extends Resource {
public MyResource(Context context, Request request, Response response) {
super(context, request, response);
// Defines two text_plain variants
Variant variant = new Variant(MediaType.TEXT_PLAIN);
variant.getLanguages().add(Language.ENGLISH);
getVariants().add(variant);
variant = new Variant(MediaType.TEXT_PLAIN);
variant.getLanguages().add(Language.FRENCH);
getVariants().add(variant);
}

@Override
public Representation getRepresentation(Variant variant) {
Representation rep = null;
if (MediaType.TEXT_PLAIN.equals(variant.getMediaType())) {
if (variant.getLanguages().contains(Language.FRENCH)) {
rep = new StringRepresentation(Je parle français.);
} else {
rep = new StringRepresentation(I speak English.);
}
// Update the representation metadata
rep.setMediaType(variant.getMediaType());
rep.getLanguages().addAll(variant.getLanguages());
}

return rep;
}
}

*


On Tue, Mar 11, 2008 at 7:11 PM, Jonathan Hall [EMAIL PROTECTED] wrote:
  

Hi,

 I've been looking at getting the preferred locale and I have a couple of
 questions.

 I see that getPreferredVariant() uses apaches content negotiation
 algorithm
 (http://httpd.apache.org/docs/2.2/en/content-negotiation.html#algorithm)
 which includes using the Accept-Language header:

 |Accept-Language: en-gb,en;q=0.5

 I'm unsure how (if) this comes into play or how to use it to get the
 preferred language.

 I added Language.FRENCH only to a variant and added it to
 Resource.getVariants() thinking it may use it in content negotiation, it
 seems not.

 If this worked as expected I propose a method like
 Resource.||getPreferredVariant().getPreferredLanguage()|| to get the
 preferred locale.|||
 |
 || If the client's language does not match then 406 or use a default
 language. Make it backwards compatible by only using that algorithm when
 languages are set?

 Any help, thoughts appreciated

 jon

 |||
 ||




  




Re: Confused with locale

2008-03-12 Thread Jonathan Hall

Thanks for the reply Thierry.

Ah I see, you can only have one language per variant.

I was in a different mindset adding multiple languages per variant.

So, with one language per variant am I correct in thinking that if I 
wished to support 6 languages and 3 mediatypes (json,xml,html) that I 
would have to add 18 variants?

If so, this approach does not seem to scale well.

I initially thought it would work like:
A match would occur for the mediatype and if the language was in the 
variants language list.

Then provide a method like getPreferredLanguage().

Variant variant = new Variant(MediaType.TEXT_PLAIN);
variant.getLanguages().add(Language.ENGLISH);
variant.getLanguages().add(Language.FRENCH);
...
(or more likely have a single ListLanguage and variant.setLanguages(list))
getVariants().add(variant);



if (MediaType.TEXT_PLAIN.equals(variant.getMediaType())) {
if (Language.FRENCH.equals(variant.getPreferredLanguage())) {
rep = new StringRepresentation(Je parle français.);
  } else {
  ...
}

For my real usage to grab a ResourceBundle, I would just use 
variant.getPreferredLanguage() and push it to the freemarker template.


What do you think about this approach?

jon


Thierry Boileau wrote:

Hi Jonathan,

I'm not sure to clearly understand what you say.
The framework actually includes a content negotiation algorithm which
is in charge to compare the clients preferences (media-type and
languages only) on one side with the list of supported variants
declared by the resource on the other side and to determine the
preferred variant [1]. Once the choice is done, the framework calls
the Resource#represent(Variant) method (instead of deprecated
getRepresentation(Variant)...) which is the place where you decide
to generate the representation according to the variant passed as
parameter.
In this case, the variant contains only one Language metadata
(Language.FRENCH or Language.ENGLISH) which allows to make the tests
with the contains method.

I hope I answer your question.

best regards,
Thierry Boileau

[1] see com.noelios.restlet.Engine#getPreferredVariant(ClientInfo,
ListVariant, Language)


On Wed, Mar 12, 2008 at 2:28 PM, Jonathan Hall [EMAIL PROTECTED] wrote:
  

Hi Thierry,

 Say I had the client send multiple languages:

  Accept-Language: en-gb,fr;q=0.7,en;q=0.3

 If using a variant with multiple languages, the code given wouldn't
 satisfy the clients preference, since it is using .contains(...). It
 would return the language depending on the control code.

 To return the correct preference, the client language preference/weights
 should be compared to the variants languages and a best match found.

 I can't find a method like this, I think it sounds like a useful
 addition to the framework, do you?

 (btw I'm testing with 1.1-SNAPSHOT and 1.1-M2)

 jon



 Thierry Boileau wrote:
  Hello Jon,
 
  here is the code of a sample resource declaring 2 variants with the
  same media-type and distinct languages.
  I've tested it against release 1.1m2.
 
  best regards,
  Thierry Boileau
 
  *
  import org.restlet.Context;
  import org.restlet.data.Language;
  import org.restlet.data.MediaType;
  import org.restlet.data.Request;
  import org.restlet.data.Response;
  import org.restlet.resource.Representation;
  import org.restlet.resource.Resource;
  import org.restlet.resource.StringRepresentation;
  import org.restlet.resource.Variant;
 
  public class MyResource extends Resource {
  public MyResource(Context context, Request request, Response response) {
  super(context, request, response);
  // Defines two text_plain variants
  Variant variant = new Variant(MediaType.TEXT_PLAIN);
  variant.getLanguages().add(Language.ENGLISH);
  getVariants().add(variant);
  variant = new Variant(MediaType.TEXT_PLAIN);
  variant.getLanguages().add(Language.FRENCH);
  getVariants().add(variant);
  }
 
  @Override
  public Representation getRepresentation(Variant variant) {
  Representation rep = null;
  if (MediaType.TEXT_PLAIN.equals(variant.getMediaType())) {
  if (variant.getLanguages().contains(Language.FRENCH)) {
  rep = new StringRepresentation(Je parle français.);
  } else {
  rep = new StringRepresentation(I speak English.);
  }
  // Update the representation metadata
  rep.setMediaType(variant.getMediaType());
  rep.getLanguages().addAll(variant.getLanguages());
  }
 
  return rep;
  }
  }
 
  *
 
 
  On Tue, Mar 11, 2008 at 7:11 PM, Jonathan Hall [EMAIL PROTECTED] wrote:
 
  Hi,
 
   I've been looking at getting the preferred locale and I have a couple of
   questions.
 
   I see that getPreferredVariant() uses apaches content negotiation
   algorithm
   (http://httpd.apache.org/docs/2.2/en/content-negotiation.html#algorithm)
   which includes using the Accept-Language header

Confused with locale

2008-03-11 Thread Jonathan Hall

Hi,

I've been looking at getting the preferred locale and I have a couple of 
questions.


I see that getPreferredVariant() uses apaches content negotiation 
algorithm 
(http://httpd.apache.org/docs/2.2/en/content-negotiation.html#algorithm) 
which includes using the Accept-Language header:


|Accept-Language: en-gb,en;q=0.5

I'm unsure how (if) this comes into play or how to use it to get the 
preferred language.


I added Language.FRENCH only to a variant and added it to 
Resource.getVariants() thinking it may use it in content negotiation, it 
seems not.


If this worked as expected I propose a method like 
Resource.||getPreferredVariant().getPreferredLanguage()|| to get the 
preferred locale.|||

|
|| If the client's language does not match then 406 or use a default 
language. Make it backwards compatible by only using that algorithm when 
languages are set?


Any help, thoughts appreciated

jon

|||
||


Re: I had finished Using Ajax in Restlet draft,pls review

2008-02-13 Thread Jonathan Hall
Hi,

Some comments.

I wonder how useful it is to just post all of the source code for a
tutorial, I find it hard reading and confusing.
I prefer to have a general overview of what I am going to learn in this
tutorial and then small code snippets with an explanation,
output,config,etc for each step. You have linked the full source zip, so
if needed, people can extract the full source from that.

hope this helps,

Jonathan Hall

cleverpig wrote:
 I post this draft in wiki.restlet.org--Using AJAX in
 Restlet:http://wiki.restlet.org/docs_1.1/g1/43-restlet/52-restlet.html

 I will start this tutorial with a simply example-microblog,that's a
 text based micro blog for demo how to using AJAX in Restlet.
 Demo construction:
 * Web client: call background service via JSON protocol in full
 REST way(GET/PUT/POST/DELETE).
 * Server side: uses db4o to work as store service provider,and
 expose data in RESTful way.
 * Server handle process: Application dispatch request to
 Router,Router find corresponding reource,Resource handle request and
 return representation.

 Pls make review and point out drawback.
   



Re: Bad implementation of Status error checking

2008-01-16 Thread Jonathan Hall

... That, plus what Joshua Tuberville quoted from RFC 2616:

... applications MUST understand the class of any status code, as 
indicated by the first digit, and treat any unrecognized response as 
being equivalent to the x00 status code of that class
Note the use of the word MUST.  Hence, Restlet is NOT in compliance 
with the RFC.  I would consider this a bug.


After reading that bit of the RFC I agree.
isSuccess() should return true for all 2xx. Also, for all other applicables.

Jon


Re: tunnelFilter in tomcat container - how ???

2007-08-24 Thread Jonathan Hall

Hi regis,

Your previous zip looks a bit involved to be honest.

Pull everything out (spring, hibernate, everthing,etc) anything that 
isn't realted to your problem, and build the most simple testcase you can.

I'm really busy at the moment but I'll do my best to try to help :)

Jon


regis regis wrote:

Nobody can help me ? Aith my buggy situation ?

Thanks for any advice Maybe it is not possible to get the form at 
this time in the put method ?





On 8/23/07, *regis regis*  [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:

Nop, it is the same behavior same error !
(but i check another time even i did before).

thanks.

PS; maybe you are right, it is a bug...






Re: Sax Server Examples?

2007-08-24 Thread Jonathan Hall

Hey Justin,

this is pretty much a new api., and as such is growing. I'm really 
enjoying using it. But you need to give people more than six hours to 
answer a question. I do not presume to speak for most, but I feel most 
have working jobs and help purely out of community spirit. If you need a 
professional service then the email [EMAIL PROTECTED] might be of some 
use.



Stanczak Group wrote:
I'm guessing there is no real examples? Or everyone is tired of my 
stupid questions. Either is fine, I'm starting to pick it up. I've 
been running through all the code, which is very little. I feel a 
little stupid that I'm not picking this up easier. I've pretty much 
been through all the code and still have issues. This is by far the 
simplest api I've ever had trouble with. I guess all I was looking for 
in the examples is one using the Sax server then client side. I think 
what I've written so far will work, so I probably don't need an 
example now. My brain my be at a blue screen.


Stanczak Group wrote:

Any Sax server examples? I'm trying it out now. Thanks.





Re: Why use SpringContext?

2007-08-23 Thread Jonathan Hall

org.restlet.ext.spring_2.0 has SpringFinder. So it's a case of :

   bean id=my class=org.restlet.ext.spring.SpringFinder
   lookup-method name=createResource bean=myResource/
   /bean

   bean id=myResource class=com.blah.myResource scope=prototype/

I use restlet via a servlet, I have to jump through some hoops but it 
can mostly be wired via spring.


Jon

Adam Taft wrote:

Kim,

One of the bigger problems you'll have (in my opinion) is 
integration of Restlet's Resource classes within your Spring 
framework.  A Restlet Resource will generally be the class you'll want 
talking to your spring backend (like your spring DAOs, etc.).  
However, the Resource instances are created per request in a stateful 
manner (not stateless like a traditional spring bean).  So, you have 
to play some tricks.


To get around this, you'll need to use a custom Finder class.  Various 
people have contributed different implementations of Finder which 
works with Spring.  I've got one posted in a previous email which 
you're free to use (or I can send it to you).


Jerome has made a lot of changes which will help in configuring 
Spring.  I think most of these changes are in the 1.1 branch, but they 
may be in the main 1.0 branch as well.  Not sure.  But, he's added a 
lot of traditional getter/setter methods (javabean style).  So, that 
helps a lot.  But, you'll still have to deal with Resource instances 
being created per request by the Restlet framework.


Yes, you are right though.  There is no real reason for the 
SpringContext.  You can use your spring configuration file to map your 
urls to the right Restlet (Filter, Router, Finder, etc.).  So, I don't 
think you're missing anything there.


Hope this helps,

Adam



Kim Pepper wrote:
I'm just starting out with the Restlet framework after reading the 
excellent
RESTful Web Services book. I've had a lot of experience with Spring 
MVC and

Hibernate web applications, but it doesn't cut it for RESTful web
applications.

However, I want to reuse the spring managed objects and Data Access 
Objects
from my existing projects. I also want to remove the dependency on 
Servlets

and use the Restlet framework supported by Jetty or AsyncWeb.

I'm confused by the need for the SpringContext? I assume you can just 
create

a
ClassPathXmlApplicationContext passing the applicationContext.xml. 
All you
need is the map of url = SpringFinder beans for each of your 
resources. Am

I missing something?

Also, has anyone tried wiring an entire application with Spring? A few
BeanFactory's here and there would do the trick!

-- Kim





Re: tunnelFilter in tomcat container - how ???

2007-08-23 Thread Jonathan Hall

As a quicky,

Instead of
  Form form = new Form(entity);
What about

  Form form = getRequest().getEntityAsForm();

Just wondering if new Form(entity) is buggy.


regis regis wrote:
I made some new progress, this error error is thrown when the entity 
object is not available
entity.isAvailable() and it is the case when i display this value in 
debug mode.


Also in debug mode the parameter entity in the public void 
post(Representation entity) is not nul. This object is an instance of 
an InputRepresentation instance and the attribute inputstream is null !


I try to give you more clue. i hope it will help.
Bye



On 8/23/07, *regis regis* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Thanks for the reply.

So i never use in my java code the entity (Representation object).
I attach my java code (i use also spring, and a servlet context).

= Could give me more details about in which case to use the
handlePut() and the put(Representation entity) ?

Here my FormResource.java, as you will see in my code, i m just
testing the function.




Re: Vacations

2007-08-22 Thread Jonathan Hall

Congratulations, hope you have a great wedding and honeymoon.

Jerome Louvel wrote:

Dear Restlet community,

I'll be offline until the 11th of September for my wedding and a few weeks
of vacations. 


Happy coding and discussions on Restlet. The perspectives of the project
have never been so promising. Thanks all for your interest, support and
contributions!

Take care,
Jerome

  


Re: Requesting Objects?

2007-08-21 Thread Jonathan Hall

Hi,
try something like:

ClientInfo clientInfo = new ClientInfo();
clientInfo.setAcceptedMediaTypes(new ArrayListPreferenceMediaType().);
clientInfo.getAcceptedMediaTypes().add(new 
PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT));

request.setClientInfo(clientInfo);

jon

Stanczak Group wrote:

Here's the code:

Request request = new Request(Method.GET, 
http://localhost:8182/users/dog;);
   ChallengeResponse authentication = new 
ChallengeResponse(ChallengeScheme.HTTP_BASIC, admin, admin);

   request.setChallengeResponse(authentication);
   Client client = new Client(Protocol.HTTP);
   Response response = client.handle(request);
   String str = (String) response.getEntityAsObject();
   System.out.println(str);

Keeps requesting MediaType.TEXT_PLAIN but I'm trying to get an object. 
I have the server setup to send object.



   if 
(variant.getMediaType().equals(MediaType.APPLICATION_JAVA_OBJECT)) {

   result = new ObjectRepresentation(Testing);
   System.out.println(\nAPPLICATION_JAVA_OBJECT\n);
   }

Where am I going wrong?




Re: Requesting Objects?

2007-08-21 Thread Jonathan Hall

Whoops,

clientInfo.setAcceptedMediaTypes(new ArrayListPreferenceMediaType().);

should be:

clientInfo.setAcceptedMediaTypes(new ArrayListPreferenceMediaType()); 


Jonathan Hall wrote:

Hi,
try something like:

ClientInfo clientInfo = new ClientInfo();
clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType().);
clientInfo.getAcceptedMediaTypes().add(new 
PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT));

request.setClientInfo(clientInfo);

jon

Stanczak Group wrote:

Here's the code:

Request request = new Request(Method.GET, 
http://localhost:8182/users/dog;);
   ChallengeResponse authentication = new 
ChallengeResponse(ChallengeScheme.HTTP_BASIC, admin, admin);

   request.setChallengeResponse(authentication);
   Client client = new Client(Protocol.HTTP);
   Response response = client.handle(request);
   String str = (String) response.getEntityAsObject();
   System.out.println(str);

Keeps requesting MediaType.TEXT_PLAIN but I'm trying to get an 
object. I have the server setup to send object.



   if 
(variant.getMediaType().equals(MediaType.APPLICATION_JAVA_OBJECT)) {

   result = new ObjectRepresentation(Testing);
   System.out.println(\nAPPLICATION_JAVA_OBJECT\n);
   }

Where am I going wrong?







Re: Requesting Objects?

2007-08-21 Thread Jonathan Hall

Ah, I am running from http://www.restlet.org/downloads/archives/1.1/

Jerome wrote:
Now that the 1.0 code base seems to be quite stable it is time to move 
forward. We have just created a maintenance branch for 1.0 in SVN.

From now on, the SVN trunk will be dedicated to the upcoming version 1.1.

Bleeding edge and all that :0)

Stanczak Group wrote:
I don't have a request.setClientInfo() in my request object. Do I have 
an older version? I'm using 1.0.4.


Jonathan Hall wrote:

Whoops,

clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType().);


should be:

clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType());

Jonathan Hall wrote:

Hi,
try something like:

ClientInfo clientInfo = new ClientInfo();
clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType().);
clientInfo.getAcceptedMediaTypes().add(new 
PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT));

request.setClientInfo(clientInfo);

jon

Stanczak Group wrote:

Here's the code:

Request request = new Request(Method.GET, 
http://localhost:8182/users/dog;);
   ChallengeResponse authentication = new 
ChallengeResponse(ChallengeScheme.HTTP_BASIC, admin, admin);

   request.setChallengeResponse(authentication);
   Client client = new Client(Protocol.HTTP);
   Response response = client.handle(request);
   String str = (String) response.getEntityAsObject();
   System.out.println(str);

Keeps requesting MediaType.TEXT_PLAIN but I'm trying to get an 
object. I have the server setup to send object.



   if 
(variant.getMediaType().equals(MediaType.APPLICATION_JAVA_OBJECT)) {

   result = new ObjectRepresentation(Testing);
   System.out.println(\nAPPLICATION_JAVA_OBJECT\n);
   }

Where am I going wrong?











Re: Requesting Objects?

2007-08-21 Thread Jonathan Hall
request.getClientInfo().getAcceptedMediaTypes().add(new 
PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT));


I only used the new ClientInfo() before in order to make sure it was the 
only MediaType.


If you still have a problem try seeing what other mediatypes are in the 
request.getClientInfo().getAcceptedMediaTypes() are set and remove 
them accordingly.




Stanczak Group wrote:

So how do I use 1.0 to get objects?

Jonathan Hall wrote:

Ah, I am running from http://www.restlet.org/downloads/archives/1.1/

Jerome wrote:
Now that the 1.0 code base seems to be quite stable it is time to 
move forward. We have just created a maintenance branch for 1.0 in SVN.
From now on, the SVN trunk will be dedicated to the upcoming version 
1.1.


Bleeding edge and all that :0)

Stanczak Group wrote:
I don't have a request.setClientInfo() in my request object. Do I 
have an older version? I'm using 1.0.4.


Jonathan Hall wrote:

Whoops,

clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType().);


should be:

clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType());

Jonathan Hall wrote:

Hi,
try something like:

ClientInfo clientInfo = new ClientInfo();
clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType().);
clientInfo.getAcceptedMediaTypes().add(new 
PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT));

request.setClientInfo(clientInfo);

jon

Stanczak Group wrote:

Here's the code:

Request request = new Request(Method.GET, 
http://localhost:8182/users/dog;);
   ChallengeResponse authentication = new 
ChallengeResponse(ChallengeScheme.HTTP_BASIC, admin, admin);

   request.setChallengeResponse(authentication);
   Client client = new Client(Protocol.HTTP);
   Response response = client.handle(request);
   String str = (String) response.getEntityAsObject();
   System.out.println(str);

Keeps requesting MediaType.TEXT_PLAIN but I'm trying to get an 
object. I have the server setup to send object.



   if 
(variant.getMediaType().equals(MediaType.APPLICATION_JAVA_OBJECT)) {

   result = new ObjectRepresentation(Testing);
   System.out.println(\nAPPLICATION_JAVA_OBJECT\n);
   }

Where am I going wrong?















Re: Requesting Objects?

2007-08-21 Thread Jonathan Hall

Hard to say without knowing what you are doing :)

Using ObjectRepresentation for a String is strange if that is your 
usecase as it is meant for a serializable Java object.
If you are just wanting to pass plain text then you should use the 
following:


if (variant.getMediaType().equals(MediaType.TEXT_PLAIN)) {
  result = new StringRepresentation(Testing);
  }


Stanczak Group wrote:

Should I even be using object?

Stanczak Group wrote:

So how do I use 1.0 to get objects?

Jonathan Hall wrote:

Ah, I am running from http://www.restlet.org/downloads/archives/1.1/

Jerome wrote:
Now that the 1.0 code base seems to be quite stable it is time to 
move forward. We have just created a maintenance branch for 1.0 in SVN.
From now on, the SVN trunk will be dedicated to the upcoming version 
1.1.


Bleeding edge and all that :0)

Stanczak Group wrote:
I don't have a request.setClientInfo() in my request object. Do I 
have an older version? I'm using 1.0.4.


Jonathan Hall wrote:

Whoops,

clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType().);


should be:

clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType());

Jonathan Hall wrote:

Hi,
try something like:

ClientInfo clientInfo = new ClientInfo();
clientInfo.setAcceptedMediaTypes(new 
ArrayListPreferenceMediaType().);
clientInfo.getAcceptedMediaTypes().add(new 
PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT));

request.setClientInfo(clientInfo);

jon

Stanczak Group wrote:

Here's the code:

Request request = new Request(Method.GET, 
http://localhost:8182/users/dog;);
   ChallengeResponse authentication = new 
ChallengeResponse(ChallengeScheme.HTTP_BASIC, admin, admin);

   request.setChallengeResponse(authentication);
   Client client = new Client(Protocol.HTTP);
   Response response = client.handle(request);
   String str = (String) response.getEntityAsObject();
   System.out.println(str);

Keeps requesting MediaType.TEXT_PLAIN but I'm trying to get an 
object. I have the server setup to send object.



   if 
(variant.getMediaType().equals(MediaType.APPLICATION_JAVA_OBJECT)) 
{

   result = new ObjectRepresentation(Testing);
   System.out.println(\nAPPLICATION_JAVA_OBJECT\n);
   }

Where am I going wrong?

















Re: JSP to generate Representation

2007-07-20 Thread Jonathan Hall

Niice :)

I'd be interested in using this.

Jonathan Hall


Michael Terrington wrote:

Hi Leigh,

I've ported facelets to run without JSF and integrated with Restlet 
for generating representations.  JSTL core is supported by that so it 
may deliver what you want.


Take a look at http://trac.sarugo.org/xtc and if you are interested 
drop me an e-mail as the published binary lacks the Restlet 
integration and building might be a bit hairy as yet.  Proper public 
release coming soon!


Regards,
Michael.

Klotz, Leigh wrote:

Has anybody done an integration with JSP 2.x (JSPX) to generate
representations, as has been done for Velocity and Freemarker?
Thanks,
Leigh.




Re: Easy Spring Integration with Restlet

2007-07-19 Thread Jonathan Hall
I use spring aop and cglib and it works well for me. I do appreciate 
problems with cglib and proxys however.


I also use my own version of SpringRouter to map uri and resources and 
to filter them with globally before and after filter lists. I also 
have filters set on my individual resources. I find it works well and 
that spring extensions do satisfy my needs (even though they need some 
tweaking).


Best regaards,

Jonathan Hall

Valdis Rigdon wrote:

Adam Taft wrote:


Ultimately, no matter how we get there, Resource needs to be a 
stateless in order to work well with Ioc.
Having used Spring and Restlet together on my current project I 
disagree.   I can't speak for other IoC frameworks, but Spring 
provides multiple way to inject other beans into stateful (or 
prototype) beans.   I like the fact that Resources are not singletons 
and I don't have to pass along Request, Resource, etc. to every method 
that may or may not need them.  For those that have used Struts, I 
can't count how many times I've seen non-thread safe code in Struts 
Actions.  It's just a bug waiting to happen.


To retrieve new instances of classes with injected resources define 
your bean with 'scope=prototype' in your Spring configuration and 
then use one of the following:


1.  Use @Configurable and AspectJ (see Chapter 6 of the Spring 
documentation)
2.  Use Spring AOP and cglib extensions via lookup-method (see 
SpringFinder)

3.  Call  ApplicationContext.getBean(beanId)

I'm currently using option 1 with compile-time weaving under Maven2 
and it's works great.


In addition, Jerome's suggestion of a SpringRouter makes perfect 
sense.  I've implemented something similar but it's an extension to 
Application.  It's a simple bean with (1) a Map for URI to Resource 
classes, (2) a Map for URI to Restlet instances and (3) a Map for URI 
to guarded Resources.  One can also set the default Resource as well 
as provide the Guard to use for the guarded resources.   We've also 
added an ApplicationContextAwareFinder which allows Resource classes 
to implement ApplicationContextAware and have a handle to the 
ApplicationContext if needed.  I could clean it up a bit and share it 
if anyone is interested.




Valdis








URI matching again

2007-06-08 Thread Jonathan Hall

Hi,

Is it possible to do this:

/user
/user/{id}
/user/list

The problem comes from the app thinking list is just a {id}  variable.  
I thought router.setRoutingMode(Router.FIRST) sounded like it would pick 
the route I wished by the order they were attached.

In which case this would work:

/user
/user/list
/user/{id}

However, it seems to not work like that.  No matter what order I attach 
the routes they seem to end up in the same order in a RouteList. I also 
need to have optional parameters attached to all of the urls.



Any ideas?

Best Regards,

Jon



Re: PUT example?

2007-05-10 Thread Jonathan Hall

Chris Battey wrote:

Is there anything in the NRE reference implementation (or anywhere else) with an
example of using the put() method on a Resource?  Using a Finder to find a
Resource and call handleGet() on it was pretty straightforward, but the put()
case seems more complex, and I couldn't find anywhere that the NRE uses that 
method.


Thanks,
Chris


  

Hi Chris,

For a Resource I would use the following if you can as it is cleaner and 
keeps the handleGet code to sort some stuff out for you

@Override
   public Representation getRepresentation(Variant variant) {}

Anyway, for put:

   @Override
   public boolean allowPut() {
   return true;
   }

 @Override
   public void put(Representation entity) { }

Jonathan Hall


HttpRequest not retreiving a custom entity

2007-05-07 Thread Jonathan Hall

Hi,

I have a usecase  where I want to replace the entity in a request. 
However this does not work due to the following:


com.noelios.restlet.http.HttpRequest

   public Representation getEntity() {
   if (!this.entityAdded) {
   setEntity(((HttpServerCall) getHttpCall()).getRequestEntity());
   this.entityAdded = true;
   }

   return super.getEntity();
   }

Is it possible to modify the code or allow an accessor for entityAdded.

Cheers,

Jonathan Hall



Re: HttpRequest not retreiving a custom entity

2007-05-07 Thread Jonathan Hall

Thanks Jerome,  prompt as always :)


Jerome Louvel wrote:

Hi Jonathan,

Good point. Instead of exposing the internal entityAdded member variable,
I have overloaded the HttpRequest.setEntity() method to set entityAdded to
true.

Checked in SVN trunk and branches/1.0.

Best regards,
Jerome  

  

-Message d'origine-
De : Jonathan Hall [mailto:[EMAIL PROTECTED] 
Envoyé : lundi 7 mai 2007 08:41

À : discuss@restlet.tigris.org
Objet : HttpRequest not retreiving a custom entity

Hi,

I have a usecase  where I want to replace the entity in a request. 
However this does not work due to the following:


 com.noelios.restlet.http.HttpRequest

public Representation getEntity() {
if (!this.entityAdded) {
setEntity(((HttpServerCall) 
getHttpCall()).getRequestEntity());

this.entityAdded = true;
}

return super.getEntity();
}

Is it possible to modify the code or allow an accessor for 
entityAdded.


Cheers,

Jonathan Hall




  


Re: StackOverflowError

2007-03-09 Thread Jonathan Hall

Hi Piyush,

Seems a sneaky start() in the handle method of the demo at 
http://www.restlet.org/downloads/restlet-1.0rc1.zip was the critter. 
Running very nice now :)


Best Regards,
Jonathan


Piyush Purang wrote:

Perhaps this helps?

http://63.246.22.60/browse/CONF-7573



On 3/8/07, *Jonathan Hall*  [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Hi,

Just before I start to debug. Has anyone load tested an
application yet?
I'm getting StackOverflowError on 1.0rc5:
Happens after about 1k requests on 1.6.

SEVERE: Unhandled exception or error intercepted
java.lang.StackOverflowError
at sun.util.calendar.ZoneInfo.getOffsets (ZoneInfo.java:215)
at
java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2024)
at
java.util.GregorianCalendar.computeFields(GregorianCalendar.java:1996)
at java.util.Calendar.setTimeInMillis (Calendar.java:1104)
at java.util.Calendar.setTime(Calendar.java:1070)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:859)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:852)
at java.text.DateFormat.format(DateFormat.java:276)
at java.text.Format.format(Format.java:140)
at java.text.MessageFormat.subformat(MessageFormat.java:1288)
at java.text.MessageFormat.format(MessageFormat.java :795)
at
java.util.logging.SimpleFormatter.format(SimpleFormatter.java:50)
at java.util.logging.StreamHandler.publish(StreamHandler.java:179)
at
java.util.logging.ConsoleHandler.publish(ConsoleHandler.java :88)
at java.util.logging.Logger.log(Logger.java:472)
at java.util.logging.Logger.doLog(Logger.java:494)
at java.util.logging.Logger.log(Logger.java:583)
at com.noelios.restlet.StatusFilter.doHandle
(StatusFilter.java:89)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle (Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle(Filter.java:105)
at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87)
at org.restlet.Filter.handle (Filter.java:134)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java :134)
at org.restlet.Filter.doHandle(Filter.java:105)
...
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java :134)
at org.restlet.Filter.doHandle(Filter.java:105)
at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle (Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle(Filter.java :105)
at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Filter.doHandle(Filter.java:105)
08-Mar-2007 17:47:49 com.noelios.restlet.LogFilter afterHandle

Cheers,

Jonathan




Re: New Restlet web site

2007-03-09 Thread Jonathan Hall

Hi Jerome and Thierry,

Well done it looks great!

Some comments :-)

How about a subnav for About and Documentation.
Link to an old release archive directory for Downloads.
Reuse/add more graphics; everyone loves eye candy.
Comparisons with alternative RESTful Web Service frameworks. CXF, axis2
Under DocumentationLearnExamples link to the wiki examples
Demo app to run stats on, for the blog wars. (joke)

(Tables for layout are naughty mmkay)

Congrats,

Jonathan Hall



Jerome Louvel wrote:

Hi again,

Thierry Boileau and I are very happy to roll out a fully redesigned web
site. We looking forward to hearing your comments and improving it before
publicly launching our final 1.0 release!

http://www.restlet.org

Best regards,
Jerome

  


StackOverflowError

2007-03-08 Thread Jonathan Hall

Hi,

Just before I start to debug. Has anyone load tested an application yet? 
I'm getting StackOverflowError on 1.0rc5:

Happens after about 1k requests on 1.6.

SEVERE: Unhandled exception or error intercepted
java.lang.StackOverflowError
   at sun.util.calendar.ZoneInfo.getOffsets(ZoneInfo.java:215)
   at 
java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2024)
   at 
java.util.GregorianCalendar.computeFields(GregorianCalendar.java:1996)

   at java.util.Calendar.setTimeInMillis(Calendar.java:1104)
   at java.util.Calendar.setTime(Calendar.java:1070)
   at java.text.SimpleDateFormat.format(SimpleDateFormat.java:859)
   at java.text.SimpleDateFormat.format(SimpleDateFormat.java:852)
   at java.text.DateFormat.format(DateFormat.java:276)
   at java.text.Format.format(Format.java:140)
   at java.text.MessageFormat.subformat(MessageFormat.java:1288)
   at java.text.MessageFormat.format(MessageFormat.java:795)
   at java.util.logging.SimpleFormatter.format(SimpleFormatter.java:50)
   at java.util.logging.StreamHandler.publish(StreamHandler.java:179)
   at java.util.logging.ConsoleHandler.publish(ConsoleHandler.java:88)
   at java.util.logging.Logger.log(Logger.java:472)
   at java.util.logging.Logger.doLog(Logger.java:494)
   at java.util.logging.Logger.log(Logger.java:583)
   at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:89)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
...
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
   at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87)
   at org.restlet.Filter.handle(Filter.java:134)
   at org.restlet.Filter.doHandle(Filter.java:105)
08-Mar-2007 17:47:49 com.noelios.restlet.LogFilter afterHandle

Cheers,

Jonathan


Re: Servlet Context

2007-03-07 Thread Jonathan Hall

Hey Jerome,

I did have a look at the org.restlet.ext.spring.SpringContext class. It 
seems it requires:


SpringContext springContext = new SpringContext(getContext());
springContext.getXmlConfigRefs().add(RESOURCES);

Which would be the same inconvenience of hard coding the resource 
locations.


With having access to the Servlet Context, you can then access the 
Spring Context by:


web.xml

   listener
   
listener-classorg.springframework.web.context.ContextLoaderListener/listener-class

   /listener
   context-param
   param-namecontextConfigLocation/param-name
   param-value
   /WEB-INF/resources.xml
   /param-value
   /context-param

and the previous code.

This seems to be a popular way to load Spring Contexts. Just a thought.

Cheers,
Jonathan Hall




Jerome Louvel wrote:

Hi Jonathan,

For this use case, couldn't you leverage the SpringContext class in the
org.restlet.ext.spring extension?

Best regards,
Jerome  

  

-Message d'origine-
De : Jonathan Hall [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 6 mars 2007 22:27

À : discuss@restlet.tigris.org
Objet : Re: Servlet Context

Hi Jerome,

Thankyou for responding.

The use case I had in mind was for creating a springContext without 
hardcoding the configuration xml locations:


WebApplicationContext springContext = 
WebApplicationContextUtils.getWebApplicationContext(getServlet

Context());

This requires a ServletContext and I couldn't find another way to 
access/cast it.
I haven't looked into it, so I shouldn't really comment if other IoC 
frameworks use this or not.


If you don't believe this should be added, it is fair enough. It is 
trivial to extend ServerServlet myself and use that. I just 
thought it 
might be useful to have.


Best Regards,
Jonathan



Jerome Louvel wrote:


Hi Jonathan,

When using the ServerServlet, the Restlet's context already 
  

wraps the

Servlet's context (logging, resource loading, parameters, 
  

etc.). Why would


you need a direct access to the Servlet context?

Best regards,
Jerome  

  
  

-Message d'origine-
De : Jonathan Hall [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 6 mars 2007 20:27

À : discuss@restlet.tigris.org
Objet : Servlet Context

Hi,

I was wondering if a way to access the ServletContext could 
be added to 
the code. This would be useful for Spring and I presume other IoC 
frameworks.
It would not tie Restlet to any other libraries or harm it as 
far as I 
can see.


As per shloks example, it would require changes to 
com.noelios.restlet.ext.servlet.ServerServlet and 
org.restlet.Application


com.noelios.restlet.ext.servlet.ServerServlet 


public Application createApplication(Context context) {
...

if (application != null)
application.setServletContext(getServletContext());

}


org.restlet.Application.java

private ServletContext servletContext = null;

public ServletContext getServletContext() {
return servletContext;
}

public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}

Please let me know what you think,

Best Regards,
Jonathan



  
  


  


Servlet Context

2007-03-06 Thread Jonathan Hall

Hi,

I was wondering if a way to access the ServletContext could be added to 
the code. This would be useful for Spring and I presume other IoC 
frameworks.
It would not tie Restlet to any other libraries or harm it as far as I 
can see.


As per shloks example, it would require changes to 
com.noelios.restlet.ext.servlet.ServerServlet and org.restlet.Application


com.noelios.restlet.ext.servlet.ServerServlet 


   public Application createApplication(Context context) {
...

   if (application != null)
   application.setServletContext(getServletContext());

}


org.restlet.Application.java

   private ServletContext servletContext = null;

   public ServletContext getServletContext() {
   return servletContext;
   }

   public void setServletContext(ServletContext servletContext) {
   this.servletContext = servletContext;
   }

Please let me know what you think,

Best Regards,
Jonathan



Filter chaining

2007-03-05 Thread Jonathan Hall

Hi,

What is the solution for filtering particularly when using Spring and 
still using the Restlet approach? After looking at the API and examples, 
I can't seem to find one.

At the minute, it seems it relies on setting setNext, which is not ideal.

  !-- Maps the URI (entry key) to Resources finder --
   bean id=manager class=com.restlet.RestManager
   property name=resourceMappings
   bean class=java.util.HashMap
   constructor-arg
   map
   entry key=/user/{user}
   ref local=userSpringFinder/
   /entry
   /map
   /constructor-arg
   /bean
   /property
   /bean

The entry key would have to point to the topmost Filter bean and not the 
Resource/Finder/Restlet. That bean would then have to point setNext to 
the next filter bean, and so on until the Resource is passed. This would 
mean I would need a unique chain of Filter beans for every Resource.


Have I missed the solution for this (It is Monday morning here :) )?


Re: Filter chaining

2007-03-05 Thread Jonathan Hall

Thanks Jerome,

Doh! It looks like I did get the Monday morning brain deadness. I 
misunderstood the way the filters worked.


Thanks for clearing that up,

Jon

Jerome Louvel wrote:

Hi Jonathan,

Instead of having a unique chain of Filters for each Resource, can't you
create one chain only? You could attach your Router to your last Filter in
the chain, then normally attach the Resources to the Router.

Best regards,
Jerome  

  

-Message d'origine-
De : Jonathan Hall [mailto:[EMAIL PROTECTED] 
Envoyé : lundi 5 mars 2007 11:38

À : discuss@restlet.tigris.org
Objet : Filter chaining

Hi,

What is the solution for filtering particularly when using Spring and 
still using the Restlet approach? After looking at the API 
and examples, 
I can't seem to find one.
At the minute, it seems it relies on setting setNext, which 
is not ideal.


   !-- Maps the URI (entry key) to Resources finder --
bean id=manager class=com.restlet.RestManager
property name=resourceMappings
bean class=java.util.HashMap
constructor-arg
map
entry key=/user/{user}
ref local=userSpringFinder/
/entry
/map
/constructor-arg
/bean
/property
/bean

The entry key would have to point to the topmost Filter bean 
and not the 
Resource/Finder/Restlet. That bean would then have to point 
setNext to 
the next filter bean, and so on until the Resource is passed. 
This would 
mean I would need a unique chain of Filter beans for every Resource.


Have I missed the solution for this (It is Monday morning here :) )?



  


Re: Spring context and Resource

2007-02-26 Thread Jonathan Hall

Here is how I am currently implementing it. It's pretty much a slight
modification of the other wiki examples.
It's just a quick example, it won't compile.

(link due to no attachments) http://www.crysop.co.uk/restlet-spring.zip

Hope it helps,

Jonathan


in your  Resource file:

@Override
   public void init(Context context, Request request, Response 
response) {

   super.init(context, request, response);
 ...
 }

If you mean in the Finder:

   @Override
   public Resource createResource(Request request, Response response) {
   Resource result = createResource();

   if (result != null) {
   result.init(getContext(), request, response);
   }

   return result;
   }

The new org.restlet.ext.spring.SpringFinder class has this all setup 
for you.


Jonathan

Makunas, Michael wrote:

Hi-

Been lurking for a while but this is my first post so forgive my 
newbieness


With solution 2, how do you call the init() method on the resource in 
such a way that it is aware of the restlet context?


Cheers,
Michael

-Original Message-
From: Jerome Louvel [mailto:[EMAIL PROTECTED] Sent: 26 February 
2007 09:28

To: discuss@restlet.tigris.org
Subject: RE: Spring context and Resource


Hi all,

Thanks for the discussion. I've added a SpringFinder class into the 
Spring

extension package with the
Javadocs based on solution 2.

Best regards,
Jerome 
 

-Message d'origine-
De : Jonathan Hall [mailto:[EMAIL PROTECTED] Envoyé : samedi 24 
février 2007 16:10

À : discuss@restlet.tigris.org
Objet : Re: Spring context and Resource

Thankyou Valdis, I went with option 2 which works great.

Jonathan


Valdis Rigdon wrote:
   

I've found 2 approaches that work, and there are possibly more.

1.  Use @Configurable on your Resource classes, and use   
Spring AOP to
inject dependencies.  Search the message archives for more   
details on

this.

2.  If you don't like having the dependency on AspectJ, you   
can extend
org.restlet.Finder and override createResource(Request,   
Response) to
delegate to a no-arg createResource() method (but be sure to call 
init() on it after it's created).  Then create a singleton   
Spring bean
based on that Finder,  and configure it using lookup-method to 
return instances of a prototype bean for   
createResource().  Finally,
attach the Finder to your Router.  When the   
createResource() method is
invoked, a new instance of your prototype bean will be created and 
returned.



A sample xml for lookup-method:

bean id=myRestlet class=com.mycompany.rest.SpringFinder
   lookup-method name=createResource bean=myResource/
/bean
bean id=myResource   
class=com.mycompany.rest.resource.MyResource

scope=prototype
   property name=aProperty value=anotherOne/
   property name=oneMore value=true/
/bean


Perhaps org.restlet.Finder could be reworked so this worked   
out of the

box, instead of having to have a custom Finder object.


Valdis


Jonathan Hall wrote:
 

Hi,

Following the wiki examples, I integrated Spring and 

Restlet by using an
   
extended Restlet bean and handle(Request request, Response 

response).
   
However, it seems I would want to extend Resource instead, 

as it has all
   
the gubbins for get/post/put/etc. The problem is the 

router accepts a
   
class and not an object; so I can't use Spring to inject 

other beans
   

into my extended class.

The following options occur to me:
modify Router to accept instances,
recreate the spring context on every call in the Resource,
stash the springcontext in the restlet context.

Have I missed something that would solve this problem, or 

misunderstood
   
the framework? If not, then would it be possible to add 

something to
   

help with this in future releases?

Thanks for all the great work, I'm enjoying learning this 

framework.
   

Best Regards,
Jonathan