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:

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...

Environment

Fedora 15, opennms-core-1.9.8-0.20110503.0.noarch, opennms-webapp-jetty-1.9.8-0.20110503.0.noarch, java-1.6.0-openjdk-1.6.0.0-55.1.10.fc15.x86_64

Acceptance / Success Criteria

None

Attachments

1

Lucidchart Diagrams

Activity

Benjamin Reed May 5, 2011 at 3:23 PM

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.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

PagerDuty

Created May 3, 2011 at 5:17 PM
Updated January 27, 2017 at 4:20 PM
Resolved May 5, 2011 at 3:23 PM