Restlet + Clojure = Prudence: Talk in Chicago, December 15th

2010-12-02 Thread Tal Liron
In case you're interested, I'll be giving a talk on December 15th
(Wednesday) at 6pm, at ThoughtWorks (200 E. Randolph).

The Clojure edition is Prudence's most exciting: the combination of
Prudence's high-concurrency Restlet container and Clojure's persistent data
structure promises very robust, scalable web applications.

http://www.meetup.com/Chicago-Clojure/calendar/15623004/

If you've never used a Lisp before, don't be too intimidated: the Clojure
meetup crowd always includes a mix of old hands and parentheses noobs.

(defn signature [salutation]
  (sign salutation "Sincerely" 'Tal))

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

RE: Post method not work when deployed to GAE

2010-12-02 Thread Thierry Boileau
Hello all,

this should have been fixed in the current snapshot.
Could you give it a try?  http://www.restlet.org/downloads/unstable

Best regards,
Thierry Boileau

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


Re: ClientInfo.getPreferredMediaType and Internet Explorer

2010-12-02 Thread Rickard Öberg
On 2010-12-02 17.07, Jerome Louvel wrote:
> Hi Rickard,
>
> This was indeed a bug. It is now fixed in SVN 2.0 branch and trunk.
> Thanks for the report.

Goodie, thanks!

> Regarding the TunnelService, it can automatically replace the
> "Accept" header sent by broken clients with a more sensible one,
> based in the "UserAgent" header value. See the TunnelService Javadocs
> for more details.

Ok, then I understand, thanks.

> Could you elaborate a bit more on what is lacking in ServerResource
> from your point of view? We have plans to support HATEOS more
> automatically in 2.2 so this might help. Any pointer to your
> suggested approach (UseCases?).

Basically it comes down to very fundamental issues with what people tend 
expose as their REST API (domain model=VERY BAD IDEA!), and the problems 
that come from that, and what to do instead. And once you start 
realizing that HATEOAS is superimportant, and only really works if you 
expose usecases instead, and that it should be as native as possible in 
code, that also changes things.

What we have done is to do sort of a custom router mechanism. Let's say 
we have the following URL:
/account/changepassword

In my current code this is handled by first having a root resource that 
represents "/" with:
public class RootResource
   extends CommandQueryResource
{
@SubResource
public void account()
{
   subResource( AccountResource.class );
}

... more subresources ...
}

So a Restlet will instantiate RootResource and call handle() on it, 
which through reflect will find "account" and call that, which 
instantiates AccountResource, which looks like this:
public class AccountResource
extends CommandQueryResource
{
public AccountResource( )
{
   super( AccountContext.class );
}

... more subresources to /account/ ...
}

/account/ represents a usecase, and now "changepassword" is one of the 
interactions in this usecase. The AccountContext finally contains the 
actual code for the usecase (the *Resource is on the REST level, not the 
usecase level):
public class AccountContext
{
@Structure
Module module;

public void changepassword( ChangePasswordCommand newPassword )
  throws WrongPasswordException
{
   UserAuthentication user = RoleMap.role( UserAuthentication.class );

   user.changePassword( newPassword.oldPassword().get(), newPassword
 .newPassword().get() );
}
}
Where ChangePasswordCommand is a value object that will be 
created+filled in with form data (either POST'ed or from request query 
parameters). If I do GET on /account/changepassword I get a form with 
the required fields (oldPassword, newPassword).

And that's all. Now I don't have to bother with much RESTy stuff in my 
usecase code, and yet I get my REST API constructed more or less 
automatically.

Additionally, a core requirement in REST is that the client has to find 
it's way to this URL by following links. Given the above code my 
framework can automatically generate HTML/JSON with links for every path 
that ends with "/". So from "/" you would get HTML that includes:
Account
and from "/account/" you would get HTML that includes:
changepassword
With this the client can find the URL without having to know the URL 
structure, only rel attributes, which is how it should be. This allow me 
to restructure the API without having to change clients interpretation 
of paths and whatnot, which is a key point of HATEOAS.

So this is how we write our application code, with Restlet handling all 
the RESTy details of parsing requests and generating responses. Which is 
perfect!

With this as background, ServerResource is (IMO) simply too low-level, 
and exposes things that for most application API's should not be 
bothered with. I still use it for other parts of my API, but not the 
core application-level part.

For more details see:
http://www.jroller.com/rickard/entry/rest_api_for_infrastructure_domain
http://www.jroller.com/rickard/entry/rest_and_the_missing_link

/Rickard

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


RE: ClientInfo.getPreferredMediaType and Internet Explorer

2010-12-02 Thread Jerome Louvel
Hi Rickard,

This was indeed a bug. It is now fixed in SVN 2.0 branch and trunk. Thanks for 
the report.

Regarding the TunnelService, it can automatically replace the "Accept" header 
sent by broken clients with a more sensible one, based in the "UserAgent" 
header value. See the TunnelService Javadocs for more details. 

Could you elaborate a bit more on what is lacking in ServerResource from your 
point of view? We have plans to support HATEOS more automatically in 2.2 so 
this might help. Any pointer to your suggested approach (UseCases?).

Best regards,
Jerome
--
Restlet ~ Founder and Technical Lead ~ http://www.restlet.o​rg
Noelios Technologies ~ http://www.noelios.com


-Message d'origine-
De : Rickard Öberg [mailto:rickardob...@gmail.com] 
Envoyé : jeudi 2 décembre 2010 03:42
À : discuss@restlet.tigris.org
Objet : Re: ClientInfo.getPreferredMediaType and Internet Explorer

On 2010-12-02 04.03, Thierry Boileau wrote:
> the current algorithm implemented in ConnegUtils#getPreferredMetadata 
> was a bit restrictive. It checked the presence of the preference (in 
> this case "*/*") inside the given list of supported metadatas. Having 
> said that, I'm quite confused. I'm not sure it will fit your need, 
> because it returns a metadata taken from the list of preferences (in 
> your case "*/*"), not from the supported ones, which seems in 
> contradiction with the javadocs...

It needs to return a MediaType from the supported list, not the accepted ones 
(which could be generic, i.e. "*/*").

/Rickard

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

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