Content negotiation problem when using a specific server connector (Jetty, Simple or Netty)

2010-08-09 Thread Bruno Harbulot
Hi,

The problem I described in 
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2639896
 
was fixed in version 2.0.0 (I was using 2.0-RC4 for this test). Great!

However, there's a new problem.

(I'm using the same code: http://gist.github.com/496447)

This works:
dependencies
dependency
groupIdorg.restlet.jse/groupId
artifactIdorg.restlet/artifactId
version2.0.0/version
/dependency
dependency
groupIdorg.restlet.jse/groupId
artifactIdorg.restlet.ext.httpclient/artifactId
version2.0.0/version
/dependency
dependency
groupIdjunit/groupId
artifactIdjunit/artifactId
version4.4/version
/dependency
/dependencies



As soon as I add Jetty, Simple or Netty, the tests fail.
dependency
groupIdorg.restlet.jse/groupId
artifactIdorg.restlet.ext.jetty/artifactId
version2.0.0/version
/dependency



The main difference I've been able to notice is that, on a GET request, 
with the default connector, the request's entity is an 
EmptyRepresentation, whereas with either Jetty, Simple or Netty, the 
request's entity is in InputRepresentation with isAvailable() being true.
When AnnotationInfo.isCompatibleRequestEntity(...) is called as part of 
the automatic ServerResource.getVariants() call, the fact that there is 
an entity available makes it return 'false' and thus the variants are 
never added.


Best wishes,

Bruno.

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


Is Multiple Get and Put annotations Possible?

2010-08-09 Thread Neelmani Gautam
Hi,

   I would like to know if it possible to annotate multiple methods with Get 
and/or Put ? While I was trying to annotate multiple methods with Put 
annotations only one was got recognized. 

Thanks.

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


RE: Strange failure

2010-08-09 Thread jupiterroom
Hi Thierry,

OS = Windows XP
JDK Version = jdk1.5.0_15

Not sure what you mean by server connector and client?

We're also using version 2.0 of the restlet framework

Thanks

Richard
-- 
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Strange-failure-tp5371669p5388452.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


RE: Android client : how to add cookies ?

2010-08-09 Thread Pierre-Yves Ricau
My answer hasn't been published yet so I'll add some more thoughts right here 
:-) 

= When something doesn't work the way you want, maybe that's because you don't 
want the good thing...

I've been thinking about my authentication problem, and finally came to the 
conclusion that securing the URLs in the web.xml wasn't the best solution. It 
automatically redirects the user to the appengine login page... However, when 
calling those Rest resources, I don't care about redirections. I just wanna 
know that my authentication is not valid any more..

So the solution was of course disabling appengine security, and using a simple 
servlet filter :

public void doFilter(ServletRequest request, ServletResponse response, 
FilterChain filterChain) throws IOException, ServletException {
User currentUser = userService.getCurrentUser();

if (currentUser != null) {
filterChain.doFilter(request, response);
} else {
if (response instanceof HttpServletResponse) {
HttpServletResponse httpResponse = 
(HttpServletResponse) response;

httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN, You must authenticate 
to access this resource.);
}
}
}

Then, it's all a matter of catching a ResourceException in my Android client, 
and checking if the status code is 403...

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


RE: Android client : how to add cookies ?

2010-08-09 Thread Pierre-Yves Ricau
Thanks Thierry, sorry for not answering any sooner. I had found the solution by 
myself a few minutes after posting (...), but couldn't say it before the post 
was accepted.

About the void issue... It seems that I had been using a pre-M1 release of 
Restlet 2.0. Getting the M1 fixed the problem. Sorry for bullshiting. 

In fact, everything is working pretty well, which is cool. However, I still 
have a blocking issue !

When the auth cookie is expired, AppEngine redirects the HTTP call to the auth 
page. However, Restlet follows the redirect, and return null.

The JacksonRepresentation should not return null when not being able to parse a 
JSON stream, it should throw an exception. Otherwise, how can we handle errors 
? See JacksonRepresentation line 129 :

public T getObject() {
T result = null;

if (this.object != null) {
result = this.object;
} else if (this.jsonRepresentation != null) {
try {
result = getObjectMapper().readValue(
this.jsonRepresentation.getStream(), this.objectClass);
} catch (IOException e) {
Context.getCurrentLogger().log(Level.WARNING,
Unable to parse the object with Jackson., e);
}
}

return result;
}

I tried to disable followRedirects on client resource. However, in this case, 
the toObject method from the ConverterService (line 144)  is given an 
EmptyRepresentation as a source. And therefore the method returns null.

I'd like to be able to tweek the InvocationHandler so that it might throws 
exceptions when getting a redirect and not following it.

However, for now, I think I'll subclass the JacksonRepresentation and 
JacksonConverter, and throw exceptions when it fails to parse the object.

I also found a Jackson framework issue : when ObjectMapper class is loaded, it 
tries to load a bunch of classes that are not available. This doesn't cause any 
bug (only appears in logs), but it takes a long time and slows down the 
startup. I'll post a bug report on the Jackson framework page.

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