Re: Different @Post: xml, json and java String
that works, I did not think about it, even if it's in the book :) but is not documented in the API. What if the parameter is a Map or a generic POJO? On Wed, Mar 23, 2011 at 12:07 AM, Fabian Mandelbaum wrote: > Hello Daniele, > > @Post("txt") > > should accept strings. Test it though ;-) > > On Tue, Mar 22, 2011 at 1:07 PM, Daniele Dellafiore > wrote: > > Hi. > > > > I built a server resource with a > > > >@Post > >public void request(final String email) { } > > > > that works great with the restlet client. With a real form I have two > > options: json/xml, say json, or post parameters. > > > > Json, I just add > > > >@Post("json") > >public void xml(final Representation representation) { ...} > > > > in which parse the email from the json and call the request(String email) > so > > I do not duplicate code. > > There is a problem here: the application/json post does not end in the > > @Post("json"), everything falls in the first @Post. > > If I remove the annotation from the first method, everything works. > > > > There is a notation to say to the first method he is waiting for a String > > class? > > > > Thanks. > > -- > > Daniele Dellafiore > > http://danieledellafiore.net > > > > > > -- > Fabián Mandelbaum > IS Engineer > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713282 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713287
GET returns wrong representation
Hi, I'm developing a restlet application and I have a ServerResource with only one Get: @GET("xml") public DomRepresentation responseToXML(){} The GET works, I receive the xml document. However, when I set the Accept Header to anything different, The ServerResource still sends me the xml. Here's an example: curl -H "Accept: application/json" "http://site/users/2"; then I receive the xml, but I should have received nothing or a 404 error. Am I missing something here? Is there a way to restrict the response if the Accept Header sent by the client is not available in the ServerResource? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713325
Setting timeout on built-in client connector of 2.0
Hi all, I’ve been digging through the docs but I can’t figure this out. I’m trying to set the timeout used by an instance of ClientResource. I figured I could do that by setting a parameter of the ClientResource’s Context before making any requests. However, I can’t seem to identify any parameter which would set the timeout for the built-in client connector, even when using the Client class directly. I’d appreciate any pointers on this! Thanks, Avi Avi Flax » Partner » Arc90 » http://arc90.com Readability » Enjoy Reading, Support Writing » http://readability.com Kindling » Innovation through Collaboration » http://kindlingapp.com -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713284
Re: Different @Post: xml, json and java String
Hello Daniele, @Post("txt") should accept strings. Test it though ;-) On Tue, Mar 22, 2011 at 1:07 PM, Daniele Dellafiore wrote: > Hi. > > I built a server resource with a > > @Post > public void request(final String email) { } > > that works great with the restlet client. With a real form I have two > options: json/xml, say json, or post parameters. > > Json, I just add > > @Post("json") > public void xml(final Representation representation) { ...} > > in which parse the email from the json and call the request(String email) so > I do not duplicate code. > There is a problem here: the application/json post does not end in the > @Post("json"), everything falls in the first @Post. > If I remove the annotation from the first method, everything works. > > There is a notation to say to the first method he is waiting for a String > class? > > Thanks. > -- > Daniele Dellafiore > http://danieledellafiore.net > -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713282
Re: Re: HTTPS Server set up error at runtime
I don't know about explicit jars needed to support HTTPS (or SSL). In the libs/readme.txt file of the Restlet distribution you can find the dependencies list for all the distributed jars, plus the following statement at the beginning of that file: "Below is a list of the dependencies between Restlet libraries. You need to ensure that all the dependencies of the libraries that you are using are on the classpath of your Restlet program, otherwise ClassNotFound exceptions will be thrown." Hope this helps, good luck On Tue, Mar 22, 2011 at 2:52 PM, Jason Richards wrote: > Thanks for the response. I am trying to implement the jetty server now but I > am running into another problem. When I try to run the main class that > implements the server I get the following two errors: > > INFO: Unable to register the helper org.restlet.ext.jetty.AjpServerHelper > > INFO: Unable to register the helper org.restlet.ext.jetty.HttpServerHelper > > > It says that both of them are caused by a class not found error, specifically > this: > > Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.Server > > I have attempted to add the org.restlet.ext.jetty.jar to my build path in > eclipse by adding the before mentioned .jar to my project then referencing it > in my configuration build libraries. > > I am I missing something else? > > Here is the code I am actually trying to run: > > > package com.it447.capstone; > > import org.restlet.Component; > import org.restlet.Server; > import org.restlet.data.Parameter; > import org.restlet.data.Protocol; > import org.restlet.util.Series; > > > > > public class HTTPSServer { > > public static void main(String[] args) throws Exception { > Component component = new Component(); > > Server server = component.getServers().add(Protocol.HTTPS, 8183); > Series parameters = server.getContext().getParameters(); > parameters.add("keystorePath", "C:/Program > Files/Java/jre6/lib/security/cacerts/BoomStart.jks"); > parameters.add("keystorePassword", "changeit"); > parameters.add("keyPassword", "audrey06"); > parameters.add("keystoreType", "JKS"); > // Attach the application. > component.getDefaultHost().attach("/Request", new RequestRouter()); > component.start(); > } > > } > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713235 > -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713272
RE: Re: HTTPS Server set up error at runtime
Thierry: Could you (or anyone on this thread) be more explicit about which jar to add to support HTTPS? Even a specific class name would let me look it up in jarvana.com, for example. "HTTPS Connector" is way too overloaded a word for most people to be able to find the relevant class or jar. There's simply no way I'm going to find it w/o the deeper knowledge of what is needed, that you already have. (And Murphy is clearly listening... I went to the jetty site to scan thru their javadoc in the hope of recognizing a connector class... only to find that their javadoc is all 404! Argh.) Thanks! -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713248
ClientInfo.getUpstreamAddress on Google App Engine
I’m running Restlet 2.0.4 on Google App Engine, behind a Squid reverse proxy. Although Squid correctly sets the “X-Forwarded-For“ HTTP header, getRequest().getClientInfo().getUpstreamAddress() returns the proxy’s address as opposed to the user-agent’s forwarded address. Documentation says I should set a “useForwardedForHeader” to true in order to activate this feature. But how exactly do I set it when running on App Engine? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713243
RE: Re: HTTPS Server set up error at runtime
Thanks for the response. I am trying to implement the jetty server now but I am running into another problem. When I try to run the main class that implements the server I get the following two errors: INFO: Unable to register the helper org.restlet.ext.jetty.AjpServerHelper INFO: Unable to register the helper org.restlet.ext.jetty.HttpServerHelper It says that both of them are caused by a class not found error, specifically this: Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.Server I have attempted to add the org.restlet.ext.jetty.jar to my build path in eclipse by adding the before mentioned .jar to my project then referencing it in my configuration build libraries. I am I missing something else? Here is the code I am actually trying to run: package com.it447.capstone; import org.restlet.Component; import org.restlet.Server; import org.restlet.data.Parameter; import org.restlet.data.Protocol; import org.restlet.util.Series; public class HTTPSServer { public static void main(String[] args) throws Exception { Component component = new Component(); Server server = component.getServers().add(Protocol.HTTPS, 8183); Series parameters = server.getContext().getParameters(); parameters.add("keystorePath", "C:/Program Files/Java/jre6/lib/security/cacerts/BoomStart.jks"); parameters.add("keystorePassword", "changeit"); parameters.add("keyPassword", "audrey06"); parameters.add("keystoreType", "JKS"); // Attach the application. component.getDefaultHost().attach("/Request", new RequestRouter()); component.start(); } } -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713235
Different @Post: xml, json and java String
Hi. I built a server resource with a @Post public void request(final String email) { } that works great with the restlet client. With a real form I have two options: json/xml, say json, or post parameters. Json, I just add @Post("json") public void xml(final Representation representation) { ...} in which parse the email from the json and call the request(String email) so I do not duplicate code. There is a problem here: the application/json post does not end in the @Post("json"), everything falls in the first @Post. If I remove the annotation from the first method, everything works. There is a notation to say to the first method he is waiting for a String class? Thanks. -- Daniele Dellafiore http://danieledellafiore.net -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713196
RE: Restlet Resource with mixed Media Type
Hello Vanessa, as the tag of the template file have been swallowed, I don't clearly see what happens. I understand that you design a resource that represents a video and is able to generate an HTML representation to the client browser. In this web page there is a reference to a video. I guess the server application lacks the way to serve this static file. I suggest you define a Directory Restlet in order to solve all these static files: public class TestApplication extends Application{ @Override public synchronized Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/test", test.class); Directory directory = new Directory(getContext(), "file:///user/data/files/"); router.attach("/static/", directory); return router; } } Having said that, you can also make the Test Resource able to generate two representations of its state : the HTML one, and the video one by using several Get annotations: @Get("video") public File getVideo(){ [...] } @Get public Representation toHtml(){ // As done already } But this solution requires a little bit more explanations. I cannot answer this right now, but will try to find time tomorrow. Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713175
Re: Problem Restlet with GAE
Hello Charles, I think your project is missing the core module of the GWT *edition* (and not the GWT *extension*, that you can find in the GAE *edition*...). You can find more detailled explanations in this post: http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2710080 Best regards, Thierry Boileau I have a problem with Restlet and GAE. I am working with Windows Seven Pro > and Eclipse. I strictly followed this page to setup my project using GWT, > RESTLET and GAE. > > http://wiki.restlet.org/docs_2.0/13-restlet/275-restlet/144-restlet/186-restlet.html > > I wrote this line in my Project.gwt.xml : > > > And I added restlet library (org.restlet.jar from GAE library) to my > buildpath > > When I compile my application (Google-GWT compile), I have this error : > Loading inherited module 'org.restlet.Restlet' > [ERROR] Unable to find 'org/restlet/Restlet.gwt.xml' on your classpath; > could be a typo, or maybe you forgot to include a classpath entry for > source? > [ERROR] Line 14: Unexpected exception while processing element 'inherits' > > Best regards > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2712921 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713167
Re: HTTPS Server set up error at runtime
Hello Jason, your question is related to the usage of the server connectors. You can have a look here for more details about this topics. http://wiki.restlet.org/docs_2.0/13-restlet/37-restlet.html Having said that, as the internal server connector does not implement yet the HTTPS protocol (Jérôme is coping with this topic, in the 2.1 trunk), you can add any other one that support it such as jetty, simple. Best regards, Thierry Boileau > This may have already been covered in another topic. I looked but couldn't > find it. If it has been covered, forgive me for asking again. > > I am trying to set up HTTPS. When I run the test server in eclipse I get > this error: > > Mar 21, 2011 10:54:32 PM org.restlet.engine.Engine createHelper > WARNING: No available server connector supports the required protocols: > 'HTTPS' . Please add the JAR of a matching connector to your classpath. > > I am not sure what else to add to the class path as I have already added > the: > org.restlet.ext.ssl.jar > org.jssutils.jar > org.restlet.jar > > > I am I missing any other jar that I need to have this run? How I added them > was to go into the build path in Eclipse and add them. Is this the right way > to do it? > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713058 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713165
Re: Support for the HTTP PATCH method
Hello Andreas, the framework does not support it yet, you can have a look here: http://restlet.tigris.org/issues/show_bug.cgi?id=625 Best regards, Thierry Boileau Does Restlet support the HTTP PATCH method (defined in RFC5789)? > > Andy > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713155 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713163
Support for the HTTP PATCH method
Does Restlet support the HTTP PATCH method (defined in RFC5789)? Andy -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713155
Restlet Resource with mixed Media Type
Hi, I'm trying to implement a Restlet resource that should display different media type, for example: text and video, text and image, image and video. In particular, the example that I consider aims to show a video and its textual description, I prepared a Freemarker Template for Html Representation, the code is as follows: TEMPLATE FTL Video Preview.avi Texual Description of video Preview.avi When I call the Restlet resource from the browser a failure occurs; the resource displays only the box corresponding to the video, the text "connecting to server localhost: 8182" and after a few seconds, the player stops without playing the video. The path of the video included in the code is correct, we also tried to change the Representation type replacing "text_html" with "Multipart_all" or "Video_avi" but no change occurs. Previously I specified in the template also the path of the player to use but I did't have a different result. The video plays correctly if, instead of accessing the Restlet resource, I open the ftl template with a standard browser. Below is also the Restlet application code that uses the video. package test; import org.restlet.resource.*; import freemarker.template.Configuration; import org.restlet.data.MediaType; import org.restlet.ext.freemarker.TemplateRepresentation; import org.restlet.representation.Representation; public class Test extends ServerResource{ private static final String HTML_TEMPLATE_FILE = "test.ftl"; private String htmlRepresentationTemplate; protected void doInit() throws ResourceException { super.doInit(); setHtmlRepresentationTemplate(HTML_TEMPLATE_FILE); } @Override public Representation get(){ Configuration c = new Configuration(); TemplateRepresentation t = new TemplateRepresentation(HTML_TEMPLATE_FILE, c, MediaType.TEXT_HTML); return t; } protected void setHtmlRepresentationTemplate( String htmlRepresentationTemplate) { this.htmlRepresentationTemplate = htmlRepresentationTemplate; } protected String getHtmlRepresentationTemplate() { return this.htmlRepresentationTemplate; } } TEST APPLICATION package test; import org.restlet.Application; import org.restlet.Restlet; import org.restlet.routing.Router; public class TestApplication extends Application{ @Override public synchronized Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/test", test.class); router.attach("/test/Preview.avi", test.class); return router; } } MAIN CLASS package test; import org.restlet.Component; import org.restlet.data.Protocol; public class MainClass { public static void main(String[] args) throws Exception { // Create a new Component. Component component = new Component(); // Add a new HTTP server listening on port 8182. component.getServers().add(Protocol.HTTP, 8182); // Attach the sample application. TestApplication t = new TestApplication(); component.getDefaultHost().attach("/testApplication", t); // Start the component. component.start(); } } Could you suggest me a solution to this error? Should I use particular libraries to play videos? -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Restlet-Resource-with-mixed-Media-Type-tp6195924p6195924.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2713136