diff --git a/lib/progress.all.js b/lib/progress.all.js index 56596d6..379b735 100644 --- a/lib/progress.all.js +++ b/lib/progress.all.js @@ -1,7 +1,6 @@ +// Progress JSDO Version: 6.0.1 /* -Progress JSDO Version: 6.0.1 - -Copyright 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright 2012-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,9 +17,8 @@ limitations under the License. /*eslint no-global-assign: ["error", {"exceptions": ["localStorage"]}]*/ /*global XMLHttpRequest:true, require, console, localStorage:true, sessionStorage:true, $:true, Promise, setTimeout */ /* -progress.util.js Version: 6.0.1 -Copyright (c) 2014-2018 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2014-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Contains support objects used by the jsdo and/or session object @@ -52,21 +50,26 @@ limitations under the License. // Required packages should be installed before loading progress-jsdo. // Node.js: // - xmlhttprequest - // - node-localstorage // NativeScript: // - nativescript-localstorage - // - base-64 var isNativeScript = false, isNodeJS = false; var pkg_xmlhttprequest = "xmlhttprequest", - pkg_nodeLocalstorage = "node-localstorage", pkg_nativescriptLocalstorage = "nativescript-localstorage", - pkg_fileSystemAccess = "file-system/file-system-access", - pkg_base64 = "base-64" + pkg_fileSystemAccess = "file-system/file-system-access" ; + //In memory localStorage emulation used for node + function LocalStorageEmulation() { + this._data = {}; + }; + LocalStorageEmulation.prototype.setItem = function(id, val) { return this._data[id] = String(val); }, + LocalStorageEmulation.prototype.getItem = function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; }, + LocalStorageEmulation.prototype.removeItem = function(id) { return delete this._data[id]; }, + LocalStorageEmulation.prototype.clear = function() { return this._data = {}; } + // If XMLHttpRequest is undefined, enviroment would appear to be Node.js // load xmlhttprequest module // Web browser and NativeScript clients have a built-in XMLHttpRequest object @@ -112,44 +115,47 @@ limitations under the License. + "Please install nativescript-localstorage package."); } - // load module base-64 + // Polyfill the btoa() function (which we use to encode BASIC authorization) try { if (typeof btoa === "undefined") { - btoa = require("" + pkg_base64).encode; + btoa = function(str) { return Buffer.from(str).toString('base64'); } } } catch(exception3) { - console.error("Error: JSDO library requires btoa() function in NativeScript.\n" - + "Please install base-64 package."); + console.error("Error: JSDO library requires toString('base64') function in NativeScript."); } } - // If environment is NodeJS, load module node-localstorage if (isNodeJS) { - var LocalStorage; if (typeof localStorage === "undefined") { - try { - var module = require("" + pkg_nodeLocalstorage); - LocalStorage = module.LocalStorage; - localStorage = new LocalStorage('./scratch1'); - } catch(e) { - console.error("Error: JSDO library requires localStorage and sessionStorage objects in Node.js.\n" - + "Please install node-localstorage package."); - } + localStorage = new LocalStorageEmulation(); } - if (typeof sessionStorage === "undefined" - && typeof LocalStorage !== "undefined") { - sessionStorage = new LocalStorage('./scratch2'); + if (typeof sessionStorage === "undefined") { + sessionStorage = new LocalStorageEmulation(); } - // load module base-64 + // Polyfill the btoa() function (which we use to encode BASIC authorization) try { if (typeof btoa === "undefined") { - btoa = require("" + pkg_base64).encode; + btoa = function(str) { return Buffer.from(str).toString('base64'); } } } catch(exception3) { - console.error("Error: JSDO library requires btoa() function in Node.js.\n" - + "Please install base-64 package."); + console.error("Error: JSDO library requires toString('base64')function in Node.js."); + } + } + + // If we're running in the browser, edit btoa() to properly encode Unicode strings + // taken from https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa#Unicode_strings + if (!isNodeJS && !isNativeScript) { + if (typeof btoa !== "undefined") { + let btoaOriginal = btoa; + + // this section of code is functionally identical to the toString('base-64') + // btoa() doesn't exist on node though, which is why we have different styles + // of encoding in NS/node + btoa = function (str) { + return btoaOriginal(unescape(encodeURIComponent(str))); + }; } } }()); @@ -1095,9 +1101,7 @@ limitations under the License. }()); //# sourceURL=progress.jsdo.js /* -progress.js Version: 6.0.1 - -Copyright (c) 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2012-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -7468,67 +7472,75 @@ limitations under the License. var xhr = this; if (xhr.readyState == 4) { var request = xhr.request; - - /* try to parse response even if request is considered "failed" due to http status */ try { - request.response = JSON.parse(xhr.responseText); - // in some cases the object back from appserver has a "response" property which represents - // the real content of the JSON...happens when multiple output parameters are returned. - // this of course assumes no one names their root object "response". - if (request.response && request.response.response) { - request.response = request.response.response; + + /* try to parse response even if request is considered "failed" due to http status */ + try { + request.response = JSON.parse(xhr.responseText); + // in some cases the object back from appserver has a "response" property which represents + // the real content of the JSON...happens when multiple output parameters are returned. + // this of course assumes no one names their root object "response". + if (request.response && request.response.response) { + request.response = request.response.response; + } + } catch (e) { + request.response = undefined; } - } catch (e) { - request.response = undefined; - } - try { - if ((xhr.status >= 200 && xhr.status < 300) - || (xhr.status === 0 && xhr.responseText !== "")) { - - request.success = true; - // get the Client Context ID (AppServer ID) - xhr.jsdo._session._saveClientContextId(xhr); - if ((typeof xhr.onSuccessFn) == 'function') { - var operation; - if (xhr.request.fnName !== undefined - && xhr.jsdo._resource.fn[xhr.request.fnName] !== undefined) { - operation = xhr.jsdo._resource.fn[xhr.request.fnName].operation; + try { + if ((xhr.status >= 200 && xhr.status < 300) + || (xhr.status === 0 && xhr.responseText !== "")) { + + request.success = true; + // get the Client Context ID (AppServer ID) + xhr.jsdo._session._saveClientContextId(xhr); + if ((typeof xhr.onSuccessFn) == 'function') { + var operation; + if (xhr.request.fnName !== undefined + && xhr.jsdo._resource.fn[xhr.request.fnName] !== undefined) { + operation = xhr.jsdo._resource.fn[xhr.request.fnName].operation; + } + else + operation = null; + if ((operation === undefined) || (operation !== null && operation.mergeMode)) + xhr.jsdo._mergeInvoke(request.response, xhr); + if (request.success) + xhr.onSuccessFn(xhr.jsdo, request.success, request); + else if ((typeof xhr.onErrorFn) == 'function') + xhr.onErrorFn(xhr.jsdo, request.success, request); } - else - operation = null; - if ((operation === undefined) || (operation !== null && operation.mergeMode)) - xhr.jsdo._mergeInvoke(request.response, xhr); - if (request.success) - xhr.onSuccessFn(xhr.jsdo, request.success, request); - else if ((typeof xhr.onErrorFn) == 'function') - xhr.onErrorFn(xhr.jsdo, request.success, request); - } - } else { - request.success = false; - if (xhr.status === 0) { - request.exception = new Error(msg.getMsgText("jsdoMSG101")); + } else { + request.success = false; + if (xhr.status === 0) { + request.exception = new Error(msg.getMsgText("jsdoMSG101")); + } + if ((typeof xhr.onErrorFn) == 'function') { + xhr.onErrorFn(xhr.jsdo, request.success, request); + } } + } catch (e) { + request.success = false; + request.exception = e; if ((typeof xhr.onErrorFn) == 'function') { xhr.onErrorFn(xhr.jsdo, request.success, request); } } - } catch (e) { - request.success = false; - request.exception = e; - if ((typeof xhr.onErrorFn) == 'function') { - xhr.onErrorFn(xhr.jsdo, request.success, request); + // get the Client Context ID (AppServer ID) + xhr.jsdo._session._checkServiceResponse(xhr, request.success, request); + + if ((typeof xhr.onCompleteFn) == 'function') { + xhr.onCompleteFn(xhr.jsdo, request.success, request); } - } - // get the Client Context ID (AppServer ID) - xhr.jsdo._session._checkServiceResponse(xhr, request.success, request); - if ((typeof xhr.onCompleteFn) == 'function') { - xhr.onCompleteFn(xhr.jsdo, request.success, request); + } catch (e) { + request.success = false; + request.exception = e; + if ((typeof xhr.onErrorFn) == 'function') { + xhr.onErrorFn(xhr.jsdo, request.success, request); + } + } } - - } }; /* @@ -8271,8 +8283,17 @@ limitations under the License. } } + // Christian Bryan - 10.02.2019 Add this back in + // Mike Fechner, Consultingwerk Ltd. 16.03.2016 + // Adding the tableRef property of the JSDO Parameters to + // the Filter Parameter so that the backend can use this + // information to actually know which Business Entity Table + // the query filter string is intended for ... + filter = JSON.stringify({ ablFilter: ablFilter, + tableRef: params.tableRef, + viewTables: jsdo.viewTables, sqlQuery: sqlQuery, orderBy: sortFields, skip: params.skip, @@ -8727,9 +8748,8 @@ limitations under the License. //this is so that we can see the code in Chrome's Source tab when script is loaded via XHR //# sourceURL=progress.jsdo.js /* -progress.session.js Version: 6.0.1 -Copyright (c) 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2012-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -9525,7 +9545,9 @@ limitations under the License. // connects to online the last time it was checked? // (value is always false if session is not logged in) oepingAvailable = false, - defaultPartialPingURI = "/rest/_oeping", + hasResolvedPingURI = false, + defaultPartialPingURI = "/rest/_oepingService/_oeping", + classicPartialPingURI = "/rest/_oeping", partialPingURI = defaultPartialPingURI, _storageKey, _authProvider = null, @@ -9724,6 +9746,7 @@ limitations under the License. case progress.data.Session.AUTH_TYPE_BASIC: case progress.data.Session.AUTH_TYPE_ANON: case progress.data.Session.AUTH_TYPE_SSO: + case progress.data.Session.AUTH_TYPE_BEARER: case null: _authenticationModel = newval; storeSessionInfo("authenticationModel", newval); @@ -10833,7 +10856,8 @@ limitations under the License. xhr._jsdosession = jsdosession; // in case the caller is a JSDOSession xhr._deferred = deferred; // in case the caller is a JSDOSession if (this.authenticationModel === progress.data.Session.AUTH_TYPE_FORM || - this.authenticationModel === progress.data.Session.AUTH_TYPE_BASIC) { + this.authenticationModel === progress.data.Session.AUTH_TYPE_BASIC || + this.authenticationModel === progress.data.Session.AUTH_TYPE_BEARER) { if (isAsync) { xhr.onreadystatechange = this._onReadyStateChangeGeneric; xhr.onResponseFn = this._processLogoutResult; @@ -10929,7 +10953,8 @@ limitations under the License. } else if (xhr.status !== 200) { /* Determine whether an error returned from the server is really an error */ - if (pdsession.authenticationModel === progress.data.Session.AUTH_TYPE_BASIC) { + if (pdsession.authenticationModel === progress.data.Session.AUTH_TYPE_BASIC || + pdsession.authenticationModel === progress.data.Session.AUTH_TYPE_BEARER) { /* If the Auth model is Basic, we probably got back a 404 Not found. * But that's OK, because logout from Basic is meaningless on the * server side unless it happens to be stateful, which is the only @@ -11645,40 +11670,71 @@ limitations under the License. this._onReadyStateChangePing = function () { var xhr = this; var args; - - if (xhr.readyState === 4) { - args = { - xhr: xhr, - fireEventIfOfflineChange: true, - offlineReason: null - }; - that._processPingResult(args); - if (_pingInterval > 0) { - _timeoutID = setTimeout(that._autoping, _pingInterval); + try { + if (xhr.readyState === 4) { + args = { + xhr: xhr, + fireEventIfOfflineChange: true, + offlineReason: null + }; + that._processPingResult(args); + if (_pingInterval > 0) { + _timeoutID = setTimeout(that._autoping, _pingInterval); + } } + } catch(e) { } }; this._pingtestOnReadyStateChange = function () { var xhr = this; + try { + if (xhr.readyState === 4) { + var foundOeping = false; + if (xhr.status >= 200 && xhr.status < 300) { + foundOeping = true; + } else { + setPartialPingURI(that.loginTarget); + console.warn("Default ping target not available, will use loginTarget instead."); + } + setOepingAvailable(foundOeping); - if (xhr.readyState === 4) { - var foundOeping = false; - if (xhr.status >= 200 && xhr.status < 300) { - foundOeping = true; - } else { - setPartialPingURI(that.loginTarget); - console.warn("Default ping target not available, will use loginTarget instead."); + // If we're here, we've just logged in. If pingInterval has been set, we need + // to start autopinging + if (_pingInterval > 0) { + _timeoutID = setTimeout(that._autoping, _pingInterval); + } } - setOepingAvailable(foundOeping); + } catch(e) { + } + }; - // If we're here, we've just logged in. If pingInterval has been set, we need - // to start autopinging - if (_pingInterval > 0) { - _timeoutID = setTimeout(that._autoping, _pingInterval); + var resolvePingURI = () => { + var xhr = new XMLHttpRequest(), + deferred = new progress.util.Deferred(); + + xhr.onreadystatechange = () => { + if (xhr.readyState === 4) { + // If we can't find the new ping endpoint, we go back to the Classic Ping URI. + if (xhr.status === 404) { + setPartialPingURI(classicPartialPingURI); + deferred.reject(false); + } else { + deferred.resolve(true); + } + hasResolvedPingURI = true; } + }; + + // if we've resolved the pingURI OR we haven't logged in, then we don't have to do anything + if (hasResolvedPingURI || (this.loginResult !== progress.data.Session.LOGIN_SUCCESS && !this.authProvider)) { + deferred.resolve(true); + } else { + this._openRequest(xhr, "GET", partialPingURI, true, () => xhr.send()); } - }; + + return deferred.promise(); + } /* * args: pingURI @@ -11691,6 +11747,8 @@ limitations under the License. var xhr = new XMLHttpRequest(), that = this; + args.xhr = xhr; + function sendPingAfterOpen() { if (args.async) { xhr.onreadystatechange = args.onReadyStateFn; @@ -11710,30 +11768,35 @@ limitations under the License. xhr.send(null); } - try { - if (this._authProvider) { - this._authProvider._openRequestAndAuthorize( - xhr, - 'GET', - args.pingURI, - args.async, - sendPingAfterOpen - ); - } else { - // get rid of this if we do away with synchronous support (i.e., customer use of - // old Session API) - this._setXHRCredentials(xhr, "GET", args.pingURI, this.userName, _password, args.async); - - // Sending the XHR request after opening the channel - if (xhr.readyState === 1) { - sendPingAfterOpen(); + resolvePingURI().then(() => { + // do nothing on success because the new oePingService was found + }, () => { + // re-create the pingURI since we changed to the old classic AppServer ping URI + args.pingURI = this._makePingURI(); + }).then(() => { + try { + if (this._authProvider) { + this._authProvider._openRequestAndAuthorize( + xhr, + 'GET', + args.pingURI, + args.async, + sendPingAfterOpen + ); + } else { + // get rid of this if we do away with synchronous support (i.e., customer use of + // old Session API) + this._setXHRCredentials(xhr, "GET", args.pingURI, this.userName, _password, args.async); + + // Sending the XHR request after opening the channel + if (xhr.readyState === 1) { + sendPingAfterOpen(); + } } + } catch (e) { + args.error = e; } - } catch (e) { - args.error = e; - } - - args.xhr = xhr; + }) }; this._makePingURI = function () { @@ -12314,7 +12377,15 @@ limitations under the License. enumerable: true } ); - + Object.defineProperty( + progress.data.Session, + 'AUTH_TYPE_BEARER', + { + value: "bearer", + enumerable: true + } + ); + Object.defineProperty( progress.data.Session, 'DEVICE_OFFLINE', @@ -12369,6 +12440,7 @@ limitations under the License. progress.data.Session.AUTH_TYPE_BASIC = "basic"; progress.data.Session.AUTH_TYPE_FORM = "form"; progress.data.Session.AUTH_TYPE_SSO = "sso"; + progress.data.Session.AUTH_TYPE_BEARER = "bearer"; /* deliberately not including the "offline reasons" that are defined in the * 1st part of the conditional. We believe that we can be used only in environments where @@ -13192,34 +13264,36 @@ limitations under the License. var xhr = this, cbresult, info; - - if (xhr.readyState === 4) { - info = { - xhr: xhr, - offlineReason: undefined, - fireEventIfOfflineChange: true, - usingOepingFormat: false - }; - - // call _processPingResult because it has logic for - // detecting change in online/offline state - _pdsession._processPingResult(info); - - if (xhr.status >= 200 && xhr.status < 300) { - deferred.resolve( - that, - progress.data.Session.SUCCESS, - info - ); - } else { - if (xhr.status === 401) { - cbresult = progress.data.AuthenticationProvider._getAuthFailureReason(xhr); + try { + if (xhr.readyState === 4) { + info = { + xhr: xhr, + offlineReason: undefined, + fireEventIfOfflineChange: true, + usingOepingFormat: false + }; + + // call _processPingResult because it has logic for + // detecting change in online/offline state + _pdsession._processPingResult(info); + + if (xhr.status >= 200 && xhr.status < 300) { + deferred.resolve( + that, + progress.data.Session.SUCCESS, + info + ); } else { - cbresult = progress.data.Session.GENERAL_FAILURE; + if (xhr.status === 401) { + cbresult = progress.data.AuthenticationProvider._getAuthFailureReason(xhr); + } else { + cbresult = progress.data.Session.GENERAL_FAILURE; + } + deferred.reject(that, cbresult, info); } - deferred.reject(that, cbresult, info); } - } + } catch (e) { + } }; try { @@ -13458,8 +13532,8 @@ limitations under the License. progress.data.getSession = function (options) { var deferred = new progress.util.Deferred(), authProvider, - promise, - authProviderInitObject = {}; + authProviderInitObject = {}, + session; // This is the reject handler for session-related operations // login, addCatalog, and logout @@ -13487,26 +13561,23 @@ limitations under the License. } function loginHandler(object) { - var jsdosession; + let jsdosession; try { - jsdosession = new progress.data.JSDOSession(options); - try { - jsdosession.isAuthorized() - .then(function() { - return jsdosession.addCatalog(options.catalogURI); - }, sessionRejectHandler) - .then(function (object, result, info) { - object = progress.util.Deferred.getParamObject(object, result, info); - deferred.resolve(object.jsdosession, progress.data.Session.SUCCESS); - }, sessionRejectHandler); - } catch (e) { - sessionRejectHandler( - jsdosession, - progress.data.Session.GENERAL_FAILURE, - {errorObject: e} - ); + if (typeof session === "undefined") { + jsdosession = new progress.data.JSDOSession(options); + } else { + jsdosession = session; } + + jsdosession.isAuthorized() + .then(function() { + return jsdosession.addCatalog(options.catalogURI); + }, sessionRejectHandler) + .then(function (object, result, info) { + object = progress.util.Deferred.getParamObject(object, result, info); + deferred.resolve(object.jsdosession, progress.data.Session.SUCCESS); + }, sessionRejectHandler); } catch (ex) { sessionRejectHandler( jsdosession, @@ -13632,7 +13703,33 @@ limitations under the License. options.authProvider = authProvider; if (authProvider.hasClientCredentials()) { - loginHandler(authProvider); + // FAKE SESSION + let jsdosession = new progress.data.JSDOSession(options), + statusCode = 0; + + // This is a band-aid. We need to refactor and re-modularize + // getSession() now that the team has a better understanding + // of async operations --aestrada + jsdosession.isAuthorized().then(() => { + session = jsdosession; + return; + }, (obj) => { + statusCode = obj && obj.info && obj.info.xhr && obj.info.xhr.status; + return progress.util.Deferred.when([ + jsdosession.invalidate(), + options.authProvider.logout() + ]); + }).then(() => { + // If we have a 401, then we need to get rid of our old authProvider and try a fresh start + // Otherwise, we still good. + if (statusCode === 401) { + authProvider = new progress.data.AuthenticationProvider(authProviderInitObject); + options.authProvider = authProvider; + callLogin(authProvider); + } else { + loginHandler(authProvider); + } + }); } else { // If model is anon, just log in. if (authProvider.authenticationModel === progress.data.Session.AUTH_TYPE_ANON) { @@ -13699,12 +13796,10 @@ limitations under the License. if (typeof exports !== "undefined") { exports.progress = progress; } - //# sourceURL=progress.jsdo.js /* -progress.auth.js Version: 6.0.1 -Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2016-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13791,6 +13886,9 @@ limitations under the License. case progress.data.Session.AUTH_TYPE_FORM_SSO: authProv = new progress.data.AuthenticationProviderSSO(initObject.uri); break; + case progress.data.Session.AUTH_TYPE_BEARER: + authProv = new progress.data.AuthenticationProviderBearer(initObject.uri); + break; default: // AuthenticationProvider: The 'init-object' parameter passed to the 'constructor' function // has an invalid value for the 'authenticationModel' property. @@ -13832,7 +13930,10 @@ limitations under the License. xhr.onreadystatechange = function () { if (xhr.readyState === 4) { // process the response from the Web application - that._processLoginResult(xhr, deferred); + try { + that._processLoginResult(xhr, deferred); + } catch (e) { + } } }; @@ -14173,9 +14274,8 @@ limitations under the License. //# sourceURL=progress.jsdo.js /* -progress.auth.basic.js Version: 6.0.1 -Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2016-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14332,9 +14432,154 @@ limitations under the License. }()); //# sourceURL=progress.jsdo.js /* -progress.auth.form.js Version: 6.0.1 -Copyright (c) 2016-2018 Progress Software Corporation and/or its subsidiaries or affiliates. + +Copyright (c) 2017-2019 Progress Software Corporation and/or its subsidiaries or affiliates. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + */ + +(function () { + + "use strict"; // note that this makes JSLint complain if you use arguments[x] + + /*global progress : true*/ + /*global storage, XMLHttpRequest, msg, btoa*/ + + progress.data.AuthenticationProviderBearer = function (uri) { + var bearerToken = null, + fn; + + // process constructor arguments, etc. + this._initialize(uri, progress.data.Session.AUTH_TYPE_BEARER, + {"_loginURI": progress.data.AuthenticationProvider._homeLoginURIBase}); + + // PRIVATE FUNCTIONS + + function make_Bearer_auth_header(token) { + return "Bearer " + token; + } + + // "INTERNAL" METHODS + // Override the protoype's method but call it from within the override + // (Define the override here in the constructor so it has access to instance variables) + this._reset = function () { + bearerToken = null; + progress.data.AuthenticationProviderBearer.prototype._reset.apply(this); + }; + + // Override the protoype's method (this method does not invoke the prototype's copy) + // (Define the override here in the constructor so it has access to instance variables) + this._openLoginRequest = function (xhr, uri) { + var auth; + + xhr.open("GET", uri, true); // but see comments below inside the "if bearerToken" + // may have to go with that approach + + if (bearerToken) { + + // set Authorization header + auth = make_Bearer_auth_header(bearerToken); + xhr.setRequestHeader('Authorization', auth); + } + + progress.data.Session._setNoCacheHeaders(xhr); + }; + + // Override the protoype's method but call it from within the override + // (Define the override here in the constructor so it has access to instance variables) + this._processLoginResult = function _Bearer_processLoginResult(xhr, deferred) { + progress.data.AuthenticationProviderBearer.prototype._processLoginResult.apply( + this, + [xhr, deferred] + ); + if (!this._loggedIn) { + // login failed, clear the credentials + bearerToken = null; + } + }; + + // Override the protoype's method (this method does not invoke the prototype's copy, but + // calls a prototype general-purpose login method) + // (Define the override here in the constructor so it has access to instance variables) + this.login = function (token) { + // these throw if the check fails (may want to do something more elegant) + this._checkStringArg("login", token, 1, "token"); + + bearerToken = token; + return this._loginProto(); + }; + + // Override the protoype's method (this method does not invoke the prototype's copy) + // (Define the override here in the constructor so it has access to instance variables) + // TODO: This method uses a callback, primarily to avoid breaking tdriver tests. We should change + // it to use promises + this._openRequestAndAuthorize = function (xhr, verb, uri, async, callback) { + var auth, + errorObject; + + if (this.hasClientCredentials()) { + + xhr.open(verb, uri, async); // but see comments below inside the "if bearerToken" + // may have to go with that approach + + if (bearerToken) { + + // set Authorization header + auth = make_Bearer_auth_header(bearerToken); + xhr.setRequestHeader('Authorization', auth); + } + + progress.data.Session._setNoCacheHeaders(xhr); + } else { + // AuthenticationProvider: The AuthenticationProvider is not managing valid credentials. + errorObject = new Error(progress.data._getMsgText("jsdoMSG125", "AuthenticationProvider")); + } + + callback(errorObject); + }; + }; + + + // Give this constructor the prototype from the "base" AuthenticationProvider + // Do this indirectly by way of an intermediate object so changes to the prototype ("method overrides") + // don't affect other types of AuthenticationProviders that use the prototype) + function BearerProxy() {} + BearerProxy.prototype = progress.data.AuthenticationProvider.prototype; + progress.data.AuthenticationProviderBearer.prototype = new BearerProxy(); + + // Reset the prototype's constructor property so it points to AuthenticationProviderForm rather than + // the one that it just inherited (this is pretty much irrelevant though - the correct constructor + // will get called regardless) + progress.data.AuthenticationProviderBearer.prototype.constructor = + progress.data.AuthenticationProviderBearer; + + + // OVERRIDE METHODS ON PROTOTYPE IF NECESSARY AND POSSIBLE + // (SOME METHODS ARE OVERRIDDEN IN THE CONSTRUCTOR BECAUSE THEY NEED ACCESS TO INSTANCE VARIABLES) + + // NOTE: There are no overrides of the following methods (either here or in the constructor). + // This object uses these methods from the original prototype(i.e., the implementations from the + // AuthenticationProvider object): + // logout (API method) + // hasClientCredentials (API method) + +}()); +//# sourceURL=progress.jsdo.js +/* + +Copyright (c) 2016-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14451,7 +14696,10 @@ limitations under the License. xhr.onreadystatechange = function () { if (xhr.readyState === 4) { // process the response from the Web application - that._processLogoutResult(xhr, deferred); + try { + that._processLogoutResult(xhr, deferred); + } catch (e) { + } } }; @@ -14544,9 +14792,8 @@ limitations under the License. }()); //# sourceURL=progress.jsdo.js /* -progress.auth.sso.js Version: 6.0.1 -Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2016-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14903,7 +15150,10 @@ limitations under the License. xhr.onreadystatechange = function () { if (xhr.readyState === 4) { // process the response from the Web application - processRefreshResult(xhr, deferred); + try { + processRefreshResult(xhr, deferred); + } catch (e){ + } } }; @@ -15037,10 +15287,9 @@ limitations under the License. }()); -/* -progress.data.kendo.js Version: 6.0.1 +/* -Copyright (c) 2015-2018 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2015-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/progress.all.min.js b/lib/progress.all.min.js index 81f07f1..2840762 100644 --- a/lib/progress.all.min.js +++ b/lib/progress.all.min.js @@ -1,7 +1,5 @@ /* -Progress JSDO Version: 6.0.1 - -Copyright 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright 2012-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,5 +13,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -(function(){var isNativeScript=false,isNodeJS=false;var pkg_xmlhttprequest="xmlhttprequest",pkg_nodeLocalstorage="node-localstorage",pkg_nativescriptLocalstorage="nativescript-localstorage",pkg_fileSystemAccess="file-system/file-system-access",pkg_base64="base-64";if(typeof XMLHttpRequest==="undefined"){isNodeJS=true;try{XMLHttpRequest=require(""+pkg_xmlhttprequest).XMLHttpRequest}catch(e){console.error("Error: JSDO library requires XMLHttpRequest object in Node.js.\n"+"Please install xmlhttprequest package.")}}if(!isNodeJS&&(typeof localStorage==="undefined"||typeof sessionStorage==="undefined")){try{require(""+pkg_fileSystemAccess);isNativeScript=true}catch(exception1){isNativeScript=false}}if(isNativeScript){try{if(typeof sessionStorage==="undefined"){sessionStorage=require(""+pkg_nativescriptLocalstorage)}if(typeof localStorage==="undefined"){localStorage=require(""+pkg_nativescriptLocalstorage)}}catch(exception2){console.error("Error: JSDO library requires localStorage and sessionStorage objects in NativeScript.\n"+"Please install nativescript-localstorage package.")}try{if(typeof btoa==="undefined"){btoa=require(""+pkg_base64).encode}}catch(exception3){console.error("Error: JSDO library requires btoa() function in NativeScript.\n"+"Please install base-64 package.")}}if(isNodeJS){var LocalStorage;if(typeof localStorage==="undefined"){try{var module=require(""+pkg_nodeLocalstorage);LocalStorage=module.LocalStorage;localStorage=new LocalStorage("./scratch1")}catch(e){console.error("Error: JSDO library requires localStorage and sessionStorage objects in Node.js.\n"+"Please install node-localstorage package.")}}if(typeof sessionStorage==="undefined"&&typeof LocalStorage!=="undefined"){sessionStorage=new LocalStorage("./scratch2")}try{if(typeof btoa==="undefined"){btoa=require(""+pkg_base64).encode}}catch(exception3){console.error("Error: JSDO library requires btoa() function in Node.js.\n"+"Please install base-64 package.")}}})();(function(){if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.util={};var STRING_OBJECT_TYPE="String",DATE_OBJECT_TYPE="Date",CHARACTER_ABL_TYPE="CHARACTER";progress.util.Deferred=function(){function Deferred(){this._deferred={}}Deferred.prototype.promise=function(){var that=this;if(progress.util.Deferred.useJQueryPromises){if(typeof $!=="undefined"&&typeof $.Deferred==="function"){this._deferred._jQuerydeferred=$.Deferred();this._promise=this._deferred._jQuerydeferred.promise()}else{throw new Error("JQuery Promises not found in environment.")}}else{this._promise=new Promise(function(resolve,reject){that._deferred.resolve=resolve;that._deferred.reject=reject})}if(this._resolveArguments||this._rejectArguments){setTimeout(function(){if(that._resolveArguments){that.resolve.apply(that,that._resolveArguments)}else if(that._rejectArguments){that.reject.apply(that,that._rejectArguments)}},500)}return this._promise};Deferred.prototype.resolve=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.resolve.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.resolve(object)}}else{this._resolveArguments=arguments}};Deferred.prototype.reject=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.reject.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.reject(object)}}else{this._rejectArguments=arguments}};Deferred.useJQueryPromises=false;Deferred.when=function(deferreds){if(progress.util.Deferred.useJQueryPromises){return $.when.apply($,deferreds)}else{return Promise.all(deferreds)}};Deferred.getParamObject1=function(arg1,arg2,arg3){var object={},objectName;try{if(typeof arg1==="undefined"||arg1===null){object.result=arg2;object.info=arg3}else{if(arg1 instanceof progress.data.JSDOSession){objectName="jsdosession"}else if(arg1 instanceof progress.data.AuthenticationProvider){objectName="provider"}else if(arg1 instanceof progress.data.JSDO){objectName="jsdo"}else if(typeof arg1==="number"){objectName="result"}else{objectName=typeof arg1}object[objectName]=arg1;if(objectName==="jsdo"){object.success=arg2;if(arg3&&arg3.xhr){object.request=arg3}else if(arg3&&arg3.batch){object.request=arg3}else{object.info=arg3}}else{if(objectName==="result"){object.info=arg2;if(arg3){object.info2=arg3}}else{object.result=arg2;object.info=arg3}}}}catch(e){console.log("Error: Undetermined argument in getParamObject() call.")}return object};Deferred.getParamObject=function(arg1,arg2,arg3){var object={};if(progress.util.Deferred.useJQueryPromises){object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3)}else{if(typeof arg1==="undefined"){object.result=arg2;object.info=arg3;arg1=object}return arg1}return object};return Deferred}();progress.util.Observable=function(){function _filterObservers(observers,fn,scope,operation){return observers.filter(function(el){if(el.fn!==fn||el.scope!==scope||el.operation!==operation){return el}},this)}this.validateSubscribe=function(args,evt,listenerData){if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="string"){listenerData.operation=args[1];listenerData.fn=args[2];listenerData.scope=args[3]}else if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="function"){listenerData.operation=undefined;listenerData.scope=args[2];listenerData.fn=args[1]}else{throw new Error}};this.subscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"subscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",progress.data._getMsgText("jsdoMSG039")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",e.message))}observers=this._events[evt]||[];observers=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation);observers.push(listenerData);this._events[evt]=observers;return this};this.unsubscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"unsubscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",progress.data._getMsgText("jsdoMSG037")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",e.message))}observers=this._events[evt]||[];if(observers.length>0){this._events[evt]=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation)}return this};this.trigger=function(evt,operation,args){var observers,op;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"trigger"))}this._events=this._events||{};evt=evt.toLowerCase();observers=this._events[evt]||[];if(observers.length>0){args=Array.prototype.slice.call(arguments);if(arguments.length>=2&&typeof evt==="string"&&typeof operation==="string"){op=operation;args=args.length>2?args.slice(2):[]}else if(arguments.length>=1&&typeof evt==="string"){op=undefined;args=args.length>1?args.slice(1):[]}else{throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"trigger"))}observers.forEach(function(el){if(el.operation===op){el.fn.apply(el.scope,args)}})}return this};this.unsubscribeAll=function(evt,operation){var observers;if(evt){this._events=this._events||{};if(typeof evt==="string"){evt=evt.toLowerCase();observers=this._events[evt]||[];observers.forEach(function(el){if(el.operation){this.unsubscribe(evt,el.operation,el.fn,el.scope)}else{this.unsubscribe(evt,el.fn,el.scope)}},this)}}else{this._events={}}return this}};progress.data.LocalStorage=function LocalStorage(){if(typeof localStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","progress.data.LocalStorage","localStorage"))}this.saveToLocalStorage=function(name,dataObj){localStorage.setItem(name,JSON.stringify(dataObj))};this.readFromLocalStorage=function(name){var jsonStr=localStorage.getItem(name),dataObj=null;if(jsonStr!==null){try{dataObj=JSON.parse(jsonStr)}catch(e){dataObj=null}}return dataObj};this.clearLocalStorage=function(name){localStorage.removeItem(name)}};progress.util._convertToABLWhereString=function(tableRef,filter){var result=[],logic=filter.logic||"and",idx,length,field,fieldInfo,type,format,operator,value,ablType,filters=filter.filters||[filter],whereOperators={eq:"=",neq:"<>",gt:">",gte:">=",lt:"<",lte:"<=",contains:"INDEX",doesnotcontain:"INDEX",endswith:"R-INDEX",startswith:"BEGINS",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};for(idx=0,length=filters.length;idx 0"}else{format="{2} MATCHES '*{1}'"}}else{format="{2} {0} "+format}filter=progress.util._format(format,operator,value,field)}else if(operator&&value===undefined){if(filter.operator==="isempty"||filter.operator==="isnotempty"){ablType=tableRef._getABLType(field);if(ablType!==CHARACTER_ABL_TYPE){throw new Error("Error parsing filter object. The operator "+filter.operator+" requires a CHARACTER field")}if(filter.operator==="isempty"){format="{2} = ''"}else if(filter.operator==="isnotempty"){format="{2} <> ''"}}else{if(filter.operator==="isnull"){format="{2} = ?"}else if(filter.operator==="isnotnull"){format="{2} <> ?"}else{format="{2} {0} ?"}}filter=progress.util._format(format,operator,value,field)}}result.push(filter)}filter=result.join(" "+logic+" ");if(result.length>1){filter="("+filter+")"}return filter};progress.util._convertToSQLQueryString=function(tableRef,filter,addSelect){var result=[],logic=filter.logic||"and",idx,length,field,type,format,operator,value,fieldFormat,filters=filter.filters||[filter],filterStr,usingLike=true,whereOperators={eq:"=",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<=",contains:"LIKE",doesnotcontain:"NOT LIKE",endswith:"LIKE",startswith:"LIKE",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};if(typeof addSelect==="undefined"){addSelect=false}for(idx=0,length=filters.length;idx1){filterStr="("+filterStr+")"}if(addSelect===true){filterStr="SELECT * FROM "+tableRef._name+" WHERE "+filterStr}return filterStr};progress.util._getObjectType=function(value){return Object.prototype.toString.call(value).slice(8,-1)};progress.util._format=function(fmt){var values=arguments,formatRegExp=/\{(\d+)(:[^\}]+)?\}/g;return fmt.replace(formatRegExp,function(match,index,placeholderFormat){var value=values[parseInt(index,10)+1];return progress.util._toString(value,placeholderFormat?placeholderFormat.substring(1):"")})};progress.util._toString=function(value,fmt){var str;if(fmt){if(progress.util._getObjectType(value)==="Date"){return progress.util._formatDate(value,fmt)}}if(typeof value==="number"){str=value.toString()}else{str=value!==undefined?value:""}return str};progress.util._pad=function(number,digits){var zeros=["","0","00","000","0000"],end;number=String(number);digits=digits||2;end=digits-number.length;if(end){return zeros[digits].substring(0,end)+number}return number};progress.util._formatDate=function(date,format){var dateFormatRegExp=/dd|MM|yyyy|hh|mm|fff|FFF|ss|zzz|iso|"[^"]*"|'[^']*'/g;return format.replace(dateFormatRegExp,function(match){var minutes,result,sign;if(match==="dd"){result=progress.util._pad(date.getDate())}else if(match==="MM"){result=progress.util._pad(date.getMonth()+1)}else if(match==="yyyy"){result=progress.util._pad(date.getFullYear(),4)}else if(match==="hh"){result=progress.util._pad(date.getHours())}else if(match==="mm"){result=progress.util._pad(date.getMinutes())}else if(match==="ss"){result=progress.util._pad(date.getSeconds())}else if(match==="fff"){result=progress.util._pad(date.getMilliseconds(),3)}else if(match==="FFF"){result=String(date.getTime())}else if(match==="zzz"){minutes=date.getTimezoneOffset();sign=minutes<0;result=(sign?"+":"-")+minutes}else if(match==="iso"){result=date.toISOString()}return result!==undefined?result:match.slice(1,match.length-1)})};progress.util.jsdoSettingsProcessor=function jsdoSettingsProcessor(jsdoSettings){if(typeof jsdoSettings==="object"){if(jsdoSettings.authenticationModel===undefined||jsdoSettings.authenticationModel===""){jsdoSettings.authenticationModel="ANONYMOUS"}}}})();(function(){var PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS=20,PROGRESS_JSDO_OP_STRING=["none","create","read","update","delete","submit"],PROGRESS_JSDO_ROW_STATE_STRING=["","created","","modified","deleted"];if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data._nextid=0;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime());var UID_MAX_VALUE=999999999999999;progress.data._getNextId=function(){var uid=++progress.data._nextid;if(uid>=UID_MAX_VALUE){progress.data._nextid=uid=1;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime())}return progress.data._uidprefix+"-"+uid};var msg={};msg.msgs={};msg.msgs.jsdoMSG000="JSDO, Internal Error: {1}";msg.msgs.jsdoMSG001="JSDO: JSDO has multiple tables. Please use {1} at the table reference level.";msg.msgs.jsdoMSG002="JSDO: Working record for '{1}' is undefined.";msg.msgs.jsdoMSG003="JSDO: {1} function requires a function as a parameter.";msg.msgs.jsdoMSG004="JSDO: Unable to find resource '{1}' in the catalog.";msg.msgs.jsdoMSG005="JSDO: Data for table '{1}' was not specified in addRecords() call.";msg.msgs.jsdoMSG006="JSDO: Data for JSDO was not specified in addRecords() call.";msg.msgs.jsdoMSG007="JSDO: Test function in {1} must return a boolean.";msg.msgs.jsdoMSG008="JSDO: Invalid keyFields parameter in addRecords() call.";msg.msgs.jsdoMSG009="JSDO: KeyField '{1}' in addRecords() call was not found in the schema.";msg.msgs.jsdoMSG010="JSDO: Field '{1}' in relationship was not found in the schema.";msg.msgs.jsdoMSG011="UIHelper: JSDO has multiple tables. "+"Please use {1} at the table reference level.";msg.msgs.jsdoMSG012="UIHelper: Invalid {2} parameter in {1} call.";msg.msgs.jsdoMSG020="JSDO: tableName parameter must be a string in addRecords() call.";msg.msgs.jsdoMSG021="JSDO: addMode parameter must be specified in addRecords() call.";msg.msgs.jsdoMSG022="JSDO: Invalid addMode specified in addRecords() call.";msg.msgs.jsdoMSG023="JSDO: Duplicate found in addRecords() call using APPEND mode.";msg.msgs.jsdoMSG024="{1}: Unexpected signature in call to {2} function.";msg.msgs.jsdoMSG025="{1}: Invalid parameters in call to {2} function.";msg.msgs.jsdoMSG026="JSDO: saveChanges requires a "+"CREATE, UPDATE, DELETE or SUBMIT operation to be defined.";msg.msgs.jsdoMSG030="JSDO: Invalid {1}, expected {2}.";msg.msgs.jsdoMSG031="JSDO: Specified sort field name '{1}' was not found in the schema.";msg.msgs.jsdoMSG032="JSDO: Before-image data already exists for record in addRecords() call.";msg.msgs.jsdoMSG033="{1}: Invalid signature for {2}. {3}";msg.msgs.jsdoMSG034="JSDO: In '{1}' function, JSON data is missing _id";msg.msgs.jsdoMSG035="JSDO: In '{1}' function, before-image JSON data is missing prods:clientId";msg.msgs.jsdoMSG036="JSDO: '{1}' can only be called for a dataset";msg.msgs.jsdoMSG037="{1}: Event name must be provided for {2}.";msg.msgs.jsdoMSG038="Too few arguments. There must be at least {1}.";msg.msgs.jsdoMSG039="The name of the event is not a string.";msg.msgs.jsdoMSG040="The event listener is not a function.";msg.msgs.jsdoMSG041="The event listener scope is not an object.";msg.msgs.jsdoMSG042="'{1}' is not a defined event for this object.";msg.msgs.jsdoMSG043="{1}: A session object was requested to check the status of a Mobile "+"Service named '{2}', but it has not loaded the definition of that service.";msg.msgs.jsdoMSG044="JSDO: In '{1}' function, {2} is missing {3} property.";msg.msgs.jsdoMSG045="JSDO: {1} function: {2} is missing {3} property.";msg.msgs.jsdoMSG046="JSDO: {1} operation is not defined.";msg.msgs.jsdoMSG047="{1} timeout expired.";msg.msgs.jsdoMSG048="{1}: {2} method has argument '{3}' that is missing property '{4}'.";msg.msgs.jsdoMSG049="{1}: Unexpected error calling {2}: {3}";msg.msgs.jsdoMSG050="No token returned from server";msg.msgs.jsdoMSG051="{1} The login method was not executed because the AuthenticationProvider is already logged in.";msg.msgs.jsdoMSG052="{1}: The login method was not executed because no credentials were supplied.";msg.msgs.jsdoMSG053="{1}: {2} was not executed because the AuthenticationProvider is not logged in.";msg.msgs.jsdoMSG054="{1}: Token refresh was not executed because the AuthenticationProvider does not have a refresh token.";msg.msgs.jsdoMSG055="{1}: Token refresh was not executed because the authentication model is not sso.";msg.msgs.jsdoMSG056="{1}: Already logged in.";msg.msgs.jsdoMSG057="{1}: Cannot call {2} when authenticationModel is SSO. Please use the AuthenticationProvider object instead.";msg.msgs.jsdoMSG058="{1}: Cannot pass username and password to addCatalog when authenticationModel "+"is sso. Pass an AuthenticationProvider instead.";msg.msgs.jsdoMSG059="{1}: Error in constructor. The authenticationModels of the "+"AuthenticationProvider ({2}) and the JSDOSession ({3}) were not compatible.";msg.msgs.jsdoMSG060="AuthenticationProvider: AuthenticationProvider is no longer logged in. "+"Tried to refresh SSO token but failed due to authentication error at token server.";msg.msgs.jsdoMSG061="{1}: Attempted to set {2} property to an invalid value.";msg.msgs.jsdoMSG062="{1}: Cannot call {2} when an AuthenticationProvider is already available and logged in.";msg.msgs.jsdoMSG100="JSDO: Unexpected HTTP response. Too many records.";msg.msgs.jsdoMSG101="Network error while executing HTTP request.";msg.msgs.jsdoMSG110="Catalog error: idProperty not specified for resource '{1}'. "+"idProperty is required {2}.";msg.msgs.jsdoMSG111="Catalog error: Schema '{1}' was not found in catalog.";msg.msgs.jsdoMSG112="Catalog error: Output parameter '{1}' was not found for operation '{2}'.";msg.msgs.jsdoMSG113="Catalog error: Found xType '{1}' for output parameter '{2}' "+"for operation '{3}' but xType DATASET, TABLE or ARRAY was expected.";msg.msgs.jsdoMSG114="JSDO: idProperty '{1}' is missing from '{2}' record.";msg.msgs.jsdoMSG115="JSDO: Invalid option specified in {1}() call.";msg.msgs.jsdoMSG116="JSDO: {1} parameter must be a string in {2} call.";msg.msgs.jsdoMSG117="JSDO: Schema from storage area '{1}' does not match JSDO schema";msg.msgs.jsdoMSG118="JSDO: Plugin '{1}' was not found.";msg.msgs.jsdoMSG119="JSDO: A mappingType is expected when 'capabilities' is set."+" Please specify a plugin (ex: JFP).";msg.msgs.jsdoMSG120="JSDO: Parameter '{2}' requires capability '{1}' in the catalog.";msg.msgs.jsdoMSG121="{1}: Argument {2} must be of type {3} in {4} call.";msg.msgs.jsdoMSG122="{1}: Incorrect number of arguments in {2} call. There should be {3}.";msg.msgs.jsdoMSG123="{1}: A server response included an invalid '{2}' header.";msg.msgs.jsdoMSG124="JSDO: autoApplyChanges is not supported for saveChanges(true) "+"with a temp-table. Use jsdo.autoApplyChanges = false.";msg.msgs.jsdoMSG125="{1}: The AuthenticationProvider is not managing valid credentials.";msg.msgs.jsdoMSG126="{1}: No support for {2}.";msg.msgs.jsdoMSG127="JSDO: acceptRowChanges() cannot be called for record with _rejected === true.";msg.msgs.jsdoMSG500="{1}: '{2}' objects must contain a '{3}' property.";msg.msgs.jsdoMSG501="{1}: '{2}' in '{3}' function cannot be an empty string.";msg.msgs.jsdoMSG502="{1}: The '{2}' parameter passed to the '{3}' function has an invalid value for "+"its '{4}' property.";msg.msgs.jsdoMSG503="{1}: '{2}' must be of type '{3}'.";msg.msgs.jsdoMSG504="{1}: {2} has an invalid value for the '{3}' property.";msg.msgs.jsdoMSG505="{1}: '{2}' objects must have a '{3}' method.";msg.msgs.jsdoMSG506="{1}: Invalid argument for the {2} parameter in {3} call.";msg.msgs.jsdoMSG507="{1}: '{2}' is an invalid value for the {3} parameter in {4} call.";msg.msgs.jsdoMSG508="JSDOSession: If a JSDOSession object is using the SSO authentication model, "+"the options object passed to its constructor must include an authProvider property.";msg.msgs.jsdoMSG509="progress.data.getSession: If the authenticationModel is AUTH_TYPE_SSO, "+"authenticationURI and authProviderAuthenticationModel are required parameters.";msg.msgs.jsdoMSG510="{1}: This session has been invalidated and cannot be used.";msg.msgs.jsdoMSG511="JSDOSession: addCatalog() can only be called if an AuthenticationProvider was passed as an argument or "+"connect() has been successfully called.";msg.msgs.jsdoMSG512="JSDOSession: Error while loading multiple catalogs.";msg.msgs.jsdoMSG998="JSDO: JSON object in addRecords() must be DataSet or Temp-Table data.";msg.getMsgText=function(n,args){var text=msg.msgs[n],i;if(!text){throw new Error("Message text was not found by getMsgText()")}for(i=1;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true;data=newDataArray}else{if(params&&(params.sort||params.top)){newDataArray=[];for(i=0;i0){sortObject.tableRef=this;data.sort(this._getCompareFn(sortObject))}}if(params.top){if(typeof params.skip=="undefined"){params.skip=0}data=data.splice(params.skip,params.top)}}return data};this._recToDataObject=function(record,includeChildren){var array=[record];var dataObject=array;if(typeof includeChildren=="undefined"){includeChildren=false}if(this._jsdo._dataSetName){dataObject={};dataObject[this._jsdo._dataSetName]={};dataObject[this._jsdo._dataSetName][this._name]=array;if(includeChildren&&this._children.length>0){var jsrecord=this._findById(record._id,false);if(jsrecord){for(var i=0;i0){for(var j=0;j0){for(var i=0;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true};this._equalRecord=function(rec1,rec2,keyFields){var field;var match=true;for(var i=0;ivalue2||(value1===undefined||value1===null))return sortAscending[i]?1:-1;else if(value10)this._sort(sortObject)}else{this._sort(arg1)}this._createIndex()};this._sort=function(arg1){if(arguments.length===0&&(!this.autoSort||this._sortFn===undefined&&this._sortObject.sortFields===undefined))return;if(arguments.length===0){if(this._sortFn){this._data.sort(this._sortFn)}else{this._data.sort(this._compareFields)}this._needsAutoSorting=false}else{if(typeof arg1=="function"){this._data.sort(this._getCompareFn(arg1))}else{arg1.tableRef=this;this._data.sort(this._getCompareFn(arg1))}if(this.autoSort)this._needsAutoSorting=true}};this.addRecords=function(jsonObject,addMode,keyFields,trackChanges,isInvoke){this._jsdo._addRecords(this._name,jsonObject,addMode,keyFields,trackChanges,isInvoke)};this.acceptChanges=function(){var tableRef=this;for(var id in tableRef._beforeImage){if(tableRef._beforeImage[id]===null){var jsrecord=tableRef._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}else if(this._changed[id]!==undefined){var jsrecord=this._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}}tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[];tableRef._beforeImage={}};this.rejectChanges=function(){for(var id in this._beforeImage){if(this._beforeImage[id]===null){this._jsdo._undoCreate(this,id)}else if(this._changed[id]!==undefined){this._jsdo._undoUpdate(this,id,true)}else{this._jsdo._undoDelete(this,id,true)}}var tableRef=this;tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[]};this.hasChanges=function(){return Object.keys(this._beforeImage).length!==0};this.getChanges=function(){var result=[];for(var id in this._beforeImage){var item={rowState:"",record:null};if(this._beforeImage[id]===null){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_CREATE];item.record=this._findById(id,false)}else if(this._changed[id]!==undefined){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_UPDATE];item.record=this._findById(id,false)}else{item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_DELETE];item.record=new progress.data.JSRecord(this,this._beforeImage[id])}result.push(item)}return result};this._clearErrorStrings=function(){var record=null;for(var id in this._beforeImage){if(this._beforeImage[id]===null){record=this._findById(id,false);if(record){delete record.data._errorString}}else{record=this._findById(id,false);if(record){delete record.data._errorString}else{delete this._beforeImage[id]._errorString}}}};this._applyChanges=function(){var i;for(var id in this._beforeImage){if(this._beforeImage[id]===null){var jsrecord=this._findById(id,false);if(jsrecord===null&&this._jsdo._resource.idProperty!==undefined){if(this._tmpIndex[id]){var record=this._data[this._tmpIndex[id].index];jsrecord=record?new progress.data.JSRecord(this,record):null;delete this._tmpIndex[id]}}if(jsrecord!==null){if(jsrecord.data._rejected||jsrecord.data._errorString!==undefined){this._jsdo._undoCreate(this,id)}else{jsrecord.acceptRowChanges()}}else{var found=false;for(var i=0;i0){for(var i=0;iindex){i--}if(i!=index){this._tableRef._data.splice(index,1);this._tableRef._data.splice(i,0,record);this._tableRef._createIndex()}}}};this.assign=function(record){if(record===undefined)throw new Error(msg.getMsgText("jsdoMSG024","JSDO","assign() or update()"));this._saveBeforeImageUpdate();var fieldName,i,j,value,schema=this._tableRef.getSchema(),prefixElement,name;if(record){for(i=0;i0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){return this.record.data[name][element-1]}}return this.record.data[fieldName]}else return null},set:function(value){var name=fieldName,index,element,fieldInfo;if(this.record){this.record._saveBeforeImageUpdate();try{index=fieldName.indexOf(progress.data.JSDO.ARRAY_INDEX_SEPARATOR);if(index>0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){this.record.data[name][element-1]=value;return}}this.record.data[fieldName]=value}finally{this.record._sortRecord(name)}}},enumerable:true,writeable:true})};Object.defineProperty(this,"hasSubmitOperation",{get:function(){return this._hasSubmitOperation},enumerable:true});Object.defineProperty(this,"hasCUDOperations",{get:function(){return this._hasCUDOperations},enumerable:true});Object.defineProperty(this,"defaultTableRef",{get:function(){return this._defaultTableRef},enumerable:true});this._buffers={};this._numBuffers=0;this._defaultTableRef=null;this._async=true;this._dataProperty=null;this._dataSetName=null;this.operations=[];this.useRelationships=true;this._session=null;this._needCompaction=false;this._hasCUDOperations=false;this._hasSubmitOperation=false;this._useSubmit=false;this.autoApplyChanges=true;this._lastErrors=[];this._localStorage=null;this._convertForServer;this._fillMergeMode;var autoFill=false;if(!arguments[0]){throw new Error("JSDO: Parameters are required in constructor.")}if(typeof arguments[0]=="string"){this.name=arguments[0]}else if(typeof arguments[0]=="object"){var args=arguments[0];for(var v in args){switch(v){case"autoFill":autoFill=args[v];break;case"events":this._events={};for(var eventName in args[v]){this._events[eventName.toLowerCase()]=args[v][eventName]}break;case"dataProperty":this._dataProperty=args[v];break;default:this[v]=args[v]}}}if(!this.name){throw new Error("JSDO: JSDO constructor is missing the value for 'name'")}if(this._events){if(typeof this._events!=="object"){throw new Error("JSDO: JSDO constructor event object is not defined as an object")}for(var prop in this._events){var evt=this._events[prop];if(!(evt instanceof Array)){throw new Error("JSDO: JSDO constructor event object for "+prop+" must be an array")}evt.forEach(function(el){if(typeof el!=="object"){throw new Error("JSDO: JSDO constuctor event object for "+prop+" is not defined as an object")}if(typeof el.fn!=="function"){throw new Error("JSDO: JSDO event listener for "+prop+" is not a function.")}if(el.scope&&typeof el.scope!=="object"){throw new Error("JSDO: JSDO event listener scope for "+prop+" is not an object.")}})}}if(this.name){this._resource=progress.data.ServicesManager.getResource(this.name);if(this._resource){if(!this.url)this.url=this._resource.url;if(!this._dataSetName&&this._resource._dataSetName){this._dataSetName=this._resource._dataSetName;if(this._resource.dataProperty){var buffer=this[this._resource.dataProperty]=new progress.data.JSTableRef(this,this._resource.dataProperty);this._buffers[this._resource.dataProperty]=buffer}else{for(var tableName in this._resource.fields){var buffer=this[tableName]=new progress.data.JSTableRef(this,tableName);this._buffers[tableName]=buffer}}}if(!this._dataProperty&&this._resource.dataProperty)this._dataProperty=this._resource.dataProperty;if(!this._dataSetName){var tableName=this._dataProperty?this._dataProperty:"";this._buffers[tableName]=new progress.data.JSTableRef(this,tableName);if(tableName)this[tableName]=this._buffers[tableName]}var properties,tableName;if(this._dataSetName&&this._resource.schema&&this._resource.schema.properties[this._dataSetName]){properties=this._resource.schema.properties[this._dataSetName].properties;if(Object.keys(properties).length===1){tableName=Object.keys(properties)[0];if(properties[tableName].idProperty){this._resource.idProperty=properties[tableName].idProperty}}}else if(this._resource.schema&&this._resource.schema.properties&&this._resource.schema.properties[tableName]&&this._resource.schema.properties[tableName].idProperty){this._resource.idProperty=this._resource.schema.properties[tableName].idProperty}for(var fnName in this._resource.fn){this[fnName]=this._resource.fn[fnName]["function"]}this._hasCUDOperations=this._resource.generic["create"]!==undefined||this._resource.generic["update"]!==undefined||this._resource.generic["delete"]!==undefined;this._hasSubmitOperation=this._resource.generic["submit"]!==undefined;if(!this._session){var myservice=progress.data.ServicesManager.getService(this._resource.service.name);this._session=myservice._session;this._session._pushJSDOs(this)}}else{throw new Error(msg.getMsgText("jsdoMSG004",this.name))}}else{this._buffers[""]=new progress.data.JSTableRef(this,"")}if(!this._session){throw new Error("JSDO: Unable to get user session for resource '"+this.name+"'")}for(var buf in this._buffers){this._buffers[buf]._parent=null;this._buffers[buf]._children=[];this._buffers[buf]._relationship=null;this._buffers[buf]._isNested=false;if(!this._defaultTableRef)this._defaultTableRef=this._buffers[buf];this._numBuffers++}if(this._numBuffers!=1)this._defaultTableRef=null;else{this.record=null}if(typeof Object.defineProperty=="function"){this._caseSensitive=false;Object.defineProperty(this,"caseSensitive",{get:function(){return this._caseSensitive},set:function(value){this._caseSensitive=value?true:false;for(var buf in this._buffers){this._buffers[buf].caseSensitive=this._caseSensitive}},enumerable:true,writeable:true});this._autoSort=true;Object.defineProperty(this,"autoSort",{get:function(){return this._autoSort},set:function(value){this._autoSort=value?true:false;for(var buf in this._buffers){this._buffers[buf].autoSort=this._autoSort}},enumerable:true,writeable:true})}this._properties={};if(typeof Object.defineProperty=="function"){Object.defineProperty(this,"this._properties",{get:function(){return this._properties},enumerable:false})}if(this._resource&&this._resource.fields){for(var buf in this._buffers){this._buffers[buf]._schema=this._resource.fields[buf];this._buffers[buf]._primaryKeys=this._resource.primaryKeys[buf];this._buffers[buf]._fields={};var fields=this._buffers[buf]._schema;for(var i=0;i1){for(var buf in this._buffers){var fields=[];var found=false;for(var i=0;i=0?index+1:"");element.value=value?value[index]:undefined;return element};this.isDataSet=function(){return this._dataSetName?true:false};this._invokeComplete=function(jsdo,success,request){if(request.async&&request.fnName){jsdo.trigger("afterInvoke",request.fnName,jsdo,success,request)}if(request.deferred){if(success){request.deferred.resolve(jsdo,success,request)}else{request.deferred.reject(jsdo,success,request)}}};this._invokeSuccess=function(){};this._invokeError=function(){};this._httpRequest=function(xhr,method,url,reqBody,request){function afterOpenRequest(){var input=null;if(reqBody){xhr.setRequestHeader("Content-Type","application/json; charset=utf-8");input=JSON.stringify(reqBody)}try{xhr.send(input)}catch(e){request.success=false;request.exception=e;xhr.jsdo._session._checkServiceResponse(xhr,request.success,request)}}if(!xhr){xhr=new XMLHttpRequest;xhr.onCompleteFn=this._invokeComplete;xhr.onSuccessFn=this._invokeSuccess;xhr.onErrorFn=this._invokeError;xhr.onreadystatechange=this.onReadyStateChangeGeneric;if(request.async&&request.fnName){this.trigger("beforeInvoke",request.fnName,this,request)}if(reqBody){if(this._resource&&this._resource.service){var useRequest=this._resource.service.useRequest;if(this._resource.service.settings&&this._resource.service.settings.useRequest!==undefined){useRequest=this._resource.service.settings.useRequest}if(useRequest){reqBody={request:reqBody}}}}}xhr.request=request;xhr.jsdo=this;request.jsdo=this;request.xhr=xhr;this._session._openRequest(xhr,method,url,request.async,afterOpenRequest);return request};this._getDataObject=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};var oldUseRelationships=this.useRelationships;try{this.useRelationships=false;for(var buf in this._buffers){dataObject[this._dataSetName][buf]=this._buffers[buf].getData()}}finally{this.useRelationships=oldUseRelationships}}else{if(this._dataProperty){dataObject[this._dataProperty]=this.getData()}else return this.getData()}return dataObject};this._getDataObjectAsNested=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};try{for(var buf in this._buffers){var bufObj=this._buffers[buf];if(bufObj._isNested)continue;this._nestChildren=false;if(bufObj._children.length>0){for(var i=0;i0){hasErrors=true}}if(hasErrors){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._allRecordsRejected=true;this._someRecordsRejected=false;hasCommittedRecords=false;for(i=0;i0&&!param.operations[0].success){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._convertForServer=true;this._buffers[buf]._convertForServer=true}}};this._convertRequestData=function(objParam){var buf,beforeData;if(this._convertForServer===false){return}for(buf in this._buffers){if(this._buffers[buf]._convertForServer){if(objParam[this._dataSetName]){if(objParam[this._dataSetName][buf]){this._convertTableData(this._buffers[buf],objParam[this._dataSetName][buf])}beforeData=objParam[this._dataSetName]["prods:before"];if(beforeData&&beforeData[buf]){this._convertTableData(this._buffers[buf],beforeData[buf])}}else if(objParam[buf]){this._convertTableData(this._buffers[buf],objParam[buf])}}}};this._convertTableData=function(tableRef,tableData){var i;for(i=0;i0){this._confirmOperationExists(progress.data.JSDO._OP_DELETE);checkedDelete=true}if(!checkedCreate&&tableRef._added.length>0){this._confirmOperationExists(progress.data.JSDO._OP_CREATE);checkedCreate=true}if(!checkedUpdate&&Object.keys(tableRef._changed).length>0){this._confirmOperationExists(progress.data.JSDO._OP_UPDATE);checkedUpdate=true}if(checkedDelete&&checkedCreate&&checkedUpdate){break}}};this._confirmOperationExists=function(operation){var operationStr=PROGRESS_JSDO_OP_STRING[operation];if(typeof this._resource.generic[operationStr]!=="function"){throw new Error(msg.getMsgText("jsdoMSG046",operationStr.toUpperCase()))}};this.invoke=function(name,object){var deferred,promise;try{var request=this[name](object);if(request.deferred){deferred=request.deferred;promise=request.deferred.promise()}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{if(!deferred){deferred=new progress.util.Deferred;promise=deferred.promise()}deferred.reject(this,false,{errorObject:error})}}return promise};this._syncTableRef=function(operation,tableRef,batch){var rowData,requestData,jsonObject,dataSetObject;if(tableRef._visited)return;tableRef._visited=true;if(!batch){batch={operations:[]}}else if(!batch.operations){batch.operations=[]}switch(operation){case progress.data.JSDO._OP_CREATE:for(var i=0;i0&&!dataSetJsonObject[tableRef._name])dataSetJsonObject[tableRef._name]=[];for(var i=0;i0||tableRef._added.length>0||hasUpdates){hasChanges=true;break}}return hasChanges};this._addDeletesToChangeSet=function(tableRef,dataSetJsonObject,request){for(var i=0;i=10){tmpIndex={};for(var i=0;ivalue2||value1===null)return false;else if(value11){for(var buf in this._buffers){if(this._buffers[buf]._isNested&&this._buffers[buf]._parent&&this._buffers[this._buffers[buf]._parent]){var srcData=this._buffers[this._buffers[buf]._parent]._data;var data=[];for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}var recordId=beforeTableJsonObject[0]["prods:clientId"];if(!recordId){throw new Error(msg.getMsgText("jsdoMSG035","_checkForDeleteError()"))}if(beforeTableJsonObject[0]["prods:hasErrors"]){var prods_id=beforeTableJsonObject[0]["prods:id"];var errorString=this._getErrorStringFromJsonObject(dataSetJsonObject,tableRef,prods_id);this._setErrorString(tableRef,recordId,errorString,true);hasError=true}}return hasError};this._mergeUpdateForSubmit=function(jsonObject,xhr){var errorString;if(!this._dataSetName){throw new Error(msg.getMsgText("jsdoMSG036","_mergeUpdateForSubmit()"))}var dataSetJsonObject=jsonObject[this._dataSetName];if(dataSetJsonObject[this._dataSetName])dataSetJsonObject=dataSetJsonObject[this._dataSetName];var beforeJsonObject=dataSetJsonObject["prods:before"];for(var buf in this._buffers){var tableRef=this._buffers[buf];var tableJsonObject=dataSetJsonObject[tableRef._name];if(tableJsonObject instanceof Array){for(var i=0;i1){request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}}if(beforeJsonObject){hasError=jsdo._checkForDeleteError(dataSetJsonObject,xhr)}if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._deleteError(jsdo,success,request)}}};this._deleteError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoDelete(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._createComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterCreate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterCreate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._createSuccess=function(jsdo,success,request){var xhr=request.xhr;var record=request.response;var hasError=jsdo._mergeUpdateForCUD(record,xhr);if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._createError(jsdo,success,request)}}};this._createError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoCreate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._updateComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterUpdate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterUpdate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._updateSuccess=function(jsdo,success,request){var xhr=request.xhr;var hasError=jsdo._mergeUpdateForCUD(request.response,xhr);if(hasError){request.success=false}if(jsdo.autoApplyChanges){if(!hasError){request.success=true;delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._updateError(jsdo,success,request)}}};this._updateError=function(jsdo,success,request){if(jsdo.autoApplyChanges){request.success=false;jsdo._undoUpdate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._saveChangesSuccess=function(jsdo,success,request){var records=request.response;jsdo._mergeUpdateForSubmit(records,request.xhr);jsdo._clearErrors();var changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(changes);if(jsdo.autoApplyChanges){jsdo._applyChanges()}};this._saveChangesError=function(jsdo,success,request){jsdo._setAllRecordsRejected(true);if(jsdo.autoApplyChanges){jsdo.rejectChanges()}jsdo._updateLastErrors(jsdo,null,null,request)};this._saveChangesSuccessTT=function(jsdo,success,request){var changes;jsdo._clearErrors();changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(false)};this._saveChangesComplete=function(jsdo,success,request){if(request.xhr.status>=200&&request.xhr.status<300&&(jsdo._lastErrors.length>0||jsdo._someRecordsRejected)){request.success=false}if(jsdo._useSubmit===true){jsdo._fireCUDTriggersForSubmit(request)}jsdo._undefWorkingRecord();jsdo._fireAfterSaveChanges(request.success,request)};this._fireAfterSaveChanges=function(success,request){this.trigger("afterSaveChanges",this,success,request);if(request.jsrecords){if(request.deferred){if(success){request.deferred.resolve(this,success,request)}else{request.deferred.reject(this,success,request)}}}else if(request.batch&&request.batch.deferred){if(success){request.batch.deferred.resolve(this,success,request)}else{request.batch.deferred.reject(this,success,request)}}var clearErrorString=this.autoApplyChanges;if(request.jsrecords){for(var idx=0;idx=400&&request.xhr.status<600){try{var responseObject=JSON.parse(request.xhr.responseText);if(responseObject instanceof Array){errorArray=responseObject}else if(responseObject instanceof Object){errorArray.push(responseObject)}for(i=0;i=400&&request.xhr.status<600)){errors.push({type:progress.data.JSDO.ERROR,error:"Error: HTTP Status "+request.xhr.status+" "+request.xhr.statusText,responseText:request.xhr.responseText})}}return errors};this._updateLastErrors=function(jsdo,batch,changes,request){var errors,errorText,responseObject,i,j,buf;if(batch){if(batch.operations===undefined)return;for(i=0;i=200&&request.xhr.status<300){jsdo._lastErrors.push({errorString:request.jsrecord.data._errorString});jsdo._buffers[request.jsrecord._tableRef._name]._lastErrors.push({type:progress.data.JSDO.DATA_ERROR,id:request.jsrecord.data._id,error:request.jsrecord.data._errorString})}else{errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}if(request.jsrecord&&(errors[j].type===progress.data.JSDO.APP_ERROR||errors[j].type===progress.data.JSDO.RETVAL)){errors[j].id=request.jsrecord.data._id;request.jsrecord._tableRef._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}}}}else if(changes instanceof Array){for(i=0;i=400&&request.xhr.status<600||request.xhr.status===0)){errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}for(buf in this._buffers){this._buffers[buf]._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}};this._checkSaveComplete=function(xhr){if(xhr.request){var jsdo=xhr.request.jsdo;var batch=xhr.request.batch;if(jsdo&&batch&&jsdo._async){if(jsdo._isBatchComplete(batch)){var success=jsdo._isBatchSuccess(batch);var request={batch:batch,success:success};jsdo._undefWorkingRecord();jsdo._lastErrors=[];if(!success&&batch.operations){jsdo._updateLastErrors(jsdo,batch,null)}this._setAllRecordsRejected(batch);jsdo._fireAfterSaveChanges(success,request)}}}};this._isBatchSuccess=function(batch){if(batch.operations){for(var i=0;i=200&&xhr.status<300||xhr.status===0&&xhr.responseText!==""){request.success=true;xhr.jsdo._session._saveClientContextId(xhr);if(typeof xhr.onSuccessFn=="function"){var operation;if(xhr.request.fnName!==undefined&&xhr.jsdo._resource.fn[xhr.request.fnName]!==undefined){operation=xhr.jsdo._resource.fn[xhr.request.fnName].operation}else operation=null;if(operation===undefined||operation!==null&&operation.mergeMode)xhr.jsdo._mergeInvoke(request.response,xhr);if(request.success)xhr.onSuccessFn(xhr.jsdo,request.success,request);else if(typeof xhr.onErrorFn=="function")xhr.onErrorFn(xhr.jsdo,request.success,request)}}else{request.success=false;if(xhr.status===0){request.exception=new Error(msg.getMsgText("jsdoMSG101"))}if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}xhr.jsdo._session._checkServiceResponse(xhr,request.success,request);if(typeof xhr.onCompleteFn=="function"){xhr.onCompleteFn(xhr.jsdo,request.success,request)}}};this.acceptChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].acceptChanges()}};this.rejectChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].rejectChanges()}};this.getChanges=function(){var result=[];for(var buf in this._buffers){var changes=this._buffers[this._buffers[buf]._name].getChanges();result=result.concat(changes)}return result};this.hasChanges=function(){for(var buf in this._buffers){if(this._buffers[this._buffers[buf]._name].hasChanges())return true}return false};this._applyChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name]._applyChanges()}};this.acceptRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.acceptRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","acceptRowChanges()"))};this.rejectRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.rejectRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","rejectRowChanges()"))};this.setProperties=function(propertiesObject){var prop;if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(typeof propertiesObject=="object"){this._properties={};for(prop in propertiesObject){if(propertiesObject.hasOwnProperty(prop)){if(typeof propertiesObject[prop]!=="function"){this._properties[prop]=propertiesObject[prop]}}}}else if(propertiesObject===undefined||propertiesObject===null){this._properties={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"Object","setProperties"))}};this.setProperty=function(propertyName,propertyValue){if(arguments.length<2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(arguments.length!==2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(typeof propertyName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"string","setProperty"))}if(propertyValue===undefined){delete this._properties[propertyName]}else{this._properties[propertyName]=propertyValue}};this.getProperties=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperties",0))}return this._properties};this.getProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}return this._properties[propertyName]};this.saveLocal=function saveLocal(arg1,arg2){var name;var dataMode;if(arguments.length>2){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"||arg1===null||arg1===undefined){name=arg1;dataMode=arg2}else{name=null;dataMode=arg1}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}if(typeof dataMode=="undefined"){dataMode=progress.data.JSDO.ALL_DATA}else{switch(dataMode){case progress.data.JSDO.ALL_DATA:case progress.data.JSDO.CHANGES_ONLY:break;default:throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var dataObj=this._prepareDataObjectForLocalStorage(dataMode);this._localStorage.saveToLocalStorage(name,dataObj)};this.readLocal=function readLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));this._restoreFromLocalStorage(object,progress.data.JSDO.MODE_EMPTY)}return object!==null};this.addLocalRecords=function addLocalRecords(arg1,arg2,arg3){var name;var addMode;var keyFields;if(arguments.length<1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"){name=arg1;addMode=arg2;keyFields=arg3}else{name="jsdo_"+this._resource.service.name+"_"+this._resource.name;addMode=arg1;keyFields=arg2}if(typeof name=="undefined"||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(addMode!=progress.data.JSDO.MODE_REPLACE){throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));try{this._restoreFromLocalStorage(object,addMode,keyFields)}catch(e){var text=e.message;throw new Error(text.replace(new RegExp("addRecords","g"),"addLocalRecords"))}}return object!==null};this._containsPrimaryKeys=function _containsPrimaryKeys(){for(var buf in this._buffers){if(this._buffers[buf]._primaryKeys===null)return false}return true};this._hasMatchingSchema=function _hasMatchingSchema(storageObject){var isValid=true;if(storageObject===null||Object.keys(storageObject).length===0)return true;if(this._dataSetName){if(storageObject[this._dataSetName]){for(var buf in this._buffers)if(storageObject[this._dataSetName][buf]===undefined){isValid=false;break}}else isValid=false}else if(this._dataProperty){storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._dataProperty]===undefined)isValid=false}else{storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._defaultTableRef._name]===undefined)isValid=false}return isValid};this.deleteLocal=function deleteLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}this._localStorage.clearLocalStorage(name)};this._prepareDataObjectForLocalStorage=function(option){var storageObject={};if(this._dataSetName){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet(this._dataSetName);break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet(this._dataSetName,true);break}}else if(this._dataProperty){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}else{switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}return storageObject};this._restoreFromLocalStorage=function(storageObject,addMode,keyFields){if(storageObject&&Object.keys(storageObject).length>0){if(this._dataSetName){for(var buf in this._buffers)this._restoreDataForTable(this._buffers[buf],storageObject,addMode,keyFields)}else this._restoreDataForTable(this._defaultTableRef,storageObject,addMode,keyFields)}else if(addMode===progress.data.JSDO.MODE_EMPTY)this._clearData()};this._restoreDataForTable=function(tableRef,jsonObject,addMode,keyFields){keyFields=keyFields!==undefined?keyFields:tableRef._primaryKeys;if(keyFields===undefined&&this._resource.idProperty){keyFields=[];keyFields[0]=this._resource.idProperty}if(this._dataSetName){var oldUseRelationships=this.useRelationships;this.useRelationships=false;try{tableRef.addRecords(jsonObject,addMode,keyFields)}finally{this.useRelationships=oldUseRelationships}}else{this._dataSetName="_localStorage";tableRef.addRecords(jsonObject,addMode,keyFields);this._dataSetName=null}};this.getMethodProperties=function(operation,name){var idx;if(this._resource._operations){if(this._resource._operations[operation]){return this._resource._operations[operation]}}else{this._resource._operations={}}for(var idx=0;idx1?[params.sort]:[]}sortFields="";for(index=0;index=1?params.filter:undefined}if(params.filter){if(typeof params.filter==="string"){doConversion=false}params.tableRef=tableName;if(doConversion&¶ms.tableRef===undefined){throw new Error(msg.getMsgText("jsdoMSG045","fill() or read()","params","tableRef"))}if(reqCapabilities["filter"].mapping==="ablFilter"){if(doConversion){ablFilter=progress.util._convertToABLWhereString(jsdo._buffers[params.tableRef],params.filter)}else{ablFilter=params.filter}}else if(reqCapabilities["filter"].mapping==="sqlQuery"){if(doConversion){sqlQuery=progress.util._convertToSQLQueryString(jsdo._buffers[params.tableRef],params.filter,true)}else{sqlQuery=params.filter}}}filter=JSON.stringify({ablFilter:ablFilter,sqlQuery:sqlQuery,orderBy:sortFields,skip:params.skip,top:params.top,id:params.id});params={filter:filter}}return params}});if(typeof progress.ui=="undefined")progress.ui={};progress.ui.UITableRef=function UITableRef(tableRef){this._tableRef=tableRef;this._listview=null;this._detailPage=null;this._listviewContent=undefined;this.addItem=function(format){var detailForm;if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._name));if(!this._listview)return;format=format?format:this._listview.format;detailForm=this._detailPage&&this._detailPage.name?this._detailPage.name:"";if(this._listviewContent===undefined){this.clearItems()}var text=this._listview.itemTemplate?this._listview.itemTemplate:progress.ui.UIHelper._itemTemplate;text=text.replace(new RegExp("{__format__}","g"),format);text=text.replace(new RegExp("{__id__}","g"),this._tableRef.record.data._id);text=text.replace(new RegExp("{__page__}","g"),detailForm);for(var field in this._tableRef.record.data){var value=this._tableRef.record.data[field];text=text.replace(new RegExp("{"+field+"}","g"),value!==undefined&&value!==null?value:"")}this._listviewContent+=text};this.clearItems=function(){if(this._listview){this._listviewContent="";var listviewElement=document.getElementById(this._listview.name);if(listviewElement){listviewElement.innerHTML=""}}};this._getFormFieldValue=function(fieldName,detailPageName){var value=null,field;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)value=field.val()}else{field=document.getElementById(fieldName);if(field){value=field.value}}return value};this._setFormField=function(fieldName,value,detailPageName){var field=null;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)field.val(value)}else{field=document.getElementById(fieldName);if(field){field.value=value}}};this.assign=function(detailPageName){if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._tableRef._name));if(arguments.length!==0&&typeof detailPageName!="string")throw new Error(msg.getMsgText("jsdoMSG024","UIHelper","assign()"));this._tableRef.record.assign(null);var fieldName;var schema=this._tableRef.getSchema();for(var i=0;i0){for(var i=0;i0&&fieldName.charAt(0)=="_")continue;if(fields&&fields[fieldName]===undefined)continue;var fieldLabel=this._tableRef._schema[i].title?this._tableRef._schema[i].title:this._tableRef._schema[i].name;var text=this._detailPage&&this._detailPage.fieldTemplate?this._detailPage.fieldTemplate:progress.ui.UIHelper._fieldTemplate;text=text.replace(new RegExp("{__label__}","g"),fieldLabel);text=text.replace(new RegExp("{__name__}","g"),this._tableRef._schema[i].name);htmltext+=text}htmltext+="";fields=null;return htmltext};this.getListViewRecord=function(htmlIElement){var id=htmlIElement.getAttribute("data-id");return this._tableRef.findById(id)};this.getFormRecord=function(detailPageName){var id=this._getFormFieldValue("_id",detailPageName);return this._tableRef.findById(id)};this._getIdOfElement=function(name){if(typeof $=="function"){var element=$("#"+name);if(!element||element.length===0){element=$('[dsid="'+name+'"]');if(element&&element.length==1){var id=element.attr("id");if(id)return id}}}return name};this.setDetailPage=function setDetailPage(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));this._detailPage=obj;this._detailPage.name=this._getIdOfElement(this._detailPage.name)};this.setListView=function setListView(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));if(obj.format&&typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"format"));this._listview=obj;this._listview.name=this._getIdOfElement(this._listview.name);if(!this._listview.format){if(typeof $=="function"){for(var i=0;i{__format__}';progress.ui.UIHelper._defaultFieldTemplate='
'+''+'
';progress.ui.UIHelper._itemTemplate=progress.ui.UIHelper._defaultItemTemplate;progress.ui.UIHelper._fieldTemplate=progress.ui.UIHelper._defaultFieldTemplate;progress.ui.UIHelper.setItemTemplate=function(template){progress.ui.UIHelper._itemTemplate=template?template:progress.ui.UIHelper._defaultItemTemplate};progress.ui.UIHelper.setFieldTemplate=function(template){progress.ui.UIHelper._fieldTemplate=template?template:progress.ui.UIHelper._defaultFieldTemplate}})();(function(){if(progress===undefined){progress={}}if(progress.data===undefined){progress.data={}}progress.data.ServicesManager={};progress.data.ServicesManager._services=[];progress.data.ServicesManager._resources=[];progress.data.ServicesManager._data=[];progress.data.ServicesManager._sessions=[];progress.data.ServicesManager._jsdosessions=[];progress.data.ServicesManager.addResource=function(id,resource){if(progress.data.ServicesManager._resources[id]===undefined){progress.data.ServicesManager._resources[id]=resource}else{throw new Error("A resource named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getResource=function(id){return progress.data.ServicesManager._resources[id]};progress.data.ServicesManager.addService=function(id,service){if(progress.data.ServicesManager._services[id]===undefined){progress.data.ServicesManager._services[id]=service}else{throw new Error("A service named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getService=function(id){return progress.data.ServicesManager._services[id]};progress.data.ServicesManager.addSession=function(catalogURI,session){if(progress.data.ServicesManager._sessions[catalogURI]===undefined){progress.data.ServicesManager._sessions[catalogURI]=session}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.addJSDOSession=function(catalogURI,jsdosession){if(progress.data.ServicesManager._jsdosessions[catalogURI]===undefined){progress.data.ServicesManager._jsdosessions[catalogURI]=jsdosession}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.getSession=function(catalogURI){try{return progress.data.ServicesManager._sessions[catalogURI]}catch(e){return null}};progress.data.ServicesManager.cleanSession=function(session){var servicesKey,resourcesKey,sessionsKey,service,services=progress.data.ServicesManager._services,resources=progress.data.ServicesManager._resources,sessions=progress.data.ServicesManager._sessions,jsdosessions=progress.data.ServicesManager._jsdosessions;for(servicesKey in services){service=null;if(services[servicesKey]._session===session){service=services[servicesKey];delete services[servicesKey]}if(!service){continue}for(resourcesKey in resources){if(resources[resourcesKey].service===service){delete resources[resourcesKey]}}}for(sessionsKey in sessions){if(sessions[sessionsKey]===session){delete sessions[sessionsKey];if(jsdosessions[sessionsKey]){delete jsdosessions[sessionsKey]}}}};function extractParamsFromURL(url){var urlParams=[],paramName=null;if(typeof url==="string"){url.split("").forEach(function(c){if(c==="{"){paramName=""}else if(c==="}"){if(paramName){urlParams.push(paramName)}paramName=null}else if(paramName!==null){paramName+=c}})}return urlParams}progress.data.ServicesManager.addCatalog=function(services,session){var name,value;if(!services){throw new Error("Cannot find 'services' property in catalog file.")}if(services instanceof Array){services.forEach(function(service){if(progress.data.ServicesManager.getService(service.name)!==undefined){throw new Error("A service named '"+service.name+"' was already loaded.")}if(service.resources instanceof Array){service.resources.forEach(function(resource){if(progress.data.ServicesManager.getResource(resource.name)!==undefined){throw new Error("A resource named '"+resource.name+"' was already loaded.")}})}else{throw new Error("Missing 'resources' array in catalog.")}});for(var j=0;j1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","setContext",1))}if(typeof context==="object"){contextObject={};for(prop in context){if(context.hasOwnProperty(prop)){if(typeof context[prop]!=="function"){contextObject[prop]=context[prop]}}}}else if(context===undefined||context===null){contextObject={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","Session",1,"Object","setContextProperty"))}contextString=null};this.getContext=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContext",0))}return contextObject};this.getContextProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}return contextObject[propertyName]}};progress.data.Session=function Session(options){var defPropSupported=false;if(typeof Object.defineProperty==="function"){defPropSupported=true}var that=this,jsdosession,isUserAgentiOS=false,isFirefox=false,isEdge=false,isIE=false,canPassCredentialsToOpenWithCORS=false,defaultiOSBasicAuthTimeout=4e3,deviceIsOnline=true,restApplicationIsOnline=false,oepingAvailable=false,defaultPartialPingURI="/rest/_oeping",partialPingURI=defaultPartialPingURI,_storageKey,_authProvider=null,customCredentials=false,storedAuthModel,storedURI,newURI,stateWasReadFromStorage=false;if(!options||options._silent!==true){console.warn("Session: As of JSDO 4.4, the Session object has been deprecated. "+"Please use the JSDOSession object instead.")}if(typeof navigator!=="undefined"){if(typeof navigator.userAgent!=="undefined"){isUserAgentiOS=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i);isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;isEdge=navigator.userAgent.indexOf("Edge/")>-1;isIE=navigator.userAgent.indexOf("Trident/")>-1||navigator.userAgent.indexOf("MSIE 10")>-1}}canPassCredentialsToOpenWithCORS=!(isFirefox||isEdge||isIE);function canPassCredentialsToOpen(){return canPassCredentialsToOpenWithCORS}this._onlineHandler=function(){setDeviceIsOnline(true);that.trigger("online",that,null)};this._offlineHandler=function(){setDeviceIsOnline(false);that.trigger("offline",that,progress.data.Session.DEVICE_OFFLINE,null)};if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("online",this._onlineHandler,false);window.addEventListener("offline",this._offlineHandler,false)}var _catalogURIs=[];var _services=[];var _jsdos=[];this.onOpenRequest=null;var _password=null;if(defPropSupported){var _userName=null;Object.defineProperty(this,"userName",{get:function(){return _userName},enumerable:true});var _loginTarget="/static/home.html";Object.defineProperty(this,"loginTarget",{get:function(){return _loginTarget},enumerable:true});var _serviceURI=null;Object.defineProperty(this,"serviceURI",{get:function(){return _serviceURI},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _catalogURIs},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _services},enumerable:true});var _loginResult=null;Object.defineProperty(this,"loginResult",{get:function(){return _loginResult},enumerable:true});var _loginHttpStatus=null;Object.defineProperty(this,"loginHttpStatus",{get:function(){return _loginHttpStatus},enumerable:true});var _clientContextId=null;Object.defineProperty(this,"clientContextId",{get:function(){return _clientContextId},enumerable:true});var _authenticationModel=progress.data.Session.AUTH_TYPE_ANON;Object.defineProperty(this,"authenticationModel",{get:function(){return _authenticationModel},set:function(newval){if(newval){newval=newval.toLowerCase()}switch(newval){case progress.data.Session.AUTH_TYPE_FORM:case progress.data.Session.AUTH_TYPE_BASIC:case progress.data.Session.AUTH_TYPE_ANON:case progress.data.Session.AUTH_TYPE_SSO:case null:_authenticationModel=newval;storeSessionInfo("authenticationModel",newval);break;default:throw new Error("Error setting Session.authenticationModel. '"+newval+"' is an invalid value.")}},enumerable:true});var _lastSessionXHR=null;Object.defineProperty(this,"lastSessionXHR",{get:function(){return _lastSessionXHR},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return this.loginResult===progress.data.Session.LOGIN_SUCCESS&&restApplicationIsOnline&&deviceIsOnline},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _jsdos},enumerable:true});var _pingInterval=0;var _timeoutID=null;Object.defineProperty(this,"pingInterval",{get:function(){return _pingInterval},set:function(newval){if(typeof newval==="number"&&newval>=0){_pingInterval=newval;storeSessionInfo("pingInterval",newval);if(newval>0){if(this.loginResult===progress.data.Session.LOGIN_SUCCESS){_timeoutID=setTimeout(this._autoping,newval)}}else if(newval===0){clearTimeout(_timeoutID);_pingInterval=0}}else{throw new Error("Error setting Session.pingInterval. '"+newval+"' is an invalid value.")}},enumerable:true});var _contextProperties=new progress.data.ContextProperties;Object.defineProperty(this,"_contextProperties",{get:function(){return _contextProperties},enumerable:false});var isInvalidated=false;Object.defineProperty(this,"_isInvalidated",{get:function(){return isInvalidated},enumerable:false});Object.defineProperty(this,"_authProvider",{get:function(){return _authProvider},set:function(newval){if(_authProvider){throw new Error("Internal Error setting Session._authProvider. '"+"The property has already been set.")}setAuthProvider(newval)},enumerable:false})}else{this.userName=null;this.loginTarget="/static/home.html";this.serviceURI=null;this.catalogURIs=[];this.services=[];this.loginResult=null;this.loginHttpStatus=null;this.clientContextId=null;this.authenticationModel=progress.data.Session.AUTH_TYPE_ANON;this.lastSessionXHR=null}function storeSessionInfo(infoName,value){var key;if(that.loginResult===progress.data.Session.LOGIN_SUCCESS&&typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}if(typeof value!=="undefined"){sessionStorage.setItem(key,JSON.stringify(value))}}}function retrieveSessionInfo(infoName){var key,jsonStr,value=null;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}jsonStr=sessionStorage.getItem(key);if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}}function clearSessionInfo(infoName){var key;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName;sessionStorage.removeItem(key)}}}function storeAllSessionInfo(){if(_storageKey){storeSessionInfo("loginResult",that.loginResult);storeSessionInfo("userName",that.userName);storeSessionInfo("serviceURI",that.serviceURI);storeSessionInfo("loginHttpStatus",that.loginHttpStatus);storeSessionInfo("authenticationModel",that.authenticationModel);storeSessionInfo("pingInterval",that.pingInterval);storeSessionInfo("oepingAvailable",oepingAvailable);storeSessionInfo("partialPingURI",partialPingURI);storeSessionInfo("clientContextId",that.clientContextId);storeSessionInfo("deviceIsOnline",deviceIsOnline);storeSessionInfo("restApplicationIsOnline",restApplicationIsOnline);if(that._authProvider){storeSessionInfo("_authProvider.init",{uri:that._authProvider.uri,authenticationModel:that._authProvider.authenticationModel})}storeSessionInfo(_storageKey,true)}}function clearAllSessionInfo(){if(_storageKey){if(retrieveSessionInfo(_storageKey)){clearSessionInfo("loginResult");clearSessionInfo("userName");clearSessionInfo("serviceURI");clearSessionInfo("loginHttpStatus");clearSessionInfo("clientContextId");clearSessionInfo("deviceIsOnline");clearSessionInfo("restApplicationIsOnline");clearSessionInfo("authenticationModel");clearSessionInfo("pingInterval");clearSessionInfo("oepingAvailable");clearSessionInfo("partialPingURI");clearSessionInfo("_authProvider.init");clearSessionInfo(_storageKey)}}}function setSessionInfoFromStorage(key){var authproviderInitObject;if(retrieveSessionInfo(key)){setLoginResult(retrieveSessionInfo("loginResult"),this);setUserName(retrieveSessionInfo("userName"),this);setServiceURI(retrieveSessionInfo("serviceURI"),this);setLoginHttpStatus(retrieveSessionInfo("loginHttpStatus"),this);setClientContextID(retrieveSessionInfo("clientContextId"),this);setDeviceIsOnline(retrieveSessionInfo("deviceIsOnline"));setRestApplicationIsOnline(retrieveSessionInfo("restApplicationIsOnline"));that.authenticationModel=retrieveSessionInfo("authenticationModel");that.pingInterval=retrieveSessionInfo("pingInterval");setOepingAvailable(retrieveSessionInfo("oepingAvailable"));setPartialPingURI(retrieveSessionInfo("partialPingURI"));if(!that._authProvider){authproviderInitObject=retrieveSessionInfo("_authProvider.init");if(authproviderInitObject){setAuthProvider(new progress.data.AuthenticationProvider(authproviderInitObject))}}}}function setUserName(newname,sessionObject){if(defPropSupported){_userName=newname}else{sessionObject.userName=newname}storeSessionInfo("userName",newname)}function setLoginTarget(target,sessionObject){if(defPropSupported){_loginTarget=target}else{sessionObject.loginTarget=target}}function setServiceURI(url,sessionObject){if(defPropSupported){_serviceURI=url}else{sessionObject.serviceURI=url}storeSessionInfo("serviceURI",url)}function pushCatalogURIs(url,sessionObject){if(defPropSupported){_catalogURIs.push(url)}else{sessionObject.catalogURIs.push(url)}}function pushService(serviceObject,sessionObject){if(defPropSupported){_services.push(serviceObject)}else{sessionObject.services.push(serviceObject)}}function findService(serviceName){_services.forEach(function(service){if(service.name===serviceName){return service}});return null}function setLoginResult(result,sessionObject){if(defPropSupported){_loginResult=result}else{sessionObject.loginResult=result}if(result===progress.data.Session.LOGIN_SUCCESS){storeSessionInfo("loginResult",result)}else{clearAllSessionInfo()}}function setLoginHttpStatus(status,sessionObject){if(defPropSupported){_loginHttpStatus=status}else{sessionObject.loginHttpStatus=status}storeSessionInfo("loginHttpStatus",status)}function setClientContextIDfromXHR(xhr,sessionObject){if(xhr){setClientContextID(getResponseHeaderNoError(xhr,"X-CLIENT-CONTEXT-ID"),sessionObject)}}function setClientContextID(ccid,sessionObject){if(defPropSupported){_clientContextId=ccid}else{sessionObject.clientContextId=ccid}storeSessionInfo("clientContextId",ccid)}function setLastSessionXHR(xhr,sessionObject){if(defPropSupported){_lastSessionXHR=xhr}else{sessionObject.lastSessionXHR=xhr}}function setDeviceIsOnline(value){deviceIsOnline=value;storeSessionInfo("deviceIsOnline",value)}function setAuthProvider(value){_authProvider=value?value:null}function setRestApplicationIsOnline(value){restApplicationIsOnline=value;storeSessionInfo("restApplicationIsOnline",value)}function setOepingAvailable(value){oepingAvailable=value;storeSessionInfo("oepingAvailable",value)}function setPartialPingURI(value){partialPingURI=value;storeSessionInfo("partialPingURI",value)}function getResponseHeaderNoError(xhr,headerName){var allHeaders=xhr._pdsResponseHeaders,regExp;if(allHeaders===undefined){allHeaders=xhr.getAllResponseHeaders();if(allHeaders){xhr._pdsResponseHeaders=allHeaders}else{xhr._pdsResponseHeaders=null}}if(allHeaders){regExp=new RegExp("^"+headerName+":","mi");if(allHeaders.match(regExp)){return xhr.getResponseHeader(headerName)}}return null}this._pushJSDOs=function(jsdo){_jsdos.push(jsdo)};this._openRequest=function(xhr,verb,url,async,callback){var urlPlusCCID,that=this;function afterOpenAndAuthorize(arg){if(arg instanceof Error){throw arg}else{if(that.clientContextId&&that.clientContextId!=="0"){xhr.setRequestHeader("X-CLIENT-CONTEXT-ID",that.clientContextId)}setRequestHeaderFromContextProps(that,xhr);if(typeof that.onOpenRequest==="function"){var params={xhr:xhr,verb:verb,uri:urlPlusCCID,async:async,formPreTest:false,session:that};that.onOpenRequest(params)}if(callback){callback()}}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to make server request when there is no active session.")}urlPlusCCID=this._prependAppURL(url);urlPlusCCID=this._addCCIDtoURL(urlPlusCCID);if(progress.data.Session._useTimeStamp){urlPlusCCID=progress.data.Session._addTimeStampToURL(urlPlusCCID)}if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,verb,urlPlusCCID,async,afterOpenAndAuthorize)}else{this._setXHRCredentials(xhr,verb,urlPlusCCID,this.userName,_password,async);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json")}afterOpenAndAuthorize(xhr)}};this.pingTestCallback=function(cbArgs){var foundOeping=cbArgs.pingResult?true:false;setOepingAvailable(foundOeping)};this._onReadyStateChangeGeneric=function(){var xhr=this;var result;var errorObject;clearTimeout(xhr._requestTimeout);if(xhr.readyState===4){result=null;errorObject=null;if(typeof xhr.onResponseFn==="function"){try{result=xhr.onResponseFn(xhr)}catch(e){errorObject=e}}if(typeof xhr.onResponseProcessedFn==="function"){if(!result){result=progress.data.Session.GENERAL_FAILURE}xhr.onResponseProcessedFn(xhr.pdsession,result,errorObject,xhr)}}};this._disconnect=function(deferred){this._processDisconnectResult(null,deferred)};this._processDisconnectResult=function(xhr,deferred){this._reinitializeAfterLogout(this,progress.data.Session.SUCCESS);this._disconnectComplete(this,progress.data.Session.SUCCESS,null,null,deferred)};this._disconnectComplete=function(pdsession,result,errObj,xhr,deferred){pdsession.trigger("afterDisconnect",pdsession,result,errObj,xhr,deferred)};var pwSave=null;var unameSave=null;this.login=function(serviceURI,loginUserName,loginPassword,loginTarget){var uname,pw,isAsync=false,args=[],deferred,iOSBasicAuthTimeout,uriForRequest;pwSave=null;unameSave=null;if(!defPropSupported){this.authenticationModel=this.authenticationModel.toLowerCase()}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","login()"))}if(this.loginResult===progress.data.Session.LOGIN_SUCCESS||this._authProvider){throw new Error("Attempted to call login() on a Session object that is already logged in.")}if(arguments.length>0){if(arguments[0]&&typeof arguments[0]==="object"){args[0]=arguments[0].serviceURI;args[1]=arguments[0].userName;args[2]=arguments[0].password;args[3]=arguments[0].loginTarget;args[4]=arguments[0].async;deferred=arguments[0].deferred;iOSBasicAuthTimeout=arguments[0].iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","login","The iOSBasicAuthTimeout argument was invalid."))}}else{args=arguments}}if(args.length>0){if(args[0]){var restURLtemp=args[0];if(restURLtemp[restURLtemp.length-1]==="/"){restURLtemp=restURLtemp.substring(0,restURLtemp.length-1)}setServiceURI(restURLtemp,this)}else if(!this.serviceURI){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}if(args[1]){uname=args[1]}if(args[2]){pw=args[2]}if(args[3]){setLoginTarget(args[3],this)}if(args[4]){if(typeof args[4]==="boolean"){isAsync=args[4]}else{throw new Error("Session.login() was passed an async setting that is not a boolean.")}}}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}unameSave=uname;pwSave=pw;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON||this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){uname=null;pw=null}var xhr=new XMLHttpRequest;xhr.pdsession=this;try{uriForRequest=this.serviceURI+this.loginTarget;if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(uriForRequest)}this._setXHRCredentials(xhr,"GET",uriForRequest,uname,pw,isAsync);progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(this,xhr);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr._isAsync=isAsync;if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){xhr.onResponseFn=this._afterFormPretestLogin}else{xhr.onResponseFn=this._processLoginResult;xhr.onResponseProcessedFn=this._loginComplete}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout>0){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred}if(typeof this.onOpenRequest==="function"){var isFormPreTest=false;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){isFormPreTest=true}setLastSessionXHR(xhr,this);var params={xhr:xhr,verb:"GET",uri:this.serviceURI+this.loginTarget,async:false,formPreTest:isFormPreTest,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send(null)}catch(e){clearTimeout(xhr._requestTimeout);setLoginHttpStatus(xhr.status,this);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);unameSave=null;pwSave=null;throw e}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{setLoginHttpStatus(xhr.status,this);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){return this._afterFormPretestLogin(xhr)}else{return this._processLoginResult(xhr)}}};this._afterFormPretestLogin=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);var formLoginParams={xhr:xhr,pw:pwSave,uname:unameSave,theSession:pdsession};try{return doFormLogin(formLoginParams)}catch(e){pwSave=null;unameSave=null;throw e}};function doFormLogin(args){var xhr=args.xhr;var theSession=args.theSession;var oldXHR;var contentType=null;var needAuth=false;var params={session:theSession,xhr:xhr,statusFromjson:null};contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson||params.statusFromjson>=400&¶ms.statusFromjson<500){needAuth=true}else{setLoginHttpStatus(params.statusFromjson,theSession)}}else{if(theSession.loginHttpStatus===200){if(_gotLoginForm(xhr)){needAuth=true}}}if(needAuth){oldXHR=xhr;xhr=new XMLHttpRequest;args.xhr=xhr;params.xhr=xhr;xhr.pdsession=oldXHR.pdsession;xhr._isAsync=oldXHR._isAsync;xhr._deferred=oldXHR._deferred;xhr._jsdosession=oldXHR._jsdosession;xhr.open("POST",theSession.serviceURI+"/static/auth/j_spring_security_check",xhr._isAsync);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.setRequestHeader("Cache-Control","max-age=0");setRequestHeaderFromContextProps(theSession,xhr);_addWithCredentialsAndAccept(xhr,"application/json");try{if(typeof theSession.onOpenRequest==="function"){var cbparams={xhr:xhr,verb:"POST",uri:theSession.serviceURI+"/static/auth/j_spring_security_check",async:xhr._isAsync,formPreTest:false,session:theSession};theSession.onOpenRequest(cbparams);xhr=cbparams.xhr}if(xhr._isAsync){xhr.onreadystatechange=theSession._onReadyStateChangeGeneric;xhr.onResponseFn=theSession._afterFormLogin;xhr.onResponseProcessedFn=theSession._loginComplete}xhr.send("j_username="+encodeURIComponent(args.uname)+"&j_password="+encodeURIComponent(args.pw)+"&submit=Submit")}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,theSession);setLoginHttpStatus(xhr.status,theSession);unameSave=null;pwSave=null;throw e}}if(xhr._isAsync&&!needAuth){xhr.onResponseProcessedFn=theSession._loginComplete;return theSession._afterFormLogin(xhr)}if(!xhr._isAsync){return theSession._afterFormLogin(xhr)}}this._afterFormLogin=function(xhr){var theSession=xhr.pdsession;var params={session:theSession,xhr:xhr,statusFromjson:null};var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson){throw new Error("Internal OpenEdge Mobile client error handling login response. HTTP status: "+xhr.status+".")}setLoginHttpStatus(params.statusFromjson,theSession)}else{if(xhr.status===200){if(_gotLoginFailure(xhr)||_gotLoginForm(xhr)){setLoginHttpStatus(401,theSession)}else{setLoginHttpStatus(xhr.status,theSession)}}}return theSession._processLoginResult(xhr)};this._processLoginResult=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);if(pdsession.loginHttpStatus===200){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);setUserName(unameSave,pdsession);_password=pwSave;pdsession._saveClientContextId(xhr);storeAllSessionInfo();var pingTestArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:pdsession._pingtestOnReadyStateChange};pingTestArgs.pingURI=pdsession._makePingURI();pdsession._sendPing(pingTestArgs)}else{if(pdsession.loginHttpStatus===401){setLoginResult(progress.data.Session.LOGIN_AUTHENTICATION_FAILURE,pdsession)}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);unameSave=null;pwSave=null;if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","login"))}return pdsession.loginResult};this._loginComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterLogin",pdsession,result,errObj,xhr)};this.logout=function(args){var isAsync=false,errorObject=null,xhr,deferred,params;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","logout()"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&this.authenticationModel){throw new Error("Attempted to call logout when there is no active session.")}if(typeof args==="object"){isAsync=args.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","logout","The async argument was invalid."))}deferred=args.deferred}xhr=new XMLHttpRequest;xhr.pdsession=this;try{xhr._jsdosession=jsdosession;xhr._deferred=deferred;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM||this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;xhr.onResponseFn=this._processLogoutResult;xhr.onResponseProcessedFn=this._logoutComplete}xhr.open("GET",this.serviceURI+"/static/auth/j_spring_security_logout",isAsync);try{xhr.withCredentials=true}catch(e){}xhr.setRequestHeader("Accept","application/json");setRequestHeaderFromContextProps(this,xhr);if(typeof this.onOpenRequest==="function"){setLastSessionXHR(xhr,this);params={xhr:xhr,verb:"GET",uri:this.serviceURI+"/static/auth/j_spring_security_logout",async:false,formPreTest:false,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send()}else{xhr._anonymousLogoutOK=true}}catch(e){this._reinitializeAfterLogout(this,false);throw e}if(!isAsync){try{this._processLogoutResult(xhr)}catch(e){throw e}}if(isAsync&&this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){try{this._processLogoutResult(xhr)}catch(e){errorObject=e}this._logoutComplete(this,null,errorObject,xhr)}};this.invalidate=function(){isInvalidated=true;cleanServicesManager()};this._logoutComplete=function(pdsession,result,errorObject,xhr){pdsession.trigger("afterLogout",pdsession,errorObject,xhr)};this._processLogoutResult=function(xhr){var logoutSucceeded;var pdsession=xhr.pdsession;var basicStatusOK=false;if(xhr._anonymousLogoutOK){logoutSucceeded=true}else if(xhr.status!==200){if(pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(xhr.status===404){logoutSucceeded=true}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=true}updateContextPropsFromResponse(pdsession,xhr);pdsession._reinitializeAfterLogout(pdsession,logoutSucceeded)};this._reinitializeAfterLogout=function(pdsession,success){setLoginResult(null,pdsession);setLoginHttpStatus(null,pdsession);setClientContextID(null,pdsession);setUserName(null,pdsession);setAuthProvider(null);_password=null;if(success){setRestApplicationIsOnline(false);setOepingAvailable(false);setPartialPingURI(defaultPartialPingURI);setLastSessionXHR(null,pdsession);clearTimeout(_timeoutID)}};this.addCatalog=function(arg1,arg2,arg3,arg4){var catalogURI,catalogUserName,catalogPassword,isAsync=false,xhr,deferred,iOSBasicAuthTimeout,catalogIndex,authProvider,that=this;function addCatalogAfterOpen(){progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(isAsync){xhr.onreadystatechange=that._onReadyStateChangeGeneric;xhr.onResponseFn=that._processAddCatalogResult;xhr.onResponseProcessedFn=that._addCatalogComplete;if(that.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex}try{if(typeof that.onOpenRequest==="function"){setLastSessionXHR(xhr,that);var params={xhr:xhr,verb:"GET",uri:catalogURI,async:false,formPreTest:false,session:that};that.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,that);xhr.send(null)}catch(e){throw new Error("Error retrieving catalog '"+catalogURI+"'.\n"+e.message)}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{return that._processAddCatalogResult(xhr)}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}customCredentials=true;if(arguments.length>0){if(typeof arg1==="object"){if(!arguments[0].offlineAddCatalog){if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to call addCatalog when there is no active session.")}}catalogURI=arg1.catalogURI;if(!catalogURI||typeof catalogURI!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogURI argument was missing or invalid."))}catalogUserName=arg1.userName;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogUserName argument was invalid."))}catalogPassword=arg1.password;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogPassword argument was invalid."))}isAsync=arg1.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The async argument was invalid."))}iOSBasicAuthTimeout=arg1.iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The iOSBasicAuthTimeout argument was invalid."))}authProvider=arg1.authProvider;deferred=arg1.deferred;catalogIndex=arg1.catalogIndex}else{catalogURI=arg1;if(typeof catalogURI!=="string"){throw new Error("First argument to Session.addCatalog must be the URL of the catalog.")}catalogUserName=arg2;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error("Second argument to Session.addCatalog must be a user name string.")}catalogPassword=arg3;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error("Third argument to Session.addCatalog must be a password string.")}}}else{throw new Error("Session.addCatalog is missing its first argument, the URL of the catalog.")}if(!authProvider){authProvider=this._authProvider;customCredentials=false}if(!catalogUserName){catalogUserName=this.userName}if(!catalogPassword){catalogPassword=_password}xhr=new XMLHttpRequest;xhr.pdsession=this;xhr._catalogURI=catalogURI;if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){if(isAsync){xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex;setTimeout(this._addCatalogComplete,10,this,progress.data.Session.CATALOG_ALREADY_LOADED,null,xhr);return progress.data.Session.ASYNC_PENDING}return progress.data.Session.CATALOG_ALREADY_LOADED}if(authProvider){authProvider._openRequestAndAuthorize(xhr,"GET",catalogURI,isAsync,addCatalogAfterOpen);return progress.data.Session.ASYNC_PENDING}else{this._setXHRCredentials(xhr,"GET",catalogURI,catalogUserName,catalogPassword,isAsync);return addCatalogAfterOpen()}};this._processAddCatalogResult=function(xhr){var _catalogHttpStatus=xhr.status;var theSession=xhr.pdsession;var servicedata;var catalogURI=xhr._catalogURI,serviceURL,theJSDOSession=jsdosession;if(!customCredentials){toggleOnlineState(xhr)}if((_catalogHttpStatus===200||_catalogHttpStatus===0)&&xhr.responseText){servicedata=theSession._parseCatalog(xhr);try{progress.data.ServicesManager.addCatalog(servicedata,theSession)}catch(e){if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){return progress.data.Session.CATALOG_ALREADY_LOADED}throw new Error("Error processing catalog '"+catalogURI+"'. \n"+e.message)}servicedata.forEach(function(service){serviceURL=theSession._prependAppURL(service.address);pushService(new progress.data.MobileServiceObject({name:service.name,uri:serviceURL}),theSession);if(service.settings&&service.settings.useXClientProps&&!theSession.xClientProps){console.warn("Catalog warning: Service settings property 'useXClientProps' "+"is true but 'xClientProps' property has not been set.")}});pushCatalogURIs(catalogURI,theSession);progress.data.ServicesManager.addSession(catalogURI,theSession);if(theJSDOSession){progress.data.ServicesManager.addJSDOSession(catalogURI,theJSDOSession)}}else if(_catalogHttpStatus===401){return progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","addCatalog"))}else{throw new Error("Error retrieving catalog '"+catalogURI+"'. Http status: "+_catalogHttpStatus+".")}return progress.data.Session.SUCCESS};this._addCatalogComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterAddCatalog",pdsession,result,errObj,xhr)};this.ping=function(args){var pingResult=false,pingArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:this._onReadyStateChangePing,offlineReason:null};if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(!this._authProvider&&this.loginResult!==progress.data.Session.LOGIN_SUCCESS){throw new Error("Attempted to call ping when not logged in.")}if(args){if(args.async!==undefined){pingArgs.async=args.async}if(args.doNotFireEvent!==undefined){pingArgs.fireEventIfOfflineChange=!args.doNotFireEvent}if(args.onCompleteFn&&typeof args.onCompleteFn==="function"){pingArgs.onCompleteFn=args.onCompleteFn}pingArgs.deferred=args.deferred;pingArgs.jsdosession=args.jsdosession}pingArgs.pingURI=that._makePingURI();that._sendPing(pingArgs);if(!pingArgs.async){if(pingArgs.xhr){pingResult=that._processPingResult(pingArgs);if(args.offlineReason!==undefined){args.offlineReason=pingArgs.offlineReason}}else{pingResult=false}if(args.xhr!==undefined){args.xhr=pingArgs.xhr}}return pingResult};this._isOnlineStateChange=function(isOnline){var stateChanged=false;if(isOnline&&!this.connected){stateChanged=true}else if(!isOnline&&this.connected){stateChanged=true}return stateChanged};this._checkServiceResponse=function(xhr,success,request){var offlineReason=null,wasOnline=this.connected;updateContextPropsFromResponse(this,xhr);if(!this._events){return}var offlineObservers=this._events.offline||[];var onlineObservers=this._events.online||[];if(offlineObservers.length===0&&onlineObservers.length===0){return}if(success){setRestApplicationIsOnline(true);setDeviceIsOnline(true)}else{if(deviceIsOnline){var localPingArgs={doNotFireEvent:true,offlineReason:null,async:false};if(!that.ping(localPingArgs)){offlineReason=localPingArgs.offlineReason;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}}if(wasOnline&&!this.connected){this.trigger("offline",this,offlineReason,request)}else if(!wasOnline&&this.connected){this.trigger("online",this,request)}};this._processPingResult=function(args){var xhr=args.xhr,pingResponseJSON,appServerStatus=null,wasOnline=this.connected,connectedBeforeCallback,assumeOepingFormat;if(args.hasOwnProperty("usingOepingFormat")){assumeOepingFormat=args.usingOepingFormat}else{assumeOepingFormat=oepingAvailable}if(xhr.status>=200&&xhr.status<300){updateContextPropsFromResponse(this,xhr);if(assumeOepingFormat){try{pingResponseJSON=JSON.parse(xhr.responseText);appServerStatus=pingResponseJSON.AppServerStatus}catch(e){console.error("Unable to parse ping response.")}}toggleOnlineState(xhr)}else{if(deviceIsOnline){if(xhr.status===0){args.offlineReason=progress.data.Session.SERVER_OFFLINE;setRestApplicationIsOnline(false)}else if(xhr.status===404||xhr.status===410){args.offlineReason=progress.data.Session.WEB_APPLICATION_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}else{args.offlineReason=progress.data.Session.DEVICE_OFFLINE}}if(appServerStatus){if(appServerStatus.PingStatus==="false"){args.offlineReason=progress.data.Session.APPSERVER_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}connectedBeforeCallback=this.connected;if(typeof xhr.onCompleteFn==="function"){xhr.onCompleteFn({pingResult:this.connected,xhr:xhr,offlineReason:args.offlineReason})}if(args.fireEventIfOfflineChange){if(wasOnline&&!connectedBeforeCallback){that.trigger("offline",that,args.offlineReason,null)}else if(!wasOnline&&connectedBeforeCallback){that.trigger("online",that,null)}}return this.connected};this._onReadyStateChangePing=function(){var xhr=this;var args;if(xhr.readyState===4){args={xhr:xhr,fireEventIfOfflineChange:true,offlineReason:null};that._processPingResult(args);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._pingtestOnReadyStateChange=function(){var xhr=this;if(xhr.readyState===4){var foundOeping=false;if(xhr.status>=200&&xhr.status<300){foundOeping=true}else{setPartialPingURI(that.loginTarget);console.warn("Default ping target not available, will use loginTarget instead.")}setOepingAvailable(foundOeping);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._sendPing=function(args){var xhr=new XMLHttpRequest,that=this;function sendPingAfterOpen(){if(args.async){xhr.onreadystatechange=args.onReadyStateFn;xhr.onCompleteFn=args.onCompleteFn;xhr._jsdosession=jsdosession;xhr._deferred=args.deferred}progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(that.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr.send(null)}try{if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,"GET",args.pingURI,args.async,sendPingAfterOpen)}else{this._setXHRCredentials(xhr,"GET",args.pingURI,this.userName,_password,args.async);if(xhr.readyState===1){sendPingAfterOpen()}}}catch(e){args.error=e}args.xhr=xhr};this._makePingURI=function(){var pingURI=this.serviceURI+partialPingURI;if(progress.data.Session._useTimeStamp){pingURI=progress.data.Session._addTimeStampToURL(pingURI)}return pingURI};this._autoping=function(){that.ping({async:true})};this._setXHRCredentials=function(xhr,verb,uri,userName,password,async){if(userName&&this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(canPassCredentialsToOpen()){xhr.open(verb,uri,async,userName,password)}else{xhr.open(verb,uri,async)}var auth=_make_basic_auth(userName,password);xhr.setRequestHeader("Authorization",auth)}else{xhr.open(verb,uri,async)}};this._addCCIDtoURL=function(url){var urlPart1,urlPart2,jsessionidStr,index;if(this.clientContextId&&this.clientContextId!=="0"){if(url.substring(0,this.serviceURI.length)===this.serviceURI){jsessionidStr=";"+"JSESSIONID="+this.clientContextId;index=url.indexOf("?");if(index===-1){url+=jsessionidStr}else{urlPart1=url.substring(0,index);urlPart2=url.substring(index);url=urlPart1+jsessionidStr+urlPart2}}}return url};this._saveClientContextId=function(xhr){setClientContextIDfromXHR(xhr,this)};this._parseCatalog=function(xhr){var jsonObject;var catalogdata;try{jsonObject=JSON.parse(xhr.responseText);catalogdata=jsonObject.services}catch(e){console.error("Unable to parse response. Make sure catalog has correct format.");catalogdata=null}return catalogdata};this._prependAppURL=function(oldURL){if(!oldURL){return this.serviceURI}var newURL=oldURL;var pat=/^https?:\/\//i;if(!pat.test(newURL)){if(newURL.indexOf("/")!==0){newURL="/"+newURL}newURL=this.serviceURI+newURL}return newURL};function _addWithCredentialsAndAccept(xhr,acceptString){try{xhr.withCredentials=true;xhr.setRequestHeader("Accept",acceptString)}catch(e){}}function _make_basic_auth(user,pw){var tok=user+":"+pw;var hash=btoa(tok);return"Basic "+hash}var loginFormIDString="j_spring_security_check";function _gotLoginForm(xhr){return _findStringInResponseHTML(xhr,loginFormIDString)}var loginFailureIdentificationString="login failed";function _gotLoginFailure(xhr){return _findStringInResponseHTML(xhr,loginFailureIdentificationString)}function _findStringInResponseHTML(xhr,searchString){if(!xhr.responseText){return false}var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("text/html")>=0&&xhr.responseText.indexOf(searchString)>=0){return true}return false}function handleJSONLoginResponse(params){var jsonObject;params.statusFromjson=null;try{jsonObject=JSON.parse(params.xhr.responseText);if(jsonObject.status_code!==undefined&&jsonObject.status_txt!==undefined){params.statusFromjson=jsonObject.status_code}}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,params.session);setLoginHttpStatus(params.xhr.status,params.session);throw new Error("Unable to parse login response from server.")}}function setRequestHeaderFromContextProps(session,xhr){if(session.xClientProps){xhr.setRequestHeader("X-CLIENT-PROPS",session.xClientProps)}else if(session._contextProperties.contextHeader!==undefined){xhr.setRequestHeader("X-CLIENT-PROPS",session._contextProperties.contextHeader)}}function toggleOnlineState(xhr){var pdsession=that;setLoginHttpStatus(xhr.status,pdsession);if(pdsession.loginHttpStatus>=200&&pdsession.loginHttpStatus<400){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);pdsession._saveClientContextId(xhr);storeAllSessionInfo()}else{if(pdsession.loginHttpStatus===0||pdsession.loginHttpStatus===400||pdsession.loginHttpStatus===410){setRestApplicationIsOnline(false);setLoginResult(progress.data.AuthenticationProvider._getAuthFailureReason(xhr),pdsession)}else{setRestApplicationIsOnline(true);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);return pdsession.loginResult}function updateContextPropsFromResponse(session,xhr){var contextString,context;if(xhr){contextString=getResponseHeaderNoError(xhr,"X-CLIENT-PROPS");if(contextString){try{context=JSON.parse(contextString)}catch(e){}if(typeof context==="object"){session._contextProperties.setContext(context)}else{throw new Error(progress.data._getMsgText("jsdoMSG123","Session","X-CLIENT-PROPS"))}}else if(contextString===""){session._contextProperties.setContext({})}}}function cleanServicesManager(){progress.data.ServicesManager.cleanSession(that)}if(typeof options==="object"){jsdosession=options.jsdosession;newURI=options.serviceURI;setAuthProvider(options.authProvider);if(options.authProvider&&options.authProvider.hasClientCredentials()){_loginResult=progress.data.Session.LOGIN_SUCCESS}if(newURI&&newURI[newURI.length-1]==="/"){newURI=newURI.substring(0,newURI.length-1)}_storageKey=options._storageKey;if(_storageKey){if(retrieveSessionInfo(_storageKey)){storedAuthModel=retrieveSessionInfo("authenticationModel");storedURI=retrieveSessionInfo("serviceURI");if(storedAuthModel!==options.authenticationModel||storedURI!==newURI){clearAllSessionInfo()}else{setSessionInfoFromStorage(_storageKey);stateWasReadFromStorage=true}}if(options.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){_storageKey=undefined}}if(!stateWasReadFromStorage){if(newURI){setServiceURI(newURI,this)}if(options.authenticationModel){this.authenticationModel=options.authenticationModel}}}};progress.data.Session._useTimeStamp=true;var SEQ_MAX_VALUE=999999999999999;var _tsseq=SEQ_MAX_VALUE;var _tsprefix1=0;var _tsprefix2=0;progress.data.Session._getNextTimeStamp=function(){var seq;_tsseq+=1;seq=_tsseq;if(seq>=SEQ_MAX_VALUE){_tsseq=1;seq=1;var t=Math.floor((Date.now?Date.now():(new Date).getTime())/1e4);if(_tsprefix1===t){_tsprefix2+=1;if(_tsprefix2>=SEQ_MAX_VALUE){_tsprefix2=1}}else{_tsprefix1=t;Math.random();_tsprefix2=Math.round(Math.random()*1e10)}}return _tsprefix1+"-"+_tsprefix2+"-"+seq};progress.data.Session._addTimeStampToURL=function(url){var timeStamp="_ts="+progress.data.Session._getNextTimeStamp();url+=(url.indexOf("?")===-1?"?":"&")+timeStamp;return url};progress.data.Session._setNoCacheHeaders=function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache")};if(typeof Object.defineProperty==="function"){Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_REQUIRED",{value:0,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"CATALOG_ALREADY_LOADED",{value:4,enumerable:true});Object.defineProperty(progress.data.Session,"ASYNC_PENDING",{value:5,enumerable:true});Object.defineProperty(progress.data.Session,"EXPIRED_TOKEN",{value:6,enumerable:true});Object.defineProperty(progress.data.Session,"SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_ANON",{value:"anonymous",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BASIC",{value:"basic",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM",{value:"form",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_SSO",{value:"sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM_SSO",{value:"form_sso",enumerable:true});Object.defineProperty(progress.data.Session,"DEVICE_OFFLINE",{value:"Device is offline",enumerable:true});Object.defineProperty(progress.data.Session,"SERVER_OFFLINE",{value:"Cannot contact server",enumerable:true});Object.defineProperty(progress.data.Session,"WEB_APPLICATION_OFFLINE",{value:"Mobile Web Application is not available",enumerable:true});Object.defineProperty(progress.data.Session,"SERVICE_OFFLINE",{value:"REST web Service is not available",enumerable:true});Object.defineProperty(progress.data.Session,"APPSERVER_OFFLINE",{value:"AppServer is not available",enumerable:true})}else{progress.data.Session.LOGIN_SUCCESS=1;progress.data.Session.LOGIN_AUTHENTICATION_FAILURE=2;progress.data.Session.LOGIN_GENERAL_FAILURE=3;progress.data.Session.CATALOG_ALREADY_LOADED=4;progress.data.Session.SUCCESS=1;progress.data.Session.AUTHENTICATION_FAILURE=2;progress.data.Session.GENERAL_FAILURE=3;progress.data.Session.AUTH_TYPE_ANON="anonymous";progress.data.Session.AUTH_TYPE_BASIC="basic";progress.data.Session.AUTH_TYPE_FORM="form";progress.data.Session.AUTH_TYPE_SSO="sso"}progress.data.Session.prototype=new progress.util.Observable;progress.data.Session.prototype.constructor=progress.data.Session;function validateSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}else{listenerData.scope=args[2]}}}progress.data.Session.prototype._eventNames=["offline","online","afterLogin","afterAddCatalog","afterLogout","afterDisconnect"];progress.data.Session.prototype.validateSubscribe=validateSessionSubscribe;progress.data.Session.prototype.toString=function(radix){return"progress.data.Session"};progress.data.JSDOSession=function JSDOSession(options){var _pdsession,_serviceURI,that=this,_name;Object.defineProperty(this,"authenticationModel",{get:function(){return _pdsession?_pdsession.authenticationModel:undefined},enumerable:true});Object.defineProperty(this,"authProvider",{get:function(){return _pdsession?_pdsession._authProvider:null},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _pdsession?_pdsession.catalogURIs:undefined},enumerable:true});Object.defineProperty(this,"clientContextId",{get:function(){return _pdsession?_pdsession.clientContextId:undefined},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return _pdsession?_pdsession.connected:undefined},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _pdsession?_pdsession.JSDOs:undefined},enumerable:true});Object.defineProperty(this,"loginResult",{get:function(){return _pdsession?_pdsession.loginResult:undefined},enumerable:true});Object.defineProperty(this,"loginHttpStatus",{get:function(){return _pdsession?_pdsession.loginHttpStatus:undefined},enumerable:true});Object.defineProperty(this,"onOpenRequest",{get:function(){return _pdsession?_pdsession.onOpenRequest:undefined},set:function(newval){if(_pdsession){_pdsession.onOpenRequest=newval}},enumerable:true});Object.defineProperty(this,"pingInterval",{get:function(){return _pdsession?_pdsession.pingInterval:undefined},set:function(newval){if(_pdsession){_pdsession.pingInterval=newval}},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _pdsession?_pdsession.services:undefined},enumerable:true});Object.defineProperty(this,"serviceURI",{get:function(){if(_pdsession&&_pdsession.serviceURI){return _pdsession.serviceURI}else{return _serviceURI}},enumerable:true});Object.defineProperty(this,"userName",{get:function(){return _pdsession?_pdsession.userName:undefined},enumerable:true});Object.defineProperty(this,"name",{get:function(){return _name},enumerable:true});Object.defineProperty(this,"_isInvalidated",{get:function(){return _pdsession._isInvalidated},enumerable:false});function settlePromise(promise,fulfill,result,info){if(fulfill){promise.resolve(that,result,info)}else{promise.reject(that,result,info)}}function genericSessionEventHandler(pdsession,result,errorObject,xhr,deferred){var myDeferred;if(xhr){myDeferred=xhr._deferred}else{myDeferred=deferred}settlePromise(myDeferred,result===progress.data.Session.SUCCESS?true:false,result,{errorObject:errorObject,xhr:xhr})}function onAfterAddCatalog(pdsession,result,errorObject,xhr){var deferred,fulfill=false,settleResult,info;if(result===progress.data.Session.EXPIRED_TOKEN){settleResult=progress.data.Session.EXPIRED_TOKEN}else if(result===progress.data.Session.LOGIN_AUTHENTICATION_FAILURE){settleResult=progress.data.Session.LOGIN_AUTHENTICATION_FAILURE}else{settleResult=progress.data.Session.GENERAL_FAILURE}if(xhr&&xhr._deferred){deferred=xhr._deferred;if(result!==progress.data.Session.SUCCESS&&result!==progress.data.Session.CATALOG_ALREADY_LOADED){result=result||progress.data.Session.GENERAL_FAILURE;deferred._overallCatalogResult=progress.data.Session.GENERAL_FAILURE}deferred._results[xhr._catalogIndex]={catalogURI:xhr._catalogURI,result:result,errorObject:errorObject,xhr:xhr};deferred._numCatalogsProcessed+=1;if(deferred._numCatalogsProcessed===deferred._numCatalogs){deferred._processedPromise=true;if(!deferred._overallCatalogResult){fulfill=true;settleResult=progress.data.Session.SUCCESS}if(settleResult===progress.data.Session.SUCCESS){if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,details:xhr._deferred._results}}}else{if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,errorObject:new Error(progress.data._getMsgText("jsdoMSG512")),details:xhr._deferred._results}}}settlePromise(xhr._deferred,fulfill,settleResult,info)}}}function onAfterLogout(pdsession,errorObject,xhr){var result=progress.data.Session.GENERAL_FAILURE,fulfill=false;if(xhr&&xhr._deferred){if(!errorObject&&!pdsession.loginResult){result=progress.data.Session.SUCCESS;fulfill=true}settlePromise(xhr._deferred,fulfill,result,{errorObject:errorObject,xhr:xhr})}}function onPingComplete(args){var xhr=args.xhr;if(xhr&&xhr._deferred){settlePromise(xhr._deferred,args.pingResult,args.pingResult,{offlineReason:args.offlineReason,xhr:xhr})}}this.login=function(username,password,options){var deferred=new progress.util.Deferred,iOSBasicAuthTimeout;function callIsAuthorized(){that.isAuthorized().then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(that,object.result,object.info)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","JSDOSession","login()"))}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout}if(!_pdsession._authProvider){_pdsession._authProvider=new progress.data.AuthenticationProvider({uri:this.serviceURI,authenticationModel:this.authenticationModel});_pdsession._authProvider.logout().then(function(){return _pdsession._authProvider.login(username,password)}).then(function(){callIsAuthorized()},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}else{throw new Error(progress.data._getMsgText("jsdoMSG062","JSDOSession","login()"))}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.disconnect=function(){var deferred=new progress.util.Deferred,errorObject;try{_pdsession.subscribe("afterDisconnect",genericSessionEventHandler,this);_pdsession._disconnect(deferred)}catch(e){errorObject=new Error(progress.data._getMsgText("jsdoMSG049","JSDOSession","disconnect",e.message))}if(errorObject){if(progress.util.Deferred.useJQueryPromises){throw errorObject}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:errorObject})}}else{return deferred.promise()}};this.addCatalog=function(catalogURI,unameOrOpts,password,opts){var deferred=new progress.util.Deferred,catalogURIs,numCatalogs,catalogIndex,addResult,errorObject,iOSBasicAuthTimeout,username,options,authProvider;try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(typeof catalogURI==="string"){catalogURIs=[catalogURI]}else if(catalogURI instanceof Array){catalogURIs=catalogURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","addCatalog","The first argument must be a string or an array of strings specifying the URI of the catalog."))}if(unameOrOpts){if(typeof unameOrOpts==="string"){if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG058","Session"))}username=unameOrOpts;if(opts){options=opts;options.authProvider=undefined}}else if(typeof unameOrOpts==="object"){options=unameOrOpts}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDOSession","2","object","addCatalog"))}}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout;if(options.authProvider){authProvider=options.authProvider}else if(this.authProvider){authProvider=this.authProvider}}if(!authProvider&&!this.authProvider&&!username){throw new Error(progress.data._getMsgText("jsdoMSG511"))}_pdsession.subscribe("afterAddCatalog",onAfterAddCatalog,this);numCatalogs=catalogURIs.length;deferred._numCatalogs=numCatalogs;deferred._numCatalogsProcessed=0;deferred._results=[];deferred._results.length=numCatalogs;for(catalogIndex=0;catalogIndex=200&&xhr.status<300){deferred.resolve(that,progress.data.Session.SUCCESS,info)}else{if(xhr.status===401){cbresult=progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else{cbresult=progress.data.Session.GENERAL_FAILURE}deferred.reject(that,cbresult,info)}}};try{xhr.send()}catch(e){throw new Error("JSDOSession: Unable to validate authorization. "+e.message)}})}else{result=progress.data.Session.LOGIN_AUTHENTICATION_REQUIRED;deferred.reject(that,result,{xhr:xhr})}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(that,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.setContext=function(context){_pdsession._contextProperties.setContext(context)};this.setContextProperty=function(propertyName,propertyValue){_pdsession._contextProperties.setContextProperty(propertyName,propertyValue)};this.getContext=function(){return _pdsession._contextProperties.getContext()};this.getContextProperty=function(propertyName){return _pdsession._contextProperties.getContextProperty(propertyName)};this._onlineHandler=function(session,request){that.trigger("online",that,request)};this._offlineHandler=function(session,offlineReason,request){that.trigger("offline",that,offlineReason,request)};if(arguments.length>0&&typeof arguments[0]==="object"){if(options.serviceURI&&typeof options.serviceURI==="string"){_serviceURI=options.serviceURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options parameter must include a 'serviceURI' property that is a string."))}if(options.authenticationModel){if(typeof options.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The authenticationModel property of the options parameter must be a string."))}options.authenticationModel=options.authenticationModel.toLowerCase()}else{options.authenticationModel=progress.data.Session.AUTH_TYPE_ANON}if(options.authProvider){if(typeof options.authProvider!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG502","JSDOSession","options","constructor","authProvider"))}if(options.authProvider.authenticationModel!==progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authProvider.authenticationModel!==options.authenticationModel||options.authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authenticationModel!==progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG059","JSDOSession",options.authProvider.authenticationModel,options.authenticationModel))}if(typeof options.authProvider.hasClientCredentials==="function"){if(!options.authProvider.hasClientCredentials()){throw new Error(progress.data._getMsgText("jsdoMSG125","JSDOSession"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG505","JSDOSession","AuthenticationProvider","hasClientCredentials"))}}else if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG508"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options argument was missing or invalid."))}_name=options.name;_pdsession=new progress.data.Session({_storageKey:_name,_silent:true,authenticationModel:options.authenticationModel,serviceURI:options.serviceURI,jsdosession:this,authProvider:options.authProvider});try{if(options.context){this.setContext(options.context)}_pdsession.subscribe("online",this._onlineHandler,this);_pdsession.subscribe("offline",this._offlineHandler,this)}catch(err){_pdsession=undefined;throw err}};progress.data.JSDOSession.prototype=new progress.util.Observable;progress.data.JSDOSession.prototype.constructor=progress.data.JSDOSession;function validateJSDOSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}listenerData.scope=args[2]}}progress.data.JSDOSession.prototype._eventNames=["offline","online"];progress.data.JSDOSession.prototype.validateSubscribe=validateJSDOSessionSubscribe;progress.data.JSDOSession.prototype.toString=function(radix){return"progress.data.JSDOSession"};progress.data.getSession=function(options){var deferred=new progress.util.Deferred,authProvider,promise,authProviderInitObject={};function sessionRejectHandler(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);if(authProvider&&authProvider.hasClientCredentials()){var callback=function(){deferred.reject(object.result,object.info)};authProvider.logout().then(callback,callback)}else{deferred.reject(object.result,object.info)}}function callbackRejectHandler(reason){deferred.reject(progress.data.Session.GENERAL_FAILURE,{reason:reason})}function loginHandler(object){var jsdosession;try{jsdosession=new progress.data.JSDOSession(options);try{jsdosession.isAuthorized().then(function(){return jsdosession.addCatalog(options.catalogURI)},sessionRejectHandler).then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(object.jsdosession,progress.data.Session.SUCCESS)},sessionRejectHandler)}catch(e){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}catch(ex){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:ex})}}function callLogin(provider){var errorObject;if(typeof options.loginCallback!=="undefined"){options.loginCallback().then(function(result){try{provider.login(result.username,result.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}},callbackRejectHandler)}else if(options.username&&options.password){try{provider.login(options.username,options.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG052","getSession()"));sessionRejectHandler(provider,progress.data.Session.AUTHENTICATION_FAILURE,{errorObject:errorObject})}}if(typeof options!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options","object"))}if(typeof options.loginCallback!=="undefined"&&typeof options.loginCallback!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options.loginCallback","function"))}try{if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){if(!options.authenticationURI||!options.authProviderAuthenticationModel){throw new Error(progress.data._getMsgText("jsdoMSG509"))}}if(options.authenticationURI){authProviderInitObject.uri=options.authenticationURI;authProviderInitObject.authenticationModel=options.authProviderAuthenticationModel;if(typeof authProviderInitObject.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG502","progress.data.getSession","object","getSession","authProviderAuthenticationModel"))}}else{authProviderInitObject.uri=options.serviceURI;authProviderInitObject.authenticationModel=options.authenticationModel}authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;if(authProvider.hasClientCredentials()){loginHandler(authProvider)}else{if(authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){authProvider.login().then(loginHandler,sessionRejectHandler)}else{callLogin(authProvider)}}}catch(error){sessionRejectHandler(null,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}return deferred.promise()};progress.data.invalidateAllSessions=function(){var jsdosession,key,deferred=new progress.util.Deferred,jsdosessions=progress.data.ServicesManager._jsdosessions,invalidatePromises=[];try{for(key in jsdosessions){if(jsdosessions.hasOwnProperty(key)){jsdosession=jsdosessions[key];invalidatePromises.push(jsdosession.invalidate())}}progress.util.Deferred.when(invalidatePromises).then(function(){deferred.resolve(progress.data.Session.SUCCESS)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(progress.data.Session.GENERAL_FAILURE,info)})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()}})();if(typeof exports!=="undefined"){exports.progress=progress}(function(){"use strict";if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data.AuthenticationProvider=function AuthenticationProvider(initObject){var authProv,authModel,uri;if(typeof initObject==="object"){this._checkStringArg("constructor",initObject.authenticationModel,"initObject.authenticationModel","initObject.authenticationModel");this._checkStringArg("constructor",initObject.uri,"init-object.uri","init-object.uri")}else{throw new Error(progress.data._getMsgText("jsdoMSG033","AuthenticationProvider","the constructor","The init-object argument was missing or invalid."))}authModel=initObject.authenticationModel.toLowerCase();switch(authModel){case progress.data.Session.AUTH_TYPE_ANON:this._initialize(initObject.uri,progress.data.Session.AUTH_TYPE_ANON,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});authProv=this;break;case progress.data.Session.AUTH_TYPE_BASIC:authProv=new progress.data.AuthenticationProviderBasic(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM:authProv=new progress.data.AuthenticationProviderForm(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM_SSO:authProv=new progress.data.AuthenticationProviderSSO(initObject.uri);break;default:throw new Error(progress.data._getMsgText("jsdoMSG502","AuthenticationProvider","init-object","constructor","authenticationModel"))}return authProv};progress.data.AuthenticationProvider.prototype._loginProto=function(sendParam){var deferred=new progress.util.Deferred,xhr,uriForRequest,header,that=this;try{if(this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG051","AuthenticationProvider"))}xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLoginResult(xhr,deferred)}};if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(this._loginURI)}else{uriForRequest=this._loginURI}this._openLoginRequest(xhr,uriForRequest);xhr.setRequestHeader("Accept","application/json");xhr.send(sendParam)}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.login=function(){return this._loginProto()};progress.data.AuthenticationProvider.prototype._openLoginRequest=function(xhr,uri){xhr.open("GET",uri,true);progress.data.Session._setNoCacheHeaders(xhr)};progress.data.AuthenticationProvider.prototype._processLoginResult=function(xhr,deferred){var result;if(xhr.status===200){this._loggedIn=true;this._storeInfo();result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};progress.data.AuthenticationProvider.prototype.logout=function(){var deferred=new progress.util.Deferred;try{this._reset();deferred.resolve(this,progress.data.Session.SUCCESS,{})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.hasClientCredentials=function(){return this._loggedIn};progress.data.AuthenticationProvider.prototype.hasRefreshToken=function(){return false};progress.data.AuthenticationProvider.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);xhr.setRequestHeader("Accept","application/json");callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};progress.data.AuthenticationProvider.prototype._initialize=function(uriParam,authModel,targetURIs){var tempURI,target;Object.defineProperty(this,"uri",{get:function(){return this._uri},enumerable:true});Object.defineProperty(this,"authenticationModel",{get:function(){return this._authenticationModel},enumerable:true});if(uriParam[uriParam.length-1]==="/"){tempURI=uriParam.substring(0,uriParam.length-1)}else{tempURI=uriParam}for(target in targetURIs){if(targetURIs.hasOwnProperty(target)){this[target]=tempURI+targetURIs[target]}}this._authenticationModel=authModel;this._uri=uriParam;this._loggedIn=false;this._dataKeys={uri:".uri",loggedIn:".loggedIn"};if(typeof sessionStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","AuthenticationProvider","sessionStorage"))}this._storage=sessionStorage;this._storageKey=this._uri;this._dataKeys.uri=this._storageKey+this._dataKeys.uri;this._dataKeys.loggedIn=this._storageKey+this._dataKeys.loggedIn;if(this._retrieveLoggedIn()){this._loggedIn=true}};progress.data.AuthenticationProvider.prototype._storeInfo=function(){this._storage.setItem(this._dataKeys.uri,JSON.stringify(this._uri));this._storage.setItem(this._dataKeys.loggedIn,JSON.stringify(this._loggedIn))};progress.data.AuthenticationProvider.prototype._retrieveInfoItem=function(propName){var jsonStr=this._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value};progress.data.AuthenticationProvider.prototype._retrieveURI=function(){return this._retrieveInfoItem(this._dataKeys.uri)};progress.data.AuthenticationProvider.prototype._retrieveLoggedIn=function(){return this._retrieveInfoItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._clearInfo=function(info){this._storage.removeItem(this._dataKeys.uri);this._storage.removeItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._reset=function(){this._clearInfo();this._loggedIn=false};progress.data.AuthenticationProvider.prototype._settlePromise=function(deferred,result,info){if(result===progress.data.Session.SUCCESS){deferred.resolve(this,result,info)}else{deferred.reject(this,result,info)}};progress.data.AuthenticationProvider.prototype._checkStringArg=function(fnName,argToCheck,argPosition,argName){if(typeof argToCheck!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","AuthenticationProvider",argPosition,"string",fnName))}else if(argToCheck.length===0){throw new Error(progress.data._getMsgText("jsdoMSG501","AuthenticationProvider",argName,fnName))}};progress.data.AuthenticationProvider._getAuthFailureReason=function(xhr){var contentType,jsonObject,result=progress.data.Session.AUTHENTICATION_FAILURE;if(xhr.status===401){contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>-1&&xhr.responseText){jsonObject=JSON.parse(xhr.responseText);if(jsonObject.error==="sso.token.expired_token"){result=progress.data.Session.EXPIRED_TOKEN}}}else{result=null}return result};Object.defineProperty(progress.data.AuthenticationProvider,"_homeLoginURIBase",{value:"/static/home.html",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLoginURIBase",{value:"/static/auth/j_spring_security_check",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLogoutURIBase",{value:"/static/auth/j_spring_security_logout",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenLoginURIBase",{value:progress.data.AuthenticationProvider._springLoginURIBase+"?OECP=yes",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenRefreshURIBase",{value:"/static/auth/token?op=refresh",enumerable:true})})();(function(){"use strict";progress.data.AuthenticationProviderBasic=function(uri){var defaultiOSBasicAuthTimeout,userName=null,password=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BASIC,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});this._reset();function make_basic_auth_header(user,pw){var tok=user+":"+pw,hash=btoa(tok);return"Basic "+hash}this._reset=function(){userName=null;password=null;progress.data.AuthenticationProviderBasic.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _basic_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBasic.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){userName=null;password=null}};this.login=function(userNameParam,passwordParam){this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");userName=userNameParam;password=passwordParam;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr);callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}}};function BasicProxy(){}BasicProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBasic.prototype=new BasicProxy;progress.data.AuthenticationProviderBasic.prototype.constructor=progress.data.AuthenticationProviderBasic})();(function(){"use strict";var fn;progress.data.AuthenticationProviderForm=function(uri){this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM,{_loginURI:progress.data.AuthenticationProvider._springLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase})};function FormProxy(){}FormProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderForm.prototype=new FormProxy;progress.data.AuthenticationProviderForm.prototype.constructor=progress.data.AuthenticationProviderForm;progress.data.AuthenticationProviderForm.prototype.login=function(userNameParam,passwordParam){var deferred=new progress.util.Deferred,xhr,that=this;this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");return this._loginProto("j_username="+encodeURIComponent(userNameParam)+"&j_password="+encodeURIComponent(passwordParam)+"&submit=Submit")};progress.data.AuthenticationProviderForm.prototype._openLoginRequest=function(xhr,uri){xhr.open("POST",uri,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.setRequestHeader("Pragma","no-cache");xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.withCredentials=true};progress.data.AuthenticationProviderForm.prototype.logout=function(){var deferred=new progress.util.Deferred,xhr,that=this;try{if(!this._loggedIn){deferred.resolve(this,progress.data.Session.SUCCESS,{})}else{xhr=new XMLHttpRequest;this._openLogoutRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLogoutResult(xhr,deferred)}};xhr.send()}this._reset()}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProviderForm.prototype._openLogoutRequest=function(xhr){xhr.open("GET",this._logoutURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Accept","application/json")};progress.data.AuthenticationProviderForm.prototype._processLogoutResult=function(xhr,deferred){var result;if(xhr.status===200){result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};fn=progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize;progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){function afterSuper(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.withCredentials=true;callback(xhr)}}try{progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super.apply(this,[xhr,verb,uri,async,afterSuper])}catch(e){callback(e)}};progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super=fn})();(function(){"use strict";var fn;progress.data.AuthenticationProviderSSO=function(uri){var that=this,_automaticTokenRefresh,temp,ssoTokenInfo=null,tokenDataKeys={token:".access_token",refreshToken:".refresh_token",tokenType:".token_type",expiration:".expires_in",accessTokenExpiration:".accessTokenExpiration"};function storeTokenInfo(info){var date,accessTokenExpiration;if(info.access_token.length){that._storage.setItem(tokenDataKeys.token,JSON.stringify(info.access_token))}if(info.refresh_token.length){that._storage.setItem(tokenDataKeys.refreshToken,JSON.stringify(info.refresh_token));date=new Date;accessTokenExpiration=date.getTime()+info.expires_in*1e3*.75;that._storage.setItem(tokenDataKeys.accessTokenExpiration,JSON.stringify(accessTokenExpiration))}else{that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}that._storage.setItem(tokenDataKeys.tokenType,JSON.stringify(info.token_type));that._storage.setItem(tokenDataKeys.expiration,JSON.stringify(info.expires_in))}function retrieveTokenProperty(propName){var jsonStr=that._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}function retrieveToken(){return retrieveTokenProperty(tokenDataKeys.token)}function retrieveRefreshToken(){return retrieveTokenProperty(tokenDataKeys.refreshToken)}function retrieveAccessTokenExpiration(){return retrieveTokenProperty(tokenDataKeys.accessTokenExpiration)}function retrieveTokenType(){return retrieveTokenProperty(tokenDataKeys.tokenType)}function getToken(){return retrieveToken()}function retrieveExpiration(){return retrieveTokenProperty(tokenDataKeys.expiration)}function clearTokenInfo(info){that._storage.removeItem(tokenDataKeys.token);that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.tokenType);that._storage.removeItem(tokenDataKeys.expiration);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}function openRefreshRequest(xhr){xhr.open("POST",that._refreshURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Accept","application/json")}function processRefreshResult(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",ex.message))}}else if(xhr.status===401){that._reset();result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}that._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})}this._processLoginResult=function(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){this._loggedIn=true;try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",ex.message))}if(result!==progress.data.Session.SUCCESS){var callback=function(params){params=progress.util.Deferred.getParamObject(params);params.provider._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})};this.logout().then(callback,callback);return}}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};this._reset=function(){progress.data.AuthenticationProviderSSO.prototype._reset.apply(this);clearTokenInfo();ssoTokenInfo=null};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var that=this,date,errorObject;function afterRefreshCheck(provider,result,info){if(result===progress.data.Session.AUTHENTICATION_FAILURE){callback(new Error(progress.data._getMsgText("jsdoMSG060")))}else{progress.data.AuthenticationProviderSSO.prototype._openRequestAndAuthorize.apply(that,[xhr,verb,uri,async,function(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.setRequestHeader("Authorization","oecp "+getToken());callback(xhr)}}])}}if(this.hasClientCredentials()){date=new Date;if(this.automaticTokenRefresh&&this.hasRefreshToken()&&date.getTime()>retrieveAccessTokenExpiration()){try{var callback=function(params,result,info){params=progress.util.Deferred.getParamObject(params,result,info);afterRefreshCheck(params.provider,params.result,params.info)};this.refresh().then(callback,callback)}catch(e){callback(e)}}else{afterRefreshCheck(this,progress.data.Session.SUCCESS,null)}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};this.hasClientCredentials=function(){return retrieveToken()===null?false:true};this.refresh=function(){var deferred=new progress.util.Deferred,xhr;try{if(!this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG053","AuthenticationProvider","refresh"))}if(!this.hasRefreshToken()){throw new Error(progress.data._getMsgText("jsdoMSG054","AuthenticationProvider"))}xhr=new XMLHttpRequest;openRefreshRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){processRefreshResult(xhr,deferred)}};xhr.send('{"token_type":"'+retrieveTokenType()+'","refresh_token":"'+retrieveRefreshToken()+'"}')}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.hasRefreshToken=function(){return retrieveRefreshToken()===null?false:true};this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM_SSO,{_loginURI:progress.data.AuthenticationProvider._springFormTokenLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase,_refreshURI:progress.data.AuthenticationProvider._springFormTokenRefreshURIBase});_automaticTokenRefresh=true;Object.defineProperty(this,"automaticTokenRefresh",{get:function(){return _automaticTokenRefresh},set:function(value){if(value===true||value===false){_automaticTokenRefresh=value}else{throw new Error(progress.data._getMsgText("jsdoMSG061","AuthenticationProvider","automaticTokenRefresh"))}},enumerable:true});this._dataKeys.automaticTokenRefresh=this._storageKey+".automaticTokenRefresh";temp=this._retrieveInfoItem(this._dataKeys.automaticTokenRefresh);if(temp===false){_automaticTokenRefresh=false}tokenDataKeys.token=this._storageKey+tokenDataKeys.token;tokenDataKeys.refreshToken=this._storageKey+tokenDataKeys.refreshToken;tokenDataKeys.tokenType=this._storageKey+tokenDataKeys.tokenType;tokenDataKeys.expiration=this._storageKey+tokenDataKeys.expiration;tokenDataKeys.accessTokenExpiration=this._storageKey+tokenDataKeys.accessTokenExpiration;if(retrieveToken()){this._loggedIn=true}};function SSOProxy(){}SSOProxy.prototype=progress.data.AuthenticationProviderForm.prototype;progress.data.AuthenticationProviderSSO.prototype=new SSOProxy;progress.data.AuthenticationProviderSSO.prototype.constructor=progress.data.AuthenticationProviderSSO;fn=progress.data.AuthenticationProviderSSO.prototype._storeInfo;progress.data.AuthenticationProviderSSO.prototype._storeInfo=function(){progress.data.AuthenticationProviderSSO.prototype._storeInfo._super.apply(this);this._storage.setItem(this._dataKeys.automaticTokenRefresh,JSON.stringify(this._automaticTokenRefresh))};progress.data.AuthenticationProviderSSO.prototype._storeInfo._super=fn;fn=progress.data.AuthenticationProviderSSO.prototype._clearInfo;progress.data.AuthenticationProviderSSO.prototype._clearInfo=function(){progress.data.AuthenticationProviderSSO.prototype._clearInfo._super.apply(this);this._storage.removeItem(this._dataKeys.automaticTokenRefresh)};progress.data.AuthenticationProviderSSO.prototype._clearInfo._super=fn})();if(typeof kendo!=="undefined"){(function(){var JSDODataReader,JSDOTransport,JSDOObservable=new kendo.Observable;function initializeJSDO(transport,options){var jsdo,resourceName;if(options.jsdo instanceof progress.data.JSDO){jsdo=options.jsdo}else if(typeof options.jsdo==="string"){resourceName=options.jsdo;jsdo=new progress.data.JSDO({name:resourceName})}else{throw new Error("JSDO: jsdo property must be either a JSDO instance or a string.")}if(transport.tableRef===undefined&&jsdo._defaultTableRef){transport.tableRef=jsdo._defaultTableRef._name}if(transport.tableRef===undefined){throw new Error("JSDO: A tableRef must be specified when using a multi-table DataSet.")}else if(jsdo[transport.tableRef]===undefined){throw new Error("JSDO: tableRef '"+transport.tableRef+"' is not present in JSDO definition.")}return jsdo}JSDODataReader=kendo.data.readers.json.extend({init:function(arg1){var event={},transport;JSDOObservable.trigger("info",event);transport=this.transport=event.sender._events.info.transport;kendo.data.readers.json.fn.init.call(this,arg1);this.model=kendo.data.Model.define({init:function(data){var record;if(!data||jQuery.isEmptyObject(data)){data=transport._getInitialValues()}record=transport._convertDataTypes(data);transport.jsdo._deleteProdsProperties(record,true);kendo.data.Model.fn.init.call(this,record)},id:"_id",fields:transport._getModel()})},total:function(data){return data.total||(data.data?data.data.length:data.length)},data:function(data){return data.data||data}});JSDOTransport=kendo.data.RemoteTransport.extend({init:function(options){var transport=this,fnName;if(options.tableRef!==undefined){transport.tableRef=options.tableRef}transport.jsdo=initializeJSDO(transport,options);transport._initFromServer=false;transport.autoSave=options.autoSave!==undefined?options.autoSave:true;transport.readLocal=options.readLocal!==undefined?options.readLocal:false;transport.countFnName=options.countFnName;transport.useArrays=options.useArrays!==undefined?options.useArrays:false;if(transport.countFnName!==undefined){if(typeof transport.jsdo[transport.countFnName]!=="function"){throw new Error("Invoke operation '"+transport.countFnName+"' for countFnName is not defined.")}}else if(transport.jsdo._resource.generic.count!==undefined){for(fnName in transport.jsdo._resource.fn){if(transport.jsdo._resource.fn.hasOwnProperty(fnName)){if(transport.jsdo._resource.generic.count===transport.jsdo._resource.fn[fnName]["function"]){transport.countFnName=fnName;break}}}}JSDOObservable.one("info",function(e){e.sender._events.info.transport=transport});transport._initConvertTypes();kendo.data.RemoteTransport.fn.init.call(this,options)},_initConvertTypes:function(){var transport=this,i,schema,fieldName,dateFields=[],arrayFields=[],convertDateFields=false;transport._convertTypes=false;schema=transport.jsdo[transport.tableRef].getSchema();for(i=0;i0&&fieldName.charAt(0)!=="_"){if(schema[i].type==="string"&&schema[i].format&&schema[i].format.indexOf("date")!==-1){dateFields.push(fieldName);if(!convertDateFields){convertDateFields=true}}else if(!transport.useArrays&&schema[i].type==="array"){arrayFields.push(fieldName);if(!convertDateFields&&schema[i].ablType&&schema[i].ablType.indexOf("DATE")===0){convertDateFields=true}}}}if(dateFields.length>0||arrayFields.length>0){transport._convertTypes=true;transport._convertFields={};transport._convertFields._arrayFields=[];transport._convertFields._dateFields=[]}if(dateFields.length>0){transport._convertFields._dateFields=dateFields}if(convertDateFields){transport._convertFields._datePattern=new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?$");transport._convertFields._dateTimePattern=new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?"+"T([0-9]{2})?:([0-9]{2})?:([0-9]{2})?.([0-9]{3})?$")}if(arrayFields.length>0){transport._convertFields._arrayFields=arrayFields}},_convertStringToDate:function(data,fieldName,targetFieldName){var transport=this,array,ablType,orig;if(!targetFieldName){targetFieldName=fieldName}array=transport._convertFields._datePattern.exec(data[targetFieldName])||[];if(array.length>0){data[targetFieldName]=new Date(parseInt(array[1],10),parseInt(array[2],10)-1,parseInt(array[3],10))}else{ablType=transport.jsdo[transport.tableRef]._fields[fieldName.toLowerCase()].ablType;if(ablType==="DATETIME"){array=transport._convertFields._dateTimePattern.exec(data[targetFieldName])||[];if(array.length>0){data[targetFieldName]=new Date(parseInt(array[1],10),parseInt(array[2],10)-1,parseInt(array[3],10),parseInt(array[4],10),parseInt(array[5],10),parseInt(array[6],10),parseInt(array[7],10))}}if(typeof data[targetFieldName]==="string"){orig=data[targetFieldName];try{data[targetFieldName]=new Date(data[targetFieldName])}catch(e){data[targetFieldName]=orig;console.log(progress.data._getMsgText("jsdoMSG000","_convertStringToDate() could not convert to date object: "+orig))}}}},_convertDataTypes:function(data){var transport=this,i,k,fieldName,schemaInfo,prefixElement,elementName,copy;delete data["prods:rowState"];if(!transport.useArrays&&transport._convertTypes&&transport._convertFields._arrayFields.length>0){copy={};transport.jsdo._copyRecord(transport.jsdo._buffers[transport.tableRef],data,copy);data=copy}if(!transport._convertTypes){return data}for(k=0;k0&&schema[i].name.charAt(0)!=="_"){type=schema[i].type;if(type==="integer"){type="number"}else if(type==="string"&&schema[i].format&&schema[i].format.indexOf("date")!==-1){type="date"}if(type==="array"){for(j=0;j0&&schema[i].name.charAt(0)!=="_"){defaultValue=transport.jsdo._getDefaultValue(schema[i]);if(schema[i].type==="array"){data[schema[i].name]=[];for(j=0;j0||jsdo[this.tableRef]._data instanceof Array&&jsdo[this.tableRef]._data.length>0}else{this._initFromServer=jsdo[this.tableRef]._data instanceof Array&&jsdo[this.tableRef]._data.length>0}}data.data=[];if(this.readLocal&&this._initFromServer){saveUseRelationships=jsdo.useRelationships;jsdo.useRelationships=false;data=this._getData(options);jsdo.useRelationships=saveUseRelationships;options.success(data);return}if(!this.readLocal){if(options.data){for(property in options.data){if(options.data.hasOwnProperty(property)){if(options.data[property]!==undefined&&optionsMapping[property]){if(filter===undefined){filter={}}filter[optionsMapping[property]]=options.data[property]}}}if(filter){filter.tableRef=this.tableRef}}}callback=function onAfterFillJSDO(object,success,request){var data={},saveUseRelationships,promise,total,exception,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;if(success){saveUseRelationships=jsdo.useRelationships;jsdo.useRelationships=false;if(transport.readLocal){data=transport._getData(options)}else{data.data=jsdo[transport.tableRef].getData();total=jsdo.getProperty("server.count");if(total){data.total=total}}jsdo.useRelationships=saveUseRelationships;transport._initFromServer=true;if(options.data&&options.data.take){if(!transport.readLocal&&transport.countFnName!==undefined&&typeof jsdo[transport.countFnName]==="function"){if(options.data.skip===0&&options.data.take>data.data.length){options.success(data);return}promise=jsdo.invoke(transport.countFnName,{filter:request.objParam.filter});promise.then(function(object,success,request){var exception,total,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;try{if(typeof request.response==="object"&&Object.keys(request.response).length===1){total=request.response[Object.keys(request.response)];if(typeof total!=="number"){total=undefined}}}catch(e){}if(total!==undefined){if(total){data.total=total}options.success(data)}else{exception=new Error("Unexpected response from '"+transport.countFnName+"' operation.");options.error(request.xhr,request.xhr.status,exception)}},function(object,success,request){var exception,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;exception=new Error("Error invoking '"+transport.countFnName+"' operation.");options.error(request.xhr,request.xhr.status,exception)})}else{options.success(data)}}else{options.success(data)}}else{exception=new Error("Error while reading records.");options.error(request.xhr,request.xhr.status,exception)}};jsdo.fill(filter).then(callback,callback)}catch(e){options.error(null,null,e)}},_processChanges:function(options,request){var jsdo=this.jsdo,transport=this,array,i,jsrecord,id,record;if(options.batch){array=[];if(options.data.created instanceof Array){if(jsdo._resource.idProperty){if(request.jsrecords){for(i=0;i=2&&typeof args[0]==="string"&&typeof args[1]==="string"){listenerData.operation=args[1];listenerData.fn=args[2];listenerData.scope=args[3]}else if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="function"){listenerData.operation=undefined;listenerData.scope=args[2];listenerData.fn=args[1]}else{throw new Error}};this.subscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"subscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",progress.data._getMsgText("jsdoMSG039")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",e.message))}observers=this._events[evt]||[];observers=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation);observers.push(listenerData);this._events[evt]=observers;return this};this.unsubscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"unsubscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",progress.data._getMsgText("jsdoMSG037")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",e.message))}observers=this._events[evt]||[];if(observers.length>0){this._events[evt]=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation)}return this};this.trigger=function(evt,operation,args){var observers,op;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"trigger"))}this._events=this._events||{};evt=evt.toLowerCase();observers=this._events[evt]||[];if(observers.length>0){args=Array.prototype.slice.call(arguments);if(arguments.length>=2&&typeof evt==="string"&&typeof operation==="string"){op=operation;args=args.length>2?args.slice(2):[]}else if(arguments.length>=1&&typeof evt==="string"){op=undefined;args=args.length>1?args.slice(1):[]}else{throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"trigger"))}observers.forEach(function(el){if(el.operation===op){el.fn.apply(el.scope,args)}})}return this};this.unsubscribeAll=function(evt,operation){var observers;if(evt){this._events=this._events||{};if(typeof evt==="string"){evt=evt.toLowerCase();observers=this._events[evt]||[];observers.forEach(function(el){if(el.operation){this.unsubscribe(evt,el.operation,el.fn,el.scope)}else{this.unsubscribe(evt,el.fn,el.scope)}},this)}}else{this._events={}}return this}};progress.data.LocalStorage=function LocalStorage(){if(typeof localStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","progress.data.LocalStorage","localStorage"))}this.saveToLocalStorage=function(name,dataObj){localStorage.setItem(name,JSON.stringify(dataObj))};this.readFromLocalStorage=function(name){var jsonStr=localStorage.getItem(name),dataObj=null;if(jsonStr!==null){try{dataObj=JSON.parse(jsonStr)}catch(e){dataObj=null}}return dataObj};this.clearLocalStorage=function(name){localStorage.removeItem(name)}};progress.util._convertToABLWhereString=function(tableRef,filter){var result=[],logic=filter.logic||"and",idx,length,field,fieldInfo,type,format,operator,value,ablType,filters=filter.filters||[filter],whereOperators={eq:"=",neq:"<>",gt:">",gte:">=",lt:"<",lte:"<=",contains:"INDEX",doesnotcontain:"INDEX",endswith:"R-INDEX",startswith:"BEGINS",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};for(idx=0,length=filters.length;idx 0"}else{format="{2} MATCHES '*{1}'"}}else{format="{2} {0} "+format}filter=progress.util._format(format,operator,value,field)}else if(operator&&value===undefined){if(filter.operator==="isempty"||filter.operator==="isnotempty"){ablType=tableRef._getABLType(field);if(ablType!==CHARACTER_ABL_TYPE){throw new Error("Error parsing filter object. The operator "+filter.operator+" requires a CHARACTER field")}if(filter.operator==="isempty"){format="{2} = ''"}else if(filter.operator==="isnotempty"){format="{2} <> ''"}}else{if(filter.operator==="isnull"){format="{2} = ?"}else if(filter.operator==="isnotnull"){format="{2} <> ?"}else{format="{2} {0} ?"}}filter=progress.util._format(format,operator,value,field)}}result.push(filter)}filter=result.join(" "+logic+" ");if(result.length>1){filter="("+filter+")"}return filter};progress.util._convertToSQLQueryString=function(tableRef,filter,addSelect){var result=[],logic=filter.logic||"and",idx,length,field,type,format,operator,value,fieldFormat,filters=filter.filters||[filter],filterStr,usingLike=true,whereOperators={eq:"=",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<=",contains:"LIKE",doesnotcontain:"NOT LIKE",endswith:"LIKE",startswith:"LIKE",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};if(typeof addSelect==="undefined"){addSelect=false}for(idx=0,length=filters.length;idx1){filterStr="("+filterStr+")"}if(addSelect===true){filterStr="SELECT * FROM "+tableRef._name+" WHERE "+filterStr}return filterStr};progress.util._getObjectType=function(value){return Object.prototype.toString.call(value).slice(8,-1)};progress.util._format=function(fmt){var values=arguments,formatRegExp=/\{(\d+)(:[^\}]+)?\}/g;return fmt.replace(formatRegExp,function(match,index,placeholderFormat){var value=values[parseInt(index,10)+1];return progress.util._toString(value,placeholderFormat?placeholderFormat.substring(1):"")})};progress.util._toString=function(value,fmt){var str;if(fmt){if(progress.util._getObjectType(value)==="Date"){return progress.util._formatDate(value,fmt)}}if(typeof value==="number"){str=value.toString()}else{str=value!==undefined?value:""}return str};progress.util._pad=function(number,digits){var zeros=["","0","00","000","0000"],end;number=String(number);digits=digits||2;end=digits-number.length;if(end){return zeros[digits].substring(0,end)+number}return number};progress.util._formatDate=function(date,format){var dateFormatRegExp=/dd|MM|yyyy|hh|mm|fff|FFF|ss|zzz|iso|"[^"]*"|'[^']*'/g;return format.replace(dateFormatRegExp,function(match){var minutes,result,sign;if(match==="dd"){result=progress.util._pad(date.getDate())}else if(match==="MM"){result=progress.util._pad(date.getMonth()+1)}else if(match==="yyyy"){result=progress.util._pad(date.getFullYear(),4)}else if(match==="hh"){result=progress.util._pad(date.getHours())}else if(match==="mm"){result=progress.util._pad(date.getMinutes())}else if(match==="ss"){result=progress.util._pad(date.getSeconds())}else if(match==="fff"){result=progress.util._pad(date.getMilliseconds(),3)}else if(match==="FFF"){result=String(date.getTime())}else if(match==="zzz"){minutes=date.getTimezoneOffset();sign=minutes<0;result=(sign?"+":"-")+minutes}else if(match==="iso"){result=date.toISOString()}return result!==undefined?result:match.slice(1,match.length-1)})};progress.util.jsdoSettingsProcessor=function jsdoSettingsProcessor(jsdoSettings){if(typeof jsdoSettings==="object"){if(jsdoSettings.authenticationModel===undefined||jsdoSettings.authenticationModel===""){jsdoSettings.authenticationModel="ANONYMOUS"}}}})();(function(){var PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS=20,PROGRESS_JSDO_OP_STRING=["none","create","read","update","delete","submit"],PROGRESS_JSDO_ROW_STATE_STRING=["","created","","modified","deleted"];if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data._nextid=0;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime());var UID_MAX_VALUE=999999999999999;progress.data._getNextId=function(){var uid=++progress.data._nextid;if(uid>=UID_MAX_VALUE){progress.data._nextid=uid=1;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime())}return progress.data._uidprefix+"-"+uid};var msg={};msg.msgs={};msg.msgs.jsdoMSG000="JSDO, Internal Error: {1}";msg.msgs.jsdoMSG001="JSDO: JSDO has multiple tables. Please use {1} at the table reference level.";msg.msgs.jsdoMSG002="JSDO: Working record for '{1}' is undefined.";msg.msgs.jsdoMSG003="JSDO: {1} function requires a function as a parameter.";msg.msgs.jsdoMSG004="JSDO: Unable to find resource '{1}' in the catalog.";msg.msgs.jsdoMSG005="JSDO: Data for table '{1}' was not specified in addRecords() call.";msg.msgs.jsdoMSG006="JSDO: Data for JSDO was not specified in addRecords() call.";msg.msgs.jsdoMSG007="JSDO: Test function in {1} must return a boolean.";msg.msgs.jsdoMSG008="JSDO: Invalid keyFields parameter in addRecords() call.";msg.msgs.jsdoMSG009="JSDO: KeyField '{1}' in addRecords() call was not found in the schema.";msg.msgs.jsdoMSG010="JSDO: Field '{1}' in relationship was not found in the schema.";msg.msgs.jsdoMSG011="UIHelper: JSDO has multiple tables. "+"Please use {1} at the table reference level.";msg.msgs.jsdoMSG012="UIHelper: Invalid {2} parameter in {1} call.";msg.msgs.jsdoMSG020="JSDO: tableName parameter must be a string in addRecords() call.";msg.msgs.jsdoMSG021="JSDO: addMode parameter must be specified in addRecords() call.";msg.msgs.jsdoMSG022="JSDO: Invalid addMode specified in addRecords() call.";msg.msgs.jsdoMSG023="JSDO: Duplicate found in addRecords() call using APPEND mode.";msg.msgs.jsdoMSG024="{1}: Unexpected signature in call to {2} function.";msg.msgs.jsdoMSG025="{1}: Invalid parameters in call to {2} function.";msg.msgs.jsdoMSG026="JSDO: saveChanges requires a "+"CREATE, UPDATE, DELETE or SUBMIT operation to be defined.";msg.msgs.jsdoMSG030="JSDO: Invalid {1}, expected {2}.";msg.msgs.jsdoMSG031="JSDO: Specified sort field name '{1}' was not found in the schema.";msg.msgs.jsdoMSG032="JSDO: Before-image data already exists for record in addRecords() call.";msg.msgs.jsdoMSG033="{1}: Invalid signature for {2}. {3}";msg.msgs.jsdoMSG034="JSDO: In '{1}' function, JSON data is missing _id";msg.msgs.jsdoMSG035="JSDO: In '{1}' function, before-image JSON data is missing prods:clientId";msg.msgs.jsdoMSG036="JSDO: '{1}' can only be called for a dataset";msg.msgs.jsdoMSG037="{1}: Event name must be provided for {2}.";msg.msgs.jsdoMSG038="Too few arguments. There must be at least {1}.";msg.msgs.jsdoMSG039="The name of the event is not a string.";msg.msgs.jsdoMSG040="The event listener is not a function.";msg.msgs.jsdoMSG041="The event listener scope is not an object.";msg.msgs.jsdoMSG042="'{1}' is not a defined event for this object.";msg.msgs.jsdoMSG043="{1}: A session object was requested to check the status of a Mobile "+"Service named '{2}', but it has not loaded the definition of that service.";msg.msgs.jsdoMSG044="JSDO: In '{1}' function, {2} is missing {3} property.";msg.msgs.jsdoMSG045="JSDO: {1} function: {2} is missing {3} property.";msg.msgs.jsdoMSG046="JSDO: {1} operation is not defined.";msg.msgs.jsdoMSG047="{1} timeout expired.";msg.msgs.jsdoMSG048="{1}: {2} method has argument '{3}' that is missing property '{4}'.";msg.msgs.jsdoMSG049="{1}: Unexpected error calling {2}: {3}";msg.msgs.jsdoMSG050="No token returned from server";msg.msgs.jsdoMSG051="{1} The login method was not executed because the AuthenticationProvider is already logged in.";msg.msgs.jsdoMSG052="{1}: The login method was not executed because no credentials were supplied.";msg.msgs.jsdoMSG053="{1}: {2} was not executed because the AuthenticationProvider is not logged in.";msg.msgs.jsdoMSG054="{1}: Token refresh was not executed because the AuthenticationProvider does not have a refresh token.";msg.msgs.jsdoMSG055="{1}: Token refresh was not executed because the authentication model is not sso.";msg.msgs.jsdoMSG056="{1}: Already logged in.";msg.msgs.jsdoMSG057="{1}: Cannot call {2} when authenticationModel is SSO. Please use the AuthenticationProvider object instead.";msg.msgs.jsdoMSG058="{1}: Cannot pass username and password to addCatalog when authenticationModel "+"is sso. Pass an AuthenticationProvider instead.";msg.msgs.jsdoMSG059="{1}: Error in constructor. The authenticationModels of the "+"AuthenticationProvider ({2}) and the JSDOSession ({3}) were not compatible.";msg.msgs.jsdoMSG060="AuthenticationProvider: AuthenticationProvider is no longer logged in. "+"Tried to refresh SSO token but failed due to authentication error at token server.";msg.msgs.jsdoMSG061="{1}: Attempted to set {2} property to an invalid value.";msg.msgs.jsdoMSG062="{1}: Cannot call {2} when an AuthenticationProvider is already available and logged in.";msg.msgs.jsdoMSG100="JSDO: Unexpected HTTP response. Too many records.";msg.msgs.jsdoMSG101="Network error while executing HTTP request.";msg.msgs.jsdoMSG110="Catalog error: idProperty not specified for resource '{1}'. "+"idProperty is required {2}.";msg.msgs.jsdoMSG111="Catalog error: Schema '{1}' was not found in catalog.";msg.msgs.jsdoMSG112="Catalog error: Output parameter '{1}' was not found for operation '{2}'.";msg.msgs.jsdoMSG113="Catalog error: Found xType '{1}' for output parameter '{2}' "+"for operation '{3}' but xType DATASET, TABLE or ARRAY was expected.";msg.msgs.jsdoMSG114="JSDO: idProperty '{1}' is missing from '{2}' record.";msg.msgs.jsdoMSG115="JSDO: Invalid option specified in {1}() call.";msg.msgs.jsdoMSG116="JSDO: {1} parameter must be a string in {2} call.";msg.msgs.jsdoMSG117="JSDO: Schema from storage area '{1}' does not match JSDO schema";msg.msgs.jsdoMSG118="JSDO: Plugin '{1}' was not found.";msg.msgs.jsdoMSG119="JSDO: A mappingType is expected when 'capabilities' is set."+" Please specify a plugin (ex: JFP).";msg.msgs.jsdoMSG120="JSDO: Parameter '{2}' requires capability '{1}' in the catalog.";msg.msgs.jsdoMSG121="{1}: Argument {2} must be of type {3} in {4} call.";msg.msgs.jsdoMSG122="{1}: Incorrect number of arguments in {2} call. There should be {3}.";msg.msgs.jsdoMSG123="{1}: A server response included an invalid '{2}' header.";msg.msgs.jsdoMSG124="JSDO: autoApplyChanges is not supported for saveChanges(true) "+"with a temp-table. Use jsdo.autoApplyChanges = false.";msg.msgs.jsdoMSG125="{1}: The AuthenticationProvider is not managing valid credentials.";msg.msgs.jsdoMSG126="{1}: No support for {2}.";msg.msgs.jsdoMSG127="JSDO: acceptRowChanges() cannot be called for record with _rejected === true.";msg.msgs.jsdoMSG500="{1}: '{2}' objects must contain a '{3}' property.";msg.msgs.jsdoMSG501="{1}: '{2}' in '{3}' function cannot be an empty string.";msg.msgs.jsdoMSG502="{1}: The '{2}' parameter passed to the '{3}' function has an invalid value for "+"its '{4}' property.";msg.msgs.jsdoMSG503="{1}: '{2}' must be of type '{3}'.";msg.msgs.jsdoMSG504="{1}: {2} has an invalid value for the '{3}' property.";msg.msgs.jsdoMSG505="{1}: '{2}' objects must have a '{3}' method.";msg.msgs.jsdoMSG506="{1}: Invalid argument for the {2} parameter in {3} call.";msg.msgs.jsdoMSG507="{1}: '{2}' is an invalid value for the {3} parameter in {4} call.";msg.msgs.jsdoMSG508="JSDOSession: If a JSDOSession object is using the SSO authentication model, "+"the options object passed to its constructor must include an authProvider property.";msg.msgs.jsdoMSG509="progress.data.getSession: If the authenticationModel is AUTH_TYPE_SSO, "+"authenticationURI and authProviderAuthenticationModel are required parameters.";msg.msgs.jsdoMSG510="{1}: This session has been invalidated and cannot be used.";msg.msgs.jsdoMSG511="JSDOSession: addCatalog() can only be called if an AuthenticationProvider was passed as an argument or "+"connect() has been successfully called.";msg.msgs.jsdoMSG512="JSDOSession: Error while loading multiple catalogs.";msg.msgs.jsdoMSG998="JSDO: JSON object in addRecords() must be DataSet or Temp-Table data.";msg.getMsgText=function(n,args){var text=msg.msgs[n],i;if(!text){throw new Error("Message text was not found by getMsgText()")}for(i=1;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true;data=newDataArray}else{if(params&&(params.sort||params.top)){newDataArray=[];for(i=0;i0){sortObject.tableRef=this;data.sort(this._getCompareFn(sortObject))}}if(params.top){if(typeof params.skip=="undefined"){params.skip=0}data=data.splice(params.skip,params.top)}}return data};this._recToDataObject=function(record,includeChildren){var array=[record];var dataObject=array;if(typeof includeChildren=="undefined"){includeChildren=false}if(this._jsdo._dataSetName){dataObject={};dataObject[this._jsdo._dataSetName]={};dataObject[this._jsdo._dataSetName][this._name]=array;if(includeChildren&&this._children.length>0){var jsrecord=this._findById(record._id,false);if(jsrecord){for(var i=0;i0){for(var j=0;j0){for(var i=0;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true};this._equalRecord=function(rec1,rec2,keyFields){var field;var match=true;for(var i=0;ivalue2||(value1===undefined||value1===null))return sortAscending[i]?1:-1;else if(value10)this._sort(sortObject)}else{this._sort(arg1)}this._createIndex()};this._sort=function(arg1){if(arguments.length===0&&(!this.autoSort||this._sortFn===undefined&&this._sortObject.sortFields===undefined))return;if(arguments.length===0){if(this._sortFn){this._data.sort(this._sortFn)}else{this._data.sort(this._compareFields)}this._needsAutoSorting=false}else{if(typeof arg1=="function"){this._data.sort(this._getCompareFn(arg1))}else{arg1.tableRef=this;this._data.sort(this._getCompareFn(arg1))}if(this.autoSort)this._needsAutoSorting=true}};this.addRecords=function(jsonObject,addMode,keyFields,trackChanges,isInvoke){this._jsdo._addRecords(this._name,jsonObject,addMode,keyFields,trackChanges,isInvoke)};this.acceptChanges=function(){var tableRef=this;for(var id in tableRef._beforeImage){if(tableRef._beforeImage[id]===null){var jsrecord=tableRef._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}else if(this._changed[id]!==undefined){var jsrecord=this._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}}tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[];tableRef._beforeImage={}};this.rejectChanges=function(){for(var id in this._beforeImage){if(this._beforeImage[id]===null){this._jsdo._undoCreate(this,id)}else if(this._changed[id]!==undefined){this._jsdo._undoUpdate(this,id,true)}else{this._jsdo._undoDelete(this,id,true)}}var tableRef=this;tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[]};this.hasChanges=function(){return Object.keys(this._beforeImage).length!==0};this.getChanges=function(){var result=[];for(var id in this._beforeImage){var item={rowState:"",record:null};if(this._beforeImage[id]===null){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_CREATE];item.record=this._findById(id,false)}else if(this._changed[id]!==undefined){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_UPDATE];item.record=this._findById(id,false)}else{item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_DELETE];item.record=new progress.data.JSRecord(this,this._beforeImage[id])}result.push(item)}return result};this._clearErrorStrings=function(){var record=null;for(var id in this._beforeImage){if(this._beforeImage[id]===null){record=this._findById(id,false);if(record){delete record.data._errorString}}else{record=this._findById(id,false);if(record){delete record.data._errorString}else{delete this._beforeImage[id]._errorString}}}};this._applyChanges=function(){var i;for(var id in this._beforeImage){if(this._beforeImage[id]===null){var jsrecord=this._findById(id,false);if(jsrecord===null&&this._jsdo._resource.idProperty!==undefined){if(this._tmpIndex[id]){var record=this._data[this._tmpIndex[id].index];jsrecord=record?new progress.data.JSRecord(this,record):null;delete this._tmpIndex[id]}}if(jsrecord!==null){if(jsrecord.data._rejected||jsrecord.data._errorString!==undefined){this._jsdo._undoCreate(this,id)}else{jsrecord.acceptRowChanges()}}else{var found=false;for(var i=0;i0){for(var i=0;iindex){i--}if(i!=index){this._tableRef._data.splice(index,1);this._tableRef._data.splice(i,0,record);this._tableRef._createIndex()}}}};this.assign=function(record){if(record===undefined)throw new Error(msg.getMsgText("jsdoMSG024","JSDO","assign() or update()"));this._saveBeforeImageUpdate();var fieldName,i,j,value,schema=this._tableRef.getSchema(),prefixElement,name;if(record){for(i=0;i0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){return this.record.data[name][element-1]}}return this.record.data[fieldName]}else return null},set:function(value){var name=fieldName,index,element,fieldInfo;if(this.record){this.record._saveBeforeImageUpdate();try{index=fieldName.indexOf(progress.data.JSDO.ARRAY_INDEX_SEPARATOR);if(index>0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){this.record.data[name][element-1]=value;return}}this.record.data[fieldName]=value}finally{this.record._sortRecord(name)}}},enumerable:true,writeable:true})};Object.defineProperty(this,"hasSubmitOperation",{get:function(){return this._hasSubmitOperation},enumerable:true});Object.defineProperty(this,"hasCUDOperations",{get:function(){return this._hasCUDOperations},enumerable:true});Object.defineProperty(this,"defaultTableRef",{get:function(){return this._defaultTableRef},enumerable:true});this._buffers={};this._numBuffers=0;this._defaultTableRef=null;this._async=true;this._dataProperty=null;this._dataSetName=null;this.operations=[];this.useRelationships=true;this._session=null;this._needCompaction=false;this._hasCUDOperations=false;this._hasSubmitOperation=false;this._useSubmit=false;this.autoApplyChanges=true;this._lastErrors=[];this._localStorage=null;this._convertForServer;this._fillMergeMode;var autoFill=false;if(!arguments[0]){throw new Error("JSDO: Parameters are required in constructor.")}if(typeof arguments[0]=="string"){this.name=arguments[0]}else if(typeof arguments[0]=="object"){var args=arguments[0];for(var v in args){switch(v){case"autoFill":autoFill=args[v];break;case"events":this._events={};for(var eventName in args[v]){this._events[eventName.toLowerCase()]=args[v][eventName]}break;case"dataProperty":this._dataProperty=args[v];break;default:this[v]=args[v]}}}if(!this.name){throw new Error("JSDO: JSDO constructor is missing the value for 'name'")}if(this._events){if(typeof this._events!=="object"){throw new Error("JSDO: JSDO constructor event object is not defined as an object")}for(var prop in this._events){var evt=this._events[prop];if(!(evt instanceof Array)){throw new Error("JSDO: JSDO constructor event object for "+prop+" must be an array")}evt.forEach(function(el){if(typeof el!=="object"){throw new Error("JSDO: JSDO constuctor event object for "+prop+" is not defined as an object")}if(typeof el.fn!=="function"){throw new Error("JSDO: JSDO event listener for "+prop+" is not a function.")}if(el.scope&&typeof el.scope!=="object"){throw new Error("JSDO: JSDO event listener scope for "+prop+" is not an object.")}})}}if(this.name){this._resource=progress.data.ServicesManager.getResource(this.name);if(this._resource){if(!this.url)this.url=this._resource.url;if(!this._dataSetName&&this._resource._dataSetName){this._dataSetName=this._resource._dataSetName;if(this._resource.dataProperty){var buffer=this[this._resource.dataProperty]=new progress.data.JSTableRef(this,this._resource.dataProperty);this._buffers[this._resource.dataProperty]=buffer}else{for(var tableName in this._resource.fields){var buffer=this[tableName]=new progress.data.JSTableRef(this,tableName);this._buffers[tableName]=buffer}}}if(!this._dataProperty&&this._resource.dataProperty)this._dataProperty=this._resource.dataProperty;if(!this._dataSetName){var tableName=this._dataProperty?this._dataProperty:"";this._buffers[tableName]=new progress.data.JSTableRef(this,tableName);if(tableName)this[tableName]=this._buffers[tableName]}var properties,tableName;if(this._dataSetName&&this._resource.schema&&this._resource.schema.properties[this._dataSetName]){properties=this._resource.schema.properties[this._dataSetName].properties;if(Object.keys(properties).length===1){tableName=Object.keys(properties)[0];if(properties[tableName].idProperty){this._resource.idProperty=properties[tableName].idProperty}}}else if(this._resource.schema&&this._resource.schema.properties&&this._resource.schema.properties[tableName]&&this._resource.schema.properties[tableName].idProperty){this._resource.idProperty=this._resource.schema.properties[tableName].idProperty}for(var fnName in this._resource.fn){this[fnName]=this._resource.fn[fnName]["function"]}this._hasCUDOperations=this._resource.generic["create"]!==undefined||this._resource.generic["update"]!==undefined||this._resource.generic["delete"]!==undefined;this._hasSubmitOperation=this._resource.generic["submit"]!==undefined;if(!this._session){var myservice=progress.data.ServicesManager.getService(this._resource.service.name);this._session=myservice._session;this._session._pushJSDOs(this)}}else{throw new Error(msg.getMsgText("jsdoMSG004",this.name))}}else{this._buffers[""]=new progress.data.JSTableRef(this,"")}if(!this._session){throw new Error("JSDO: Unable to get user session for resource '"+this.name+"'")}for(var buf in this._buffers){this._buffers[buf]._parent=null;this._buffers[buf]._children=[];this._buffers[buf]._relationship=null;this._buffers[buf]._isNested=false;if(!this._defaultTableRef)this._defaultTableRef=this._buffers[buf];this._numBuffers++}if(this._numBuffers!=1)this._defaultTableRef=null;else{this.record=null}if(typeof Object.defineProperty=="function"){this._caseSensitive=false;Object.defineProperty(this,"caseSensitive",{get:function(){return this._caseSensitive},set:function(value){this._caseSensitive=value?true:false;for(var buf in this._buffers){this._buffers[buf].caseSensitive=this._caseSensitive}},enumerable:true,writeable:true});this._autoSort=true;Object.defineProperty(this,"autoSort",{get:function(){return this._autoSort},set:function(value){this._autoSort=value?true:false;for(var buf in this._buffers){this._buffers[buf].autoSort=this._autoSort}},enumerable:true,writeable:true})}this._properties={};if(typeof Object.defineProperty=="function"){Object.defineProperty(this,"this._properties",{get:function(){return this._properties},enumerable:false})}if(this._resource&&this._resource.fields){for(var buf in this._buffers){this._buffers[buf]._schema=this._resource.fields[buf];this._buffers[buf]._primaryKeys=this._resource.primaryKeys[buf];this._buffers[buf]._fields={};var fields=this._buffers[buf]._schema;for(var i=0;i1){for(var buf in this._buffers){var fields=[];var found=false;for(var i=0;i=0?index+1:"");element.value=value?value[index]:undefined;return element};this.isDataSet=function(){return this._dataSetName?true:false};this._invokeComplete=function(jsdo,success,request){if(request.async&&request.fnName){jsdo.trigger("afterInvoke",request.fnName,jsdo,success,request)}if(request.deferred){if(success){request.deferred.resolve(jsdo,success,request)}else{request.deferred.reject(jsdo,success,request)}}};this._invokeSuccess=function(){};this._invokeError=function(){};this._httpRequest=function(xhr,method,url,reqBody,request){function afterOpenRequest(){var input=null;if(reqBody){xhr.setRequestHeader("Content-Type","application/json; charset=utf-8");input=JSON.stringify(reqBody)}try{xhr.send(input)}catch(e){request.success=false;request.exception=e;xhr.jsdo._session._checkServiceResponse(xhr,request.success,request)}}if(!xhr){xhr=new XMLHttpRequest;xhr.onCompleteFn=this._invokeComplete;xhr.onSuccessFn=this._invokeSuccess;xhr.onErrorFn=this._invokeError;xhr.onreadystatechange=this.onReadyStateChangeGeneric;if(request.async&&request.fnName){this.trigger("beforeInvoke",request.fnName,this,request)}if(reqBody){if(this._resource&&this._resource.service){var useRequest=this._resource.service.useRequest;if(this._resource.service.settings&&this._resource.service.settings.useRequest!==undefined){useRequest=this._resource.service.settings.useRequest}if(useRequest){reqBody={request:reqBody}}}}}xhr.request=request;xhr.jsdo=this;request.jsdo=this;request.xhr=xhr;this._session._openRequest(xhr,method,url,request.async,afterOpenRequest);return request};this._getDataObject=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};var oldUseRelationships=this.useRelationships;try{this.useRelationships=false;for(var buf in this._buffers){dataObject[this._dataSetName][buf]=this._buffers[buf].getData()}}finally{this.useRelationships=oldUseRelationships}}else{if(this._dataProperty){dataObject[this._dataProperty]=this.getData()}else return this.getData()}return dataObject};this._getDataObjectAsNested=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};try{for(var buf in this._buffers){var bufObj=this._buffers[buf];if(bufObj._isNested)continue;this._nestChildren=false;if(bufObj._children.length>0){for(var i=0;i0){hasErrors=true}}if(hasErrors){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._allRecordsRejected=true;this._someRecordsRejected=false;hasCommittedRecords=false;for(i=0;i0&&!param.operations[0].success){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._convertForServer=true;this._buffers[buf]._convertForServer=true}}};this._convertRequestData=function(objParam){var buf,beforeData;if(this._convertForServer===false){return}for(buf in this._buffers){if(this._buffers[buf]._convertForServer){if(objParam[this._dataSetName]){if(objParam[this._dataSetName][buf]){this._convertTableData(this._buffers[buf],objParam[this._dataSetName][buf])}beforeData=objParam[this._dataSetName]["prods:before"];if(beforeData&&beforeData[buf]){this._convertTableData(this._buffers[buf],beforeData[buf])}}else if(objParam[buf]){this._convertTableData(this._buffers[buf],objParam[buf])}}}};this._convertTableData=function(tableRef,tableData){var i;for(i=0;i0){this._confirmOperationExists(progress.data.JSDO._OP_DELETE);checkedDelete=true}if(!checkedCreate&&tableRef._added.length>0){this._confirmOperationExists(progress.data.JSDO._OP_CREATE);checkedCreate=true}if(!checkedUpdate&&Object.keys(tableRef._changed).length>0){this._confirmOperationExists(progress.data.JSDO._OP_UPDATE);checkedUpdate=true}if(checkedDelete&&checkedCreate&&checkedUpdate){break}}};this._confirmOperationExists=function(operation){var operationStr=PROGRESS_JSDO_OP_STRING[operation];if(typeof this._resource.generic[operationStr]!=="function"){throw new Error(msg.getMsgText("jsdoMSG046",operationStr.toUpperCase()))}};this.invoke=function(name,object){var deferred,promise;try{var request=this[name](object);if(request.deferred){deferred=request.deferred;promise=request.deferred.promise()}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{if(!deferred){deferred=new progress.util.Deferred;promise=deferred.promise()}deferred.reject(this,false,{errorObject:error})}}return promise};this._syncTableRef=function(operation,tableRef,batch){var rowData,requestData,jsonObject,dataSetObject;if(tableRef._visited)return;tableRef._visited=true;if(!batch){batch={operations:[]}}else if(!batch.operations){batch.operations=[]}switch(operation){case progress.data.JSDO._OP_CREATE:for(var i=0;i0&&!dataSetJsonObject[tableRef._name])dataSetJsonObject[tableRef._name]=[];for(var i=0;i0||tableRef._added.length>0||hasUpdates){hasChanges=true;break}}return hasChanges};this._addDeletesToChangeSet=function(tableRef,dataSetJsonObject,request){for(var i=0;i=10){tmpIndex={};for(var i=0;ivalue2||value1===null)return false;else if(value11){for(var buf in this._buffers){if(this._buffers[buf]._isNested&&this._buffers[buf]._parent&&this._buffers[this._buffers[buf]._parent]){var srcData=this._buffers[this._buffers[buf]._parent]._data;var data=[];for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}var recordId=beforeTableJsonObject[0]["prods:clientId"];if(!recordId){throw new Error(msg.getMsgText("jsdoMSG035","_checkForDeleteError()"))}if(beforeTableJsonObject[0]["prods:hasErrors"]){var prods_id=beforeTableJsonObject[0]["prods:id"];var errorString=this._getErrorStringFromJsonObject(dataSetJsonObject,tableRef,prods_id);this._setErrorString(tableRef,recordId,errorString,true);hasError=true}}return hasError};this._mergeUpdateForSubmit=function(jsonObject,xhr){var errorString;if(!this._dataSetName){throw new Error(msg.getMsgText("jsdoMSG036","_mergeUpdateForSubmit()"))}var dataSetJsonObject=jsonObject[this._dataSetName];if(dataSetJsonObject[this._dataSetName])dataSetJsonObject=dataSetJsonObject[this._dataSetName];var beforeJsonObject=dataSetJsonObject["prods:before"];for(var buf in this._buffers){var tableRef=this._buffers[buf];var tableJsonObject=dataSetJsonObject[tableRef._name];if(tableJsonObject instanceof Array){for(var i=0;i1){request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}}if(beforeJsonObject){hasError=jsdo._checkForDeleteError(dataSetJsonObject,xhr)}if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._deleteError(jsdo,success,request)}}};this._deleteError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoDelete(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._createComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterCreate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterCreate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._createSuccess=function(jsdo,success,request){var xhr=request.xhr;var record=request.response;var hasError=jsdo._mergeUpdateForCUD(record,xhr);if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._createError(jsdo,success,request)}}};this._createError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoCreate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._updateComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterUpdate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterUpdate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._updateSuccess=function(jsdo,success,request){var xhr=request.xhr;var hasError=jsdo._mergeUpdateForCUD(request.response,xhr);if(hasError){request.success=false}if(jsdo.autoApplyChanges){if(!hasError){request.success=true;delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._updateError(jsdo,success,request)}}};this._updateError=function(jsdo,success,request){if(jsdo.autoApplyChanges){request.success=false;jsdo._undoUpdate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._saveChangesSuccess=function(jsdo,success,request){var records=request.response;jsdo._mergeUpdateForSubmit(records,request.xhr);jsdo._clearErrors();var changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(changes);if(jsdo.autoApplyChanges){jsdo._applyChanges()}};this._saveChangesError=function(jsdo,success,request){jsdo._setAllRecordsRejected(true);if(jsdo.autoApplyChanges){jsdo.rejectChanges()}jsdo._updateLastErrors(jsdo,null,null,request)};this._saveChangesSuccessTT=function(jsdo,success,request){var changes;jsdo._clearErrors();changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(false)};this._saveChangesComplete=function(jsdo,success,request){if(request.xhr.status>=200&&request.xhr.status<300&&(jsdo._lastErrors.length>0||jsdo._someRecordsRejected)){request.success=false}if(jsdo._useSubmit===true){jsdo._fireCUDTriggersForSubmit(request)}jsdo._undefWorkingRecord();jsdo._fireAfterSaveChanges(request.success,request)};this._fireAfterSaveChanges=function(success,request){this.trigger("afterSaveChanges",this,success,request);if(request.jsrecords){if(request.deferred){if(success){request.deferred.resolve(this,success,request)}else{request.deferred.reject(this,success,request)}}}else if(request.batch&&request.batch.deferred){if(success){request.batch.deferred.resolve(this,success,request)}else{request.batch.deferred.reject(this,success,request)}}var clearErrorString=this.autoApplyChanges;if(request.jsrecords){for(var idx=0;idx=400&&request.xhr.status<600){try{var responseObject=JSON.parse(request.xhr.responseText);if(responseObject instanceof Array){errorArray=responseObject}else if(responseObject instanceof Object){errorArray.push(responseObject)}for(i=0;i=400&&request.xhr.status<600)){errors.push({type:progress.data.JSDO.ERROR,error:"Error: HTTP Status "+request.xhr.status+" "+request.xhr.statusText,responseText:request.xhr.responseText})}}return errors};this._updateLastErrors=function(jsdo,batch,changes,request){var errors,errorText,responseObject,i,j,buf;if(batch){if(batch.operations===undefined)return;for(i=0;i=200&&request.xhr.status<300){jsdo._lastErrors.push({errorString:request.jsrecord.data._errorString});jsdo._buffers[request.jsrecord._tableRef._name]._lastErrors.push({type:progress.data.JSDO.DATA_ERROR,id:request.jsrecord.data._id,error:request.jsrecord.data._errorString})}else{errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}if(request.jsrecord&&(errors[j].type===progress.data.JSDO.APP_ERROR||errors[j].type===progress.data.JSDO.RETVAL)){errors[j].id=request.jsrecord.data._id;request.jsrecord._tableRef._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}}}}else if(changes instanceof Array){for(i=0;i=400&&request.xhr.status<600||request.xhr.status===0)){errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}for(buf in this._buffers){this._buffers[buf]._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}};this._checkSaveComplete=function(xhr){if(xhr.request){var jsdo=xhr.request.jsdo;var batch=xhr.request.batch;if(jsdo&&batch&&jsdo._async){if(jsdo._isBatchComplete(batch)){var success=jsdo._isBatchSuccess(batch);var request={batch:batch,success:success};jsdo._undefWorkingRecord();jsdo._lastErrors=[];if(!success&&batch.operations){jsdo._updateLastErrors(jsdo,batch,null)}this._setAllRecordsRejected(batch);jsdo._fireAfterSaveChanges(success,request)}}}};this._isBatchSuccess=function(batch){if(batch.operations){for(var i=0;i=200&&xhr.status<300||xhr.status===0&&xhr.responseText!==""){request.success=true;xhr.jsdo._session._saveClientContextId(xhr);if(typeof xhr.onSuccessFn=="function"){var operation;if(xhr.request.fnName!==undefined&&xhr.jsdo._resource.fn[xhr.request.fnName]!==undefined){operation=xhr.jsdo._resource.fn[xhr.request.fnName].operation}else operation=null;if(operation===undefined||operation!==null&&operation.mergeMode)xhr.jsdo._mergeInvoke(request.response,xhr);if(request.success)xhr.onSuccessFn(xhr.jsdo,request.success,request);else if(typeof xhr.onErrorFn=="function")xhr.onErrorFn(xhr.jsdo,request.success,request)}}else{request.success=false;if(xhr.status===0){request.exception=new Error(msg.getMsgText("jsdoMSG101"))}if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}xhr.jsdo._session._checkServiceResponse(xhr,request.success,request);if(typeof xhr.onCompleteFn=="function"){xhr.onCompleteFn(xhr.jsdo,request.success,request)}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}};this.acceptChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].acceptChanges()}};this.rejectChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].rejectChanges()}};this.getChanges=function(){var result=[];for(var buf in this._buffers){var changes=this._buffers[this._buffers[buf]._name].getChanges();result=result.concat(changes)}return result};this.hasChanges=function(){for(var buf in this._buffers){if(this._buffers[this._buffers[buf]._name].hasChanges())return true}return false};this._applyChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name]._applyChanges()}};this.acceptRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.acceptRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","acceptRowChanges()"))};this.rejectRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.rejectRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","rejectRowChanges()"))};this.setProperties=function(propertiesObject){var prop;if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(typeof propertiesObject=="object"){this._properties={};for(prop in propertiesObject){if(propertiesObject.hasOwnProperty(prop)){if(typeof propertiesObject[prop]!=="function"){this._properties[prop]=propertiesObject[prop]}}}}else if(propertiesObject===undefined||propertiesObject===null){this._properties={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"Object","setProperties"))}};this.setProperty=function(propertyName,propertyValue){if(arguments.length<2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(arguments.length!==2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(typeof propertyName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"string","setProperty"))}if(propertyValue===undefined){delete this._properties[propertyName]}else{this._properties[propertyName]=propertyValue}};this.getProperties=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperties",0))}return this._properties};this.getProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}return this._properties[propertyName]};this.saveLocal=function saveLocal(arg1,arg2){var name;var dataMode;if(arguments.length>2){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"||arg1===null||arg1===undefined){name=arg1;dataMode=arg2}else{name=null;dataMode=arg1}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}if(typeof dataMode=="undefined"){dataMode=progress.data.JSDO.ALL_DATA}else{switch(dataMode){case progress.data.JSDO.ALL_DATA:case progress.data.JSDO.CHANGES_ONLY:break;default:throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var dataObj=this._prepareDataObjectForLocalStorage(dataMode);this._localStorage.saveToLocalStorage(name,dataObj)};this.readLocal=function readLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));this._restoreFromLocalStorage(object,progress.data.JSDO.MODE_EMPTY)}return object!==null};this.addLocalRecords=function addLocalRecords(arg1,arg2,arg3){var name;var addMode;var keyFields;if(arguments.length<1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"){name=arg1;addMode=arg2;keyFields=arg3}else{name="jsdo_"+this._resource.service.name+"_"+this._resource.name;addMode=arg1;keyFields=arg2}if(typeof name=="undefined"||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(addMode!=progress.data.JSDO.MODE_REPLACE){throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));try{this._restoreFromLocalStorage(object,addMode,keyFields)}catch(e){var text=e.message;throw new Error(text.replace(new RegExp("addRecords","g"),"addLocalRecords"))}}return object!==null};this._containsPrimaryKeys=function _containsPrimaryKeys(){for(var buf in this._buffers){if(this._buffers[buf]._primaryKeys===null)return false}return true};this._hasMatchingSchema=function _hasMatchingSchema(storageObject){var isValid=true;if(storageObject===null||Object.keys(storageObject).length===0)return true;if(this._dataSetName){if(storageObject[this._dataSetName]){for(var buf in this._buffers)if(storageObject[this._dataSetName][buf]===undefined){isValid=false;break}}else isValid=false}else if(this._dataProperty){storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._dataProperty]===undefined)isValid=false}else{storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._defaultTableRef._name]===undefined)isValid=false}return isValid};this.deleteLocal=function deleteLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}this._localStorage.clearLocalStorage(name)};this._prepareDataObjectForLocalStorage=function(option){var storageObject={};if(this._dataSetName){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet(this._dataSetName);break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet(this._dataSetName,true);break}}else if(this._dataProperty){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}else{switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}return storageObject};this._restoreFromLocalStorage=function(storageObject,addMode,keyFields){if(storageObject&&Object.keys(storageObject).length>0){if(this._dataSetName){for(var buf in this._buffers)this._restoreDataForTable(this._buffers[buf],storageObject,addMode,keyFields)}else this._restoreDataForTable(this._defaultTableRef,storageObject,addMode,keyFields)}else if(addMode===progress.data.JSDO.MODE_EMPTY)this._clearData()};this._restoreDataForTable=function(tableRef,jsonObject,addMode,keyFields){keyFields=keyFields!==undefined?keyFields:tableRef._primaryKeys;if(keyFields===undefined&&this._resource.idProperty){keyFields=[];keyFields[0]=this._resource.idProperty}if(this._dataSetName){var oldUseRelationships=this.useRelationships;this.useRelationships=false;try{tableRef.addRecords(jsonObject,addMode,keyFields)}finally{this.useRelationships=oldUseRelationships}}else{this._dataSetName="_localStorage";tableRef.addRecords(jsonObject,addMode,keyFields);this._dataSetName=null}};this.getMethodProperties=function(operation,name){var idx;if(this._resource._operations){if(this._resource._operations[operation]){return this._resource._operations[operation]}}else{this._resource._operations={}}for(var idx=0;idx1?[params.sort]:[]}sortFields="";for(index=0;index=1?params.filter:undefined}if(params.filter){if(typeof params.filter==="string"){doConversion=false}params.tableRef=tableName;if(doConversion&¶ms.tableRef===undefined){throw new Error(msg.getMsgText("jsdoMSG045","fill() or read()","params","tableRef"))}if(reqCapabilities["filter"].mapping==="ablFilter"){if(doConversion){ablFilter=progress.util._convertToABLWhereString(jsdo._buffers[params.tableRef],params.filter)}else{ablFilter=params.filter}}else if(reqCapabilities["filter"].mapping==="sqlQuery"){if(doConversion){sqlQuery=progress.util._convertToSQLQueryString(jsdo._buffers[params.tableRef],params.filter,true)}else{sqlQuery=params.filter}}}filter=JSON.stringify({ablFilter:ablFilter,tableRef:params.tableRef,viewTables:jsdo.viewTables,sqlQuery:sqlQuery,orderBy:sortFields,skip:params.skip,top:params.top,id:params.id});params={filter:filter}}return params}});if(typeof progress.ui=="undefined")progress.ui={};progress.ui.UITableRef=function UITableRef(tableRef){this._tableRef=tableRef;this._listview=null;this._detailPage=null;this._listviewContent=undefined;this.addItem=function(format){var detailForm;if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._name));if(!this._listview)return;format=format?format:this._listview.format;detailForm=this._detailPage&&this._detailPage.name?this._detailPage.name:"";if(this._listviewContent===undefined){this.clearItems()}var text=this._listview.itemTemplate?this._listview.itemTemplate:progress.ui.UIHelper._itemTemplate;text=text.replace(new RegExp("{__format__}","g"),format);text=text.replace(new RegExp("{__id__}","g"),this._tableRef.record.data._id);text=text.replace(new RegExp("{__page__}","g"),detailForm);for(var field in this._tableRef.record.data){var value=this._tableRef.record.data[field];text=text.replace(new RegExp("{"+field+"}","g"),value!==undefined&&value!==null?value:"")}this._listviewContent+=text};this.clearItems=function(){if(this._listview){this._listviewContent="";var listviewElement=document.getElementById(this._listview.name);if(listviewElement){listviewElement.innerHTML=""}}};this._getFormFieldValue=function(fieldName,detailPageName){var value=null,field;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)value=field.val()}else{field=document.getElementById(fieldName);if(field){value=field.value}}return value};this._setFormField=function(fieldName,value,detailPageName){var field=null;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)field.val(value)}else{field=document.getElementById(fieldName);if(field){field.value=value}}};this.assign=function(detailPageName){if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._tableRef._name));if(arguments.length!==0&&typeof detailPageName!="string")throw new Error(msg.getMsgText("jsdoMSG024","UIHelper","assign()"));this._tableRef.record.assign(null);var fieldName;var schema=this._tableRef.getSchema();for(var i=0;i0){for(var i=0;i0&&fieldName.charAt(0)=="_")continue;if(fields&&fields[fieldName]===undefined)continue;var fieldLabel=this._tableRef._schema[i].title?this._tableRef._schema[i].title:this._tableRef._schema[i].name;var text=this._detailPage&&this._detailPage.fieldTemplate?this._detailPage.fieldTemplate:progress.ui.UIHelper._fieldTemplate;text=text.replace(new RegExp("{__label__}","g"),fieldLabel);text=text.replace(new RegExp("{__name__}","g"),this._tableRef._schema[i].name);htmltext+=text}htmltext+="";fields=null;return htmltext};this.getListViewRecord=function(htmlIElement){var id=htmlIElement.getAttribute("data-id");return this._tableRef.findById(id)};this.getFormRecord=function(detailPageName){var id=this._getFormFieldValue("_id",detailPageName);return this._tableRef.findById(id)};this._getIdOfElement=function(name){if(typeof $=="function"){var element=$("#"+name);if(!element||element.length===0){element=$('[dsid="'+name+'"]');if(element&&element.length==1){var id=element.attr("id");if(id)return id}}}return name};this.setDetailPage=function setDetailPage(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));this._detailPage=obj;this._detailPage.name=this._getIdOfElement(this._detailPage.name)};this.setListView=function setListView(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));if(obj.format&&typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"format"));this._listview=obj;this._listview.name=this._getIdOfElement(this._listview.name);if(!this._listview.format){if(typeof $=="function"){for(var i=0;i{__format__}';progress.ui.UIHelper._defaultFieldTemplate='
'+''+'
';progress.ui.UIHelper._itemTemplate=progress.ui.UIHelper._defaultItemTemplate;progress.ui.UIHelper._fieldTemplate=progress.ui.UIHelper._defaultFieldTemplate;progress.ui.UIHelper.setItemTemplate=function(template){progress.ui.UIHelper._itemTemplate=template?template:progress.ui.UIHelper._defaultItemTemplate};progress.ui.UIHelper.setFieldTemplate=function(template){progress.ui.UIHelper._fieldTemplate=template?template:progress.ui.UIHelper._defaultFieldTemplate}})();(function(){if(progress===undefined){progress={}}if(progress.data===undefined){progress.data={}}progress.data.ServicesManager={};progress.data.ServicesManager._services=[];progress.data.ServicesManager._resources=[];progress.data.ServicesManager._data=[];progress.data.ServicesManager._sessions=[];progress.data.ServicesManager._jsdosessions=[];progress.data.ServicesManager.addResource=function(id,resource){if(progress.data.ServicesManager._resources[id]===undefined){progress.data.ServicesManager._resources[id]=resource}else{throw new Error("A resource named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getResource=function(id){return progress.data.ServicesManager._resources[id]};progress.data.ServicesManager.addService=function(id,service){if(progress.data.ServicesManager._services[id]===undefined){progress.data.ServicesManager._services[id]=service}else{throw new Error("A service named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getService=function(id){return progress.data.ServicesManager._services[id]};progress.data.ServicesManager.addSession=function(catalogURI,session){if(progress.data.ServicesManager._sessions[catalogURI]===undefined){progress.data.ServicesManager._sessions[catalogURI]=session}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.addJSDOSession=function(catalogURI,jsdosession){if(progress.data.ServicesManager._jsdosessions[catalogURI]===undefined){progress.data.ServicesManager._jsdosessions[catalogURI]=jsdosession}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.getSession=function(catalogURI){try{return progress.data.ServicesManager._sessions[catalogURI]}catch(e){return null}};progress.data.ServicesManager.cleanSession=function(session){var servicesKey,resourcesKey,sessionsKey,service,services=progress.data.ServicesManager._services,resources=progress.data.ServicesManager._resources,sessions=progress.data.ServicesManager._sessions,jsdosessions=progress.data.ServicesManager._jsdosessions;for(servicesKey in services){service=null;if(services[servicesKey]._session===session){service=services[servicesKey];delete services[servicesKey]}if(!service){continue}for(resourcesKey in resources){if(resources[resourcesKey].service===service){delete resources[resourcesKey]}}}for(sessionsKey in sessions){if(sessions[sessionsKey]===session){delete sessions[sessionsKey];if(jsdosessions[sessionsKey]){delete jsdosessions[sessionsKey]}}}};function extractParamsFromURL(url){var urlParams=[],paramName=null;if(typeof url==="string"){url.split("").forEach(function(c){if(c==="{"){paramName=""}else if(c==="}"){if(paramName){urlParams.push(paramName)}paramName=null}else if(paramName!==null){paramName+=c}})}return urlParams}progress.data.ServicesManager.addCatalog=function(services,session){var name,value;if(!services){throw new Error("Cannot find 'services' property in catalog file.")}if(services instanceof Array){services.forEach(function(service){if(progress.data.ServicesManager.getService(service.name)!==undefined){throw new Error("A service named '"+service.name+"' was already loaded.")}if(service.resources instanceof Array){service.resources.forEach(function(resource){if(progress.data.ServicesManager.getResource(resource.name)!==undefined){throw new Error("A resource named '"+resource.name+"' was already loaded.")}})}else{throw new Error("Missing 'resources' array in catalog.")}});for(var j=0;j1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","setContext",1))}if(typeof context==="object"){contextObject={};for(prop in context){if(context.hasOwnProperty(prop)){if(typeof context[prop]!=="function"){contextObject[prop]=context[prop]}}}}else if(context===undefined||context===null){contextObject={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","Session",1,"Object","setContextProperty"))}contextString=null};this.getContext=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContext",0))}return contextObject};this.getContextProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}return contextObject[propertyName]}};progress.data.Session=function Session(options){var defPropSupported=false;if(typeof Object.defineProperty==="function"){defPropSupported=true}var that=this,jsdosession,isUserAgentiOS=false,isFirefox=false,isEdge=false,isIE=false,canPassCredentialsToOpenWithCORS=false,defaultiOSBasicAuthTimeout=4e3,deviceIsOnline=true,restApplicationIsOnline=false,oepingAvailable=false,hasResolvedPingURI=false,defaultPartialPingURI="/rest/_oepingService/_oeping",classicPartialPingURI="/rest/_oeping",partialPingURI=defaultPartialPingURI,_storageKey,_authProvider=null,customCredentials=false,storedAuthModel,storedURI,newURI,stateWasReadFromStorage=false;if(!options||options._silent!==true){console.warn("Session: As of JSDO 4.4, the Session object has been deprecated. "+"Please use the JSDOSession object instead.")}if(typeof navigator!=="undefined"){if(typeof navigator.userAgent!=="undefined"){isUserAgentiOS=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i);isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;isEdge=navigator.userAgent.indexOf("Edge/")>-1;isIE=navigator.userAgent.indexOf("Trident/")>-1||navigator.userAgent.indexOf("MSIE 10")>-1}}canPassCredentialsToOpenWithCORS=!(isFirefox||isEdge||isIE);function canPassCredentialsToOpen(){return canPassCredentialsToOpenWithCORS}this._onlineHandler=function(){setDeviceIsOnline(true);that.trigger("online",that,null)};this._offlineHandler=function(){setDeviceIsOnline(false);that.trigger("offline",that,progress.data.Session.DEVICE_OFFLINE,null)};if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("online",this._onlineHandler,false);window.addEventListener("offline",this._offlineHandler,false)}var _catalogURIs=[];var _services=[];var _jsdos=[];this.onOpenRequest=null;var _password=null;if(defPropSupported){var _userName=null;Object.defineProperty(this,"userName",{get:function(){return _userName},enumerable:true});var _loginTarget="/static/home.html";Object.defineProperty(this,"loginTarget",{get:function(){return _loginTarget},enumerable:true});var _serviceURI=null;Object.defineProperty(this,"serviceURI",{get:function(){return _serviceURI},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _catalogURIs},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _services},enumerable:true});var _loginResult=null;Object.defineProperty(this,"loginResult",{get:function(){return _loginResult},enumerable:true});var _loginHttpStatus=null;Object.defineProperty(this,"loginHttpStatus",{get:function(){return _loginHttpStatus},enumerable:true});var _clientContextId=null;Object.defineProperty(this,"clientContextId",{get:function(){return _clientContextId},enumerable:true});var _authenticationModel=progress.data.Session.AUTH_TYPE_ANON;Object.defineProperty(this,"authenticationModel",{get:function(){return _authenticationModel},set:function(newval){if(newval){newval=newval.toLowerCase()}switch(newval){case progress.data.Session.AUTH_TYPE_FORM:case progress.data.Session.AUTH_TYPE_BASIC:case progress.data.Session.AUTH_TYPE_ANON:case progress.data.Session.AUTH_TYPE_SSO:case progress.data.Session.AUTH_TYPE_BEARER:case null:_authenticationModel=newval;storeSessionInfo("authenticationModel",newval);break;default:throw new Error("Error setting Session.authenticationModel. '"+newval+"' is an invalid value.")}},enumerable:true});var _lastSessionXHR=null;Object.defineProperty(this,"lastSessionXHR",{get:function(){return _lastSessionXHR},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return this.loginResult===progress.data.Session.LOGIN_SUCCESS&&restApplicationIsOnline&&deviceIsOnline},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _jsdos},enumerable:true});var _pingInterval=0;var _timeoutID=null;Object.defineProperty(this,"pingInterval",{get:function(){return _pingInterval},set:function(newval){if(typeof newval==="number"&&newval>=0){_pingInterval=newval;storeSessionInfo("pingInterval",newval);if(newval>0){if(this.loginResult===progress.data.Session.LOGIN_SUCCESS){_timeoutID=setTimeout(this._autoping,newval)}}else if(newval===0){clearTimeout(_timeoutID);_pingInterval=0}}else{throw new Error("Error setting Session.pingInterval. '"+newval+"' is an invalid value.")}},enumerable:true});var _contextProperties=new progress.data.ContextProperties;Object.defineProperty(this,"_contextProperties",{get:function(){return _contextProperties},enumerable:false});var isInvalidated=false;Object.defineProperty(this,"_isInvalidated",{get:function(){return isInvalidated},enumerable:false});Object.defineProperty(this,"_authProvider",{get:function(){return _authProvider},set:function(newval){if(_authProvider){throw new Error("Internal Error setting Session._authProvider. '"+"The property has already been set.")}setAuthProvider(newval)},enumerable:false})}else{this.userName=null;this.loginTarget="/static/home.html";this.serviceURI=null;this.catalogURIs=[];this.services=[];this.loginResult=null;this.loginHttpStatus=null;this.clientContextId=null;this.authenticationModel=progress.data.Session.AUTH_TYPE_ANON;this.lastSessionXHR=null}function storeSessionInfo(infoName,value){var key;if(that.loginResult===progress.data.Session.LOGIN_SUCCESS&&typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}if(typeof value!=="undefined"){sessionStorage.setItem(key,JSON.stringify(value))}}}function retrieveSessionInfo(infoName){var key,jsonStr,value=null;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}jsonStr=sessionStorage.getItem(key);if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}}function clearSessionInfo(infoName){var key;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName;sessionStorage.removeItem(key)}}}function storeAllSessionInfo(){if(_storageKey){storeSessionInfo("loginResult",that.loginResult);storeSessionInfo("userName",that.userName);storeSessionInfo("serviceURI",that.serviceURI);storeSessionInfo("loginHttpStatus",that.loginHttpStatus);storeSessionInfo("authenticationModel",that.authenticationModel);storeSessionInfo("pingInterval",that.pingInterval);storeSessionInfo("oepingAvailable",oepingAvailable);storeSessionInfo("partialPingURI",partialPingURI);storeSessionInfo("clientContextId",that.clientContextId);storeSessionInfo("deviceIsOnline",deviceIsOnline);storeSessionInfo("restApplicationIsOnline",restApplicationIsOnline);if(that._authProvider){storeSessionInfo("_authProvider.init",{uri:that._authProvider.uri,authenticationModel:that._authProvider.authenticationModel})}storeSessionInfo(_storageKey,true)}}function clearAllSessionInfo(){if(_storageKey){if(retrieveSessionInfo(_storageKey)){clearSessionInfo("loginResult");clearSessionInfo("userName");clearSessionInfo("serviceURI");clearSessionInfo("loginHttpStatus");clearSessionInfo("clientContextId");clearSessionInfo("deviceIsOnline");clearSessionInfo("restApplicationIsOnline");clearSessionInfo("authenticationModel");clearSessionInfo("pingInterval");clearSessionInfo("oepingAvailable");clearSessionInfo("partialPingURI");clearSessionInfo("_authProvider.init");clearSessionInfo(_storageKey)}}}function setSessionInfoFromStorage(key){var authproviderInitObject;if(retrieveSessionInfo(key)){setLoginResult(retrieveSessionInfo("loginResult"),this);setUserName(retrieveSessionInfo("userName"),this);setServiceURI(retrieveSessionInfo("serviceURI"),this);setLoginHttpStatus(retrieveSessionInfo("loginHttpStatus"),this);setClientContextID(retrieveSessionInfo("clientContextId"),this);setDeviceIsOnline(retrieveSessionInfo("deviceIsOnline"));setRestApplicationIsOnline(retrieveSessionInfo("restApplicationIsOnline"));that.authenticationModel=retrieveSessionInfo("authenticationModel");that.pingInterval=retrieveSessionInfo("pingInterval");setOepingAvailable(retrieveSessionInfo("oepingAvailable"));setPartialPingURI(retrieveSessionInfo("partialPingURI"));if(!that._authProvider){authproviderInitObject=retrieveSessionInfo("_authProvider.init");if(authproviderInitObject){setAuthProvider(new progress.data.AuthenticationProvider(authproviderInitObject))}}}}function setUserName(newname,sessionObject){if(defPropSupported){_userName=newname}else{sessionObject.userName=newname}storeSessionInfo("userName",newname)}function setLoginTarget(target,sessionObject){if(defPropSupported){_loginTarget=target}else{sessionObject.loginTarget=target}}function setServiceURI(url,sessionObject){if(defPropSupported){_serviceURI=url}else{sessionObject.serviceURI=url}storeSessionInfo("serviceURI",url)}function pushCatalogURIs(url,sessionObject){if(defPropSupported){_catalogURIs.push(url)}else{sessionObject.catalogURIs.push(url)}}function pushService(serviceObject,sessionObject){if(defPropSupported){_services.push(serviceObject)}else{sessionObject.services.push(serviceObject)}}function findService(serviceName){_services.forEach(function(service){if(service.name===serviceName){return service}});return null}function setLoginResult(result,sessionObject){if(defPropSupported){_loginResult=result}else{sessionObject.loginResult=result}if(result===progress.data.Session.LOGIN_SUCCESS){storeSessionInfo("loginResult",result)}else{clearAllSessionInfo()}}function setLoginHttpStatus(status,sessionObject){if(defPropSupported){_loginHttpStatus=status}else{sessionObject.loginHttpStatus=status}storeSessionInfo("loginHttpStatus",status)}function setClientContextIDfromXHR(xhr,sessionObject){if(xhr){setClientContextID(getResponseHeaderNoError(xhr,"X-CLIENT-CONTEXT-ID"),sessionObject)}}function setClientContextID(ccid,sessionObject){if(defPropSupported){_clientContextId=ccid}else{sessionObject.clientContextId=ccid}storeSessionInfo("clientContextId",ccid)}function setLastSessionXHR(xhr,sessionObject){if(defPropSupported){_lastSessionXHR=xhr}else{sessionObject.lastSessionXHR=xhr}}function setDeviceIsOnline(value){deviceIsOnline=value;storeSessionInfo("deviceIsOnline",value)}function setAuthProvider(value){_authProvider=value?value:null}function setRestApplicationIsOnline(value){restApplicationIsOnline=value;storeSessionInfo("restApplicationIsOnline",value)}function setOepingAvailable(value){oepingAvailable=value;storeSessionInfo("oepingAvailable",value)}function setPartialPingURI(value){partialPingURI=value;storeSessionInfo("partialPingURI",value)}function getResponseHeaderNoError(xhr,headerName){var allHeaders=xhr._pdsResponseHeaders,regExp;if(allHeaders===undefined){allHeaders=xhr.getAllResponseHeaders();if(allHeaders){xhr._pdsResponseHeaders=allHeaders}else{xhr._pdsResponseHeaders=null}}if(allHeaders){regExp=new RegExp("^"+headerName+":","mi");if(allHeaders.match(regExp)){return xhr.getResponseHeader(headerName)}}return null}this._pushJSDOs=function(jsdo){_jsdos.push(jsdo)};this._openRequest=function(xhr,verb,url,async,callback){var urlPlusCCID,that=this;function afterOpenAndAuthorize(arg){if(arg instanceof Error){throw arg}else{if(that.clientContextId&&that.clientContextId!=="0"){xhr.setRequestHeader("X-CLIENT-CONTEXT-ID",that.clientContextId)}setRequestHeaderFromContextProps(that,xhr);if(typeof that.onOpenRequest==="function"){var params={xhr:xhr,verb:verb,uri:urlPlusCCID,async:async,formPreTest:false,session:that};that.onOpenRequest(params)}if(callback){callback()}}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to make server request when there is no active session.")}urlPlusCCID=this._prependAppURL(url);urlPlusCCID=this._addCCIDtoURL(urlPlusCCID);if(progress.data.Session._useTimeStamp){urlPlusCCID=progress.data.Session._addTimeStampToURL(urlPlusCCID)}if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,verb,urlPlusCCID,async,afterOpenAndAuthorize)}else{this._setXHRCredentials(xhr,verb,urlPlusCCID,this.userName,_password,async);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json")}afterOpenAndAuthorize(xhr)}};this.pingTestCallback=function(cbArgs){var foundOeping=cbArgs.pingResult?true:false;setOepingAvailable(foundOeping)};this._onReadyStateChangeGeneric=function(){var xhr=this;var result;var errorObject;clearTimeout(xhr._requestTimeout);if(xhr.readyState===4){result=null;errorObject=null;if(typeof xhr.onResponseFn==="function"){try{result=xhr.onResponseFn(xhr)}catch(e){errorObject=e}}if(typeof xhr.onResponseProcessedFn==="function"){if(!result){result=progress.data.Session.GENERAL_FAILURE}xhr.onResponseProcessedFn(xhr.pdsession,result,errorObject,xhr)}}};this._disconnect=function(deferred){this._processDisconnectResult(null,deferred)};this._processDisconnectResult=function(xhr,deferred){this._reinitializeAfterLogout(this,progress.data.Session.SUCCESS);this._disconnectComplete(this,progress.data.Session.SUCCESS,null,null,deferred)};this._disconnectComplete=function(pdsession,result,errObj,xhr,deferred){pdsession.trigger("afterDisconnect",pdsession,result,errObj,xhr,deferred)};var pwSave=null;var unameSave=null;this.login=function(serviceURI,loginUserName,loginPassword,loginTarget){var uname,pw,isAsync=false,args=[],deferred,iOSBasicAuthTimeout,uriForRequest;pwSave=null;unameSave=null;if(!defPropSupported){this.authenticationModel=this.authenticationModel.toLowerCase()}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","login()"))}if(this.loginResult===progress.data.Session.LOGIN_SUCCESS||this._authProvider){throw new Error("Attempted to call login() on a Session object that is already logged in.")}if(arguments.length>0){if(arguments[0]&&typeof arguments[0]==="object"){args[0]=arguments[0].serviceURI;args[1]=arguments[0].userName;args[2]=arguments[0].password;args[3]=arguments[0].loginTarget;args[4]=arguments[0].async;deferred=arguments[0].deferred;iOSBasicAuthTimeout=arguments[0].iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","login","The iOSBasicAuthTimeout argument was invalid."))}}else{args=arguments}}if(args.length>0){if(args[0]){var restURLtemp=args[0];if(restURLtemp[restURLtemp.length-1]==="/"){restURLtemp=restURLtemp.substring(0,restURLtemp.length-1)}setServiceURI(restURLtemp,this)}else if(!this.serviceURI){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}if(args[1]){uname=args[1]}if(args[2]){pw=args[2]}if(args[3]){setLoginTarget(args[3],this)}if(args[4]){if(typeof args[4]==="boolean"){isAsync=args[4]}else{throw new Error("Session.login() was passed an async setting that is not a boolean.")}}}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}unameSave=uname;pwSave=pw;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON||this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){uname=null;pw=null}var xhr=new XMLHttpRequest;xhr.pdsession=this;try{uriForRequest=this.serviceURI+this.loginTarget;if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(uriForRequest)}this._setXHRCredentials(xhr,"GET",uriForRequest,uname,pw,isAsync);progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(this,xhr);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr._isAsync=isAsync;if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){xhr.onResponseFn=this._afterFormPretestLogin}else{xhr.onResponseFn=this._processLoginResult;xhr.onResponseProcessedFn=this._loginComplete}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout>0){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred}if(typeof this.onOpenRequest==="function"){var isFormPreTest=false;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){isFormPreTest=true}setLastSessionXHR(xhr,this);var params={xhr:xhr,verb:"GET",uri:this.serviceURI+this.loginTarget,async:false,formPreTest:isFormPreTest,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send(null)}catch(e){clearTimeout(xhr._requestTimeout);setLoginHttpStatus(xhr.status,this);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);unameSave=null;pwSave=null;throw e}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{setLoginHttpStatus(xhr.status,this);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){return this._afterFormPretestLogin(xhr)}else{return this._processLoginResult(xhr)}}};this._afterFormPretestLogin=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);var formLoginParams={xhr:xhr,pw:pwSave,uname:unameSave,theSession:pdsession};try{return doFormLogin(formLoginParams)}catch(e){pwSave=null;unameSave=null;throw e}};function doFormLogin(args){var xhr=args.xhr;var theSession=args.theSession;var oldXHR;var contentType=null;var needAuth=false;var params={session:theSession,xhr:xhr,statusFromjson:null};contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson||params.statusFromjson>=400&¶ms.statusFromjson<500){needAuth=true}else{setLoginHttpStatus(params.statusFromjson,theSession)}}else{if(theSession.loginHttpStatus===200){if(_gotLoginForm(xhr)){needAuth=true}}}if(needAuth){oldXHR=xhr;xhr=new XMLHttpRequest;args.xhr=xhr;params.xhr=xhr;xhr.pdsession=oldXHR.pdsession;xhr._isAsync=oldXHR._isAsync;xhr._deferred=oldXHR._deferred;xhr._jsdosession=oldXHR._jsdosession;xhr.open("POST",theSession.serviceURI+"/static/auth/j_spring_security_check",xhr._isAsync);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.setRequestHeader("Cache-Control","max-age=0");setRequestHeaderFromContextProps(theSession,xhr);_addWithCredentialsAndAccept(xhr,"application/json");try{if(typeof theSession.onOpenRequest==="function"){var cbparams={xhr:xhr,verb:"POST",uri:theSession.serviceURI+"/static/auth/j_spring_security_check",async:xhr._isAsync,formPreTest:false,session:theSession};theSession.onOpenRequest(cbparams);xhr=cbparams.xhr}if(xhr._isAsync){xhr.onreadystatechange=theSession._onReadyStateChangeGeneric;xhr.onResponseFn=theSession._afterFormLogin;xhr.onResponseProcessedFn=theSession._loginComplete}xhr.send("j_username="+encodeURIComponent(args.uname)+"&j_password="+encodeURIComponent(args.pw)+"&submit=Submit")}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,theSession);setLoginHttpStatus(xhr.status,theSession);unameSave=null;pwSave=null;throw e}}if(xhr._isAsync&&!needAuth){xhr.onResponseProcessedFn=theSession._loginComplete;return theSession._afterFormLogin(xhr)}if(!xhr._isAsync){return theSession._afterFormLogin(xhr)}}this._afterFormLogin=function(xhr){var theSession=xhr.pdsession;var params={session:theSession,xhr:xhr,statusFromjson:null};var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson){throw new Error("Internal OpenEdge Mobile client error handling login response. HTTP status: "+xhr.status+".")}setLoginHttpStatus(params.statusFromjson,theSession)}else{if(xhr.status===200){if(_gotLoginFailure(xhr)||_gotLoginForm(xhr)){setLoginHttpStatus(401,theSession)}else{setLoginHttpStatus(xhr.status,theSession)}}}return theSession._processLoginResult(xhr)};this._processLoginResult=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);if(pdsession.loginHttpStatus===200){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);setUserName(unameSave,pdsession);_password=pwSave;pdsession._saveClientContextId(xhr);storeAllSessionInfo();var pingTestArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:pdsession._pingtestOnReadyStateChange};pingTestArgs.pingURI=pdsession._makePingURI();pdsession._sendPing(pingTestArgs)}else{if(pdsession.loginHttpStatus===401){setLoginResult(progress.data.Session.LOGIN_AUTHENTICATION_FAILURE,pdsession)}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);unameSave=null;pwSave=null;if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","login"))}return pdsession.loginResult};this._loginComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterLogin",pdsession,result,errObj,xhr)};this.logout=function(args){var isAsync=false,errorObject=null,xhr,deferred,params;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","logout()"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&this.authenticationModel){throw new Error("Attempted to call logout when there is no active session.")}if(typeof args==="object"){isAsync=args.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","logout","The async argument was invalid."))}deferred=args.deferred}xhr=new XMLHttpRequest;xhr.pdsession=this;try{xhr._jsdosession=jsdosession;xhr._deferred=deferred;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM||this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC||this.authenticationModel===progress.data.Session.AUTH_TYPE_BEARER){if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;xhr.onResponseFn=this._processLogoutResult;xhr.onResponseProcessedFn=this._logoutComplete}xhr.open("GET",this.serviceURI+"/static/auth/j_spring_security_logout",isAsync);try{xhr.withCredentials=true}catch(e){}xhr.setRequestHeader("Accept","application/json");setRequestHeaderFromContextProps(this,xhr);if(typeof this.onOpenRequest==="function"){setLastSessionXHR(xhr,this);params={xhr:xhr,verb:"GET",uri:this.serviceURI+"/static/auth/j_spring_security_logout",async:false,formPreTest:false,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send()}else{xhr._anonymousLogoutOK=true}}catch(e){this._reinitializeAfterLogout(this,false);throw e}if(!isAsync){try{this._processLogoutResult(xhr)}catch(e){throw e}}if(isAsync&&this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){try{this._processLogoutResult(xhr)}catch(e){errorObject=e}this._logoutComplete(this,null,errorObject,xhr)}};this.invalidate=function(){isInvalidated=true;cleanServicesManager()};this._logoutComplete=function(pdsession,result,errorObject,xhr){pdsession.trigger("afterLogout",pdsession,errorObject,xhr)};this._processLogoutResult=function(xhr){var logoutSucceeded;var pdsession=xhr.pdsession;var basicStatusOK=false;if(xhr._anonymousLogoutOK){logoutSucceeded=true}else if(xhr.status!==200){if(pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC||pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BEARER){if(xhr.status===404){logoutSucceeded=true}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=true}updateContextPropsFromResponse(pdsession,xhr);pdsession._reinitializeAfterLogout(pdsession,logoutSucceeded)};this._reinitializeAfterLogout=function(pdsession,success){setLoginResult(null,pdsession);setLoginHttpStatus(null,pdsession);setClientContextID(null,pdsession);setUserName(null,pdsession);setAuthProvider(null);_password=null;if(success){setRestApplicationIsOnline(false);setOepingAvailable(false);setPartialPingURI(defaultPartialPingURI);setLastSessionXHR(null,pdsession);clearTimeout(_timeoutID)}};this.addCatalog=function(arg1,arg2,arg3,arg4){var catalogURI,catalogUserName,catalogPassword,isAsync=false,xhr,deferred,iOSBasicAuthTimeout,catalogIndex,authProvider,that=this;function addCatalogAfterOpen(){progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(isAsync){xhr.onreadystatechange=that._onReadyStateChangeGeneric;xhr.onResponseFn=that._processAddCatalogResult;xhr.onResponseProcessedFn=that._addCatalogComplete;if(that.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex}try{if(typeof that.onOpenRequest==="function"){setLastSessionXHR(xhr,that);var params={xhr:xhr,verb:"GET",uri:catalogURI,async:false,formPreTest:false,session:that};that.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,that);xhr.send(null)}catch(e){throw new Error("Error retrieving catalog '"+catalogURI+"'.\n"+e.message)}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{return that._processAddCatalogResult(xhr)}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}customCredentials=true;if(arguments.length>0){if(typeof arg1==="object"){if(!arguments[0].offlineAddCatalog){if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to call addCatalog when there is no active session.")}}catalogURI=arg1.catalogURI;if(!catalogURI||typeof catalogURI!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogURI argument was missing or invalid."))}catalogUserName=arg1.userName;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogUserName argument was invalid."))}catalogPassword=arg1.password;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogPassword argument was invalid."))}isAsync=arg1.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The async argument was invalid."))}iOSBasicAuthTimeout=arg1.iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The iOSBasicAuthTimeout argument was invalid."))}authProvider=arg1.authProvider;deferred=arg1.deferred;catalogIndex=arg1.catalogIndex}else{catalogURI=arg1;if(typeof catalogURI!=="string"){throw new Error("First argument to Session.addCatalog must be the URL of the catalog.")}catalogUserName=arg2;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error("Second argument to Session.addCatalog must be a user name string.")}catalogPassword=arg3;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error("Third argument to Session.addCatalog must be a password string.")}}}else{throw new Error("Session.addCatalog is missing its first argument, the URL of the catalog.")}if(!authProvider){authProvider=this._authProvider;customCredentials=false}if(!catalogUserName){catalogUserName=this.userName}if(!catalogPassword){catalogPassword=_password}xhr=new XMLHttpRequest;xhr.pdsession=this;xhr._catalogURI=catalogURI;if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){if(isAsync){xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex;setTimeout(this._addCatalogComplete,10,this,progress.data.Session.CATALOG_ALREADY_LOADED,null,xhr);return progress.data.Session.ASYNC_PENDING}return progress.data.Session.CATALOG_ALREADY_LOADED}if(authProvider){authProvider._openRequestAndAuthorize(xhr,"GET",catalogURI,isAsync,addCatalogAfterOpen);return progress.data.Session.ASYNC_PENDING}else{this._setXHRCredentials(xhr,"GET",catalogURI,catalogUserName,catalogPassword,isAsync);return addCatalogAfterOpen()}};this._processAddCatalogResult=function(xhr){var _catalogHttpStatus=xhr.status;var theSession=xhr.pdsession;var servicedata;var catalogURI=xhr._catalogURI,serviceURL,theJSDOSession=jsdosession;if(!customCredentials){toggleOnlineState(xhr)}if((_catalogHttpStatus===200||_catalogHttpStatus===0)&&xhr.responseText){servicedata=theSession._parseCatalog(xhr);try{progress.data.ServicesManager.addCatalog(servicedata,theSession)}catch(e){if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){return progress.data.Session.CATALOG_ALREADY_LOADED}throw new Error("Error processing catalog '"+catalogURI+"'. \n"+e.message)}servicedata.forEach(function(service){serviceURL=theSession._prependAppURL(service.address);pushService(new progress.data.MobileServiceObject({name:service.name,uri:serviceURL}),theSession);if(service.settings&&service.settings.useXClientProps&&!theSession.xClientProps){console.warn("Catalog warning: Service settings property 'useXClientProps' "+"is true but 'xClientProps' property has not been set.")}});pushCatalogURIs(catalogURI,theSession);progress.data.ServicesManager.addSession(catalogURI,theSession);if(theJSDOSession){progress.data.ServicesManager.addJSDOSession(catalogURI,theJSDOSession)}}else if(_catalogHttpStatus===401){return progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","addCatalog"))}else{throw new Error("Error retrieving catalog '"+catalogURI+"'. Http status: "+_catalogHttpStatus+".")}return progress.data.Session.SUCCESS};this._addCatalogComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterAddCatalog",pdsession,result,errObj,xhr)};this.ping=function(args){var pingResult=false,pingArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:this._onReadyStateChangePing,offlineReason:null};if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(!this._authProvider&&this.loginResult!==progress.data.Session.LOGIN_SUCCESS){throw new Error("Attempted to call ping when not logged in.")}if(args){if(args.async!==undefined){pingArgs.async=args.async}if(args.doNotFireEvent!==undefined){pingArgs.fireEventIfOfflineChange=!args.doNotFireEvent}if(args.onCompleteFn&&typeof args.onCompleteFn==="function"){pingArgs.onCompleteFn=args.onCompleteFn}pingArgs.deferred=args.deferred;pingArgs.jsdosession=args.jsdosession}pingArgs.pingURI=that._makePingURI();that._sendPing(pingArgs);if(!pingArgs.async){if(pingArgs.xhr){pingResult=that._processPingResult(pingArgs);if(args.offlineReason!==undefined){args.offlineReason=pingArgs.offlineReason}}else{pingResult=false}if(args.xhr!==undefined){args.xhr=pingArgs.xhr}}return pingResult};this._isOnlineStateChange=function(isOnline){var stateChanged=false;if(isOnline&&!this.connected){stateChanged=true}else if(!isOnline&&this.connected){stateChanged=true}return stateChanged};this._checkServiceResponse=function(xhr,success,request){var offlineReason=null,wasOnline=this.connected;updateContextPropsFromResponse(this,xhr);if(!this._events){return}var offlineObservers=this._events.offline||[];var onlineObservers=this._events.online||[];if(offlineObservers.length===0&&onlineObservers.length===0){return}if(success){setRestApplicationIsOnline(true);setDeviceIsOnline(true)}else{if(deviceIsOnline){var localPingArgs={doNotFireEvent:true,offlineReason:null,async:false};if(!that.ping(localPingArgs)){offlineReason=localPingArgs.offlineReason;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}}if(wasOnline&&!this.connected){this.trigger("offline",this,offlineReason,request)}else if(!wasOnline&&this.connected){this.trigger("online",this,request)}};this._processPingResult=function(args){var xhr=args.xhr,pingResponseJSON,appServerStatus=null,wasOnline=this.connected,connectedBeforeCallback,assumeOepingFormat;if(args.hasOwnProperty("usingOepingFormat")){assumeOepingFormat=args.usingOepingFormat}else{assumeOepingFormat=oepingAvailable}if(xhr.status>=200&&xhr.status<300){updateContextPropsFromResponse(this,xhr);if(assumeOepingFormat){try{pingResponseJSON=JSON.parse(xhr.responseText);appServerStatus=pingResponseJSON.AppServerStatus}catch(e){console.error("Unable to parse ping response.")}}toggleOnlineState(xhr)}else{if(deviceIsOnline){if(xhr.status===0){args.offlineReason=progress.data.Session.SERVER_OFFLINE;setRestApplicationIsOnline(false)}else if(xhr.status===404||xhr.status===410){args.offlineReason=progress.data.Session.WEB_APPLICATION_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}else{args.offlineReason=progress.data.Session.DEVICE_OFFLINE}}if(appServerStatus){if(appServerStatus.PingStatus==="false"){args.offlineReason=progress.data.Session.APPSERVER_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}connectedBeforeCallback=this.connected;if(typeof xhr.onCompleteFn==="function"){xhr.onCompleteFn({pingResult:this.connected,xhr:xhr,offlineReason:args.offlineReason})}if(args.fireEventIfOfflineChange){if(wasOnline&&!connectedBeforeCallback){that.trigger("offline",that,args.offlineReason,null)}else if(!wasOnline&&connectedBeforeCallback){that.trigger("online",that,null)}}return this.connected};this._onReadyStateChangePing=function(){var xhr=this;var args;try{if(xhr.readyState===4){args={xhr:xhr,fireEventIfOfflineChange:true,offlineReason:null};that._processPingResult(args);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}}catch(e){}};this._pingtestOnReadyStateChange=function(){var xhr=this;try{if(xhr.readyState===4){var foundOeping=false;if(xhr.status>=200&&xhr.status<300){foundOeping=true}else{setPartialPingURI(that.loginTarget);console.warn("Default ping target not available, will use loginTarget instead.")}setOepingAvailable(foundOeping);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}}catch(e){}};var resolvePingURI=()=>{var xhr=new XMLHttpRequest,deferred=new progress.util.Deferred;xhr.onreadystatechange=(()=>{if(xhr.readyState===4){if(xhr.status===404){setPartialPingURI(classicPartialPingURI);deferred.reject(false)}else{deferred.resolve(true)}hasResolvedPingURI=true}});if(hasResolvedPingURI||this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this.authProvider){deferred.resolve(true)}else{this._openRequest(xhr,"GET",partialPingURI,true,()=>xhr.send())}return deferred.promise()};this._sendPing=function(args){var xhr=new XMLHttpRequest,that=this;args.xhr=xhr;function sendPingAfterOpen(){if(args.async){xhr.onreadystatechange=args.onReadyStateFn;xhr.onCompleteFn=args.onCompleteFn;xhr._jsdosession=jsdosession;xhr._deferred=args.deferred}progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(that.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr.send(null)}resolvePingURI().then(()=>{},()=>{args.pingURI=this._makePingURI()}).then(()=>{try{if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,"GET",args.pingURI,args.async,sendPingAfterOpen)}else{this._setXHRCredentials(xhr,"GET",args.pingURI,this.userName,_password,args.async);if(xhr.readyState===1){sendPingAfterOpen()}}}catch(e){args.error=e}})};this._makePingURI=function(){var pingURI=this.serviceURI+partialPingURI;if(progress.data.Session._useTimeStamp){pingURI=progress.data.Session._addTimeStampToURL(pingURI)}return pingURI};this._autoping=function(){that.ping({async:true})};this._setXHRCredentials=function(xhr,verb,uri,userName,password,async){if(userName&&this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(canPassCredentialsToOpen()){xhr.open(verb,uri,async,userName,password)}else{xhr.open(verb,uri,async)}var auth=_make_basic_auth(userName,password);xhr.setRequestHeader("Authorization",auth)}else{xhr.open(verb,uri,async)}};this._addCCIDtoURL=function(url){var urlPart1,urlPart2,jsessionidStr,index;if(this.clientContextId&&this.clientContextId!=="0"){if(url.substring(0,this.serviceURI.length)===this.serviceURI){jsessionidStr=";"+"JSESSIONID="+this.clientContextId;index=url.indexOf("?");if(index===-1){url+=jsessionidStr}else{urlPart1=url.substring(0,index);urlPart2=url.substring(index);url=urlPart1+jsessionidStr+urlPart2}}}return url};this._saveClientContextId=function(xhr){setClientContextIDfromXHR(xhr,this)};this._parseCatalog=function(xhr){var jsonObject;var catalogdata;try{jsonObject=JSON.parse(xhr.responseText);catalogdata=jsonObject.services}catch(e){console.error("Unable to parse response. Make sure catalog has correct format.");catalogdata=null}return catalogdata};this._prependAppURL=function(oldURL){if(!oldURL){return this.serviceURI}var newURL=oldURL;var pat=/^https?:\/\//i;if(!pat.test(newURL)){if(newURL.indexOf("/")!==0){newURL="/"+newURL}newURL=this.serviceURI+newURL}return newURL};function _addWithCredentialsAndAccept(xhr,acceptString){try{xhr.withCredentials=true;xhr.setRequestHeader("Accept",acceptString)}catch(e){}}function _make_basic_auth(user,pw){var tok=user+":"+pw;var hash=btoa(tok);return"Basic "+hash}var loginFormIDString="j_spring_security_check";function _gotLoginForm(xhr){return _findStringInResponseHTML(xhr,loginFormIDString)}var loginFailureIdentificationString="login failed";function _gotLoginFailure(xhr){return _findStringInResponseHTML(xhr,loginFailureIdentificationString)}function _findStringInResponseHTML(xhr,searchString){if(!xhr.responseText){return false}var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("text/html")>=0&&xhr.responseText.indexOf(searchString)>=0){return true}return false}function handleJSONLoginResponse(params){var jsonObject;params.statusFromjson=null;try{jsonObject=JSON.parse(params.xhr.responseText);if(jsonObject.status_code!==undefined&&jsonObject.status_txt!==undefined){params.statusFromjson=jsonObject.status_code}}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,params.session);setLoginHttpStatus(params.xhr.status,params.session);throw new Error("Unable to parse login response from server.")}}function setRequestHeaderFromContextProps(session,xhr){if(session.xClientProps){xhr.setRequestHeader("X-CLIENT-PROPS",session.xClientProps)}else if(session._contextProperties.contextHeader!==undefined){xhr.setRequestHeader("X-CLIENT-PROPS",session._contextProperties.contextHeader)}}function toggleOnlineState(xhr){var pdsession=that;setLoginHttpStatus(xhr.status,pdsession);if(pdsession.loginHttpStatus>=200&&pdsession.loginHttpStatus<400){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);pdsession._saveClientContextId(xhr);storeAllSessionInfo()}else{if(pdsession.loginHttpStatus===0||pdsession.loginHttpStatus===400||pdsession.loginHttpStatus===410){setRestApplicationIsOnline(false);setLoginResult(progress.data.AuthenticationProvider._getAuthFailureReason(xhr),pdsession)}else{setRestApplicationIsOnline(true);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);return pdsession.loginResult}function updateContextPropsFromResponse(session,xhr){var contextString,context;if(xhr){contextString=getResponseHeaderNoError(xhr,"X-CLIENT-PROPS");if(contextString){try{context=JSON.parse(contextString)}catch(e){}if(typeof context==="object"){session._contextProperties.setContext(context)}else{throw new Error(progress.data._getMsgText("jsdoMSG123","Session","X-CLIENT-PROPS"))}}else if(contextString===""){session._contextProperties.setContext({})}}}function cleanServicesManager(){progress.data.ServicesManager.cleanSession(that)}if(typeof options==="object"){jsdosession=options.jsdosession;newURI=options.serviceURI;setAuthProvider(options.authProvider);if(options.authProvider&&options.authProvider.hasClientCredentials()){_loginResult=progress.data.Session.LOGIN_SUCCESS}if(newURI&&newURI[newURI.length-1]==="/"){newURI=newURI.substring(0,newURI.length-1)}_storageKey=options._storageKey;if(_storageKey){if(retrieveSessionInfo(_storageKey)){storedAuthModel=retrieveSessionInfo("authenticationModel");storedURI=retrieveSessionInfo("serviceURI");if(storedAuthModel!==options.authenticationModel||storedURI!==newURI){clearAllSessionInfo()}else{setSessionInfoFromStorage(_storageKey);stateWasReadFromStorage=true}}if(options.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){_storageKey=undefined}}if(!stateWasReadFromStorage){if(newURI){setServiceURI(newURI,this)}if(options.authenticationModel){this.authenticationModel=options.authenticationModel}}}};progress.data.Session._useTimeStamp=true;var SEQ_MAX_VALUE=999999999999999;var _tsseq=SEQ_MAX_VALUE;var _tsprefix1=0;var _tsprefix2=0;progress.data.Session._getNextTimeStamp=function(){var seq;_tsseq+=1;seq=_tsseq;if(seq>=SEQ_MAX_VALUE){_tsseq=1;seq=1;var t=Math.floor((Date.now?Date.now():(new Date).getTime())/1e4);if(_tsprefix1===t){_tsprefix2+=1;if(_tsprefix2>=SEQ_MAX_VALUE){_tsprefix2=1}}else{_tsprefix1=t;Math.random();_tsprefix2=Math.round(Math.random()*1e10)}}return _tsprefix1+"-"+_tsprefix2+"-"+seq};progress.data.Session._addTimeStampToURL=function(url){var timeStamp="_ts="+progress.data.Session._getNextTimeStamp();url+=(url.indexOf("?")===-1?"?":"&")+timeStamp;return url};progress.data.Session._setNoCacheHeaders=function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache")};if(typeof Object.defineProperty==="function"){Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_REQUIRED",{value:0,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"CATALOG_ALREADY_LOADED",{value:4,enumerable:true});Object.defineProperty(progress.data.Session,"ASYNC_PENDING",{value:5,enumerable:true});Object.defineProperty(progress.data.Session,"EXPIRED_TOKEN",{value:6,enumerable:true});Object.defineProperty(progress.data.Session,"SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_ANON",{value:"anonymous",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BASIC",{value:"basic",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM",{value:"form",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_SSO",{value:"sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM_SSO",{value:"form_sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BEARER",{value:"bearer",enumerable:true});Object.defineProperty(progress.data.Session,"DEVICE_OFFLINE",{value:"Device is offline",enumerable:true});Object.defineProperty(progress.data.Session,"SERVER_OFFLINE",{value:"Cannot contact server",enumerable:true});Object.defineProperty(progress.data.Session,"WEB_APPLICATION_OFFLINE",{value:"Mobile Web Application is not available",enumerable:true});Object.defineProperty(progress.data.Session,"SERVICE_OFFLINE",{value:"REST web Service is not available",enumerable:true});Object.defineProperty(progress.data.Session,"APPSERVER_OFFLINE",{value:"AppServer is not available",enumerable:true})}else{progress.data.Session.LOGIN_SUCCESS=1;progress.data.Session.LOGIN_AUTHENTICATION_FAILURE=2;progress.data.Session.LOGIN_GENERAL_FAILURE=3;progress.data.Session.CATALOG_ALREADY_LOADED=4;progress.data.Session.SUCCESS=1;progress.data.Session.AUTHENTICATION_FAILURE=2;progress.data.Session.GENERAL_FAILURE=3;progress.data.Session.AUTH_TYPE_ANON="anonymous";progress.data.Session.AUTH_TYPE_BASIC="basic";progress.data.Session.AUTH_TYPE_FORM="form";progress.data.Session.AUTH_TYPE_SSO="sso";progress.data.Session.AUTH_TYPE_BEARER="bearer"}progress.data.Session.prototype=new progress.util.Observable;progress.data.Session.prototype.constructor=progress.data.Session;function validateSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}else{listenerData.scope=args[2]}}}progress.data.Session.prototype._eventNames=["offline","online","afterLogin","afterAddCatalog","afterLogout","afterDisconnect"];progress.data.Session.prototype.validateSubscribe=validateSessionSubscribe;progress.data.Session.prototype.toString=function(radix){return"progress.data.Session"};progress.data.JSDOSession=function JSDOSession(options){var _pdsession,_serviceURI,that=this,_name;Object.defineProperty(this,"authenticationModel",{get:function(){return _pdsession?_pdsession.authenticationModel:undefined},enumerable:true});Object.defineProperty(this,"authProvider",{get:function(){return _pdsession?_pdsession._authProvider:null},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _pdsession?_pdsession.catalogURIs:undefined},enumerable:true});Object.defineProperty(this,"clientContextId",{get:function(){return _pdsession?_pdsession.clientContextId:undefined},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return _pdsession?_pdsession.connected:undefined},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _pdsession?_pdsession.JSDOs:undefined},enumerable:true});Object.defineProperty(this,"loginResult",{get:function(){return _pdsession?_pdsession.loginResult:undefined},enumerable:true});Object.defineProperty(this,"loginHttpStatus",{get:function(){return _pdsession?_pdsession.loginHttpStatus:undefined},enumerable:true});Object.defineProperty(this,"onOpenRequest",{get:function(){return _pdsession?_pdsession.onOpenRequest:undefined},set:function(newval){if(_pdsession){_pdsession.onOpenRequest=newval}},enumerable:true});Object.defineProperty(this,"pingInterval",{get:function(){return _pdsession?_pdsession.pingInterval:undefined},set:function(newval){if(_pdsession){_pdsession.pingInterval=newval}},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _pdsession?_pdsession.services:undefined},enumerable:true});Object.defineProperty(this,"serviceURI",{get:function(){if(_pdsession&&_pdsession.serviceURI){return _pdsession.serviceURI}else{return _serviceURI}},enumerable:true});Object.defineProperty(this,"userName",{get:function(){return _pdsession?_pdsession.userName:undefined},enumerable:true});Object.defineProperty(this,"name",{get:function(){return _name},enumerable:true});Object.defineProperty(this,"_isInvalidated",{get:function(){return _pdsession._isInvalidated},enumerable:false});function settlePromise(promise,fulfill,result,info){if(fulfill){promise.resolve(that,result,info)}else{promise.reject(that,result,info)}}function genericSessionEventHandler(pdsession,result,errorObject,xhr,deferred){var myDeferred;if(xhr){myDeferred=xhr._deferred}else{myDeferred=deferred}settlePromise(myDeferred,result===progress.data.Session.SUCCESS?true:false,result,{errorObject:errorObject,xhr:xhr})}function onAfterAddCatalog(pdsession,result,errorObject,xhr){var deferred,fulfill=false,settleResult,info;if(result===progress.data.Session.EXPIRED_TOKEN){settleResult=progress.data.Session.EXPIRED_TOKEN}else if(result===progress.data.Session.LOGIN_AUTHENTICATION_FAILURE){settleResult=progress.data.Session.LOGIN_AUTHENTICATION_FAILURE}else{settleResult=progress.data.Session.GENERAL_FAILURE}if(xhr&&xhr._deferred){deferred=xhr._deferred;if(result!==progress.data.Session.SUCCESS&&result!==progress.data.Session.CATALOG_ALREADY_LOADED){result=result||progress.data.Session.GENERAL_FAILURE;deferred._overallCatalogResult=progress.data.Session.GENERAL_FAILURE}deferred._results[xhr._catalogIndex]={catalogURI:xhr._catalogURI,result:result,errorObject:errorObject,xhr:xhr};deferred._numCatalogsProcessed+=1;if(deferred._numCatalogsProcessed===deferred._numCatalogs){deferred._processedPromise=true;if(!deferred._overallCatalogResult){fulfill=true;settleResult=progress.data.Session.SUCCESS}if(settleResult===progress.data.Session.SUCCESS){if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,details:xhr._deferred._results}}}else{if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,errorObject:new Error(progress.data._getMsgText("jsdoMSG512")),details:xhr._deferred._results}}}settlePromise(xhr._deferred,fulfill,settleResult,info)}}}function onAfterLogout(pdsession,errorObject,xhr){var result=progress.data.Session.GENERAL_FAILURE,fulfill=false;if(xhr&&xhr._deferred){if(!errorObject&&!pdsession.loginResult){result=progress.data.Session.SUCCESS;fulfill=true}settlePromise(xhr._deferred,fulfill,result,{errorObject:errorObject,xhr:xhr})}}function onPingComplete(args){var xhr=args.xhr;if(xhr&&xhr._deferred){settlePromise(xhr._deferred,args.pingResult,args.pingResult,{offlineReason:args.offlineReason,xhr:xhr})}}this.login=function(username,password,options){var deferred=new progress.util.Deferred,iOSBasicAuthTimeout;function callIsAuthorized(){that.isAuthorized().then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(that,object.result,object.info)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","JSDOSession","login()"))}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout}if(!_pdsession._authProvider){_pdsession._authProvider=new progress.data.AuthenticationProvider({uri:this.serviceURI,authenticationModel:this.authenticationModel});_pdsession._authProvider.logout().then(function(){return _pdsession._authProvider.login(username,password)}).then(function(){callIsAuthorized()},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}else{throw new Error(progress.data._getMsgText("jsdoMSG062","JSDOSession","login()"))}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.disconnect=function(){var deferred=new progress.util.Deferred,errorObject;try{_pdsession.subscribe("afterDisconnect",genericSessionEventHandler,this);_pdsession._disconnect(deferred)}catch(e){errorObject=new Error(progress.data._getMsgText("jsdoMSG049","JSDOSession","disconnect",e.message))}if(errorObject){if(progress.util.Deferred.useJQueryPromises){throw errorObject}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:errorObject})}}else{return deferred.promise()}};this.addCatalog=function(catalogURI,unameOrOpts,password,opts){var deferred=new progress.util.Deferred,catalogURIs,numCatalogs,catalogIndex,addResult,errorObject,iOSBasicAuthTimeout,username,options,authProvider;try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(typeof catalogURI==="string"){catalogURIs=[catalogURI]}else if(catalogURI instanceof Array){catalogURIs=catalogURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","addCatalog","The first argument must be a string or an array of strings specifying the URI of the catalog."))}if(unameOrOpts){if(typeof unameOrOpts==="string"){if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG058","Session"))}username=unameOrOpts;if(opts){options=opts;options.authProvider=undefined}}else if(typeof unameOrOpts==="object"){options=unameOrOpts}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDOSession","2","object","addCatalog"))}}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout;if(options.authProvider){authProvider=options.authProvider}else if(this.authProvider){authProvider=this.authProvider}}if(!authProvider&&!this.authProvider&&!username){throw new Error(progress.data._getMsgText("jsdoMSG511"))}_pdsession.subscribe("afterAddCatalog",onAfterAddCatalog,this);numCatalogs=catalogURIs.length;deferred._numCatalogs=numCatalogs;deferred._numCatalogsProcessed=0;deferred._results=[];deferred._results.length=numCatalogs;for(catalogIndex=0;catalogIndex=200&&xhr.status<300){deferred.resolve(that,progress.data.Session.SUCCESS,info)}else{if(xhr.status===401){cbresult=progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else{cbresult=progress.data.Session.GENERAL_FAILURE}deferred.reject(that,cbresult,info)}}}catch(e){}};try{xhr.send()}catch(e){throw new Error("JSDOSession: Unable to validate authorization. "+e.message)}})}else{result=progress.data.Session.LOGIN_AUTHENTICATION_REQUIRED;deferred.reject(that,result,{xhr:xhr})}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(that,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.setContext=function(context){_pdsession._contextProperties.setContext(context)};this.setContextProperty=function(propertyName,propertyValue){_pdsession._contextProperties.setContextProperty(propertyName,propertyValue)};this.getContext=function(){return _pdsession._contextProperties.getContext()};this.getContextProperty=function(propertyName){return _pdsession._contextProperties.getContextProperty(propertyName)};this._onlineHandler=function(session,request){that.trigger("online",that,request)};this._offlineHandler=function(session,offlineReason,request){that.trigger("offline",that,offlineReason,request)};if(arguments.length>0&&typeof arguments[0]==="object"){if(options.serviceURI&&typeof options.serviceURI==="string"){_serviceURI=options.serviceURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options parameter must include a 'serviceURI' property that is a string."))}if(options.authenticationModel){if(typeof options.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The authenticationModel property of the options parameter must be a string."))}options.authenticationModel=options.authenticationModel.toLowerCase()}else{options.authenticationModel=progress.data.Session.AUTH_TYPE_ANON}if(options.authProvider){if(typeof options.authProvider!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG502","JSDOSession","options","constructor","authProvider"))}if(options.authProvider.authenticationModel!==progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authProvider.authenticationModel!==options.authenticationModel||options.authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authenticationModel!==progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG059","JSDOSession",options.authProvider.authenticationModel,options.authenticationModel))}if(typeof options.authProvider.hasClientCredentials==="function"){if(!options.authProvider.hasClientCredentials()){throw new Error(progress.data._getMsgText("jsdoMSG125","JSDOSession"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG505","JSDOSession","AuthenticationProvider","hasClientCredentials"))}}else if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG508"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options argument was missing or invalid."))}_name=options.name;_pdsession=new progress.data.Session({_storageKey:_name,_silent:true,authenticationModel:options.authenticationModel,serviceURI:options.serviceURI,jsdosession:this,authProvider:options.authProvider});try{if(options.context){this.setContext(options.context)}_pdsession.subscribe("online",this._onlineHandler,this);_pdsession.subscribe("offline",this._offlineHandler,this)}catch(err){_pdsession=undefined;throw err}};progress.data.JSDOSession.prototype=new progress.util.Observable;progress.data.JSDOSession.prototype.constructor=progress.data.JSDOSession;function validateJSDOSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}listenerData.scope=args[2]}}progress.data.JSDOSession.prototype._eventNames=["offline","online"];progress.data.JSDOSession.prototype.validateSubscribe=validateJSDOSessionSubscribe;progress.data.JSDOSession.prototype.toString=function(radix){return"progress.data.JSDOSession"};progress.data.getSession=function(options){var deferred=new progress.util.Deferred,authProvider,authProviderInitObject={},session;function sessionRejectHandler(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);if(authProvider&&authProvider.hasClientCredentials()){var callback=function(){deferred.reject(object.result,object.info)};authProvider.logout().then(callback,callback)}else{deferred.reject(object.result,object.info)}}function callbackRejectHandler(reason){deferred.reject(progress.data.Session.GENERAL_FAILURE,{reason:reason})}function loginHandler(object){let jsdosession;try{if(typeof session==="undefined"){jsdosession=new progress.data.JSDOSession(options)}else{jsdosession=session}jsdosession.isAuthorized().then(function(){return jsdosession.addCatalog(options.catalogURI)},sessionRejectHandler).then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(object.jsdosession,progress.data.Session.SUCCESS)},sessionRejectHandler)}catch(ex){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:ex})}}function callLogin(provider){var errorObject;if(typeof options.loginCallback!=="undefined"){options.loginCallback().then(function(result){try{provider.login(result.username,result.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}},callbackRejectHandler)}else if(options.username&&options.password){try{provider.login(options.username,options.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG052","getSession()"));sessionRejectHandler(provider,progress.data.Session.AUTHENTICATION_FAILURE,{errorObject:errorObject})}}if(typeof options!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options","object"))}if(typeof options.loginCallback!=="undefined"&&typeof options.loginCallback!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options.loginCallback","function"))}try{if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){if(!options.authenticationURI||!options.authProviderAuthenticationModel){throw new Error(progress.data._getMsgText("jsdoMSG509"))}}if(options.authenticationURI){authProviderInitObject.uri=options.authenticationURI;authProviderInitObject.authenticationModel=options.authProviderAuthenticationModel;if(typeof authProviderInitObject.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG502","progress.data.getSession","object","getSession","authProviderAuthenticationModel"))}}else{authProviderInitObject.uri=options.serviceURI;authProviderInitObject.authenticationModel=options.authenticationModel}authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;if(authProvider.hasClientCredentials()){let jsdosession=new progress.data.JSDOSession(options),statusCode=0;jsdosession.isAuthorized().then(()=>{session=jsdosession;return},obj=>{statusCode=obj&&obj.info&&obj.info.xhr&&obj.info.xhr.status;return progress.util.Deferred.when([jsdosession.invalidate(),options.authProvider.logout()])}).then(()=>{if(statusCode===401){authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;callLogin(authProvider)}else{loginHandler(authProvider)}})}else{if(authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){authProvider.login().then(loginHandler,sessionRejectHandler)}else{callLogin(authProvider)}}}catch(error){sessionRejectHandler(null,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}return deferred.promise()};progress.data.invalidateAllSessions=function(){var jsdosession,key,deferred=new progress.util.Deferred,jsdosessions=progress.data.ServicesManager._jsdosessions,invalidatePromises=[];try{for(key in jsdosessions){if(jsdosessions.hasOwnProperty(key)){jsdosession=jsdosessions[key];invalidatePromises.push(jsdosession.invalidate())}}progress.util.Deferred.when(invalidatePromises).then(function(){deferred.resolve(progress.data.Session.SUCCESS)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(progress.data.Session.GENERAL_FAILURE,info)})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()}})();if(typeof exports!=="undefined"){exports.progress=progress}(function(){"use strict";if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data.AuthenticationProvider=function AuthenticationProvider(initObject){var authProv,authModel,uri;if(typeof initObject==="object"){this._checkStringArg("constructor",initObject.authenticationModel,"initObject.authenticationModel","initObject.authenticationModel");this._checkStringArg("constructor",initObject.uri,"init-object.uri","init-object.uri")}else{throw new Error(progress.data._getMsgText("jsdoMSG033","AuthenticationProvider","the constructor","The init-object argument was missing or invalid."))}authModel=initObject.authenticationModel.toLowerCase();switch(authModel){case progress.data.Session.AUTH_TYPE_ANON:this._initialize(initObject.uri,progress.data.Session.AUTH_TYPE_ANON,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});authProv=this;break;case progress.data.Session.AUTH_TYPE_BASIC:authProv=new progress.data.AuthenticationProviderBasic(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM:authProv=new progress.data.AuthenticationProviderForm(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM_SSO:authProv=new progress.data.AuthenticationProviderSSO(initObject.uri);break;case progress.data.Session.AUTH_TYPE_BEARER:authProv=new progress.data.AuthenticationProviderBearer(initObject.uri);break;default:throw new Error(progress.data._getMsgText("jsdoMSG502","AuthenticationProvider","init-object","constructor","authenticationModel"))}return authProv};progress.data.AuthenticationProvider.prototype._loginProto=function(sendParam){var deferred=new progress.util.Deferred,xhr,uriForRequest,header,that=this;try{if(this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG051","AuthenticationProvider"))}xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){if(xhr.readyState===4){try{that._processLoginResult(xhr,deferred)}catch(e){}}};if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(this._loginURI)}else{uriForRequest=this._loginURI}this._openLoginRequest(xhr,uriForRequest);xhr.setRequestHeader("Accept","application/json");xhr.send(sendParam)}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.login=function(){return this._loginProto()};progress.data.AuthenticationProvider.prototype._openLoginRequest=function(xhr,uri){xhr.open("GET",uri,true);progress.data.Session._setNoCacheHeaders(xhr)};progress.data.AuthenticationProvider.prototype._processLoginResult=function(xhr,deferred){var result;if(xhr.status===200){this._loggedIn=true;this._storeInfo();result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};progress.data.AuthenticationProvider.prototype.logout=function(){var deferred=new progress.util.Deferred;try{this._reset();deferred.resolve(this,progress.data.Session.SUCCESS,{})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.hasClientCredentials=function(){return this._loggedIn};progress.data.AuthenticationProvider.prototype.hasRefreshToken=function(){return false};progress.data.AuthenticationProvider.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);xhr.setRequestHeader("Accept","application/json");callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};progress.data.AuthenticationProvider.prototype._initialize=function(uriParam,authModel,targetURIs){var tempURI,target;Object.defineProperty(this,"uri",{get:function(){return this._uri},enumerable:true});Object.defineProperty(this,"authenticationModel",{get:function(){return this._authenticationModel},enumerable:true});if(uriParam[uriParam.length-1]==="/"){tempURI=uriParam.substring(0,uriParam.length-1)}else{tempURI=uriParam}for(target in targetURIs){if(targetURIs.hasOwnProperty(target)){this[target]=tempURI+targetURIs[target]}}this._authenticationModel=authModel;this._uri=uriParam;this._loggedIn=false;this._dataKeys={uri:".uri",loggedIn:".loggedIn"};if(typeof sessionStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","AuthenticationProvider","sessionStorage"))}this._storage=sessionStorage;this._storageKey=this._uri;this._dataKeys.uri=this._storageKey+this._dataKeys.uri;this._dataKeys.loggedIn=this._storageKey+this._dataKeys.loggedIn;if(this._retrieveLoggedIn()){this._loggedIn=true}};progress.data.AuthenticationProvider.prototype._storeInfo=function(){this._storage.setItem(this._dataKeys.uri,JSON.stringify(this._uri));this._storage.setItem(this._dataKeys.loggedIn,JSON.stringify(this._loggedIn))};progress.data.AuthenticationProvider.prototype._retrieveInfoItem=function(propName){var jsonStr=this._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value};progress.data.AuthenticationProvider.prototype._retrieveURI=function(){return this._retrieveInfoItem(this._dataKeys.uri)};progress.data.AuthenticationProvider.prototype._retrieveLoggedIn=function(){return this._retrieveInfoItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._clearInfo=function(info){this._storage.removeItem(this._dataKeys.uri);this._storage.removeItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._reset=function(){this._clearInfo();this._loggedIn=false};progress.data.AuthenticationProvider.prototype._settlePromise=function(deferred,result,info){if(result===progress.data.Session.SUCCESS){deferred.resolve(this,result,info)}else{deferred.reject(this,result,info)}};progress.data.AuthenticationProvider.prototype._checkStringArg=function(fnName,argToCheck,argPosition,argName){if(typeof argToCheck!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","AuthenticationProvider",argPosition,"string",fnName))}else if(argToCheck.length===0){throw new Error(progress.data._getMsgText("jsdoMSG501","AuthenticationProvider",argName,fnName))}};progress.data.AuthenticationProvider._getAuthFailureReason=function(xhr){var contentType,jsonObject,result=progress.data.Session.AUTHENTICATION_FAILURE;if(xhr.status===401){contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>-1&&xhr.responseText){jsonObject=JSON.parse(xhr.responseText);if(jsonObject.error==="sso.token.expired_token"){result=progress.data.Session.EXPIRED_TOKEN}}}else{result=null}return result};Object.defineProperty(progress.data.AuthenticationProvider,"_homeLoginURIBase",{value:"/static/home.html",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLoginURIBase",{value:"/static/auth/j_spring_security_check",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLogoutURIBase",{value:"/static/auth/j_spring_security_logout",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenLoginURIBase",{value:progress.data.AuthenticationProvider._springLoginURIBase+"?OECP=yes",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenRefreshURIBase",{value:"/static/auth/token?op=refresh",enumerable:true})})();(function(){"use strict";progress.data.AuthenticationProviderBasic=function(uri){var defaultiOSBasicAuthTimeout,userName=null,password=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BASIC,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});this._reset();function make_basic_auth_header(user,pw){var tok=user+":"+pw,hash=btoa(tok);return"Basic "+hash}this._reset=function(){userName=null;password=null;progress.data.AuthenticationProviderBasic.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _basic_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBasic.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){userName=null;password=null}};this.login=function(userNameParam,passwordParam){this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");userName=userNameParam;password=passwordParam;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr);callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}}};function BasicProxy(){}BasicProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBasic.prototype=new BasicProxy;progress.data.AuthenticationProviderBasic.prototype.constructor=progress.data.AuthenticationProviderBasic})();(function(){"use strict";progress.data.AuthenticationProviderBearer=function(uri){var bearerToken=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BEARER,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});function make_Bearer_auth_header(token){return"Bearer "+token}this._reset=function(){bearerToken=null;progress.data.AuthenticationProviderBearer.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(bearerToken){auth=make_Bearer_auth_header(bearerToken);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _Bearer_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBearer.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){bearerToken=null}};this.login=function(token){this._checkStringArg("login",token,1,"token");bearerToken=token;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(bearerToken){auth=make_Bearer_auth_header(bearerToken);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"))}callback(errorObject)}};function BearerProxy(){}BearerProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBearer.prototype=new BearerProxy;progress.data.AuthenticationProviderBearer.prototype.constructor=progress.data.AuthenticationProviderBearer})();(function(){"use strict";var fn;progress.data.AuthenticationProviderForm=function(uri){this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM,{_loginURI:progress.data.AuthenticationProvider._springLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase})};function FormProxy(){}FormProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderForm.prototype=new FormProxy;progress.data.AuthenticationProviderForm.prototype.constructor=progress.data.AuthenticationProviderForm;progress.data.AuthenticationProviderForm.prototype.login=function(userNameParam,passwordParam){var deferred=new progress.util.Deferred,xhr,that=this;this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");return this._loginProto("j_username="+encodeURIComponent(userNameParam)+"&j_password="+encodeURIComponent(passwordParam)+"&submit=Submit")};progress.data.AuthenticationProviderForm.prototype._openLoginRequest=function(xhr,uri){xhr.open("POST",uri,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.setRequestHeader("Pragma","no-cache");xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.withCredentials=true};progress.data.AuthenticationProviderForm.prototype.logout=function(){var deferred=new progress.util.Deferred,xhr,that=this;try{if(!this._loggedIn){deferred.resolve(this,progress.data.Session.SUCCESS,{})}else{xhr=new XMLHttpRequest;this._openLogoutRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){try{that._processLogoutResult(xhr,deferred)}catch(e){}}};xhr.send()}this._reset()}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProviderForm.prototype._openLogoutRequest=function(xhr){xhr.open("GET",this._logoutURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Accept","application/json")};progress.data.AuthenticationProviderForm.prototype._processLogoutResult=function(xhr,deferred){var result;if(xhr.status===200){result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};fn=progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize;progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){function afterSuper(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.withCredentials=true;callback(xhr)}}try{progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super.apply(this,[xhr,verb,uri,async,afterSuper])}catch(e){callback(e)}};progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super=fn})();(function(){"use strict";var fn;progress.data.AuthenticationProviderSSO=function(uri){var that=this,_automaticTokenRefresh,temp,ssoTokenInfo=null,tokenDataKeys={token:".access_token",refreshToken:".refresh_token",tokenType:".token_type",expiration:".expires_in",accessTokenExpiration:".accessTokenExpiration"};function storeTokenInfo(info){var date,accessTokenExpiration;if(info.access_token.length){that._storage.setItem(tokenDataKeys.token,JSON.stringify(info.access_token))}if(info.refresh_token.length){that._storage.setItem(tokenDataKeys.refreshToken,JSON.stringify(info.refresh_token));date=new Date;accessTokenExpiration=date.getTime()+info.expires_in*1e3*.75;that._storage.setItem(tokenDataKeys.accessTokenExpiration,JSON.stringify(accessTokenExpiration))}else{that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}that._storage.setItem(tokenDataKeys.tokenType,JSON.stringify(info.token_type));that._storage.setItem(tokenDataKeys.expiration,JSON.stringify(info.expires_in))}function retrieveTokenProperty(propName){var jsonStr=that._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}function retrieveToken(){return retrieveTokenProperty(tokenDataKeys.token)}function retrieveRefreshToken(){return retrieveTokenProperty(tokenDataKeys.refreshToken)}function retrieveAccessTokenExpiration(){return retrieveTokenProperty(tokenDataKeys.accessTokenExpiration)}function retrieveTokenType(){return retrieveTokenProperty(tokenDataKeys.tokenType)}function getToken(){return retrieveToken()}function retrieveExpiration(){return retrieveTokenProperty(tokenDataKeys.expiration)}function clearTokenInfo(info){that._storage.removeItem(tokenDataKeys.token);that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.tokenType);that._storage.removeItem(tokenDataKeys.expiration);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}function openRefreshRequest(xhr){xhr.open("POST",that._refreshURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Accept","application/json")}function processRefreshResult(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",ex.message))}}else if(xhr.status===401){that._reset();result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}that._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})}this._processLoginResult=function(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){this._loggedIn=true;try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",ex.message))}if(result!==progress.data.Session.SUCCESS){var callback=function(params){params=progress.util.Deferred.getParamObject(params);params.provider._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})};this.logout().then(callback,callback);return}}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};this._reset=function(){progress.data.AuthenticationProviderSSO.prototype._reset.apply(this);clearTokenInfo();ssoTokenInfo=null};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var that=this,date,errorObject;function afterRefreshCheck(provider,result,info){if(result===progress.data.Session.AUTHENTICATION_FAILURE){callback(new Error(progress.data._getMsgText("jsdoMSG060")))}else{progress.data.AuthenticationProviderSSO.prototype._openRequestAndAuthorize.apply(that,[xhr,verb,uri,async,function(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.setRequestHeader("Authorization","oecp "+getToken());callback(xhr)}}])}}if(this.hasClientCredentials()){date=new Date;if(this.automaticTokenRefresh&&this.hasRefreshToken()&&date.getTime()>retrieveAccessTokenExpiration()){try{var callback=function(params,result,info){params=progress.util.Deferred.getParamObject(params,result,info);afterRefreshCheck(params.provider,params.result,params.info)};this.refresh().then(callback,callback)}catch(e){callback(e)}}else{afterRefreshCheck(this,progress.data.Session.SUCCESS,null)}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};this.hasClientCredentials=function(){return retrieveToken()===null?false:true};this.refresh=function(){var deferred=new progress.util.Deferred,xhr;try{if(!this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG053","AuthenticationProvider","refresh"))}if(!this.hasRefreshToken()){throw new Error(progress.data._getMsgText("jsdoMSG054","AuthenticationProvider"))}xhr=new XMLHttpRequest;openRefreshRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){try{processRefreshResult(xhr,deferred)}catch(e){}}};xhr.send('{"token_type":"'+retrieveTokenType()+'","refresh_token":"'+retrieveRefreshToken()+'"}')}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.hasRefreshToken=function(){return retrieveRefreshToken()===null?false:true};this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM_SSO,{_loginURI:progress.data.AuthenticationProvider._springFormTokenLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase,_refreshURI:progress.data.AuthenticationProvider._springFormTokenRefreshURIBase});_automaticTokenRefresh=true;Object.defineProperty(this,"automaticTokenRefresh",{get:function(){return _automaticTokenRefresh},set:function(value){if(value===true||value===false){_automaticTokenRefresh=value}else{throw new Error(progress.data._getMsgText("jsdoMSG061","AuthenticationProvider","automaticTokenRefresh"))}},enumerable:true});this._dataKeys.automaticTokenRefresh=this._storageKey+".automaticTokenRefresh";temp=this._retrieveInfoItem(this._dataKeys.automaticTokenRefresh);if(temp===false){_automaticTokenRefresh=false}tokenDataKeys.token=this._storageKey+tokenDataKeys.token;tokenDataKeys.refreshToken=this._storageKey+tokenDataKeys.refreshToken;tokenDataKeys.tokenType=this._storageKey+tokenDataKeys.tokenType;tokenDataKeys.expiration=this._storageKey+tokenDataKeys.expiration;tokenDataKeys.accessTokenExpiration=this._storageKey+tokenDataKeys.accessTokenExpiration;if(retrieveToken()){this._loggedIn=true}};function SSOProxy(){}SSOProxy.prototype=progress.data.AuthenticationProviderForm.prototype;progress.data.AuthenticationProviderSSO.prototype=new SSOProxy;progress.data.AuthenticationProviderSSO.prototype.constructor=progress.data.AuthenticationProviderSSO;fn=progress.data.AuthenticationProviderSSO.prototype._storeInfo;progress.data.AuthenticationProviderSSO.prototype._storeInfo=function(){progress.data.AuthenticationProviderSSO.prototype._storeInfo._super.apply(this);this._storage.setItem(this._dataKeys.automaticTokenRefresh,JSON.stringify(this._automaticTokenRefresh))};progress.data.AuthenticationProviderSSO.prototype._storeInfo._super=fn;fn=progress.data.AuthenticationProviderSSO.prototype._clearInfo;progress.data.AuthenticationProviderSSO.prototype._clearInfo=function(){progress.data.AuthenticationProviderSSO.prototype._clearInfo._super.apply(this);this._storage.removeItem(this._dataKeys.automaticTokenRefresh)};progress.data.AuthenticationProviderSSO.prototype._clearInfo._super=fn})();if(typeof kendo!=="undefined"){(function(){var JSDODataReader,JSDOTransport,JSDOObservable=new kendo.Observable;function initializeJSDO(transport,options){var jsdo,resourceName;if(options.jsdo instanceof progress.data.JSDO){jsdo=options.jsdo}else if(typeof options.jsdo==="string"){resourceName=options.jsdo;jsdo=new progress.data.JSDO({name:resourceName})}else{throw new Error("JSDO: jsdo property must be either a JSDO instance or a string.")}if(transport.tableRef===undefined&&jsdo._defaultTableRef){transport.tableRef=jsdo._defaultTableRef._name}if(transport.tableRef===undefined){throw new Error("JSDO: A tableRef must be specified when using a multi-table DataSet.")}else if(jsdo[transport.tableRef]===undefined){throw new Error("JSDO: tableRef '"+transport.tableRef+"' is not present in JSDO definition.")}return jsdo}JSDODataReader=kendo.data.readers.json.extend({init:function(arg1){var event={},transport;JSDOObservable.trigger("info",event);transport=this.transport=event.sender._events.info.transport;kendo.data.readers.json.fn.init.call(this,arg1);this.model=kendo.data.Model.define({init:function(data){var record;if(!data||jQuery.isEmptyObject(data)){data=transport._getInitialValues()}record=transport._convertDataTypes(data);transport.jsdo._deleteProdsProperties(record,true);kendo.data.Model.fn.init.call(this,record)},id:"_id",fields:transport._getModel()})},total:function(data){return data.total||(data.data?data.data.length:data.length)},data:function(data){return data.data||data}});JSDOTransport=kendo.data.RemoteTransport.extend({init:function(options){var transport=this,fnName;if(options.tableRef!==undefined){transport.tableRef=options.tableRef}transport.jsdo=initializeJSDO(transport,options);transport._initFromServer=false;transport.autoSave=options.autoSave!==undefined?options.autoSave:true;transport.readLocal=options.readLocal!==undefined?options.readLocal:false;transport.countFnName=options.countFnName;transport.useArrays=options.useArrays!==undefined?options.useArrays:false;if(transport.countFnName!==undefined){if(typeof transport.jsdo[transport.countFnName]!=="function"){throw new Error("Invoke operation '"+transport.countFnName+"' for countFnName is not defined.")}}else if(transport.jsdo._resource.generic.count!==undefined){for(fnName in transport.jsdo._resource.fn){if(transport.jsdo._resource.fn.hasOwnProperty(fnName)){if(transport.jsdo._resource.generic.count===transport.jsdo._resource.fn[fnName]["function"]){transport.countFnName=fnName;break}}}}JSDOObservable.one("info",function(e){e.sender._events.info.transport=transport});transport._initConvertTypes();kendo.data.RemoteTransport.fn.init.call(this,options)},_initConvertTypes:function(){var transport=this,i,schema,fieldName,dateFields=[],arrayFields=[],convertDateFields=false;transport._convertTypes=false;schema=transport.jsdo[transport.tableRef].getSchema();for(i=0;i0&&fieldName.charAt(0)!=="_"){if(schema[i].type==="string"&&schema[i].format&&schema[i].format.indexOf("date")!==-1){dateFields.push(fieldName);if(!convertDateFields){convertDateFields=true}}else if(!transport.useArrays&&schema[i].type==="array"){arrayFields.push(fieldName);if(!convertDateFields&&schema[i].ablType&&schema[i].ablType.indexOf("DATE")===0){convertDateFields=true}}}}if(dateFields.length>0||arrayFields.length>0){transport._convertTypes=true;transport._convertFields={};transport._convertFields._arrayFields=[];transport._convertFields._dateFields=[]}if(dateFields.length>0){transport._convertFields._dateFields=dateFields}if(convertDateFields){transport._convertFields._datePattern=new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?$");transport._convertFields._dateTimePattern=new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?"+"T([0-9]{2})?:([0-9]{2})?:([0-9]{2})?.([0-9]{3})?$")}if(arrayFields.length>0){transport._convertFields._arrayFields=arrayFields}},_convertStringToDate:function(data,fieldName,targetFieldName){var transport=this,array,ablType,orig;if(!targetFieldName){targetFieldName=fieldName}array=transport._convertFields._datePattern.exec(data[targetFieldName])||[];if(array.length>0){data[targetFieldName]=new Date(parseInt(array[1],10),parseInt(array[2],10)-1,parseInt(array[3],10))}else{ablType=transport.jsdo[transport.tableRef]._fields[fieldName.toLowerCase()].ablType;if(ablType==="DATETIME"){array=transport._convertFields._dateTimePattern.exec(data[targetFieldName])||[];if(array.length>0){data[targetFieldName]=new Date(parseInt(array[1],10),parseInt(array[2],10)-1,parseInt(array[3],10),parseInt(array[4],10),parseInt(array[5],10),parseInt(array[6],10),parseInt(array[7],10))}}if(typeof data[targetFieldName]==="string"){orig=data[targetFieldName];try{data[targetFieldName]=new Date(data[targetFieldName])}catch(e){data[targetFieldName]=orig;console.log(progress.data._getMsgText("jsdoMSG000","_convertStringToDate() could not convert to date object: "+orig))}}}},_convertDataTypes:function(data){var transport=this,i,k,fieldName,schemaInfo,prefixElement,elementName,copy;delete data["prods:rowState"];if(!transport.useArrays&&transport._convertTypes&&transport._convertFields._arrayFields.length>0){copy={};transport.jsdo._copyRecord(transport.jsdo._buffers[transport.tableRef],data,copy);data=copy}if(!transport._convertTypes){return data}for(k=0;k0&&schema[i].name.charAt(0)!=="_"){type=schema[i].type;if(type==="integer"){type="number"}else if(type==="string"&&schema[i].format&&schema[i].format.indexOf("date")!==-1){type="date"}if(type==="array"){for(j=0;j0&&schema[i].name.charAt(0)!=="_"){defaultValue=transport.jsdo._getDefaultValue(schema[i]);if(schema[i].type==="array"){data[schema[i].name]=[];for(j=0;j0||jsdo[this.tableRef]._data instanceof Array&&jsdo[this.tableRef]._data.length>0}else{this._initFromServer=jsdo[this.tableRef]._data instanceof Array&&jsdo[this.tableRef]._data.length>0}}data.data=[];if(this.readLocal&&this._initFromServer){saveUseRelationships=jsdo.useRelationships;jsdo.useRelationships=false;data=this._getData(options);jsdo.useRelationships=saveUseRelationships;options.success(data);return}if(!this.readLocal){if(options.data){for(property in options.data){if(options.data.hasOwnProperty(property)){if(options.data[property]!==undefined&&optionsMapping[property]){if(filter===undefined){filter={}}filter[optionsMapping[property]]=options.data[property]}}}if(filter){filter.tableRef=this.tableRef}}}callback=function onAfterFillJSDO(object,success,request){var data={},saveUseRelationships,promise,total,exception,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;if(success){saveUseRelationships=jsdo.useRelationships;jsdo.useRelationships=false;if(transport.readLocal){data=transport._getData(options)}else{data.data=jsdo[transport.tableRef].getData();total=jsdo.getProperty("server.count");if(total){data.total=total}}jsdo.useRelationships=saveUseRelationships;transport._initFromServer=true;if(options.data&&options.data.take){if(!transport.readLocal&&transport.countFnName!==undefined&&typeof jsdo[transport.countFnName]==="function"){if(options.data.skip===0&&options.data.take>data.data.length){options.success(data);return}promise=jsdo.invoke(transport.countFnName,{filter:request.objParam.filter});promise.then(function(object,success,request){var exception,total,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;try{if(typeof request.response==="object"&&Object.keys(request.response).length===1){total=request.response[Object.keys(request.response)];if(typeof total!=="number"){total=undefined}}}catch(e){}if(total!==undefined){if(total){data.total=total}options.success(data)}else{exception=new Error("Unexpected response from '"+transport.countFnName+"' operation.");options.error(request.xhr,request.xhr.status,exception)}},function(object,success,request){var exception,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;exception=new Error("Error invoking '"+transport.countFnName+"' operation.");options.error(request.xhr,request.xhr.status,exception)})}else{options.success(data)}}else{options.success(data)}}else{exception=new Error("Error while reading records.");options.error(request.xhr,request.xhr.status,exception)}};jsdo.fill(filter).then(callback,callback)}catch(e){options.error(null,null,e)}},_processChanges:function(options,request){var jsdo=this.jsdo,transport=this,array,i,jsrecord,id,record;if(options.batch){array=[];if(options.data.created instanceof Array){if(jsdo._resource.idProperty){if(request.jsrecords){for(i=0;i= 200 && xhr.status < 300) - || (xhr.status === 0 && xhr.responseText !== "")) { - - request.success = true; - // get the Client Context ID (AppServer ID) - xhr.jsdo._session._saveClientContextId(xhr); - if ((typeof xhr.onSuccessFn) == 'function') { - var operation; - if (xhr.request.fnName !== undefined - && xhr.jsdo._resource.fn[xhr.request.fnName] !== undefined) { - operation = xhr.jsdo._resource.fn[xhr.request.fnName].operation; + try { + if ((xhr.status >= 200 && xhr.status < 300) + || (xhr.status === 0 && xhr.responseText !== "")) { + + request.success = true; + // get the Client Context ID (AppServer ID) + xhr.jsdo._session._saveClientContextId(xhr); + if ((typeof xhr.onSuccessFn) == 'function') { + var operation; + if (xhr.request.fnName !== undefined + && xhr.jsdo._resource.fn[xhr.request.fnName] !== undefined) { + operation = xhr.jsdo._resource.fn[xhr.request.fnName].operation; + } + else + operation = null; + if ((operation === undefined) || (operation !== null && operation.mergeMode)) + xhr.jsdo._mergeInvoke(request.response, xhr); + if (request.success) + xhr.onSuccessFn(xhr.jsdo, request.success, request); + else if ((typeof xhr.onErrorFn) == 'function') + xhr.onErrorFn(xhr.jsdo, request.success, request); } - else - operation = null; - if ((operation === undefined) || (operation !== null && operation.mergeMode)) - xhr.jsdo._mergeInvoke(request.response, xhr); - if (request.success) - xhr.onSuccessFn(xhr.jsdo, request.success, request); - else if ((typeof xhr.onErrorFn) == 'function') - xhr.onErrorFn(xhr.jsdo, request.success, request); - } - } else { - request.success = false; - if (xhr.status === 0) { - request.exception = new Error(msg.getMsgText("jsdoMSG101")); + } else { + request.success = false; + if (xhr.status === 0) { + request.exception = new Error(msg.getMsgText("jsdoMSG101")); + } + if ((typeof xhr.onErrorFn) == 'function') { + xhr.onErrorFn(xhr.jsdo, request.success, request); + } } + } catch (e) { + request.success = false; + request.exception = e; if ((typeof xhr.onErrorFn) == 'function') { xhr.onErrorFn(xhr.jsdo, request.success, request); } } - } catch (e) { - request.success = false; - request.exception = e; - if ((typeof xhr.onErrorFn) == 'function') { - xhr.onErrorFn(xhr.jsdo, request.success, request); + // get the Client Context ID (AppServer ID) + xhr.jsdo._session._checkServiceResponse(xhr, request.success, request); + + if ((typeof xhr.onCompleteFn) == 'function') { + xhr.onCompleteFn(xhr.jsdo, request.success, request); } - } - // get the Client Context ID (AppServer ID) - xhr.jsdo._session._checkServiceResponse(xhr, request.success, request); - if ((typeof xhr.onCompleteFn) == 'function') { - xhr.onCompleteFn(xhr.jsdo, request.success, request); + } catch (e) { + request.success = false; + request.exception = e; + if ((typeof xhr.onErrorFn) == 'function') { + xhr.onErrorFn(xhr.jsdo, request.success, request); + } + } } - - } }; /* @@ -8271,8 +8283,17 @@ limitations under the License. } } + // Christian Bryan - 10.02.2019 Add this back in + // Mike Fechner, Consultingwerk Ltd. 16.03.2016 + // Adding the tableRef property of the JSDO Parameters to + // the Filter Parameter so that the backend can use this + // information to actually know which Business Entity Table + // the query filter string is intended for ... + filter = JSON.stringify({ ablFilter: ablFilter, + tableRef: params.tableRef, + viewTables: jsdo.viewTables, sqlQuery: sqlQuery, orderBy: sortFields, skip: params.skip, @@ -8727,9 +8748,8 @@ limitations under the License. //this is so that we can see the code in Chrome's Source tab when script is loaded via XHR //# sourceURL=progress.jsdo.js /* -progress.session.js Version: 6.0.1 -Copyright (c) 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2012-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -9525,7 +9545,9 @@ limitations under the License. // connects to online the last time it was checked? // (value is always false if session is not logged in) oepingAvailable = false, - defaultPartialPingURI = "/rest/_oeping", + hasResolvedPingURI = false, + defaultPartialPingURI = "/rest/_oepingService/_oeping", + classicPartialPingURI = "/rest/_oeping", partialPingURI = defaultPartialPingURI, _storageKey, _authProvider = null, @@ -9724,6 +9746,7 @@ limitations under the License. case progress.data.Session.AUTH_TYPE_BASIC: case progress.data.Session.AUTH_TYPE_ANON: case progress.data.Session.AUTH_TYPE_SSO: + case progress.data.Session.AUTH_TYPE_BEARER: case null: _authenticationModel = newval; storeSessionInfo("authenticationModel", newval); @@ -10833,7 +10856,8 @@ limitations under the License. xhr._jsdosession = jsdosession; // in case the caller is a JSDOSession xhr._deferred = deferred; // in case the caller is a JSDOSession if (this.authenticationModel === progress.data.Session.AUTH_TYPE_FORM || - this.authenticationModel === progress.data.Session.AUTH_TYPE_BASIC) { + this.authenticationModel === progress.data.Session.AUTH_TYPE_BASIC || + this.authenticationModel === progress.data.Session.AUTH_TYPE_BEARER) { if (isAsync) { xhr.onreadystatechange = this._onReadyStateChangeGeneric; xhr.onResponseFn = this._processLogoutResult; @@ -10929,7 +10953,8 @@ limitations under the License. } else if (xhr.status !== 200) { /* Determine whether an error returned from the server is really an error */ - if (pdsession.authenticationModel === progress.data.Session.AUTH_TYPE_BASIC) { + if (pdsession.authenticationModel === progress.data.Session.AUTH_TYPE_BASIC || + pdsession.authenticationModel === progress.data.Session.AUTH_TYPE_BEARER) { /* If the Auth model is Basic, we probably got back a 404 Not found. * But that's OK, because logout from Basic is meaningless on the * server side unless it happens to be stateful, which is the only @@ -11645,40 +11670,71 @@ limitations under the License. this._onReadyStateChangePing = function () { var xhr = this; var args; - - if (xhr.readyState === 4) { - args = { - xhr: xhr, - fireEventIfOfflineChange: true, - offlineReason: null - }; - that._processPingResult(args); - if (_pingInterval > 0) { - _timeoutID = setTimeout(that._autoping, _pingInterval); + try { + if (xhr.readyState === 4) { + args = { + xhr: xhr, + fireEventIfOfflineChange: true, + offlineReason: null + }; + that._processPingResult(args); + if (_pingInterval > 0) { + _timeoutID = setTimeout(that._autoping, _pingInterval); + } } + } catch(e) { } }; this._pingtestOnReadyStateChange = function () { var xhr = this; + try { + if (xhr.readyState === 4) { + var foundOeping = false; + if (xhr.status >= 200 && xhr.status < 300) { + foundOeping = true; + } else { + setPartialPingURI(that.loginTarget); + console.warn("Default ping target not available, will use loginTarget instead."); + } + setOepingAvailable(foundOeping); - if (xhr.readyState === 4) { - var foundOeping = false; - if (xhr.status >= 200 && xhr.status < 300) { - foundOeping = true; - } else { - setPartialPingURI(that.loginTarget); - console.warn("Default ping target not available, will use loginTarget instead."); + // If we're here, we've just logged in. If pingInterval has been set, we need + // to start autopinging + if (_pingInterval > 0) { + _timeoutID = setTimeout(that._autoping, _pingInterval); + } } - setOepingAvailable(foundOeping); + } catch(e) { + } + }; + + var resolvePingURI = () => { + var xhr = new XMLHttpRequest(), + deferred = new progress.util.Deferred(); - // If we're here, we've just logged in. If pingInterval has been set, we need - // to start autopinging - if (_pingInterval > 0) { - _timeoutID = setTimeout(that._autoping, _pingInterval); + xhr.onreadystatechange = () => { + if (xhr.readyState === 4) { + // If we can't find the new ping endpoint, we go back to the Classic Ping URI. + if (xhr.status === 404) { + setPartialPingURI(classicPartialPingURI); + deferred.reject(false); + } else { + deferred.resolve(true); + } + hasResolvedPingURI = true; } + }; + + // if we've resolved the pingURI OR we haven't logged in, then we don't have to do anything + if (hasResolvedPingURI || (this.loginResult !== progress.data.Session.LOGIN_SUCCESS && !this.authProvider)) { + deferred.resolve(true); + } else { + this._openRequest(xhr, "GET", partialPingURI, true, () => xhr.send()); } - }; + + return deferred.promise(); + } /* * args: pingURI @@ -11691,6 +11747,8 @@ limitations under the License. var xhr = new XMLHttpRequest(), that = this; + args.xhr = xhr; + function sendPingAfterOpen() { if (args.async) { xhr.onreadystatechange = args.onReadyStateFn; @@ -11710,30 +11768,35 @@ limitations under the License. xhr.send(null); } - try { - if (this._authProvider) { - this._authProvider._openRequestAndAuthorize( - xhr, - 'GET', - args.pingURI, - args.async, - sendPingAfterOpen - ); - } else { - // get rid of this if we do away with synchronous support (i.e., customer use of - // old Session API) - this._setXHRCredentials(xhr, "GET", args.pingURI, this.userName, _password, args.async); - - // Sending the XHR request after opening the channel - if (xhr.readyState === 1) { - sendPingAfterOpen(); + resolvePingURI().then(() => { + // do nothing on success because the new oePingService was found + }, () => { + // re-create the pingURI since we changed to the old classic AppServer ping URI + args.pingURI = this._makePingURI(); + }).then(() => { + try { + if (this._authProvider) { + this._authProvider._openRequestAndAuthorize( + xhr, + 'GET', + args.pingURI, + args.async, + sendPingAfterOpen + ); + } else { + // get rid of this if we do away with synchronous support (i.e., customer use of + // old Session API) + this._setXHRCredentials(xhr, "GET", args.pingURI, this.userName, _password, args.async); + + // Sending the XHR request after opening the channel + if (xhr.readyState === 1) { + sendPingAfterOpen(); + } } + } catch (e) { + args.error = e; } - } catch (e) { - args.error = e; - } - - args.xhr = xhr; + }) }; this._makePingURI = function () { @@ -12314,7 +12377,15 @@ limitations under the License. enumerable: true } ); - + Object.defineProperty( + progress.data.Session, + 'AUTH_TYPE_BEARER', + { + value: "bearer", + enumerable: true + } + ); + Object.defineProperty( progress.data.Session, 'DEVICE_OFFLINE', @@ -12369,6 +12440,7 @@ limitations under the License. progress.data.Session.AUTH_TYPE_BASIC = "basic"; progress.data.Session.AUTH_TYPE_FORM = "form"; progress.data.Session.AUTH_TYPE_SSO = "sso"; + progress.data.Session.AUTH_TYPE_BEARER = "bearer"; /* deliberately not including the "offline reasons" that are defined in the * 1st part of the conditional. We believe that we can be used only in environments where @@ -13192,34 +13264,36 @@ limitations under the License. var xhr = this, cbresult, info; - - if (xhr.readyState === 4) { - info = { - xhr: xhr, - offlineReason: undefined, - fireEventIfOfflineChange: true, - usingOepingFormat: false - }; - - // call _processPingResult because it has logic for - // detecting change in online/offline state - _pdsession._processPingResult(info); - - if (xhr.status >= 200 && xhr.status < 300) { - deferred.resolve( - that, - progress.data.Session.SUCCESS, - info - ); - } else { - if (xhr.status === 401) { - cbresult = progress.data.AuthenticationProvider._getAuthFailureReason(xhr); + try { + if (xhr.readyState === 4) { + info = { + xhr: xhr, + offlineReason: undefined, + fireEventIfOfflineChange: true, + usingOepingFormat: false + }; + + // call _processPingResult because it has logic for + // detecting change in online/offline state + _pdsession._processPingResult(info); + + if (xhr.status >= 200 && xhr.status < 300) { + deferred.resolve( + that, + progress.data.Session.SUCCESS, + info + ); } else { - cbresult = progress.data.Session.GENERAL_FAILURE; + if (xhr.status === 401) { + cbresult = progress.data.AuthenticationProvider._getAuthFailureReason(xhr); + } else { + cbresult = progress.data.Session.GENERAL_FAILURE; + } + deferred.reject(that, cbresult, info); } - deferred.reject(that, cbresult, info); } - } + } catch (e) { + } }; try { @@ -13458,8 +13532,8 @@ limitations under the License. progress.data.getSession = function (options) { var deferred = new progress.util.Deferred(), authProvider, - promise, - authProviderInitObject = {}; + authProviderInitObject = {}, + session; // This is the reject handler for session-related operations // login, addCatalog, and logout @@ -13487,26 +13561,23 @@ limitations under the License. } function loginHandler(object) { - var jsdosession; + let jsdosession; try { - jsdosession = new progress.data.JSDOSession(options); - try { - jsdosession.isAuthorized() - .then(function() { - return jsdosession.addCatalog(options.catalogURI); - }, sessionRejectHandler) - .then(function (object, result, info) { - object = progress.util.Deferred.getParamObject(object, result, info); - deferred.resolve(object.jsdosession, progress.data.Session.SUCCESS); - }, sessionRejectHandler); - } catch (e) { - sessionRejectHandler( - jsdosession, - progress.data.Session.GENERAL_FAILURE, - {errorObject: e} - ); + if (typeof session === "undefined") { + jsdosession = new progress.data.JSDOSession(options); + } else { + jsdosession = session; } + + jsdosession.isAuthorized() + .then(function() { + return jsdosession.addCatalog(options.catalogURI); + }, sessionRejectHandler) + .then(function (object, result, info) { + object = progress.util.Deferred.getParamObject(object, result, info); + deferred.resolve(object.jsdosession, progress.data.Session.SUCCESS); + }, sessionRejectHandler); } catch (ex) { sessionRejectHandler( jsdosession, @@ -13632,7 +13703,33 @@ limitations under the License. options.authProvider = authProvider; if (authProvider.hasClientCredentials()) { - loginHandler(authProvider); + // FAKE SESSION + let jsdosession = new progress.data.JSDOSession(options), + statusCode = 0; + + // This is a band-aid. We need to refactor and re-modularize + // getSession() now that the team has a better understanding + // of async operations --aestrada + jsdosession.isAuthorized().then(() => { + session = jsdosession; + return; + }, (obj) => { + statusCode = obj && obj.info && obj.info.xhr && obj.info.xhr.status; + return progress.util.Deferred.when([ + jsdosession.invalidate(), + options.authProvider.logout() + ]); + }).then(() => { + // If we have a 401, then we need to get rid of our old authProvider and try a fresh start + // Otherwise, we still good. + if (statusCode === 401) { + authProvider = new progress.data.AuthenticationProvider(authProviderInitObject); + options.authProvider = authProvider; + callLogin(authProvider); + } else { + loginHandler(authProvider); + } + }); } else { // If model is anon, just log in. if (authProvider.authenticationModel === progress.data.Session.AUTH_TYPE_ANON) { @@ -13699,12 +13796,10 @@ limitations under the License. if (typeof exports !== "undefined") { exports.progress = progress; } - //# sourceURL=progress.jsdo.js /* -progress.auth.js Version: 6.0.1 -Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2016-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -13791,6 +13886,9 @@ limitations under the License. case progress.data.Session.AUTH_TYPE_FORM_SSO: authProv = new progress.data.AuthenticationProviderSSO(initObject.uri); break; + case progress.data.Session.AUTH_TYPE_BEARER: + authProv = new progress.data.AuthenticationProviderBearer(initObject.uri); + break; default: // AuthenticationProvider: The 'init-object' parameter passed to the 'constructor' function // has an invalid value for the 'authenticationModel' property. @@ -13832,7 +13930,10 @@ limitations under the License. xhr.onreadystatechange = function () { if (xhr.readyState === 4) { // process the response from the Web application - that._processLoginResult(xhr, deferred); + try { + that._processLoginResult(xhr, deferred); + } catch (e) { + } } }; @@ -14173,9 +14274,8 @@ limitations under the License. //# sourceURL=progress.jsdo.js /* -progress.auth.basic.js Version: 6.0.1 -Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2016-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14332,9 +14432,154 @@ limitations under the License. }()); //# sourceURL=progress.jsdo.js /* -progress.auth.form.js Version: 6.0.1 -Copyright (c) 2016-2018 Progress Software Corporation and/or its subsidiaries or affiliates. + +Copyright (c) 2017-2019 Progress Software Corporation and/or its subsidiaries or affiliates. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + */ + +(function () { + + "use strict"; // note that this makes JSLint complain if you use arguments[x] + + /*global progress : true*/ + /*global storage, XMLHttpRequest, msg, btoa*/ + + progress.data.AuthenticationProviderBearer = function (uri) { + var bearerToken = null, + fn; + + // process constructor arguments, etc. + this._initialize(uri, progress.data.Session.AUTH_TYPE_BEARER, + {"_loginURI": progress.data.AuthenticationProvider._homeLoginURIBase}); + + // PRIVATE FUNCTIONS + + function make_Bearer_auth_header(token) { + return "Bearer " + token; + } + + // "INTERNAL" METHODS + // Override the protoype's method but call it from within the override + // (Define the override here in the constructor so it has access to instance variables) + this._reset = function () { + bearerToken = null; + progress.data.AuthenticationProviderBearer.prototype._reset.apply(this); + }; + + // Override the protoype's method (this method does not invoke the prototype's copy) + // (Define the override here in the constructor so it has access to instance variables) + this._openLoginRequest = function (xhr, uri) { + var auth; + + xhr.open("GET", uri, true); // but see comments below inside the "if bearerToken" + // may have to go with that approach + + if (bearerToken) { + + // set Authorization header + auth = make_Bearer_auth_header(bearerToken); + xhr.setRequestHeader('Authorization', auth); + } + + progress.data.Session._setNoCacheHeaders(xhr); + }; + + // Override the protoype's method but call it from within the override + // (Define the override here in the constructor so it has access to instance variables) + this._processLoginResult = function _Bearer_processLoginResult(xhr, deferred) { + progress.data.AuthenticationProviderBearer.prototype._processLoginResult.apply( + this, + [xhr, deferred] + ); + if (!this._loggedIn) { + // login failed, clear the credentials + bearerToken = null; + } + }; + + // Override the protoype's method (this method does not invoke the prototype's copy, but + // calls a prototype general-purpose login method) + // (Define the override here in the constructor so it has access to instance variables) + this.login = function (token) { + // these throw if the check fails (may want to do something more elegant) + this._checkStringArg("login", token, 1, "token"); + + bearerToken = token; + return this._loginProto(); + }; + + // Override the protoype's method (this method does not invoke the prototype's copy) + // (Define the override here in the constructor so it has access to instance variables) + // TODO: This method uses a callback, primarily to avoid breaking tdriver tests. We should change + // it to use promises + this._openRequestAndAuthorize = function (xhr, verb, uri, async, callback) { + var auth, + errorObject; + + if (this.hasClientCredentials()) { + + xhr.open(verb, uri, async); // but see comments below inside the "if bearerToken" + // may have to go with that approach + + if (bearerToken) { + + // set Authorization header + auth = make_Bearer_auth_header(bearerToken); + xhr.setRequestHeader('Authorization', auth); + } + + progress.data.Session._setNoCacheHeaders(xhr); + } else { + // AuthenticationProvider: The AuthenticationProvider is not managing valid credentials. + errorObject = new Error(progress.data._getMsgText("jsdoMSG125", "AuthenticationProvider")); + } + + callback(errorObject); + }; + }; + + + // Give this constructor the prototype from the "base" AuthenticationProvider + // Do this indirectly by way of an intermediate object so changes to the prototype ("method overrides") + // don't affect other types of AuthenticationProviders that use the prototype) + function BearerProxy() {} + BearerProxy.prototype = progress.data.AuthenticationProvider.prototype; + progress.data.AuthenticationProviderBearer.prototype = new BearerProxy(); + + // Reset the prototype's constructor property so it points to AuthenticationProviderForm rather than + // the one that it just inherited (this is pretty much irrelevant though - the correct constructor + // will get called regardless) + progress.data.AuthenticationProviderBearer.prototype.constructor = + progress.data.AuthenticationProviderBearer; + + + // OVERRIDE METHODS ON PROTOTYPE IF NECESSARY AND POSSIBLE + // (SOME METHODS ARE OVERRIDDEN IN THE CONSTRUCTOR BECAUSE THEY NEED ACCESS TO INSTANCE VARIABLES) + + // NOTE: There are no overrides of the following methods (either here or in the constructor). + // This object uses these methods from the original prototype(i.e., the implementations from the + // AuthenticationProvider object): + // logout (API method) + // hasClientCredentials (API method) + +}()); +//# sourceURL=progress.jsdo.js +/* + +Copyright (c) 2016-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14451,7 +14696,10 @@ limitations under the License. xhr.onreadystatechange = function () { if (xhr.readyState === 4) { // process the response from the Web application - that._processLogoutResult(xhr, deferred); + try { + that._processLogoutResult(xhr, deferred); + } catch (e) { + } } }; @@ -14544,9 +14792,8 @@ limitations under the License. }()); //# sourceURL=progress.jsdo.js /* -progress.auth.sso.js Version: 6.0.1 -Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright (c) 2016-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14903,7 +15150,10 @@ limitations under the License. xhr.onreadystatechange = function () { if (xhr.readyState === 4) { // process the response from the Web application - processRefreshResult(xhr, deferred); + try { + processRefreshResult(xhr, deferred); + } catch (e){ + } } }; diff --git a/lib/progress.jsdo.min.js b/lib/progress.jsdo.min.js index fc0f831..5129200 100644 --- a/lib/progress.jsdo.min.js +++ b/lib/progress.jsdo.min.js @@ -1,7 +1,5 @@ /* -Progress JSDO Version: 6.0.1 - -Copyright 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates. +Copyright 2012-2019 Progress Software Corporation and/or its subsidiaries or affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,5 +13,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -(function(){var isNativeScript=false,isNodeJS=false;var pkg_xmlhttprequest="xmlhttprequest",pkg_nodeLocalstorage="node-localstorage",pkg_nativescriptLocalstorage="nativescript-localstorage",pkg_fileSystemAccess="file-system/file-system-access",pkg_base64="base-64";if(typeof XMLHttpRequest==="undefined"){isNodeJS=true;try{XMLHttpRequest=require(""+pkg_xmlhttprequest).XMLHttpRequest}catch(e){console.error("Error: JSDO library requires XMLHttpRequest object in Node.js.\n"+"Please install xmlhttprequest package.")}}if(!isNodeJS&&(typeof localStorage==="undefined"||typeof sessionStorage==="undefined")){try{require(""+pkg_fileSystemAccess);isNativeScript=true}catch(exception1){isNativeScript=false}}if(isNativeScript){try{if(typeof sessionStorage==="undefined"){sessionStorage=require(""+pkg_nativescriptLocalstorage)}if(typeof localStorage==="undefined"){localStorage=require(""+pkg_nativescriptLocalstorage)}}catch(exception2){console.error("Error: JSDO library requires localStorage and sessionStorage objects in NativeScript.\n"+"Please install nativescript-localstorage package.")}try{if(typeof btoa==="undefined"){btoa=require(""+pkg_base64).encode}}catch(exception3){console.error("Error: JSDO library requires btoa() function in NativeScript.\n"+"Please install base-64 package.")}}if(isNodeJS){var LocalStorage;if(typeof localStorage==="undefined"){try{var module=require(""+pkg_nodeLocalstorage);LocalStorage=module.LocalStorage;localStorage=new LocalStorage("./scratch1")}catch(e){console.error("Error: JSDO library requires localStorage and sessionStorage objects in Node.js.\n"+"Please install node-localstorage package.")}}if(typeof sessionStorage==="undefined"&&typeof LocalStorage!=="undefined"){sessionStorage=new LocalStorage("./scratch2")}try{if(typeof btoa==="undefined"){btoa=require(""+pkg_base64).encode}}catch(exception3){console.error("Error: JSDO library requires btoa() function in Node.js.\n"+"Please install base-64 package.")}}})();(function(){if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.util={};var STRING_OBJECT_TYPE="String",DATE_OBJECT_TYPE="Date",CHARACTER_ABL_TYPE="CHARACTER";progress.util.Deferred=function(){function Deferred(){this._deferred={}}Deferred.prototype.promise=function(){var that=this;if(progress.util.Deferred.useJQueryPromises){if(typeof $!=="undefined"&&typeof $.Deferred==="function"){this._deferred._jQuerydeferred=$.Deferred();this._promise=this._deferred._jQuerydeferred.promise()}else{throw new Error("JQuery Promises not found in environment.")}}else{this._promise=new Promise(function(resolve,reject){that._deferred.resolve=resolve;that._deferred.reject=reject})}if(this._resolveArguments||this._rejectArguments){setTimeout(function(){if(that._resolveArguments){that.resolve.apply(that,that._resolveArguments)}else if(that._rejectArguments){that.reject.apply(that,that._rejectArguments)}},500)}return this._promise};Deferred.prototype.resolve=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.resolve.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.resolve(object)}}else{this._resolveArguments=arguments}};Deferred.prototype.reject=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.reject.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.reject(object)}}else{this._rejectArguments=arguments}};Deferred.useJQueryPromises=false;Deferred.when=function(deferreds){if(progress.util.Deferred.useJQueryPromises){return $.when.apply($,deferreds)}else{return Promise.all(deferreds)}};Deferred.getParamObject1=function(arg1,arg2,arg3){var object={},objectName;try{if(typeof arg1==="undefined"||arg1===null){object.result=arg2;object.info=arg3}else{if(arg1 instanceof progress.data.JSDOSession){objectName="jsdosession"}else if(arg1 instanceof progress.data.AuthenticationProvider){objectName="provider"}else if(arg1 instanceof progress.data.JSDO){objectName="jsdo"}else if(typeof arg1==="number"){objectName="result"}else{objectName=typeof arg1}object[objectName]=arg1;if(objectName==="jsdo"){object.success=arg2;if(arg3&&arg3.xhr){object.request=arg3}else if(arg3&&arg3.batch){object.request=arg3}else{object.info=arg3}}else{if(objectName==="result"){object.info=arg2;if(arg3){object.info2=arg3}}else{object.result=arg2;object.info=arg3}}}}catch(e){console.log("Error: Undetermined argument in getParamObject() call.")}return object};Deferred.getParamObject=function(arg1,arg2,arg3){var object={};if(progress.util.Deferred.useJQueryPromises){object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3)}else{if(typeof arg1==="undefined"){object.result=arg2;object.info=arg3;arg1=object}return arg1}return object};return Deferred}();progress.util.Observable=function(){function _filterObservers(observers,fn,scope,operation){return observers.filter(function(el){if(el.fn!==fn||el.scope!==scope||el.operation!==operation){return el}},this)}this.validateSubscribe=function(args,evt,listenerData){if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="string"){listenerData.operation=args[1];listenerData.fn=args[2];listenerData.scope=args[3]}else if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="function"){listenerData.operation=undefined;listenerData.scope=args[2];listenerData.fn=args[1]}else{throw new Error}};this.subscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"subscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",progress.data._getMsgText("jsdoMSG039")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",e.message))}observers=this._events[evt]||[];observers=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation);observers.push(listenerData);this._events[evt]=observers;return this};this.unsubscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"unsubscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",progress.data._getMsgText("jsdoMSG037")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",e.message))}observers=this._events[evt]||[];if(observers.length>0){this._events[evt]=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation)}return this};this.trigger=function(evt,operation,args){var observers,op;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"trigger"))}this._events=this._events||{};evt=evt.toLowerCase();observers=this._events[evt]||[];if(observers.length>0){args=Array.prototype.slice.call(arguments);if(arguments.length>=2&&typeof evt==="string"&&typeof operation==="string"){op=operation;args=args.length>2?args.slice(2):[]}else if(arguments.length>=1&&typeof evt==="string"){op=undefined;args=args.length>1?args.slice(1):[]}else{throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"trigger"))}observers.forEach(function(el){if(el.operation===op){el.fn.apply(el.scope,args)}})}return this};this.unsubscribeAll=function(evt,operation){var observers;if(evt){this._events=this._events||{};if(typeof evt==="string"){evt=evt.toLowerCase();observers=this._events[evt]||[];observers.forEach(function(el){if(el.operation){this.unsubscribe(evt,el.operation,el.fn,el.scope)}else{this.unsubscribe(evt,el.fn,el.scope)}},this)}}else{this._events={}}return this}};progress.data.LocalStorage=function LocalStorage(){if(typeof localStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","progress.data.LocalStorage","localStorage"))}this.saveToLocalStorage=function(name,dataObj){localStorage.setItem(name,JSON.stringify(dataObj))};this.readFromLocalStorage=function(name){var jsonStr=localStorage.getItem(name),dataObj=null;if(jsonStr!==null){try{dataObj=JSON.parse(jsonStr)}catch(e){dataObj=null}}return dataObj};this.clearLocalStorage=function(name){localStorage.removeItem(name)}};progress.util._convertToABLWhereString=function(tableRef,filter){var result=[],logic=filter.logic||"and",idx,length,field,fieldInfo,type,format,operator,value,ablType,filters=filter.filters||[filter],whereOperators={eq:"=",neq:"<>",gt:">",gte:">=",lt:"<",lte:"<=",contains:"INDEX",doesnotcontain:"INDEX",endswith:"R-INDEX",startswith:"BEGINS",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};for(idx=0,length=filters.length;idx 0"}else{format="{2} MATCHES '*{1}'"}}else{format="{2} {0} "+format}filter=progress.util._format(format,operator,value,field)}else if(operator&&value===undefined){if(filter.operator==="isempty"||filter.operator==="isnotempty"){ablType=tableRef._getABLType(field);if(ablType!==CHARACTER_ABL_TYPE){throw new Error("Error parsing filter object. The operator "+filter.operator+" requires a CHARACTER field")}if(filter.operator==="isempty"){format="{2} = ''"}else if(filter.operator==="isnotempty"){format="{2} <> ''"}}else{if(filter.operator==="isnull"){format="{2} = ?"}else if(filter.operator==="isnotnull"){format="{2} <> ?"}else{format="{2} {0} ?"}}filter=progress.util._format(format,operator,value,field)}}result.push(filter)}filter=result.join(" "+logic+" ");if(result.length>1){filter="("+filter+")"}return filter};progress.util._convertToSQLQueryString=function(tableRef,filter,addSelect){var result=[],logic=filter.logic||"and",idx,length,field,type,format,operator,value,fieldFormat,filters=filter.filters||[filter],filterStr,usingLike=true,whereOperators={eq:"=",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<=",contains:"LIKE",doesnotcontain:"NOT LIKE",endswith:"LIKE",startswith:"LIKE",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};if(typeof addSelect==="undefined"){addSelect=false}for(idx=0,length=filters.length;idx1){filterStr="("+filterStr+")"}if(addSelect===true){filterStr="SELECT * FROM "+tableRef._name+" WHERE "+filterStr}return filterStr};progress.util._getObjectType=function(value){return Object.prototype.toString.call(value).slice(8,-1)};progress.util._format=function(fmt){var values=arguments,formatRegExp=/\{(\d+)(:[^\}]+)?\}/g;return fmt.replace(formatRegExp,function(match,index,placeholderFormat){var value=values[parseInt(index,10)+1];return progress.util._toString(value,placeholderFormat?placeholderFormat.substring(1):"")})};progress.util._toString=function(value,fmt){var str;if(fmt){if(progress.util._getObjectType(value)==="Date"){return progress.util._formatDate(value,fmt)}}if(typeof value==="number"){str=value.toString()}else{str=value!==undefined?value:""}return str};progress.util._pad=function(number,digits){var zeros=["","0","00","000","0000"],end;number=String(number);digits=digits||2;end=digits-number.length;if(end){return zeros[digits].substring(0,end)+number}return number};progress.util._formatDate=function(date,format){var dateFormatRegExp=/dd|MM|yyyy|hh|mm|fff|FFF|ss|zzz|iso|"[^"]*"|'[^']*'/g;return format.replace(dateFormatRegExp,function(match){var minutes,result,sign;if(match==="dd"){result=progress.util._pad(date.getDate())}else if(match==="MM"){result=progress.util._pad(date.getMonth()+1)}else if(match==="yyyy"){result=progress.util._pad(date.getFullYear(),4)}else if(match==="hh"){result=progress.util._pad(date.getHours())}else if(match==="mm"){result=progress.util._pad(date.getMinutes())}else if(match==="ss"){result=progress.util._pad(date.getSeconds())}else if(match==="fff"){result=progress.util._pad(date.getMilliseconds(),3)}else if(match==="FFF"){result=String(date.getTime())}else if(match==="zzz"){minutes=date.getTimezoneOffset();sign=minutes<0;result=(sign?"+":"-")+minutes}else if(match==="iso"){result=date.toISOString()}return result!==undefined?result:match.slice(1,match.length-1)})};progress.util.jsdoSettingsProcessor=function jsdoSettingsProcessor(jsdoSettings){if(typeof jsdoSettings==="object"){if(jsdoSettings.authenticationModel===undefined||jsdoSettings.authenticationModel===""){jsdoSettings.authenticationModel="ANONYMOUS"}}}})();(function(){var PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS=20,PROGRESS_JSDO_OP_STRING=["none","create","read","update","delete","submit"],PROGRESS_JSDO_ROW_STATE_STRING=["","created","","modified","deleted"];if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data._nextid=0;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime());var UID_MAX_VALUE=999999999999999;progress.data._getNextId=function(){var uid=++progress.data._nextid;if(uid>=UID_MAX_VALUE){progress.data._nextid=uid=1;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime())}return progress.data._uidprefix+"-"+uid};var msg={};msg.msgs={};msg.msgs.jsdoMSG000="JSDO, Internal Error: {1}";msg.msgs.jsdoMSG001="JSDO: JSDO has multiple tables. Please use {1} at the table reference level.";msg.msgs.jsdoMSG002="JSDO: Working record for '{1}' is undefined.";msg.msgs.jsdoMSG003="JSDO: {1} function requires a function as a parameter.";msg.msgs.jsdoMSG004="JSDO: Unable to find resource '{1}' in the catalog.";msg.msgs.jsdoMSG005="JSDO: Data for table '{1}' was not specified in addRecords() call.";msg.msgs.jsdoMSG006="JSDO: Data for JSDO was not specified in addRecords() call.";msg.msgs.jsdoMSG007="JSDO: Test function in {1} must return a boolean.";msg.msgs.jsdoMSG008="JSDO: Invalid keyFields parameter in addRecords() call.";msg.msgs.jsdoMSG009="JSDO: KeyField '{1}' in addRecords() call was not found in the schema.";msg.msgs.jsdoMSG010="JSDO: Field '{1}' in relationship was not found in the schema.";msg.msgs.jsdoMSG011="UIHelper: JSDO has multiple tables. "+"Please use {1} at the table reference level.";msg.msgs.jsdoMSG012="UIHelper: Invalid {2} parameter in {1} call.";msg.msgs.jsdoMSG020="JSDO: tableName parameter must be a string in addRecords() call.";msg.msgs.jsdoMSG021="JSDO: addMode parameter must be specified in addRecords() call.";msg.msgs.jsdoMSG022="JSDO: Invalid addMode specified in addRecords() call.";msg.msgs.jsdoMSG023="JSDO: Duplicate found in addRecords() call using APPEND mode.";msg.msgs.jsdoMSG024="{1}: Unexpected signature in call to {2} function.";msg.msgs.jsdoMSG025="{1}: Invalid parameters in call to {2} function.";msg.msgs.jsdoMSG026="JSDO: saveChanges requires a "+"CREATE, UPDATE, DELETE or SUBMIT operation to be defined.";msg.msgs.jsdoMSG030="JSDO: Invalid {1}, expected {2}.";msg.msgs.jsdoMSG031="JSDO: Specified sort field name '{1}' was not found in the schema.";msg.msgs.jsdoMSG032="JSDO: Before-image data already exists for record in addRecords() call.";msg.msgs.jsdoMSG033="{1}: Invalid signature for {2}. {3}";msg.msgs.jsdoMSG034="JSDO: In '{1}' function, JSON data is missing _id";msg.msgs.jsdoMSG035="JSDO: In '{1}' function, before-image JSON data is missing prods:clientId";msg.msgs.jsdoMSG036="JSDO: '{1}' can only be called for a dataset";msg.msgs.jsdoMSG037="{1}: Event name must be provided for {2}.";msg.msgs.jsdoMSG038="Too few arguments. There must be at least {1}.";msg.msgs.jsdoMSG039="The name of the event is not a string.";msg.msgs.jsdoMSG040="The event listener is not a function.";msg.msgs.jsdoMSG041="The event listener scope is not an object.";msg.msgs.jsdoMSG042="'{1}' is not a defined event for this object.";msg.msgs.jsdoMSG043="{1}: A session object was requested to check the status of a Mobile "+"Service named '{2}', but it has not loaded the definition of that service.";msg.msgs.jsdoMSG044="JSDO: In '{1}' function, {2} is missing {3} property.";msg.msgs.jsdoMSG045="JSDO: {1} function: {2} is missing {3} property.";msg.msgs.jsdoMSG046="JSDO: {1} operation is not defined.";msg.msgs.jsdoMSG047="{1} timeout expired.";msg.msgs.jsdoMSG048="{1}: {2} method has argument '{3}' that is missing property '{4}'.";msg.msgs.jsdoMSG049="{1}: Unexpected error calling {2}: {3}";msg.msgs.jsdoMSG050="No token returned from server";msg.msgs.jsdoMSG051="{1} The login method was not executed because the AuthenticationProvider is already logged in.";msg.msgs.jsdoMSG052="{1}: The login method was not executed because no credentials were supplied.";msg.msgs.jsdoMSG053="{1}: {2} was not executed because the AuthenticationProvider is not logged in.";msg.msgs.jsdoMSG054="{1}: Token refresh was not executed because the AuthenticationProvider does not have a refresh token.";msg.msgs.jsdoMSG055="{1}: Token refresh was not executed because the authentication model is not sso.";msg.msgs.jsdoMSG056="{1}: Already logged in.";msg.msgs.jsdoMSG057="{1}: Cannot call {2} when authenticationModel is SSO. Please use the AuthenticationProvider object instead.";msg.msgs.jsdoMSG058="{1}: Cannot pass username and password to addCatalog when authenticationModel "+"is sso. Pass an AuthenticationProvider instead.";msg.msgs.jsdoMSG059="{1}: Error in constructor. The authenticationModels of the "+"AuthenticationProvider ({2}) and the JSDOSession ({3}) were not compatible.";msg.msgs.jsdoMSG060="AuthenticationProvider: AuthenticationProvider is no longer logged in. "+"Tried to refresh SSO token but failed due to authentication error at token server.";msg.msgs.jsdoMSG061="{1}: Attempted to set {2} property to an invalid value.";msg.msgs.jsdoMSG062="{1}: Cannot call {2} when an AuthenticationProvider is already available and logged in.";msg.msgs.jsdoMSG100="JSDO: Unexpected HTTP response. Too many records.";msg.msgs.jsdoMSG101="Network error while executing HTTP request.";msg.msgs.jsdoMSG110="Catalog error: idProperty not specified for resource '{1}'. "+"idProperty is required {2}.";msg.msgs.jsdoMSG111="Catalog error: Schema '{1}' was not found in catalog.";msg.msgs.jsdoMSG112="Catalog error: Output parameter '{1}' was not found for operation '{2}'.";msg.msgs.jsdoMSG113="Catalog error: Found xType '{1}' for output parameter '{2}' "+"for operation '{3}' but xType DATASET, TABLE or ARRAY was expected.";msg.msgs.jsdoMSG114="JSDO: idProperty '{1}' is missing from '{2}' record.";msg.msgs.jsdoMSG115="JSDO: Invalid option specified in {1}() call.";msg.msgs.jsdoMSG116="JSDO: {1} parameter must be a string in {2} call.";msg.msgs.jsdoMSG117="JSDO: Schema from storage area '{1}' does not match JSDO schema";msg.msgs.jsdoMSG118="JSDO: Plugin '{1}' was not found.";msg.msgs.jsdoMSG119="JSDO: A mappingType is expected when 'capabilities' is set."+" Please specify a plugin (ex: JFP).";msg.msgs.jsdoMSG120="JSDO: Parameter '{2}' requires capability '{1}' in the catalog.";msg.msgs.jsdoMSG121="{1}: Argument {2} must be of type {3} in {4} call.";msg.msgs.jsdoMSG122="{1}: Incorrect number of arguments in {2} call. There should be {3}.";msg.msgs.jsdoMSG123="{1}: A server response included an invalid '{2}' header.";msg.msgs.jsdoMSG124="JSDO: autoApplyChanges is not supported for saveChanges(true) "+"with a temp-table. Use jsdo.autoApplyChanges = false.";msg.msgs.jsdoMSG125="{1}: The AuthenticationProvider is not managing valid credentials.";msg.msgs.jsdoMSG126="{1}: No support for {2}.";msg.msgs.jsdoMSG127="JSDO: acceptRowChanges() cannot be called for record with _rejected === true.";msg.msgs.jsdoMSG500="{1}: '{2}' objects must contain a '{3}' property.";msg.msgs.jsdoMSG501="{1}: '{2}' in '{3}' function cannot be an empty string.";msg.msgs.jsdoMSG502="{1}: The '{2}' parameter passed to the '{3}' function has an invalid value for "+"its '{4}' property.";msg.msgs.jsdoMSG503="{1}: '{2}' must be of type '{3}'.";msg.msgs.jsdoMSG504="{1}: {2} has an invalid value for the '{3}' property.";msg.msgs.jsdoMSG505="{1}: '{2}' objects must have a '{3}' method.";msg.msgs.jsdoMSG506="{1}: Invalid argument for the {2} parameter in {3} call.";msg.msgs.jsdoMSG507="{1}: '{2}' is an invalid value for the {3} parameter in {4} call.";msg.msgs.jsdoMSG508="JSDOSession: If a JSDOSession object is using the SSO authentication model, "+"the options object passed to its constructor must include an authProvider property.";msg.msgs.jsdoMSG509="progress.data.getSession: If the authenticationModel is AUTH_TYPE_SSO, "+"authenticationURI and authProviderAuthenticationModel are required parameters.";msg.msgs.jsdoMSG510="{1}: This session has been invalidated and cannot be used.";msg.msgs.jsdoMSG511="JSDOSession: addCatalog() can only be called if an AuthenticationProvider was passed as an argument or "+"connect() has been successfully called.";msg.msgs.jsdoMSG512="JSDOSession: Error while loading multiple catalogs.";msg.msgs.jsdoMSG998="JSDO: JSON object in addRecords() must be DataSet or Temp-Table data.";msg.getMsgText=function(n,args){var text=msg.msgs[n],i;if(!text){throw new Error("Message text was not found by getMsgText()")}for(i=1;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true;data=newDataArray}else{if(params&&(params.sort||params.top)){newDataArray=[];for(i=0;i0){sortObject.tableRef=this;data.sort(this._getCompareFn(sortObject))}}if(params.top){if(typeof params.skip=="undefined"){params.skip=0}data=data.splice(params.skip,params.top)}}return data};this._recToDataObject=function(record,includeChildren){var array=[record];var dataObject=array;if(typeof includeChildren=="undefined"){includeChildren=false}if(this._jsdo._dataSetName){dataObject={};dataObject[this._jsdo._dataSetName]={};dataObject[this._jsdo._dataSetName][this._name]=array;if(includeChildren&&this._children.length>0){var jsrecord=this._findById(record._id,false);if(jsrecord){for(var i=0;i0){for(var j=0;j0){for(var i=0;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true};this._equalRecord=function(rec1,rec2,keyFields){var field;var match=true;for(var i=0;ivalue2||(value1===undefined||value1===null))return sortAscending[i]?1:-1;else if(value10)this._sort(sortObject)}else{this._sort(arg1)}this._createIndex()};this._sort=function(arg1){if(arguments.length===0&&(!this.autoSort||this._sortFn===undefined&&this._sortObject.sortFields===undefined))return;if(arguments.length===0){if(this._sortFn){this._data.sort(this._sortFn)}else{this._data.sort(this._compareFields)}this._needsAutoSorting=false}else{if(typeof arg1=="function"){this._data.sort(this._getCompareFn(arg1))}else{arg1.tableRef=this;this._data.sort(this._getCompareFn(arg1))}if(this.autoSort)this._needsAutoSorting=true}};this.addRecords=function(jsonObject,addMode,keyFields,trackChanges,isInvoke){this._jsdo._addRecords(this._name,jsonObject,addMode,keyFields,trackChanges,isInvoke)};this.acceptChanges=function(){var tableRef=this;for(var id in tableRef._beforeImage){if(tableRef._beforeImage[id]===null){var jsrecord=tableRef._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}else if(this._changed[id]!==undefined){var jsrecord=this._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}}tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[];tableRef._beforeImage={}};this.rejectChanges=function(){for(var id in this._beforeImage){if(this._beforeImage[id]===null){this._jsdo._undoCreate(this,id)}else if(this._changed[id]!==undefined){this._jsdo._undoUpdate(this,id,true)}else{this._jsdo._undoDelete(this,id,true)}}var tableRef=this;tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[]};this.hasChanges=function(){return Object.keys(this._beforeImage).length!==0};this.getChanges=function(){var result=[];for(var id in this._beforeImage){var item={rowState:"",record:null};if(this._beforeImage[id]===null){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_CREATE];item.record=this._findById(id,false)}else if(this._changed[id]!==undefined){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_UPDATE];item.record=this._findById(id,false)}else{item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_DELETE];item.record=new progress.data.JSRecord(this,this._beforeImage[id])}result.push(item)}return result};this._clearErrorStrings=function(){var record=null;for(var id in this._beforeImage){if(this._beforeImage[id]===null){record=this._findById(id,false);if(record){delete record.data._errorString}}else{record=this._findById(id,false);if(record){delete record.data._errorString}else{delete this._beforeImage[id]._errorString}}}};this._applyChanges=function(){var i;for(var id in this._beforeImage){if(this._beforeImage[id]===null){var jsrecord=this._findById(id,false);if(jsrecord===null&&this._jsdo._resource.idProperty!==undefined){if(this._tmpIndex[id]){var record=this._data[this._tmpIndex[id].index];jsrecord=record?new progress.data.JSRecord(this,record):null;delete this._tmpIndex[id]}}if(jsrecord!==null){if(jsrecord.data._rejected||jsrecord.data._errorString!==undefined){this._jsdo._undoCreate(this,id)}else{jsrecord.acceptRowChanges()}}else{var found=false;for(var i=0;i0){for(var i=0;iindex){i--}if(i!=index){this._tableRef._data.splice(index,1);this._tableRef._data.splice(i,0,record);this._tableRef._createIndex()}}}};this.assign=function(record){if(record===undefined)throw new Error(msg.getMsgText("jsdoMSG024","JSDO","assign() or update()"));this._saveBeforeImageUpdate();var fieldName,i,j,value,schema=this._tableRef.getSchema(),prefixElement,name;if(record){for(i=0;i0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){return this.record.data[name][element-1]}}return this.record.data[fieldName]}else return null},set:function(value){var name=fieldName,index,element,fieldInfo;if(this.record){this.record._saveBeforeImageUpdate();try{index=fieldName.indexOf(progress.data.JSDO.ARRAY_INDEX_SEPARATOR);if(index>0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){this.record.data[name][element-1]=value;return}}this.record.data[fieldName]=value}finally{this.record._sortRecord(name)}}},enumerable:true,writeable:true})};Object.defineProperty(this,"hasSubmitOperation",{get:function(){return this._hasSubmitOperation},enumerable:true});Object.defineProperty(this,"hasCUDOperations",{get:function(){return this._hasCUDOperations},enumerable:true});Object.defineProperty(this,"defaultTableRef",{get:function(){return this._defaultTableRef},enumerable:true});this._buffers={};this._numBuffers=0;this._defaultTableRef=null;this._async=true;this._dataProperty=null;this._dataSetName=null;this.operations=[];this.useRelationships=true;this._session=null;this._needCompaction=false;this._hasCUDOperations=false;this._hasSubmitOperation=false;this._useSubmit=false;this.autoApplyChanges=true;this._lastErrors=[];this._localStorage=null;this._convertForServer;this._fillMergeMode;var autoFill=false;if(!arguments[0]){throw new Error("JSDO: Parameters are required in constructor.")}if(typeof arguments[0]=="string"){this.name=arguments[0]}else if(typeof arguments[0]=="object"){var args=arguments[0];for(var v in args){switch(v){case"autoFill":autoFill=args[v];break;case"events":this._events={};for(var eventName in args[v]){this._events[eventName.toLowerCase()]=args[v][eventName]}break;case"dataProperty":this._dataProperty=args[v];break;default:this[v]=args[v]}}}if(!this.name){throw new Error("JSDO: JSDO constructor is missing the value for 'name'")}if(this._events){if(typeof this._events!=="object"){throw new Error("JSDO: JSDO constructor event object is not defined as an object")}for(var prop in this._events){var evt=this._events[prop];if(!(evt instanceof Array)){throw new Error("JSDO: JSDO constructor event object for "+prop+" must be an array")}evt.forEach(function(el){if(typeof el!=="object"){throw new Error("JSDO: JSDO constuctor event object for "+prop+" is not defined as an object")}if(typeof el.fn!=="function"){throw new Error("JSDO: JSDO event listener for "+prop+" is not a function.")}if(el.scope&&typeof el.scope!=="object"){throw new Error("JSDO: JSDO event listener scope for "+prop+" is not an object.")}})}}if(this.name){this._resource=progress.data.ServicesManager.getResource(this.name);if(this._resource){if(!this.url)this.url=this._resource.url;if(!this._dataSetName&&this._resource._dataSetName){this._dataSetName=this._resource._dataSetName;if(this._resource.dataProperty){var buffer=this[this._resource.dataProperty]=new progress.data.JSTableRef(this,this._resource.dataProperty);this._buffers[this._resource.dataProperty]=buffer}else{for(var tableName in this._resource.fields){var buffer=this[tableName]=new progress.data.JSTableRef(this,tableName);this._buffers[tableName]=buffer}}}if(!this._dataProperty&&this._resource.dataProperty)this._dataProperty=this._resource.dataProperty;if(!this._dataSetName){var tableName=this._dataProperty?this._dataProperty:"";this._buffers[tableName]=new progress.data.JSTableRef(this,tableName);if(tableName)this[tableName]=this._buffers[tableName]}var properties,tableName;if(this._dataSetName&&this._resource.schema&&this._resource.schema.properties[this._dataSetName]){properties=this._resource.schema.properties[this._dataSetName].properties;if(Object.keys(properties).length===1){tableName=Object.keys(properties)[0];if(properties[tableName].idProperty){this._resource.idProperty=properties[tableName].idProperty}}}else if(this._resource.schema&&this._resource.schema.properties&&this._resource.schema.properties[tableName]&&this._resource.schema.properties[tableName].idProperty){this._resource.idProperty=this._resource.schema.properties[tableName].idProperty}for(var fnName in this._resource.fn){this[fnName]=this._resource.fn[fnName]["function"]}this._hasCUDOperations=this._resource.generic["create"]!==undefined||this._resource.generic["update"]!==undefined||this._resource.generic["delete"]!==undefined;this._hasSubmitOperation=this._resource.generic["submit"]!==undefined;if(!this._session){var myservice=progress.data.ServicesManager.getService(this._resource.service.name);this._session=myservice._session;this._session._pushJSDOs(this)}}else{throw new Error(msg.getMsgText("jsdoMSG004",this.name))}}else{this._buffers[""]=new progress.data.JSTableRef(this,"")}if(!this._session){throw new Error("JSDO: Unable to get user session for resource '"+this.name+"'")}for(var buf in this._buffers){this._buffers[buf]._parent=null;this._buffers[buf]._children=[];this._buffers[buf]._relationship=null;this._buffers[buf]._isNested=false;if(!this._defaultTableRef)this._defaultTableRef=this._buffers[buf];this._numBuffers++}if(this._numBuffers!=1)this._defaultTableRef=null;else{this.record=null}if(typeof Object.defineProperty=="function"){this._caseSensitive=false;Object.defineProperty(this,"caseSensitive",{get:function(){return this._caseSensitive},set:function(value){this._caseSensitive=value?true:false;for(var buf in this._buffers){this._buffers[buf].caseSensitive=this._caseSensitive}},enumerable:true,writeable:true});this._autoSort=true;Object.defineProperty(this,"autoSort",{get:function(){return this._autoSort},set:function(value){this._autoSort=value?true:false;for(var buf in this._buffers){this._buffers[buf].autoSort=this._autoSort}},enumerable:true,writeable:true})}this._properties={};if(typeof Object.defineProperty=="function"){Object.defineProperty(this,"this._properties",{get:function(){return this._properties},enumerable:false})}if(this._resource&&this._resource.fields){for(var buf in this._buffers){this._buffers[buf]._schema=this._resource.fields[buf];this._buffers[buf]._primaryKeys=this._resource.primaryKeys[buf];this._buffers[buf]._fields={};var fields=this._buffers[buf]._schema;for(var i=0;i1){for(var buf in this._buffers){var fields=[];var found=false;for(var i=0;i=0?index+1:"");element.value=value?value[index]:undefined;return element};this.isDataSet=function(){return this._dataSetName?true:false};this._invokeComplete=function(jsdo,success,request){if(request.async&&request.fnName){jsdo.trigger("afterInvoke",request.fnName,jsdo,success,request)}if(request.deferred){if(success){request.deferred.resolve(jsdo,success,request)}else{request.deferred.reject(jsdo,success,request)}}};this._invokeSuccess=function(){};this._invokeError=function(){};this._httpRequest=function(xhr,method,url,reqBody,request){function afterOpenRequest(){var input=null;if(reqBody){xhr.setRequestHeader("Content-Type","application/json; charset=utf-8");input=JSON.stringify(reqBody)}try{xhr.send(input)}catch(e){request.success=false;request.exception=e;xhr.jsdo._session._checkServiceResponse(xhr,request.success,request)}}if(!xhr){xhr=new XMLHttpRequest;xhr.onCompleteFn=this._invokeComplete;xhr.onSuccessFn=this._invokeSuccess;xhr.onErrorFn=this._invokeError;xhr.onreadystatechange=this.onReadyStateChangeGeneric;if(request.async&&request.fnName){this.trigger("beforeInvoke",request.fnName,this,request)}if(reqBody){if(this._resource&&this._resource.service){var useRequest=this._resource.service.useRequest;if(this._resource.service.settings&&this._resource.service.settings.useRequest!==undefined){useRequest=this._resource.service.settings.useRequest}if(useRequest){reqBody={request:reqBody}}}}}xhr.request=request;xhr.jsdo=this;request.jsdo=this;request.xhr=xhr;this._session._openRequest(xhr,method,url,request.async,afterOpenRequest);return request};this._getDataObject=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};var oldUseRelationships=this.useRelationships;try{this.useRelationships=false;for(var buf in this._buffers){dataObject[this._dataSetName][buf]=this._buffers[buf].getData()}}finally{this.useRelationships=oldUseRelationships}}else{if(this._dataProperty){dataObject[this._dataProperty]=this.getData()}else return this.getData()}return dataObject};this._getDataObjectAsNested=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};try{for(var buf in this._buffers){var bufObj=this._buffers[buf];if(bufObj._isNested)continue;this._nestChildren=false;if(bufObj._children.length>0){for(var i=0;i0){hasErrors=true}}if(hasErrors){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._allRecordsRejected=true;this._someRecordsRejected=false;hasCommittedRecords=false;for(i=0;i0&&!param.operations[0].success){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._convertForServer=true;this._buffers[buf]._convertForServer=true}}};this._convertRequestData=function(objParam){var buf,beforeData;if(this._convertForServer===false){return}for(buf in this._buffers){if(this._buffers[buf]._convertForServer){if(objParam[this._dataSetName]){if(objParam[this._dataSetName][buf]){this._convertTableData(this._buffers[buf],objParam[this._dataSetName][buf])}beforeData=objParam[this._dataSetName]["prods:before"];if(beforeData&&beforeData[buf]){this._convertTableData(this._buffers[buf],beforeData[buf])}}else if(objParam[buf]){this._convertTableData(this._buffers[buf],objParam[buf])}}}};this._convertTableData=function(tableRef,tableData){var i;for(i=0;i0){this._confirmOperationExists(progress.data.JSDO._OP_DELETE);checkedDelete=true}if(!checkedCreate&&tableRef._added.length>0){this._confirmOperationExists(progress.data.JSDO._OP_CREATE);checkedCreate=true}if(!checkedUpdate&&Object.keys(tableRef._changed).length>0){this._confirmOperationExists(progress.data.JSDO._OP_UPDATE);checkedUpdate=true}if(checkedDelete&&checkedCreate&&checkedUpdate){break}}};this._confirmOperationExists=function(operation){var operationStr=PROGRESS_JSDO_OP_STRING[operation];if(typeof this._resource.generic[operationStr]!=="function"){throw new Error(msg.getMsgText("jsdoMSG046",operationStr.toUpperCase()))}};this.invoke=function(name,object){var deferred,promise;try{var request=this[name](object);if(request.deferred){deferred=request.deferred;promise=request.deferred.promise()}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{if(!deferred){deferred=new progress.util.Deferred;promise=deferred.promise()}deferred.reject(this,false,{errorObject:error})}}return promise};this._syncTableRef=function(operation,tableRef,batch){var rowData,requestData,jsonObject,dataSetObject;if(tableRef._visited)return;tableRef._visited=true;if(!batch){batch={operations:[]}}else if(!batch.operations){batch.operations=[]}switch(operation){case progress.data.JSDO._OP_CREATE:for(var i=0;i0&&!dataSetJsonObject[tableRef._name])dataSetJsonObject[tableRef._name]=[];for(var i=0;i0||tableRef._added.length>0||hasUpdates){hasChanges=true;break}}return hasChanges};this._addDeletesToChangeSet=function(tableRef,dataSetJsonObject,request){for(var i=0;i=10){tmpIndex={};for(var i=0;ivalue2||value1===null)return false;else if(value11){for(var buf in this._buffers){if(this._buffers[buf]._isNested&&this._buffers[buf]._parent&&this._buffers[this._buffers[buf]._parent]){var srcData=this._buffers[this._buffers[buf]._parent]._data;var data=[];for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}var recordId=beforeTableJsonObject[0]["prods:clientId"];if(!recordId){throw new Error(msg.getMsgText("jsdoMSG035","_checkForDeleteError()"))}if(beforeTableJsonObject[0]["prods:hasErrors"]){var prods_id=beforeTableJsonObject[0]["prods:id"];var errorString=this._getErrorStringFromJsonObject(dataSetJsonObject,tableRef,prods_id);this._setErrorString(tableRef,recordId,errorString,true);hasError=true}}return hasError};this._mergeUpdateForSubmit=function(jsonObject,xhr){var errorString;if(!this._dataSetName){throw new Error(msg.getMsgText("jsdoMSG036","_mergeUpdateForSubmit()"))}var dataSetJsonObject=jsonObject[this._dataSetName];if(dataSetJsonObject[this._dataSetName])dataSetJsonObject=dataSetJsonObject[this._dataSetName];var beforeJsonObject=dataSetJsonObject["prods:before"];for(var buf in this._buffers){var tableRef=this._buffers[buf];var tableJsonObject=dataSetJsonObject[tableRef._name];if(tableJsonObject instanceof Array){for(var i=0;i1){request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}}if(beforeJsonObject){hasError=jsdo._checkForDeleteError(dataSetJsonObject,xhr)}if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._deleteError(jsdo,success,request)}}};this._deleteError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoDelete(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._createComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterCreate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterCreate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._createSuccess=function(jsdo,success,request){var xhr=request.xhr;var record=request.response;var hasError=jsdo._mergeUpdateForCUD(record,xhr);if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._createError(jsdo,success,request)}}};this._createError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoCreate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._updateComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterUpdate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterUpdate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._updateSuccess=function(jsdo,success,request){var xhr=request.xhr;var hasError=jsdo._mergeUpdateForCUD(request.response,xhr);if(hasError){request.success=false}if(jsdo.autoApplyChanges){if(!hasError){request.success=true;delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._updateError(jsdo,success,request)}}};this._updateError=function(jsdo,success,request){if(jsdo.autoApplyChanges){request.success=false;jsdo._undoUpdate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._saveChangesSuccess=function(jsdo,success,request){var records=request.response;jsdo._mergeUpdateForSubmit(records,request.xhr);jsdo._clearErrors();var changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(changes);if(jsdo.autoApplyChanges){jsdo._applyChanges()}};this._saveChangesError=function(jsdo,success,request){jsdo._setAllRecordsRejected(true);if(jsdo.autoApplyChanges){jsdo.rejectChanges()}jsdo._updateLastErrors(jsdo,null,null,request)};this._saveChangesSuccessTT=function(jsdo,success,request){var changes;jsdo._clearErrors();changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(false)};this._saveChangesComplete=function(jsdo,success,request){if(request.xhr.status>=200&&request.xhr.status<300&&(jsdo._lastErrors.length>0||jsdo._someRecordsRejected)){request.success=false}if(jsdo._useSubmit===true){jsdo._fireCUDTriggersForSubmit(request)}jsdo._undefWorkingRecord();jsdo._fireAfterSaveChanges(request.success,request)};this._fireAfterSaveChanges=function(success,request){this.trigger("afterSaveChanges",this,success,request);if(request.jsrecords){if(request.deferred){if(success){request.deferred.resolve(this,success,request)}else{request.deferred.reject(this,success,request)}}}else if(request.batch&&request.batch.deferred){if(success){request.batch.deferred.resolve(this,success,request)}else{request.batch.deferred.reject(this,success,request)}}var clearErrorString=this.autoApplyChanges;if(request.jsrecords){for(var idx=0;idx=400&&request.xhr.status<600){try{var responseObject=JSON.parse(request.xhr.responseText);if(responseObject instanceof Array){errorArray=responseObject}else if(responseObject instanceof Object){errorArray.push(responseObject)}for(i=0;i=400&&request.xhr.status<600)){errors.push({type:progress.data.JSDO.ERROR,error:"Error: HTTP Status "+request.xhr.status+" "+request.xhr.statusText,responseText:request.xhr.responseText})}}return errors};this._updateLastErrors=function(jsdo,batch,changes,request){var errors,errorText,responseObject,i,j,buf;if(batch){if(batch.operations===undefined)return;for(i=0;i=200&&request.xhr.status<300){jsdo._lastErrors.push({errorString:request.jsrecord.data._errorString});jsdo._buffers[request.jsrecord._tableRef._name]._lastErrors.push({type:progress.data.JSDO.DATA_ERROR,id:request.jsrecord.data._id,error:request.jsrecord.data._errorString})}else{errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}if(request.jsrecord&&(errors[j].type===progress.data.JSDO.APP_ERROR||errors[j].type===progress.data.JSDO.RETVAL)){errors[j].id=request.jsrecord.data._id;request.jsrecord._tableRef._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}}}}else if(changes instanceof Array){for(i=0;i=400&&request.xhr.status<600||request.xhr.status===0)){errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}for(buf in this._buffers){this._buffers[buf]._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}};this._checkSaveComplete=function(xhr){if(xhr.request){var jsdo=xhr.request.jsdo;var batch=xhr.request.batch;if(jsdo&&batch&&jsdo._async){if(jsdo._isBatchComplete(batch)){var success=jsdo._isBatchSuccess(batch);var request={batch:batch,success:success};jsdo._undefWorkingRecord();jsdo._lastErrors=[];if(!success&&batch.operations){jsdo._updateLastErrors(jsdo,batch,null)}this._setAllRecordsRejected(batch);jsdo._fireAfterSaveChanges(success,request)}}}};this._isBatchSuccess=function(batch){if(batch.operations){for(var i=0;i=200&&xhr.status<300||xhr.status===0&&xhr.responseText!==""){request.success=true;xhr.jsdo._session._saveClientContextId(xhr);if(typeof xhr.onSuccessFn=="function"){var operation;if(xhr.request.fnName!==undefined&&xhr.jsdo._resource.fn[xhr.request.fnName]!==undefined){operation=xhr.jsdo._resource.fn[xhr.request.fnName].operation}else operation=null;if(operation===undefined||operation!==null&&operation.mergeMode)xhr.jsdo._mergeInvoke(request.response,xhr);if(request.success)xhr.onSuccessFn(xhr.jsdo,request.success,request);else if(typeof xhr.onErrorFn=="function")xhr.onErrorFn(xhr.jsdo,request.success,request)}}else{request.success=false;if(xhr.status===0){request.exception=new Error(msg.getMsgText("jsdoMSG101"))}if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}xhr.jsdo._session._checkServiceResponse(xhr,request.success,request);if(typeof xhr.onCompleteFn=="function"){xhr.onCompleteFn(xhr.jsdo,request.success,request)}}};this.acceptChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].acceptChanges()}};this.rejectChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].rejectChanges()}};this.getChanges=function(){var result=[];for(var buf in this._buffers){var changes=this._buffers[this._buffers[buf]._name].getChanges();result=result.concat(changes)}return result};this.hasChanges=function(){for(var buf in this._buffers){if(this._buffers[this._buffers[buf]._name].hasChanges())return true}return false};this._applyChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name]._applyChanges()}};this.acceptRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.acceptRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","acceptRowChanges()"))};this.rejectRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.rejectRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","rejectRowChanges()"))};this.setProperties=function(propertiesObject){var prop;if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(typeof propertiesObject=="object"){this._properties={};for(prop in propertiesObject){if(propertiesObject.hasOwnProperty(prop)){if(typeof propertiesObject[prop]!=="function"){this._properties[prop]=propertiesObject[prop]}}}}else if(propertiesObject===undefined||propertiesObject===null){this._properties={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"Object","setProperties"))}};this.setProperty=function(propertyName,propertyValue){if(arguments.length<2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(arguments.length!==2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(typeof propertyName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"string","setProperty"))}if(propertyValue===undefined){delete this._properties[propertyName]}else{this._properties[propertyName]=propertyValue}};this.getProperties=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperties",0))}return this._properties};this.getProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}return this._properties[propertyName]};this.saveLocal=function saveLocal(arg1,arg2){var name;var dataMode;if(arguments.length>2){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"||arg1===null||arg1===undefined){name=arg1;dataMode=arg2}else{name=null;dataMode=arg1}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}if(typeof dataMode=="undefined"){dataMode=progress.data.JSDO.ALL_DATA}else{switch(dataMode){case progress.data.JSDO.ALL_DATA:case progress.data.JSDO.CHANGES_ONLY:break;default:throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var dataObj=this._prepareDataObjectForLocalStorage(dataMode);this._localStorage.saveToLocalStorage(name,dataObj)};this.readLocal=function readLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));this._restoreFromLocalStorage(object,progress.data.JSDO.MODE_EMPTY)}return object!==null};this.addLocalRecords=function addLocalRecords(arg1,arg2,arg3){var name;var addMode;var keyFields;if(arguments.length<1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"){name=arg1;addMode=arg2;keyFields=arg3}else{name="jsdo_"+this._resource.service.name+"_"+this._resource.name;addMode=arg1;keyFields=arg2}if(typeof name=="undefined"||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(addMode!=progress.data.JSDO.MODE_REPLACE){throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));try{this._restoreFromLocalStorage(object,addMode,keyFields)}catch(e){var text=e.message;throw new Error(text.replace(new RegExp("addRecords","g"),"addLocalRecords"))}}return object!==null};this._containsPrimaryKeys=function _containsPrimaryKeys(){for(var buf in this._buffers){if(this._buffers[buf]._primaryKeys===null)return false}return true};this._hasMatchingSchema=function _hasMatchingSchema(storageObject){var isValid=true;if(storageObject===null||Object.keys(storageObject).length===0)return true;if(this._dataSetName){if(storageObject[this._dataSetName]){for(var buf in this._buffers)if(storageObject[this._dataSetName][buf]===undefined){isValid=false;break}}else isValid=false}else if(this._dataProperty){storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._dataProperty]===undefined)isValid=false}else{storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._defaultTableRef._name]===undefined)isValid=false}return isValid};this.deleteLocal=function deleteLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}this._localStorage.clearLocalStorage(name)};this._prepareDataObjectForLocalStorage=function(option){var storageObject={};if(this._dataSetName){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet(this._dataSetName);break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet(this._dataSetName,true);break}}else if(this._dataProperty){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}else{switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}return storageObject};this._restoreFromLocalStorage=function(storageObject,addMode,keyFields){if(storageObject&&Object.keys(storageObject).length>0){if(this._dataSetName){for(var buf in this._buffers)this._restoreDataForTable(this._buffers[buf],storageObject,addMode,keyFields)}else this._restoreDataForTable(this._defaultTableRef,storageObject,addMode,keyFields)}else if(addMode===progress.data.JSDO.MODE_EMPTY)this._clearData()};this._restoreDataForTable=function(tableRef,jsonObject,addMode,keyFields){keyFields=keyFields!==undefined?keyFields:tableRef._primaryKeys;if(keyFields===undefined&&this._resource.idProperty){keyFields=[];keyFields[0]=this._resource.idProperty}if(this._dataSetName){var oldUseRelationships=this.useRelationships;this.useRelationships=false;try{tableRef.addRecords(jsonObject,addMode,keyFields)}finally{this.useRelationships=oldUseRelationships}}else{this._dataSetName="_localStorage";tableRef.addRecords(jsonObject,addMode,keyFields);this._dataSetName=null}};this.getMethodProperties=function(operation,name){var idx;if(this._resource._operations){if(this._resource._operations[operation]){return this._resource._operations[operation]}}else{this._resource._operations={}}for(var idx=0;idx1?[params.sort]:[]}sortFields="";for(index=0;index=1?params.filter:undefined}if(params.filter){if(typeof params.filter==="string"){doConversion=false}params.tableRef=tableName;if(doConversion&¶ms.tableRef===undefined){throw new Error(msg.getMsgText("jsdoMSG045","fill() or read()","params","tableRef"))}if(reqCapabilities["filter"].mapping==="ablFilter"){if(doConversion){ablFilter=progress.util._convertToABLWhereString(jsdo._buffers[params.tableRef],params.filter)}else{ablFilter=params.filter}}else if(reqCapabilities["filter"].mapping==="sqlQuery"){if(doConversion){sqlQuery=progress.util._convertToSQLQueryString(jsdo._buffers[params.tableRef],params.filter,true)}else{sqlQuery=params.filter}}}filter=JSON.stringify({ablFilter:ablFilter,sqlQuery:sqlQuery,orderBy:sortFields,skip:params.skip,top:params.top,id:params.id});params={filter:filter}}return params}});if(typeof progress.ui=="undefined")progress.ui={};progress.ui.UITableRef=function UITableRef(tableRef){this._tableRef=tableRef;this._listview=null;this._detailPage=null;this._listviewContent=undefined;this.addItem=function(format){var detailForm;if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._name));if(!this._listview)return;format=format?format:this._listview.format;detailForm=this._detailPage&&this._detailPage.name?this._detailPage.name:"";if(this._listviewContent===undefined){this.clearItems()}var text=this._listview.itemTemplate?this._listview.itemTemplate:progress.ui.UIHelper._itemTemplate;text=text.replace(new RegExp("{__format__}","g"),format);text=text.replace(new RegExp("{__id__}","g"),this._tableRef.record.data._id);text=text.replace(new RegExp("{__page__}","g"),detailForm);for(var field in this._tableRef.record.data){var value=this._tableRef.record.data[field];text=text.replace(new RegExp("{"+field+"}","g"),value!==undefined&&value!==null?value:"")}this._listviewContent+=text};this.clearItems=function(){if(this._listview){this._listviewContent="";var listviewElement=document.getElementById(this._listview.name);if(listviewElement){listviewElement.innerHTML=""}}};this._getFormFieldValue=function(fieldName,detailPageName){var value=null,field;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)value=field.val()}else{field=document.getElementById(fieldName);if(field){value=field.value}}return value};this._setFormField=function(fieldName,value,detailPageName){var field=null;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)field.val(value)}else{field=document.getElementById(fieldName);if(field){field.value=value}}};this.assign=function(detailPageName){if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._tableRef._name));if(arguments.length!==0&&typeof detailPageName!="string")throw new Error(msg.getMsgText("jsdoMSG024","UIHelper","assign()"));this._tableRef.record.assign(null);var fieldName;var schema=this._tableRef.getSchema();for(var i=0;i0){for(var i=0;i0&&fieldName.charAt(0)=="_")continue;if(fields&&fields[fieldName]===undefined)continue;var fieldLabel=this._tableRef._schema[i].title?this._tableRef._schema[i].title:this._tableRef._schema[i].name;var text=this._detailPage&&this._detailPage.fieldTemplate?this._detailPage.fieldTemplate:progress.ui.UIHelper._fieldTemplate;text=text.replace(new RegExp("{__label__}","g"),fieldLabel);text=text.replace(new RegExp("{__name__}","g"),this._tableRef._schema[i].name);htmltext+=text}htmltext+="";fields=null;return htmltext};this.getListViewRecord=function(htmlIElement){var id=htmlIElement.getAttribute("data-id");return this._tableRef.findById(id)};this.getFormRecord=function(detailPageName){var id=this._getFormFieldValue("_id",detailPageName);return this._tableRef.findById(id)};this._getIdOfElement=function(name){if(typeof $=="function"){var element=$("#"+name);if(!element||element.length===0){element=$('[dsid="'+name+'"]');if(element&&element.length==1){var id=element.attr("id");if(id)return id}}}return name};this.setDetailPage=function setDetailPage(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));this._detailPage=obj;this._detailPage.name=this._getIdOfElement(this._detailPage.name)};this.setListView=function setListView(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));if(obj.format&&typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"format"));this._listview=obj;this._listview.name=this._getIdOfElement(this._listview.name);if(!this._listview.format){if(typeof $=="function"){for(var i=0;i{__format__}';progress.ui.UIHelper._defaultFieldTemplate='
'+''+'
';progress.ui.UIHelper._itemTemplate=progress.ui.UIHelper._defaultItemTemplate;progress.ui.UIHelper._fieldTemplate=progress.ui.UIHelper._defaultFieldTemplate;progress.ui.UIHelper.setItemTemplate=function(template){progress.ui.UIHelper._itemTemplate=template?template:progress.ui.UIHelper._defaultItemTemplate};progress.ui.UIHelper.setFieldTemplate=function(template){progress.ui.UIHelper._fieldTemplate=template?template:progress.ui.UIHelper._defaultFieldTemplate}})();(function(){if(progress===undefined){progress={}}if(progress.data===undefined){progress.data={}}progress.data.ServicesManager={};progress.data.ServicesManager._services=[];progress.data.ServicesManager._resources=[];progress.data.ServicesManager._data=[];progress.data.ServicesManager._sessions=[];progress.data.ServicesManager._jsdosessions=[];progress.data.ServicesManager.addResource=function(id,resource){if(progress.data.ServicesManager._resources[id]===undefined){progress.data.ServicesManager._resources[id]=resource}else{throw new Error("A resource named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getResource=function(id){return progress.data.ServicesManager._resources[id]};progress.data.ServicesManager.addService=function(id,service){if(progress.data.ServicesManager._services[id]===undefined){progress.data.ServicesManager._services[id]=service}else{throw new Error("A service named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getService=function(id){return progress.data.ServicesManager._services[id]};progress.data.ServicesManager.addSession=function(catalogURI,session){if(progress.data.ServicesManager._sessions[catalogURI]===undefined){progress.data.ServicesManager._sessions[catalogURI]=session}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.addJSDOSession=function(catalogURI,jsdosession){if(progress.data.ServicesManager._jsdosessions[catalogURI]===undefined){progress.data.ServicesManager._jsdosessions[catalogURI]=jsdosession}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.getSession=function(catalogURI){try{return progress.data.ServicesManager._sessions[catalogURI]}catch(e){return null}};progress.data.ServicesManager.cleanSession=function(session){var servicesKey,resourcesKey,sessionsKey,service,services=progress.data.ServicesManager._services,resources=progress.data.ServicesManager._resources,sessions=progress.data.ServicesManager._sessions,jsdosessions=progress.data.ServicesManager._jsdosessions;for(servicesKey in services){service=null;if(services[servicesKey]._session===session){service=services[servicesKey];delete services[servicesKey]}if(!service){continue}for(resourcesKey in resources){if(resources[resourcesKey].service===service){delete resources[resourcesKey]}}}for(sessionsKey in sessions){if(sessions[sessionsKey]===session){delete sessions[sessionsKey];if(jsdosessions[sessionsKey]){delete jsdosessions[sessionsKey]}}}};function extractParamsFromURL(url){var urlParams=[],paramName=null;if(typeof url==="string"){url.split("").forEach(function(c){if(c==="{"){paramName=""}else if(c==="}"){if(paramName){urlParams.push(paramName)}paramName=null}else if(paramName!==null){paramName+=c}})}return urlParams}progress.data.ServicesManager.addCatalog=function(services,session){var name,value;if(!services){throw new Error("Cannot find 'services' property in catalog file.")}if(services instanceof Array){services.forEach(function(service){if(progress.data.ServicesManager.getService(service.name)!==undefined){throw new Error("A service named '"+service.name+"' was already loaded.")}if(service.resources instanceof Array){service.resources.forEach(function(resource){if(progress.data.ServicesManager.getResource(resource.name)!==undefined){throw new Error("A resource named '"+resource.name+"' was already loaded.")}})}else{throw new Error("Missing 'resources' array in catalog.")}});for(var j=0;j1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","setContext",1))}if(typeof context==="object"){contextObject={};for(prop in context){if(context.hasOwnProperty(prop)){if(typeof context[prop]!=="function"){contextObject[prop]=context[prop]}}}}else if(context===undefined||context===null){contextObject={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","Session",1,"Object","setContextProperty"))}contextString=null};this.getContext=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContext",0))}return contextObject};this.getContextProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}return contextObject[propertyName]}};progress.data.Session=function Session(options){var defPropSupported=false;if(typeof Object.defineProperty==="function"){defPropSupported=true}var that=this,jsdosession,isUserAgentiOS=false,isFirefox=false,isEdge=false,isIE=false,canPassCredentialsToOpenWithCORS=false,defaultiOSBasicAuthTimeout=4e3,deviceIsOnline=true,restApplicationIsOnline=false,oepingAvailable=false,defaultPartialPingURI="/rest/_oeping",partialPingURI=defaultPartialPingURI,_storageKey,_authProvider=null,customCredentials=false,storedAuthModel,storedURI,newURI,stateWasReadFromStorage=false;if(!options||options._silent!==true){console.warn("Session: As of JSDO 4.4, the Session object has been deprecated. "+"Please use the JSDOSession object instead.")}if(typeof navigator!=="undefined"){if(typeof navigator.userAgent!=="undefined"){isUserAgentiOS=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i);isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;isEdge=navigator.userAgent.indexOf("Edge/")>-1;isIE=navigator.userAgent.indexOf("Trident/")>-1||navigator.userAgent.indexOf("MSIE 10")>-1}}canPassCredentialsToOpenWithCORS=!(isFirefox||isEdge||isIE);function canPassCredentialsToOpen(){return canPassCredentialsToOpenWithCORS}this._onlineHandler=function(){setDeviceIsOnline(true);that.trigger("online",that,null)};this._offlineHandler=function(){setDeviceIsOnline(false);that.trigger("offline",that,progress.data.Session.DEVICE_OFFLINE,null)};if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("online",this._onlineHandler,false);window.addEventListener("offline",this._offlineHandler,false)}var _catalogURIs=[];var _services=[];var _jsdos=[];this.onOpenRequest=null;var _password=null;if(defPropSupported){var _userName=null;Object.defineProperty(this,"userName",{get:function(){return _userName},enumerable:true});var _loginTarget="/static/home.html";Object.defineProperty(this,"loginTarget",{get:function(){return _loginTarget},enumerable:true});var _serviceURI=null;Object.defineProperty(this,"serviceURI",{get:function(){return _serviceURI},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _catalogURIs},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _services},enumerable:true});var _loginResult=null;Object.defineProperty(this,"loginResult",{get:function(){return _loginResult},enumerable:true});var _loginHttpStatus=null;Object.defineProperty(this,"loginHttpStatus",{get:function(){return _loginHttpStatus},enumerable:true});var _clientContextId=null;Object.defineProperty(this,"clientContextId",{get:function(){return _clientContextId},enumerable:true});var _authenticationModel=progress.data.Session.AUTH_TYPE_ANON;Object.defineProperty(this,"authenticationModel",{get:function(){return _authenticationModel},set:function(newval){if(newval){newval=newval.toLowerCase()}switch(newval){case progress.data.Session.AUTH_TYPE_FORM:case progress.data.Session.AUTH_TYPE_BASIC:case progress.data.Session.AUTH_TYPE_ANON:case progress.data.Session.AUTH_TYPE_SSO:case null:_authenticationModel=newval;storeSessionInfo("authenticationModel",newval);break;default:throw new Error("Error setting Session.authenticationModel. '"+newval+"' is an invalid value.")}},enumerable:true});var _lastSessionXHR=null;Object.defineProperty(this,"lastSessionXHR",{get:function(){return _lastSessionXHR},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return this.loginResult===progress.data.Session.LOGIN_SUCCESS&&restApplicationIsOnline&&deviceIsOnline},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _jsdos},enumerable:true});var _pingInterval=0;var _timeoutID=null;Object.defineProperty(this,"pingInterval",{get:function(){return _pingInterval},set:function(newval){if(typeof newval==="number"&&newval>=0){_pingInterval=newval;storeSessionInfo("pingInterval",newval);if(newval>0){if(this.loginResult===progress.data.Session.LOGIN_SUCCESS){_timeoutID=setTimeout(this._autoping,newval)}}else if(newval===0){clearTimeout(_timeoutID);_pingInterval=0}}else{throw new Error("Error setting Session.pingInterval. '"+newval+"' is an invalid value.")}},enumerable:true});var _contextProperties=new progress.data.ContextProperties;Object.defineProperty(this,"_contextProperties",{get:function(){return _contextProperties},enumerable:false});var isInvalidated=false;Object.defineProperty(this,"_isInvalidated",{get:function(){return isInvalidated},enumerable:false});Object.defineProperty(this,"_authProvider",{get:function(){return _authProvider},set:function(newval){if(_authProvider){throw new Error("Internal Error setting Session._authProvider. '"+"The property has already been set.")}setAuthProvider(newval)},enumerable:false})}else{this.userName=null;this.loginTarget="/static/home.html";this.serviceURI=null;this.catalogURIs=[];this.services=[];this.loginResult=null;this.loginHttpStatus=null;this.clientContextId=null;this.authenticationModel=progress.data.Session.AUTH_TYPE_ANON;this.lastSessionXHR=null}function storeSessionInfo(infoName,value){var key;if(that.loginResult===progress.data.Session.LOGIN_SUCCESS&&typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}if(typeof value!=="undefined"){sessionStorage.setItem(key,JSON.stringify(value))}}}function retrieveSessionInfo(infoName){var key,jsonStr,value=null;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}jsonStr=sessionStorage.getItem(key);if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}}function clearSessionInfo(infoName){var key;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName;sessionStorage.removeItem(key)}}}function storeAllSessionInfo(){if(_storageKey){storeSessionInfo("loginResult",that.loginResult);storeSessionInfo("userName",that.userName);storeSessionInfo("serviceURI",that.serviceURI);storeSessionInfo("loginHttpStatus",that.loginHttpStatus);storeSessionInfo("authenticationModel",that.authenticationModel);storeSessionInfo("pingInterval",that.pingInterval);storeSessionInfo("oepingAvailable",oepingAvailable);storeSessionInfo("partialPingURI",partialPingURI);storeSessionInfo("clientContextId",that.clientContextId);storeSessionInfo("deviceIsOnline",deviceIsOnline);storeSessionInfo("restApplicationIsOnline",restApplicationIsOnline);if(that._authProvider){storeSessionInfo("_authProvider.init",{uri:that._authProvider.uri,authenticationModel:that._authProvider.authenticationModel})}storeSessionInfo(_storageKey,true)}}function clearAllSessionInfo(){if(_storageKey){if(retrieveSessionInfo(_storageKey)){clearSessionInfo("loginResult");clearSessionInfo("userName");clearSessionInfo("serviceURI");clearSessionInfo("loginHttpStatus");clearSessionInfo("clientContextId");clearSessionInfo("deviceIsOnline");clearSessionInfo("restApplicationIsOnline");clearSessionInfo("authenticationModel");clearSessionInfo("pingInterval");clearSessionInfo("oepingAvailable");clearSessionInfo("partialPingURI");clearSessionInfo("_authProvider.init");clearSessionInfo(_storageKey)}}}function setSessionInfoFromStorage(key){var authproviderInitObject;if(retrieveSessionInfo(key)){setLoginResult(retrieveSessionInfo("loginResult"),this);setUserName(retrieveSessionInfo("userName"),this);setServiceURI(retrieveSessionInfo("serviceURI"),this);setLoginHttpStatus(retrieveSessionInfo("loginHttpStatus"),this);setClientContextID(retrieveSessionInfo("clientContextId"),this);setDeviceIsOnline(retrieveSessionInfo("deviceIsOnline"));setRestApplicationIsOnline(retrieveSessionInfo("restApplicationIsOnline"));that.authenticationModel=retrieveSessionInfo("authenticationModel");that.pingInterval=retrieveSessionInfo("pingInterval");setOepingAvailable(retrieveSessionInfo("oepingAvailable"));setPartialPingURI(retrieveSessionInfo("partialPingURI"));if(!that._authProvider){authproviderInitObject=retrieveSessionInfo("_authProvider.init");if(authproviderInitObject){setAuthProvider(new progress.data.AuthenticationProvider(authproviderInitObject))}}}}function setUserName(newname,sessionObject){if(defPropSupported){_userName=newname}else{sessionObject.userName=newname}storeSessionInfo("userName",newname)}function setLoginTarget(target,sessionObject){if(defPropSupported){_loginTarget=target}else{sessionObject.loginTarget=target}}function setServiceURI(url,sessionObject){if(defPropSupported){_serviceURI=url}else{sessionObject.serviceURI=url}storeSessionInfo("serviceURI",url)}function pushCatalogURIs(url,sessionObject){if(defPropSupported){_catalogURIs.push(url)}else{sessionObject.catalogURIs.push(url)}}function pushService(serviceObject,sessionObject){if(defPropSupported){_services.push(serviceObject)}else{sessionObject.services.push(serviceObject)}}function findService(serviceName){_services.forEach(function(service){if(service.name===serviceName){return service}});return null}function setLoginResult(result,sessionObject){if(defPropSupported){_loginResult=result}else{sessionObject.loginResult=result}if(result===progress.data.Session.LOGIN_SUCCESS){storeSessionInfo("loginResult",result)}else{clearAllSessionInfo()}}function setLoginHttpStatus(status,sessionObject){if(defPropSupported){_loginHttpStatus=status}else{sessionObject.loginHttpStatus=status}storeSessionInfo("loginHttpStatus",status)}function setClientContextIDfromXHR(xhr,sessionObject){if(xhr){setClientContextID(getResponseHeaderNoError(xhr,"X-CLIENT-CONTEXT-ID"),sessionObject)}}function setClientContextID(ccid,sessionObject){if(defPropSupported){_clientContextId=ccid}else{sessionObject.clientContextId=ccid}storeSessionInfo("clientContextId",ccid)}function setLastSessionXHR(xhr,sessionObject){if(defPropSupported){_lastSessionXHR=xhr}else{sessionObject.lastSessionXHR=xhr}}function setDeviceIsOnline(value){deviceIsOnline=value;storeSessionInfo("deviceIsOnline",value)}function setAuthProvider(value){_authProvider=value?value:null}function setRestApplicationIsOnline(value){restApplicationIsOnline=value;storeSessionInfo("restApplicationIsOnline",value)}function setOepingAvailable(value){oepingAvailable=value;storeSessionInfo("oepingAvailable",value)}function setPartialPingURI(value){partialPingURI=value;storeSessionInfo("partialPingURI",value)}function getResponseHeaderNoError(xhr,headerName){var allHeaders=xhr._pdsResponseHeaders,regExp;if(allHeaders===undefined){allHeaders=xhr.getAllResponseHeaders();if(allHeaders){xhr._pdsResponseHeaders=allHeaders}else{xhr._pdsResponseHeaders=null}}if(allHeaders){regExp=new RegExp("^"+headerName+":","mi");if(allHeaders.match(regExp)){return xhr.getResponseHeader(headerName)}}return null}this._pushJSDOs=function(jsdo){_jsdos.push(jsdo)};this._openRequest=function(xhr,verb,url,async,callback){var urlPlusCCID,that=this;function afterOpenAndAuthorize(arg){if(arg instanceof Error){throw arg}else{if(that.clientContextId&&that.clientContextId!=="0"){xhr.setRequestHeader("X-CLIENT-CONTEXT-ID",that.clientContextId)}setRequestHeaderFromContextProps(that,xhr);if(typeof that.onOpenRequest==="function"){var params={xhr:xhr,verb:verb,uri:urlPlusCCID,async:async,formPreTest:false,session:that};that.onOpenRequest(params)}if(callback){callback()}}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to make server request when there is no active session.")}urlPlusCCID=this._prependAppURL(url);urlPlusCCID=this._addCCIDtoURL(urlPlusCCID);if(progress.data.Session._useTimeStamp){urlPlusCCID=progress.data.Session._addTimeStampToURL(urlPlusCCID)}if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,verb,urlPlusCCID,async,afterOpenAndAuthorize)}else{this._setXHRCredentials(xhr,verb,urlPlusCCID,this.userName,_password,async);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json")}afterOpenAndAuthorize(xhr)}};this.pingTestCallback=function(cbArgs){var foundOeping=cbArgs.pingResult?true:false;setOepingAvailable(foundOeping)};this._onReadyStateChangeGeneric=function(){var xhr=this;var result;var errorObject;clearTimeout(xhr._requestTimeout);if(xhr.readyState===4){result=null;errorObject=null;if(typeof xhr.onResponseFn==="function"){try{result=xhr.onResponseFn(xhr)}catch(e){errorObject=e}}if(typeof xhr.onResponseProcessedFn==="function"){if(!result){result=progress.data.Session.GENERAL_FAILURE}xhr.onResponseProcessedFn(xhr.pdsession,result,errorObject,xhr)}}};this._disconnect=function(deferred){this._processDisconnectResult(null,deferred)};this._processDisconnectResult=function(xhr,deferred){this._reinitializeAfterLogout(this,progress.data.Session.SUCCESS);this._disconnectComplete(this,progress.data.Session.SUCCESS,null,null,deferred)};this._disconnectComplete=function(pdsession,result,errObj,xhr,deferred){pdsession.trigger("afterDisconnect",pdsession,result,errObj,xhr,deferred)};var pwSave=null;var unameSave=null;this.login=function(serviceURI,loginUserName,loginPassword,loginTarget){var uname,pw,isAsync=false,args=[],deferred,iOSBasicAuthTimeout,uriForRequest;pwSave=null;unameSave=null;if(!defPropSupported){this.authenticationModel=this.authenticationModel.toLowerCase()}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","login()"))}if(this.loginResult===progress.data.Session.LOGIN_SUCCESS||this._authProvider){throw new Error("Attempted to call login() on a Session object that is already logged in.")}if(arguments.length>0){if(arguments[0]&&typeof arguments[0]==="object"){args[0]=arguments[0].serviceURI;args[1]=arguments[0].userName;args[2]=arguments[0].password;args[3]=arguments[0].loginTarget;args[4]=arguments[0].async;deferred=arguments[0].deferred;iOSBasicAuthTimeout=arguments[0].iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","login","The iOSBasicAuthTimeout argument was invalid."))}}else{args=arguments}}if(args.length>0){if(args[0]){var restURLtemp=args[0];if(restURLtemp[restURLtemp.length-1]==="/"){restURLtemp=restURLtemp.substring(0,restURLtemp.length-1)}setServiceURI(restURLtemp,this)}else if(!this.serviceURI){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}if(args[1]){uname=args[1]}if(args[2]){pw=args[2]}if(args[3]){setLoginTarget(args[3],this)}if(args[4]){if(typeof args[4]==="boolean"){isAsync=args[4]}else{throw new Error("Session.login() was passed an async setting that is not a boolean.")}}}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}unameSave=uname;pwSave=pw;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON||this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){uname=null;pw=null}var xhr=new XMLHttpRequest;xhr.pdsession=this;try{uriForRequest=this.serviceURI+this.loginTarget;if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(uriForRequest)}this._setXHRCredentials(xhr,"GET",uriForRequest,uname,pw,isAsync);progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(this,xhr);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr._isAsync=isAsync;if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){xhr.onResponseFn=this._afterFormPretestLogin}else{xhr.onResponseFn=this._processLoginResult;xhr.onResponseProcessedFn=this._loginComplete}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout>0){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred}if(typeof this.onOpenRequest==="function"){var isFormPreTest=false;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){isFormPreTest=true}setLastSessionXHR(xhr,this);var params={xhr:xhr,verb:"GET",uri:this.serviceURI+this.loginTarget,async:false,formPreTest:isFormPreTest,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send(null)}catch(e){clearTimeout(xhr._requestTimeout);setLoginHttpStatus(xhr.status,this);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);unameSave=null;pwSave=null;throw e}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{setLoginHttpStatus(xhr.status,this);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){return this._afterFormPretestLogin(xhr)}else{return this._processLoginResult(xhr)}}};this._afterFormPretestLogin=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);var formLoginParams={xhr:xhr,pw:pwSave,uname:unameSave,theSession:pdsession};try{return doFormLogin(formLoginParams)}catch(e){pwSave=null;unameSave=null;throw e}};function doFormLogin(args){var xhr=args.xhr;var theSession=args.theSession;var oldXHR;var contentType=null;var needAuth=false;var params={session:theSession,xhr:xhr,statusFromjson:null};contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson||params.statusFromjson>=400&¶ms.statusFromjson<500){needAuth=true}else{setLoginHttpStatus(params.statusFromjson,theSession)}}else{if(theSession.loginHttpStatus===200){if(_gotLoginForm(xhr)){needAuth=true}}}if(needAuth){oldXHR=xhr;xhr=new XMLHttpRequest;args.xhr=xhr;params.xhr=xhr;xhr.pdsession=oldXHR.pdsession;xhr._isAsync=oldXHR._isAsync;xhr._deferred=oldXHR._deferred;xhr._jsdosession=oldXHR._jsdosession;xhr.open("POST",theSession.serviceURI+"/static/auth/j_spring_security_check",xhr._isAsync);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.setRequestHeader("Cache-Control","max-age=0");setRequestHeaderFromContextProps(theSession,xhr);_addWithCredentialsAndAccept(xhr,"application/json");try{if(typeof theSession.onOpenRequest==="function"){var cbparams={xhr:xhr,verb:"POST",uri:theSession.serviceURI+"/static/auth/j_spring_security_check",async:xhr._isAsync,formPreTest:false,session:theSession};theSession.onOpenRequest(cbparams);xhr=cbparams.xhr}if(xhr._isAsync){xhr.onreadystatechange=theSession._onReadyStateChangeGeneric;xhr.onResponseFn=theSession._afterFormLogin;xhr.onResponseProcessedFn=theSession._loginComplete}xhr.send("j_username="+encodeURIComponent(args.uname)+"&j_password="+encodeURIComponent(args.pw)+"&submit=Submit")}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,theSession);setLoginHttpStatus(xhr.status,theSession);unameSave=null;pwSave=null;throw e}}if(xhr._isAsync&&!needAuth){xhr.onResponseProcessedFn=theSession._loginComplete;return theSession._afterFormLogin(xhr)}if(!xhr._isAsync){return theSession._afterFormLogin(xhr)}}this._afterFormLogin=function(xhr){var theSession=xhr.pdsession;var params={session:theSession,xhr:xhr,statusFromjson:null};var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson){throw new Error("Internal OpenEdge Mobile client error handling login response. HTTP status: "+xhr.status+".")}setLoginHttpStatus(params.statusFromjson,theSession)}else{if(xhr.status===200){if(_gotLoginFailure(xhr)||_gotLoginForm(xhr)){setLoginHttpStatus(401,theSession)}else{setLoginHttpStatus(xhr.status,theSession)}}}return theSession._processLoginResult(xhr)};this._processLoginResult=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);if(pdsession.loginHttpStatus===200){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);setUserName(unameSave,pdsession);_password=pwSave;pdsession._saveClientContextId(xhr);storeAllSessionInfo();var pingTestArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:pdsession._pingtestOnReadyStateChange};pingTestArgs.pingURI=pdsession._makePingURI();pdsession._sendPing(pingTestArgs)}else{if(pdsession.loginHttpStatus===401){setLoginResult(progress.data.Session.LOGIN_AUTHENTICATION_FAILURE,pdsession)}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);unameSave=null;pwSave=null;if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","login"))}return pdsession.loginResult};this._loginComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterLogin",pdsession,result,errObj,xhr)};this.logout=function(args){var isAsync=false,errorObject=null,xhr,deferred,params;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","logout()"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&this.authenticationModel){throw new Error("Attempted to call logout when there is no active session.")}if(typeof args==="object"){isAsync=args.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","logout","The async argument was invalid."))}deferred=args.deferred}xhr=new XMLHttpRequest;xhr.pdsession=this;try{xhr._jsdosession=jsdosession;xhr._deferred=deferred;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM||this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;xhr.onResponseFn=this._processLogoutResult;xhr.onResponseProcessedFn=this._logoutComplete}xhr.open("GET",this.serviceURI+"/static/auth/j_spring_security_logout",isAsync);try{xhr.withCredentials=true}catch(e){}xhr.setRequestHeader("Accept","application/json");setRequestHeaderFromContextProps(this,xhr);if(typeof this.onOpenRequest==="function"){setLastSessionXHR(xhr,this);params={xhr:xhr,verb:"GET",uri:this.serviceURI+"/static/auth/j_spring_security_logout",async:false,formPreTest:false,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send()}else{xhr._anonymousLogoutOK=true}}catch(e){this._reinitializeAfterLogout(this,false);throw e}if(!isAsync){try{this._processLogoutResult(xhr)}catch(e){throw e}}if(isAsync&&this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){try{this._processLogoutResult(xhr)}catch(e){errorObject=e}this._logoutComplete(this,null,errorObject,xhr)}};this.invalidate=function(){isInvalidated=true;cleanServicesManager()};this._logoutComplete=function(pdsession,result,errorObject,xhr){pdsession.trigger("afterLogout",pdsession,errorObject,xhr)};this._processLogoutResult=function(xhr){var logoutSucceeded;var pdsession=xhr.pdsession;var basicStatusOK=false;if(xhr._anonymousLogoutOK){logoutSucceeded=true}else if(xhr.status!==200){if(pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(xhr.status===404){logoutSucceeded=true}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=true}updateContextPropsFromResponse(pdsession,xhr);pdsession._reinitializeAfterLogout(pdsession,logoutSucceeded)};this._reinitializeAfterLogout=function(pdsession,success){setLoginResult(null,pdsession);setLoginHttpStatus(null,pdsession);setClientContextID(null,pdsession);setUserName(null,pdsession);setAuthProvider(null);_password=null;if(success){setRestApplicationIsOnline(false);setOepingAvailable(false);setPartialPingURI(defaultPartialPingURI);setLastSessionXHR(null,pdsession);clearTimeout(_timeoutID)}};this.addCatalog=function(arg1,arg2,arg3,arg4){var catalogURI,catalogUserName,catalogPassword,isAsync=false,xhr,deferred,iOSBasicAuthTimeout,catalogIndex,authProvider,that=this;function addCatalogAfterOpen(){progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(isAsync){xhr.onreadystatechange=that._onReadyStateChangeGeneric;xhr.onResponseFn=that._processAddCatalogResult;xhr.onResponseProcessedFn=that._addCatalogComplete;if(that.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex}try{if(typeof that.onOpenRequest==="function"){setLastSessionXHR(xhr,that);var params={xhr:xhr,verb:"GET",uri:catalogURI,async:false,formPreTest:false,session:that};that.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,that);xhr.send(null)}catch(e){throw new Error("Error retrieving catalog '"+catalogURI+"'.\n"+e.message)}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{return that._processAddCatalogResult(xhr)}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}customCredentials=true;if(arguments.length>0){if(typeof arg1==="object"){if(!arguments[0].offlineAddCatalog){if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to call addCatalog when there is no active session.")}}catalogURI=arg1.catalogURI;if(!catalogURI||typeof catalogURI!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogURI argument was missing or invalid."))}catalogUserName=arg1.userName;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogUserName argument was invalid."))}catalogPassword=arg1.password;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogPassword argument was invalid."))}isAsync=arg1.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The async argument was invalid."))}iOSBasicAuthTimeout=arg1.iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The iOSBasicAuthTimeout argument was invalid."))}authProvider=arg1.authProvider;deferred=arg1.deferred;catalogIndex=arg1.catalogIndex}else{catalogURI=arg1;if(typeof catalogURI!=="string"){throw new Error("First argument to Session.addCatalog must be the URL of the catalog.")}catalogUserName=arg2;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error("Second argument to Session.addCatalog must be a user name string.")}catalogPassword=arg3;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error("Third argument to Session.addCatalog must be a password string.")}}}else{throw new Error("Session.addCatalog is missing its first argument, the URL of the catalog.")}if(!authProvider){authProvider=this._authProvider;customCredentials=false}if(!catalogUserName){catalogUserName=this.userName}if(!catalogPassword){catalogPassword=_password}xhr=new XMLHttpRequest;xhr.pdsession=this;xhr._catalogURI=catalogURI;if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){if(isAsync){xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex;setTimeout(this._addCatalogComplete,10,this,progress.data.Session.CATALOG_ALREADY_LOADED,null,xhr);return progress.data.Session.ASYNC_PENDING}return progress.data.Session.CATALOG_ALREADY_LOADED}if(authProvider){authProvider._openRequestAndAuthorize(xhr,"GET",catalogURI,isAsync,addCatalogAfterOpen);return progress.data.Session.ASYNC_PENDING}else{this._setXHRCredentials(xhr,"GET",catalogURI,catalogUserName,catalogPassword,isAsync);return addCatalogAfterOpen()}};this._processAddCatalogResult=function(xhr){var _catalogHttpStatus=xhr.status;var theSession=xhr.pdsession;var servicedata;var catalogURI=xhr._catalogURI,serviceURL,theJSDOSession=jsdosession;if(!customCredentials){toggleOnlineState(xhr)}if((_catalogHttpStatus===200||_catalogHttpStatus===0)&&xhr.responseText){servicedata=theSession._parseCatalog(xhr);try{progress.data.ServicesManager.addCatalog(servicedata,theSession)}catch(e){if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){return progress.data.Session.CATALOG_ALREADY_LOADED}throw new Error("Error processing catalog '"+catalogURI+"'. \n"+e.message)}servicedata.forEach(function(service){serviceURL=theSession._prependAppURL(service.address);pushService(new progress.data.MobileServiceObject({name:service.name,uri:serviceURL}),theSession);if(service.settings&&service.settings.useXClientProps&&!theSession.xClientProps){console.warn("Catalog warning: Service settings property 'useXClientProps' "+"is true but 'xClientProps' property has not been set.")}});pushCatalogURIs(catalogURI,theSession);progress.data.ServicesManager.addSession(catalogURI,theSession);if(theJSDOSession){progress.data.ServicesManager.addJSDOSession(catalogURI,theJSDOSession)}}else if(_catalogHttpStatus===401){return progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","addCatalog"))}else{throw new Error("Error retrieving catalog '"+catalogURI+"'. Http status: "+_catalogHttpStatus+".")}return progress.data.Session.SUCCESS};this._addCatalogComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterAddCatalog",pdsession,result,errObj,xhr)};this.ping=function(args){var pingResult=false,pingArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:this._onReadyStateChangePing,offlineReason:null};if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(!this._authProvider&&this.loginResult!==progress.data.Session.LOGIN_SUCCESS){throw new Error("Attempted to call ping when not logged in.")}if(args){if(args.async!==undefined){pingArgs.async=args.async}if(args.doNotFireEvent!==undefined){pingArgs.fireEventIfOfflineChange=!args.doNotFireEvent}if(args.onCompleteFn&&typeof args.onCompleteFn==="function"){pingArgs.onCompleteFn=args.onCompleteFn}pingArgs.deferred=args.deferred;pingArgs.jsdosession=args.jsdosession}pingArgs.pingURI=that._makePingURI();that._sendPing(pingArgs);if(!pingArgs.async){if(pingArgs.xhr){pingResult=that._processPingResult(pingArgs);if(args.offlineReason!==undefined){args.offlineReason=pingArgs.offlineReason}}else{pingResult=false}if(args.xhr!==undefined){args.xhr=pingArgs.xhr}}return pingResult};this._isOnlineStateChange=function(isOnline){var stateChanged=false;if(isOnline&&!this.connected){stateChanged=true}else if(!isOnline&&this.connected){stateChanged=true}return stateChanged};this._checkServiceResponse=function(xhr,success,request){var offlineReason=null,wasOnline=this.connected;updateContextPropsFromResponse(this,xhr);if(!this._events){return}var offlineObservers=this._events.offline||[];var onlineObservers=this._events.online||[];if(offlineObservers.length===0&&onlineObservers.length===0){return}if(success){setRestApplicationIsOnline(true);setDeviceIsOnline(true)}else{if(deviceIsOnline){var localPingArgs={doNotFireEvent:true,offlineReason:null,async:false};if(!that.ping(localPingArgs)){offlineReason=localPingArgs.offlineReason;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}}if(wasOnline&&!this.connected){this.trigger("offline",this,offlineReason,request)}else if(!wasOnline&&this.connected){this.trigger("online",this,request)}};this._processPingResult=function(args){var xhr=args.xhr,pingResponseJSON,appServerStatus=null,wasOnline=this.connected,connectedBeforeCallback,assumeOepingFormat;if(args.hasOwnProperty("usingOepingFormat")){assumeOepingFormat=args.usingOepingFormat}else{assumeOepingFormat=oepingAvailable}if(xhr.status>=200&&xhr.status<300){updateContextPropsFromResponse(this,xhr);if(assumeOepingFormat){try{pingResponseJSON=JSON.parse(xhr.responseText);appServerStatus=pingResponseJSON.AppServerStatus}catch(e){console.error("Unable to parse ping response.")}}toggleOnlineState(xhr)}else{if(deviceIsOnline){if(xhr.status===0){args.offlineReason=progress.data.Session.SERVER_OFFLINE;setRestApplicationIsOnline(false)}else if(xhr.status===404||xhr.status===410){args.offlineReason=progress.data.Session.WEB_APPLICATION_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}else{args.offlineReason=progress.data.Session.DEVICE_OFFLINE}}if(appServerStatus){if(appServerStatus.PingStatus==="false"){args.offlineReason=progress.data.Session.APPSERVER_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}connectedBeforeCallback=this.connected;if(typeof xhr.onCompleteFn==="function"){xhr.onCompleteFn({pingResult:this.connected,xhr:xhr,offlineReason:args.offlineReason})}if(args.fireEventIfOfflineChange){if(wasOnline&&!connectedBeforeCallback){that.trigger("offline",that,args.offlineReason,null)}else if(!wasOnline&&connectedBeforeCallback){that.trigger("online",that,null)}}return this.connected};this._onReadyStateChangePing=function(){var xhr=this;var args;if(xhr.readyState===4){args={xhr:xhr,fireEventIfOfflineChange:true,offlineReason:null};that._processPingResult(args);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._pingtestOnReadyStateChange=function(){var xhr=this;if(xhr.readyState===4){var foundOeping=false;if(xhr.status>=200&&xhr.status<300){foundOeping=true}else{setPartialPingURI(that.loginTarget);console.warn("Default ping target not available, will use loginTarget instead.")}setOepingAvailable(foundOeping);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._sendPing=function(args){var xhr=new XMLHttpRequest,that=this;function sendPingAfterOpen(){if(args.async){xhr.onreadystatechange=args.onReadyStateFn;xhr.onCompleteFn=args.onCompleteFn;xhr._jsdosession=jsdosession;xhr._deferred=args.deferred}progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(that.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr.send(null)}try{if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,"GET",args.pingURI,args.async,sendPingAfterOpen)}else{this._setXHRCredentials(xhr,"GET",args.pingURI,this.userName,_password,args.async);if(xhr.readyState===1){sendPingAfterOpen()}}}catch(e){args.error=e}args.xhr=xhr};this._makePingURI=function(){var pingURI=this.serviceURI+partialPingURI;if(progress.data.Session._useTimeStamp){pingURI=progress.data.Session._addTimeStampToURL(pingURI)}return pingURI};this._autoping=function(){that.ping({async:true})};this._setXHRCredentials=function(xhr,verb,uri,userName,password,async){if(userName&&this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(canPassCredentialsToOpen()){xhr.open(verb,uri,async,userName,password)}else{xhr.open(verb,uri,async)}var auth=_make_basic_auth(userName,password);xhr.setRequestHeader("Authorization",auth)}else{xhr.open(verb,uri,async)}};this._addCCIDtoURL=function(url){var urlPart1,urlPart2,jsessionidStr,index;if(this.clientContextId&&this.clientContextId!=="0"){if(url.substring(0,this.serviceURI.length)===this.serviceURI){jsessionidStr=";"+"JSESSIONID="+this.clientContextId;index=url.indexOf("?");if(index===-1){url+=jsessionidStr}else{urlPart1=url.substring(0,index);urlPart2=url.substring(index);url=urlPart1+jsessionidStr+urlPart2}}}return url};this._saveClientContextId=function(xhr){setClientContextIDfromXHR(xhr,this)};this._parseCatalog=function(xhr){var jsonObject;var catalogdata;try{jsonObject=JSON.parse(xhr.responseText);catalogdata=jsonObject.services}catch(e){console.error("Unable to parse response. Make sure catalog has correct format.");catalogdata=null}return catalogdata};this._prependAppURL=function(oldURL){if(!oldURL){return this.serviceURI}var newURL=oldURL;var pat=/^https?:\/\//i;if(!pat.test(newURL)){if(newURL.indexOf("/")!==0){newURL="/"+newURL}newURL=this.serviceURI+newURL}return newURL};function _addWithCredentialsAndAccept(xhr,acceptString){try{xhr.withCredentials=true;xhr.setRequestHeader("Accept",acceptString)}catch(e){}}function _make_basic_auth(user,pw){var tok=user+":"+pw;var hash=btoa(tok);return"Basic "+hash}var loginFormIDString="j_spring_security_check";function _gotLoginForm(xhr){return _findStringInResponseHTML(xhr,loginFormIDString)}var loginFailureIdentificationString="login failed";function _gotLoginFailure(xhr){return _findStringInResponseHTML(xhr,loginFailureIdentificationString)}function _findStringInResponseHTML(xhr,searchString){if(!xhr.responseText){return false}var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("text/html")>=0&&xhr.responseText.indexOf(searchString)>=0){return true}return false}function handleJSONLoginResponse(params){var jsonObject;params.statusFromjson=null;try{jsonObject=JSON.parse(params.xhr.responseText);if(jsonObject.status_code!==undefined&&jsonObject.status_txt!==undefined){params.statusFromjson=jsonObject.status_code}}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,params.session);setLoginHttpStatus(params.xhr.status,params.session);throw new Error("Unable to parse login response from server.")}}function setRequestHeaderFromContextProps(session,xhr){if(session.xClientProps){xhr.setRequestHeader("X-CLIENT-PROPS",session.xClientProps)}else if(session._contextProperties.contextHeader!==undefined){xhr.setRequestHeader("X-CLIENT-PROPS",session._contextProperties.contextHeader)}}function toggleOnlineState(xhr){var pdsession=that;setLoginHttpStatus(xhr.status,pdsession);if(pdsession.loginHttpStatus>=200&&pdsession.loginHttpStatus<400){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);pdsession._saveClientContextId(xhr);storeAllSessionInfo()}else{if(pdsession.loginHttpStatus===0||pdsession.loginHttpStatus===400||pdsession.loginHttpStatus===410){setRestApplicationIsOnline(false);setLoginResult(progress.data.AuthenticationProvider._getAuthFailureReason(xhr),pdsession)}else{setRestApplicationIsOnline(true);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);return pdsession.loginResult}function updateContextPropsFromResponse(session,xhr){var contextString,context;if(xhr){contextString=getResponseHeaderNoError(xhr,"X-CLIENT-PROPS");if(contextString){try{context=JSON.parse(contextString)}catch(e){}if(typeof context==="object"){session._contextProperties.setContext(context)}else{throw new Error(progress.data._getMsgText("jsdoMSG123","Session","X-CLIENT-PROPS"))}}else if(contextString===""){session._contextProperties.setContext({})}}}function cleanServicesManager(){progress.data.ServicesManager.cleanSession(that)}if(typeof options==="object"){jsdosession=options.jsdosession;newURI=options.serviceURI;setAuthProvider(options.authProvider);if(options.authProvider&&options.authProvider.hasClientCredentials()){_loginResult=progress.data.Session.LOGIN_SUCCESS}if(newURI&&newURI[newURI.length-1]==="/"){newURI=newURI.substring(0,newURI.length-1)}_storageKey=options._storageKey;if(_storageKey){if(retrieveSessionInfo(_storageKey)){storedAuthModel=retrieveSessionInfo("authenticationModel");storedURI=retrieveSessionInfo("serviceURI");if(storedAuthModel!==options.authenticationModel||storedURI!==newURI){clearAllSessionInfo()}else{setSessionInfoFromStorage(_storageKey);stateWasReadFromStorage=true}}if(options.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){_storageKey=undefined}}if(!stateWasReadFromStorage){if(newURI){setServiceURI(newURI,this)}if(options.authenticationModel){this.authenticationModel=options.authenticationModel}}}};progress.data.Session._useTimeStamp=true;var SEQ_MAX_VALUE=999999999999999;var _tsseq=SEQ_MAX_VALUE;var _tsprefix1=0;var _tsprefix2=0;progress.data.Session._getNextTimeStamp=function(){var seq;_tsseq+=1;seq=_tsseq;if(seq>=SEQ_MAX_VALUE){_tsseq=1;seq=1;var t=Math.floor((Date.now?Date.now():(new Date).getTime())/1e4);if(_tsprefix1===t){_tsprefix2+=1;if(_tsprefix2>=SEQ_MAX_VALUE){_tsprefix2=1}}else{_tsprefix1=t;Math.random();_tsprefix2=Math.round(Math.random()*1e10)}}return _tsprefix1+"-"+_tsprefix2+"-"+seq};progress.data.Session._addTimeStampToURL=function(url){var timeStamp="_ts="+progress.data.Session._getNextTimeStamp();url+=(url.indexOf("?")===-1?"?":"&")+timeStamp;return url};progress.data.Session._setNoCacheHeaders=function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache")};if(typeof Object.defineProperty==="function"){Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_REQUIRED",{value:0,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"CATALOG_ALREADY_LOADED",{value:4,enumerable:true});Object.defineProperty(progress.data.Session,"ASYNC_PENDING",{value:5,enumerable:true});Object.defineProperty(progress.data.Session,"EXPIRED_TOKEN",{value:6,enumerable:true});Object.defineProperty(progress.data.Session,"SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_ANON",{value:"anonymous",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BASIC",{value:"basic",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM",{value:"form",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_SSO",{value:"sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM_SSO",{value:"form_sso",enumerable:true});Object.defineProperty(progress.data.Session,"DEVICE_OFFLINE",{value:"Device is offline",enumerable:true});Object.defineProperty(progress.data.Session,"SERVER_OFFLINE",{value:"Cannot contact server",enumerable:true});Object.defineProperty(progress.data.Session,"WEB_APPLICATION_OFFLINE",{value:"Mobile Web Application is not available",enumerable:true});Object.defineProperty(progress.data.Session,"SERVICE_OFFLINE",{value:"REST web Service is not available",enumerable:true});Object.defineProperty(progress.data.Session,"APPSERVER_OFFLINE",{value:"AppServer is not available",enumerable:true})}else{progress.data.Session.LOGIN_SUCCESS=1;progress.data.Session.LOGIN_AUTHENTICATION_FAILURE=2;progress.data.Session.LOGIN_GENERAL_FAILURE=3;progress.data.Session.CATALOG_ALREADY_LOADED=4;progress.data.Session.SUCCESS=1;progress.data.Session.AUTHENTICATION_FAILURE=2;progress.data.Session.GENERAL_FAILURE=3;progress.data.Session.AUTH_TYPE_ANON="anonymous";progress.data.Session.AUTH_TYPE_BASIC="basic";progress.data.Session.AUTH_TYPE_FORM="form";progress.data.Session.AUTH_TYPE_SSO="sso"}progress.data.Session.prototype=new progress.util.Observable;progress.data.Session.prototype.constructor=progress.data.Session;function validateSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}else{listenerData.scope=args[2]}}}progress.data.Session.prototype._eventNames=["offline","online","afterLogin","afterAddCatalog","afterLogout","afterDisconnect"];progress.data.Session.prototype.validateSubscribe=validateSessionSubscribe;progress.data.Session.prototype.toString=function(radix){return"progress.data.Session"};progress.data.JSDOSession=function JSDOSession(options){var _pdsession,_serviceURI,that=this,_name;Object.defineProperty(this,"authenticationModel",{get:function(){return _pdsession?_pdsession.authenticationModel:undefined},enumerable:true});Object.defineProperty(this,"authProvider",{get:function(){return _pdsession?_pdsession._authProvider:null},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _pdsession?_pdsession.catalogURIs:undefined},enumerable:true});Object.defineProperty(this,"clientContextId",{get:function(){return _pdsession?_pdsession.clientContextId:undefined},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return _pdsession?_pdsession.connected:undefined},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _pdsession?_pdsession.JSDOs:undefined},enumerable:true});Object.defineProperty(this,"loginResult",{get:function(){return _pdsession?_pdsession.loginResult:undefined},enumerable:true});Object.defineProperty(this,"loginHttpStatus",{get:function(){return _pdsession?_pdsession.loginHttpStatus:undefined},enumerable:true});Object.defineProperty(this,"onOpenRequest",{get:function(){return _pdsession?_pdsession.onOpenRequest:undefined},set:function(newval){if(_pdsession){_pdsession.onOpenRequest=newval}},enumerable:true});Object.defineProperty(this,"pingInterval",{get:function(){return _pdsession?_pdsession.pingInterval:undefined},set:function(newval){if(_pdsession){_pdsession.pingInterval=newval}},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _pdsession?_pdsession.services:undefined},enumerable:true});Object.defineProperty(this,"serviceURI",{get:function(){if(_pdsession&&_pdsession.serviceURI){return _pdsession.serviceURI}else{return _serviceURI}},enumerable:true});Object.defineProperty(this,"userName",{get:function(){return _pdsession?_pdsession.userName:undefined},enumerable:true});Object.defineProperty(this,"name",{get:function(){return _name},enumerable:true});Object.defineProperty(this,"_isInvalidated",{get:function(){return _pdsession._isInvalidated},enumerable:false});function settlePromise(promise,fulfill,result,info){if(fulfill){promise.resolve(that,result,info)}else{promise.reject(that,result,info)}}function genericSessionEventHandler(pdsession,result,errorObject,xhr,deferred){var myDeferred;if(xhr){myDeferred=xhr._deferred}else{myDeferred=deferred}settlePromise(myDeferred,result===progress.data.Session.SUCCESS?true:false,result,{errorObject:errorObject,xhr:xhr})}function onAfterAddCatalog(pdsession,result,errorObject,xhr){var deferred,fulfill=false,settleResult,info;if(result===progress.data.Session.EXPIRED_TOKEN){settleResult=progress.data.Session.EXPIRED_TOKEN}else if(result===progress.data.Session.LOGIN_AUTHENTICATION_FAILURE){settleResult=progress.data.Session.LOGIN_AUTHENTICATION_FAILURE}else{settleResult=progress.data.Session.GENERAL_FAILURE}if(xhr&&xhr._deferred){deferred=xhr._deferred;if(result!==progress.data.Session.SUCCESS&&result!==progress.data.Session.CATALOG_ALREADY_LOADED){result=result||progress.data.Session.GENERAL_FAILURE;deferred._overallCatalogResult=progress.data.Session.GENERAL_FAILURE}deferred._results[xhr._catalogIndex]={catalogURI:xhr._catalogURI,result:result,errorObject:errorObject,xhr:xhr};deferred._numCatalogsProcessed+=1;if(deferred._numCatalogsProcessed===deferred._numCatalogs){deferred._processedPromise=true;if(!deferred._overallCatalogResult){fulfill=true;settleResult=progress.data.Session.SUCCESS}if(settleResult===progress.data.Session.SUCCESS){if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,details:xhr._deferred._results}}}else{if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,errorObject:new Error(progress.data._getMsgText("jsdoMSG512")),details:xhr._deferred._results}}}settlePromise(xhr._deferred,fulfill,settleResult,info)}}}function onAfterLogout(pdsession,errorObject,xhr){var result=progress.data.Session.GENERAL_FAILURE,fulfill=false;if(xhr&&xhr._deferred){if(!errorObject&&!pdsession.loginResult){result=progress.data.Session.SUCCESS;fulfill=true}settlePromise(xhr._deferred,fulfill,result,{errorObject:errorObject,xhr:xhr})}}function onPingComplete(args){var xhr=args.xhr;if(xhr&&xhr._deferred){settlePromise(xhr._deferred,args.pingResult,args.pingResult,{offlineReason:args.offlineReason,xhr:xhr})}}this.login=function(username,password,options){var deferred=new progress.util.Deferred,iOSBasicAuthTimeout;function callIsAuthorized(){that.isAuthorized().then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(that,object.result,object.info)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","JSDOSession","login()"))}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout}if(!_pdsession._authProvider){_pdsession._authProvider=new progress.data.AuthenticationProvider({uri:this.serviceURI,authenticationModel:this.authenticationModel});_pdsession._authProvider.logout().then(function(){return _pdsession._authProvider.login(username,password)}).then(function(){callIsAuthorized()},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}else{throw new Error(progress.data._getMsgText("jsdoMSG062","JSDOSession","login()"))}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.disconnect=function(){var deferred=new progress.util.Deferred,errorObject;try{_pdsession.subscribe("afterDisconnect",genericSessionEventHandler,this);_pdsession._disconnect(deferred)}catch(e){errorObject=new Error(progress.data._getMsgText("jsdoMSG049","JSDOSession","disconnect",e.message))}if(errorObject){if(progress.util.Deferred.useJQueryPromises){throw errorObject}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:errorObject})}}else{return deferred.promise()}};this.addCatalog=function(catalogURI,unameOrOpts,password,opts){var deferred=new progress.util.Deferred,catalogURIs,numCatalogs,catalogIndex,addResult,errorObject,iOSBasicAuthTimeout,username,options,authProvider;try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(typeof catalogURI==="string"){catalogURIs=[catalogURI]}else if(catalogURI instanceof Array){catalogURIs=catalogURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","addCatalog","The first argument must be a string or an array of strings specifying the URI of the catalog."))}if(unameOrOpts){if(typeof unameOrOpts==="string"){if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG058","Session"))}username=unameOrOpts;if(opts){options=opts;options.authProvider=undefined}}else if(typeof unameOrOpts==="object"){options=unameOrOpts}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDOSession","2","object","addCatalog"))}}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout;if(options.authProvider){authProvider=options.authProvider}else if(this.authProvider){authProvider=this.authProvider}}if(!authProvider&&!this.authProvider&&!username){throw new Error(progress.data._getMsgText("jsdoMSG511"))}_pdsession.subscribe("afterAddCatalog",onAfterAddCatalog,this);numCatalogs=catalogURIs.length;deferred._numCatalogs=numCatalogs;deferred._numCatalogsProcessed=0;deferred._results=[];deferred._results.length=numCatalogs;for(catalogIndex=0;catalogIndex=200&&xhr.status<300){deferred.resolve(that,progress.data.Session.SUCCESS,info)}else{if(xhr.status===401){cbresult=progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else{cbresult=progress.data.Session.GENERAL_FAILURE}deferred.reject(that,cbresult,info)}}};try{xhr.send()}catch(e){throw new Error("JSDOSession: Unable to validate authorization. "+e.message)}})}else{result=progress.data.Session.LOGIN_AUTHENTICATION_REQUIRED;deferred.reject(that,result,{xhr:xhr})}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(that,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.setContext=function(context){_pdsession._contextProperties.setContext(context)};this.setContextProperty=function(propertyName,propertyValue){_pdsession._contextProperties.setContextProperty(propertyName,propertyValue)};this.getContext=function(){return _pdsession._contextProperties.getContext()};this.getContextProperty=function(propertyName){return _pdsession._contextProperties.getContextProperty(propertyName)};this._onlineHandler=function(session,request){that.trigger("online",that,request)};this._offlineHandler=function(session,offlineReason,request){that.trigger("offline",that,offlineReason,request)};if(arguments.length>0&&typeof arguments[0]==="object"){if(options.serviceURI&&typeof options.serviceURI==="string"){_serviceURI=options.serviceURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options parameter must include a 'serviceURI' property that is a string."))}if(options.authenticationModel){if(typeof options.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The authenticationModel property of the options parameter must be a string."))}options.authenticationModel=options.authenticationModel.toLowerCase()}else{options.authenticationModel=progress.data.Session.AUTH_TYPE_ANON}if(options.authProvider){if(typeof options.authProvider!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG502","JSDOSession","options","constructor","authProvider"))}if(options.authProvider.authenticationModel!==progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authProvider.authenticationModel!==options.authenticationModel||options.authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authenticationModel!==progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG059","JSDOSession",options.authProvider.authenticationModel,options.authenticationModel))}if(typeof options.authProvider.hasClientCredentials==="function"){if(!options.authProvider.hasClientCredentials()){throw new Error(progress.data._getMsgText("jsdoMSG125","JSDOSession"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG505","JSDOSession","AuthenticationProvider","hasClientCredentials"))}}else if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG508"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options argument was missing or invalid."))}_name=options.name;_pdsession=new progress.data.Session({_storageKey:_name,_silent:true,authenticationModel:options.authenticationModel,serviceURI:options.serviceURI,jsdosession:this,authProvider:options.authProvider});try{if(options.context){this.setContext(options.context)}_pdsession.subscribe("online",this._onlineHandler,this);_pdsession.subscribe("offline",this._offlineHandler,this)}catch(err){_pdsession=undefined;throw err}};progress.data.JSDOSession.prototype=new progress.util.Observable;progress.data.JSDOSession.prototype.constructor=progress.data.JSDOSession;function validateJSDOSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}listenerData.scope=args[2]}}progress.data.JSDOSession.prototype._eventNames=["offline","online"];progress.data.JSDOSession.prototype.validateSubscribe=validateJSDOSessionSubscribe;progress.data.JSDOSession.prototype.toString=function(radix){return"progress.data.JSDOSession"};progress.data.getSession=function(options){var deferred=new progress.util.Deferred,authProvider,promise,authProviderInitObject={};function sessionRejectHandler(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);if(authProvider&&authProvider.hasClientCredentials()){var callback=function(){deferred.reject(object.result,object.info)};authProvider.logout().then(callback,callback)}else{deferred.reject(object.result,object.info)}}function callbackRejectHandler(reason){deferred.reject(progress.data.Session.GENERAL_FAILURE,{reason:reason})}function loginHandler(object){var jsdosession;try{jsdosession=new progress.data.JSDOSession(options);try{jsdosession.isAuthorized().then(function(){return jsdosession.addCatalog(options.catalogURI)},sessionRejectHandler).then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(object.jsdosession,progress.data.Session.SUCCESS)},sessionRejectHandler)}catch(e){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}catch(ex){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:ex})}}function callLogin(provider){var errorObject;if(typeof options.loginCallback!=="undefined"){options.loginCallback().then(function(result){try{provider.login(result.username,result.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}},callbackRejectHandler)}else if(options.username&&options.password){try{provider.login(options.username,options.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG052","getSession()"));sessionRejectHandler(provider,progress.data.Session.AUTHENTICATION_FAILURE,{errorObject:errorObject})}}if(typeof options!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options","object"))}if(typeof options.loginCallback!=="undefined"&&typeof options.loginCallback!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options.loginCallback","function"))}try{if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){if(!options.authenticationURI||!options.authProviderAuthenticationModel){throw new Error(progress.data._getMsgText("jsdoMSG509"))}}if(options.authenticationURI){authProviderInitObject.uri=options.authenticationURI;authProviderInitObject.authenticationModel=options.authProviderAuthenticationModel;if(typeof authProviderInitObject.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG502","progress.data.getSession","object","getSession","authProviderAuthenticationModel"))}}else{authProviderInitObject.uri=options.serviceURI;authProviderInitObject.authenticationModel=options.authenticationModel}authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;if(authProvider.hasClientCredentials()){loginHandler(authProvider)}else{if(authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){authProvider.login().then(loginHandler,sessionRejectHandler)}else{callLogin(authProvider)}}}catch(error){sessionRejectHandler(null,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}return deferred.promise()};progress.data.invalidateAllSessions=function(){var jsdosession,key,deferred=new progress.util.Deferred,jsdosessions=progress.data.ServicesManager._jsdosessions,invalidatePromises=[];try{for(key in jsdosessions){if(jsdosessions.hasOwnProperty(key)){jsdosession=jsdosessions[key];invalidatePromises.push(jsdosession.invalidate())}}progress.util.Deferred.when(invalidatePromises).then(function(){deferred.resolve(progress.data.Session.SUCCESS)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(progress.data.Session.GENERAL_FAILURE,info)})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()}})();if(typeof exports!=="undefined"){exports.progress=progress}(function(){"use strict";if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data.AuthenticationProvider=function AuthenticationProvider(initObject){var authProv,authModel,uri;if(typeof initObject==="object"){this._checkStringArg("constructor",initObject.authenticationModel,"initObject.authenticationModel","initObject.authenticationModel");this._checkStringArg("constructor",initObject.uri,"init-object.uri","init-object.uri")}else{throw new Error(progress.data._getMsgText("jsdoMSG033","AuthenticationProvider","the constructor","The init-object argument was missing or invalid."))}authModel=initObject.authenticationModel.toLowerCase();switch(authModel){case progress.data.Session.AUTH_TYPE_ANON:this._initialize(initObject.uri,progress.data.Session.AUTH_TYPE_ANON,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});authProv=this;break;case progress.data.Session.AUTH_TYPE_BASIC:authProv=new progress.data.AuthenticationProviderBasic(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM:authProv=new progress.data.AuthenticationProviderForm(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM_SSO:authProv=new progress.data.AuthenticationProviderSSO(initObject.uri);break;default:throw new Error(progress.data._getMsgText("jsdoMSG502","AuthenticationProvider","init-object","constructor","authenticationModel"))}return authProv};progress.data.AuthenticationProvider.prototype._loginProto=function(sendParam){var deferred=new progress.util.Deferred,xhr,uriForRequest,header,that=this;try{if(this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG051","AuthenticationProvider"))}xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLoginResult(xhr,deferred)}};if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(this._loginURI)}else{uriForRequest=this._loginURI}this._openLoginRequest(xhr,uriForRequest);xhr.setRequestHeader("Accept","application/json");xhr.send(sendParam)}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.login=function(){return this._loginProto()};progress.data.AuthenticationProvider.prototype._openLoginRequest=function(xhr,uri){xhr.open("GET",uri,true);progress.data.Session._setNoCacheHeaders(xhr)};progress.data.AuthenticationProvider.prototype._processLoginResult=function(xhr,deferred){var result;if(xhr.status===200){this._loggedIn=true;this._storeInfo();result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};progress.data.AuthenticationProvider.prototype.logout=function(){var deferred=new progress.util.Deferred;try{this._reset();deferred.resolve(this,progress.data.Session.SUCCESS,{})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.hasClientCredentials=function(){return this._loggedIn};progress.data.AuthenticationProvider.prototype.hasRefreshToken=function(){return false};progress.data.AuthenticationProvider.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);xhr.setRequestHeader("Accept","application/json");callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};progress.data.AuthenticationProvider.prototype._initialize=function(uriParam,authModel,targetURIs){var tempURI,target;Object.defineProperty(this,"uri",{get:function(){return this._uri},enumerable:true});Object.defineProperty(this,"authenticationModel",{get:function(){return this._authenticationModel},enumerable:true});if(uriParam[uriParam.length-1]==="/"){tempURI=uriParam.substring(0,uriParam.length-1)}else{tempURI=uriParam}for(target in targetURIs){if(targetURIs.hasOwnProperty(target)){this[target]=tempURI+targetURIs[target]}}this._authenticationModel=authModel;this._uri=uriParam;this._loggedIn=false;this._dataKeys={uri:".uri",loggedIn:".loggedIn"};if(typeof sessionStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","AuthenticationProvider","sessionStorage"))}this._storage=sessionStorage;this._storageKey=this._uri;this._dataKeys.uri=this._storageKey+this._dataKeys.uri;this._dataKeys.loggedIn=this._storageKey+this._dataKeys.loggedIn;if(this._retrieveLoggedIn()){this._loggedIn=true}};progress.data.AuthenticationProvider.prototype._storeInfo=function(){this._storage.setItem(this._dataKeys.uri,JSON.stringify(this._uri));this._storage.setItem(this._dataKeys.loggedIn,JSON.stringify(this._loggedIn))};progress.data.AuthenticationProvider.prototype._retrieveInfoItem=function(propName){var jsonStr=this._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value};progress.data.AuthenticationProvider.prototype._retrieveURI=function(){return this._retrieveInfoItem(this._dataKeys.uri)};progress.data.AuthenticationProvider.prototype._retrieveLoggedIn=function(){return this._retrieveInfoItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._clearInfo=function(info){this._storage.removeItem(this._dataKeys.uri);this._storage.removeItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._reset=function(){this._clearInfo();this._loggedIn=false};progress.data.AuthenticationProvider.prototype._settlePromise=function(deferred,result,info){if(result===progress.data.Session.SUCCESS){deferred.resolve(this,result,info)}else{deferred.reject(this,result,info)}};progress.data.AuthenticationProvider.prototype._checkStringArg=function(fnName,argToCheck,argPosition,argName){if(typeof argToCheck!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","AuthenticationProvider",argPosition,"string",fnName))}else if(argToCheck.length===0){throw new Error(progress.data._getMsgText("jsdoMSG501","AuthenticationProvider",argName,fnName))}};progress.data.AuthenticationProvider._getAuthFailureReason=function(xhr){var contentType,jsonObject,result=progress.data.Session.AUTHENTICATION_FAILURE;if(xhr.status===401){contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>-1&&xhr.responseText){jsonObject=JSON.parse(xhr.responseText);if(jsonObject.error==="sso.token.expired_token"){result=progress.data.Session.EXPIRED_TOKEN}}}else{result=null}return result};Object.defineProperty(progress.data.AuthenticationProvider,"_homeLoginURIBase",{value:"/static/home.html",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLoginURIBase",{value:"/static/auth/j_spring_security_check",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLogoutURIBase",{value:"/static/auth/j_spring_security_logout",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenLoginURIBase",{value:progress.data.AuthenticationProvider._springLoginURIBase+"?OECP=yes",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenRefreshURIBase",{value:"/static/auth/token?op=refresh",enumerable:true})})();(function(){"use strict";progress.data.AuthenticationProviderBasic=function(uri){var defaultiOSBasicAuthTimeout,userName=null,password=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BASIC,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});this._reset();function make_basic_auth_header(user,pw){var tok=user+":"+pw,hash=btoa(tok);return"Basic "+hash}this._reset=function(){userName=null;password=null;progress.data.AuthenticationProviderBasic.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _basic_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBasic.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){userName=null;password=null}};this.login=function(userNameParam,passwordParam){this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");userName=userNameParam;password=passwordParam;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr);callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}}};function BasicProxy(){}BasicProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBasic.prototype=new BasicProxy;progress.data.AuthenticationProviderBasic.prototype.constructor=progress.data.AuthenticationProviderBasic})();(function(){"use strict";var fn;progress.data.AuthenticationProviderForm=function(uri){this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM,{_loginURI:progress.data.AuthenticationProvider._springLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase})};function FormProxy(){}FormProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderForm.prototype=new FormProxy;progress.data.AuthenticationProviderForm.prototype.constructor=progress.data.AuthenticationProviderForm;progress.data.AuthenticationProviderForm.prototype.login=function(userNameParam,passwordParam){var deferred=new progress.util.Deferred,xhr,that=this;this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");return this._loginProto("j_username="+encodeURIComponent(userNameParam)+"&j_password="+encodeURIComponent(passwordParam)+"&submit=Submit")};progress.data.AuthenticationProviderForm.prototype._openLoginRequest=function(xhr,uri){xhr.open("POST",uri,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.setRequestHeader("Pragma","no-cache");xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.withCredentials=true};progress.data.AuthenticationProviderForm.prototype.logout=function(){var deferred=new progress.util.Deferred,xhr,that=this;try{if(!this._loggedIn){deferred.resolve(this,progress.data.Session.SUCCESS,{})}else{xhr=new XMLHttpRequest;this._openLogoutRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLogoutResult(xhr,deferred)}};xhr.send()}this._reset()}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProviderForm.prototype._openLogoutRequest=function(xhr){xhr.open("GET",this._logoutURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Accept","application/json")};progress.data.AuthenticationProviderForm.prototype._processLogoutResult=function(xhr,deferred){var result;if(xhr.status===200){result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};fn=progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize;progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){function afterSuper(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.withCredentials=true;callback(xhr)}}try{progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super.apply(this,[xhr,verb,uri,async,afterSuper])}catch(e){callback(e)}};progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super=fn})();(function(){"use strict";var fn;progress.data.AuthenticationProviderSSO=function(uri){var that=this,_automaticTokenRefresh,temp,ssoTokenInfo=null,tokenDataKeys={token:".access_token",refreshToken:".refresh_token",tokenType:".token_type",expiration:".expires_in",accessTokenExpiration:".accessTokenExpiration"};function storeTokenInfo(info){var date,accessTokenExpiration;if(info.access_token.length){that._storage.setItem(tokenDataKeys.token,JSON.stringify(info.access_token))}if(info.refresh_token.length){that._storage.setItem(tokenDataKeys.refreshToken,JSON.stringify(info.refresh_token));date=new Date;accessTokenExpiration=date.getTime()+info.expires_in*1e3*.75;that._storage.setItem(tokenDataKeys.accessTokenExpiration,JSON.stringify(accessTokenExpiration))}else{that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}that._storage.setItem(tokenDataKeys.tokenType,JSON.stringify(info.token_type));that._storage.setItem(tokenDataKeys.expiration,JSON.stringify(info.expires_in))}function retrieveTokenProperty(propName){var jsonStr=that._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}function retrieveToken(){return retrieveTokenProperty(tokenDataKeys.token)}function retrieveRefreshToken(){return retrieveTokenProperty(tokenDataKeys.refreshToken)}function retrieveAccessTokenExpiration(){return retrieveTokenProperty(tokenDataKeys.accessTokenExpiration)}function retrieveTokenType(){return retrieveTokenProperty(tokenDataKeys.tokenType)}function getToken(){return retrieveToken()}function retrieveExpiration(){return retrieveTokenProperty(tokenDataKeys.expiration)}function clearTokenInfo(info){that._storage.removeItem(tokenDataKeys.token);that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.tokenType);that._storage.removeItem(tokenDataKeys.expiration);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}function openRefreshRequest(xhr){xhr.open("POST",that._refreshURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Accept","application/json")}function processRefreshResult(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",ex.message))}}else if(xhr.status===401){that._reset();result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}that._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})}this._processLoginResult=function(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){this._loggedIn=true;try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",ex.message))}if(result!==progress.data.Session.SUCCESS){var callback=function(params){params=progress.util.Deferred.getParamObject(params);params.provider._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})};this.logout().then(callback,callback);return}}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};this._reset=function(){progress.data.AuthenticationProviderSSO.prototype._reset.apply(this);clearTokenInfo();ssoTokenInfo=null};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var that=this,date,errorObject;function afterRefreshCheck(provider,result,info){if(result===progress.data.Session.AUTHENTICATION_FAILURE){callback(new Error(progress.data._getMsgText("jsdoMSG060")))}else{progress.data.AuthenticationProviderSSO.prototype._openRequestAndAuthorize.apply(that,[xhr,verb,uri,async,function(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.setRequestHeader("Authorization","oecp "+getToken());callback(xhr)}}])}}if(this.hasClientCredentials()){date=new Date;if(this.automaticTokenRefresh&&this.hasRefreshToken()&&date.getTime()>retrieveAccessTokenExpiration()){try{var callback=function(params,result,info){params=progress.util.Deferred.getParamObject(params,result,info);afterRefreshCheck(params.provider,params.result,params.info)};this.refresh().then(callback,callback)}catch(e){callback(e)}}else{afterRefreshCheck(this,progress.data.Session.SUCCESS,null)}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};this.hasClientCredentials=function(){return retrieveToken()===null?false:true};this.refresh=function(){var deferred=new progress.util.Deferred,xhr;try{if(!this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG053","AuthenticationProvider","refresh"))}if(!this.hasRefreshToken()){throw new Error(progress.data._getMsgText("jsdoMSG054","AuthenticationProvider"))}xhr=new XMLHttpRequest;openRefreshRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){processRefreshResult(xhr,deferred)}};xhr.send('{"token_type":"'+retrieveTokenType()+'","refresh_token":"'+retrieveRefreshToken()+'"}')}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.hasRefreshToken=function(){return retrieveRefreshToken()===null?false:true};this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM_SSO,{_loginURI:progress.data.AuthenticationProvider._springFormTokenLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase,_refreshURI:progress.data.AuthenticationProvider._springFormTokenRefreshURIBase});_automaticTokenRefresh=true;Object.defineProperty(this,"automaticTokenRefresh",{get:function(){return _automaticTokenRefresh},set:function(value){if(value===true||value===false){_automaticTokenRefresh=value}else{throw new Error(progress.data._getMsgText("jsdoMSG061","AuthenticationProvider","automaticTokenRefresh"))}},enumerable:true});this._dataKeys.automaticTokenRefresh=this._storageKey+".automaticTokenRefresh";temp=this._retrieveInfoItem(this._dataKeys.automaticTokenRefresh);if(temp===false){_automaticTokenRefresh=false}tokenDataKeys.token=this._storageKey+tokenDataKeys.token;tokenDataKeys.refreshToken=this._storageKey+tokenDataKeys.refreshToken;tokenDataKeys.tokenType=this._storageKey+tokenDataKeys.tokenType;tokenDataKeys.expiration=this._storageKey+tokenDataKeys.expiration;tokenDataKeys.accessTokenExpiration=this._storageKey+tokenDataKeys.accessTokenExpiration;if(retrieveToken()){this._loggedIn=true}};function SSOProxy(){}SSOProxy.prototype=progress.data.AuthenticationProviderForm.prototype;progress.data.AuthenticationProviderSSO.prototype=new SSOProxy;progress.data.AuthenticationProviderSSO.prototype.constructor=progress.data.AuthenticationProviderSSO;fn=progress.data.AuthenticationProviderSSO.prototype._storeInfo;progress.data.AuthenticationProviderSSO.prototype._storeInfo=function(){progress.data.AuthenticationProviderSSO.prototype._storeInfo._super.apply(this);this._storage.setItem(this._dataKeys.automaticTokenRefresh,JSON.stringify(this._automaticTokenRefresh))};progress.data.AuthenticationProviderSSO.prototype._storeInfo._super=fn;fn=progress.data.AuthenticationProviderSSO.prototype._clearInfo;progress.data.AuthenticationProviderSSO.prototype._clearInfo=function(){progress.data.AuthenticationProviderSSO.prototype._clearInfo._super.apply(this);this._storage.removeItem(this._dataKeys.automaticTokenRefresh)};progress.data.AuthenticationProviderSSO.prototype._clearInfo._super=fn})(); +(function(){var isNativeScript=false,isNodeJS=false;var pkg_xmlhttprequest="xmlhttprequest",pkg_nativescriptLocalstorage="nativescript-localstorage",pkg_fileSystemAccess="file-system/file-system-access";function LocalStorageEmulation(){this._data={}}LocalStorageEmulation.prototype.setItem=function(id,val){return this._data[id]=String(val)},LocalStorageEmulation.prototype.getItem=function(id){return this._data.hasOwnProperty(id)?this._data[id]:undefined},LocalStorageEmulation.prototype.removeItem=function(id){return delete this._data[id]},LocalStorageEmulation.prototype.clear=function(){return this._data={}};if(typeof XMLHttpRequest==="undefined"){isNodeJS=true;try{XMLHttpRequest=require(""+pkg_xmlhttprequest).XMLHttpRequest}catch(e){console.error("Error: JSDO library requires XMLHttpRequest object in Node.js.\n"+"Please install xmlhttprequest package.")}}if(!isNodeJS&&(typeof localStorage==="undefined"||typeof sessionStorage==="undefined")){try{require(""+pkg_fileSystemAccess);isNativeScript=true}catch(exception1){isNativeScript=false}}if(isNativeScript){try{if(typeof sessionStorage==="undefined"){sessionStorage=require(""+pkg_nativescriptLocalstorage)}if(typeof localStorage==="undefined"){localStorage=require(""+pkg_nativescriptLocalstorage)}}catch(exception2){console.error("Error: JSDO library requires localStorage and sessionStorage objects in NativeScript.\n"+"Please install nativescript-localstorage package.")}try{if(typeof btoa==="undefined"){btoa=function(str){return Buffer.from(str).toString("base64")}}}catch(exception3){console.error("Error: JSDO library requires toString('base64') function in NativeScript.")}}if(isNodeJS){if(typeof localStorage==="undefined"){localStorage=new LocalStorageEmulation}if(typeof sessionStorage==="undefined"){sessionStorage=new LocalStorageEmulation}try{if(typeof btoa==="undefined"){btoa=function(str){return Buffer.from(str).toString("base64")}}}catch(exception3){console.error("Error: JSDO library requires toString('base64')function in Node.js.")}}if(!isNodeJS&&!isNativeScript){if(typeof btoa!=="undefined"){let btoaOriginal=btoa;btoa=function(str){return btoaOriginal(unescape(encodeURIComponent(str)))}}}})();(function(){if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.util={};var STRING_OBJECT_TYPE="String",DATE_OBJECT_TYPE="Date",CHARACTER_ABL_TYPE="CHARACTER";progress.util.Deferred=function(){function Deferred(){this._deferred={}}Deferred.prototype.promise=function(){var that=this;if(progress.util.Deferred.useJQueryPromises){if(typeof $!=="undefined"&&typeof $.Deferred==="function"){this._deferred._jQuerydeferred=$.Deferred();this._promise=this._deferred._jQuerydeferred.promise()}else{throw new Error("JQuery Promises not found in environment.")}}else{this._promise=new Promise(function(resolve,reject){that._deferred.resolve=resolve;that._deferred.reject=reject})}if(this._resolveArguments||this._rejectArguments){setTimeout(function(){if(that._resolveArguments){that.resolve.apply(that,that._resolveArguments)}else if(that._rejectArguments){that.reject.apply(that,that._rejectArguments)}},500)}return this._promise};Deferred.prototype.resolve=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.resolve.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.resolve(object)}}else{this._resolveArguments=arguments}};Deferred.prototype.reject=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.reject.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.reject(object)}}else{this._rejectArguments=arguments}};Deferred.useJQueryPromises=false;Deferred.when=function(deferreds){if(progress.util.Deferred.useJQueryPromises){return $.when.apply($,deferreds)}else{return Promise.all(deferreds)}};Deferred.getParamObject1=function(arg1,arg2,arg3){var object={},objectName;try{if(typeof arg1==="undefined"||arg1===null){object.result=arg2;object.info=arg3}else{if(arg1 instanceof progress.data.JSDOSession){objectName="jsdosession"}else if(arg1 instanceof progress.data.AuthenticationProvider){objectName="provider"}else if(arg1 instanceof progress.data.JSDO){objectName="jsdo"}else if(typeof arg1==="number"){objectName="result"}else{objectName=typeof arg1}object[objectName]=arg1;if(objectName==="jsdo"){object.success=arg2;if(arg3&&arg3.xhr){object.request=arg3}else if(arg3&&arg3.batch){object.request=arg3}else{object.info=arg3}}else{if(objectName==="result"){object.info=arg2;if(arg3){object.info2=arg3}}else{object.result=arg2;object.info=arg3}}}}catch(e){console.log("Error: Undetermined argument in getParamObject() call.")}return object};Deferred.getParamObject=function(arg1,arg2,arg3){var object={};if(progress.util.Deferred.useJQueryPromises){object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3)}else{if(typeof arg1==="undefined"){object.result=arg2;object.info=arg3;arg1=object}return arg1}return object};return Deferred}();progress.util.Observable=function(){function _filterObservers(observers,fn,scope,operation){return observers.filter(function(el){if(el.fn!==fn||el.scope!==scope||el.operation!==operation){return el}},this)}this.validateSubscribe=function(args,evt,listenerData){if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="string"){listenerData.operation=args[1];listenerData.fn=args[2];listenerData.scope=args[3]}else if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="function"){listenerData.operation=undefined;listenerData.scope=args[2];listenerData.fn=args[1]}else{throw new Error}};this.subscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"subscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",progress.data._getMsgText("jsdoMSG039")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",e.message))}observers=this._events[evt]||[];observers=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation);observers.push(listenerData);this._events[evt]=observers;return this};this.unsubscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"unsubscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",progress.data._getMsgText("jsdoMSG037")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",e.message))}observers=this._events[evt]||[];if(observers.length>0){this._events[evt]=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation)}return this};this.trigger=function(evt,operation,args){var observers,op;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"trigger"))}this._events=this._events||{};evt=evt.toLowerCase();observers=this._events[evt]||[];if(observers.length>0){args=Array.prototype.slice.call(arguments);if(arguments.length>=2&&typeof evt==="string"&&typeof operation==="string"){op=operation;args=args.length>2?args.slice(2):[]}else if(arguments.length>=1&&typeof evt==="string"){op=undefined;args=args.length>1?args.slice(1):[]}else{throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"trigger"))}observers.forEach(function(el){if(el.operation===op){el.fn.apply(el.scope,args)}})}return this};this.unsubscribeAll=function(evt,operation){var observers;if(evt){this._events=this._events||{};if(typeof evt==="string"){evt=evt.toLowerCase();observers=this._events[evt]||[];observers.forEach(function(el){if(el.operation){this.unsubscribe(evt,el.operation,el.fn,el.scope)}else{this.unsubscribe(evt,el.fn,el.scope)}},this)}}else{this._events={}}return this}};progress.data.LocalStorage=function LocalStorage(){if(typeof localStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","progress.data.LocalStorage","localStorage"))}this.saveToLocalStorage=function(name,dataObj){localStorage.setItem(name,JSON.stringify(dataObj))};this.readFromLocalStorage=function(name){var jsonStr=localStorage.getItem(name),dataObj=null;if(jsonStr!==null){try{dataObj=JSON.parse(jsonStr)}catch(e){dataObj=null}}return dataObj};this.clearLocalStorage=function(name){localStorage.removeItem(name)}};progress.util._convertToABLWhereString=function(tableRef,filter){var result=[],logic=filter.logic||"and",idx,length,field,fieldInfo,type,format,operator,value,ablType,filters=filter.filters||[filter],whereOperators={eq:"=",neq:"<>",gt:">",gte:">=",lt:"<",lte:"<=",contains:"INDEX",doesnotcontain:"INDEX",endswith:"R-INDEX",startswith:"BEGINS",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};for(idx=0,length=filters.length;idx 0"}else{format="{2} MATCHES '*{1}'"}}else{format="{2} {0} "+format}filter=progress.util._format(format,operator,value,field)}else if(operator&&value===undefined){if(filter.operator==="isempty"||filter.operator==="isnotempty"){ablType=tableRef._getABLType(field);if(ablType!==CHARACTER_ABL_TYPE){throw new Error("Error parsing filter object. The operator "+filter.operator+" requires a CHARACTER field")}if(filter.operator==="isempty"){format="{2} = ''"}else if(filter.operator==="isnotempty"){format="{2} <> ''"}}else{if(filter.operator==="isnull"){format="{2} = ?"}else if(filter.operator==="isnotnull"){format="{2} <> ?"}else{format="{2} {0} ?"}}filter=progress.util._format(format,operator,value,field)}}result.push(filter)}filter=result.join(" "+logic+" ");if(result.length>1){filter="("+filter+")"}return filter};progress.util._convertToSQLQueryString=function(tableRef,filter,addSelect){var result=[],logic=filter.logic||"and",idx,length,field,type,format,operator,value,fieldFormat,filters=filter.filters||[filter],filterStr,usingLike=true,whereOperators={eq:"=",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<=",contains:"LIKE",doesnotcontain:"NOT LIKE",endswith:"LIKE",startswith:"LIKE",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};if(typeof addSelect==="undefined"){addSelect=false}for(idx=0,length=filters.length;idx1){filterStr="("+filterStr+")"}if(addSelect===true){filterStr="SELECT * FROM "+tableRef._name+" WHERE "+filterStr}return filterStr};progress.util._getObjectType=function(value){return Object.prototype.toString.call(value).slice(8,-1)};progress.util._format=function(fmt){var values=arguments,formatRegExp=/\{(\d+)(:[^\}]+)?\}/g;return fmt.replace(formatRegExp,function(match,index,placeholderFormat){var value=values[parseInt(index,10)+1];return progress.util._toString(value,placeholderFormat?placeholderFormat.substring(1):"")})};progress.util._toString=function(value,fmt){var str;if(fmt){if(progress.util._getObjectType(value)==="Date"){return progress.util._formatDate(value,fmt)}}if(typeof value==="number"){str=value.toString()}else{str=value!==undefined?value:""}return str};progress.util._pad=function(number,digits){var zeros=["","0","00","000","0000"],end;number=String(number);digits=digits||2;end=digits-number.length;if(end){return zeros[digits].substring(0,end)+number}return number};progress.util._formatDate=function(date,format){var dateFormatRegExp=/dd|MM|yyyy|hh|mm|fff|FFF|ss|zzz|iso|"[^"]*"|'[^']*'/g;return format.replace(dateFormatRegExp,function(match){var minutes,result,sign;if(match==="dd"){result=progress.util._pad(date.getDate())}else if(match==="MM"){result=progress.util._pad(date.getMonth()+1)}else if(match==="yyyy"){result=progress.util._pad(date.getFullYear(),4)}else if(match==="hh"){result=progress.util._pad(date.getHours())}else if(match==="mm"){result=progress.util._pad(date.getMinutes())}else if(match==="ss"){result=progress.util._pad(date.getSeconds())}else if(match==="fff"){result=progress.util._pad(date.getMilliseconds(),3)}else if(match==="FFF"){result=String(date.getTime())}else if(match==="zzz"){minutes=date.getTimezoneOffset();sign=minutes<0;result=(sign?"+":"-")+minutes}else if(match==="iso"){result=date.toISOString()}return result!==undefined?result:match.slice(1,match.length-1)})};progress.util.jsdoSettingsProcessor=function jsdoSettingsProcessor(jsdoSettings){if(typeof jsdoSettings==="object"){if(jsdoSettings.authenticationModel===undefined||jsdoSettings.authenticationModel===""){jsdoSettings.authenticationModel="ANONYMOUS"}}}})();(function(){var PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS=20,PROGRESS_JSDO_OP_STRING=["none","create","read","update","delete","submit"],PROGRESS_JSDO_ROW_STATE_STRING=["","created","","modified","deleted"];if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data._nextid=0;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime());var UID_MAX_VALUE=999999999999999;progress.data._getNextId=function(){var uid=++progress.data._nextid;if(uid>=UID_MAX_VALUE){progress.data._nextid=uid=1;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime())}return progress.data._uidprefix+"-"+uid};var msg={};msg.msgs={};msg.msgs.jsdoMSG000="JSDO, Internal Error: {1}";msg.msgs.jsdoMSG001="JSDO: JSDO has multiple tables. Please use {1} at the table reference level.";msg.msgs.jsdoMSG002="JSDO: Working record for '{1}' is undefined.";msg.msgs.jsdoMSG003="JSDO: {1} function requires a function as a parameter.";msg.msgs.jsdoMSG004="JSDO: Unable to find resource '{1}' in the catalog.";msg.msgs.jsdoMSG005="JSDO: Data for table '{1}' was not specified in addRecords() call.";msg.msgs.jsdoMSG006="JSDO: Data for JSDO was not specified in addRecords() call.";msg.msgs.jsdoMSG007="JSDO: Test function in {1} must return a boolean.";msg.msgs.jsdoMSG008="JSDO: Invalid keyFields parameter in addRecords() call.";msg.msgs.jsdoMSG009="JSDO: KeyField '{1}' in addRecords() call was not found in the schema.";msg.msgs.jsdoMSG010="JSDO: Field '{1}' in relationship was not found in the schema.";msg.msgs.jsdoMSG011="UIHelper: JSDO has multiple tables. "+"Please use {1} at the table reference level.";msg.msgs.jsdoMSG012="UIHelper: Invalid {2} parameter in {1} call.";msg.msgs.jsdoMSG020="JSDO: tableName parameter must be a string in addRecords() call.";msg.msgs.jsdoMSG021="JSDO: addMode parameter must be specified in addRecords() call.";msg.msgs.jsdoMSG022="JSDO: Invalid addMode specified in addRecords() call.";msg.msgs.jsdoMSG023="JSDO: Duplicate found in addRecords() call using APPEND mode.";msg.msgs.jsdoMSG024="{1}: Unexpected signature in call to {2} function.";msg.msgs.jsdoMSG025="{1}: Invalid parameters in call to {2} function.";msg.msgs.jsdoMSG026="JSDO: saveChanges requires a "+"CREATE, UPDATE, DELETE or SUBMIT operation to be defined.";msg.msgs.jsdoMSG030="JSDO: Invalid {1}, expected {2}.";msg.msgs.jsdoMSG031="JSDO: Specified sort field name '{1}' was not found in the schema.";msg.msgs.jsdoMSG032="JSDO: Before-image data already exists for record in addRecords() call.";msg.msgs.jsdoMSG033="{1}: Invalid signature for {2}. {3}";msg.msgs.jsdoMSG034="JSDO: In '{1}' function, JSON data is missing _id";msg.msgs.jsdoMSG035="JSDO: In '{1}' function, before-image JSON data is missing prods:clientId";msg.msgs.jsdoMSG036="JSDO: '{1}' can only be called for a dataset";msg.msgs.jsdoMSG037="{1}: Event name must be provided for {2}.";msg.msgs.jsdoMSG038="Too few arguments. There must be at least {1}.";msg.msgs.jsdoMSG039="The name of the event is not a string.";msg.msgs.jsdoMSG040="The event listener is not a function.";msg.msgs.jsdoMSG041="The event listener scope is not an object.";msg.msgs.jsdoMSG042="'{1}' is not a defined event for this object.";msg.msgs.jsdoMSG043="{1}: A session object was requested to check the status of a Mobile "+"Service named '{2}', but it has not loaded the definition of that service.";msg.msgs.jsdoMSG044="JSDO: In '{1}' function, {2} is missing {3} property.";msg.msgs.jsdoMSG045="JSDO: {1} function: {2} is missing {3} property.";msg.msgs.jsdoMSG046="JSDO: {1} operation is not defined.";msg.msgs.jsdoMSG047="{1} timeout expired.";msg.msgs.jsdoMSG048="{1}: {2} method has argument '{3}' that is missing property '{4}'.";msg.msgs.jsdoMSG049="{1}: Unexpected error calling {2}: {3}";msg.msgs.jsdoMSG050="No token returned from server";msg.msgs.jsdoMSG051="{1} The login method was not executed because the AuthenticationProvider is already logged in.";msg.msgs.jsdoMSG052="{1}: The login method was not executed because no credentials were supplied.";msg.msgs.jsdoMSG053="{1}: {2} was not executed because the AuthenticationProvider is not logged in.";msg.msgs.jsdoMSG054="{1}: Token refresh was not executed because the AuthenticationProvider does not have a refresh token.";msg.msgs.jsdoMSG055="{1}: Token refresh was not executed because the authentication model is not sso.";msg.msgs.jsdoMSG056="{1}: Already logged in.";msg.msgs.jsdoMSG057="{1}: Cannot call {2} when authenticationModel is SSO. Please use the AuthenticationProvider object instead.";msg.msgs.jsdoMSG058="{1}: Cannot pass username and password to addCatalog when authenticationModel "+"is sso. Pass an AuthenticationProvider instead.";msg.msgs.jsdoMSG059="{1}: Error in constructor. The authenticationModels of the "+"AuthenticationProvider ({2}) and the JSDOSession ({3}) were not compatible.";msg.msgs.jsdoMSG060="AuthenticationProvider: AuthenticationProvider is no longer logged in. "+"Tried to refresh SSO token but failed due to authentication error at token server.";msg.msgs.jsdoMSG061="{1}: Attempted to set {2} property to an invalid value.";msg.msgs.jsdoMSG062="{1}: Cannot call {2} when an AuthenticationProvider is already available and logged in.";msg.msgs.jsdoMSG100="JSDO: Unexpected HTTP response. Too many records.";msg.msgs.jsdoMSG101="Network error while executing HTTP request.";msg.msgs.jsdoMSG110="Catalog error: idProperty not specified for resource '{1}'. "+"idProperty is required {2}.";msg.msgs.jsdoMSG111="Catalog error: Schema '{1}' was not found in catalog.";msg.msgs.jsdoMSG112="Catalog error: Output parameter '{1}' was not found for operation '{2}'.";msg.msgs.jsdoMSG113="Catalog error: Found xType '{1}' for output parameter '{2}' "+"for operation '{3}' but xType DATASET, TABLE or ARRAY was expected.";msg.msgs.jsdoMSG114="JSDO: idProperty '{1}' is missing from '{2}' record.";msg.msgs.jsdoMSG115="JSDO: Invalid option specified in {1}() call.";msg.msgs.jsdoMSG116="JSDO: {1} parameter must be a string in {2} call.";msg.msgs.jsdoMSG117="JSDO: Schema from storage area '{1}' does not match JSDO schema";msg.msgs.jsdoMSG118="JSDO: Plugin '{1}' was not found.";msg.msgs.jsdoMSG119="JSDO: A mappingType is expected when 'capabilities' is set."+" Please specify a plugin (ex: JFP).";msg.msgs.jsdoMSG120="JSDO: Parameter '{2}' requires capability '{1}' in the catalog.";msg.msgs.jsdoMSG121="{1}: Argument {2} must be of type {3} in {4} call.";msg.msgs.jsdoMSG122="{1}: Incorrect number of arguments in {2} call. There should be {3}.";msg.msgs.jsdoMSG123="{1}: A server response included an invalid '{2}' header.";msg.msgs.jsdoMSG124="JSDO: autoApplyChanges is not supported for saveChanges(true) "+"with a temp-table. Use jsdo.autoApplyChanges = false.";msg.msgs.jsdoMSG125="{1}: The AuthenticationProvider is not managing valid credentials.";msg.msgs.jsdoMSG126="{1}: No support for {2}.";msg.msgs.jsdoMSG127="JSDO: acceptRowChanges() cannot be called for record with _rejected === true.";msg.msgs.jsdoMSG500="{1}: '{2}' objects must contain a '{3}' property.";msg.msgs.jsdoMSG501="{1}: '{2}' in '{3}' function cannot be an empty string.";msg.msgs.jsdoMSG502="{1}: The '{2}' parameter passed to the '{3}' function has an invalid value for "+"its '{4}' property.";msg.msgs.jsdoMSG503="{1}: '{2}' must be of type '{3}'.";msg.msgs.jsdoMSG504="{1}: {2} has an invalid value for the '{3}' property.";msg.msgs.jsdoMSG505="{1}: '{2}' objects must have a '{3}' method.";msg.msgs.jsdoMSG506="{1}: Invalid argument for the {2} parameter in {3} call.";msg.msgs.jsdoMSG507="{1}: '{2}' is an invalid value for the {3} parameter in {4} call.";msg.msgs.jsdoMSG508="JSDOSession: If a JSDOSession object is using the SSO authentication model, "+"the options object passed to its constructor must include an authProvider property.";msg.msgs.jsdoMSG509="progress.data.getSession: If the authenticationModel is AUTH_TYPE_SSO, "+"authenticationURI and authProviderAuthenticationModel are required parameters.";msg.msgs.jsdoMSG510="{1}: This session has been invalidated and cannot be used.";msg.msgs.jsdoMSG511="JSDOSession: addCatalog() can only be called if an AuthenticationProvider was passed as an argument or "+"connect() has been successfully called.";msg.msgs.jsdoMSG512="JSDOSession: Error while loading multiple catalogs.";msg.msgs.jsdoMSG998="JSDO: JSON object in addRecords() must be DataSet or Temp-Table data.";msg.getMsgText=function(n,args){var text=msg.msgs[n],i;if(!text){throw new Error("Message text was not found by getMsgText()")}for(i=1;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true;data=newDataArray}else{if(params&&(params.sort||params.top)){newDataArray=[];for(i=0;i0){sortObject.tableRef=this;data.sort(this._getCompareFn(sortObject))}}if(params.top){if(typeof params.skip=="undefined"){params.skip=0}data=data.splice(params.skip,params.top)}}return data};this._recToDataObject=function(record,includeChildren){var array=[record];var dataObject=array;if(typeof includeChildren=="undefined"){includeChildren=false}if(this._jsdo._dataSetName){dataObject={};dataObject[this._jsdo._dataSetName]={};dataObject[this._jsdo._dataSetName][this._name]=array;if(includeChildren&&this._children.length>0){var jsrecord=this._findById(record._id,false);if(jsrecord){for(var i=0;i0){for(var j=0;j0){for(var i=0;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true};this._equalRecord=function(rec1,rec2,keyFields){var field;var match=true;for(var i=0;ivalue2||(value1===undefined||value1===null))return sortAscending[i]?1:-1;else if(value10)this._sort(sortObject)}else{this._sort(arg1)}this._createIndex()};this._sort=function(arg1){if(arguments.length===0&&(!this.autoSort||this._sortFn===undefined&&this._sortObject.sortFields===undefined))return;if(arguments.length===0){if(this._sortFn){this._data.sort(this._sortFn)}else{this._data.sort(this._compareFields)}this._needsAutoSorting=false}else{if(typeof arg1=="function"){this._data.sort(this._getCompareFn(arg1))}else{arg1.tableRef=this;this._data.sort(this._getCompareFn(arg1))}if(this.autoSort)this._needsAutoSorting=true}};this.addRecords=function(jsonObject,addMode,keyFields,trackChanges,isInvoke){this._jsdo._addRecords(this._name,jsonObject,addMode,keyFields,trackChanges,isInvoke)};this.acceptChanges=function(){var tableRef=this;for(var id in tableRef._beforeImage){if(tableRef._beforeImage[id]===null){var jsrecord=tableRef._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}else if(this._changed[id]!==undefined){var jsrecord=this._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}}tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[];tableRef._beforeImage={}};this.rejectChanges=function(){for(var id in this._beforeImage){if(this._beforeImage[id]===null){this._jsdo._undoCreate(this,id)}else if(this._changed[id]!==undefined){this._jsdo._undoUpdate(this,id,true)}else{this._jsdo._undoDelete(this,id,true)}}var tableRef=this;tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[]};this.hasChanges=function(){return Object.keys(this._beforeImage).length!==0};this.getChanges=function(){var result=[];for(var id in this._beforeImage){var item={rowState:"",record:null};if(this._beforeImage[id]===null){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_CREATE];item.record=this._findById(id,false)}else if(this._changed[id]!==undefined){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_UPDATE];item.record=this._findById(id,false)}else{item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_DELETE];item.record=new progress.data.JSRecord(this,this._beforeImage[id])}result.push(item)}return result};this._clearErrorStrings=function(){var record=null;for(var id in this._beforeImage){if(this._beforeImage[id]===null){record=this._findById(id,false);if(record){delete record.data._errorString}}else{record=this._findById(id,false);if(record){delete record.data._errorString}else{delete this._beforeImage[id]._errorString}}}};this._applyChanges=function(){var i;for(var id in this._beforeImage){if(this._beforeImage[id]===null){var jsrecord=this._findById(id,false);if(jsrecord===null&&this._jsdo._resource.idProperty!==undefined){if(this._tmpIndex[id]){var record=this._data[this._tmpIndex[id].index];jsrecord=record?new progress.data.JSRecord(this,record):null;delete this._tmpIndex[id]}}if(jsrecord!==null){if(jsrecord.data._rejected||jsrecord.data._errorString!==undefined){this._jsdo._undoCreate(this,id)}else{jsrecord.acceptRowChanges()}}else{var found=false;for(var i=0;i0){for(var i=0;iindex){i--}if(i!=index){this._tableRef._data.splice(index,1);this._tableRef._data.splice(i,0,record);this._tableRef._createIndex()}}}};this.assign=function(record){if(record===undefined)throw new Error(msg.getMsgText("jsdoMSG024","JSDO","assign() or update()"));this._saveBeforeImageUpdate();var fieldName,i,j,value,schema=this._tableRef.getSchema(),prefixElement,name;if(record){for(i=0;i0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){return this.record.data[name][element-1]}}return this.record.data[fieldName]}else return null},set:function(value){var name=fieldName,index,element,fieldInfo;if(this.record){this.record._saveBeforeImageUpdate();try{index=fieldName.indexOf(progress.data.JSDO.ARRAY_INDEX_SEPARATOR);if(index>0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){this.record.data[name][element-1]=value;return}}this.record.data[fieldName]=value}finally{this.record._sortRecord(name)}}},enumerable:true,writeable:true})};Object.defineProperty(this,"hasSubmitOperation",{get:function(){return this._hasSubmitOperation},enumerable:true});Object.defineProperty(this,"hasCUDOperations",{get:function(){return this._hasCUDOperations},enumerable:true});Object.defineProperty(this,"defaultTableRef",{get:function(){return this._defaultTableRef},enumerable:true});this._buffers={};this._numBuffers=0;this._defaultTableRef=null;this._async=true;this._dataProperty=null;this._dataSetName=null;this.operations=[];this.useRelationships=true;this._session=null;this._needCompaction=false;this._hasCUDOperations=false;this._hasSubmitOperation=false;this._useSubmit=false;this.autoApplyChanges=true;this._lastErrors=[];this._localStorage=null;this._convertForServer;this._fillMergeMode;var autoFill=false;if(!arguments[0]){throw new Error("JSDO: Parameters are required in constructor.")}if(typeof arguments[0]=="string"){this.name=arguments[0]}else if(typeof arguments[0]=="object"){var args=arguments[0];for(var v in args){switch(v){case"autoFill":autoFill=args[v];break;case"events":this._events={};for(var eventName in args[v]){this._events[eventName.toLowerCase()]=args[v][eventName]}break;case"dataProperty":this._dataProperty=args[v];break;default:this[v]=args[v]}}}if(!this.name){throw new Error("JSDO: JSDO constructor is missing the value for 'name'")}if(this._events){if(typeof this._events!=="object"){throw new Error("JSDO: JSDO constructor event object is not defined as an object")}for(var prop in this._events){var evt=this._events[prop];if(!(evt instanceof Array)){throw new Error("JSDO: JSDO constructor event object for "+prop+" must be an array")}evt.forEach(function(el){if(typeof el!=="object"){throw new Error("JSDO: JSDO constuctor event object for "+prop+" is not defined as an object")}if(typeof el.fn!=="function"){throw new Error("JSDO: JSDO event listener for "+prop+" is not a function.")}if(el.scope&&typeof el.scope!=="object"){throw new Error("JSDO: JSDO event listener scope for "+prop+" is not an object.")}})}}if(this.name){this._resource=progress.data.ServicesManager.getResource(this.name);if(this._resource){if(!this.url)this.url=this._resource.url;if(!this._dataSetName&&this._resource._dataSetName){this._dataSetName=this._resource._dataSetName;if(this._resource.dataProperty){var buffer=this[this._resource.dataProperty]=new progress.data.JSTableRef(this,this._resource.dataProperty);this._buffers[this._resource.dataProperty]=buffer}else{for(var tableName in this._resource.fields){var buffer=this[tableName]=new progress.data.JSTableRef(this,tableName);this._buffers[tableName]=buffer}}}if(!this._dataProperty&&this._resource.dataProperty)this._dataProperty=this._resource.dataProperty;if(!this._dataSetName){var tableName=this._dataProperty?this._dataProperty:"";this._buffers[tableName]=new progress.data.JSTableRef(this,tableName);if(tableName)this[tableName]=this._buffers[tableName]}var properties,tableName;if(this._dataSetName&&this._resource.schema&&this._resource.schema.properties[this._dataSetName]){properties=this._resource.schema.properties[this._dataSetName].properties;if(Object.keys(properties).length===1){tableName=Object.keys(properties)[0];if(properties[tableName].idProperty){this._resource.idProperty=properties[tableName].idProperty}}}else if(this._resource.schema&&this._resource.schema.properties&&this._resource.schema.properties[tableName]&&this._resource.schema.properties[tableName].idProperty){this._resource.idProperty=this._resource.schema.properties[tableName].idProperty}for(var fnName in this._resource.fn){this[fnName]=this._resource.fn[fnName]["function"]}this._hasCUDOperations=this._resource.generic["create"]!==undefined||this._resource.generic["update"]!==undefined||this._resource.generic["delete"]!==undefined;this._hasSubmitOperation=this._resource.generic["submit"]!==undefined;if(!this._session){var myservice=progress.data.ServicesManager.getService(this._resource.service.name);this._session=myservice._session;this._session._pushJSDOs(this)}}else{throw new Error(msg.getMsgText("jsdoMSG004",this.name))}}else{this._buffers[""]=new progress.data.JSTableRef(this,"")}if(!this._session){throw new Error("JSDO: Unable to get user session for resource '"+this.name+"'")}for(var buf in this._buffers){this._buffers[buf]._parent=null;this._buffers[buf]._children=[];this._buffers[buf]._relationship=null;this._buffers[buf]._isNested=false;if(!this._defaultTableRef)this._defaultTableRef=this._buffers[buf];this._numBuffers++}if(this._numBuffers!=1)this._defaultTableRef=null;else{this.record=null}if(typeof Object.defineProperty=="function"){this._caseSensitive=false;Object.defineProperty(this,"caseSensitive",{get:function(){return this._caseSensitive},set:function(value){this._caseSensitive=value?true:false;for(var buf in this._buffers){this._buffers[buf].caseSensitive=this._caseSensitive}},enumerable:true,writeable:true});this._autoSort=true;Object.defineProperty(this,"autoSort",{get:function(){return this._autoSort},set:function(value){this._autoSort=value?true:false;for(var buf in this._buffers){this._buffers[buf].autoSort=this._autoSort}},enumerable:true,writeable:true})}this._properties={};if(typeof Object.defineProperty=="function"){Object.defineProperty(this,"this._properties",{get:function(){return this._properties},enumerable:false})}if(this._resource&&this._resource.fields){for(var buf in this._buffers){this._buffers[buf]._schema=this._resource.fields[buf];this._buffers[buf]._primaryKeys=this._resource.primaryKeys[buf];this._buffers[buf]._fields={};var fields=this._buffers[buf]._schema;for(var i=0;i1){for(var buf in this._buffers){var fields=[];var found=false;for(var i=0;i=0?index+1:"");element.value=value?value[index]:undefined;return element};this.isDataSet=function(){return this._dataSetName?true:false};this._invokeComplete=function(jsdo,success,request){if(request.async&&request.fnName){jsdo.trigger("afterInvoke",request.fnName,jsdo,success,request)}if(request.deferred){if(success){request.deferred.resolve(jsdo,success,request)}else{request.deferred.reject(jsdo,success,request)}}};this._invokeSuccess=function(){};this._invokeError=function(){};this._httpRequest=function(xhr,method,url,reqBody,request){function afterOpenRequest(){var input=null;if(reqBody){xhr.setRequestHeader("Content-Type","application/json; charset=utf-8");input=JSON.stringify(reqBody)}try{xhr.send(input)}catch(e){request.success=false;request.exception=e;xhr.jsdo._session._checkServiceResponse(xhr,request.success,request)}}if(!xhr){xhr=new XMLHttpRequest;xhr.onCompleteFn=this._invokeComplete;xhr.onSuccessFn=this._invokeSuccess;xhr.onErrorFn=this._invokeError;xhr.onreadystatechange=this.onReadyStateChangeGeneric;if(request.async&&request.fnName){this.trigger("beforeInvoke",request.fnName,this,request)}if(reqBody){if(this._resource&&this._resource.service){var useRequest=this._resource.service.useRequest;if(this._resource.service.settings&&this._resource.service.settings.useRequest!==undefined){useRequest=this._resource.service.settings.useRequest}if(useRequest){reqBody={request:reqBody}}}}}xhr.request=request;xhr.jsdo=this;request.jsdo=this;request.xhr=xhr;this._session._openRequest(xhr,method,url,request.async,afterOpenRequest);return request};this._getDataObject=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};var oldUseRelationships=this.useRelationships;try{this.useRelationships=false;for(var buf in this._buffers){dataObject[this._dataSetName][buf]=this._buffers[buf].getData()}}finally{this.useRelationships=oldUseRelationships}}else{if(this._dataProperty){dataObject[this._dataProperty]=this.getData()}else return this.getData()}return dataObject};this._getDataObjectAsNested=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};try{for(var buf in this._buffers){var bufObj=this._buffers[buf];if(bufObj._isNested)continue;this._nestChildren=false;if(bufObj._children.length>0){for(var i=0;i0){hasErrors=true}}if(hasErrors){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._allRecordsRejected=true;this._someRecordsRejected=false;hasCommittedRecords=false;for(i=0;i0&&!param.operations[0].success){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._convertForServer=true;this._buffers[buf]._convertForServer=true}}};this._convertRequestData=function(objParam){var buf,beforeData;if(this._convertForServer===false){return}for(buf in this._buffers){if(this._buffers[buf]._convertForServer){if(objParam[this._dataSetName]){if(objParam[this._dataSetName][buf]){this._convertTableData(this._buffers[buf],objParam[this._dataSetName][buf])}beforeData=objParam[this._dataSetName]["prods:before"];if(beforeData&&beforeData[buf]){this._convertTableData(this._buffers[buf],beforeData[buf])}}else if(objParam[buf]){this._convertTableData(this._buffers[buf],objParam[buf])}}}};this._convertTableData=function(tableRef,tableData){var i;for(i=0;i0){this._confirmOperationExists(progress.data.JSDO._OP_DELETE);checkedDelete=true}if(!checkedCreate&&tableRef._added.length>0){this._confirmOperationExists(progress.data.JSDO._OP_CREATE);checkedCreate=true}if(!checkedUpdate&&Object.keys(tableRef._changed).length>0){this._confirmOperationExists(progress.data.JSDO._OP_UPDATE);checkedUpdate=true}if(checkedDelete&&checkedCreate&&checkedUpdate){break}}};this._confirmOperationExists=function(operation){var operationStr=PROGRESS_JSDO_OP_STRING[operation];if(typeof this._resource.generic[operationStr]!=="function"){throw new Error(msg.getMsgText("jsdoMSG046",operationStr.toUpperCase()))}};this.invoke=function(name,object){var deferred,promise;try{var request=this[name](object);if(request.deferred){deferred=request.deferred;promise=request.deferred.promise()}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{if(!deferred){deferred=new progress.util.Deferred;promise=deferred.promise()}deferred.reject(this,false,{errorObject:error})}}return promise};this._syncTableRef=function(operation,tableRef,batch){var rowData,requestData,jsonObject,dataSetObject;if(tableRef._visited)return;tableRef._visited=true;if(!batch){batch={operations:[]}}else if(!batch.operations){batch.operations=[]}switch(operation){case progress.data.JSDO._OP_CREATE:for(var i=0;i0&&!dataSetJsonObject[tableRef._name])dataSetJsonObject[tableRef._name]=[];for(var i=0;i0||tableRef._added.length>0||hasUpdates){hasChanges=true;break}}return hasChanges};this._addDeletesToChangeSet=function(tableRef,dataSetJsonObject,request){for(var i=0;i=10){tmpIndex={};for(var i=0;ivalue2||value1===null)return false;else if(value11){for(var buf in this._buffers){if(this._buffers[buf]._isNested&&this._buffers[buf]._parent&&this._buffers[this._buffers[buf]._parent]){var srcData=this._buffers[this._buffers[buf]._parent]._data;var data=[];for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}var recordId=beforeTableJsonObject[0]["prods:clientId"];if(!recordId){throw new Error(msg.getMsgText("jsdoMSG035","_checkForDeleteError()"))}if(beforeTableJsonObject[0]["prods:hasErrors"]){var prods_id=beforeTableJsonObject[0]["prods:id"];var errorString=this._getErrorStringFromJsonObject(dataSetJsonObject,tableRef,prods_id);this._setErrorString(tableRef,recordId,errorString,true);hasError=true}}return hasError};this._mergeUpdateForSubmit=function(jsonObject,xhr){var errorString;if(!this._dataSetName){throw new Error(msg.getMsgText("jsdoMSG036","_mergeUpdateForSubmit()"))}var dataSetJsonObject=jsonObject[this._dataSetName];if(dataSetJsonObject[this._dataSetName])dataSetJsonObject=dataSetJsonObject[this._dataSetName];var beforeJsonObject=dataSetJsonObject["prods:before"];for(var buf in this._buffers){var tableRef=this._buffers[buf];var tableJsonObject=dataSetJsonObject[tableRef._name];if(tableJsonObject instanceof Array){for(var i=0;i1){request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}}if(beforeJsonObject){hasError=jsdo._checkForDeleteError(dataSetJsonObject,xhr)}if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._deleteError(jsdo,success,request)}}};this._deleteError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoDelete(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._createComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterCreate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterCreate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._createSuccess=function(jsdo,success,request){var xhr=request.xhr;var record=request.response;var hasError=jsdo._mergeUpdateForCUD(record,xhr);if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._createError(jsdo,success,request)}}};this._createError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoCreate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._updateComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterUpdate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterUpdate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._updateSuccess=function(jsdo,success,request){var xhr=request.xhr;var hasError=jsdo._mergeUpdateForCUD(request.response,xhr);if(hasError){request.success=false}if(jsdo.autoApplyChanges){if(!hasError){request.success=true;delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._updateError(jsdo,success,request)}}};this._updateError=function(jsdo,success,request){if(jsdo.autoApplyChanges){request.success=false;jsdo._undoUpdate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._saveChangesSuccess=function(jsdo,success,request){var records=request.response;jsdo._mergeUpdateForSubmit(records,request.xhr);jsdo._clearErrors();var changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(changes);if(jsdo.autoApplyChanges){jsdo._applyChanges()}};this._saveChangesError=function(jsdo,success,request){jsdo._setAllRecordsRejected(true);if(jsdo.autoApplyChanges){jsdo.rejectChanges()}jsdo._updateLastErrors(jsdo,null,null,request)};this._saveChangesSuccessTT=function(jsdo,success,request){var changes;jsdo._clearErrors();changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(false)};this._saveChangesComplete=function(jsdo,success,request){if(request.xhr.status>=200&&request.xhr.status<300&&(jsdo._lastErrors.length>0||jsdo._someRecordsRejected)){request.success=false}if(jsdo._useSubmit===true){jsdo._fireCUDTriggersForSubmit(request)}jsdo._undefWorkingRecord();jsdo._fireAfterSaveChanges(request.success,request)};this._fireAfterSaveChanges=function(success,request){this.trigger("afterSaveChanges",this,success,request);if(request.jsrecords){if(request.deferred){if(success){request.deferred.resolve(this,success,request)}else{request.deferred.reject(this,success,request)}}}else if(request.batch&&request.batch.deferred){if(success){request.batch.deferred.resolve(this,success,request)}else{request.batch.deferred.reject(this,success,request)}}var clearErrorString=this.autoApplyChanges;if(request.jsrecords){for(var idx=0;idx=400&&request.xhr.status<600){try{var responseObject=JSON.parse(request.xhr.responseText);if(responseObject instanceof Array){errorArray=responseObject}else if(responseObject instanceof Object){errorArray.push(responseObject)}for(i=0;i=400&&request.xhr.status<600)){errors.push({type:progress.data.JSDO.ERROR,error:"Error: HTTP Status "+request.xhr.status+" "+request.xhr.statusText,responseText:request.xhr.responseText})}}return errors};this._updateLastErrors=function(jsdo,batch,changes,request){var errors,errorText,responseObject,i,j,buf;if(batch){if(batch.operations===undefined)return;for(i=0;i=200&&request.xhr.status<300){jsdo._lastErrors.push({errorString:request.jsrecord.data._errorString});jsdo._buffers[request.jsrecord._tableRef._name]._lastErrors.push({type:progress.data.JSDO.DATA_ERROR,id:request.jsrecord.data._id,error:request.jsrecord.data._errorString})}else{errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}if(request.jsrecord&&(errors[j].type===progress.data.JSDO.APP_ERROR||errors[j].type===progress.data.JSDO.RETVAL)){errors[j].id=request.jsrecord.data._id;request.jsrecord._tableRef._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}}}}else if(changes instanceof Array){for(i=0;i=400&&request.xhr.status<600||request.xhr.status===0)){errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}for(buf in this._buffers){this._buffers[buf]._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}};this._checkSaveComplete=function(xhr){if(xhr.request){var jsdo=xhr.request.jsdo;var batch=xhr.request.batch;if(jsdo&&batch&&jsdo._async){if(jsdo._isBatchComplete(batch)){var success=jsdo._isBatchSuccess(batch);var request={batch:batch,success:success};jsdo._undefWorkingRecord();jsdo._lastErrors=[];if(!success&&batch.operations){jsdo._updateLastErrors(jsdo,batch,null)}this._setAllRecordsRejected(batch);jsdo._fireAfterSaveChanges(success,request)}}}};this._isBatchSuccess=function(batch){if(batch.operations){for(var i=0;i=200&&xhr.status<300||xhr.status===0&&xhr.responseText!==""){request.success=true;xhr.jsdo._session._saveClientContextId(xhr);if(typeof xhr.onSuccessFn=="function"){var operation;if(xhr.request.fnName!==undefined&&xhr.jsdo._resource.fn[xhr.request.fnName]!==undefined){operation=xhr.jsdo._resource.fn[xhr.request.fnName].operation}else operation=null;if(operation===undefined||operation!==null&&operation.mergeMode)xhr.jsdo._mergeInvoke(request.response,xhr);if(request.success)xhr.onSuccessFn(xhr.jsdo,request.success,request);else if(typeof xhr.onErrorFn=="function")xhr.onErrorFn(xhr.jsdo,request.success,request)}}else{request.success=false;if(xhr.status===0){request.exception=new Error(msg.getMsgText("jsdoMSG101"))}if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}xhr.jsdo._session._checkServiceResponse(xhr,request.success,request);if(typeof xhr.onCompleteFn=="function"){xhr.onCompleteFn(xhr.jsdo,request.success,request)}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}};this.acceptChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].acceptChanges()}};this.rejectChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].rejectChanges()}};this.getChanges=function(){var result=[];for(var buf in this._buffers){var changes=this._buffers[this._buffers[buf]._name].getChanges();result=result.concat(changes)}return result};this.hasChanges=function(){for(var buf in this._buffers){if(this._buffers[this._buffers[buf]._name].hasChanges())return true}return false};this._applyChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name]._applyChanges()}};this.acceptRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.acceptRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","acceptRowChanges()"))};this.rejectRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.rejectRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","rejectRowChanges()"))};this.setProperties=function(propertiesObject){var prop;if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(typeof propertiesObject=="object"){this._properties={};for(prop in propertiesObject){if(propertiesObject.hasOwnProperty(prop)){if(typeof propertiesObject[prop]!=="function"){this._properties[prop]=propertiesObject[prop]}}}}else if(propertiesObject===undefined||propertiesObject===null){this._properties={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"Object","setProperties"))}};this.setProperty=function(propertyName,propertyValue){if(arguments.length<2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(arguments.length!==2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(typeof propertyName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"string","setProperty"))}if(propertyValue===undefined){delete this._properties[propertyName]}else{this._properties[propertyName]=propertyValue}};this.getProperties=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperties",0))}return this._properties};this.getProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}return this._properties[propertyName]};this.saveLocal=function saveLocal(arg1,arg2){var name;var dataMode;if(arguments.length>2){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"||arg1===null||arg1===undefined){name=arg1;dataMode=arg2}else{name=null;dataMode=arg1}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}if(typeof dataMode=="undefined"){dataMode=progress.data.JSDO.ALL_DATA}else{switch(dataMode){case progress.data.JSDO.ALL_DATA:case progress.data.JSDO.CHANGES_ONLY:break;default:throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var dataObj=this._prepareDataObjectForLocalStorage(dataMode);this._localStorage.saveToLocalStorage(name,dataObj)};this.readLocal=function readLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));this._restoreFromLocalStorage(object,progress.data.JSDO.MODE_EMPTY)}return object!==null};this.addLocalRecords=function addLocalRecords(arg1,arg2,arg3){var name;var addMode;var keyFields;if(arguments.length<1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"){name=arg1;addMode=arg2;keyFields=arg3}else{name="jsdo_"+this._resource.service.name+"_"+this._resource.name;addMode=arg1;keyFields=arg2}if(typeof name=="undefined"||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(addMode!=progress.data.JSDO.MODE_REPLACE){throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));try{this._restoreFromLocalStorage(object,addMode,keyFields)}catch(e){var text=e.message;throw new Error(text.replace(new RegExp("addRecords","g"),"addLocalRecords"))}}return object!==null};this._containsPrimaryKeys=function _containsPrimaryKeys(){for(var buf in this._buffers){if(this._buffers[buf]._primaryKeys===null)return false}return true};this._hasMatchingSchema=function _hasMatchingSchema(storageObject){var isValid=true;if(storageObject===null||Object.keys(storageObject).length===0)return true;if(this._dataSetName){if(storageObject[this._dataSetName]){for(var buf in this._buffers)if(storageObject[this._dataSetName][buf]===undefined){isValid=false;break}}else isValid=false}else if(this._dataProperty){storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._dataProperty]===undefined)isValid=false}else{storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._defaultTableRef._name]===undefined)isValid=false}return isValid};this.deleteLocal=function deleteLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}this._localStorage.clearLocalStorage(name)};this._prepareDataObjectForLocalStorage=function(option){var storageObject={};if(this._dataSetName){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet(this._dataSetName);break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet(this._dataSetName,true);break}}else if(this._dataProperty){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}else{switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}return storageObject};this._restoreFromLocalStorage=function(storageObject,addMode,keyFields){if(storageObject&&Object.keys(storageObject).length>0){if(this._dataSetName){for(var buf in this._buffers)this._restoreDataForTable(this._buffers[buf],storageObject,addMode,keyFields)}else this._restoreDataForTable(this._defaultTableRef,storageObject,addMode,keyFields)}else if(addMode===progress.data.JSDO.MODE_EMPTY)this._clearData()};this._restoreDataForTable=function(tableRef,jsonObject,addMode,keyFields){keyFields=keyFields!==undefined?keyFields:tableRef._primaryKeys;if(keyFields===undefined&&this._resource.idProperty){keyFields=[];keyFields[0]=this._resource.idProperty}if(this._dataSetName){var oldUseRelationships=this.useRelationships;this.useRelationships=false;try{tableRef.addRecords(jsonObject,addMode,keyFields)}finally{this.useRelationships=oldUseRelationships}}else{this._dataSetName="_localStorage";tableRef.addRecords(jsonObject,addMode,keyFields);this._dataSetName=null}};this.getMethodProperties=function(operation,name){var idx;if(this._resource._operations){if(this._resource._operations[operation]){return this._resource._operations[operation]}}else{this._resource._operations={}}for(var idx=0;idx1?[params.sort]:[]}sortFields="";for(index=0;index=1?params.filter:undefined}if(params.filter){if(typeof params.filter==="string"){doConversion=false}params.tableRef=tableName;if(doConversion&¶ms.tableRef===undefined){throw new Error(msg.getMsgText("jsdoMSG045","fill() or read()","params","tableRef"))}if(reqCapabilities["filter"].mapping==="ablFilter"){if(doConversion){ablFilter=progress.util._convertToABLWhereString(jsdo._buffers[params.tableRef],params.filter)}else{ablFilter=params.filter}}else if(reqCapabilities["filter"].mapping==="sqlQuery"){if(doConversion){sqlQuery=progress.util._convertToSQLQueryString(jsdo._buffers[params.tableRef],params.filter,true)}else{sqlQuery=params.filter}}}filter=JSON.stringify({ablFilter:ablFilter,tableRef:params.tableRef,viewTables:jsdo.viewTables,sqlQuery:sqlQuery,orderBy:sortFields,skip:params.skip,top:params.top,id:params.id});params={filter:filter}}return params}});if(typeof progress.ui=="undefined")progress.ui={};progress.ui.UITableRef=function UITableRef(tableRef){this._tableRef=tableRef;this._listview=null;this._detailPage=null;this._listviewContent=undefined;this.addItem=function(format){var detailForm;if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._name));if(!this._listview)return;format=format?format:this._listview.format;detailForm=this._detailPage&&this._detailPage.name?this._detailPage.name:"";if(this._listviewContent===undefined){this.clearItems()}var text=this._listview.itemTemplate?this._listview.itemTemplate:progress.ui.UIHelper._itemTemplate;text=text.replace(new RegExp("{__format__}","g"),format);text=text.replace(new RegExp("{__id__}","g"),this._tableRef.record.data._id);text=text.replace(new RegExp("{__page__}","g"),detailForm);for(var field in this._tableRef.record.data){var value=this._tableRef.record.data[field];text=text.replace(new RegExp("{"+field+"}","g"),value!==undefined&&value!==null?value:"")}this._listviewContent+=text};this.clearItems=function(){if(this._listview){this._listviewContent="";var listviewElement=document.getElementById(this._listview.name);if(listviewElement){listviewElement.innerHTML=""}}};this._getFormFieldValue=function(fieldName,detailPageName){var value=null,field;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)value=field.val()}else{field=document.getElementById(fieldName);if(field){value=field.value}}return value};this._setFormField=function(fieldName,value,detailPageName){var field=null;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)field.val(value)}else{field=document.getElementById(fieldName);if(field){field.value=value}}};this.assign=function(detailPageName){if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._tableRef._name));if(arguments.length!==0&&typeof detailPageName!="string")throw new Error(msg.getMsgText("jsdoMSG024","UIHelper","assign()"));this._tableRef.record.assign(null);var fieldName;var schema=this._tableRef.getSchema();for(var i=0;i0){for(var i=0;i0&&fieldName.charAt(0)=="_")continue;if(fields&&fields[fieldName]===undefined)continue;var fieldLabel=this._tableRef._schema[i].title?this._tableRef._schema[i].title:this._tableRef._schema[i].name;var text=this._detailPage&&this._detailPage.fieldTemplate?this._detailPage.fieldTemplate:progress.ui.UIHelper._fieldTemplate;text=text.replace(new RegExp("{__label__}","g"),fieldLabel);text=text.replace(new RegExp("{__name__}","g"),this._tableRef._schema[i].name);htmltext+=text}htmltext+="";fields=null;return htmltext};this.getListViewRecord=function(htmlIElement){var id=htmlIElement.getAttribute("data-id");return this._tableRef.findById(id)};this.getFormRecord=function(detailPageName){var id=this._getFormFieldValue("_id",detailPageName);return this._tableRef.findById(id)};this._getIdOfElement=function(name){if(typeof $=="function"){var element=$("#"+name);if(!element||element.length===0){element=$('[dsid="'+name+'"]');if(element&&element.length==1){var id=element.attr("id");if(id)return id}}}return name};this.setDetailPage=function setDetailPage(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));this._detailPage=obj;this._detailPage.name=this._getIdOfElement(this._detailPage.name)};this.setListView=function setListView(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));if(obj.format&&typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"format"));this._listview=obj;this._listview.name=this._getIdOfElement(this._listview.name);if(!this._listview.format){if(typeof $=="function"){for(var i=0;i{__format__}';progress.ui.UIHelper._defaultFieldTemplate='
'+''+'
';progress.ui.UIHelper._itemTemplate=progress.ui.UIHelper._defaultItemTemplate;progress.ui.UIHelper._fieldTemplate=progress.ui.UIHelper._defaultFieldTemplate;progress.ui.UIHelper.setItemTemplate=function(template){progress.ui.UIHelper._itemTemplate=template?template:progress.ui.UIHelper._defaultItemTemplate};progress.ui.UIHelper.setFieldTemplate=function(template){progress.ui.UIHelper._fieldTemplate=template?template:progress.ui.UIHelper._defaultFieldTemplate}})();(function(){if(progress===undefined){progress={}}if(progress.data===undefined){progress.data={}}progress.data.ServicesManager={};progress.data.ServicesManager._services=[];progress.data.ServicesManager._resources=[];progress.data.ServicesManager._data=[];progress.data.ServicesManager._sessions=[];progress.data.ServicesManager._jsdosessions=[];progress.data.ServicesManager.addResource=function(id,resource){if(progress.data.ServicesManager._resources[id]===undefined){progress.data.ServicesManager._resources[id]=resource}else{throw new Error("A resource named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getResource=function(id){return progress.data.ServicesManager._resources[id]};progress.data.ServicesManager.addService=function(id,service){if(progress.data.ServicesManager._services[id]===undefined){progress.data.ServicesManager._services[id]=service}else{throw new Error("A service named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getService=function(id){return progress.data.ServicesManager._services[id]};progress.data.ServicesManager.addSession=function(catalogURI,session){if(progress.data.ServicesManager._sessions[catalogURI]===undefined){progress.data.ServicesManager._sessions[catalogURI]=session}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.addJSDOSession=function(catalogURI,jsdosession){if(progress.data.ServicesManager._jsdosessions[catalogURI]===undefined){progress.data.ServicesManager._jsdosessions[catalogURI]=jsdosession}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.getSession=function(catalogURI){try{return progress.data.ServicesManager._sessions[catalogURI]}catch(e){return null}};progress.data.ServicesManager.cleanSession=function(session){var servicesKey,resourcesKey,sessionsKey,service,services=progress.data.ServicesManager._services,resources=progress.data.ServicesManager._resources,sessions=progress.data.ServicesManager._sessions,jsdosessions=progress.data.ServicesManager._jsdosessions;for(servicesKey in services){service=null;if(services[servicesKey]._session===session){service=services[servicesKey];delete services[servicesKey]}if(!service){continue}for(resourcesKey in resources){if(resources[resourcesKey].service===service){delete resources[resourcesKey]}}}for(sessionsKey in sessions){if(sessions[sessionsKey]===session){delete sessions[sessionsKey];if(jsdosessions[sessionsKey]){delete jsdosessions[sessionsKey]}}}};function extractParamsFromURL(url){var urlParams=[],paramName=null;if(typeof url==="string"){url.split("").forEach(function(c){if(c==="{"){paramName=""}else if(c==="}"){if(paramName){urlParams.push(paramName)}paramName=null}else if(paramName!==null){paramName+=c}})}return urlParams}progress.data.ServicesManager.addCatalog=function(services,session){var name,value;if(!services){throw new Error("Cannot find 'services' property in catalog file.")}if(services instanceof Array){services.forEach(function(service){if(progress.data.ServicesManager.getService(service.name)!==undefined){throw new Error("A service named '"+service.name+"' was already loaded.")}if(service.resources instanceof Array){service.resources.forEach(function(resource){if(progress.data.ServicesManager.getResource(resource.name)!==undefined){throw new Error("A resource named '"+resource.name+"' was already loaded.")}})}else{throw new Error("Missing 'resources' array in catalog.")}});for(var j=0;j1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","setContext",1))}if(typeof context==="object"){contextObject={};for(prop in context){if(context.hasOwnProperty(prop)){if(typeof context[prop]!=="function"){contextObject[prop]=context[prop]}}}}else if(context===undefined||context===null){contextObject={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","Session",1,"Object","setContextProperty"))}contextString=null};this.getContext=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContext",0))}return contextObject};this.getContextProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}return contextObject[propertyName]}};progress.data.Session=function Session(options){var defPropSupported=false;if(typeof Object.defineProperty==="function"){defPropSupported=true}var that=this,jsdosession,isUserAgentiOS=false,isFirefox=false,isEdge=false,isIE=false,canPassCredentialsToOpenWithCORS=false,defaultiOSBasicAuthTimeout=4e3,deviceIsOnline=true,restApplicationIsOnline=false,oepingAvailable=false,hasResolvedPingURI=false,defaultPartialPingURI="/rest/_oepingService/_oeping",classicPartialPingURI="/rest/_oeping",partialPingURI=defaultPartialPingURI,_storageKey,_authProvider=null,customCredentials=false,storedAuthModel,storedURI,newURI,stateWasReadFromStorage=false;if(!options||options._silent!==true){console.warn("Session: As of JSDO 4.4, the Session object has been deprecated. "+"Please use the JSDOSession object instead.")}if(typeof navigator!=="undefined"){if(typeof navigator.userAgent!=="undefined"){isUserAgentiOS=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i);isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;isEdge=navigator.userAgent.indexOf("Edge/")>-1;isIE=navigator.userAgent.indexOf("Trident/")>-1||navigator.userAgent.indexOf("MSIE 10")>-1}}canPassCredentialsToOpenWithCORS=!(isFirefox||isEdge||isIE);function canPassCredentialsToOpen(){return canPassCredentialsToOpenWithCORS}this._onlineHandler=function(){setDeviceIsOnline(true);that.trigger("online",that,null)};this._offlineHandler=function(){setDeviceIsOnline(false);that.trigger("offline",that,progress.data.Session.DEVICE_OFFLINE,null)};if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("online",this._onlineHandler,false);window.addEventListener("offline",this._offlineHandler,false)}var _catalogURIs=[];var _services=[];var _jsdos=[];this.onOpenRequest=null;var _password=null;if(defPropSupported){var _userName=null;Object.defineProperty(this,"userName",{get:function(){return _userName},enumerable:true});var _loginTarget="/static/home.html";Object.defineProperty(this,"loginTarget",{get:function(){return _loginTarget},enumerable:true});var _serviceURI=null;Object.defineProperty(this,"serviceURI",{get:function(){return _serviceURI},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _catalogURIs},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _services},enumerable:true});var _loginResult=null;Object.defineProperty(this,"loginResult",{get:function(){return _loginResult},enumerable:true});var _loginHttpStatus=null;Object.defineProperty(this,"loginHttpStatus",{get:function(){return _loginHttpStatus},enumerable:true});var _clientContextId=null;Object.defineProperty(this,"clientContextId",{get:function(){return _clientContextId},enumerable:true});var _authenticationModel=progress.data.Session.AUTH_TYPE_ANON;Object.defineProperty(this,"authenticationModel",{get:function(){return _authenticationModel},set:function(newval){if(newval){newval=newval.toLowerCase()}switch(newval){case progress.data.Session.AUTH_TYPE_FORM:case progress.data.Session.AUTH_TYPE_BASIC:case progress.data.Session.AUTH_TYPE_ANON:case progress.data.Session.AUTH_TYPE_SSO:case progress.data.Session.AUTH_TYPE_BEARER:case null:_authenticationModel=newval;storeSessionInfo("authenticationModel",newval);break;default:throw new Error("Error setting Session.authenticationModel. '"+newval+"' is an invalid value.")}},enumerable:true});var _lastSessionXHR=null;Object.defineProperty(this,"lastSessionXHR",{get:function(){return _lastSessionXHR},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return this.loginResult===progress.data.Session.LOGIN_SUCCESS&&restApplicationIsOnline&&deviceIsOnline},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _jsdos},enumerable:true});var _pingInterval=0;var _timeoutID=null;Object.defineProperty(this,"pingInterval",{get:function(){return _pingInterval},set:function(newval){if(typeof newval==="number"&&newval>=0){_pingInterval=newval;storeSessionInfo("pingInterval",newval);if(newval>0){if(this.loginResult===progress.data.Session.LOGIN_SUCCESS){_timeoutID=setTimeout(this._autoping,newval)}}else if(newval===0){clearTimeout(_timeoutID);_pingInterval=0}}else{throw new Error("Error setting Session.pingInterval. '"+newval+"' is an invalid value.")}},enumerable:true});var _contextProperties=new progress.data.ContextProperties;Object.defineProperty(this,"_contextProperties",{get:function(){return _contextProperties},enumerable:false});var isInvalidated=false;Object.defineProperty(this,"_isInvalidated",{get:function(){return isInvalidated},enumerable:false});Object.defineProperty(this,"_authProvider",{get:function(){return _authProvider},set:function(newval){if(_authProvider){throw new Error("Internal Error setting Session._authProvider. '"+"The property has already been set.")}setAuthProvider(newval)},enumerable:false})}else{this.userName=null;this.loginTarget="/static/home.html";this.serviceURI=null;this.catalogURIs=[];this.services=[];this.loginResult=null;this.loginHttpStatus=null;this.clientContextId=null;this.authenticationModel=progress.data.Session.AUTH_TYPE_ANON;this.lastSessionXHR=null}function storeSessionInfo(infoName,value){var key;if(that.loginResult===progress.data.Session.LOGIN_SUCCESS&&typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}if(typeof value!=="undefined"){sessionStorage.setItem(key,JSON.stringify(value))}}}function retrieveSessionInfo(infoName){var key,jsonStr,value=null;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}jsonStr=sessionStorage.getItem(key);if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}}function clearSessionInfo(infoName){var key;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName;sessionStorage.removeItem(key)}}}function storeAllSessionInfo(){if(_storageKey){storeSessionInfo("loginResult",that.loginResult);storeSessionInfo("userName",that.userName);storeSessionInfo("serviceURI",that.serviceURI);storeSessionInfo("loginHttpStatus",that.loginHttpStatus);storeSessionInfo("authenticationModel",that.authenticationModel);storeSessionInfo("pingInterval",that.pingInterval);storeSessionInfo("oepingAvailable",oepingAvailable);storeSessionInfo("partialPingURI",partialPingURI);storeSessionInfo("clientContextId",that.clientContextId);storeSessionInfo("deviceIsOnline",deviceIsOnline);storeSessionInfo("restApplicationIsOnline",restApplicationIsOnline);if(that._authProvider){storeSessionInfo("_authProvider.init",{uri:that._authProvider.uri,authenticationModel:that._authProvider.authenticationModel})}storeSessionInfo(_storageKey,true)}}function clearAllSessionInfo(){if(_storageKey){if(retrieveSessionInfo(_storageKey)){clearSessionInfo("loginResult");clearSessionInfo("userName");clearSessionInfo("serviceURI");clearSessionInfo("loginHttpStatus");clearSessionInfo("clientContextId");clearSessionInfo("deviceIsOnline");clearSessionInfo("restApplicationIsOnline");clearSessionInfo("authenticationModel");clearSessionInfo("pingInterval");clearSessionInfo("oepingAvailable");clearSessionInfo("partialPingURI");clearSessionInfo("_authProvider.init");clearSessionInfo(_storageKey)}}}function setSessionInfoFromStorage(key){var authproviderInitObject;if(retrieveSessionInfo(key)){setLoginResult(retrieveSessionInfo("loginResult"),this);setUserName(retrieveSessionInfo("userName"),this);setServiceURI(retrieveSessionInfo("serviceURI"),this);setLoginHttpStatus(retrieveSessionInfo("loginHttpStatus"),this);setClientContextID(retrieveSessionInfo("clientContextId"),this);setDeviceIsOnline(retrieveSessionInfo("deviceIsOnline"));setRestApplicationIsOnline(retrieveSessionInfo("restApplicationIsOnline"));that.authenticationModel=retrieveSessionInfo("authenticationModel");that.pingInterval=retrieveSessionInfo("pingInterval");setOepingAvailable(retrieveSessionInfo("oepingAvailable"));setPartialPingURI(retrieveSessionInfo("partialPingURI"));if(!that._authProvider){authproviderInitObject=retrieveSessionInfo("_authProvider.init");if(authproviderInitObject){setAuthProvider(new progress.data.AuthenticationProvider(authproviderInitObject))}}}}function setUserName(newname,sessionObject){if(defPropSupported){_userName=newname}else{sessionObject.userName=newname}storeSessionInfo("userName",newname)}function setLoginTarget(target,sessionObject){if(defPropSupported){_loginTarget=target}else{sessionObject.loginTarget=target}}function setServiceURI(url,sessionObject){if(defPropSupported){_serviceURI=url}else{sessionObject.serviceURI=url}storeSessionInfo("serviceURI",url)}function pushCatalogURIs(url,sessionObject){if(defPropSupported){_catalogURIs.push(url)}else{sessionObject.catalogURIs.push(url)}}function pushService(serviceObject,sessionObject){if(defPropSupported){_services.push(serviceObject)}else{sessionObject.services.push(serviceObject)}}function findService(serviceName){_services.forEach(function(service){if(service.name===serviceName){return service}});return null}function setLoginResult(result,sessionObject){if(defPropSupported){_loginResult=result}else{sessionObject.loginResult=result}if(result===progress.data.Session.LOGIN_SUCCESS){storeSessionInfo("loginResult",result)}else{clearAllSessionInfo()}}function setLoginHttpStatus(status,sessionObject){if(defPropSupported){_loginHttpStatus=status}else{sessionObject.loginHttpStatus=status}storeSessionInfo("loginHttpStatus",status)}function setClientContextIDfromXHR(xhr,sessionObject){if(xhr){setClientContextID(getResponseHeaderNoError(xhr,"X-CLIENT-CONTEXT-ID"),sessionObject)}}function setClientContextID(ccid,sessionObject){if(defPropSupported){_clientContextId=ccid}else{sessionObject.clientContextId=ccid}storeSessionInfo("clientContextId",ccid)}function setLastSessionXHR(xhr,sessionObject){if(defPropSupported){_lastSessionXHR=xhr}else{sessionObject.lastSessionXHR=xhr}}function setDeviceIsOnline(value){deviceIsOnline=value;storeSessionInfo("deviceIsOnline",value)}function setAuthProvider(value){_authProvider=value?value:null}function setRestApplicationIsOnline(value){restApplicationIsOnline=value;storeSessionInfo("restApplicationIsOnline",value)}function setOepingAvailable(value){oepingAvailable=value;storeSessionInfo("oepingAvailable",value)}function setPartialPingURI(value){partialPingURI=value;storeSessionInfo("partialPingURI",value)}function getResponseHeaderNoError(xhr,headerName){var allHeaders=xhr._pdsResponseHeaders,regExp;if(allHeaders===undefined){allHeaders=xhr.getAllResponseHeaders();if(allHeaders){xhr._pdsResponseHeaders=allHeaders}else{xhr._pdsResponseHeaders=null}}if(allHeaders){regExp=new RegExp("^"+headerName+":","mi");if(allHeaders.match(regExp)){return xhr.getResponseHeader(headerName)}}return null}this._pushJSDOs=function(jsdo){_jsdos.push(jsdo)};this._openRequest=function(xhr,verb,url,async,callback){var urlPlusCCID,that=this;function afterOpenAndAuthorize(arg){if(arg instanceof Error){throw arg}else{if(that.clientContextId&&that.clientContextId!=="0"){xhr.setRequestHeader("X-CLIENT-CONTEXT-ID",that.clientContextId)}setRequestHeaderFromContextProps(that,xhr);if(typeof that.onOpenRequest==="function"){var params={xhr:xhr,verb:verb,uri:urlPlusCCID,async:async,formPreTest:false,session:that};that.onOpenRequest(params)}if(callback){callback()}}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to make server request when there is no active session.")}urlPlusCCID=this._prependAppURL(url);urlPlusCCID=this._addCCIDtoURL(urlPlusCCID);if(progress.data.Session._useTimeStamp){urlPlusCCID=progress.data.Session._addTimeStampToURL(urlPlusCCID)}if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,verb,urlPlusCCID,async,afterOpenAndAuthorize)}else{this._setXHRCredentials(xhr,verb,urlPlusCCID,this.userName,_password,async);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json")}afterOpenAndAuthorize(xhr)}};this.pingTestCallback=function(cbArgs){var foundOeping=cbArgs.pingResult?true:false;setOepingAvailable(foundOeping)};this._onReadyStateChangeGeneric=function(){var xhr=this;var result;var errorObject;clearTimeout(xhr._requestTimeout);if(xhr.readyState===4){result=null;errorObject=null;if(typeof xhr.onResponseFn==="function"){try{result=xhr.onResponseFn(xhr)}catch(e){errorObject=e}}if(typeof xhr.onResponseProcessedFn==="function"){if(!result){result=progress.data.Session.GENERAL_FAILURE}xhr.onResponseProcessedFn(xhr.pdsession,result,errorObject,xhr)}}};this._disconnect=function(deferred){this._processDisconnectResult(null,deferred)};this._processDisconnectResult=function(xhr,deferred){this._reinitializeAfterLogout(this,progress.data.Session.SUCCESS);this._disconnectComplete(this,progress.data.Session.SUCCESS,null,null,deferred)};this._disconnectComplete=function(pdsession,result,errObj,xhr,deferred){pdsession.trigger("afterDisconnect",pdsession,result,errObj,xhr,deferred)};var pwSave=null;var unameSave=null;this.login=function(serviceURI,loginUserName,loginPassword,loginTarget){var uname,pw,isAsync=false,args=[],deferred,iOSBasicAuthTimeout,uriForRequest;pwSave=null;unameSave=null;if(!defPropSupported){this.authenticationModel=this.authenticationModel.toLowerCase()}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","login()"))}if(this.loginResult===progress.data.Session.LOGIN_SUCCESS||this._authProvider){throw new Error("Attempted to call login() on a Session object that is already logged in.")}if(arguments.length>0){if(arguments[0]&&typeof arguments[0]==="object"){args[0]=arguments[0].serviceURI;args[1]=arguments[0].userName;args[2]=arguments[0].password;args[3]=arguments[0].loginTarget;args[4]=arguments[0].async;deferred=arguments[0].deferred;iOSBasicAuthTimeout=arguments[0].iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","login","The iOSBasicAuthTimeout argument was invalid."))}}else{args=arguments}}if(args.length>0){if(args[0]){var restURLtemp=args[0];if(restURLtemp[restURLtemp.length-1]==="/"){restURLtemp=restURLtemp.substring(0,restURLtemp.length-1)}setServiceURI(restURLtemp,this)}else if(!this.serviceURI){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}if(args[1]){uname=args[1]}if(args[2]){pw=args[2]}if(args[3]){setLoginTarget(args[3],this)}if(args[4]){if(typeof args[4]==="boolean"){isAsync=args[4]}else{throw new Error("Session.login() was passed an async setting that is not a boolean.")}}}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}unameSave=uname;pwSave=pw;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON||this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){uname=null;pw=null}var xhr=new XMLHttpRequest;xhr.pdsession=this;try{uriForRequest=this.serviceURI+this.loginTarget;if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(uriForRequest)}this._setXHRCredentials(xhr,"GET",uriForRequest,uname,pw,isAsync);progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(this,xhr);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr._isAsync=isAsync;if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){xhr.onResponseFn=this._afterFormPretestLogin}else{xhr.onResponseFn=this._processLoginResult;xhr.onResponseProcessedFn=this._loginComplete}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout>0){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred}if(typeof this.onOpenRequest==="function"){var isFormPreTest=false;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){isFormPreTest=true}setLastSessionXHR(xhr,this);var params={xhr:xhr,verb:"GET",uri:this.serviceURI+this.loginTarget,async:false,formPreTest:isFormPreTest,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send(null)}catch(e){clearTimeout(xhr._requestTimeout);setLoginHttpStatus(xhr.status,this);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);unameSave=null;pwSave=null;throw e}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{setLoginHttpStatus(xhr.status,this);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){return this._afterFormPretestLogin(xhr)}else{return this._processLoginResult(xhr)}}};this._afterFormPretestLogin=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);var formLoginParams={xhr:xhr,pw:pwSave,uname:unameSave,theSession:pdsession};try{return doFormLogin(formLoginParams)}catch(e){pwSave=null;unameSave=null;throw e}};function doFormLogin(args){var xhr=args.xhr;var theSession=args.theSession;var oldXHR;var contentType=null;var needAuth=false;var params={session:theSession,xhr:xhr,statusFromjson:null};contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson||params.statusFromjson>=400&¶ms.statusFromjson<500){needAuth=true}else{setLoginHttpStatus(params.statusFromjson,theSession)}}else{if(theSession.loginHttpStatus===200){if(_gotLoginForm(xhr)){needAuth=true}}}if(needAuth){oldXHR=xhr;xhr=new XMLHttpRequest;args.xhr=xhr;params.xhr=xhr;xhr.pdsession=oldXHR.pdsession;xhr._isAsync=oldXHR._isAsync;xhr._deferred=oldXHR._deferred;xhr._jsdosession=oldXHR._jsdosession;xhr.open("POST",theSession.serviceURI+"/static/auth/j_spring_security_check",xhr._isAsync);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.setRequestHeader("Cache-Control","max-age=0");setRequestHeaderFromContextProps(theSession,xhr);_addWithCredentialsAndAccept(xhr,"application/json");try{if(typeof theSession.onOpenRequest==="function"){var cbparams={xhr:xhr,verb:"POST",uri:theSession.serviceURI+"/static/auth/j_spring_security_check",async:xhr._isAsync,formPreTest:false,session:theSession};theSession.onOpenRequest(cbparams);xhr=cbparams.xhr}if(xhr._isAsync){xhr.onreadystatechange=theSession._onReadyStateChangeGeneric;xhr.onResponseFn=theSession._afterFormLogin;xhr.onResponseProcessedFn=theSession._loginComplete}xhr.send("j_username="+encodeURIComponent(args.uname)+"&j_password="+encodeURIComponent(args.pw)+"&submit=Submit")}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,theSession);setLoginHttpStatus(xhr.status,theSession);unameSave=null;pwSave=null;throw e}}if(xhr._isAsync&&!needAuth){xhr.onResponseProcessedFn=theSession._loginComplete;return theSession._afterFormLogin(xhr)}if(!xhr._isAsync){return theSession._afterFormLogin(xhr)}}this._afterFormLogin=function(xhr){var theSession=xhr.pdsession;var params={session:theSession,xhr:xhr,statusFromjson:null};var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson){throw new Error("Internal OpenEdge Mobile client error handling login response. HTTP status: "+xhr.status+".")}setLoginHttpStatus(params.statusFromjson,theSession)}else{if(xhr.status===200){if(_gotLoginFailure(xhr)||_gotLoginForm(xhr)){setLoginHttpStatus(401,theSession)}else{setLoginHttpStatus(xhr.status,theSession)}}}return theSession._processLoginResult(xhr)};this._processLoginResult=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);if(pdsession.loginHttpStatus===200){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);setUserName(unameSave,pdsession);_password=pwSave;pdsession._saveClientContextId(xhr);storeAllSessionInfo();var pingTestArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:pdsession._pingtestOnReadyStateChange};pingTestArgs.pingURI=pdsession._makePingURI();pdsession._sendPing(pingTestArgs)}else{if(pdsession.loginHttpStatus===401){setLoginResult(progress.data.Session.LOGIN_AUTHENTICATION_FAILURE,pdsession)}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);unameSave=null;pwSave=null;if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","login"))}return pdsession.loginResult};this._loginComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterLogin",pdsession,result,errObj,xhr)};this.logout=function(args){var isAsync=false,errorObject=null,xhr,deferred,params;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","logout()"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&this.authenticationModel){throw new Error("Attempted to call logout when there is no active session.")}if(typeof args==="object"){isAsync=args.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","logout","The async argument was invalid."))}deferred=args.deferred}xhr=new XMLHttpRequest;xhr.pdsession=this;try{xhr._jsdosession=jsdosession;xhr._deferred=deferred;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM||this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC||this.authenticationModel===progress.data.Session.AUTH_TYPE_BEARER){if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;xhr.onResponseFn=this._processLogoutResult;xhr.onResponseProcessedFn=this._logoutComplete}xhr.open("GET",this.serviceURI+"/static/auth/j_spring_security_logout",isAsync);try{xhr.withCredentials=true}catch(e){}xhr.setRequestHeader("Accept","application/json");setRequestHeaderFromContextProps(this,xhr);if(typeof this.onOpenRequest==="function"){setLastSessionXHR(xhr,this);params={xhr:xhr,verb:"GET",uri:this.serviceURI+"/static/auth/j_spring_security_logout",async:false,formPreTest:false,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send()}else{xhr._anonymousLogoutOK=true}}catch(e){this._reinitializeAfterLogout(this,false);throw e}if(!isAsync){try{this._processLogoutResult(xhr)}catch(e){throw e}}if(isAsync&&this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){try{this._processLogoutResult(xhr)}catch(e){errorObject=e}this._logoutComplete(this,null,errorObject,xhr)}};this.invalidate=function(){isInvalidated=true;cleanServicesManager()};this._logoutComplete=function(pdsession,result,errorObject,xhr){pdsession.trigger("afterLogout",pdsession,errorObject,xhr)};this._processLogoutResult=function(xhr){var logoutSucceeded;var pdsession=xhr.pdsession;var basicStatusOK=false;if(xhr._anonymousLogoutOK){logoutSucceeded=true}else if(xhr.status!==200){if(pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC||pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BEARER){if(xhr.status===404){logoutSucceeded=true}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=true}updateContextPropsFromResponse(pdsession,xhr);pdsession._reinitializeAfterLogout(pdsession,logoutSucceeded)};this._reinitializeAfterLogout=function(pdsession,success){setLoginResult(null,pdsession);setLoginHttpStatus(null,pdsession);setClientContextID(null,pdsession);setUserName(null,pdsession);setAuthProvider(null);_password=null;if(success){setRestApplicationIsOnline(false);setOepingAvailable(false);setPartialPingURI(defaultPartialPingURI);setLastSessionXHR(null,pdsession);clearTimeout(_timeoutID)}};this.addCatalog=function(arg1,arg2,arg3,arg4){var catalogURI,catalogUserName,catalogPassword,isAsync=false,xhr,deferred,iOSBasicAuthTimeout,catalogIndex,authProvider,that=this;function addCatalogAfterOpen(){progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(isAsync){xhr.onreadystatechange=that._onReadyStateChangeGeneric;xhr.onResponseFn=that._processAddCatalogResult;xhr.onResponseProcessedFn=that._addCatalogComplete;if(that.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex}try{if(typeof that.onOpenRequest==="function"){setLastSessionXHR(xhr,that);var params={xhr:xhr,verb:"GET",uri:catalogURI,async:false,formPreTest:false,session:that};that.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,that);xhr.send(null)}catch(e){throw new Error("Error retrieving catalog '"+catalogURI+"'.\n"+e.message)}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{return that._processAddCatalogResult(xhr)}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}customCredentials=true;if(arguments.length>0){if(typeof arg1==="object"){if(!arguments[0].offlineAddCatalog){if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to call addCatalog when there is no active session.")}}catalogURI=arg1.catalogURI;if(!catalogURI||typeof catalogURI!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogURI argument was missing or invalid."))}catalogUserName=arg1.userName;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogUserName argument was invalid."))}catalogPassword=arg1.password;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogPassword argument was invalid."))}isAsync=arg1.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The async argument was invalid."))}iOSBasicAuthTimeout=arg1.iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The iOSBasicAuthTimeout argument was invalid."))}authProvider=arg1.authProvider;deferred=arg1.deferred;catalogIndex=arg1.catalogIndex}else{catalogURI=arg1;if(typeof catalogURI!=="string"){throw new Error("First argument to Session.addCatalog must be the URL of the catalog.")}catalogUserName=arg2;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error("Second argument to Session.addCatalog must be a user name string.")}catalogPassword=arg3;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error("Third argument to Session.addCatalog must be a password string.")}}}else{throw new Error("Session.addCatalog is missing its first argument, the URL of the catalog.")}if(!authProvider){authProvider=this._authProvider;customCredentials=false}if(!catalogUserName){catalogUserName=this.userName}if(!catalogPassword){catalogPassword=_password}xhr=new XMLHttpRequest;xhr.pdsession=this;xhr._catalogURI=catalogURI;if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){if(isAsync){xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex;setTimeout(this._addCatalogComplete,10,this,progress.data.Session.CATALOG_ALREADY_LOADED,null,xhr);return progress.data.Session.ASYNC_PENDING}return progress.data.Session.CATALOG_ALREADY_LOADED}if(authProvider){authProvider._openRequestAndAuthorize(xhr,"GET",catalogURI,isAsync,addCatalogAfterOpen);return progress.data.Session.ASYNC_PENDING}else{this._setXHRCredentials(xhr,"GET",catalogURI,catalogUserName,catalogPassword,isAsync);return addCatalogAfterOpen()}};this._processAddCatalogResult=function(xhr){var _catalogHttpStatus=xhr.status;var theSession=xhr.pdsession;var servicedata;var catalogURI=xhr._catalogURI,serviceURL,theJSDOSession=jsdosession;if(!customCredentials){toggleOnlineState(xhr)}if((_catalogHttpStatus===200||_catalogHttpStatus===0)&&xhr.responseText){servicedata=theSession._parseCatalog(xhr);try{progress.data.ServicesManager.addCatalog(servicedata,theSession)}catch(e){if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){return progress.data.Session.CATALOG_ALREADY_LOADED}throw new Error("Error processing catalog '"+catalogURI+"'. \n"+e.message)}servicedata.forEach(function(service){serviceURL=theSession._prependAppURL(service.address);pushService(new progress.data.MobileServiceObject({name:service.name,uri:serviceURL}),theSession);if(service.settings&&service.settings.useXClientProps&&!theSession.xClientProps){console.warn("Catalog warning: Service settings property 'useXClientProps' "+"is true but 'xClientProps' property has not been set.")}});pushCatalogURIs(catalogURI,theSession);progress.data.ServicesManager.addSession(catalogURI,theSession);if(theJSDOSession){progress.data.ServicesManager.addJSDOSession(catalogURI,theJSDOSession)}}else if(_catalogHttpStatus===401){return progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","addCatalog"))}else{throw new Error("Error retrieving catalog '"+catalogURI+"'. Http status: "+_catalogHttpStatus+".")}return progress.data.Session.SUCCESS};this._addCatalogComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterAddCatalog",pdsession,result,errObj,xhr)};this.ping=function(args){var pingResult=false,pingArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:this._onReadyStateChangePing,offlineReason:null};if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(!this._authProvider&&this.loginResult!==progress.data.Session.LOGIN_SUCCESS){throw new Error("Attempted to call ping when not logged in.")}if(args){if(args.async!==undefined){pingArgs.async=args.async}if(args.doNotFireEvent!==undefined){pingArgs.fireEventIfOfflineChange=!args.doNotFireEvent}if(args.onCompleteFn&&typeof args.onCompleteFn==="function"){pingArgs.onCompleteFn=args.onCompleteFn}pingArgs.deferred=args.deferred;pingArgs.jsdosession=args.jsdosession}pingArgs.pingURI=that._makePingURI();that._sendPing(pingArgs);if(!pingArgs.async){if(pingArgs.xhr){pingResult=that._processPingResult(pingArgs);if(args.offlineReason!==undefined){args.offlineReason=pingArgs.offlineReason}}else{pingResult=false}if(args.xhr!==undefined){args.xhr=pingArgs.xhr}}return pingResult};this._isOnlineStateChange=function(isOnline){var stateChanged=false;if(isOnline&&!this.connected){stateChanged=true}else if(!isOnline&&this.connected){stateChanged=true}return stateChanged};this._checkServiceResponse=function(xhr,success,request){var offlineReason=null,wasOnline=this.connected;updateContextPropsFromResponse(this,xhr);if(!this._events){return}var offlineObservers=this._events.offline||[];var onlineObservers=this._events.online||[];if(offlineObservers.length===0&&onlineObservers.length===0){return}if(success){setRestApplicationIsOnline(true);setDeviceIsOnline(true)}else{if(deviceIsOnline){var localPingArgs={doNotFireEvent:true,offlineReason:null,async:false};if(!that.ping(localPingArgs)){offlineReason=localPingArgs.offlineReason;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}}if(wasOnline&&!this.connected){this.trigger("offline",this,offlineReason,request)}else if(!wasOnline&&this.connected){this.trigger("online",this,request)}};this._processPingResult=function(args){var xhr=args.xhr,pingResponseJSON,appServerStatus=null,wasOnline=this.connected,connectedBeforeCallback,assumeOepingFormat;if(args.hasOwnProperty("usingOepingFormat")){assumeOepingFormat=args.usingOepingFormat}else{assumeOepingFormat=oepingAvailable}if(xhr.status>=200&&xhr.status<300){updateContextPropsFromResponse(this,xhr);if(assumeOepingFormat){try{pingResponseJSON=JSON.parse(xhr.responseText);appServerStatus=pingResponseJSON.AppServerStatus}catch(e){console.error("Unable to parse ping response.")}}toggleOnlineState(xhr)}else{if(deviceIsOnline){if(xhr.status===0){args.offlineReason=progress.data.Session.SERVER_OFFLINE;setRestApplicationIsOnline(false)}else if(xhr.status===404||xhr.status===410){args.offlineReason=progress.data.Session.WEB_APPLICATION_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}else{args.offlineReason=progress.data.Session.DEVICE_OFFLINE}}if(appServerStatus){if(appServerStatus.PingStatus==="false"){args.offlineReason=progress.data.Session.APPSERVER_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}connectedBeforeCallback=this.connected;if(typeof xhr.onCompleteFn==="function"){xhr.onCompleteFn({pingResult:this.connected,xhr:xhr,offlineReason:args.offlineReason})}if(args.fireEventIfOfflineChange){if(wasOnline&&!connectedBeforeCallback){that.trigger("offline",that,args.offlineReason,null)}else if(!wasOnline&&connectedBeforeCallback){that.trigger("online",that,null)}}return this.connected};this._onReadyStateChangePing=function(){var xhr=this;var args;try{if(xhr.readyState===4){args={xhr:xhr,fireEventIfOfflineChange:true,offlineReason:null};that._processPingResult(args);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}}catch(e){}};this._pingtestOnReadyStateChange=function(){var xhr=this;try{if(xhr.readyState===4){var foundOeping=false;if(xhr.status>=200&&xhr.status<300){foundOeping=true}else{setPartialPingURI(that.loginTarget);console.warn("Default ping target not available, will use loginTarget instead.")}setOepingAvailable(foundOeping);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}}catch(e){}};var resolvePingURI=()=>{var xhr=new XMLHttpRequest,deferred=new progress.util.Deferred;xhr.onreadystatechange=(()=>{if(xhr.readyState===4){if(xhr.status===404){setPartialPingURI(classicPartialPingURI);deferred.reject(false)}else{deferred.resolve(true)}hasResolvedPingURI=true}});if(hasResolvedPingURI||this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this.authProvider){deferred.resolve(true)}else{this._openRequest(xhr,"GET",partialPingURI,true,()=>xhr.send())}return deferred.promise()};this._sendPing=function(args){var xhr=new XMLHttpRequest,that=this;args.xhr=xhr;function sendPingAfterOpen(){if(args.async){xhr.onreadystatechange=args.onReadyStateFn;xhr.onCompleteFn=args.onCompleteFn;xhr._jsdosession=jsdosession;xhr._deferred=args.deferred}progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(that.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr.send(null)}resolvePingURI().then(()=>{},()=>{args.pingURI=this._makePingURI()}).then(()=>{try{if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,"GET",args.pingURI,args.async,sendPingAfterOpen)}else{this._setXHRCredentials(xhr,"GET",args.pingURI,this.userName,_password,args.async);if(xhr.readyState===1){sendPingAfterOpen()}}}catch(e){args.error=e}})};this._makePingURI=function(){var pingURI=this.serviceURI+partialPingURI;if(progress.data.Session._useTimeStamp){pingURI=progress.data.Session._addTimeStampToURL(pingURI)}return pingURI};this._autoping=function(){that.ping({async:true})};this._setXHRCredentials=function(xhr,verb,uri,userName,password,async){if(userName&&this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(canPassCredentialsToOpen()){xhr.open(verb,uri,async,userName,password)}else{xhr.open(verb,uri,async)}var auth=_make_basic_auth(userName,password);xhr.setRequestHeader("Authorization",auth)}else{xhr.open(verb,uri,async)}};this._addCCIDtoURL=function(url){var urlPart1,urlPart2,jsessionidStr,index;if(this.clientContextId&&this.clientContextId!=="0"){if(url.substring(0,this.serviceURI.length)===this.serviceURI){jsessionidStr=";"+"JSESSIONID="+this.clientContextId;index=url.indexOf("?");if(index===-1){url+=jsessionidStr}else{urlPart1=url.substring(0,index);urlPart2=url.substring(index);url=urlPart1+jsessionidStr+urlPart2}}}return url};this._saveClientContextId=function(xhr){setClientContextIDfromXHR(xhr,this)};this._parseCatalog=function(xhr){var jsonObject;var catalogdata;try{jsonObject=JSON.parse(xhr.responseText);catalogdata=jsonObject.services}catch(e){console.error("Unable to parse response. Make sure catalog has correct format.");catalogdata=null}return catalogdata};this._prependAppURL=function(oldURL){if(!oldURL){return this.serviceURI}var newURL=oldURL;var pat=/^https?:\/\//i;if(!pat.test(newURL)){if(newURL.indexOf("/")!==0){newURL="/"+newURL}newURL=this.serviceURI+newURL}return newURL};function _addWithCredentialsAndAccept(xhr,acceptString){try{xhr.withCredentials=true;xhr.setRequestHeader("Accept",acceptString)}catch(e){}}function _make_basic_auth(user,pw){var tok=user+":"+pw;var hash=btoa(tok);return"Basic "+hash}var loginFormIDString="j_spring_security_check";function _gotLoginForm(xhr){return _findStringInResponseHTML(xhr,loginFormIDString)}var loginFailureIdentificationString="login failed";function _gotLoginFailure(xhr){return _findStringInResponseHTML(xhr,loginFailureIdentificationString)}function _findStringInResponseHTML(xhr,searchString){if(!xhr.responseText){return false}var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("text/html")>=0&&xhr.responseText.indexOf(searchString)>=0){return true}return false}function handleJSONLoginResponse(params){var jsonObject;params.statusFromjson=null;try{jsonObject=JSON.parse(params.xhr.responseText);if(jsonObject.status_code!==undefined&&jsonObject.status_txt!==undefined){params.statusFromjson=jsonObject.status_code}}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,params.session);setLoginHttpStatus(params.xhr.status,params.session);throw new Error("Unable to parse login response from server.")}}function setRequestHeaderFromContextProps(session,xhr){if(session.xClientProps){xhr.setRequestHeader("X-CLIENT-PROPS",session.xClientProps)}else if(session._contextProperties.contextHeader!==undefined){xhr.setRequestHeader("X-CLIENT-PROPS",session._contextProperties.contextHeader)}}function toggleOnlineState(xhr){var pdsession=that;setLoginHttpStatus(xhr.status,pdsession);if(pdsession.loginHttpStatus>=200&&pdsession.loginHttpStatus<400){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);pdsession._saveClientContextId(xhr);storeAllSessionInfo()}else{if(pdsession.loginHttpStatus===0||pdsession.loginHttpStatus===400||pdsession.loginHttpStatus===410){setRestApplicationIsOnline(false);setLoginResult(progress.data.AuthenticationProvider._getAuthFailureReason(xhr),pdsession)}else{setRestApplicationIsOnline(true);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);return pdsession.loginResult}function updateContextPropsFromResponse(session,xhr){var contextString,context;if(xhr){contextString=getResponseHeaderNoError(xhr,"X-CLIENT-PROPS");if(contextString){try{context=JSON.parse(contextString)}catch(e){}if(typeof context==="object"){session._contextProperties.setContext(context)}else{throw new Error(progress.data._getMsgText("jsdoMSG123","Session","X-CLIENT-PROPS"))}}else if(contextString===""){session._contextProperties.setContext({})}}}function cleanServicesManager(){progress.data.ServicesManager.cleanSession(that)}if(typeof options==="object"){jsdosession=options.jsdosession;newURI=options.serviceURI;setAuthProvider(options.authProvider);if(options.authProvider&&options.authProvider.hasClientCredentials()){_loginResult=progress.data.Session.LOGIN_SUCCESS}if(newURI&&newURI[newURI.length-1]==="/"){newURI=newURI.substring(0,newURI.length-1)}_storageKey=options._storageKey;if(_storageKey){if(retrieveSessionInfo(_storageKey)){storedAuthModel=retrieveSessionInfo("authenticationModel");storedURI=retrieveSessionInfo("serviceURI");if(storedAuthModel!==options.authenticationModel||storedURI!==newURI){clearAllSessionInfo()}else{setSessionInfoFromStorage(_storageKey);stateWasReadFromStorage=true}}if(options.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){_storageKey=undefined}}if(!stateWasReadFromStorage){if(newURI){setServiceURI(newURI,this)}if(options.authenticationModel){this.authenticationModel=options.authenticationModel}}}};progress.data.Session._useTimeStamp=true;var SEQ_MAX_VALUE=999999999999999;var _tsseq=SEQ_MAX_VALUE;var _tsprefix1=0;var _tsprefix2=0;progress.data.Session._getNextTimeStamp=function(){var seq;_tsseq+=1;seq=_tsseq;if(seq>=SEQ_MAX_VALUE){_tsseq=1;seq=1;var t=Math.floor((Date.now?Date.now():(new Date).getTime())/1e4);if(_tsprefix1===t){_tsprefix2+=1;if(_tsprefix2>=SEQ_MAX_VALUE){_tsprefix2=1}}else{_tsprefix1=t;Math.random();_tsprefix2=Math.round(Math.random()*1e10)}}return _tsprefix1+"-"+_tsprefix2+"-"+seq};progress.data.Session._addTimeStampToURL=function(url){var timeStamp="_ts="+progress.data.Session._getNextTimeStamp();url+=(url.indexOf("?")===-1?"?":"&")+timeStamp;return url};progress.data.Session._setNoCacheHeaders=function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache")};if(typeof Object.defineProperty==="function"){Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_REQUIRED",{value:0,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"CATALOG_ALREADY_LOADED",{value:4,enumerable:true});Object.defineProperty(progress.data.Session,"ASYNC_PENDING",{value:5,enumerable:true});Object.defineProperty(progress.data.Session,"EXPIRED_TOKEN",{value:6,enumerable:true});Object.defineProperty(progress.data.Session,"SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_ANON",{value:"anonymous",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BASIC",{value:"basic",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM",{value:"form",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_SSO",{value:"sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM_SSO",{value:"form_sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BEARER",{value:"bearer",enumerable:true});Object.defineProperty(progress.data.Session,"DEVICE_OFFLINE",{value:"Device is offline",enumerable:true});Object.defineProperty(progress.data.Session,"SERVER_OFFLINE",{value:"Cannot contact server",enumerable:true});Object.defineProperty(progress.data.Session,"WEB_APPLICATION_OFFLINE",{value:"Mobile Web Application is not available",enumerable:true});Object.defineProperty(progress.data.Session,"SERVICE_OFFLINE",{value:"REST web Service is not available",enumerable:true});Object.defineProperty(progress.data.Session,"APPSERVER_OFFLINE",{value:"AppServer is not available",enumerable:true})}else{progress.data.Session.LOGIN_SUCCESS=1;progress.data.Session.LOGIN_AUTHENTICATION_FAILURE=2;progress.data.Session.LOGIN_GENERAL_FAILURE=3;progress.data.Session.CATALOG_ALREADY_LOADED=4;progress.data.Session.SUCCESS=1;progress.data.Session.AUTHENTICATION_FAILURE=2;progress.data.Session.GENERAL_FAILURE=3;progress.data.Session.AUTH_TYPE_ANON="anonymous";progress.data.Session.AUTH_TYPE_BASIC="basic";progress.data.Session.AUTH_TYPE_FORM="form";progress.data.Session.AUTH_TYPE_SSO="sso";progress.data.Session.AUTH_TYPE_BEARER="bearer"}progress.data.Session.prototype=new progress.util.Observable;progress.data.Session.prototype.constructor=progress.data.Session;function validateSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}else{listenerData.scope=args[2]}}}progress.data.Session.prototype._eventNames=["offline","online","afterLogin","afterAddCatalog","afterLogout","afterDisconnect"];progress.data.Session.prototype.validateSubscribe=validateSessionSubscribe;progress.data.Session.prototype.toString=function(radix){return"progress.data.Session"};progress.data.JSDOSession=function JSDOSession(options){var _pdsession,_serviceURI,that=this,_name;Object.defineProperty(this,"authenticationModel",{get:function(){return _pdsession?_pdsession.authenticationModel:undefined},enumerable:true});Object.defineProperty(this,"authProvider",{get:function(){return _pdsession?_pdsession._authProvider:null},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _pdsession?_pdsession.catalogURIs:undefined},enumerable:true});Object.defineProperty(this,"clientContextId",{get:function(){return _pdsession?_pdsession.clientContextId:undefined},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return _pdsession?_pdsession.connected:undefined},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _pdsession?_pdsession.JSDOs:undefined},enumerable:true});Object.defineProperty(this,"loginResult",{get:function(){return _pdsession?_pdsession.loginResult:undefined},enumerable:true});Object.defineProperty(this,"loginHttpStatus",{get:function(){return _pdsession?_pdsession.loginHttpStatus:undefined},enumerable:true});Object.defineProperty(this,"onOpenRequest",{get:function(){return _pdsession?_pdsession.onOpenRequest:undefined},set:function(newval){if(_pdsession){_pdsession.onOpenRequest=newval}},enumerable:true});Object.defineProperty(this,"pingInterval",{get:function(){return _pdsession?_pdsession.pingInterval:undefined},set:function(newval){if(_pdsession){_pdsession.pingInterval=newval}},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _pdsession?_pdsession.services:undefined},enumerable:true});Object.defineProperty(this,"serviceURI",{get:function(){if(_pdsession&&_pdsession.serviceURI){return _pdsession.serviceURI}else{return _serviceURI}},enumerable:true});Object.defineProperty(this,"userName",{get:function(){return _pdsession?_pdsession.userName:undefined},enumerable:true});Object.defineProperty(this,"name",{get:function(){return _name},enumerable:true});Object.defineProperty(this,"_isInvalidated",{get:function(){return _pdsession._isInvalidated},enumerable:false});function settlePromise(promise,fulfill,result,info){if(fulfill){promise.resolve(that,result,info)}else{promise.reject(that,result,info)}}function genericSessionEventHandler(pdsession,result,errorObject,xhr,deferred){var myDeferred;if(xhr){myDeferred=xhr._deferred}else{myDeferred=deferred}settlePromise(myDeferred,result===progress.data.Session.SUCCESS?true:false,result,{errorObject:errorObject,xhr:xhr})}function onAfterAddCatalog(pdsession,result,errorObject,xhr){var deferred,fulfill=false,settleResult,info;if(result===progress.data.Session.EXPIRED_TOKEN){settleResult=progress.data.Session.EXPIRED_TOKEN}else if(result===progress.data.Session.LOGIN_AUTHENTICATION_FAILURE){settleResult=progress.data.Session.LOGIN_AUTHENTICATION_FAILURE}else{settleResult=progress.data.Session.GENERAL_FAILURE}if(xhr&&xhr._deferred){deferred=xhr._deferred;if(result!==progress.data.Session.SUCCESS&&result!==progress.data.Session.CATALOG_ALREADY_LOADED){result=result||progress.data.Session.GENERAL_FAILURE;deferred._overallCatalogResult=progress.data.Session.GENERAL_FAILURE}deferred._results[xhr._catalogIndex]={catalogURI:xhr._catalogURI,result:result,errorObject:errorObject,xhr:xhr};deferred._numCatalogsProcessed+=1;if(deferred._numCatalogsProcessed===deferred._numCatalogs){deferred._processedPromise=true;if(!deferred._overallCatalogResult){fulfill=true;settleResult=progress.data.Session.SUCCESS}if(settleResult===progress.data.Session.SUCCESS){if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,details:xhr._deferred._results}}}else{if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,errorObject:new Error(progress.data._getMsgText("jsdoMSG512")),details:xhr._deferred._results}}}settlePromise(xhr._deferred,fulfill,settleResult,info)}}}function onAfterLogout(pdsession,errorObject,xhr){var result=progress.data.Session.GENERAL_FAILURE,fulfill=false;if(xhr&&xhr._deferred){if(!errorObject&&!pdsession.loginResult){result=progress.data.Session.SUCCESS;fulfill=true}settlePromise(xhr._deferred,fulfill,result,{errorObject:errorObject,xhr:xhr})}}function onPingComplete(args){var xhr=args.xhr;if(xhr&&xhr._deferred){settlePromise(xhr._deferred,args.pingResult,args.pingResult,{offlineReason:args.offlineReason,xhr:xhr})}}this.login=function(username,password,options){var deferred=new progress.util.Deferred,iOSBasicAuthTimeout;function callIsAuthorized(){that.isAuthorized().then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(that,object.result,object.info)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","JSDOSession","login()"))}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout}if(!_pdsession._authProvider){_pdsession._authProvider=new progress.data.AuthenticationProvider({uri:this.serviceURI,authenticationModel:this.authenticationModel});_pdsession._authProvider.logout().then(function(){return _pdsession._authProvider.login(username,password)}).then(function(){callIsAuthorized()},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}else{throw new Error(progress.data._getMsgText("jsdoMSG062","JSDOSession","login()"))}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.disconnect=function(){var deferred=new progress.util.Deferred,errorObject;try{_pdsession.subscribe("afterDisconnect",genericSessionEventHandler,this);_pdsession._disconnect(deferred)}catch(e){errorObject=new Error(progress.data._getMsgText("jsdoMSG049","JSDOSession","disconnect",e.message))}if(errorObject){if(progress.util.Deferred.useJQueryPromises){throw errorObject}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:errorObject})}}else{return deferred.promise()}};this.addCatalog=function(catalogURI,unameOrOpts,password,opts){var deferred=new progress.util.Deferred,catalogURIs,numCatalogs,catalogIndex,addResult,errorObject,iOSBasicAuthTimeout,username,options,authProvider;try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(typeof catalogURI==="string"){catalogURIs=[catalogURI]}else if(catalogURI instanceof Array){catalogURIs=catalogURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","addCatalog","The first argument must be a string or an array of strings specifying the URI of the catalog."))}if(unameOrOpts){if(typeof unameOrOpts==="string"){if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG058","Session"))}username=unameOrOpts;if(opts){options=opts;options.authProvider=undefined}}else if(typeof unameOrOpts==="object"){options=unameOrOpts}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDOSession","2","object","addCatalog"))}}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout;if(options.authProvider){authProvider=options.authProvider}else if(this.authProvider){authProvider=this.authProvider}}if(!authProvider&&!this.authProvider&&!username){throw new Error(progress.data._getMsgText("jsdoMSG511"))}_pdsession.subscribe("afterAddCatalog",onAfterAddCatalog,this);numCatalogs=catalogURIs.length;deferred._numCatalogs=numCatalogs;deferred._numCatalogsProcessed=0;deferred._results=[];deferred._results.length=numCatalogs;for(catalogIndex=0;catalogIndex=200&&xhr.status<300){deferred.resolve(that,progress.data.Session.SUCCESS,info)}else{if(xhr.status===401){cbresult=progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else{cbresult=progress.data.Session.GENERAL_FAILURE}deferred.reject(that,cbresult,info)}}}catch(e){}};try{xhr.send()}catch(e){throw new Error("JSDOSession: Unable to validate authorization. "+e.message)}})}else{result=progress.data.Session.LOGIN_AUTHENTICATION_REQUIRED;deferred.reject(that,result,{xhr:xhr})}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(that,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.setContext=function(context){_pdsession._contextProperties.setContext(context)};this.setContextProperty=function(propertyName,propertyValue){_pdsession._contextProperties.setContextProperty(propertyName,propertyValue)};this.getContext=function(){return _pdsession._contextProperties.getContext()};this.getContextProperty=function(propertyName){return _pdsession._contextProperties.getContextProperty(propertyName)};this._onlineHandler=function(session,request){that.trigger("online",that,request)};this._offlineHandler=function(session,offlineReason,request){that.trigger("offline",that,offlineReason,request)};if(arguments.length>0&&typeof arguments[0]==="object"){if(options.serviceURI&&typeof options.serviceURI==="string"){_serviceURI=options.serviceURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options parameter must include a 'serviceURI' property that is a string."))}if(options.authenticationModel){if(typeof options.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The authenticationModel property of the options parameter must be a string."))}options.authenticationModel=options.authenticationModel.toLowerCase()}else{options.authenticationModel=progress.data.Session.AUTH_TYPE_ANON}if(options.authProvider){if(typeof options.authProvider!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG502","JSDOSession","options","constructor","authProvider"))}if(options.authProvider.authenticationModel!==progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authProvider.authenticationModel!==options.authenticationModel||options.authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authenticationModel!==progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG059","JSDOSession",options.authProvider.authenticationModel,options.authenticationModel))}if(typeof options.authProvider.hasClientCredentials==="function"){if(!options.authProvider.hasClientCredentials()){throw new Error(progress.data._getMsgText("jsdoMSG125","JSDOSession"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG505","JSDOSession","AuthenticationProvider","hasClientCredentials"))}}else if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG508"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options argument was missing or invalid."))}_name=options.name;_pdsession=new progress.data.Session({_storageKey:_name,_silent:true,authenticationModel:options.authenticationModel,serviceURI:options.serviceURI,jsdosession:this,authProvider:options.authProvider});try{if(options.context){this.setContext(options.context)}_pdsession.subscribe("online",this._onlineHandler,this);_pdsession.subscribe("offline",this._offlineHandler,this)}catch(err){_pdsession=undefined;throw err}};progress.data.JSDOSession.prototype=new progress.util.Observable;progress.data.JSDOSession.prototype.constructor=progress.data.JSDOSession;function validateJSDOSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}listenerData.scope=args[2]}}progress.data.JSDOSession.prototype._eventNames=["offline","online"];progress.data.JSDOSession.prototype.validateSubscribe=validateJSDOSessionSubscribe;progress.data.JSDOSession.prototype.toString=function(radix){return"progress.data.JSDOSession"};progress.data.getSession=function(options){var deferred=new progress.util.Deferred,authProvider,authProviderInitObject={},session;function sessionRejectHandler(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);if(authProvider&&authProvider.hasClientCredentials()){var callback=function(){deferred.reject(object.result,object.info)};authProvider.logout().then(callback,callback)}else{deferred.reject(object.result,object.info)}}function callbackRejectHandler(reason){deferred.reject(progress.data.Session.GENERAL_FAILURE,{reason:reason})}function loginHandler(object){let jsdosession;try{if(typeof session==="undefined"){jsdosession=new progress.data.JSDOSession(options)}else{jsdosession=session}jsdosession.isAuthorized().then(function(){return jsdosession.addCatalog(options.catalogURI)},sessionRejectHandler).then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(object.jsdosession,progress.data.Session.SUCCESS)},sessionRejectHandler)}catch(ex){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:ex})}}function callLogin(provider){var errorObject;if(typeof options.loginCallback!=="undefined"){options.loginCallback().then(function(result){try{provider.login(result.username,result.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}},callbackRejectHandler)}else if(options.username&&options.password){try{provider.login(options.username,options.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG052","getSession()"));sessionRejectHandler(provider,progress.data.Session.AUTHENTICATION_FAILURE,{errorObject:errorObject})}}if(typeof options!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options","object"))}if(typeof options.loginCallback!=="undefined"&&typeof options.loginCallback!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options.loginCallback","function"))}try{if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){if(!options.authenticationURI||!options.authProviderAuthenticationModel){throw new Error(progress.data._getMsgText("jsdoMSG509"))}}if(options.authenticationURI){authProviderInitObject.uri=options.authenticationURI;authProviderInitObject.authenticationModel=options.authProviderAuthenticationModel;if(typeof authProviderInitObject.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG502","progress.data.getSession","object","getSession","authProviderAuthenticationModel"))}}else{authProviderInitObject.uri=options.serviceURI;authProviderInitObject.authenticationModel=options.authenticationModel}authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;if(authProvider.hasClientCredentials()){let jsdosession=new progress.data.JSDOSession(options),statusCode=0;jsdosession.isAuthorized().then(()=>{session=jsdosession;return},obj=>{statusCode=obj&&obj.info&&obj.info.xhr&&obj.info.xhr.status;return progress.util.Deferred.when([jsdosession.invalidate(),options.authProvider.logout()])}).then(()=>{if(statusCode===401){authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;callLogin(authProvider)}else{loginHandler(authProvider)}})}else{if(authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){authProvider.login().then(loginHandler,sessionRejectHandler)}else{callLogin(authProvider)}}}catch(error){sessionRejectHandler(null,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}return deferred.promise()};progress.data.invalidateAllSessions=function(){var jsdosession,key,deferred=new progress.util.Deferred,jsdosessions=progress.data.ServicesManager._jsdosessions,invalidatePromises=[];try{for(key in jsdosessions){if(jsdosessions.hasOwnProperty(key)){jsdosession=jsdosessions[key];invalidatePromises.push(jsdosession.invalidate())}}progress.util.Deferred.when(invalidatePromises).then(function(){deferred.resolve(progress.data.Session.SUCCESS)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(progress.data.Session.GENERAL_FAILURE,info)})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()}})();if(typeof exports!=="undefined"){exports.progress=progress}(function(){"use strict";if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data.AuthenticationProvider=function AuthenticationProvider(initObject){var authProv,authModel,uri;if(typeof initObject==="object"){this._checkStringArg("constructor",initObject.authenticationModel,"initObject.authenticationModel","initObject.authenticationModel");this._checkStringArg("constructor",initObject.uri,"init-object.uri","init-object.uri")}else{throw new Error(progress.data._getMsgText("jsdoMSG033","AuthenticationProvider","the constructor","The init-object argument was missing or invalid."))}authModel=initObject.authenticationModel.toLowerCase();switch(authModel){case progress.data.Session.AUTH_TYPE_ANON:this._initialize(initObject.uri,progress.data.Session.AUTH_TYPE_ANON,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});authProv=this;break;case progress.data.Session.AUTH_TYPE_BASIC:authProv=new progress.data.AuthenticationProviderBasic(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM:authProv=new progress.data.AuthenticationProviderForm(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM_SSO:authProv=new progress.data.AuthenticationProviderSSO(initObject.uri);break;case progress.data.Session.AUTH_TYPE_BEARER:authProv=new progress.data.AuthenticationProviderBearer(initObject.uri);break;default:throw new Error(progress.data._getMsgText("jsdoMSG502","AuthenticationProvider","init-object","constructor","authenticationModel"))}return authProv};progress.data.AuthenticationProvider.prototype._loginProto=function(sendParam){var deferred=new progress.util.Deferred,xhr,uriForRequest,header,that=this;try{if(this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG051","AuthenticationProvider"))}xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){if(xhr.readyState===4){try{that._processLoginResult(xhr,deferred)}catch(e){}}};if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(this._loginURI)}else{uriForRequest=this._loginURI}this._openLoginRequest(xhr,uriForRequest);xhr.setRequestHeader("Accept","application/json");xhr.send(sendParam)}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.login=function(){return this._loginProto()};progress.data.AuthenticationProvider.prototype._openLoginRequest=function(xhr,uri){xhr.open("GET",uri,true);progress.data.Session._setNoCacheHeaders(xhr)};progress.data.AuthenticationProvider.prototype._processLoginResult=function(xhr,deferred){var result;if(xhr.status===200){this._loggedIn=true;this._storeInfo();result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};progress.data.AuthenticationProvider.prototype.logout=function(){var deferred=new progress.util.Deferred;try{this._reset();deferred.resolve(this,progress.data.Session.SUCCESS,{})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.hasClientCredentials=function(){return this._loggedIn};progress.data.AuthenticationProvider.prototype.hasRefreshToken=function(){return false};progress.data.AuthenticationProvider.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);xhr.setRequestHeader("Accept","application/json");callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};progress.data.AuthenticationProvider.prototype._initialize=function(uriParam,authModel,targetURIs){var tempURI,target;Object.defineProperty(this,"uri",{get:function(){return this._uri},enumerable:true});Object.defineProperty(this,"authenticationModel",{get:function(){return this._authenticationModel},enumerable:true});if(uriParam[uriParam.length-1]==="/"){tempURI=uriParam.substring(0,uriParam.length-1)}else{tempURI=uriParam}for(target in targetURIs){if(targetURIs.hasOwnProperty(target)){this[target]=tempURI+targetURIs[target]}}this._authenticationModel=authModel;this._uri=uriParam;this._loggedIn=false;this._dataKeys={uri:".uri",loggedIn:".loggedIn"};if(typeof sessionStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","AuthenticationProvider","sessionStorage"))}this._storage=sessionStorage;this._storageKey=this._uri;this._dataKeys.uri=this._storageKey+this._dataKeys.uri;this._dataKeys.loggedIn=this._storageKey+this._dataKeys.loggedIn;if(this._retrieveLoggedIn()){this._loggedIn=true}};progress.data.AuthenticationProvider.prototype._storeInfo=function(){this._storage.setItem(this._dataKeys.uri,JSON.stringify(this._uri));this._storage.setItem(this._dataKeys.loggedIn,JSON.stringify(this._loggedIn))};progress.data.AuthenticationProvider.prototype._retrieveInfoItem=function(propName){var jsonStr=this._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value};progress.data.AuthenticationProvider.prototype._retrieveURI=function(){return this._retrieveInfoItem(this._dataKeys.uri)};progress.data.AuthenticationProvider.prototype._retrieveLoggedIn=function(){return this._retrieveInfoItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._clearInfo=function(info){this._storage.removeItem(this._dataKeys.uri);this._storage.removeItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._reset=function(){this._clearInfo();this._loggedIn=false};progress.data.AuthenticationProvider.prototype._settlePromise=function(deferred,result,info){if(result===progress.data.Session.SUCCESS){deferred.resolve(this,result,info)}else{deferred.reject(this,result,info)}};progress.data.AuthenticationProvider.prototype._checkStringArg=function(fnName,argToCheck,argPosition,argName){if(typeof argToCheck!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","AuthenticationProvider",argPosition,"string",fnName))}else if(argToCheck.length===0){throw new Error(progress.data._getMsgText("jsdoMSG501","AuthenticationProvider",argName,fnName))}};progress.data.AuthenticationProvider._getAuthFailureReason=function(xhr){var contentType,jsonObject,result=progress.data.Session.AUTHENTICATION_FAILURE;if(xhr.status===401){contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>-1&&xhr.responseText){jsonObject=JSON.parse(xhr.responseText);if(jsonObject.error==="sso.token.expired_token"){result=progress.data.Session.EXPIRED_TOKEN}}}else{result=null}return result};Object.defineProperty(progress.data.AuthenticationProvider,"_homeLoginURIBase",{value:"/static/home.html",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLoginURIBase",{value:"/static/auth/j_spring_security_check",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLogoutURIBase",{value:"/static/auth/j_spring_security_logout",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenLoginURIBase",{value:progress.data.AuthenticationProvider._springLoginURIBase+"?OECP=yes",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenRefreshURIBase",{value:"/static/auth/token?op=refresh",enumerable:true})})();(function(){"use strict";progress.data.AuthenticationProviderBasic=function(uri){var defaultiOSBasicAuthTimeout,userName=null,password=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BASIC,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});this._reset();function make_basic_auth_header(user,pw){var tok=user+":"+pw,hash=btoa(tok);return"Basic "+hash}this._reset=function(){userName=null;password=null;progress.data.AuthenticationProviderBasic.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _basic_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBasic.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){userName=null;password=null}};this.login=function(userNameParam,passwordParam){this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");userName=userNameParam;password=passwordParam;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr);callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}}};function BasicProxy(){}BasicProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBasic.prototype=new BasicProxy;progress.data.AuthenticationProviderBasic.prototype.constructor=progress.data.AuthenticationProviderBasic})();(function(){"use strict";progress.data.AuthenticationProviderBearer=function(uri){var bearerToken=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BEARER,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});function make_Bearer_auth_header(token){return"Bearer "+token}this._reset=function(){bearerToken=null;progress.data.AuthenticationProviderBearer.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(bearerToken){auth=make_Bearer_auth_header(bearerToken);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _Bearer_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBearer.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){bearerToken=null}};this.login=function(token){this._checkStringArg("login",token,1,"token");bearerToken=token;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(bearerToken){auth=make_Bearer_auth_header(bearerToken);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"))}callback(errorObject)}};function BearerProxy(){}BearerProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBearer.prototype=new BearerProxy;progress.data.AuthenticationProviderBearer.prototype.constructor=progress.data.AuthenticationProviderBearer})();(function(){"use strict";var fn;progress.data.AuthenticationProviderForm=function(uri){this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM,{_loginURI:progress.data.AuthenticationProvider._springLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase})};function FormProxy(){}FormProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderForm.prototype=new FormProxy;progress.data.AuthenticationProviderForm.prototype.constructor=progress.data.AuthenticationProviderForm;progress.data.AuthenticationProviderForm.prototype.login=function(userNameParam,passwordParam){var deferred=new progress.util.Deferred,xhr,that=this;this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");return this._loginProto("j_username="+encodeURIComponent(userNameParam)+"&j_password="+encodeURIComponent(passwordParam)+"&submit=Submit")};progress.data.AuthenticationProviderForm.prototype._openLoginRequest=function(xhr,uri){xhr.open("POST",uri,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.setRequestHeader("Pragma","no-cache");xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.withCredentials=true};progress.data.AuthenticationProviderForm.prototype.logout=function(){var deferred=new progress.util.Deferred,xhr,that=this;try{if(!this._loggedIn){deferred.resolve(this,progress.data.Session.SUCCESS,{})}else{xhr=new XMLHttpRequest;this._openLogoutRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){try{that._processLogoutResult(xhr,deferred)}catch(e){}}};xhr.send()}this._reset()}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProviderForm.prototype._openLogoutRequest=function(xhr){xhr.open("GET",this._logoutURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Accept","application/json")};progress.data.AuthenticationProviderForm.prototype._processLogoutResult=function(xhr,deferred){var result;if(xhr.status===200){result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};fn=progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize;progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){function afterSuper(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.withCredentials=true;callback(xhr)}}try{progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super.apply(this,[xhr,verb,uri,async,afterSuper])}catch(e){callback(e)}};progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super=fn})();(function(){"use strict";var fn;progress.data.AuthenticationProviderSSO=function(uri){var that=this,_automaticTokenRefresh,temp,ssoTokenInfo=null,tokenDataKeys={token:".access_token",refreshToken:".refresh_token",tokenType:".token_type",expiration:".expires_in",accessTokenExpiration:".accessTokenExpiration"};function storeTokenInfo(info){var date,accessTokenExpiration;if(info.access_token.length){that._storage.setItem(tokenDataKeys.token,JSON.stringify(info.access_token))}if(info.refresh_token.length){that._storage.setItem(tokenDataKeys.refreshToken,JSON.stringify(info.refresh_token));date=new Date;accessTokenExpiration=date.getTime()+info.expires_in*1e3*.75;that._storage.setItem(tokenDataKeys.accessTokenExpiration,JSON.stringify(accessTokenExpiration))}else{that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}that._storage.setItem(tokenDataKeys.tokenType,JSON.stringify(info.token_type));that._storage.setItem(tokenDataKeys.expiration,JSON.stringify(info.expires_in))}function retrieveTokenProperty(propName){var jsonStr=that._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}function retrieveToken(){return retrieveTokenProperty(tokenDataKeys.token)}function retrieveRefreshToken(){return retrieveTokenProperty(tokenDataKeys.refreshToken)}function retrieveAccessTokenExpiration(){return retrieveTokenProperty(tokenDataKeys.accessTokenExpiration)}function retrieveTokenType(){return retrieveTokenProperty(tokenDataKeys.tokenType)}function getToken(){return retrieveToken()}function retrieveExpiration(){return retrieveTokenProperty(tokenDataKeys.expiration)}function clearTokenInfo(info){that._storage.removeItem(tokenDataKeys.token);that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.tokenType);that._storage.removeItem(tokenDataKeys.expiration);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}function openRefreshRequest(xhr){xhr.open("POST",that._refreshURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Accept","application/json")}function processRefreshResult(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",ex.message))}}else if(xhr.status===401){that._reset();result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}that._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})}this._processLoginResult=function(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){this._loggedIn=true;try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",ex.message))}if(result!==progress.data.Session.SUCCESS){var callback=function(params){params=progress.util.Deferred.getParamObject(params);params.provider._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})};this.logout().then(callback,callback);return}}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};this._reset=function(){progress.data.AuthenticationProviderSSO.prototype._reset.apply(this);clearTokenInfo();ssoTokenInfo=null};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var that=this,date,errorObject;function afterRefreshCheck(provider,result,info){if(result===progress.data.Session.AUTHENTICATION_FAILURE){callback(new Error(progress.data._getMsgText("jsdoMSG060")))}else{progress.data.AuthenticationProviderSSO.prototype._openRequestAndAuthorize.apply(that,[xhr,verb,uri,async,function(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.setRequestHeader("Authorization","oecp "+getToken());callback(xhr)}}])}}if(this.hasClientCredentials()){date=new Date;if(this.automaticTokenRefresh&&this.hasRefreshToken()&&date.getTime()>retrieveAccessTokenExpiration()){try{var callback=function(params,result,info){params=progress.util.Deferred.getParamObject(params,result,info);afterRefreshCheck(params.provider,params.result,params.info)};this.refresh().then(callback,callback)}catch(e){callback(e)}}else{afterRefreshCheck(this,progress.data.Session.SUCCESS,null)}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};this.hasClientCredentials=function(){return retrieveToken()===null?false:true};this.refresh=function(){var deferred=new progress.util.Deferred,xhr;try{if(!this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG053","AuthenticationProvider","refresh"))}if(!this.hasRefreshToken()){throw new Error(progress.data._getMsgText("jsdoMSG054","AuthenticationProvider"))}xhr=new XMLHttpRequest;openRefreshRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){try{processRefreshResult(xhr,deferred)}catch(e){}}};xhr.send('{"token_type":"'+retrieveTokenType()+'","refresh_token":"'+retrieveRefreshToken()+'"}')}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.hasRefreshToken=function(){return retrieveRefreshToken()===null?false:true};this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM_SSO,{_loginURI:progress.data.AuthenticationProvider._springFormTokenLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase,_refreshURI:progress.data.AuthenticationProvider._springFormTokenRefreshURIBase});_automaticTokenRefresh=true;Object.defineProperty(this,"automaticTokenRefresh",{get:function(){return _automaticTokenRefresh},set:function(value){if(value===true||value===false){_automaticTokenRefresh=value}else{throw new Error(progress.data._getMsgText("jsdoMSG061","AuthenticationProvider","automaticTokenRefresh"))}},enumerable:true});this._dataKeys.automaticTokenRefresh=this._storageKey+".automaticTokenRefresh";temp=this._retrieveInfoItem(this._dataKeys.automaticTokenRefresh);if(temp===false){_automaticTokenRefresh=false}tokenDataKeys.token=this._storageKey+tokenDataKeys.token;tokenDataKeys.refreshToken=this._storageKey+tokenDataKeys.refreshToken;tokenDataKeys.tokenType=this._storageKey+tokenDataKeys.tokenType;tokenDataKeys.expiration=this._storageKey+tokenDataKeys.expiration;tokenDataKeys.accessTokenExpiration=this._storageKey+tokenDataKeys.accessTokenExpiration;if(retrieveToken()){this._loggedIn=true}};function SSOProxy(){}SSOProxy.prototype=progress.data.AuthenticationProviderForm.prototype;progress.data.AuthenticationProviderSSO.prototype=new SSOProxy;progress.data.AuthenticationProviderSSO.prototype.constructor=progress.data.AuthenticationProviderSSO;fn=progress.data.AuthenticationProviderSSO.prototype._storeInfo;progress.data.AuthenticationProviderSSO.prototype._storeInfo=function(){progress.data.AuthenticationProviderSSO.prototype._storeInfo._super.apply(this);this._storage.setItem(this._dataKeys.automaticTokenRefresh,JSON.stringify(this._automaticTokenRefresh))};progress.data.AuthenticationProviderSSO.prototype._storeInfo._super=fn;fn=progress.data.AuthenticationProviderSSO.prototype._clearInfo;progress.data.AuthenticationProviderSSO.prototype._clearInfo=function(){progress.data.AuthenticationProviderSSO.prototype._clearInfo._super.apply(this);this._storage.removeItem(this._dataKeys.automaticTokenRefresh)};progress.data.AuthenticationProviderSSO.prototype._clearInfo._super=fn})(); //# sourceMappingURL=progress.jsdo.min.js.map \ No newline at end of file diff --git a/lib/progress.jsdo.min.js.map b/lib/progress.jsdo.min.js.map index 3e8b590..448a398 100644 --- a/lib/progress.jsdo.min.js.map +++ b/lib/progress.jsdo.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["progress.jsdo.js"],"names":["isNativeScript","isNodeJS","pkg_xmlhttprequest","pkg_nodeLocalstorage","pkg_nativescriptLocalstorage","pkg_fileSystemAccess","pkg_base64","XMLHttpRequest","require","e","console","error","localStorage","sessionStorage","exception1","exception2","btoa","encode","exception3","LocalStorage","module","progress","data","util","STRING_OBJECT_TYPE","DATE_OBJECT_TYPE","CHARACTER_ABL_TYPE","Deferred","this","_deferred","prototype","promise","that","useJQueryPromises","$","_jQuerydeferred","_promise","Error","Promise","resolve","reject","_resolveArguments","_rejectArguments","setTimeout","apply","arg1","arg2","arg3","arguments","object","getParamObject1","when","deferreds","all","objectName","result","info","JSDOSession","AuthenticationProvider","JSDO","success","xhr","request","batch","info2","log","getParamObject","Observable","_filterObservers","observers","fn","scope","operation","filter","el","validateSubscribe","args","evt","listenerData","length","undefined","subscribe","_getMsgText","toString","_events","toLowerCase","message","push","unsubscribe","trigger","op","Array","slice","call","forEach","unsubscribeAll","saveToLocalStorage","name","dataObj","setItem","JSON","stringify","readFromLocalStorage","jsonStr","getItem","parse","clearLocalStorage","removeItem","_convertToABLWhereString","tableRef","logic","idx","field","fieldInfo","type","format","operator","value","ablType","filters","whereOperators","eq","neq","gt","gte","lt","lte","contains","doesnotcontain","endswith","startswith","isnull","isnotnull","isempty","isnotempty","_name","_jsdo","_fields","origName","_getObjectType","replace","_getABLType","_format","join","_convertToSQLQueryString","addSelect","fieldFormat","filterStr","usingLike","_getFormat","Object","fmt","values","formatRegExp","match","index","placeholderFormat","parseInt","_toString","substring","str","_formatDate","_pad","number","digits","zeros","end","String","date","dateFormatRegExp","minutes","sign","getDate","getMonth","getFullYear","getHours","getMinutes","getSeconds","getMilliseconds","getTime","getTimezoneOffset","toISOString","jsdoSettingsProcessor","jsdoSettings","authenticationModel","PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS","PROGRESS_JSDO_OP_STRING","PROGRESS_JSDO_ROW_STATE_STRING","_nextid","_uidprefix","Date","now","UID_MAX_VALUE","_getNextId","uid","msg","msgs","jsdoMSG000","jsdoMSG001","jsdoMSG002","jsdoMSG003","jsdoMSG004","jsdoMSG005","jsdoMSG006","jsdoMSG007","jsdoMSG008","jsdoMSG009","jsdoMSG010","jsdoMSG011","jsdoMSG012","jsdoMSG020","jsdoMSG021","jsdoMSG022","jsdoMSG023","jsdoMSG024","jsdoMSG025","jsdoMSG026","jsdoMSG030","jsdoMSG031","jsdoMSG032","jsdoMSG033","jsdoMSG034","jsdoMSG035","jsdoMSG036","jsdoMSG037","jsdoMSG038","jsdoMSG039","jsdoMSG040","jsdoMSG041","jsdoMSG042","jsdoMSG043","jsdoMSG044","jsdoMSG045","jsdoMSG046","jsdoMSG047","jsdoMSG048","jsdoMSG049","jsdoMSG050","jsdoMSG051","jsdoMSG052","jsdoMSG053","jsdoMSG054","jsdoMSG055","jsdoMSG056","jsdoMSG057","jsdoMSG058","jsdoMSG059","jsdoMSG060","jsdoMSG061","jsdoMSG062","jsdoMSG100","jsdoMSG101","jsdoMSG110","jsdoMSG111","jsdoMSG112","jsdoMSG113","jsdoMSG114","jsdoMSG115","jsdoMSG116","jsdoMSG117","jsdoMSG118","jsdoMSG119","jsdoMSG120","jsdoMSG121","jsdoMSG122","jsdoMSG123","jsdoMSG124","jsdoMSG125","jsdoMSG126","jsdoMSG127","jsdoMSG500","jsdoMSG501","jsdoMSG502","jsdoMSG503","jsdoMSG504","jsdoMSG505","jsdoMSG506","jsdoMSG507","jsdoMSG508","jsdoMSG509","jsdoMSG510","jsdoMSG511","jsdoMSG512","jsdoMSG998","getMsgText","n","text","i","RegExp","PluginManager","_plugins","addPlugin","plugin","getPlugin","JSIndexEntry","JSTableRef","jsdo","tableName","_schema","_primaryKeys","_processed","_visited","record","_data","_index","_tmpIndex","_hasEmptyBlocks","_beforeImage","_added","_changed","_deleted","_lastErrors","_convertForServer","_createIndex","block","id","idProperty","_id","_resource","_needCompaction","_compact","newDataArray","_loadBeforeImageData","jsonObject","beforeImageJsonIndex","keyFields","prodsBeforeData","_dataSetName","tmpIndex","record2","recordId","key","tmpKeyIndex","jsrecord","tmpDataIndex","tmpDeletedIndex","j","keys","_findById","_getKey","key2","_remove","copy","_copyRecord","_tableRef","_deleteProdsProperties","JSRecord","tableObject","beforeRecord","prodsErrors","item","_errorString","_clearData","_setRecord","hasData","_nestChildren","_getDataWithNestedChildren","_getRelatedData","getData","params","_getData","numEmptyBlocks","sort","top","sortFields","dir","sortObject","_processSortFields","_getCompareFn","skip","splice","_recToDataObject","includeChildren","array","dataObject","_children","_buffers","_dataProperty","_recFromDataObject","getSchema","setSchema","schema","fieldName","add","_add","create","trackChanges","setWorkingRecord","prefixElement","maxItems","_getDefaultValue","_getArrayField","items","_convertType","useRelationships","_relationship","_parent","childFieldName","parentFieldName","v","autoSort","_sortRecords","_sortFn","_sortObject","_needsAutoSorting","_sort","ret","_compareFields","parentRecord","childBuf","_isNested","k","childRecord","m","_hasNestedChild","_findFirst","ignoreRelationships","childTable","_defaultTableRef","assign","update","remove","bTrackChanges","getId","getErrors","getErrorString","findById","find","foreach","_inforeach","_equalRecord","rec1","rec2","value1","value2","caseSensitive","toUpperCase","keyObject","jsrec1","jsrec2","sortAscending","defineProperty","_autoSort","get","set","enumerable","writeable","_caseSensitive","fields","indexOf","sortOrder","setSortFields","setSortFn","addRecords","addMode","isInvoke","_addRecords","acceptChanges","rejectChanges","_undoCreate","_undoUpdate","_undoDelete","hasChanges","getChanges","rowState","_OP_CREATE","_OP_UPDATE","_OP_DELETE","_clearErrorStrings","_applyChanges","_rejected","acceptRowChanges","found","rejectRowChanges","hasNestedChild","childBufObj","_saveBeforeImageUpdate","_sortRecord","resNameOrParmObj","serviceName","_super","Session","_defineProperty","fnGet","element","ARRAY_INDEX_SEPARATOR","isNaN","_hasSubmitOperation","_hasCUDOperations","_numBuffers","_async","operations","_session","_useSubmit","autoApplyChanges","_localStorage","_fillMergeMode","autoFill","eventName","prop","ServicesManager","getResource","url","dataProperty","buffer","properties","fnName","generic","myservice","getService","service","_pushJSDOs","buf","_properties","primaryKeys","trim","$ref","relations","relationship","childName","parentName","relationFields","defaultValue","t","d","isDate","arrayFieldName","isDataSet","_invokeComplete","async","deferred","_invokeSuccess","_invokeError","_httpRequest","method","reqBody","afterOpenRequest","input","setRequestHeader","send","exception","_checkServiceResponse","onCompleteFn","onSuccessFn","onErrorFn","onreadystatechange","onReadyStateChangeGeneric","useRequest","settings","_openRequest","_getDataObject","oldUseRelationships","_getDataObjectAsNested","bufObj","_unnestData","obj","itemType","elements","split","convertItem","parseFloat","_clearErrors","clearErrorString","_setAllRecordsRejected","param","changes","hasErrors","hasRejected","hasCommittedRecords","_allRecordsRejected","_someRecordsRejected","fill","objParam","mapping","getMethodProperties","mappingType","mergeMode","MODE_APPEND","MODE_EMPTY","MODE_MERGE","MODE_REPLACE","requestMapping","capabilities","_fillSuccess","_fillError","_fillComplete","read","errorObject","_execGenericOperation","_convertRequestData","operationStr","_OP_READ","_OP_SUBMIT","_initConvertForServer","_convertFieldsForServer","_ablTypeNeedsConversion","beforeData","_convertTableData","tableData","_convertRowData","_convertField","resultArray","_convertDate","needsConversion","_undefWorkingRecord","saveChanges","useSubmit","_checkThatJSDOHasRequiredOperations","_syncDataSetForSubmit","_syncDataSetForCUD","_syncSingleTable","checkedDelete","checkedCreate","checkedUpdate","_confirmOperationExists","invoke","_syncTableRef","rowData","requestData","dataSetObject","_useBeforeImage","_createComplete","_createSuccess","_createError","useBeforeImageFormat","beforeObject","beforeRowData","sendOnlyChanges","_updateComplete","_updateSuccess","_updateError","childTableName","_deleteComplete","_deleteSuccess","_deleteError","opType","useBeforeImage","_isBatchComplete","_isBatchSuccess","_updateLastErrors","_fireAfterSaveChanges","fireAfterSaveChanges","addedRecords","complete","completeFn","_saveChangesComplete","successFn","_saveChangesSuccess","errorFn","_saveChangesError","jsrecords","_createChangeSet","_createTTChangeSet","_saveChangesSuccessTT","dataSetName","alwaysCreateTable","changeSetJsonObject","dataSetJsonObject","_hasChanges","_addDeletesToChangeSet","_addCreatesToChangeSet","_addChangesToChangeSet","tempTableJsonObject","_addRowToTTChangeSet","hasOwnProperty","event","_createDataAndChangeSet","_addRecordsToObject","_doesRecordHaveCreateBIData","_addCreatedRowToChangeSet","_doesRecordHaveUpdateBIData","_addChangedRowToChangeSet","changedId","hasUpdates","_addDeletedRowToChangeSet","beforeTableJsonObject","_getTableInBeforeJsonObject","source","target","onlyChangesRecord","newObject","deleteRowState","beforeImageJsonObject","dataHasBeenProcessed","checkBeforeImage","isAfterSame","_sameData","isBeforeSame","_getBeforeRecordFromObject","afterRecord","tablename","record1","_mergeRead","datasetBuffer","srcData","_mergeUpdateRecord","_setErrorString","errorString","setInBeforeTable","_arrayFromDataObject","_mergeUpdateForCUD","hasError","tableJsonObject","prods_id","_getErrorStringFromJsonObject","_checkForDeleteError","beforeJsonObject","_mergeUpdateForSubmit","_fireCUDTriggersForSubmit","errorsJsonObject","response","responseMapping","entry","deleteProdsProps","_checkSaveComplete","records","status","_getErrorsFromRequest","errors","errorArray","retValString","responseObject","responseText","_retVal","RETVAL","_errors","_errorNum","_errorMsg","APP_ERROR","errorNum","ERROR","statusText","errorText","DATA_ERROR","_mergeInvoke","dataParameterName","_tempTableName","xType","readyState","_saveClientContextId","concat","setProperties","propertiesObject","setProperty","propertyName","propertyValue","getProperties","getProperty","saveLocal","dataMode","callee","ALL_DATA","CHANGES_ONLY","_prepareDataObjectForLocalStorage","readLocal","_hasMatchingSchema","_restoreFromLocalStorage","addLocalRecords","_containsPrimaryKeys","storageObject","isValid","deleteLocal","option","_restoreDataForTable","_operations","constructor","radix","sortDir","ablFilter","sqlQuery","methodProperties","position","capabilitiesObject","reqCapabilities","options","doConversion","orderBy","ui","UITableRef","_listview","_detailPage","_listviewContent","addItem","detailForm","clearItems","itemTemplate","UIHelper","_itemTemplate","listviewElement","document","getElementById","innerHTML","_getFormFieldValue","detailPageName","val","_setFormField","display","pageName","showListView","uiTableRef","html","attr","filterable","listview","autoLink","each","bind","getListViewRecord","onSelect","childElementCount","children","onclick","getFormFields","tmpFields","htmltext","charAt","fieldLabel","title","fieldTemplate","_fieldTemplate","htmlIElement","getAttribute","getFormRecord","_getIdOfElement","setDetailPage","setListView","pos","_defaultUITableRef","_uiTableRef","cnt","_defaultItemTemplate","_defaultFieldTemplate","setItemTemplate","template","setFieldTemplate","_services","_resources","_sessions","_jsdosessions","addResource","resource","addService","addSession","catalogURI","session","addJSDOSession","jsdosession","getSession","cleanSession","servicesKey","resourcesKey","sessionsKey","services","resources","sessions","jsdosessions","extractParamsFromURL","urlParams","paramName","c","addCatalog","baseAddress","address","path","primaryKey","tableProperties","RelationName","opname","verb","func","definition","Boolean","encodeURIComponent","reqParam","unwrapped","paramsFromURL","printDebugInfo","resourceName","cSchema","cOperations","MobileServiceObject","_uri","uri","ContextProperties","contextObject","contextString","header","setContextProperty","setContext","context","getContext","getContextProperty","defPropSupported","isUserAgentiOS","isFirefox","isEdge","isIE","canPassCredentialsToOpenWithCORS","defaultiOSBasicAuthTimeout","deviceIsOnline","restApplicationIsOnline","oepingAvailable","defaultPartialPingURI","partialPingURI","_storageKey","_authProvider","customCredentials","storedAuthModel","storedURI","newURI","stateWasReadFromStorage","_silent","warn","navigator","userAgent","canPassCredentialsToOpen","_onlineHandler","setDeviceIsOnline","_offlineHandler","DEVICE_OFFLINE","window","addEventListener","_catalogURIs","_jsdos","onOpenRequest","_password","_userName","_loginTarget","_serviceURI","_loginResult","_loginHttpStatus","_clientContextId","_authenticationModel","AUTH_TYPE_ANON","newval","AUTH_TYPE_FORM","AUTH_TYPE_BASIC","AUTH_TYPE_SSO","storeSessionInfo","_lastSessionXHR","loginResult","LOGIN_SUCCESS","_pingInterval","_timeoutID","_autoping","clearTimeout","_contextProperties","isInvalidated","setAuthProvider","userName","loginTarget","serviceURI","catalogURIs","loginHttpStatus","clientContextId","lastSessionXHR","infoName","retrieveSessionInfo","clearSessionInfo","storeAllSessionInfo","pingInterval","clearAllSessionInfo","setSessionInfoFromStorage","authproviderInitObject","setLoginResult","setUserName","setServiceURI","setLoginHttpStatus","setClientContextID","setRestApplicationIsOnline","setOepingAvailable","setPartialPingURI","newname","sessionObject","setLoginTarget","pushCatalogURIs","pushService","serviceObject","findService","setClientContextIDfromXHR","getResponseHeaderNoError","ccid","setLastSessionXHR","headerName","allHeaders","_pdsResponseHeaders","regExp","getAllResponseHeaders","getResponseHeader","callback","urlPlusCCID","afterOpenAndAuthorize","arg","setRequestHeaderFromContextProps","formPreTest","_isInvalidated","_prependAppURL","_addCCIDtoURL","_useTimeStamp","_addTimeStampToURL","_openRequestAndAuthorize","_setXHRCredentials","_addWithCredentialsAndAccept","pingTestCallback","cbArgs","foundOeping","pingResult","_onReadyStateChangeGeneric","_requestTimeout","onResponseFn","onResponseProcessedFn","GENERAL_FAILURE","pdsession","_disconnect","_processDisconnectResult","_reinitializeAfterLogout","SUCCESS","_disconnectComplete","errObj","pwSave","unameSave","login","loginUserName","loginPassword","uname","pw","isAsync","iOSBasicAuthTimeout","uriForRequest","password","restURLtemp","LOGIN_GENERAL_FAILURE","_setNoCacheHeaders","_isAsync","_afterFormPretestLogin","_processLoginResult","_loginComplete","_iosTimeOutExpired","abort","_jsdosession","isFormPreTest","ASYNC_PENDING","formLoginParams","theSession","doFormLogin","oldXHR","contentType","needAuth","statusFromjson","handleJSONLoginResponse","_gotLoginForm","open","cbparams","_afterFormLogin","_gotLoginFailure","pingTestArgs","pingURI","fireEventIfOfflineChange","onReadyStateFn","_pingtestOnReadyStateChange","_makePingURI","_sendPing","LOGIN_AUTHENTICATION_FAILURE","updateContextPropsFromResponse","logout","_processLogoutResult","_logoutComplete","withCredentials","_anonymousLogoutOK","invalidate","cleanServicesManager","logoutSucceeded","basicStatusOK","arg4","catalogUserName","catalogPassword","catalogIndex","authProvider","addCatalogAfterOpen","_processAddCatalogResult","_addCatalogComplete","_catalogIndex","offlineAddCatalog","_catalogURI","CATALOG_ALREADY_LOADED","_catalogHttpStatus","servicedata","serviceURL","theJSDOSession","toggleOnlineState","_parseCatalog","useXClientProps","xClientProps","_getAuthFailureReason","ping","pingArgs","_onReadyStateChangePing","offlineReason","doNotFireEvent","_processPingResult","_isOnlineStateChange","isOnline","stateChanged","wasOnline","connected","offlineObservers","offline","onlineObservers","online","localPingArgs","pingResponseJSON","appServerStatus","connectedBeforeCallback","assumeOepingFormat","usingOepingFormat","AppServerStatus","SERVER_OFFLINE","WEB_APPLICATION_OFFLINE","PingStatus","APPSERVER_OFFLINE","sendPingAfterOpen","auth","_make_basic_auth","urlPart1","urlPart2","jsessionidStr","catalogdata","oldURL","newURL","pat","test","acceptString","user","tok","hash","loginFormIDString","_findStringInResponseHTML","loginFailureIdentificationString","searchString","status_code","status_txt","contextHeader","hasClientCredentials","SEQ_MAX_VALUE","_tsseq","_tsprefix1","_tsprefix2","_getNextTimeStamp","seq","Math","floor","random","round","timeStamp","AUTHENTICATION_FAILURE","validateSessionSubscribe","_eventNames","_pdsession","JSDOs","settlePromise","fulfill","genericSessionEventHandler","myDeferred","onAfterAddCatalog","settleResult","EXPIRED_TOKEN","_overallCatalogResult","_results","_numCatalogsProcessed","_numCatalogs","_processedPromise","details","onAfterLogout","onPingComplete","username","callIsAuthorized","isAuthorized","then","disconnect","unameOrOpts","opts","numCatalogs","addResult","authProv","cbresult","LOGIN_AUTHENTICATION_REQUIRED","AUTH_TYPE_FORM_SSO","err","validateJSDOSessionSubscribe","authProviderInitObject","sessionRejectHandler","callbackRejectHandler","reason","loginHandler","ex","callLogin","provider","loginCallback","authenticationURI","authProviderAuthenticationModel","invalidateAllSessions","invalidatePromises","exports","initObject","authModel","_checkStringArg","_initialize","_loginURI","_homeLoginURIBase","AuthenticationProviderBasic","AuthenticationProviderForm","AuthenticationProviderSSO","_loginProto","sendParam","_loggedIn","_openLoginRequest","_storeInfo","_settlePromise","_reset","hasRefreshToken","uriParam","targetURIs","tempURI","_dataKeys","loggedIn","_storage","_retrieveLoggedIn","_retrieveInfoItem","propName","_retrieveURI","_clearInfo","argToCheck","argPosition","argName","_springLoginURIBase","make_basic_auth_header","_basic_processLoginResult","userNameParam","passwordParam","BasicProxy","_logoutURI","_springLogoutURIBase","FormProxy","_openLogoutRequest","afterSuper","_automaticTokenRefresh","temp","ssoTokenInfo","tokenDataKeys","token","refreshToken","tokenType","expiration","accessTokenExpiration","storeTokenInfo","access_token","refresh_token","expires_in","token_type","retrieveTokenProperty","retrieveToken","retrieveRefreshToken","retrieveAccessTokenExpiration","retrieveTokenType","getToken","retrieveExpiration","clearTokenInfo","openRefreshRequest","_refreshURI","processRefreshResult","ssoTokenJSON","afterRefreshCheck","automaticTokenRefresh","refresh","_springFormTokenLoginURIBase","_springFormTokenRefreshURIBase","SSOProxy"],"mappings":";;;;;;;;;;;;;;;;;CA0CC,WAiBG,IAAIA,eAAiB,MACjBC,SAAW,MAEf,IAAIC,mBAAkC,iBAClCC,qBAAkC,oBAClCC,6BAAkC,4BAClCC,qBAAkC,iCAClCC,WAAkC,UAMtC,UAAWC,iBAAmB,YAAa,CACvCN,SAAW,KACX,IACIM,eAAiBC,QAAQ,GAAKN,oBAAoBK,eAGpD,MAAME,GACJC,QAAQC,MAAM,mEACZ,2CAKV,IAAKV,kBACUW,eAAiB,oBACdC,iBAAmB,aAAc,CAC/C,IACIL,QAAQ,GAAKH,sBACbL,eAAiB,KACnB,MAAMc,YACJd,eAAiB,OAQzB,GAAIA,eAAgB,CAChB,IAEI,UAAWa,iBAAmB,YAAa,CACvCA,eAAiBL,QAAQ,GAAKJ,8BAElC,UAAWQ,eAAiB,YAAa,CACrCA,aAAeJ,QAAQ,GAAKJ,+BAElC,MAAMW,YACJL,QAAQC,MAAM,0FACR,qDAIV,IACI,UAAWK,OAAS,YAAa,CAC7BA,KA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W9uB,OAAOpb,MAAMhB,MAC1EA,KAAK6qC,SAAS9lC,WAAW/E,KAAK2qC,UAAUiD,wBAEhDnuC,SAASC,KAAKqqC,0BAA0B7pC,UAAUgrC,WAAW9uB,OAAS1Z,IArc1E"} \ No newline at end of file +{"version":3,"sources":["progress.jsdo.js"],"names":["isNativeScript","isNodeJS","pkg_xmlhttprequest","pkg_nativescriptLocalstorage","pkg_fileSystemAccess","LocalStorageEmulation","this","_data","prototype","setItem","id","val","String","getItem","hasOwnProperty","undefined","removeItem","clear","XMLHttpRequest","require","e","console","error","localStorage","sessionStorage","exception1","exception2","btoa","str","Buffer","from","toString","exception3","btoaOriginal","unescape","encodeURIComponent","progress","data","util","STRING_OBJECT_TYPE","DATE_OBJECT_TYPE","CHARACTER_ABL_TYPE","Deferred","_deferred","promise","that","useJQueryPromises","$","_jQuerydeferred","_promise","Error","Promise","resolve","reject","_resolveArguments","_rejectArguments","setTimeout","apply","arg1","arg2","arg3","arguments","object","getParamObject1","when","deferreds","all","objectName","result","info","JSDOSession","AuthenticationProvider","JSDO","success","xhr","request","batch","info2","log","getParamObject","Observable","_filterObservers","observers","fn","scope","operation","filter","el","validateSubscribe","args","evt","listenerData","length","subscribe","_getMsgText","_events","toLowerCase","message","push","unsubscribe","trigger","op","Array","slice","call","forEach","unsubscribeAll","LocalStorage","saveToLocalStorage","name","dataObj","JSON","stringify","readFromLocalStorage","jsonStr","parse","clearLocalStorage","_convertToABLWhereString","tableRef","logic","idx","field","fieldInfo","type","format","operator","value","ablType","filters","whereOperators","eq","neq","gt","gte","lt","lte","contains","doesnotcontain","endswith","startswith","isnull","isnotnull","isempty","isnotempty","_name","_jsdo","_fields","origName","_getObjectType","replace","_getABLType","_format","join","_convertToSQLQueryString","addSelect","fieldFormat","filterStr","usingLike","_getFormat","Object","fmt","values","formatRegExp","match","index","placeholderFormat","parseInt","_toString","substring","_formatDate","_pad","number","digits","zeros","end","date","dateFormatRegExp","minutes","sign","getDate","getMonth","getFullYear","getHours","getMinutes","getSeconds","getMilliseconds","getTime","getTimezoneOffset","toISOString","jsdoSettingsProcessor","jsdoSettings","authenticationModel","PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS","PROGRESS_JSDO_OP_STRING","PROGRESS_JSDO_ROW_STATE_STRING","_nextid","_uidprefix","Date","now","UID_MAX_VALUE","_getNextId","uid","msg","msgs","jsdoMSG000","jsdoMSG001","jsdoMSG002","jsdoMSG003","jsdoMSG004","jsdoMSG005","jsdoMSG006","jsdoMSG007","jsdoMSG008","jsdoMSG009","jsdoMSG010","jsdoMSG011","jsdoMSG012","jsdoMSG020","jsdoMSG021","jsdoMSG022","jsdoMSG023","jsdoMSG024","jsdoMSG025","jsdoMSG026","jsdoMSG030","jsdoMSG031","jsdoMSG032","jsdoMSG033","jsdoMSG034","jsdoMSG035","jsdoMSG036","jsdoMSG037","jsdoMSG038","jsdoMSG039","jsdoMSG040","jsdoMSG041","jsdoMSG042","jsdoMSG043","jsdoMSG044","jsdoMSG045","jsdoMSG046","jsdoMSG047","jsdoMSG048","jsdoMSG049","jsdoMSG050","jsdoMSG051","jsdoMSG052","jsdoMSG053","jsdoMSG054","jsdoMSG055","jsdoMSG056","jsdoMSG057","jsdoMSG058","jsdoMSG059","jsdoMSG060","jsdoMSG061","jsdoMSG062","jsdoMSG100","jsdoMSG101","jsdoMSG110","jsdoMSG111","jsdoMSG112","jsdoMSG113","jsdoMSG114","jsdoMSG115","jsdoMSG116","jsdoMSG117","jsdoMSG118","jsdoMSG119","jsdoMSG120","jsdoMSG121","jsdoMSG122","jsdoMSG123","jsdoMSG124","jsdoMSG125","jsdoMSG126","jsdoMSG127","jsdoMSG500","jsdoMSG501","jsdoMSG502","jsdoMSG503","jsdoMSG504","jsdoMSG505","jsdoMSG506","jsdoMSG507","jsdoMSG508","jsdoMSG509","jsdoMSG510","jsdoMSG511","jsdoMSG512","jsdoMSG998","getMsgText","n","text","i","RegExp","PluginManager","_plugins","addPlugin","plugin","getPlugin","JSIndexEntry","JSTableRef","jsdo","tableName","_schema","_primaryKeys","_processed","_visited","record","_index","_tmpIndex","_hasEmptyBlocks","_beforeImage","_added","_changed","_deleted","_lastErrors","_convertForServer","_createIndex","block","idProperty","_id","_resource","_needCompaction","_compact","newDataArray","_loadBeforeImageData","jsonObject","beforeImageJsonIndex","keyFields","prodsBeforeData","_dataSetName","tmpIndex","record2","recordId","key","tmpKeyIndex","jsrecord","tmpDataIndex","tmpDeletedIndex","j","keys","_findById","_getKey","key2","_remove","copy","_copyRecord","_tableRef","_deleteProdsProperties","JSRecord","tableObject","beforeRecord","prodsErrors","item","_errorString","_clearData","_setRecord","hasData","_nestChildren","_getDataWithNestedChildren","_getRelatedData","getData","params","_getData","numEmptyBlocks","sort","top","sortFields","dir","sortObject","_processSortFields","_getCompareFn","skip","splice","_recToDataObject","includeChildren","array","dataObject","_children","_buffers","_dataProperty","_recFromDataObject","getSchema","setSchema","schema","fieldName","add","_add","create","trackChanges","setWorkingRecord","prefixElement","maxItems","_getDefaultValue","_getArrayField","items","_convertType","useRelationships","_relationship","_parent","childFieldName","parentFieldName","v","autoSort","_sortRecords","_sortFn","_sortObject","_needsAutoSorting","_sort","ret","_compareFields","parentRecord","childBuf","_isNested","k","childRecord","m","_hasNestedChild","_findFirst","ignoreRelationships","childTable","_defaultTableRef","assign","update","remove","bTrackChanges","getId","getErrors","getErrorString","findById","find","foreach","_inforeach","_equalRecord","rec1","rec2","value1","value2","caseSensitive","toUpperCase","keyObject","jsrec1","jsrec2","sortAscending","defineProperty","_autoSort","get","set","enumerable","writeable","_caseSensitive","fields","indexOf","sortOrder","setSortFields","setSortFn","addRecords","addMode","isInvoke","_addRecords","acceptChanges","rejectChanges","_undoCreate","_undoUpdate","_undoDelete","hasChanges","getChanges","rowState","_OP_CREATE","_OP_UPDATE","_OP_DELETE","_clearErrorStrings","_applyChanges","_rejected","acceptRowChanges","found","rejectRowChanges","hasNestedChild","childBufObj","_saveBeforeImageUpdate","_sortRecord","resNameOrParmObj","serviceName","_super","Session","_defineProperty","fnGet","element","ARRAY_INDEX_SEPARATOR","isNaN","_hasSubmitOperation","_hasCUDOperations","_numBuffers","_async","operations","_session","_useSubmit","autoApplyChanges","_localStorage","_fillMergeMode","autoFill","eventName","prop","ServicesManager","getResource","url","dataProperty","buffer","properties","fnName","generic","myservice","getService","service","_pushJSDOs","buf","_properties","primaryKeys","trim","$ref","relations","relationship","childName","parentName","relationFields","defaultValue","t","d","isDate","arrayFieldName","isDataSet","_invokeComplete","async","deferred","_invokeSuccess","_invokeError","_httpRequest","method","reqBody","afterOpenRequest","input","setRequestHeader","send","exception","_checkServiceResponse","onCompleteFn","onSuccessFn","onErrorFn","onreadystatechange","onReadyStateChangeGeneric","useRequest","settings","_openRequest","_getDataObject","oldUseRelationships","_getDataObjectAsNested","bufObj","_unnestData","obj","itemType","elements","split","convertItem","parseFloat","_clearErrors","clearErrorString","_setAllRecordsRejected","param","changes","hasErrors","hasRejected","hasCommittedRecords","_allRecordsRejected","_someRecordsRejected","fill","objParam","mapping","getMethodProperties","mappingType","mergeMode","MODE_APPEND","MODE_EMPTY","MODE_MERGE","MODE_REPLACE","requestMapping","capabilities","_fillSuccess","_fillError","_fillComplete","read","errorObject","_execGenericOperation","_convertRequestData","operationStr","_OP_READ","_OP_SUBMIT","_initConvertForServer","_convertFieldsForServer","_ablTypeNeedsConversion","beforeData","_convertTableData","tableData","_convertRowData","_convertField","resultArray","_convertDate","needsConversion","_undefWorkingRecord","saveChanges","useSubmit","_checkThatJSDOHasRequiredOperations","_syncDataSetForSubmit","_syncDataSetForCUD","_syncSingleTable","checkedDelete","checkedCreate","checkedUpdate","_confirmOperationExists","invoke","_syncTableRef","rowData","requestData","dataSetObject","_useBeforeImage","_createComplete","_createSuccess","_createError","useBeforeImageFormat","beforeObject","beforeRowData","sendOnlyChanges","_updateComplete","_updateSuccess","_updateError","childTableName","_deleteComplete","_deleteSuccess","_deleteError","opType","useBeforeImage","_isBatchComplete","_isBatchSuccess","_updateLastErrors","_fireAfterSaveChanges","fireAfterSaveChanges","addedRecords","complete","completeFn","_saveChangesComplete","successFn","_saveChangesSuccess","errorFn","_saveChangesError","jsrecords","_createChangeSet","_createTTChangeSet","_saveChangesSuccessTT","dataSetName","alwaysCreateTable","changeSetJsonObject","dataSetJsonObject","_hasChanges","_addDeletesToChangeSet","_addCreatesToChangeSet","_addChangesToChangeSet","tempTableJsonObject","_addRowToTTChangeSet","event","_createDataAndChangeSet","_addRecordsToObject","_doesRecordHaveCreateBIData","_addCreatedRowToChangeSet","_doesRecordHaveUpdateBIData","_addChangedRowToChangeSet","changedId","hasUpdates","_addDeletedRowToChangeSet","beforeTableJsonObject","_getTableInBeforeJsonObject","source","target","onlyChangesRecord","newObject","deleteRowState","beforeImageJsonObject","dataHasBeenProcessed","checkBeforeImage","isAfterSame","_sameData","isBeforeSame","_getBeforeRecordFromObject","afterRecord","tablename","record1","_mergeRead","datasetBuffer","srcData","_mergeUpdateRecord","_setErrorString","errorString","setInBeforeTable","_arrayFromDataObject","_mergeUpdateForCUD","hasError","tableJsonObject","prods_id","_getErrorStringFromJsonObject","_checkForDeleteError","beforeJsonObject","_mergeUpdateForSubmit","_fireCUDTriggersForSubmit","errorsJsonObject","response","responseMapping","entry","deleteProdsProps","_checkSaveComplete","records","status","_getErrorsFromRequest","errors","errorArray","retValString","responseObject","responseText","_retVal","RETVAL","_errors","_errorNum","_errorMsg","APP_ERROR","errorNum","ERROR","statusText","errorText","DATA_ERROR","_mergeInvoke","dataParameterName","_tempTableName","xType","readyState","_saveClientContextId","concat","setProperties","propertiesObject","setProperty","propertyName","propertyValue","getProperties","getProperty","saveLocal","dataMode","callee","ALL_DATA","CHANGES_ONLY","_prepareDataObjectForLocalStorage","readLocal","_hasMatchingSchema","_restoreFromLocalStorage","addLocalRecords","_containsPrimaryKeys","storageObject","isValid","deleteLocal","option","_restoreDataForTable","_operations","constructor","radix","sortDir","ablFilter","sqlQuery","methodProperties","position","capabilitiesObject","reqCapabilities","options","doConversion","viewTables","orderBy","ui","UITableRef","_listview","_detailPage","_listviewContent","addItem","detailForm","clearItems","itemTemplate","UIHelper","_itemTemplate","listviewElement","document","getElementById","innerHTML","_getFormFieldValue","detailPageName","_setFormField","display","pageName","showListView","uiTableRef","html","attr","filterable","listview","autoLink","each","bind","getListViewRecord","onSelect","childElementCount","children","onclick","getFormFields","tmpFields","htmltext","charAt","fieldLabel","title","fieldTemplate","_fieldTemplate","htmlIElement","getAttribute","getFormRecord","_getIdOfElement","setDetailPage","setListView","pos","_defaultUITableRef","_uiTableRef","cnt","_defaultItemTemplate","_defaultFieldTemplate","setItemTemplate","template","setFieldTemplate","_services","_resources","_sessions","_jsdosessions","addResource","resource","addService","addSession","catalogURI","session","addJSDOSession","jsdosession","getSession","cleanSession","servicesKey","resourcesKey","sessionsKey","services","resources","sessions","jsdosessions","extractParamsFromURL","urlParams","paramName","c","addCatalog","baseAddress","address","path","primaryKey","tableProperties","RelationName","opname","verb","func","definition","Boolean","reqParam","unwrapped","paramsFromURL","printDebugInfo","resourceName","cSchema","cOperations","MobileServiceObject","_uri","uri","ContextProperties","contextObject","contextString","header","setContextProperty","setContext","context","getContext","getContextProperty","defPropSupported","isUserAgentiOS","isFirefox","isEdge","isIE","canPassCredentialsToOpenWithCORS","defaultiOSBasicAuthTimeout","deviceIsOnline","restApplicationIsOnline","oepingAvailable","hasResolvedPingURI","defaultPartialPingURI","classicPartialPingURI","partialPingURI","_storageKey","_authProvider","customCredentials","storedAuthModel","storedURI","newURI","stateWasReadFromStorage","_silent","warn","navigator","userAgent","canPassCredentialsToOpen","_onlineHandler","setDeviceIsOnline","_offlineHandler","DEVICE_OFFLINE","window","addEventListener","_catalogURIs","_jsdos","onOpenRequest","_password","_userName","_loginTarget","_serviceURI","_loginResult","_loginHttpStatus","_clientContextId","_authenticationModel","AUTH_TYPE_ANON","newval","AUTH_TYPE_FORM","AUTH_TYPE_BASIC","AUTH_TYPE_SSO","AUTH_TYPE_BEARER","storeSessionInfo","_lastSessionXHR","loginResult","LOGIN_SUCCESS","_pingInterval","_timeoutID","_autoping","clearTimeout","_contextProperties","isInvalidated","setAuthProvider","userName","loginTarget","serviceURI","catalogURIs","loginHttpStatus","clientContextId","lastSessionXHR","infoName","retrieveSessionInfo","clearSessionInfo","storeAllSessionInfo","pingInterval","clearAllSessionInfo","setSessionInfoFromStorage","authproviderInitObject","setLoginResult","setUserName","setServiceURI","setLoginHttpStatus","setClientContextID","setRestApplicationIsOnline","setOepingAvailable","setPartialPingURI","newname","sessionObject","setLoginTarget","pushCatalogURIs","pushService","serviceObject","findService","setClientContextIDfromXHR","getResponseHeaderNoError","ccid","setLastSessionXHR","headerName","allHeaders","_pdsResponseHeaders","regExp","getAllResponseHeaders","getResponseHeader","callback","urlPlusCCID","afterOpenAndAuthorize","arg","setRequestHeaderFromContextProps","formPreTest","_isInvalidated","_prependAppURL","_addCCIDtoURL","_useTimeStamp","_addTimeStampToURL","_openRequestAndAuthorize","_setXHRCredentials","_addWithCredentialsAndAccept","pingTestCallback","cbArgs","foundOeping","pingResult","_onReadyStateChangeGeneric","_requestTimeout","onResponseFn","onResponseProcessedFn","GENERAL_FAILURE","pdsession","_disconnect","_processDisconnectResult","_reinitializeAfterLogout","SUCCESS","_disconnectComplete","errObj","pwSave","unameSave","login","loginUserName","loginPassword","uname","pw","isAsync","iOSBasicAuthTimeout","uriForRequest","password","restURLtemp","LOGIN_GENERAL_FAILURE","_setNoCacheHeaders","_isAsync","_afterFormPretestLogin","_processLoginResult","_loginComplete","_iosTimeOutExpired","abort","_jsdosession","isFormPreTest","ASYNC_PENDING","formLoginParams","theSession","doFormLogin","oldXHR","contentType","needAuth","statusFromjson","handleJSONLoginResponse","_gotLoginForm","open","cbparams","_afterFormLogin","_gotLoginFailure","pingTestArgs","pingURI","fireEventIfOfflineChange","onReadyStateFn","_pingtestOnReadyStateChange","_makePingURI","_sendPing","LOGIN_AUTHENTICATION_FAILURE","updateContextPropsFromResponse","logout","_processLogoutResult","_logoutComplete","withCredentials","_anonymousLogoutOK","invalidate","cleanServicesManager","logoutSucceeded","basicStatusOK","arg4","catalogUserName","catalogPassword","catalogIndex","authProvider","addCatalogAfterOpen","_processAddCatalogResult","_addCatalogComplete","_catalogIndex","offlineAddCatalog","_catalogURI","CATALOG_ALREADY_LOADED","_catalogHttpStatus","servicedata","serviceURL","theJSDOSession","toggleOnlineState","_parseCatalog","useXClientProps","xClientProps","_getAuthFailureReason","ping","pingArgs","_onReadyStateChangePing","offlineReason","doNotFireEvent","_processPingResult","_isOnlineStateChange","isOnline","stateChanged","wasOnline","connected","offlineObservers","offline","onlineObservers","online","localPingArgs","pingResponseJSON","appServerStatus","connectedBeforeCallback","assumeOepingFormat","usingOepingFormat","AppServerStatus","SERVER_OFFLINE","WEB_APPLICATION_OFFLINE","PingStatus","APPSERVER_OFFLINE","resolvePingURI","sendPingAfterOpen","then","auth","_make_basic_auth","urlPart1","urlPart2","jsessionidStr","catalogdata","oldURL","newURL","pat","test","acceptString","user","tok","hash","loginFormIDString","_findStringInResponseHTML","loginFailureIdentificationString","searchString","status_code","status_txt","contextHeader","hasClientCredentials","SEQ_MAX_VALUE","_tsseq","_tsprefix1","_tsprefix2","_getNextTimeStamp","seq","Math","floor","random","round","timeStamp","AUTHENTICATION_FAILURE","validateSessionSubscribe","_eventNames","_pdsession","JSDOs","settlePromise","fulfill","genericSessionEventHandler","myDeferred","onAfterAddCatalog","settleResult","EXPIRED_TOKEN","_overallCatalogResult","_results","_numCatalogsProcessed","_numCatalogs","_processedPromise","details","onAfterLogout","onPingComplete","username","callIsAuthorized","isAuthorized","disconnect","unameOrOpts","opts","numCatalogs","addResult","authProv","cbresult","LOGIN_AUTHENTICATION_REQUIRED","AUTH_TYPE_FORM_SSO","err","validateJSDOSessionSubscribe","authProviderInitObject","sessionRejectHandler","callbackRejectHandler","reason","loginHandler","ex","callLogin","provider","loginCallback","authenticationURI","authProviderAuthenticationModel","statusCode","invalidateAllSessions","invalidatePromises","exports","initObject","authModel","_checkStringArg","_initialize","_loginURI","_homeLoginURIBase","AuthenticationProviderBasic","AuthenticationProviderForm","AuthenticationProviderSSO","AuthenticationProviderBearer","_loginProto","sendParam","_loggedIn","_openLoginRequest","_storeInfo","_settlePromise","_reset","hasRefreshToken","uriParam","targetURIs","tempURI","_dataKeys","loggedIn","_storage","_retrieveLoggedIn","_retrieveInfoItem","propName","_retrieveURI","_clearInfo","argToCheck","argPosition","argName","_springLoginURIBase","make_basic_auth_header","_basic_processLoginResult","userNameParam","passwordParam","BasicProxy","bearerToken","make_Bearer_auth_header","token","_Bearer_processLoginResult","BearerProxy","_logoutURI","_springLogoutURIBase","FormProxy","_openLogoutRequest","afterSuper","_automaticTokenRefresh","temp","ssoTokenInfo","tokenDataKeys","refreshToken","tokenType","expiration","accessTokenExpiration","storeTokenInfo","access_token","refresh_token","expires_in","token_type","retrieveTokenProperty","retrieveToken","retrieveRefreshToken","retrieveAccessTokenExpiration","retrieveTokenType","getToken","retrieveExpiration","clearTokenInfo","openRefreshRequest","_refreshURI","processRefreshResult","ssoTokenJSON","afterRefreshCheck","automaticTokenRefresh","refresh","_springFormTokenLoginURIBase","_springFormTokenRefreshURIBase","SSOProxy"],"mappings":";;;;;;;;;;;;;;;CAwCC,WAeG,IAAIA,eAAiB,MACjBC,SAAW,MAEf,IAAIC,mBAAkC,iBAClCC,6BAAkC,4BAClCC,qBAAkC,iCAItC,SAASC,wBACLC,KAAKC,SAETF,sBAAsBG,UAAUC,QAAU,SAASC,GAAIC,KAAO,OAAOL,KAAKC,MAAMG,IAAME,OAAOD,MAC7FN,sBAAsBG,UAAUK,QAAU,SAASH,IAAM,OAAOJ,KAAKC,MAAMO,eAAeJ,IAAMJ,KAAKC,MAAMG,IAAMK,WACjHV,sBAAsBG,UAAUQ,WAAa,SAASN,IAAM,cAAcJ,KAAKC,MAAMG,KACrFL,sBAAsBG,UAAUS,MAAQ,WAAa,OAAOX,KAAKC,UAKjE,UAAWW,iBAAmB,YAAa,CACvCjB,SAAW,KACX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