Inconsistent use of org.opennms.web.api.Util.calculateUrlBase( request )
Description
org.opennms.web.api.Util.calculateUrlBase( request ) is used throughout the OpenNMS web UI to compute the base URL. Unfortunately it's not used consistently. Sometimes when it's used it's assumed that the returned value has a trailing backslash. For example it is used in the ActionDiscoveryServlet like this:
I took a slightly different tack with this. calculateUrlBase() should always return a /, but I'm not sure that means substituteUrl() should (since it would technically be up to the pattern to decide what the contents of the URL should be). So, I fixed calculateUrlBase() to enforce a /, rather than doing it in substituteUrl().
I then made a new method calculateUrlBase( request, url ) which will Do The Right Thing as far as slashes go, and changed code to use it where available.
Jeffrey Ollie May 5, 2011 at 9:06 AM
I've now had a chance to try out the patch and it seems to work well so far.
org.opennms.web.api.Util.calculateUrlBase( request ) is used throughout the OpenNMS web UI to compute the base URL. Unfortunately it's not used consistently. Sometimes when it's used it's assumed that the returned value has a trailing backslash. For example it is used in the ActionDiscoveryServlet like this:
response.sendRedirect(Util.calculateUrlBase(request)+"event/query?msgmatchany=Discovery");
In other cases a backslash is added, as in NodeLabelChangeServlet:
response.sendRedirect(Util.calculateUrlBase(request) + "/element/node.jsp?node=" + nodeIdString);
This causes some URLs in the web UI to have a double backslash, that causes a 404 because
of the extra backslash:
http://myhost:8980/opennms//element/node.jsp?node=17
I've attached a patch that compiles, but hasn't been tested yet...