[GroovyRestlet] GroovyRestlet is hosted as a Groovy Module
GroovyRestlet is a simple and ease of use Groovy DSL for constructing Restlet application. Main features of GroovyRestlet: * Simple Groovy DSL syntax and shortcuts for easily constructing Restlet application * Better integration with Spring framework A simple example of GroovyRestlet DSL: builder.component{ current.servers.add(protocol.HTTP, 8182) application(uri:){ router{ def guard = guard(uri:/docs, scheme:challengeScheme.HTTP_BASIC, realm:Restlet Tutorials) guard.secrets.put(scott, tiger.toCharArray()) guard.next = directory(root:, autoAttach:false) restlet(uri:/users/{user}, handle:{req,resp- resp.setEntity(Account of user \${req.attributes.get('user')}\, mediaType.TEXT_PLAIN) }) restlet(uri:/users/{user}/orders, handle:{req, resp- resp.setEntity(Orders or user \${req.attributes.get('user')}\, mediaType.TEXT_PLAIN) }) restlet(uri:/users/{user}/orders/{order}, handle:{req, resp- def attrs = req.attributes def message = Order \${attrs.get('order')}\ for User \${attrs.get('user')}\ resp.setEntity(message, mediaType.TEXT_PLAIN) }) } } }.start() The detail introduction and examples of GroovyRestlet can be found here: http://docs.codehaus.org/display/GROOVY/GroovyRestlet GroovyRestlet 0.1-SNAPSHOT can be downloaded here: http://svn.codehaus.org/groovy-contrib/groovyrestlet/download/groovy-restlet-0.1-SNAPSHOT.jar Thanks for Guillaume Laforge and Jerome Louvel's help and suggestion, GroovyRestlet is hosted by Groovy as a contribution. Cheers, Keke - We paranoid love life
Re: servlet mapping question
Hello all, some words to complete Stephan's answer. Let's say that the name of the WAR file is myWar. 1- Let's say that the RestletServlet is configured like this : url-pattern/testServlet/*/url-pattern and the application as follow: router.attach(/testResource,HelloWorldResource.class); then, the resource'URI is something like this: http://localhost/myWar/testServlet/testResource 1- Let's say that the RestletServlet is configured like this : url-pattern/*/url-pattern and the application as follow: router.attach(/testResource,HelloWorldResource.class); then, the resource'URI is something like this: http://localhost/myWar/testResource best regards, Thierry Boileau On Thu, Feb 28, 2008 at 11:21 PM, Stephan Koops [EMAIL PROTECTED] wrote: Helo TA, try to request /testServlet/testServlet/*, because you give the testServlet double: one times in the web.xml and one times while attaching to the router. I think, you should remove the testServlet from the attach method. best regards Stephan TA schrieb: New user and I'm playing around with the firstStepsApplication using it in a tomcat web container. I'm trying to play with the routing. Instead of Router router = new Router(getContext()); router.attachDefault(HelloWorldResource.class); I'm trying to do router.attach(/testServlet,HelloWorldResource.class); and correspondingly, I've changed the entry in web.xml from servlet-mapping servlet-nameRestletServlet/servlet-name url-pattern/*/url-pattern /servlet-mapping to url-pattern/testServlet/*/url-pattern and I can't get it to work, keep getting 404 error. I don't want to default route to the app for all URIs in the url mapping, just ones that start with /testServlet Appreciate any help. Ted
Re: Ran into difficulty getting servlet connector working.
Hello Eben, here is a new snapshot: http://www.restlet.org/downloads/archives/1.1/restlet-1.1snapshot.zip Could you make tests and keep us informed? best regards, Thierry Boileau On Fri, Feb 29, 2008 at 2:43 AM, Rob Heittman [EMAIL PROTECTED] wrote: I believe this was a bug in ServerServlet in the 1.1M1 snapshot that has since been corrected. I usually work out of trunk and it doesn't affect me any more. This thread describes it and has a patch: http://www.mail-archive.com/discuss@restlet.tigris.org/msg03451.html There should be a new milestone snapshot imminently. I am still investigating this on my own and just thought I would see if someone else had run into this problem and already had an answer to it.
RE: riap: isConfidential()?
Hi Rob, I fully agree and fixed this in SVN trunk! Best regards, Jerome -Message d'origine- De : Rob Heittman [mailto:[EMAIL PROTECTED] Envoyé : vendredi 29 février 2008 02:30 À : discuss@restlet.tigris.org Objet : riap: isConfidential()? Interesting question came up in one of our implementations today. We check isConfidential() in a Filter and redirect people to https in certain circumstances where the response should not be transmitted in the clear. Some requests are transported over the riap: pseudoprotocol. It seems to me isConfidential() should return true for riap: requests, since the internal requests are not transmitted in the clear. Thoughts? - R
RE: [GroovyRestlet] GroovyRestlet is hosted as a Groovy Module
Hi Keke, Thanks again for your contribution! This is a nice illustration of the interest of Groovy for DSLs and an opportunity for Groovy users to leverage the Restlet project for their RESTful Web applications (http://www.restlet.org). Best regards, Jerome PS: I have also relayed the news on my blog: http://blog.noelios.com/2008/02/29/groovy-dsl-available-for-restlet/ -Message d'origine- De : keke [mailto:[EMAIL PROTECTED] Envoyé : vendredi 29 février 2008 09:03 À : discuss@restlet.tigris.org; [EMAIL PROTECTED] Objet : [GroovyRestlet] GroovyRestlet is hosted as a Groovy Module GroovyRestlet is a simple and ease of use Groovy DSL for constructing Restlet application. Main features of GroovyRestlet: * Simple Groovy DSL syntax and shortcuts for easily constructing Restlet application * Better integration with Spring framework A simple example of GroovyRestlet DSL: builder.component{ current.servers.add(protocol.HTTP, 8182) application(uri:){ router{ def guard = guard(uri:/docs, scheme:challengeScheme.HTTP_BASIC, realm:Restlet Tutorials) guard.secrets.put(scott, tiger.toCharArray()) guard.next = directory(root:, autoAttach:false) restlet(uri:/users/{user}, handle:{req,resp- resp.setEntity(Account of user \${req.attributes.get('user')}\, mediaType.TEXT_PLAIN) }) restlet(uri:/users/{user}/orders, handle:{req, resp- resp.setEntity(Orders or user \${req.attributes.get('user')}\, mediaType.TEXT_PLAIN) }) restlet(uri:/users/{user}/orders/{order}, handle:{req, resp- def attrs = req.attributes def message = Order \${attrs.get('order')}\ for User \${attrs.get('user')}\ resp.setEntity(message, mediaType.TEXT_PLAIN) }) } } }.start() The detail introduction and examples of GroovyRestlet can be found here: http://docs.codehaus.org/display/GROOVY/GroovyRestlet GroovyRestlet 0.1-SNAPSHOT can be downloaded here: http://svn.codehaus.org/groovy-contrib/groovyrestlet/download/ groovy-restlet-0.1-SNAPSHOT.jar Thanks for Guillaume Laforge and Jerome Louvel's help and suggestion, GroovyRestlet is hosted by Groovy as a contribution. Cheers, Keke - We paranoid love life
RE: First steps with Restlets in Equinox OSGi
Hi Frank, I'm not sure either how to achieve this, normally you would specify a context-param on your ServerServlet. Can't you specify that in OSGi Servlet service? Otherwise, you might want to check this upcoming presentation on Restlet at EclipseCon: RESTful OSGI Web Applications Tutorial http://www.eclipsecon.org/2008/index.php?page=sub/id=462 If Khawaja Shams or Jeff Norris are following this list, they might be able to help you. Best regards, Jerome -Message d'origine- De : news [mailto:[EMAIL PROTECTED] De la part de Frank Gerhardt Envoyé : jeudi 28 février 2008 23:47 À : discuss@restlet.tigris.org Objet : First steps with Restlets in Equinox OSGi Hi, the Restlet jars are nicely bundled as bundles ;-) but I could not find a way to run the first steps example without deploying a webapp. I'm looking for a pure OSGi+servlets, no webapp, solution. Equinox provides an extension point where I can register the ServerServlet. But Equinox does not have an extension point for an application. What do I do with the FirstStepsApplication so that the initialization code gets executed? Frank.
Re: riap: isConfidential()?
Awesome, thanks, Jerome! On Fri, Feb 29, 2008 at 6:06 AM, Jerome Louvel [EMAIL PROTECTED] wrote: Hi Rob, I fully agree and fixed this in SVN trunk!
RE: Restlet and Velocity template location.
Hello, Thanks Vincent,that's pretty way for restlet-1.1snapshot.I used this way in restlet or resource: TemplateRepresentation templateRepr= new TemplateRepresentation( /people.vm, MediaType.TEXT_HTML); ... templateRepr.setDataModel(dataModel); templateRepr.getEngine().setProperty( VelocityEngine.FILE_RESOURCE_LOADER_PATH, E:/eclipse3.1RC3/workspace/RestletPractice/templates ); response.setEntity(templateRepr); I have a lot of problem about it: 1.How to use the relative path to set file resource loader path property of velocity engine?It must to fullfill all of path? You might be interested in this RFEs: Accept Velocity templates as representations http://restlet.tigris.org/issues/show_bug.cgi?id=268 Support template inclusion for Freemarker and Velocity http://restlet.tigris.org/issues/show_bug.cgi?id=269 2.How to set once when a Velocitytemplate is initialized,without set again when you use this template? http://restlet.tigris.org/issues/show_bug.cgi?id=268 Maybe you could configure the Velocity engine in your Application constructor instead of each time the TemplateRepresentation class is used? Best regards, Jerome
Restlet 1.0.8 released
Hi all, A new maintenance release of Restlet 1.0 is available. It fixes several bugs (ServerServlet adapter, Spring XML loading issue and more) and updates FreeMarker o version 2.3.12. Thanks to all the reporters and contributors! Changes log: http://www.restlet.org/documentation/1.0/changes Download links: http://www.restlet.org/downloads/1.0/restlet-1.0.8.zip http://www.restlet.org/downloads/1.0/restlet-1.0.8.exe Maven repositories: http://maven.restlet.org will be updated on 02/01 http://maven.noelios.com has the new artifacts Best regards, Jerome Louvel Thierry Boileau
Re: re servlet mapping question
Hello Ted, some words to complete Stephan's answer. Let's say that the name of the WAR file is myWar. 1- Let's say that the RestletServlet is configured like this : url-pattern/testServlet/*/url-pattern and the application as follow: router.attach(/testResource,HelloWorldResource.class); then, the resource'URI is something like this: http://localhost/myWar/testServlet/testResource 1- Let's say that the RestletServlet is configured like this : url-pattern/*/url-pattern and the application as follow: router.attach(/testResource,HelloWorldResource.class); then, the resource'URI is something like this: http://localhost/myWar/testResource best regards, Thierry Boileau On Fri, Feb 29, 2008 at 4:27 PM, TA [EMAIL PROTECTED] wrote: Apologies for starting a new post on an existing thread but everytime I try and follow up I get a top posting error. Here is the thread on the issue Rhett, Thanks for the reply. I tried mapping to something specific and it still does not work, 404 error. I set up a route like so router.attach(/testServlet/dog,HelloWorldResource.class); and set up a mapping in the web.xml like so servlet-mapping servlet-nameRestletServlet/servlet-name url-pattern/testServlet/dog/url-pattern /servlet-mapping I tried the URLs /testServlet/dog and also /testServlet/testServlet/dog and no luck. The only way it appears to work is if attachDefault is used with a url-pattern of /* Does anyone have an example of a route and url-pattern that they know works on their setup? Ted Hi Ted, What Stephan was pointing out is that that _won't_ happen because the container will continue to route requests to the other servlets -- even if your restlet servlet wanted to handle the other requests, it won't ever see them. I'm not sure, but if I had to guess I'd suggest that your problem is that your servlet was mapped to /testServlet/* and you were trying to request /testServlet. The containers I've used (okay, just Tomcat) are very literal minded. Try requesting /testServlet/ or /testServlet/ somethingElse. Rhett Helo TA, try to request /testServlet/testServlet/*, because you give the testServlet double: one times in the web.xml and one times while attaching to the router. I think, you should remove the testServlet from the attach method. best regards Stephan New user and I'm playing around with the firstStepsApplication using it in a tomcat web container. I'm trying to play with the routing. Instead of Router router = new Router(getContext()); router.attachDefault(HelloWorldResource.class); I'm trying to do router.attach(/testServlet,HelloWorldResource.class); and correspondingly, I've changed the entry in web.xml from servlet-mapping servlet-nameRestletServlet/servlet-name url-pattern/*/url-pattern /servlet-mapping to url-pattern/testServlet/*/url-pattern and I can't get it to work, keep getting 404 error. I don't want to default route to the app for all URIs in the url mapping, just ones that start with /testServlet Appreciate any help. Ted
There's a bug with follow ups on this site
I try and do a follow up and keep getting blocked because the site thinks I 'm doing top posting. The way I got around it was to take the follow up and remove all characters from the message chain and that seemed to work.
RE: Re: re servlet mapping question
Ted, You do not want to duplicate the servlet mappings with Router URL attachments, as that will only work with double URLs. So in your example your URL would have to be: http://localhost/testServlet/dog/testServlet/dog This is assuming that you are installing your webapp under /ROOT (for Tomcat) or /root (for jetty) There is a level of routing that happens in the servlet container outside of the Restlet engine, and it is determined by either the name of the WAR file or directory in the /webapps directory (again, assuming Tomcat/Jetty). For instance, if your directory structure looks like this: /ServletContainer /webapps /testServlet ... Files for webapp Then your url, with this given web.xml, should REALLY be: http://localhost/testServlet/testServlet/dog/testServlet/dog Because the first /testServlet tells the servlet container to route it to the /testServlet webapp in the /webapps directory. The next /testServlet/dog is your mapping within the web.xml file. The last /testServlet/dog is the Router attachment. A more appropriate mapping would be this: !-- Catch all requests -- servlet-mapping servlet-nameRestletServlet/servlet-name url-pattern/*/url-pattern /servlet-mapping Then you would be able to get to your page using: http://localhost/testServlet/testServlet/dog But, if you just want dog, then you should attach the Router like this: router.attach(/dog,HelloWorldResource.class); Then you could go to: http://localhost/testServlet/dog Again, this is because the servlet container will do an initial routing of the context name based on the webapps you have installed. The Restlet engine works within this context, so Router does not use the initial context (which is testServlet) to map its URLs. As for worries about other servlets, because the Servlet container is routing initially based on context, all other webapps will take precedence. But, this is only a consideration if you install your servlet into the ROOT context. However, the servlet container will still look for installed contexts first before routing the request to the ROOT context. Hope that helps. Also, you may want to check to see if you are getting into the Restlet engine itself. Are you getting a 404 error from your servlet engine, or from the Restlet engine. They will produce different looking pages (unless you are using IE7, in which case the page will be hidden and you will see a generic 404 error displayed by IE itself). Mitch -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of TA Sent: Friday, February 29, 2008 10:28 AM To: discuss@restlet.tigris.org Subject: Re: re servlet mapping question Apologies for starting a new post on an existing thread but everytime I try and follow up I get a top posting error. Here is the thread on the issue Rhett, Thanks for the reply. I tried mapping to something specific and it still does not work, 404 error. I set up a route like so router.attach(/testServlet/dog,HelloWorldResource.class); and set up a mapping in the web.xml like so servlet-mapping servlet-nameRestletServlet/servlet-name url-pattern/testServlet/dog/url-pattern /servlet-mapping I tried the URLs /testServlet/dog and also /testServlet/testServlet/dog and no luck. The only way it appears to work is if attachDefault is used with a url-pattern of /* Does anyone have an example of a route and url-pattern that they know works on their setup? Ted Hi Ted, What Stephan was pointing out is that that _won't_ happen because the container will continue to route requests to the other servlets -- even if your restlet servlet wanted to handle the other requests, it won't ever see them. I'm not sure, but if I had to guess I'd suggest that your problem is that your servlet was mapped to /testServlet/* and you were trying to request /testServlet. The containers I've used (okay, just Tomcat) are very literal minded. Try requesting /testServlet/ or /testServlet/ somethingElse. Rhett Helo TA, try to request /testServlet/testServlet/*, because you give the testServlet double: one times in the web.xml and one times while attaching to the router. I think, you should remove the testServlet from the attach method. best regards Stephan New user and I'm playing around with the firstStepsApplication using it in a tomcat web container. I'm trying to play with the routing. Instead of Router router = new Router(getContext()); router.attachDefault(HelloWorldResource.class); I'm trying to do router.attach(/testServlet,HelloWorldResource.class); and correspondingly, I've changed the entry in web.xml from servlet-mapping servlet-nameRestletServlet/servlet-name url-pattern/*/url-pattern /servlet-mapping to url-pattern/testServlet/*/url-pattern and I can't get it to work, keep getting
RE: riap: isConfidential()?
That is fair, I've updated the official record :) It will appear on the next Web site update and release. Best regards, Jerome -Message d'origine- De : Rob Heittman [mailto:[EMAIL PROTECTED] Envoyé : vendredi 29 février 2008 19:07 À : discuss@restlet.tigris.org Objet : Re: riap: isConfidential()? To get it on the official record, Carl Scott gets credit for this suggestion :-) On Fri, Feb 29, 2008 at 7:15 AM, Rob Heittman [EMAIL PROTECTED] wrote: Awesome, thanks, Jerome!
RE: There's a bug with follow ups on this site
Hi there, That is weird, GMane works fine for me. Which email client are you using? Best regards, Jerome -Message d'origine- De : news [mailto:[EMAIL PROTECTED] De la part de TA Envoyé : vendredi 29 février 2008 16:30 À : discuss@restlet.tigris.org Objet : There's a bug with follow ups on this site I try and do a follow up and keep getting blocked because the site thinks I 'm doing top posting. The way I got around it was to take the follow up and remove all characters from the message chain and that seemed to work.
Re: Ran into difficulty getting servlet connector working.
Hello Thierry, Tests passed. Servlet connector working perfectly with 1.1m2 release. Thank you for releasing this! -Eben On Fri, Feb 29, 2008 at 2:44 AM, Thierry Boileau [EMAIL PROTECTED] wrote: Hello Eben, here is a new snapshot: http://www.restlet.org/downloads/archives/1.1/restlet-1.1snapshot.zip Could you make tests and keep us informed? best regards, Thierry Boileau
Problems extracting a POST request's entity
Hi all, I'm developing a web-based middleware (the software of my PhD) and I'm trying to use RESTLET. I create a server (and a client) and some restlets to implement the execution dynamics of my software. I'm using XML for the representation of the resources (using JAXB). Well, I tried to implement a GET method and it works, it returns a response with a XML entity on it. But now I'm programming a POST method and I have a problem. I create a request with a XML string as an entity and it seems to be ok (I'm using a StringRepresentation) for this purpose. The code that I use is one of the following: Representation rep = new StringRepresentation(xmlString, MediaType.TEXT_XML); I debug the request and it seems to be well formed. But, when I try to get back the XML string on the handlePost method, I allways obtain a null value. How could I extract the XML String from a request's entity??? (i try to do it using an InputStreamReader but the result is the same) I would appreciate some help regarding this, it takes me two days!! :-) P.D.- Please forgive my poor english :-) -- Sergio Saugar García Área de Ciencias de la Computación e Inteligencia Artificial Departamento de Ciencias de la Computación Edificio Departamental II - Despacho 053 Escuela Técnica Superior de Ingeniería Informática Universidad Rey Juan Carlos Móstoles (MADRID) Clave PGP: http://pgp.rediris.es:11371/pks/lookup?op=getsearch=0xADFA3433 signature.asc Description: OpenPGP digital signature
RE: Problems extracting a POST request's entity
If you read the stream from the representation, or call getText(), then the stream will be consumed and there will be no more data to read. This is also true if you debug a POST on the server side, and call getText(). Your debugger will consume the stream and no more data will be available to the handlePost() method. Only grab the data from the Representation once. If you need to debug, then read it into a temporary variable prior to parsing it, then you can inspect the temp variable without losing the data. Mitch -Original Message- From: Sergio Saugar [mailto:[EMAIL PROTECTED] Sent: Friday, February 29, 2008 2:30 PM To: discuss@restlet.tigris.org Subject: Problems extracting a POST request's entity Hi all, I'm developing a web-based middleware (the software of my PhD) and I'm trying to use RESTLET. I create a server (and a client) and some restlets to implement the execution dynamics of my software. I'm using XML for the representation of the resources (using JAXB). Well, I tried to implement a GET method and it works, it returns a response with a XML entity on it. But now I'm programming a POST method and I have a problem. I create a request with a XML string as an entity and it seems to be ok (I'm using a StringRepresentation) for this purpose. The code that I use is one of the following: Representation rep = new StringRepresentation(xmlString, MediaType.TEXT_XML); I debug the request and it seems to be well formed. But, when I try to get back the XML string on the handlePost method, I allways obtain a null value. How could I extract the XML String from a request's entity??? (i try to do it using an InputStreamReader but the result is the same) I would appreciate some help regarding this, it takes me two days!! :-) P.D.- Please forgive my poor english :-) -- Sergio Saugar García Área de Ciencias de la Computación e Inteligencia Artificial Departamento de Ciencias de la Computación Edificio Departamental II - Despacho 053 Escuela Técnica Superior de Ingeniería Informática Universidad Rey Juan Carlos Móstoles (MADRID) Clave PGP: http://pgp.rediris.es:11371/pks/lookup?op=getsearch=0xADFA3433