RE: Re: Resource paths with Restlet and Jax Rs

2010-10-08 Thread webpost
Thanks a lot for you help,

I guess I found a solution that works at least for me now. I took your jax-rs 
extension sample that was provided with the Restlet download to see the figure 
it out - thanks for the hint.

The @Context UriInfo does not work for parameter that are send within the HTTP 
body. So UriInfo can only be uses with a parameter list within a url (GET 
requests). For the other methods that use the HTTP body you have to use the 
MulitvalueMap in the method definition. Within this mulitvaluemap you can find 
all the parameter. Using uriInfo.getQueryParameter works only for Get requests. 

But using the MultivalueMap requires to set the content-type of the client 
request to application/x-www-form-urlencoded (at least for the ruby client I 
used, a HTTP form worked without this) Using other content types like 
application/json, text/plain... doesn't work for me. I got a 415 always, 
don't know why. Any idea?

Another thing is, when the MultivalueMap is defined in the method definition 
the request must contain any parameter data otherwise it will cash because of 
no http form data. 


So a small example how I made it running:

...
@Context UriInfo uriInfo;
@HeaderParam(Accept)  String requestedMimeType;

@javax.ws.rs.GET
@Path({blogId})
public Response getBlog(@PathParam(blogId) java.lang.Integer blogId) {
  return getResourceHandler().getBlog(new 
BlogGetParameter(uriInfo.getQueryParameters(false), blogId), requestedMimeType, 
uriInfo);
}

@javax.ws.rs.DELETE
@Path({blogId})
public Response deleteBlog(@PathParam(blogId) java.lang.Integer blogId) {
  return getResourceHandler().deleteBlog(new BlogDeleteParameter(blogId), 
requestedMimeType, uriInfo);
}

@javax.ws.rs.POST
public Response createBlog(MultivaluedMapString, String params) {
  return getResourceHandler().createBlog(new BlogCreateParameter(params), 
requestedMimeType, uriInfo);
}
...

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


RE: Re: Resource paths with Restlet and Jax Rs

2010-10-05 Thread webpost
Hi Stephan,

I guess you meant with parameter a @QueryParam annotated variable? I tried so 
and added something like this:

public String createBlog(@DefaultValue(me) @QueryParam(alias) String alias) 
{...}

But I still get the same error 405. Funnily enough the first post request is 
successful but the parameters I send with are just ignored and the alias 
variable is set to the default value. Sending the POST request a second time or 
more often I get the 405. 

The reason might be that the parameters are not parsed correctly. I followed 
you hint and debugged everything. And I guess there is something wrong within 
the Restlet/Jax-R. The parameter I send with my request are just put in front 
of HTTP method. So the resource cannot be found. With the following link you 
can see a screenshot from the debugger window. The highlighted line might be a 
bug in the framework?! http://matthias.wilkau-hasslau.net/restlet_post.png So 
you can see that the parameter m with its value blogId is set in front of 
the POST. Is this supposed to be like that?

Can you reproduce it or do you have a running version of a Restlet application 
with Jax-Rs resources that you could send me? So, if the mistake is on my side 
I could figure it out by my own?

Thanks a lot for the support.

Matthias

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


Re: Resource paths with Restlet and Jax Rs

2010-10-04 Thread Stephan Koops
Hi Matthias,

 I guess you meant with parameter a @QueryParam annotated variable? I tried 
 so and added something like this:

 public String createBlog(@DefaultValue(me) @QueryParam(alias) String 
 alias) {...}
No, not @QueryParam. Query parameter are detected from the URL.
A possibility is @FormParam.
 The reason might be that the parameters are not parsed correctly. I followed 
 you hint and debugged everything. And I guess there is something wrong within 
 the Restlet/Jax-R. The parameter I send with my request are just put in front 
 of HTTP method. So the resource cannot be found. With the following link you 
 can see a screenshot from the debugger window. The highlighted line might be 
 a bug in the framework?! http://matthias.wilkau-hasslau.net/restlet_post.png 
 So you can see that the parameter m with its value blogId is set in front 
 of the POST. Is this supposed to be like that?
Yes, you are right, that looks not good. What are the data sou send?
 Can you reproduce it or do you have a running version of a Restlet 
 application with Jax-Rs resources that you could send me? So, if the mistake 
 is on my side I could figure it out by my own?
Sorry, not here. Take a look into the project org.restlet.test, package 
org.restlet.test.jaxrs.resources . There are a lot of example resources. 
Their should also be one with post.

Good luck
Stephan

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


RE: Re: Resource paths with Restlet and Jax Rs

2010-10-01 Thread webpost
Hi Stephan,

sorry for bothering you that often but I just do not get it running. I just 
will exlain my problem a bit more in detail. While sending GET request 
everything concerning a simple GET request works. But sending a request with 
any other method I always get the 405 status code, even I do just  a normal 
POST request with a normal POST parameter. Let me explain it with a small 
example.

My Jax-Rs resource looks like:
...
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.UriInfo;

@Path(blogs)
public class BlogResource extends {
  ...
  @POST
  public String createBlog(@Context UriInfo info) {

return {\result\:\ok\}
  }
  ...
}


My HTML file looks like:

htmlheadtitleREST Web test client/title/head
body
form name=restrequest action=http://localhost:8182/blogs/blogs; 
target=right method=POST
input type=text value=me name=tags
input type=submit value=Submit /
/form
/body
/html

So it should call the POST method with a POST parameter tags=me. But the server 
just returns a 405. And when I enable the method tunneling the server logs just 
that POST is called with a POST parameter method=DELETE but that the POST 
request is not allowed and returns a 405.

To sum it up, I am not able to process a POST request either with nor without a 
parameter. Do I have to allow POST somehow?

 Hi Matthias,
  as I read parts of your master thesis I found the extension issue and that 
  it was done on purpose. So I could have found it by my own. Sorry for 
  bothering you with this.
  But I got another issue, sending parameter with a POST request. When I send 
  parameter with a POST request I just get an 405 - Method not allowed. I 
  searched the internet and found that you have to enable the different 
  methods woth allowPost(). But to do so you have to use Restlet resources 
  from the Restlet version 1.1. But I don't use Restlet 1.1 (did not found 
  such a method for 2.1) and I don't have use Restlet resources at all.
 
  Do I have to enable the POST methods somehow? (sending a POST request 
  without POST parameter works)
 In the JAX-RS extension not.
 allowPost() is for pure Restlet 1.x.
 
 Do you have the problems with post, if you add parameters for the tunnel 
 filter? Maybe the tunnel filter only works on GET requests.
 
 best regards
 Stephan

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


Re: Resource paths with Restlet and Jax Rs

2010-10-01 Thread Stephan Koops
Hi Matthias,

Maybe the reason is, that their is no parameter in createBlog() to put 
the data in.

Do you stepped thru the code with the debugger? Start at 
JaxRsApplication.handleRequest(..)

best regards
 Stephan

Am 01.10.2010 15:13, schrieb webp...@tigris.org:
 Hi Stephan,

 sorry for bothering you that often but I just do not get it running. I just 
 will exlain my problem a bit more in detail. While sending GET request 
 everything concerning a simple GET request works. But sending a request with 
 any other method I always get the 405 status code, even I do just  a normal 
 POST request with a normal POST parameter. Let me explain it with a small 
 example.

 My Jax-Rs resource looks like:
 ...
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.UriInfo;

 @Path(blogs)
 public class BlogResource extends {
...
@POST
public String createBlog(@Context UriInfo info) {
  
  return {\result\:\ok\}
}
...
 }


 My HTML file looks like:

 htmlheadtitleREST Web test client/title/head
  body
  form name=restrequest action=http://localhost:8182/blogs/blogs; 
 target=right method=POST
  input type=text value=me name=tags
  input type=submit value=Submit /
  /form
  /body
 /html

 So it should call the POST method with a POST parameter tags=me. But the 
 server just returns a 405. And when I enable the method tunneling the server 
 logs just that POST is called with a POST parameter method=DELETE but that 
 the POST request is not allowed and returns a 405.

 To sum it up, I am not able to process a POST request either with nor without 
 a parameter. Do I have to allow POST somehow?

 Hi Matthias,
 as I read parts of your master thesis I found the extension issue and that 
 it was done on purpose. So I could have found it by my own. Sorry for 
 bothering you with this.
 But I got another issue, sending parameter with a POST request. When I send 
 parameter with a POST request I just get an 405 - Method not allowed. I 
 searched the internet and found that you have to enable the different 
 methods woth allowPost(). But to do so you have to use Restlet resources 
 from the Restlet version 1.1. But I don't use Restlet 1.1 (did not found 
 such a method for 2.1) and I don't have use Restlet resources at all.

 Do I have to enable the POST methods somehow? (sending a POST request 
 without POST parameter works)
 In the JAX-RS extension not.
 allowPost() is for pure Restlet 1.x.

 Do you have the problems with post, if you add parameters for the tunnel
 filter? Maybe the tunnel filter only works on GET requests.

 best regards
  Stephan

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


RE: Re: Resource paths with Restlet and Jax Rs

2010-09-27 Thread webpost
Hi Stephan,

as I read parts of your master thesis I found the extension issue and that it 
was done on purpose. So I could have found it by my own. Sorry for bothering 
you with this.
But I got another issue, sending parameter with a POST request. When I send 
parameter with a POST request I just get an 405 - Method not allowed. I 
searched the internet and found that you have to enable the different methods 
woth allowPost(). But to do so you have to use Restlet resources from the 
Restlet version 1.1. But I don't use Restlet 1.1 (did not found such a method 
for 2.1) and I don't have use Restlet resources at all. 

Do I have to enable the POST methods somehow? (sending a POST request without 
POST parameter works) 


Kind regards, Matthias

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


Re: Resource paths with Restlet and Jax Rs

2010-09-27 Thread Stephan Koops
Hi Matthias,
 as I read parts of your master thesis I found the extension issue and that it 
 was done on purpose. So I could have found it by my own. Sorry for bothering 
 you with this.
 But I got another issue, sending parameter with a POST request. When I send 
 parameter with a POST request I just get an 405 - Method not allowed. I 
 searched the internet and found that you have to enable the different methods 
 woth allowPost(). But to do so you have to use Restlet resources from the 
 Restlet version 1.1. But I don't use Restlet 1.1 (did not found such a method 
 for 2.1) and I don't have use Restlet resources at all.

 Do I have to enable the POST methods somehow? (sending a POST request without 
 POST parameter works)
In the JAX-RS extension not.
allowPost() is for pure Restlet 1.x.

Do you have the problems with post, if you add parameters for the tunnel 
filter? Maybe the tunnel filter only works on GET requests.

best regards
Stephan

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


RE: Re: Resource paths with Restlet and Jax Rs

2010-09-24 Thread webpost
Hi Stephan, (guess I should get a name here)

The thing with the Spring is not that problem. The integration actually works 
fine. You just have to create a config file in which you specify the 
JaxRsApplication to call and you hand over the SpringComponent. It's quite easy.
The problem is that the application where I integrate the REST application just 
redirects any request that doesn't has an extionsion. (for security and other 
reasons) So even it is not usefull have a DELETE request with an extension I 
would need it because of the integration.

I will see how I can work around this (also see the tunneling you mentioned) 
and will post a possible solution (if I find a good on)

Thanks for you reply and your help.

Matthias ;)

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


Re: Resource paths with Restlet and Jax Rs

2010-09-23 Thread Stephan Koops
Hi nameless,

You are right, there is a lack for POST, DELETE and PUT.
IMO for DELETE it is meaningless (from view of HTTP / REST) to send an 
extension, because you don't want to delete one Representation (the 
json, xml, ... one), but the full resource. For PUT and POST it could 
mean the data you send or the data you get. Especially for PUT I think, 
the extension should specify the data you send, because that is PUT.

You could also try to use the tunneling via URl parameter. Maybe that 
works better for you.

I have no experience with Restlet in combination with Spring, also not 
with Restlet-JAX-RS and Spring.

best regards
Stephan

 Thanks a lot for your help. It took me a while to figure it out how I can use 
 the tunneling and the extension this way I want to. It is working for the GET 
 requests as expected. But I got some other questions/ issues.

 I just enabled the tunnel for my JaxRsApplication class and added the mime 
 types to the resource methodes within the @Produces annotation. But now I 
 discovered that it is not possible to do a POST request using the mime type 
 extension (json, xml...) I guess this is because POST is not intentend to 
 send data back to the client only http status codes. So I commented out the 
 @Produces for the POST and it was working.

 The problem is that the jax-rs application will be included in a spring 
 project that only allows requests with certain extensions like json, xml... 
 So is there a way to get around this?

 The other thing is that I would like to send response data back to the client 
 with the POST (DELETE, PUT) request to save resources on the (mobile) client 
 side. Is there a way to do this?


 Thanks in advance for the help.

 Is also searched this mailing list but did not found anything hope I did not 
 missed it somehow.
Am 21.09.2010 11:36, schrieb webp...@tigris.org:
 A note to the post before. I went on with trying a bit more and I figured out 
 that it sends data back to the client but only in the case when I don't use 
 any extensions.
 As soon as I use an extension on the POST call it prints me an 404 because it 
 tries to request /blogs.json instead of filtering the extension and call 
 /blogs

 Might this be a bug or did I miss a setting?

 I do the POST call with a HTML form and I use Restlet 2.1 (tried 2.0 before)
 Using GET this way it is working.

 Thanks for you help.

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


RE: Re: Resource paths with Restlet and Jax Rs

2010-09-21 Thread webpost
A note to the post before. I went on with trying a bit more and I figured out 
that it sends data back to the client but only in the case when I don't use any 
extensions.
As soon as I use an extension on the POST call it prints me an 404 because it 
tries to request /blogs.json instead of filtering the extension and call /blogs

Might this be a bug or did I miss a setting? 

I do the POST call with a HTML form and I use Restlet 2.1 (tried 2.0 before)
Using GET this way it is working.

Thanks for you help.

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


RE: Re: Resource paths with Restlet and Jax Rs

2010-09-20 Thread webpost
Thanks a lot for your help. It took me a while to figure it out how I can use 
the tunneling and the extension this way I want to. It is working for the GET 
requests as expected. But I got some other questions/ issues.

I just enabled the tunnel for my JaxRsApplication class and added the mime 
types to the resource methodes within the @Produces annotation. But now I 
discovered that it is not possible to do a POST request using the mime type 
extension (json, xml...) I guess this is because POST is not intentend to send 
data back to the client only http status codes. So I commented out the 
@Produces for the POST and it was working. 

The problem is that the jax-rs application will be included in a spring project 
that only allows requests with certain extensions like json, xml... So is there 
a way to get around this? 

The other thing is that I would like to send response data back to the client 
with the POST (DELETE, PUT) request to save resources on the (mobile) client 
side. Is there a way to do this?


Thanks in advance for the help.

Is also searched this mailing list but did not found anything hope I did not 
missed it somehow.

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


Re: Resource paths with Restlet and Jax Rs

2010-08-27 Thread Stephan Koops
Hi,

sorry, I've made a little mistake. You don't need a new class to do content 
negotiation by extension. Just enabled the tunnel filter on the 
JaxRsApplication and ensure, that also bson is a known extension.

best regards
   Stephan

-Ursprüngliche Nachricht-
Von: Stephan Koops stephan.ko...@web.de
Gesendet: 25.08.2010 21:20:10
An: discuss discuss@restlet.tigris.org
Betreff: Re: Resource paths with Restlet and Jax Rs

Hi how ever your name is,

the best way is to remove the extension, and set the accept-header of 
HTTP in the request, and the methods return an object, which will be 
serialized by two JAX-RS MessageBodyWriters, annotated with @Produces. 
For JSON it is already included.
If you can't or don't want to use a MessageBodyWriter, you could put 
@Produces also on the resource methods. Than you have a resource method 
for bson and one for json.
If it is not possible, to use the HTTP accept-header, you could create a 
filter which matches the extension to the accept header. I think I can 
send you code for it tomorrow.

best regards
   Stephan

webp...@tigris.org schrieb:
 Hello,

 I set up a small standalone server as JaxRsApplication like in the JAX-RS 
 extension example on the website.

 My resources are annotated with Jax-Rs Annotations. Every Resource should 
 have the same entry point. So I was thinking to put @Path() on each 
 resource class and the specified resource path to the dedicated methods. 
 When I add these resources to the application class I get a warning that 
 more than one resource uses the same root path. The main problem is that I 
 want to add a type extention to the URI. My URIs should look like this:

 www.sample.com/blogs.json
 www.sample.com/blogs/3.json
 www.sample.com/notes.json
 www.sample.com/notes/3.json

 So my class definition looks like

 @Path()
 public class Blog{
   @GET
   @Path(/blogs.{extension: [bj]son})
   public String getBlogs(...){
 ...
   }

   @GET
   @Path(/blogs/{blogId}.{extension: [bj]son})
   public String getBlog(...){
 ...
   }
 }

 @Path()
 public class Note{
   @GET
   @Path(/notes.{extension: [bj]son})
   public String getNotes(...){
 ...
   }

   @GET
   @Path(/notes/{noteId}.{extension: [bj]son})
   public String getNote(...){
 ...
   }
 }

 Is there a way to get around this?

 Thanks a lot in advance.
   

___
WEB.DE DSL SOMMER-SPECIAL: Surf  Phone Flat 16.000 für 
nur 19,99 ¿/mtl.!* http://web.de/DSL-Doppel-Flatrate/

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


Re: Resource paths with Restlet and Jax Rs

2010-08-27 Thread Stephan Koops
Hi how ever your name is,

the best way is to remove the extension, and set the accept-header of 
HTTP in the request, and the methods return an object, which will be 
serialized by two JAX-RS MessageBodyWriters, annotated with @Produces. 
For JSON it is already included.
If you can't or don't want to use a MessageBodyWriter, you could put 
@Produces also on the resource methods. Than you have a resource method 
for bson and one for json.
If it is not possible, to use the HTTP accept-header, you could create a 
filter which matches the extension to the accept header. I think I can 
send you code for it tomorrow.

best regards
   Stephan

webp...@tigris.org schrieb:
 Hello,

 I set up a small standalone server as JaxRsApplication like in the JAX-RS 
 extension example on the website.

 My resources are annotated with Jax-Rs Annotations. Every Resource should 
 have the same entry point. So I was thinking to put @Path() on each 
 resource class and the specified resource path to the dedicated methods. When 
 I add these resources to the application class I get a warning that more than 
 one resource uses the same root path. The main problem is that I want to add 
 a type extention to the URI. My URIs should look like this:

 www.sample.com/blogs.json
 www.sample.com/blogs/3.json
 www.sample.com/notes.json
 www.sample.com/notes/3.json

 So my class definition looks like

 @Path()
 public class Blog{
   @GET
   @Path(/blogs.{extension: [bj]son})
   public String getBlogs(...){
 ...
   }

   @GET
   @Path(/blogs/{blogId}.{extension: [bj]son})
   public String getBlog(...){
 ...
   }
 }

 @Path()
 public class Note{
   @GET
   @Path(/notes.{extension: [bj]son})
   public String getNotes(...){
 ...
   }

   @GET
   @Path(/notes/{noteId}.{extension: [bj]son})
   public String getNote(...){
 ...
   }
 }

 Is there a way to get around this?

 Thanks a lot in advance.


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


Resource paths with Restlet and Jax Rs

2010-08-25 Thread webpost
Hello,

I set up a small standalone server as JaxRsApplication like in the JAX-RS 
extension example on the website.

My resources are annotated with Jax-Rs Annotations. Every Resource should have 
the same entry point. So I was thinking to put @Path() on each resource class 
and the specified resource path to the dedicated methods. When I add these 
resources to the application class I get a warning that more than one resource 
uses the same root path. The main problem is that I want to add a type 
extention to the URI. My URIs should look like this:

www.sample.com/blogs.json
www.sample.com/blogs/3.json
www.sample.com/notes.json
www.sample.com/notes/3.json

So my class definition looks like

@Path()
public class Blog{
  @GET
  @Path(/blogs.{extension: [bj]son})
  public String getBlogs(...){
...
  }

  @GET
  @Path(/blogs/{blogId}.{extension: [bj]son})
  public String getBlog(...){
...
  }
}

@Path()
public class Note{
  @GET
  @Path(/notes.{extension: [bj]son})
  public String getNotes(...){
...
  }

  @GET
  @Path(/notes/{noteId}.{extension: [bj]son})
  public String getNote(...){
...
  }
}

Is there a way to get around this?

Thanks a lot in advance.

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