You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by Murray Altheim <mu...@altheim.com> on 2008/07/07 23:24:20 UTC

REST-ful URLs [Was: url rewriting supported?]

One of the things I've been working on (both related and unrelated to
JSPWiki) is a web service URL schema providing read and write access
to the wiki, in particular the wiki's page provider. Without going
into detail about that I thought I might at least mention the idea
of REST-fully regularizing *all* of the URLs used by JSPWiki to a
common approach, i.e. (optional components in square brackets):

    baseURL collectionHierarchy [objectId] action ['?' parameters]

e.g.,

    http://www.acme.org/wiki/  pages/  PageName/  get/

This would in the future permit a collection hierarchy where 'pages/'
currently exists, with 'PageName' as object ID (oid) potentially
replaced by any kind of identifier (pages may be identified by name
or by some other kind of identifier that survives across renames --
title).

    http://www.acme.org/wiki/pages/PageName/get/
    http://www.acme.org/wiki/pages/PageName/edit/
    http://www.acme.org/wiki/pages/PageName/put/
    http://www.acme.org/wiki/pages/search/?q=term

(the actual action names aren't important) or alternately, including
the action name as a parameter:

    http://www.acme.org/wiki/pages/PageName/?action=get
    http://www.acme.org/wiki/pages/PageName/?action=edit
    http://www.acme.org/wiki/pages/PageName/?action=put
    http://www.acme.org/wiki/pages/?action=search&q=term

allowing things like:

    http://www.acme.org/wiki/pages/PageName/?action=get&format=html
    http://www.acme.org/wiki/pages/PageName/?action=get&format=xml
    http://www.acme.org/wiki/pages/PageName/?action=get&format=text

etc., with advantages and disadvantages to each.

Has there been any thought amongst other members of the team in writing
a more REST-ful URL constructor? Perhaps as the default? While I do
understand dealing with legacy issues it'd be nice to just have a simple,
REST-ful URL that just worked. It's been one of those things I've never
been able to get working consistently in JSPWiki across all
installations.

I don't have it working yet but I basically have been writing a web
service that would provide complete access to the wiki's functionality
using a schema similar to the above. The question for me is how
difficult it'd be in rewriting the JSPs to generate URLs as according
to the web service instead of the existing setting, which of course
led me to think that the whole web service is really just an alternative
URL constructor...

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> I'm not so concerned about regex parsing simply because I *think* it's
> possible to design a URL schema that doesn't require it, iff that  
> schema
> is pretty exacting. I would myself prefer to avoid regex if  
> possible, for

You can't avoid regexps in a rule-based model.

You can in a code-based model.

;-)

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> I don't follow. How? If we maintain a flat wiki namespace,

But we don't.

> are using
> wiki page names as we do now as oids, have one predicate and  
> everything
> else is passed as query arguments we have a schema that looks like:
>
>    http://www.acme.com/pages/PageName/get/?param1=name?param2=name
>
> What's wrong with that?

By your definition, that's not RESTful, then ;-)

And it will break.

>>
> I am writing a new app.

But we are discussing JSPWiki 3 architecture.  And, the problem is  
that the CleanURI feature isn't going to help you, because it is static.

> I'm not suggesting it is a strong requirement of yours, only that if
> I'm going to use JSPWiki and get it to fit into our larger service
> framework I'm going to need something like what Andrew has suggested
> can be provided via Stripes, and it'd be great if that URL schema was
> also the one used by the wiki generally. A very good fit, really.

I don't see any way that it could.  Remember that the Stripes  
URIBindings are static, enforced in *static code annotations*.  So  
you would need to fork your own version of JSPWiki.

> And if it were modular (I'm here telegraphing an email from you I
> just received) it might be possible to fit this onto a 2.8 implementa-
> tion by hooking it into the wiki in the same way as the existing URL
> constructors are handled. When we get to 3.0 we may have a nicer way
> of doing it but if well designed we wouldn't have to replace anything,
> just change the means of attachment/message passing.

No, I don't see that it would be possible without breaking the 2.8.   
The Stripes stuff is a very, very invasive change, and at any rate,  
we would be stuck with the URLConstructors anyway.

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Murray Altheim <mu...@altheim.com>.
Janne Jalkanen wrote:
>>> This presents more of a challenge. We need some way of transforming 
>>> the inbound URL into a normal request -- with normal parameters -- so 
>>> that Stripes can locate the right bean, [etc.]
>>> Originally I was thinking we'd need to write our own filter to do 
>>> this, or use URLRewrite. It turns out some clever Stripes devs got 
>>> there first. They call this the "clean URL" feature. It was initially 
>>> a user contribution, but the Gregg and Tim liked it so much they put 
>>> it into the trunk.
>>> I have been watching the 1.5 builds, but TOTALLY forgot about this. 
>>> Needless to day, it completely solves the problem, and it makes my 
>>> previous comments about needing an external filter totally obsolete. 
>>> Assuming you buy into the Stripes Way, the URL scheme you describe 
>>> can be completely accommodated.
> 
> BTW, I think this is evil.  It gives you a fixed URI scheme, and sooner 
> or later you end up with URLs that look like /foo/-/-/-/a/-/-/-/c/-/-/-/
> 
> You see them all around these days.

I don't follow. How? If we maintain a flat wiki namespace, are using
wiki page names as we do now as oids, have one predicate and everything
else is passed as query arguments we have a schema that looks like:

    http://www.acme.com/pages/PageName/get/?param1=name?param2=name

What's wrong with that?

>>> "Clean URLs support both prefix mapping (/action/foo/{bar}) and 
>>> extension mapping (/foo/{bar}.action). Any number of parameters 
>>> and/or literals may be omitted from the end of a request URL."
> 
> The problem is that you can't do it from the middle of the request.
> 
>> Almost all of our present services are in need of an architectural
>> overview, and what we're trying to do is (sorry to the use the word
>> again, but) rationalize the URL schema.
> 
> We can't without breaking the URLs of all the existing websites.  *And* 
> some of them are using the ShortViewURLConstructor and some of them are 
> using the DefaultURLConstructor.  I think this is a design parameter 
> which we simply cannot afford to break.

That's not an issue since I wouldn't propose to use this with existing
websites. No existing website *can* change its URL schema constructor
without breaking all the bookmarks of all its current users. Even if
I *could* get the ShortURLConstructor to work with the CeryleWiki (and
I've not been able to since the directory level from the base URL won't
permit it, or some such thing), I have to deal with the fact that anyone
who has a bookmarked page or uses any URL reference to a page on my
site will get a 404 if I change my scheme. In my case I'll probably
just change it, but this is a non-issue for most *existing* sites -- I'm
only thinking of this for new sites.

> (And no, mod_rewrite is not an answer.)
> 
>> What I'm thinking is that Janne doesn't sound all that enthusiastic
>> about this so it might have to fit into the application as another
> 
> The Stripes stuff is great - IF you are writing a new app.  If you're 
> trying to retrofit it to the existing schema, I would very strongly 
> hesitate to just use it because it's great and we have it - that'll end 
> up in a translation layer in front of the Beans which just muddy the 
> waters so that we can use Annotations.  It'll be just like the Command 
> superstructure, but in another form ;-)

I am writing a new app.

> Note that this CleanURI feature is new in Stripes 1.5 (which isn't even 
> out yet in a stable form), and there have been tons of successful 
> applications made in Stripes 1.4 and earlier.  I don't see it as a 
> strong requirement to enforce this architecture.

I'm not suggesting it is a strong requirement of yours, only that if
I'm going to use JSPWiki and get it to fit into our larger service
framework I'm going to need something like what Andrew has suggested
can be provided via Stripes, and it'd be great if that URL schema was
also the one used by the wiki generally. A very good fit, really.

And if it were modular (I'm here telegraphing an email from you I
just received) it might be possible to fit this onto a 2.8 implementa-
tion by hooking it into the wiki in the same way as the existing URL
constructors are handled. When we get to 3.0 we may have a nicer way
of doing it but if well designed we wouldn't have to replace anything,
just change the means of attachment/message passing.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
>> This presents more of a challenge. We need some way of  
>> transforming the inbound URL into a normal request -- with normal  
>> parameters -- so that Stripes can locate the right bean, [etc.]
>> Originally I was thinking we'd need to write our own filter to do  
>> this, or use URLRewrite. It turns out some clever Stripes devs got  
>> there first. They call this the "clean URL" feature. It was  
>> initially a user contribution, but the Gregg and Tim liked it so  
>> much they put it into the trunk.
>> I have been watching the 1.5 builds, but TOTALLY forgot about  
>> this. Needless to day, it completely solves the problem, and it  
>> makes my previous comments about needing an external filter  
>> totally obsolete. Assuming you buy into the Stripes Way, the URL  
>> scheme you describe can be completely accommodated.

BTW, I think this is evil.  It gives you a fixed URI scheme, and  
sooner or later you end up with URLs that look like /foo/-/-/-/ 
a/-/-/-/c/-/-/-/

You see them all around these days.

>>
>> "Clean URLs support both prefix mapping (/action/foo/{bar}) and  
>> extension mapping (/foo/{bar}.action). Any number of parameters  
>> and/or literals may be omitted from the end of a request URL."

The problem is that you can't do it from the middle of the request.

> Almost all of our present services are in need of an architectural
> overview, and what we're trying to do is (sorry to the use the word
> again, but) rationalize the URL schema.

We can't without breaking the URLs of all the existing websites.   
*And* some of them are using the ShortViewURLConstructor and some of  
them are using the DefaultURLConstructor.  I think this is a design  
parameter which we simply cannot afford to break.

(And no, mod_rewrite is not an answer.)

> What I'm thinking is that Janne doesn't sound all that enthusiastic
> about this so it might have to fit into the application as another

The Stripes stuff is great - IF you are writing a new app.  If you're  
trying to retrofit it to the existing schema, I would very strongly  
hesitate to just use it because it's great and we have it - that'll  
end up in a translation layer in front of the Beans which just muddy  
the waters so that we can use Annotations.  It'll be just like the  
Command superstructure, but in another form ;-)

Note that this CleanURI feature is new in Stripes 1.5 (which isn't  
even out yet in a stable form), and there have been tons of  
successful applications made in Stripes 1.4 and earlier.  I don't see  
it as a strong requirement to enforce this architecture.

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> @URLBinding("@URLBinding("/pages/{page=Main}/{$event}")
> class PageActionBean {
>   WikiPage getPage()
>   void setPage(WikiPage)
>   int getVersion()
>   void setVersion(int)
>   void view()
>   void edit()
>   void comment()
> }

Not dynamic, not good.  Adding new actions requires modification of  
existing code.

(No, the current one is not very good either for the same reason.   
Each action should be a separate Bean so that template writers can  
declare them at will from their own JARs.)

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Murray Altheim <mu...@altheim.com>.
Andrew Jaquith wrote:
> Murray --
> 
> Ok, wanna turn the crank on this a little?

Yes, lets.

> My thought, after reading what you wrote, is that we (meaning: you and 
> I) could probably hammer out something that bridges 1) what you want, a 
> nicer RESTish URL format, and 2) what I've been thinking about with all 
> of the automatic bean-binding goodies that will come with JSPWiki 3.0, 
> courtesy of Stripes.

Andrew, first of all: thanks very much for taking the time and effort
to explain all of this. It took two readings but I understand it, and
it's brilliant. Yes, it ties us into Stripes, but basically the code
could be replaced in five years by whatever is the latest trend in
five years (none of that matters, really) because the real API is the
URL and the constitution of the messages passed between the URL handler
and the application, and those messages should be highly rational and
form their own mini-API without any extra work (heck, it's already
there!).

> 1) STRIPES IN 60 SECONDS
>[...]
> So far, that's pretty great, huh? We've gone through the entire bean 
> resolution, binding and event execution lifecycle without writing any 
> special code -- it's all done via simple annotations. Best of all, we 
> get to rip out lots of crappy JSP scriptlet code.

Yes, great stuff.

> 2) WHAT ABOUT MURRAY'S CLEAN URLS?
> 
> Assuming you follow the logic here, you can see how the 
> resolution/binding/event lifecycle works in a straight-ahead, 
> traditional URL format (e.g., path?param=value=&param=value).
> 
> Now, let's apply this to a "clean URL" scenario like the one you described:
> 
> http://murray.org/{subject}/{predicate}/ [optional "adjectives"]
> 
> Using our example, it might look like this:
> 
> /pages/Foo/?event=create
> 
> or maybe: /pages/Foo/create
> 
> This presents more of a challenge. We need some way of transforming the 
> inbound URL into a normal request -- with normal parameters -- so that 
> Stripes can locate the right bean, [etc.]
> 
> Originally I was thinking we'd need to write our own filter to do this, 
> or use URLRewrite. It turns out some clever Stripes devs got there 
> first. They call this the "clean URL" feature. It was initially a user 
> contribution, but the Gregg and Tim liked it so much they put it into 
> the trunk.
> 
> I have been watching the 1.5 builds, but TOTALLY forgot about this. 
> Needless to day, it completely solves the problem, and it makes my 
> previous comments about needing an external filter totally obsolete. 
> Assuming you buy into the Stripes Way, the URL scheme you describe can 
> be completely accommodated.

Very exciting, especially since the investment in code is so minimal,
the functionality so rationalized, and the result just works.

> Anyway, the new Clean URL feature works like this (from the Stripes 1.5 
> Javadoc):
> 
> "Stripes supports "Clean URLs" through the UrlBinding annotation.
> [...]
> "Clean URL parameters can be assigned default values using the = 
> operator. For example,@UrlBinding("/foo/{bar=abc}/{baz=123}"). If a 
> parameter with a default value is missing from a request URL, it will 
> still be made available as a request parameter with the default value. 
> Default values are automatically embedded when building URLs with the 
> Stripes JSP tags. The default value for $event is determined from the 
> DefaultHandler and may not be set in the @UrlBinding.
> 
> "Clean URLs support both prefix mapping (/action/foo/{bar}) and 
> extension mapping (/foo/{bar}.action). Any number of parameters and/or 
> literals may be omitted from the end of a request URL."

This is great. I spent some hours last week writing a URL remapper and
this does it via an annotation; brilliant.

> You can see some addition comments on the development of the feature here:
> 
> http://www.stripesframework.org/jira/browse/STS-262
> 
> So-- to wrap up our previous example, the @URLBinding annotation for our 
> PageActionBean class would look like this:
> 
> @URLBinding("/pages/{page=Main}/?event={$event}")
> 
> or:
> 
> @URLBinding("/pages/{page=Main}/{$event}")
> 
> Nice, huh? No coding needed.

Yes, a very clean design. Thanks.

[...]
> 4) THINKING ABOUT BEANS AND EVENTS
> 
> The difficult part of all this is figuring out how to map ActionBeans to 
> what we understand today as WikiContexts, and to the URL scheme you have 
> suggested. It all comes down to how you look at things:
> 
> - Do you select a page, then take an action on it? (view, edit, comment)
> - Or do you "edit" something... and specify that that something is a 
> particular page?
> 
> The URL scheme you suggested implies the first approach. Today's JSP 
> scheme implies the second.

Yes, but as I just replied to Janne, my own requirements are for a
REST-ful design that doesn't embed any implementation detail in the
URL (e.g., ".action") and fully separates noun from verb.

Almost all of our present services are in need of an architectural
overview, and what we're trying to do is (sorry to the use the word
again, but) rationalize the URL schema. We're for one large project
working with a major vendor who uses a term called an "intellectual
entity" or IE, similar to what in RDF are called "resources". These
form the nouns of our services, such that there is a canonical URL
to identify the IE. This can be considered both independently of a
base URL or with it, e.g.,

    oid: isbn0-87685-479-X

    resolveable oid: http://www.acme.com/item/isbn0-87685-479-X

So we have a strong requirement that from the beginning of the
base URL to the end of the oid forms a canonical reference to
an oid.

This works well with a scheme where the last or semi-last token
in a URL is the oid, the last case using the last as the verb. I'm
not wedded to either approach of where the verb should sit.

> Personally, I like the "object" followed by "verb" idea (the first 
> approach). It maps fairly cleanly to the Stripes ActionBean properties + 
> event model. 

When I read the above I smiled, as that's exactly what I'm aiming
at. So we can have either

   http://www.acme.com/item/isbn0-87685-479-X/get/

or

   http://www.acme.com/item/isbn0-87685-479-X/?action=get

as far as I'm concerned. I'm guessing that my teammates might go with
the latter (given some designs I've seen) but as I mentioned I do
have *some* flexibility (I think).

> Thus, a hypothetical PageActionBean class ("the action bean 
> you use to 'do stuff' with pages") might include the following 
> properties and methods:
>
> @URLBinding("@URLBinding("/pages/{page=Main}/{$event}")
> class PageActionBean {
>   WikiPage getPage()
>   void setPage(WikiPage)
>   int getVersion()
>   void setVersion(int)
>   void view()
>   void edit()
>   void comment()
> }
> 
> The view, edit and comment methods are the events. These are also, at 
> least in theory, "request contexts" as well. (It is easy to see how 
> these would map to WikiContext.VIEW, .EDIT, and .COMMENT...)
> 
> Murray, assuming I have not bored the crap out of you, what do you 
> think? Want to brainstorm some more about "nouns" (action beans) and 
> "verbs" (events)? Got the full schema to share?

Bored? Hardly. No, this is great, I'm keen to try this out.

What I'm thinking is that Janne doesn't sound all that enthusiastic
about this so it might have to fit into the application as another
URLConstructor, or as a sort of proxy that hands off services to
the WikiEngine, dunno. If it were handled as a modular, standalone
web service with an open backend API we'd just need the glue to
hook it into the WikiEngine et al, and it could be reused for other
related web services (those layers I mentioned) that provide alterna-
tive access to the wiki repository, e.g. a web service alternative
to some of the XML-RPC functionality, interwiki or wiki-hive features,
the means of hooking the repository into analysis or preservation
system, etc.

In other words, the Stripes stuff you've mentioned sounds like it
could be useful for all sort of things. I'm just not sure how it
might fit into JSPWiki itself at this point.

As for the URL schema, you've got most of it at this point, unless
you mean the specifics of the verb names, etc.  I don't mean to
sound secretive at all, but I just don't think the specifics matter
all that much at this point, i.e., they'd like just be implementation
details as far as I'm concerned, some constant values we can argue
over at some other time (I wouldn't want to get bogged down in that
kind of thing).

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> Digging a little deeper... when the StripesFilter encounters a URL  
> with a .action suffix, OR a JSP contains a stripes:useActionBean  
> tag, the StripesFilter goes through a defined lifecycle that:

You *could* of course map all *.jsp URLs to the given ActionBean as  
well, doing away with JSPs altogether.  Though that would mean that  
it would be rather complicated to add any new JSPs.

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Andrew Jaquith <an...@mac.com>.
Murray --

Ok, wanna turn the crank on this a little?

My thought, after reading what you wrote, is that we (meaning: you and  
I) could probably hammer out something that bridges 1) what you want,  
a nicer RESTish URL format, and 2) what I've been thinking about with  
all of the automatic bean-binding goodies that will come with JSPWiki  
3.0, courtesy of Stripes.

1) STRIPES IN 60 SECONDS

First, Stripes in 60 seconds. The core unit of data in Stripes is the  
ActionBean. ActionBeans have properties (getters/setters) and events  
(methods specially annotated). ActionBeans are essentially fairly  
lightweight objects that model the range of activities you want to  
accomplish (using a form POST or AJAX, for example) -- these are the  
"verbs." The properties map cleanly to request parameters -- these are  
the nouns and adjectives. What Stripes does is inspect the request  
URL, and automatically wire up the right ActionBean, making sure that  
the "nouns and adjectives" are mapped to parameters, and that the  
right activity is executed.

Digging a little deeper... when the StripesFilter encounters a URL  
with a .action suffix, OR a JSP contains a stripes:useActionBean tag,  
the StripesFilter goes through a defined lifecycle that:

1) locates the and instantiates the correct ActionBean based on  
the .action URL or the bean class specified in the useActionBean tag

2) binds parameters passed in the request to properties (getters/ 
setters) in the ActionBean

3) calls the "event method" specified in the URL (validating the  
properties based on annotated instructions). If no event was  
specified, it executes the default event (generally forwarding to the  
"display JSP," like Wiki.jsp)

For example, suppose we post a URL:

Wiki.action?page=Foo?&_eventName=create

Stripes will inspect the ActionBeans it knows about. Suppose it finds  
one called PageActionBean that has a matching @URLBinding of  
Wiki.action. It knows, aha, I need to create a PageActionBean and  
stash it into the request as an attribute.

Next, it sees that there you supplied a parameter called "page", and  
it notes also that PageActionBean has a setPage(WikiPage) method. It  
will say, aha, we need to call setPage() with the value "Foo". Or more  
correctly, it will use its TypeConverter system to look up the  
WikiPage object corresponding to string "Foo" and set it. (I've  
written a TypeConverter for WikiPage already; very simple.)

Next, it sees the special parameter _eventName and its value "create",  
which is the event it needs to call. It will invoke the create()  
method, making sure to run any validation routines we've asked it to  
run (specified by the @Validate annotation on the bean properties).  
(Sidebar: I have written another annotation that expresses the  
Permissions the user must have to run the event.)

Lastly, the create() method will forward to Edit.jsp to display the  
wiki editor.

So far, that's pretty great, huh? We've gone through the entire bean  
resolution, binding and event execution lifecycle without writing any  
special code -- it's all done via simple annotations. Best of all, we  
get to rip out lots of crappy JSP scriptlet code.


2) WHAT ABOUT MURRAY'S CLEAN URLS?

Assuming you follow the logic here, you can see how the resolution/ 
binding/event lifecycle works in a straight-ahead, traditional URL  
format (e.g., path?param=value=&param=value).

Now, let's apply this to a "clean URL" scenario like the one you  
described:

http://murray.org/{subject}/{predicate}/ [optional "adjectives"]

Using our example, it might look like this:

/pages/Foo/?event=create

or maybe: /pages/Foo/create

This presents more of a challenge. We need some way of transforming  
the inbound URL into a normal request -- with normal parameters -- so  
that Stripes can locate the right bean, bind its properties correctly,  
etc. Specifically: it needs to somehow "know" that /pages meant "find  
the PageActionBean", and that /Foo meant "call setPage() with page  
Foo" and that /create meant, "call the 'create' event once you've done  
all that."

Originally I was thinking we'd need to write our own filter to do  
this, or use URLRewrite. It turns out some clever Stripes devs got  
there first. They call this the "clean URL" feature. It was initially  
a user contribution, but the Gregg and Tim liked it so much they put  
it into the trunk.

I have been watching the 1.5 builds, but TOTALLY forgot about this.  
Needless to day, it completely solves the problem, and it makes my  
previous comments about needing an external filter totally obsolete.  
Assuming you buy into the Stripes Way, the URL scheme you describe can  
be completely accommodated.

Anyway, the new Clean URL feature works like this (from the Stripes  
1.5 Javadoc):

"Stripes supports "Clean URLs" through the UrlBinding annotation.  
Parameters may be embedded in the URL by placing the parameter name  
inside braces ({}). For example, @UrlBinding("/foo/{bar}/{baz}") maps  
the action to "/foo" and indicates that the "bar" and "baz" parameters  
may be embedded in the URL. In this case, the URL /foo/abc/123 would  
invoke the action with bar set to "abc" and baz set to "123". The  
literal strings between parameters can be any string.
"The special parameter name $event may be used to embed the event name  
in a clean URL. For example, given@UrlBinding("/foo/{$event}") the  
"bar" event could be invoked with the URL /foo/bar.

"Clean URL parameters can be assigned default values using the =  
operator. For example,@UrlBinding("/foo/{bar=abc}/{baz=123}"). If a  
parameter with a default value is missing from a request URL, it will  
still be made available as a request parameter with the default value.  
Default values are automatically embedded when building URLs with the  
Stripes JSP tags. The default value for $event is determined from the  
DefaultHandler and may not be set in the @UrlBinding.

"Clean URLs support both prefix mapping (/action/foo/{bar}) and  
extension mapping (/foo/{bar}.action). Any number of parameters and/or  
literals may be omitted from the end of a request URL."

You can see some addition comments on the development of the feature  
here:

http://www.stripesframework.org/jira/browse/STS-262

So-- to wrap up our previous example, the @URLBinding annotation for  
our PageActionBean class would look like this:

@URLBinding("/pages/{page=Main}/?event={$event}")

or:

@URLBinding("/pages/{page=Main}/{$event}")

Nice, huh? No coding needed.


3) OUTBOUND URLS

So far I've described how inbound URLs would be parsed and mapped.  
What about the outbound case (URL generation)?

We would need to write a custom URL constructor that might, for  
example, query the ActionBeans for the correct format, then format the  
URL according to that format. The Stripes URLBuilder class isn't  
suitable for that, because it just knows how to build URLs of the  
traditional sort. (Although the Stripes guys say they intend to make  
it match the @URLBinding format soon...)


4) THINKING ABOUT BEANS AND EVENTS

The difficult part of all this is figuring out how to map ActionBeans  
to what we understand today as WikiContexts, and to the URL scheme you  
have suggested. It all comes down to how you look at things:

- Do you select a page, then take an action on it? (view, edit, comment)
- Or do you "edit" something... and specify that that something is a  
particular page?

The URL scheme you suggested implies the first approach. Today's JSP  
scheme implies the second.

Personally, I like the "object" followed by "verb" idea (the first  
approach). It maps fairly cleanly to the Stripes ActionBean properties  
+ event model. Thus, a hypothetical PageActionBean class ("the action  
bean you use to 'do stuff' with pages") might include the following  
properties and methods:

@URLBinding("@URLBinding("/pages/{page=Main}/{$event}")
class PageActionBean {
   WikiPage getPage()
   void setPage(WikiPage)
   int getVersion()
   void setVersion(int)
   void view()
   void edit()
   void comment()
}

The view, edit and comment methods are the events. These are also, at  
least in theory, "request contexts" as well. (It is easy to see how  
these would map to WikiContext.VIEW, .EDIT, and .COMMENT...)

Murray, assuming I have not bored the crap out of you, what do you  
think? Want to brainstorm some more about "nouns" (action beans) and  
"verbs" (events)? Got the full schema to share?

Andrew


On Jul 7, 2008, at 6:06 PM, Murray Altheim wrote:

> Murray Altheim wrote:
> [...]
>> In the above scheme we can obtain the base URL, the collection  
>> hierarchy
>> and object identifier all without regex, just parsing the '/'  
>> delimiters
>> via indexOf(). If we use the '?' as the delimiter between the  
>> absolute
>> identifier of the intellectual entity (IE, to use the term we're  
>> using
>> here locally), then everything after that is parseable either by  
>> going
>> one '/' forward or backward, and everything else is a parameter  
>> available
>> via the HTTPServletRequest.
>
> I didn't finish a thought (how unusual!).
>
> The idea was that there's a subject, predicate and object embedded in
> that URL, with the '?' acting as a delimiter or boundary of sorts:
>
>  http://www.acme.org/wiki/  pages/  PageName/  get/ ['?' optional  
> params]
> or
>  http://www.acme.org/wiki/  pages/  PageName/ '?' action=get
>
> abstracted as:
>
>  subject/  predicate/ [optional "adjectives"]
> or
>  subject/ '?' predicate [optional "adjectives"]
>
> which means parsing comes down to traveling one '/' from either the  
> end
> of the URL or from '?', if the latter exists. In either case I don't
> think we need regex.
>
> Murray
>
> ...........................................................................
> Murray Altheim <murray07 at altheim.com>                            
> ===  = =
> http://www.altheim.com/murray/                                     =  
> =  ===
> SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               =  
> =  = =
>
>      Boundless wind and moon - the eye within eyes,
>      Inexhaustible heaven and earth - the light beyond light,
>      The willow dark, the flower bright - ten thousand houses,
>      Knock at any door - there's one who will respond.
>                                      -- The Blue Cliff Record


Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Murray Altheim <mu...@altheim.com>.
Murray Altheim wrote:
[...]
> In the above scheme we can obtain the base URL, the collection hierarchy
> and object identifier all without regex, just parsing the '/' delimiters
> via indexOf(). If we use the '?' as the delimiter between the absolute
> identifier of the intellectual entity (IE, to use the term we're using
> here locally), then everything after that is parseable either by going
> one '/' forward or backward, and everything else is a parameter available
> via the HTTPServletRequest.

I didn't finish a thought (how unusual!).

The idea was that there's a subject, predicate and object embedded in
that URL, with the '?' acting as a delimiter or boundary of sorts:

   http://www.acme.org/wiki/  pages/  PageName/  get/ ['?' optional params]
or
   http://www.acme.org/wiki/  pages/  PageName/ '?' action=get

abstracted as:

   subject/  predicate/ [optional "adjectives"]
or
   subject/ '?' predicate [optional "adjectives"]

which means parsing comes down to traveling one '/' from either the end
of the URL or from '?', if the latter exists. In either case I don't
think we need regex.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Murray Altheim <mu...@altheim.com>.
Andrew Jaquith wrote:
[...]
> For 3.0, my preference has been to use a plain addressing scheme like 
> the current DefaultURLConstructor. It doesn't require any special 
> decoding/remapping on the inbound side, and outbound URL construction is 
> easy. However, an URL scheme like the one you suggested is good too. In 
> theory, we could use URLRewrite. Janne has also raised concerns about 
> performance because of its reliance on regular expressions. I am less 
> concerned about that, and more concerned about the fact that you need to 
> be able to reference the HTTP response object (and its encodeURL() 
> method) to make it work.

I'm not so concerned about regex parsing simply because I *think* it's
possible to design a URL schema that doesn't require it, iff that schema
is pretty exacting. I would myself prefer to avoid regex if possible, for
the reasons Janne has suggested, partly because the service I'm looking
at could become a real bottleneck since it's effectively being proposed
for use as a kind of proxy for a high-traffic web service (e.g., it
could in theory be a pass-through for all of a site's traffic).

> The other approach would be a new ("better") URL constructor scheme. 
> Either way, we will continue to need 1) a filter (to remap the incoming 
> URLs to a proper request format and forward the correct destination JSP) 
> and 2) some kind of URL construction algorithm.


> On Jul 7, 2008, at 4:24 PM, Murray Altheim wrote:
>>
>>   baseURL collectionHierarchy [objectId] action ['?' parameters]
>>
>> e.g.,
>>
>>   http://www.acme.org/wiki/  pages/  PageName/  get/

In the above scheme we can obtain the base URL, the collection hierarchy
and object identifier all without regex, just parsing the '/' delimiters
via indexOf(). If we use the '?' as the delimiter between the absolute
identifier of the intellectual entity (IE, to use the term we're using
here locally), then everything after that is parseable either by going
one '/' forward or backward, and everything else is a parameter available
via the HTTPServletRequest.

For example, we either assume the second-to-last '/'-delimited token is
the oid ("PageName"), with the last token the action:

   http://www.acme.org/wiki/pages/PageName/put/

or we obtain the action as a parameter and assume the last token is
the oid:

   http://www.acme.org/wiki/pages/PageName/?action=get

The former is *slightly* problematic if there is no oid, e.g.,

   http://www.acme.org/wiki/pages/search/?q=term

but that's possibly handled by counting tokens or simply not using an
oid at all

   http://www.acme.org/wiki/pages/?action=search?q=term
or
   http://www.acme.org/wiki/pages/?q=term   (search is implied by
                                             the presence of 'q')

The devil may be in the details but this *seems* like a workable plan.
If we want to permit a collection hierarchy rather than simply a flat
namespace this might get more complicated, but only if we permit an
arbitrary depth (something I don't need).

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Andrew Jaquith <an...@mac.com>.
Murray --

The kind of URL scheme you describe is very interesting, and it is  
indeed related to this whole discussion on URL construction.  
URLConstructor isn't the best name, really, because it actually  
understates its role. It also performs URL *parsing*.

My earlier message about URLRewrite relates to this. On the inbound  
side, "something" needs to transform the long URL (http://www.acme.org/wiki/pages/PageName/edit/ 
) into a proper resource path, with parsed and decoded parameters.  
URLRewrite does this, as a filter. So does our own WikiServlet filter,  
albeit not using the syntax you gave.

For 3.0, my preference has been to use a plain addressing scheme like  
the current DefaultURLConstructor. It doesn't require any special  
decoding/remapping on the inbound side, and outbound URL construction  
is easy. However, an URL scheme like the one you suggested is good  
too. In theory, we could use URLRewrite. Janne has also raised  
concerns about performance because of its reliance on regular  
expressions. I am less concerned about that, and more concerned about  
the fact that you need to be able to reference the HTTP response  
object (and its encodeURL() method) to make it work.

The other approach would be a new ("better") URL constructor scheme.  
Either way, we will continue to need 1) a filter (to remap the  
incoming URLs to a proper request format and forward the correct  
destination JSP) and 2) some kind of URL construction algorithm.

Andrew


On Jul 7, 2008, at 4:24 PM, Murray Altheim wrote:

> One of the things I've been working on (both related and unrelated to
> JSPWiki) is a web service URL schema providing read and write access
> to the wiki, in particular the wiki's page provider. Without going
> into detail about that I thought I might at least mention the idea
> of REST-fully regularizing *all* of the URLs used by JSPWiki to a
> common approach, i.e. (optional components in square brackets):
>
>   baseURL collectionHierarchy [objectId] action ['?' parameters]
>
> e.g.,
>
>   http://www.acme.org/wiki/  pages/  PageName/  get/
>
> This would in the future permit a collection hierarchy where 'pages/'
> currently exists, with 'PageName' as object ID (oid) potentially
> replaced by any kind of identifier (pages may be identified by name
> or by some other kind of identifier that survives across renames --
> title).
>
>   http://www.acme.org/wiki/pages/PageName/get/
>   http://www.acme.org/wiki/pages/PageName/edit/
>   http://www.acme.org/wiki/pages/PageName/put/
>   http://www.acme.org/wiki/pages/search/?q=term
>
> (the actual action names aren't important) or alternately, including
> the action name as a parameter:
>
>   http://www.acme.org/wiki/pages/PageName/?action=get
>   http://www.acme.org/wiki/pages/PageName/?action=edit
>   http://www.acme.org/wiki/pages/PageName/?action=put
>   http://www.acme.org/wiki/pages/?action=search&q=term
>
> allowing things like:
>
>   http://www.acme.org/wiki/pages/PageName/?action=get&format=html
>   http://www.acme.org/wiki/pages/PageName/?action=get&format=xml
>   http://www.acme.org/wiki/pages/PageName/?action=get&format=text
>
> etc., with advantages and disadvantages to each.
>
> Has there been any thought amongst other members of the team in  
> writing
> a more REST-ful URL constructor? Perhaps as the default? While I do
> understand dealing with legacy issues it'd be nice to just have a  
> simple,
> REST-ful URL that just worked. It's been one of those things I've  
> never
> been able to get working consistently in JSPWiki across all
> installations.
>
> I don't have it working yet but I basically have been writing a web
> service that would provide complete access to the wiki's functionality
> using a schema similar to the above. The question for me is how
> difficult it'd be in rewriting the JSPs to generate URLs as according
> to the web service instead of the existing setting, which of course
> led me to think that the whole web service is really just an  
> alternative
> URL constructor...
>
> Murray
>
> ...........................................................................
> Murray Altheim <murray07 at altheim.com>                            
> ===  = =
> http://www.altheim.com/murray/                                     =  
> =  ===
> SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               =  
> =  = =
>
>      Boundless wind and moon - the eye within eyes,
>      Inexhaustible heaven and earth - the light beyond light,
>      The willow dark, the flower bright - ten thousand houses,
>      Knock at any door - there's one who will respond.
>                                      -- The Blue Cliff Record


Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <ja...@iki.fi>.
I think using Stripes as you've previously outlined without using
CleanURIs is a good idea.  I figured that that is the baseline, and
that you are now proposing a delta which in my opinion is a mistake.

I've essentially been rehashing the same argument all over again -
Stripes CleanURIs do not fit the bill.  I just grew tired of typing
the same stuff again, so I became categorical.  All the arguments are
available in the previous emails.

/Janne

On Wed, Jul 09, 2008 at 09:43:21AM -0400, Andrew Jaquith wrote:
> Janne --
> 
> I was expecting constructive -- rather than categorical -- comments  
> from you. I did not perceive that you had many positive suggestions,  
> and that disappoints me.
> 
> I will respond in detail later, but not today.
> 
> Andrew
> 
> On Jul 9, 2008, at 3:01 AM, Janne Jalkanen wrote:
> 
> >>I actually prefer using the '/' since it sideways fits into my  
> >>existing
> >>URL schema. My schema:
> >>
> >> baseURL collectionHierarchy [objectId] action ['?' parameters]
> >>
> >>Janne's scheme (from what I understand):
> >>
> >> baseURL  [collectionHierarchy/objectId] action ['?' parameters]
> >
> >Close, but no.  The DefaultURLConstructor schema is
> >
> >baseURL action [collectionHierarchy/objectId] ['?' parameters].
> >
> >What I am just arguing that the schema that you want *requires*  
> >code.  Or mod_rewrite.  Can't be done with Stripes automatically.
> >
> >>be resolvable, which in this system means an absolute URL. If  
> >>Stripes is
> >>capable of parsing an arbitrary depth collection hierarchy (or  
> >>directory
> >>structure, if that's what we're essentially mirroring), then that's  
> >>fine.
> >
> >No, it cannot.
> >
> >>I really hope we don't have to use some ugly syntax for that. I don't
> >>have a requirement for arbitrary depth at all, nor can I foresee  
> >>that.
> >>It's just too ugly and complicated for most users. Wikis have been  
> >>flat
> >>since their inception and I'm fine with them being flat.
> >
> >The point is that you don't have to use them.  However, for some  
> >cases, the flat namespace is a problem (like the Weblog plugin -  
> >currently we have to rely on naming conventions to identify pages,  
> >and you know how much of a mess that becomes.  Would be much nicer  
> >to just embed them as subpages for the current page.)
> >
> >>It's really hard to imagine that annotations could be less flexible  
> >>than
> >>code.
> >
> >They are, since everything in them needs to be a static value.  It  
> >cannot be recomputed at runtime.
> >
> >>I don't see that as a barrier to adoption. And if we know we're  
> >>going to
> >>using Stripes in 3.0 I can't see any reason not to *begin* to use  
> >>it now.
> >
> >There is, since it requires a massive change to the internals of  
> >JSPWiki (or else it won't be useful).
> >
> >/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Andrew Jaquith <an...@mac.com>.
Janne --

I was expecting constructive -- rather than categorical -- comments  
from you. I did not perceive that you had many positive suggestions,  
and that disappoints me.

I will respond in detail later, but not today.

Andrew

On Jul 9, 2008, at 3:01 AM, Janne Jalkanen wrote:

>> I actually prefer using the '/' since it sideways fits into my  
>> existing
>> URL schema. My schema:
>>
>>  baseURL collectionHierarchy [objectId] action ['?' parameters]
>>
>> Janne's scheme (from what I understand):
>>
>>  baseURL  [collectionHierarchy/objectId] action ['?' parameters]
>
> Close, but no.  The DefaultURLConstructor schema is
>
> baseURL action [collectionHierarchy/objectId] ['?' parameters].
>
> What I am just arguing that the schema that you want *requires*  
> code.  Or mod_rewrite.  Can't be done with Stripes automatically.
>
>> be resolvable, which in this system means an absolute URL. If  
>> Stripes is
>> capable of parsing an arbitrary depth collection hierarchy (or  
>> directory
>> structure, if that's what we're essentially mirroring), then that's  
>> fine.
>
> No, it cannot.
>
>> I really hope we don't have to use some ugly syntax for that. I don't
>> have a requirement for arbitrary depth at all, nor can I foresee  
>> that.
>> It's just too ugly and complicated for most users. Wikis have been  
>> flat
>> since their inception and I'm fine with them being flat.
>
> The point is that you don't have to use them.  However, for some  
> cases, the flat namespace is a problem (like the Weblog plugin -  
> currently we have to rely on naming conventions to identify pages,  
> and you know how much of a mess that becomes.  Would be much nicer  
> to just embed them as subpages for the current page.)
>
>> It's really hard to imagine that annotations could be less flexible  
>> than
>> code.
>
> They are, since everything in them needs to be a static value.  It  
> cannot be recomputed at runtime.
>
>> I don't see that as a barrier to adoption. And if we know we're  
>> going to
>> using Stripes in 3.0 I can't see any reason not to *begin* to use  
>> it now.
>
> There is, since it requires a massive change to the internals of  
> JSPWiki (or else it won't be useful).
>
> /Janne


Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> I actually prefer using the '/' since it sideways fits into my  
> existing
> URL schema. My schema:
>
>   baseURL collectionHierarchy [objectId] action ['?' parameters]
>
> Janne's scheme (from what I understand):
>
>   baseURL  [collectionHierarchy/objectId] action ['?' parameters]

Close, but no.  The DefaultURLConstructor schema is

baseURL action [collectionHierarchy/objectId] ['?' parameters].

What I am just arguing that the schema that you want *requires*  
code.  Or mod_rewrite.  Can't be done with Stripes automatically.

> be resolvable, which in this system means an absolute URL. If  
> Stripes is
> capable of parsing an arbitrary depth collection hierarchy (or  
> directory
> structure, if that's what we're essentially mirroring), then that's  
> fine.

No, it cannot.

> I really hope we don't have to use some ugly syntax for that. I don't
> have a requirement for arbitrary depth at all, nor can I foresee that.
> It's just too ugly and complicated for most users. Wikis have been  
> flat
> since their inception and I'm fine with them being flat.

The point is that you don't have to use them.  However, for some  
cases, the flat namespace is a problem (like the Weblog plugin -  
currently we have to rely on naming conventions to identify pages,  
and you know how much of a mess that becomes.  Would be much nicer to  
just embed them as subpages for the current page.)

> It's really hard to imagine that annotations could be less flexible  
> than
> code.

They are, since everything in them needs to be a static value.  It  
cannot be recomputed at runtime.

> I don't see that as a barrier to adoption. And if we know we're  
> going to
> using Stripes in 3.0 I can't see any reason not to *begin* to use  
> it now.

There is, since it requires a massive change to the internals of  
JSPWiki (or else it won't be useful).

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Murray Altheim <mu...@altheim.com>.
Andrew Jaquith wrote:
> Interesting thread! You guys had me at a disadvantage -- I was on a 
> plane from Latin America this morning, and have not been able to respond 
> until now.
> 
> I think I smell a resolution in the air. It is, indeed, to use Stripes 
> as the "backing technology" for short URLs. Doing this gets us 
> compatibility with all three current URLConstructors. Here's why:
> 
> First, let me state what I think I heard from Janne.
> 
> #1: we have to stay compatible with ShortURLConstructor
> #2: we have to stay compatible with DefaultURLConstructor too
> #3: Janne has no interest in coming up with a new scheme, but is happy 
> to let "others" (read: Murray) go crazy if they want to, outside of the 
> core distro
> #4: despite restrictions 1, 2, and 3,  the URL scheme needs to somehow 
> accommodate subpages and wiki spaces
> #5: we assume that the delimiter for spaces and sub-pages is the same as 
> the one separating subpath in the URL (/)
> 
> Assumption #5 is dubious IMHO, but let's assume all of the others are 
> hard requirements. 

I actually prefer using the '/' since it sideways fits into my existing
URL schema. My schema:

   baseURL collectionHierarchy [objectId] action ['?' parameters]

Janne's scheme (from what I understand):

   baseURL  [collectionHierarchy/objectId] action ['?' parameters]

The resulting URL is the same in both cases but the schema different. If
we consider that the absolute oid is the combination of baseURL and
relative oid then it makes no difference. OTOH, if we consider that the
collection hierarchy can have an arbitrary depth but use a *different*
delimiter than '/' things might get problematic. But since Janne seems to
want '/' I think we're fine. In the end the Intellectual Entity needs to
be resolvable, which in this system means an absolute URL. If Stripes is
capable of parsing an arbitrary depth collection hierarchy (or directory
structure, if that's what we're essentially mirroring), then that's fine.

> Even with these constraints, we can still use 
> @URLBindings for inbound parsing. Here's why:
[...]
> So -- if we have 1) the DefaultURLConstructor covered via 
> stripes:useActionBean and 2) the ShortURLConstructor covered via 
> URLBindings, then by definition we also have 3) ShortViewURLConstructor 
> covered. Requirement #3 (other URL schemes) is not met, but there is 
> always mid_rewrite for those cases.
> 
> The wildcard here is what happens with wikispaces and nested pages. Best 
> case: Stripes does not care what is used as a delimiter, even a '/'. 
> Worst case: Stripes does care, so we use a different delimiter, like a 
> colon.

I really hope we don't have to use some ugly syntax for that. I don't
have a requirement for arbitrary depth at all, nor can I foresee that.
It's just too ugly and complicated for most users. Wikis have been flat
since their inception and I'm fine with them being flat.  I can say I
have *no* requirement for hierarchy, and if there was one I'd hope it
only go one level (i.e., I'd really hate to see subpages of subpages
of subpages on a wiki, it would add complexity, kill interoperability
and confuse the hell out of most people). Most of the requirements for
subpages can be handled in other ways, such as facets, tags, categories,
etc.

But I don't want to enter to deep into discussion about this as it's
a black hole.

> Now, this kind of throws out Murray's particular scenario, but it does 
> neatly give us, essentially, solid backwards compatibility and much 
> better request binding, and great forward compatibility. We would still 
> need an improved URL constructor class for the short URL case, which 
> would rely on the URLBindings for instructions on how to make the URLs.

I don't see how this doesn't work with my scenario; indeed it still seems
to fit. Since I *think* we see eye-to-eye on this please clarify.

> We would effectively be trading code for annotations. Personally, I 
> think that is a good thing, because it makes it easier to create new 
> ActionBeans (features!)

It's really hard to imagine that annotations could be less flexible than
code. If we begin to rely on Stripes and then in the future decide to
dump it, as I mentioned before, the essential API contract is the URL
schema and the messaging passed back and forth between the URL handler
and the application. If in dumping Stripes we had to manually construct
what Stripes is doing with annotations that would simply be an exercise;
I don't see that as a barrier to adoption. And if we know we're going to
using Stripes in 3.0 I can't see any reason not to *begin* to use it now.
What Andrew has proposed seems almost completely plugin-and-play with
what is current in the code base. If not, then I'm not understanding
him correctly.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Andrew Jaquith <an...@mac.com>.
Janne --

I have done some in-depth testing of clean URLs in Stripes 1.5-RC1.  
Based on my testing, I have concluded that there are several new facts  
you should be aware of.

1) Stripes clean URLs supports slashes inside of extracted parameters.  
That means sub-pages ("Foo/Bar/TestPage"), can be passed and they will  
be extracted. The existing (in my 3.0 branch) WikiPageTypeConverter  
would only need a small enhancement to properly locate pages with  
hierarchical paths.

2) When using the Stripes URLBuilder with an ActionBean, it constructs  
clean URLs, well, cleanly. Parameters not otherwise specified in the  
pattern are sensibly appended to the generated URL, as you would  
expect. This is good.

3) The Stripes UrlBindingFactory class that matches incoming URLs with  
UrlBindings does not use regular expressions, and looks fairly well- 
written and efficient. It does NOT, at this time, parse parameters  
appended to the clean URL. I have uploaded a patch to the Stripes JIRA  
site that adds this enhancement.

4) The UrlBindingFactory has many helper methods for parsing URLs that  
do NOT depend on @URLBinding class annotations. In particular, this  
means that URL binding definitions could be provided from an external  
source -- for example, a config file.

The cumulative effect of these facts means that the Stripes approach  
is viable. In short, I think you should re-consider your previous  
objections. :)

Now, as to your comments:

> I think it is a hard requirement, for the following reasons:

As I mentioned, my testing shows that clean URL parameter values that  
contain slashes are parsed correctly. You previously stated that  
"Stripes cannot guess when a slash is a part of a page name, and when  
it is an action." I assure you that it can, and with the ShortURL  
scheme in particular.

> Wrong.  It still won't cover the subpages or attachments.  Also, it  
> won't cover Murray's requirement.

It does. Also Murray and I have been talking about his requirements  
offline, and he is satisfied.

> So you're saying that we should not allow pluggable URI schemes?

You have previously stated that the "URL contract" is one of the most  
important "contracts" we have. I agree. However, that does not  
reconcile with your desire to have allowing pluggable URL schemes.

I happen to believe that URL scheme pluggability is NOT important. We  
should pick a good URL scheme (e.g., based on ShortURLs) and stick  
with it. And I am quite happy to enshrine the ShortURL scheme in code,  
as ActionBean annotations. The "long URL" case, as we have agreed, is  
already covered. We will have to disagree on this point.

That said, as I mentioned, UrlBindingFactory has the capabilities to  
allow us to add other bindings, not just those specified in the  
annotations.

> I disagree.  It won't give us a better request binding (as you point  
> out, Stripes will

It might. Have you looked at the URLConstructor code lately? There's  
more 'ifs' in those classes than a busload of wishful thinkers.

> and it won't give us backwards compatibility in the case someone is  
> using something else than Default or ShortViewURLConstructors.

Our implementation choices should not be constrained by edge cases  
that depart from the URL schemes that JSPWiki supports out of the box.  
Our compatibility contract is with our existing, URL schemes, not  
hypothetical outside ones.

That said, for those websites who choose to depart from the three  
established URL schemes (short, long aka default, and shortview),  
mod_rewrite is always an alternative. So too is a NON-annotation  
driven approach that externalizes the URL binding definitions and  
loads them up into URLBindingFactory.

> I don't think so.  I think we would be shifting complexity from one  
> layer to another, and removing features and introducing a faulty URL  
> scheme

Indeed, this whole discussion has been about exactly that -- shifting  
responsibility from a series of hard-coded classes that are inelegant  
and brittle to something better. When has that stopped us before?

Two last points:

First, the whole debate about using @UrlBindings in ActionBeans is  
kind of academic, because **even if we do nothing*** Stripes will use  
its own default URL binding scheme. For example, let's say we have  
PageActionBean, a hypothetical ActionBean that would hold our view- 
page logic. Without an @UrlBinding annotation, Stripes will  
automatically bind the bean to Page.action.

You have previously said that you were unhappy about this. Ok, then --  
let's try and put it into a format that is more JSPWiki-like.

Second, I believe the UrlBindingFactory class has us covered for  
alternative cases where users wish to use an alternative URL parsing/ 
generation scheme. These definitions could be externalized to a config  
file, for example, and loaded into the factory at runtime via the  
public method UrlBindingFactory.addBinding(beanType, binding). Stripes  
will happily use these bindings too. DAV could be externalized this  
way. So could other implementations. And they would all use the same  
syntax, which is EL-like, very powerful, and in my view quite nice.

Imagine we had an urlbindings.properties file. We could put stuff in  
it that looked like this:

PageActionBean.class=/wiki/{page}/?do={$event}
GroupActionBean.class=/groups/{group}/?do={$event}

You could add DAV bindings too, and any other bindings the user  
wanted. Nice and declarative. Doing it this way would be much more  
flexible than code, and would provide ways to supplement the default  
URL bindings with other ones.

Think about it, wouldja? :) This could really work -- and simplify our  
code base too.

Andrew

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> #5: we assume that the delimiter for spaces and sub-pages is the  
> same as the one separating subpath in the URL (/)
>
> Assumption #5 is dubious IMHO, but let's assume all of the others  
> are hard requirements. Even with these constraints, we can still  
> use @URLBindings for inbound parsing. Here's why:

I think it is a hard requirement, for the following reasons:

1) JCR uses slashes to denote paths.
2) Slashes are the Web de-facto standard for denoting hierarchy
3) As Murray points out in his mail, the URL schema is the single  
most important API contract that we have, so we should design that to  
be good first, *then* figure out how to implement it.  Exposing  
implementation detail is not a good thing there.
4) WebDAV uses slashed to denote paths (which means that if we choose  
to continue to develop the WebDAV API, it would be completely  
different.  At the moment, our attachments are WebDAV endpoints -  
yes, you can PROPFIND on an /attach/Main/foo.jpg if you want to.)
5) We are already using slashes to denote attachments.

> DefaultURLConstructor is just the JSP path with appended  
> parameters. Because every top-level JSP will have a  
> stripes:useActionBean tag in it, Stripes will automatically do its  
> magic resolve-bind-execute-event thing regardless, when the JSP is  
> directly addressed. So if we have URLs that are of the "default"  
> form, we are covered.

Yes, this is correct.  And our WikiServlet covers nicely all other  
URL schemes.

> As for "short form" URLs, our current URL syntax could be handled  
> by the "clean URL" @URLBinding syntax quite easily. Janne, you  
> might not realize this, but the clean URL format is more flexible  
> than you think. It does not require an exact match; just the firrst  
> part of the URL needs to match. If the remainder is a series of  
> appended parameters (in normal '&' syntax), these are bound as  
> normal parameters. So you do not need to specify an URLBinding that  
> includes absolutely every parameter you would ever need to bind --  
> just the important ones. That is exactly how short URLs work today,  
> no?

Wrong.  It still won't cover the subpages or attachments.  Also, it  
won't cover Murray's requirement.

(I've written two Stripes applications in the meantime ;-)

> So -- if we have 1) the DefaultURLConstructor covered via  
> stripes:useActionBean and 2) the ShortURLConstructor covered via  
> URLBindings, then by definition we also have 3)  
> ShortViewURLConstructor covered. Requirement #3 (other URL schemes)  
> is not met, but there is always mid_rewrite for those cases.

So you're saying that we should not allow pluggable URI schemes?

> The wildcard here is what happens with wikispaces and nested pages.  
> Best case: Stripes does not care what is used as a delimiter, even  
> a '/'. Worst case: Stripes does care, so we use a different  
> delimiter, like a colon.

Stripes does care, and I don't think we can use anything else.

> Now, this kind of throws out Murray's particular scenario, but it  
> does neatly give us, essentially, solid backwards compatibility and  
> much better request binding, and great forward compatibility. We  
> would still need an improved URL constructor class for the short  
> URL case, which would rely on the URLBindings for instructions on  
> how to make the URLs.

I disagree.  It won't give us a better request binding (as you point  
out, Stripes will be entirely happy to bind stuff with almost any URL  
with stripes:useActionBean - and the only real problem is the "page"  
parameter - everything else is a regular query string).  It won't  
give us forward compatibility because it cannot work with subpages,  
and it won't give us backwards compatibility in the case someone is  
using something else than Default or ShortViewURLConstructors.

> We would effectively be trading code for annotations. Personally, I  
> think that is a good thing, because it makes it easier to create  
> new ActionBeans (features!)

I don't think so.  I think we would be shifting complexity from one  
layer to another, and removing features and introducing a faulty URL  
scheme, forcing people like Murray to use Apache as a front-end.

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Andrew Jaquith <an...@mac.com>.
Interesting thread! You guys had me at a disadvantage -- I was on a  
plane from Latin America this morning, and have not been able to  
respond until now.

I think I smell a resolution in the air. It is, indeed, to use Stripes  
as the "backing technology" for short URLs. Doing this gets us  
compatibility with all three current URLConstructors. Here's why:

First, let me state what I think I heard from Janne.

#1: we have to stay compatible with ShortURLConstructor
#2: we have to stay compatible with DefaultURLConstructor too
#3: Janne has no interest in coming up with a new scheme, but is happy  
to let "others" (read: Murray) go crazy if they want to, outside of  
the core distro
#4: despite restrictions 1, 2, and 3,  the URL scheme needs to somehow  
accommodate subpages and wiki spaces
#5: we assume that the delimiter for spaces and sub-pages is the same  
as the one separating subpath in the URL (/)

Assumption #5 is dubious IMHO, but let's assume all of the others are  
hard requirements. Even with these constraints, we can still use  
@URLBindings for inbound parsing. Here's why:

DefaultURLConstructor is just the JSP path with appended parameters.  
Because every top-level JSP will have a stripes:useActionBean tag in  
it, Stripes will automatically do its magic resolve-bind-execute-event  
thing regardless, when the JSP is directly addressed. So if we have  
URLs that are of the "default" form, we are covered.

As for "short form" URLs, our current URL syntax could be handled by  
the "clean URL" @URLBinding syntax quite easily. Janne, you might not  
realize this, but the clean URL format is more flexible than you  
think. It does not require an exact match; just the firrst part of the  
URL needs to match. If the remainder is a series of appended  
parameters (in normal '&' syntax), these are bound as normal  
parameters. So you do not need to specify an URLBinding that includes  
absolutely every parameter you would ever need to bind -- just the  
important ones. That is exactly how short URLs work today, no?

So -- if we have 1) the DefaultURLConstructor covered via  
stripes:useActionBean and 2) the ShortURLConstructor covered via  
URLBindings, then by definition we also have 3)  
ShortViewURLConstructor covered. Requirement #3 (other URL schemes) is  
not met, but there is always mid_rewrite for those cases.

The wildcard here is what happens with wikispaces and nested pages.  
Best case: Stripes does not care what is used as a delimiter, even a  
'/'. Worst case: Stripes does care, so we use a different delimiter,  
like a colon.

Now, this kind of throws out Murray's particular scenario, but it does  
neatly give us, essentially, solid backwards compatibility and much  
better request binding, and great forward compatibility. We would  
still need an improved URL constructor class for the short URL case,  
which would rely on the URLBindings for instructions on how to make  
the URLs.

We would effectively be trading code for annotations. Personally, I  
think that is a good thing, because it makes it easier to create new  
ActionBeans (features!)

Andrew

On Jul 8, 2008, at 12:03 PM, Janne Jalkanen <Ja...@ecyrd.com>  
wrote:

>> I'm thinking that perhaps Andrew and I might be able to fix it via
>> Stripes. I don't know how big the library is but if it's not big we
>> could possibly introduce Stripes into the mix as the backing  
>> technology
>> for the ShortURLConstructor, which would ease *everyone* into the 3.0
>> path since they could begin to use the new schema for all new sites
>>
> I don't really see any way that we could use Stripes here.  And  
> personally, I would not use a new scheme...  So it certainly  
> wouldn't help my job ;-)
>
>> The 'collectionHierarchy' is in the current wiki a single token but
>> *could* be deeper. Given I don't think we'd want arbitrary depth
>> (I may be wrong) then there's only the possibility that we might
>> go from "Main" to "Main/SubMain". That shouldn't be a big problem
>> if we design the schema such that the verb is either at the very
>> end or part of the query. So "Main/edit" can only be a page reference
>> if it's "Main/edit/verb/" (e.g., "Main/edit/edit/") or
>> "Main/edit/?action=verb". This shouldn't be a problem.
>
> It is, because Stripes CleanURLs assume static paths - item #1 is  
> always something, item #2 is something else, etc.  Stripes cannot  
> guess when a slash is a part of a page name, and when it is an  
> action.  The CleanURLs are nice, if you are developing an app from  
> scratch.  It's not so nice trying to retrofit existing URLs.
>
> This means a separate parser, and that means an URLConstructor (or  
> something similar).  Which again means that Stripes is nice, but I  
> think this particular idea is wholly unsuited for the problem at hand.
>
>>
>>> Well, the URIs *are* already RESTful. ;-)
>>> (In fact, /Edit.jsp?page=Foo is also RESTful.  Most people just  
>>> like to hide the technology [jsp in this case] by using neutral  
>>> URIs like /edit/Foo).
>>
>> Yes, I have an absolute, unbendable requirement that we have to hide
>> implementation details from the URLs. So if one's definition of  
>> RESTful
>> includes hiding implementation details (and mine does), then this  
>> is a
>> necessity. In my actual case it is a requirement.
>
> Well, you are entitled to define the words anyway you want, but  
> don't expect us to adhere to the same definitions.  JSPWiki is  
> already RESTful in the commonly agreed definition.
>
>> etc. I'd also like to be able to do PUTs via a RESTful interface in
>> addition to the human UI so we can remotely populate a wiki from an
>> external site, for synchronization, etc.
>
> I highly recommend that you implement the Atom Publishing Protocol  
> then.  It's pretty much the standard these days.  We have the basics  
> in place, but we should really switch to a better library, since the  
> current implementation does not support APP 1.0.
>
> The other possibility is to start working on the DAV interface  
> (which defines all your metadata stuff in a commonly agreed language  
> instead of redefining the meaning of the HTTP verb HEAD ;-).  The  
> DAV stuff mostly works, but it's client-specific.
>
> Both are REST.
>
> I'm not sure whether we would need a third one.
>
> /Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> I'm thinking that perhaps Andrew and I might be able to fix it via
> Stripes. I don't know how big the library is but if it's not big we
> could possibly introduce Stripes into the mix as the backing  
> technology
> for the ShortURLConstructor, which would ease *everyone* into the 3.0
> path since they could begin to use the new schema for all new sites
>
I don't really see any way that we could use Stripes here.  And  
personally, I would not use a new scheme...  So it certainly wouldn't  
help my job ;-)

> The 'collectionHierarchy' is in the current wiki a single token but
> *could* be deeper. Given I don't think we'd want arbitrary depth
> (I may be wrong) then there's only the possibility that we might
> go from "Main" to "Main/SubMain". That shouldn't be a big problem
> if we design the schema such that the verb is either at the very
> end or part of the query. So "Main/edit" can only be a page reference
> if it's "Main/edit/verb/" (e.g., "Main/edit/edit/") or
> "Main/edit/?action=verb". This shouldn't be a problem.

It is, because Stripes CleanURLs assume static paths - item #1 is  
always something, item #2 is something else, etc.  Stripes cannot  
guess when a slash is a part of a page name, and when it is an  
action.  The CleanURLs are nice, if you are developing an app from  
scratch.  It's not so nice trying to retrofit existing URLs.

This means a separate parser, and that means an URLConstructor (or  
something similar).  Which again means that Stripes is nice, but I  
think this particular idea is wholly unsuited for the problem at hand.

>
>> Well, the URIs *are* already RESTful. ;-)
>> (In fact, /Edit.jsp?page=Foo is also RESTful.  Most people just  
>> like to hide the technology [jsp in this case] by using neutral  
>> URIs like /edit/Foo).
>
> Yes, I have an absolute, unbendable requirement that we have to hide
> implementation details from the URLs. So if one's definition of  
> RESTful
> includes hiding implementation details (and mine does), then this is a
> necessity. In my actual case it is a requirement.

Well, you are entitled to define the words anyway you want, but don't  
expect us to adhere to the same definitions.  JSPWiki is already  
RESTful in the commonly agreed definition.

> etc. I'd also like to be able to do PUTs via a RESTful interface in
> addition to the human UI so we can remotely populate a wiki from an
> external site, for synchronization, etc.

I highly recommend that you implement the Atom Publishing Protocol  
then.  It's pretty much the standard these days.  We have the basics  
in place, but we should really switch to a better library, since the  
current implementation does not support APP 1.0.

The other possibility is to start working on the DAV interface (which  
defines all your metadata stuff in a commonly agreed language instead  
of redefining the meaning of the HTTP verb HEAD ;-).  The DAV stuff  
mostly works, but it's client-specific.

Both are REST.

I'm not sure whether we would need a third one.

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Murray Altheim <mu...@altheim.com>.
Janne Jalkanen wrote:
>> Yes, understood. I'm thinking it might be a fourth URLConstructor scheme
>> since it won't completely replace (plug-and-play wise) any of the
>> existing schemes. And as I mentioned to Andrew, I'd like to be able to
>> literally re-use it to invoke another web service layer on top of
>> JSPWiki (for preservation, interwiki, and other potential services).
> 
> If you're in a hurry, I would look into a specific URLConstructor...  I 
> doubt 3.0 will be ready for a long time.

Understood -- as I mentioned just a minute ago, I'd hope we could get
this developed as an add-on that would *also* work with 3.0.

>> I'm not much on hype myself, and while I do agree that the 
>> ShortURLConstructor
>> is either very close to or exactly matching the URL schema I'm 
>> considering,
>> there are some problems with the existing implementation *and* I believe
>> I may have a requirement to load the verb on as the latter token rather
>> than being included in the query string. I don't want to quibble over the
>> definition of RESTful either, but I may need to replace that latter URL
> 
> You could fix the ShortURLConstructor ;-)

I'm thinking that perhaps Andrew and I might be able to fix it via
Stripes. I don't know how big the library is but if it's not big we
could possibly introduce Stripes into the mix as the backing technology
for the ShortURLConstructor, which would ease *everyone* into the 3.0
path since they could begin to use the new schema for all new sites
once we made the new constructor available (as option #4 potentially,
if a complete replacement of ShortURLConstructor isn't feasible or the
URL schema doesn't quite match ShortURLConstructor's, and I don't think
it does exactly).

>>    ShortURLConstructor - uses path-like reference style:
>>
>>          http://mywiki.com/jspwiki/wiki/Main
>>          http://mywiki.com/jspwiki/wiki/Main?do=Edit
>>
>> with
>>
>>          http://mywiki.com/jspwiki/wiki/Main/edit/
> 
> Both of these are RESTful, with the added bonus that the latter will 
> break once we have sub-pages and someone creates a page called "Main/edit".
> 
> Which, BTW, is also a big problem with CleanURIs.

No, I don't think you noticed the schema design then:

    baseURL collectionHierarchy [objectId] action ['?' parameters]

The 'collectionHierarchy' is in the current wiki a single token but
*could* be deeper. Given I don't think we'd want arbitrary depth
(I may be wrong) then there's only the possibility that we might
go from "Main" to "Main/SubMain". That shouldn't be a big problem
if we design the schema such that the verb is either at the very
end or part of the query. So "Main/edit" can only be a page reference
if it's "Main/edit/verb/" (e.g., "Main/edit/edit/") or
"Main/edit/?action=verb". This shouldn't be a problem.

>> Yes, certainly. We're dealing with government/corporate cooperative team
>> designing and implementing an enormous application that is entirely built
>> on this principle. There are RESTful URLs all through the application and
>> I've got a requirement to hook JSPWiki into that. It would be lovely if
>> the URLs that the user sees when using the wiki are the *same* ones (or
>> are from at least the same schema) as the ones hooking the wiki into the
>> preservation system, which is why I'm excited by Andrew's latest missive.
> 
> Well, the URIs *are* already RESTful. ;-)
> 
> (In fact, /Edit.jsp?page=Foo is also RESTful.  Most people just like to 
> hide the technology [jsp in this case] by using neutral URIs like 
> /edit/Foo).

Yes, I have an absolute, unbendable requirement that we have to hide
implementation details from the URLs. So if one's definition of RESTful
includes hiding implementation details (and mine does), then this is a
necessity. In my actual case it is a requirement.

Another aspect of this I haven't mentioned is that we do want to
implement the full REST set of verbs, e.g., we want a HEAD request
(whatever it's called, doesn't matter) to deliver metadata about
a record, e.g.,

  // delivers default metadata
  http://mywiki.com/jspwiki/wiki/Main/meta/

  // delivers METS metadata
  http://mywiki.com/jspwiki/wiki/Main/meta/?schema=mets

  // delivers DC-XML metadata
  http://mywiki.com/jspwiki/wiki/Main/meta/?schema=dcxml

etc. I'd also like to be able to do PUTs via a RESTful interface in
addition to the human UI so we can remotely populate a wiki from an
external site, for synchronization, etc.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> Yes, understood. I'm thinking it might be a fourth URLConstructor  
> scheme
> since it won't completely replace (plug-and-play wise) any of the
> existing schemes. And as I mentioned to Andrew, I'd like to be able to
> literally re-use it to invoke another web service layer on top of
> JSPWiki (for preservation, interwiki, and other potential services).

If you're in a hurry, I would look into a specific URLConstructor...   
I doubt 3.0 will be ready for a long time.

> I'm not much on hype myself, and while I do agree that the  
> ShortURLConstructor
> is either very close to or exactly matching the URL schema I'm  
> considering,
> there are some problems with the existing implementation *and* I  
> believe
> I may have a requirement to load the verb on as the latter token  
> rather
> than being included in the query string. I don't want to quibble  
> over the
> definition of RESTful either, but I may need to replace that latter  
> URL

You could fix the ShortURLConstructor ;-)

>
>    ShortURLConstructor - uses path-like reference style:
>
>          http://mywiki.com/jspwiki/wiki/Main
>          http://mywiki.com/jspwiki/wiki/Main?do=Edit
>
> with
>
>          http://mywiki.com/jspwiki/wiki/Main/edit/

Both of these are RESTful, with the added bonus that the latter will  
break once we have sub-pages and someone creates a page called "Main/ 
edit".

Which, BTW, is also a big problem with CleanURIs.

> Yes, certainly. We're dealing with government/corporate cooperative  
> team
> designing and implementing an enormous application that is entirely  
> built
> on this principle. There are RESTful URLs all through the  
> application and
> I've got a requirement to hook JSPWiki into that. It would be  
> lovely if
> the URLs that the user sees when using the wiki are the *same* ones  
> (or
> are from at least the same schema) as the ones hooking the wiki  
> into the
> preservation system, which is why I'm excited by Andrew's latest  
> missive.

Well, the URIs *are* already RESTful. ;-)

(In fact, /Edit.jsp?page=Foo is also RESTful.  Most people just like  
to hide the technology [jsp in this case] by using neutral URIs like / 
edit/Foo).

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Murray Altheim <mu...@altheim.com>.
Janne Jalkanen wrote:
>> I have a strong requirement for a REST-ful scheme, with some
>> flexibility on the definition of REST-ful. One thing I didn't
> 
> Remember that we can't break existing URL schemes.  So essentially we 
> are talking about replacing the current URLConstructor scheme with 
> another URLConstructor scheme, which may or may not rely on Stripes 
> artifacts.

Yes, understood. I'm thinking it might be a fourth URLConstructor scheme
since it won't completely replace (plug-and-play wise) any of the
existing schemes. And as I mentioned to Andrew, I'd like to be able to
literally re-use it to invoke another web service layer on top of
JSPWiki (for preservation, interwiki, and other potential services).

> IMO RESTful has become an overloaded hypeword these days.  You can look 
> at it this way: we already *are* RESTful.  *All* applications which use 
> the browser are RESTful.  REST does not mean "we will not use query 
> string".  REST means that every resource is accessible through an unique 
> link (and that it's stateless, which we mostly are anyway).

I'm not much on hype myself, and while I do agree that the ShortURLConstructor
is either very close to or exactly matching the URL schema I'm considering,
there are some problems with the existing implementation *and* I believe
I may have a requirement to load the verb on as the latter token rather
than being included in the query string. I don't want to quibble over the
definition of RESTful either, but I may need to replace that latter URL

    ShortURLConstructor - uses path-like reference style:

          http://mywiki.com/jspwiki/wiki/Main
          http://mywiki.com/jspwiki/wiki/Main?do=Edit

with

          http://mywiki.com/jspwiki/wiki/Main/edit/

(both lowercased and potentially a different choice than "edit" (it won't
be up to me though I'll have some influence).

> When it comes to the machine-accessible APIs, then REST becomes a far 
> more useful paradigm (as opposed to things like XML-RPC and SOAP).  
> There is no single endpoint, but you use the same kind of an API to 
> access your data as with the regular browser.

Yes, certainly. We're dealing with government/corporate cooperative team
designing and implementing an enormous application that is entirely built
on this principle. There are RESTful URLs all through the application and
I've got a requirement to hook JSPWiki into that. It would be lovely if
the URLs that the user sees when using the wiki are the *same* ones (or
are from at least the same schema) as the ones hooking the wiki into the
preservation system, which is why I'm excited by Andrew's latest missive.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> I have a strong requirement for a REST-ful scheme, with some
> flexibility on the definition of REST-ful. One thing I didn't

Remember that we can't break existing URL schemes.  So essentially we  
are talking about replacing the current URLConstructor scheme with  
another URLConstructor scheme, which may or may not rely on Stripes  
artifacts.

IMO RESTful has become an overloaded hypeword these days.  You can  
look at it this way: we already *are* RESTful.  *All* applications  
which use the browser are RESTful.  REST does not mean "we will not  
use query string".  REST means that every resource is accessible  
through an unique link (and that it's stateless, which we mostly are  
anyway).

When it comes to the machine-accessible APIs, then REST becomes a far  
more useful paradigm (as opposed to things like XML-RPC and SOAP).   
There is no single endpoint, but you use the same kind of an API to  
access your data as with the regular browser.

/Janne

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Murray Altheim <mu...@altheim.com>.
Janne Jalkanen wrote:
>>    http://www.acme.org/wiki/pages/PageName/?action=get
>>    http://www.acme.org/wiki/pages/PageName/?action=edit
>>    http://www.acme.org/wiki/pages/PageName/?action=put
>>    http://www.acme.org/wiki/pages/?action=search&q=term
> 
> The ShortURLConstructor does just this.
> 
> Unfortunately, it's not very well tested, and is known to break some 
> things, like FCK and WikiWizard.

And I've never once got the ShortURLConstructor to work reliably
on any system (Apache/Tomcat or Jetty) I've used, after much time
and frustration. I don't think that's uncommon, and on looking at
the code I've not figured out what was going wrong. I like the
idea of having a front end request manager that acts as a web
service layer to the wiki, especially if it is in effect modular.

I have a strong requirement for a REST-ful scheme, with some
flexibility on the definition of REST-ful. One thing I didn't
mention (and Andrew's Stripes proposal might provide) is a
web service approach to both the JSPWiki instance *and* a
second web service that could either be a layer on top of
JSPWiki or literally a separate application that accessed the
wiki's repository. Since it needs to share the same JVM likely
a layer, and if it was able to hand requests off to JSPWiki
*or* something I've written, well, that's basically what I'm
looking for in a nutshell.

So the Stripes approach is quite exciting, really.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: REST-ful URLs [Was: url rewriting supported?]

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
>    http://www.acme.org/wiki/pages/PageName/?action=get
>    http://www.acme.org/wiki/pages/PageName/?action=edit
>    http://www.acme.org/wiki/pages/PageName/?action=put
>    http://www.acme.org/wiki/pages/?action=search&q=term

The ShortURLConstructor does just this.

Unfortunately, it's not very well tested, and is known to break some  
things, like FCK and WikiWizard.

/Janne