JSDO properties, methods, and events reference : invalidateAllSessions( ) stand-alone function
  

invalidateAllSessions( ) stand-alone function

Note: Applies to Progress Data Objects Version 4.4.1 or later.
A stand-alone function that invalidates all current progress.data.JSDOSession instances that were created and initialized using the progress.data.getSession( ) stand-alone function.
This function combines the features of:
*Finding all existing JSDOSession instances created using the getSession( ) stand-alone function.
*Calling the invalidate( ) method on each instance, which in turn calls the logout( ) method on the instance.
After invalidateAllSessions( ) executes, any call made to the addCatalog( ), isAuthorized( ), login( ), or ping( ) method on an existing JSDOSession instance, or any attempt to instantiate a progress.data.JSDO, throws an exception. In addition, calls to any method on an existing JSDO instance that communicates with the server associated with an invalidated JSDOSession throws an exception as well.
This method is always executed asynchronously and returns results in callbacks that you register using methods of a Promise object returned as the function value.
Note: In order to invoke this function successfully, jQuery Promises must be supported in your development environment. Otherwise, the function throws an exception.
Note: This function does not support proxy servers (servers that function as a security service).
Return type: jQuery Promise
Applies to: The progress.data namespace

Syntax

progress.data.invalidateAllSessions ( )

Promise method signatures

jQuery Promise objects define methods that register a callback function with a specific signature. The callback signatures depend on the function that returns the Promise. Following are the signatures of callbacks registered by methods in any Promise object that invalidateAllSessions( ) returns:
Syntax:
promise.done( function ( result , info ) )
promise.fail( function ( result , info ) )
promise.always( function ( result , info ) )
Note: The always( ) method is always passed what the done( ) or the fail( ) methods are passed.
promise
A reference to the Promise object that is returned as the value of the invalidateAllSessions( ) function. For more information on Promises, see the notes on Promises in the description of the progress.data.JSDOSession class.
result
An integer constant indicating the overall result of the call that can have one of the following values:
*progress.data.Session.SUCCESS — Invalidate of all JSDOSession instances has completed successfully.
*progress.data.Session.GENERAL_FAILURE — The invalidate failed because of some error.
Note: It is not always necessary to test the value of result in a Promise method callback for invalidateAllSessions( ), especially if the callback is registered using promise.done( ), where the callback always executes with the same value (progress.data.Session.SUCCESS).
info
A JavaScript object that can have the following properties:
*errorObject — An error object thrown while attempting to terminate any JSDOSession instance.
*xhr — A reference to the XMLHttpRequest object sent to the web server for the JSDOSession object that threw the error object.

Example

The following code fragment calls the invalidateAllSessions( ) method to terminate and invalidate the login session for every current JSDOSession instance that is created using progress.data.getSession( ). This example uses try and catch blocks in case invalidateAllSessions( ) throws an unexpected exception, and displays messages returned from Promise handlers accordingly:
var serviceURI = "http://oemobiledemo.progress.com/OEMobileDemoServicesForm/",
catalogURI = "http://oemobiledemo.progress.com/OEMobileDemoServicesForm/static/CustomerService.json";

// create a JSDOSession for a specified web application
// that requires Form authentication
try {
// create and initialize login session
progress.data.getSession( {
authenticationModel : progress.data.Session.AUTH_TYPE_FORM,
serviceURI : serviceURI,
catalogURI : catalogURI,
username: "formuser",
password: "formpassword"
})
.then(function( session, result ) {

// Create a JSDO and fill it with data
var jsdoCustomer = new progress.data.JSDO('Customer');
return jsdoCustomer.fill()

}, function(result, info) {
console.log("getSession failed");
})
.then(function (jsdo, result, request) {
console.log("Fill went okay!");
// Do other JSDO related tasks here
}, function (jsdo, result, request) {
console.log("Not filling it today");
// Do JSDO related failure stuff here
})
.always(function () {
// By the time we get here, we should be done with all JSDO related stuff
// and cleaning up
return progress.data.invalidateAllSessions();
})
.then(function( result, info ) {
console.log("All sessions are invalidated!");
}, function() {
console.log("A session failed validation!");
});
} catch (ex) {
console.log("Exception: " + ex.message);
}
Note that this example creates only a single login session. Any additional login sessions can be created, and associated JSDO tasks performed, anywhere appropriate in the same Promise chain prior to the Promise always( ) method handler where invalidateAllSessions( ) is invoked.

See also:

invalidate( ) method, logout( ) method (JSDOSession class), getSession( ) stand-alone function, progress.data.JSDOSession class