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
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 + "/");
......
......@@ -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()
{
......
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