Skip to content
Snippets Groups Projects
Commit 0d08a5f8 authored by cramakri's avatar cramakri
Browse files

LMS-1527 Automatically detect openbis url.

SVN: 15973
parent 9db03c96
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
package ch.systemsx.cisd.openbis.plugin.query.client.api.v1; package ch.systemsx.cisd.openbis.plugin.query.client.api.v1;
import ch.systemsx.cisd.common.spring.HttpInvokerUtils; import ch.systemsx.cisd.common.spring.HttpInvokerUtils;
import ch.systemsx.cisd.openbis.generic.shared.DefaultLimsServiceStubFactory;
import ch.systemsx.cisd.openbis.generic.shared.OpenBisServiceFactory;
import ch.systemsx.cisd.openbis.plugin.query.server.api.v1.ResourceNames; import ch.systemsx.cisd.openbis.plugin.query.server.api.v1.ResourceNames;
import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.IQueryApiServer; import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.IQueryApiServer;
...@@ -29,14 +31,24 @@ public class FacadeFactory ...@@ -29,14 +31,24 @@ public class FacadeFactory
{ {
private static final int SERVER_TIMEOUT_MIN = 5; private static final int SERVER_TIMEOUT_MIN = 5;
// Trick for discovering the server Url
private static String getServiceUrl(String serverUrl)
{
OpenBisServiceFactory openBisServiceFactory =
new OpenBisServiceFactory(serverUrl, new DefaultLimsServiceStubFactory());
openBisServiceFactory.createService();
return openBisServiceFactory.getUsedServerUrl() + ResourceNames.QUERY_PLUGIN_SERVER_URL;
}
/** /**
* Creates a facade for specified server URL, user Id, and password. * Creates a facade for specified server URL, user Id, and password.
*/ */
public static IQueryApiFacade create(String serverURL, String userID, String password) public static IQueryApiFacade create(String serverURL, String userID, String password)
{ {
String serviceUrl = getServiceUrl(serverURL);
IQueryApiServer service = IQueryApiServer service =
HttpInvokerUtils.createServiceStub(IQueryApiServer.class, serverURL HttpInvokerUtils.createServiceStub(IQueryApiServer.class, serviceUrl,
+ ResourceNames.QUERY_PLUGIN_SERVER_URL, SERVER_TIMEOUT_MIN); SERVER_TIMEOUT_MIN);
String sessionToken = service.tryToAuthenticateAtQueryServer(userID, password); String sessionToken = service.tryToAuthenticateAtQueryServer(userID, password);
if (sessionToken == null) if (sessionToken == null)
{ {
......
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