Hi Vincent,
On Wed, Feb 16, 2011 at 7:27 PM, Vincent Massol <vincent(a)massol.net> wrote:
Hi Fabio,
On Jan 26, 2011, at 10:03 PM, Fabio Mancinelli wrote:
Hi Vincent
this is very interesting. AFAIU you are proposing a REST-like (as in
http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_…).
Because of this similarity I've find quite strange to see packed in a
"string representation" that could be taken as the resource
identifier, the reference, the action, and the expected
representation.
That was just one example of serialization.
For example: page:view:wiki:space1.space2.page is
actually a request
for getting the content of the resource wiki:space1.space2.page
rendered in HTML with a skin applied.
From my point of view (very HTTP-REST biased) this would have been
"translated" like
VIEW, xwiki://wiki.space1.space2.page, {target: text/html}
Yes this is exactly the same as what I was showing ;)
Where a clear separation among actions,
identifiers and paramaters
(for example for selecting the representation) is more evident.
Other examples:
entity:view:wiki:space1.space2.page, params: context=new -> VIEW,
xwiki://wiki:space1.space2.page, {target: text/plain, params :
{context : new}}
entity:link:wiki:space.page@my.png -> VIEW,
xwiki://wiki:space.page@my.png, {target: link}
Your examples are all about VIEWing resources. But you also mentioned
creation and updating.
Something like this could be done by issuing requests like UPDATE,
xwiki://wiki:space.page, {content-type: text/plain, payload: "new page
content"}
What does this mean at the API level?
Simply having something like
execute(Action, Reference, Map<String, Object> metadata) where Action
is an enum {VIEW, UPDATE, DELETE, whatever} which consitutes the
Uniform Interface through which manipulating the resources (i.e., the
equivalent of HTTP's GET, PUT, POST DELETE or WebDav COPY, MKCOL,
etc.) What is in this enum is XWiki specific of course.
In this way the action, the identifier and the metadata are clearly
separated and not mixed in a string representation that could be taken
for the actual identifier.
I never suggested that we would manipulate data as a String! I actually proposed
ResourceReference and ResourceAction in my initial proposal.
Now I think we might not need a ResourceReference class and we might only need:
ResourceAction
{
ResourceType type
Action action
Object reference <-- for entities would contain an EntityReference
Map<String, Object> parameters
}
However we also need Resolvers and Serializers.
For example to transform from a URL into a ResourceAction:
ResourceAction ResourceActionResolver.resolve(url)
And to transform from a ResourceAction to a URL:
URL ResourceActionSerializer.serialize(ResourceAction)
Actually this was my point. Imho, URL are only for identifying
resources (i.e., they're actually entity references).