diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrl.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrl.java index 4b8a52405407906920c95670602df301b93ad688..419a735f993f916e98f0de1ecbb73fbf69612087 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrl.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrl.java @@ -30,8 +30,8 @@ public class WebAppUrl private URLMethodWithParameters builder; - public WebAppUrl(String openbisProtocol, String openbisHost, String applicationURL, - String webAppCode, String sessionId) + public WebAppUrl(String openbisProtocol, String openbisHost, String url, String webAppCode, + String sessionId) { if (openbisProtocol == null) { @@ -41,7 +41,7 @@ public class WebAppUrl { throw new IllegalArgumentException("OpenBIS host cannot be null"); } - if (applicationURL == null) + if (url == null) { throw new IllegalArgumentException("OpenBIS applicationURL cannot be null"); } @@ -53,6 +53,12 @@ public class WebAppUrl { throw new IllegalArgumentException("Session id cannot be null"); } + String applicationURL = url; + if (url.endsWith("/") == false) + { + int lastIndexFileDelim = url.lastIndexOf('/'); + applicationURL = url.substring(0, lastIndexFileDelim + 1); + } builder = new URLMethodWithParameters(openbisProtocol + "//" + openbisHost + applicationURL + "webapp/" + webAppCode + "/"); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrlTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrlTest.java index 4fb09ffcaa0d56f289e0f3c167e51d7003f39ff7..29e12192869e12a74d47b07a7c4a7d782c1ecfbd 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrlTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/webapp/WebAppUrlTest.java @@ -30,7 +30,7 @@ public class WebAppUrlTest { @Test - public void testUrlWithoutParameters() + public void testApplicationUrlWithoutParameters() { WebAppUrl url = new WebAppUrl("http:", "localhost:8888", "/openbis/", "webapp1", "mysessionid"); @@ -39,6 +39,17 @@ public class WebAppUrlTest url.toString()); } + @Test + public void testFileUrlWithoutParameters() + { + WebAppUrl url = + new WebAppUrl("http:", "localhost:8888", "/openbis/index.html", "webapp1", + "mysessionid"); + assertEquals( + "http://localhost:8888/openbis/webapp/webapp1/?webapp-code=webapp1&session-id=mysessionid", + url.toString()); + } + @Test public void testUrlWithNullParameters() {