All,

I am considering using Restlet to code up a simulator of an external
website and would appreciate some comments / help. The problem is that
the external URLs are ugly and not RESTian at all, see the examples
below. Does this preclude me from using Restlet in the first place as
I I've read the router doesn't take the query part of the URL into
account? I've looked through the tutorial and I've taken a quick look
at the source for Template and Variable but I haven't yet figured out
how the router matching/scoring works.

In the case of each example URL below, there may be additional
parameters that aren't relevant to the routing in both the POST and
GET URLs. The POST URLs will also have form-url-encoded parameters in
the body.

Example URLs (and desired mappings)
POST 
/internal/kb.portal?_pageLabel=LOG&_actionOverride=/portlet/internal/logon/logOn
--> Logon resource
POST 
/internal/kb.portal?_pageLabel=LOG&_actionOverride=/portlet/internal/logOff/logOff
--> Logoff resource
POST 
/internal/kb.portal?_pageLabel=SCH&_actionOverride=/portlet/internal/search/prepare
--> Search resource

GET 
/internal/kb.portal?_pageLabel=VIEW&_actionOverride=/portlet/internal/order/summary
--> OrderSummary resource
GET 
/internal/kb.portal?_pageLabel=VIEW&_actionOverride=/portlet/internal/order/history
--> OrderHistory resource
GET 
/internal/kb.portal?_pageLabel=VIEW&_actionOverride=/portlet/internal/order/payment
--> OrderPayments resource

Example code (that doesn't work at present ... with all the routes
above configured, all requests are routed to the last resource to be
attached):
<code>
        Router router = new Router(getContext());
        Route logonRoute =
router.attach("/internal/kb.portal?_pageLabel={page}&_actionOverride={action}&{other}",
resources.Logon.class);
        Map<String, Variable> logonVariables =
logonRoute.getTemplate().getVariables();
        logonVariables.put("page", new
Variable(Variable.TYPE_URI_QUERY, "LOG", true, true)); // required,
fixed
        logonVariables.put("action", new
Variable(Variable.TYPE_URI_QUERY, "/portlet/internal/logon/logOn",
true, true)); // required, fixed, decode, encode
        ...
</code>

So, can it be done with Restlet?

Thanks,
redentis

Reply via email to