RE: conditional request handling with annotated methods

2012-03-23 Thread John Wismar
> Does anyone know how to process If-Modified-Since requests in
> combination with annotated methods? Restlet seems to ignore the
> getInfo() methods and heads straight to the method that has the
> @Get annotation. I'm using restlet 2.0.10, in case that matters.

I don't know if it's the right or preferred way of handling it, but I'm 
checking the modified date in the resource constructor, and setting the 
response status to Status.REDIRECTION_NOT_MODIFIED if appropriate. My case may 
be unusual, because I have the modification date available at that point.

I haven't tried it, but it  also might make sense to override onInit() and do 
the check there. 

--
John Wismar

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

Re: Is there a way to get the response code from the annotated ClientResource?

2012-03-23 Thread Richard Berger
Thanks so much - that was exactly what I needed!  RB

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Is-there-a-way-to-get-the-response-code-from-the-annotated-ClientResource-tp7397618p7398735.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


conditional request handling with annotated methods

2012-03-23 Thread Arjohn Kampman
Hi all,

Does anyone know how to process If-Modified-Since requests in
combination with annotated methods? Restlet seems to ignore the
getInfo() methods and heads straight to the method that has the
@Get annotation. I'm using restlet 2.0.10, in case that matters.

-- 
Arjohn Kampman - www.aduna-software.com

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


Re: Is there a way to get the response code from the annotated ClientResource?

2012-03-23 Thread Tim Peierls
On Fri, Mar 23, 2012 at 12:43 AM, Richard Berger
wrote:

> Given code like the following...
>
> ClientResource commentClient = new ClientResource(...);
> CommentsResource commentsResource
> = commentClient.wrap(CommentsResource.class);
> commentsResource.postCommentForm(form);
>
> is there a way to get the response code from the commentsResource?
> Currently I am using: commentClient.getResponse().getStatus().getCode() -
> but that requires me to
> always have access to both the wrapped ClientResource and
> the ClientResource.  I tried casting commentsResource back to
> ClientResource but that didn't work (and was probably a silly idea - but
> hey, I get pretty excited when my code compiles :) :) ).
>


Not silly! But off in one crucial respect: You need to cast to
*ClientProxy
*, which then has a getClientResource method from which to obtain the
underlying ClientResource.

--tim

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

RE: Expected on redirect

2012-03-23 Thread Gabriel Pulido
Hello Jerome,
I've just tried it with the libraries you have provide, and it still doesn't 
work :(

My steps were:
- change the libraries on the eclipse project so I have the following:
 On the Reference libraries of the eclipse:
   -org.restlet.jar (from jee)
   -org.restlet.ext.gwt.jar (from jee)
   -org.restlet.ext.servlet.jar (from jee)
   -org.restlet.jar (from gwt)
   -RestTestServer.jar (compiled from the Netbeans project, to allow the use of 
the Contact object)

 On the war/WEB-INF
   -org.restlet.jar (from gwt)
   -org.restlet.gwt.jar (from jee)
   -org.restlet.ext.servlet.jar (from jee)
  
-Changed the libraries on the netbeans project (the one which runs the restlet 
rest server)
  In this project I have had to remove the use of the simple framework (as it 
is not available on the jee edition) and run it with the embebed restlet server.
  So the libraries that I have now on the netbeans is just the org.restlet.jar 
(from the jee edition)

If I start the netbeans server and then the eclipse web app. When I try to 
retrieve the contact resource from the client (/contacts/123) I receive the 
following error on the eclipse:

InformaciĆ³n: Redirecting via client dispatcher to: 
http://localhost:8112/contacts/123
mar 22, 2012 9:00:37 PM org.restlet.engine.log.LogFilter afterHandle
InformaciĆ³n: 2012-03-22 21:00:37127.0.0.1   -   /127.0.0.1  
8112GET /contacts/123   -   200 -   0   79  
http://127.0.0.1:   Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 
(KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11 
http://127.0.0.1:/TestGWTRestlet.html?gwt.codesvr=127.0.0.1:9997

Internal Server Error (500) - Can't parse the enclosed entity because of its 
media type. Expected  but was 
. Make sure you have added the 
org.restlet.client.ext.gwt.jar file to your server.

As I didn't know if the org.restlet.gwt.jar must be also on the netbeans 
project. I added it to test and then the error changes and I receive the 
following
On the eclipse webclient server:
[ERROR] 500 - GET /contacts/123 (127.0.0.1) 451 bytes
   Request headers
  Host: 127.0.0.1:
  Connection: keep-alive
  User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, 
like Gecko) Chrome/17.0.963.79 Safari/535.11
  Accept: application/x-java-serialized-object+gwt
  Accept-Encoding: gzip,deflate,sdch
  Accept-Language: es,en-US;q=0.8,en;q=0.6,en-GB;q=0.4
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Referer: 
http://127.0.0.1:/TestGWTRestlet.html?gwt.codesvr=127.0.0.1:9997
   Response headers
  Content-Location: http://localhost:8112/contacts/123
  Date: Thu, 22 Mar 2012 20:04:00 GMT
  Accept-Ranges: bytes
  Server: Restlet-Framework/2.1snapshot
  Content-Type: text/html; charset=UTF-8
  Content-Length: 451
  Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
Internal Server Error (500) - Internal Server Error

On the netbeans server output:
Advertencia: Exception or error caught in server resource
java.lang.NoClassDefFoundError: 
com/google/gwt/user/server/rpc/SerializationPolicyProvider
at 
org.restlet.ext.gwt.GwtConverter.toRepresentation(GwtConverter.java:165)
at 
org.restlet.service.ConverterService.toRepresentation(ConverterService.java:263)
at org.restlet.resource.Resource.toRepresentation(Resource.java:741)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:513)
at org.restlet.resource.ServerResource.get(ServerResource.java:699)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:581)
at 
org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:641)
at 
org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:340)
at org.restlet.resource.ServerResource.handle(ServerResource.java:929)
at org.restlet.resource.Finder.handle(Finder.java:246)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
..

So I move on and make a last test: I've added the com.google.gwt.server.jar 
from the jee package to the netbeans library path, althought the included is 
the version for the gwt 2.3 and I'm using the gwt 2.4 on the eclipse project.
Now when I try to retrieve the resource, it doesn't fail, but after a long 
time, a null contact is returned (maybe caused by the use of the embedded 
server on netbeans instead of the simple framework?)  So I'm back to the square 
one.

I hope this test could help you. Probably some of then were unnecessary if the 
correct libraries are on the correct paths. However as I'm using a redirector, 
the documentation available doesn't make clear were the libraries should be.
Please, let me know what is the correct scenario, and if I need to make more 
test to make this work.

Thank you in advance.
Best regards
Gabriel Pulido

--
http://restlet.tigris.org/ds/vie