diff --git a/api-data-store-server-javascript/src/js/api/server-data-store-facade.js b/api-data-store-server-javascript/src/js/api/server-data-store-facade.js index b2b5f5d6301d33d0322bbf589974e1f5a6c2978f..5a1824aa3c5d0daee4abedf111cc75bc11514dad 100644 --- a/api-data-store-server-javascript/src/js/api/server-data-store-facade.js +++ b/api-data-store-server-javascript/src/js/api/server-data-store-facade.js @@ -37,7 +37,7 @@ _DataStoreServerInternal.prototype.normalizeUrl = function(openbisUrlOrNull, htt } } - return parts.protocol + "://" + parts.authority + httpServerUri; + return parts.protocol + "://" + parts.authority + (httpServerUri || parts.path); } _DataStoreServerInternal.prototype.getUrlForMethod = function(method) { diff --git a/api-openbis-javascript/src/v3/openbis.js b/api-openbis-javascript/src/v3/openbis.js index 408d1b875fbd0d7a0949535a81f2d6e16991f4b7..35085226c7282a60e67c30f8a389475bc6216c75 100644 --- a/api-openbis-javascript/src/v3/openbis.js +++ b/api-openbis-javascript/src/v3/openbis.js @@ -435,42 +435,56 @@ define([ 'jquery', 'util/Json', 'as/dto/datastore/search/DataStoreSearchCriteria } } - var afsServerFacade = function(asFacade) { + var AfsServerFacade = function(asFacade, afsUrl) { - this.afsServer = new AfsServer("http://localhost:8085", "/data-store-server"); - this.afsServer.useSession(asFacade._private.sessionToken) + if(!afsUrl){ + throw Error("Please specify AFS server url"); + } + + var afsServer = new AfsServer(afsUrl); this.list = function(owner, source, recursively) { - return this.afsServer.list(owner, source, recursively); + useSession(); + return afsServer.list(owner, source, recursively); } this.read = function(owner, source, offset, limit){ - return this.afsServer.read(owner, source, offset, limit); + useSession(); + return afsServer.read(owner, source, offset, limit); } this.write = function(owner, source, offset, data){ - return this.afsServer.write(owner, source, offset, data); + useSession(); + return afsServer.write(owner, source, offset, data); } this.delete = function(owner, source){ - return this.afsServer.delete(owner, source); + useSession(); + return afsServer.delete(owner, source); } this.copy = function(sourceOwner, source, targetOwner, target){ - return this.afsServer.copy(sourceOwner, source, targetOwner, target); + useSession(); + return afsServer.copy(sourceOwner, source, targetOwner, target); } this.move = function(sourceOwner, source, targetOwner, target){ - return this.afsServer.move(sourceOwner, source, targetOwner, target); + useSession(); + return afsServer.move(sourceOwner, source, targetOwner, target); } this.create = function(owner, source, directory){ - return this.afsServer.create(owner, source, directory); + useSession(); + return afsServer.create(owner, source, directory); } + function useSession(){ + afsServer.useSession(asFacade._private.sessionToken) + } + } - var facade = function(openbisUrl) { + var facade = function(openbisUrl, afsUrl) { if (!openbisUrl) { openbisUrl = "/openbis/openbis/rmi-application-server-v3.json"; @@ -2458,7 +2472,7 @@ define([ 'jquery', 'util/Json', 'as/dto/datastore/search/DataStoreSearchCriteria } this.getAfsServerFacade = function() { - return new afsServerFacade(this) + return new AfsServerFacade(this, afsUrl) } this.getMajorVersion = function() { diff --git a/api-openbis-typescript/source/java/ch/ethz/sis/openbis/generic/typescript/dto/OpenBISJavaScriptFacade.java b/api-openbis-typescript/source/java/ch/ethz/sis/openbis/generic/typescript/dto/OpenBISJavaScriptFacade.java index ca7f282643dcf70979adf4b186b9c82368ccda95..62bfcaa899ef2cc16b914efbada6f6b4f1132072 100644 --- a/api-openbis-typescript/source/java/ch/ethz/sis/openbis/generic/typescript/dto/OpenBISJavaScriptFacade.java +++ b/api-openbis-typescript/source/java/ch/ethz/sis/openbis/generic/typescript/dto/OpenBISJavaScriptFacade.java @@ -259,7 +259,9 @@ public class OpenBISJavaScriptFacade implements IApplicationServerApi public OpenBISJavaScriptFacade(){} - public OpenBISJavaScriptFacade(String url){} + public OpenBISJavaScriptFacade(String openbisUrl){} + + public OpenBISJavaScriptFacade(String openbisUrl, String afsUrl){} @TypeScriptMethod(sessionToken = false, async = false) public OpenBISJavaScriptDSSFacade getDataStoreFacade(){ diff --git a/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-afs.ts b/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-afs.ts index ee639ad3212d4a44f3fb0541bc80f1d4664c2a5c..7d8f02ecb695d2934f35a49097aa04d79489bcaa 100644 --- a/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-afs.ts +++ b/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-afs.ts @@ -55,9 +55,10 @@ exports.default = new Promise((resolve) => { } resolve(function () { - executeModule("Afs tests (RequireJS)", new openbisRequireJS(), dtos) - executeModule("Afs tests (module VAR)", new window.openbis.openbis(), window.openbis) - executeModule("Afs tests (module ESM)", new window.openbisESM.openbis(), window.openbisESM) + var afsServerUrl = "http://localhost:8085/data-store-server" + executeModule("Afs tests (RequireJS)", new openbisRequireJS(null, afsServerUrl), dtos) + executeModule("Afs tests (module VAR)", new window.openbis.openbis(null, afsServerUrl), window.openbis) + executeModule("Afs tests (module ESM)", new window.openbisESM.openbis(null, afsServerUrl), window.openbisESM) }) }) }) diff --git a/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/types/openbis.esm.d.ts b/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/types/openbis.esm.d.ts index 68bfe530f7c49882d266d23cb8dadcda08c2361c..cc506ec215cdf7fb8f119d7f62cc02bc7d9f9ebf 100644 --- a/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/types/openbis.esm.d.ts +++ b/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/types/openbis.esm.d.ts @@ -1,6 +1,6 @@ /* tslint:disable */ /* eslint-disable */ -// Generated using typescript-generator version 3.2.1263 on 2024-03-27 12:40:27. +// Generated using typescript-generator version 3.2.1263 on 2024-03-28 16:04:27. export default openbis; @@ -14024,6 +14024,8 @@ export namespace openbis { new (): OpenBISJavaScriptFacade; new (arg0: string): OpenBISJavaScriptFacade; + + new (arg0: string, arg1: string): OpenBISJavaScriptFacade; } interface OperationExecution extends Serializable, ICodeHolder, IDescriptionHolder, IPermIdHolder {