Skip to content
Snippets Groups Projects
Commit cf23e0f2 authored by felmer's avatar felmer
Browse files

SP-239, SWE-6: bug fixed: Remove file part from URL to get the application URL

SVN: 26474
parent 6888ad57
No related branches found
No related tags found
No related merge requests found
...@@ -30,8 +30,8 @@ public class WebAppUrl ...@@ -30,8 +30,8 @@ public class WebAppUrl
private URLMethodWithParameters builder; private URLMethodWithParameters builder;
public WebAppUrl(String openbisProtocol, String openbisHost, String applicationURL, public WebAppUrl(String openbisProtocol, String openbisHost, String url, String webAppCode,
String webAppCode, String sessionId) String sessionId)
{ {
if (openbisProtocol == null) if (openbisProtocol == null)
{ {
...@@ -41,7 +41,7 @@ public class WebAppUrl ...@@ -41,7 +41,7 @@ public class WebAppUrl
{ {
throw new IllegalArgumentException("OpenBIS host cannot be null"); throw new IllegalArgumentException("OpenBIS host cannot be null");
} }
if (applicationURL == null) if (url == null)
{ {
throw new IllegalArgumentException("OpenBIS applicationURL cannot be null"); throw new IllegalArgumentException("OpenBIS applicationURL cannot be null");
} }
...@@ -53,6 +53,12 @@ public class WebAppUrl ...@@ -53,6 +53,12 @@ public class WebAppUrl
{ {
throw new IllegalArgumentException("Session id cannot be null"); 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 = builder =
new URLMethodWithParameters(openbisProtocol + "//" + openbisHost + applicationURL new URLMethodWithParameters(openbisProtocol + "//" + openbisHost + applicationURL
+ "webapp/" + webAppCode + "/"); + "webapp/" + webAppCode + "/");
......
...@@ -30,7 +30,7 @@ public class WebAppUrlTest ...@@ -30,7 +30,7 @@ public class WebAppUrlTest
{ {
@Test @Test
public void testUrlWithoutParameters() public void testApplicationUrlWithoutParameters()
{ {
WebAppUrl url = WebAppUrl url =
new WebAppUrl("http:", "localhost:8888", "/openbis/", "webapp1", "mysessionid"); new WebAppUrl("http:", "localhost:8888", "/openbis/", "webapp1", "mysessionid");
...@@ -39,6 +39,17 @@ public class WebAppUrlTest ...@@ -39,6 +39,17 @@ public class WebAppUrlTest
url.toString()); 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 @Test
public void testUrlWithNullParameters() public void testUrlWithNullParameters()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment