diff --git a/api-openbis-javascript/src/v3/openbis.js b/api-openbis-javascript/src/v3/openbis.js index f311a65ff8ca5a82ffd20dbe46f3f53621fd1966..03da29d5977d144e25ae4dea89de3c031d07f57f 100644 --- a/api-openbis-javascript/src/v3/openbis.js +++ b/api-openbis-javascript/src/v3/openbis.js @@ -664,6 +664,10 @@ define([ 'jquery', 'util/Json', 'as/dto/datastore/search/DataStoreSearchCriteria thisFacade._private.sessionToken = sessionToken } + this.getAfsUrl = function() { + return this._private.afsUrl; + } + this.login = function(user, password) { var thisFacade = this; thisFacade._private.checkTransactionDoesNotExist(); diff --git a/ui-admin/src/js/services/openbis/api.js b/ui-admin/src/js/services/openbis/api.js index 40bd2e7e6ccd4ead4ec0b886a1a6115020c8105a..b0bd075f5769b068778377665d8a4800565f353f 100644 --- a/ui-admin/src/js/services/openbis/api.js +++ b/ui-admin/src/js/services/openbis/api.js @@ -13,21 +13,18 @@ class Facade { requirejs( ['openbis', 'util/Json'], (openbis, stjs) => { - new openbis().getServerPublicInformation() - .then(result => { + new openbis().getServerPublicInformation().then( + result => { const afsServerUrlKey = 'server-public-information.afs-server.url' const afsServerUrl = result[afsServerUrlKey] - if (afsServerUrl) { - _this.v3 = new openbis(null, afsServerUrl) - _this.stjs = stjs - resolve() - } else { - reject(new Error(afsServerUrlKey + ' is not set.')) - } + _this.v3 = new openbis(null, afsServerUrl) + _this.stjs = stjs + resolve() }, error => { reject(error) - }) + } + ) }, error => { reject(error) @@ -36,6 +33,14 @@ class Facade { }) } + _getAfsServerFacade() { + if (!this.v3.getAfsUrl()) { + throw new Error('server-public-information.afs-server.url is not set.') + } else { + return this.v3.getAfsServerFacade(); + } + } + useSession(sessionToken) { this.v3._private.sessionToken = sessionToken } @@ -257,43 +262,55 @@ class Facade { } executeCustomDSSService(serviceId, options) { - return this.promise(this.v3.getDataStoreFacade().executeCustomDSSService(serviceId, options)); + return this.promise(this.v3.getDataStoreFacade().executeCustomDSSService(serviceId, options)) } fromJson(jsonType, jsonObject) { - return this.promise(this.stjs.fromJson(jsonType, jsonObject)); + return this.promise(this.stjs.fromJson(jsonType, jsonObject)) } list(owner, source, recursively) { - return this.promise(this.v3.getAfsServerFacade().list(owner, source, recursively)) + return this.promise( + this._getAfsServerFacade().list(owner, source, recursively) + ) } read(owner, source, offset, limit) { - return this.promise(this.v3.getAfsServerFacade().read(owner, source, offset, limit)) + return this.promise( + this._getAfsServerFacade().read(owner, source, offset, limit) + ) } write(owner, source, offset, data) { - return this.promise(this.v3.getAfsServerFacade().write(owner, source, offset, data)) + return this.promise( + this._getAfsServerFacade().write(owner, source, offset, data) + ) } delete(owner, source) { - return this.promise(this.v3.getAfsServerFacade().delete(owner, source)) + return this.promise(this._getAfsServerFacade().delete(owner, source)) } copy(sourceOwner, source, targetOwner, target) { - return this.promise(this.v3.getAfsServerFacade().copy(sourceOwner, source, targetOwner, target)) + return this.promise( + this._getAfsServerFacade().copy(sourceOwner, source, targetOwner, target) + ) } move(sourceOwner, source, targetOwner, target) { - return this.promise(this.v3.getAfsServerFacade().move(sourceOwner, source, targetOwner, target)) + return this.promise( + this._getAfsServerFacade().move(sourceOwner, source, targetOwner, target) + ) } create(owner, source, directory) { - return this.promise(this.v3.getAfsServerFacade().create(owner, source, directory)) + return this.promise( + this._getAfsServerFacade().create(owner, source, directory) + ) } free(owner, source) { - return this.promise(this.v3.getAfsServerFacade().free(owner, source)) + return this.promise(this._getAfsServerFacade().free(owner, source)) } async executeService(id, options) {