Hi,
I'm working on GSIP39 and I've stumbled in some odd
code in the REST and RESTConfig modules, so I'm looking
for some clarifications.
The first bit of code is in RESTDispatcher, line 146:
---------------------------------------------------------
//set the page uri's, proxying if necessary
String rootURI = request.getRootRef().toString();
String baseURI = null;
if ( request.getResourceRef().getBaseRef() != null ) {
baseURI = request.getResourceRef().getBaseRef().toString();
}
String pageURI = request.getResourceRef().toString();
if ( gs.getGlobal().getProxyBaseUrl() != null ) {
String host =
RequestUtils.proxifiedBaseURL(request.getHostRef().toString(), gs.getGlobal().getProxyBaseUrl());
rootURI = ResponseUtils.appendPath( host, request.getRootRef().getPath() );
baseURI = baseURI != null ?
ResponseUtils.appendPath( host, request.getResourceRef().getBaseRef().getPath() ) : baseURI;
pageURI = ResponseUtils.appendPath( host, request.getResourceRef().getPath() );
}
---------------------------------------------------------
Three URI are built, root, base and page, which are
then stored in "PageInfo".
First off, what is the meaning of the three uris?
I don't see it explained anywhere.
Second thing I've noticed is that PageInfo.baseURI is not used
anywhere, so I'm wondering why it is built to start with.
Another thing to notice is that the rootURI is two
different beasts depending on whether proxying is enabled.
If there is no proxing debugging in the tests I get:
rootURI=http://localhost/geoserver/rest
but if proxying is enabled, host ref is used, meaning
rootURI=http://localhost
before passing it down to the proxyfing code...
Unfortunately none of the two is what the proxy code expects,
the baseURL expected by the code is "http://host:port/appname" instead,
something I don't know, in general, how to extract out
of a restlet request.
To sum up, what I'd need to properly handle the url
building with the URLManglers is:
- the meaning of the three URI above
- how to get the proper context path out of that restlet
request
One final thing I've noticed is that the URLs are built
piecemeal in various places in the rest code, that needs
to change as the url manglers can (and will in Tike case)
append kvp parameters to the URL.
So it's not possible to mangle the url in one place and
then adding path and kvp pieces of it later, everything
has to be available in the place where the final URL
is built.
It does not look too bad thought, the only place I
can see that builds urls is CatalogResourceBase.
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.