addCatalog( ) method (JSDOSession class)
- Last Updated: June 14, 2019
- 6 minute read
- OpenEdge
- Version 13.0
- Documentation
Loads one or more local or remote
Data Service Catalogs into the current JSDOSession object.
The appropriate Catalog must be loaded before creating a JSDO for any resource defined in the Catalog.
If a Catalog is on a web server (remote), this method throws an exception if it is not possible to send a request to the specified web application.
This method is always executed asynchronously and returns results in callbacks that you register using methods of a Promise object returned as the method value.
JSDOSession object has successfully established a JSDO login
session using its login( ) method. However, if the Data
Service Catalog is stored remotely in the web application that hosts the Data Object
Service, Progress recommends that you log into the web application before calling
this method.JSDOSession object, you can create a new, initialized
JSDOSession using the progress.data.getSession( ) stand-alone function. In one call, this function
instantiates the object, invokes its login( ) method with
specified credentials, then invokes its addCatalog( )
method to load a specified Data Service Catalog. For more information, see the getSession( ) stand-alone function description.Return type: jQuery Promise
Applies to: progress.data.JSDOSession class
Syntax
|
- catalog-uri
- A
stringexpression that specifies the URI of a Data Service Catalog file. This URI can specify either a location (remote) in a web application running on a web server or a location (local) that is relative to the device where the app is currently running. If the URI specifies a remote location, it is typically the location of the web application that hosts the Data Object Service and where theJSDOSessionobject has a JSDO login session. If the URI is a relative path (e.g., catalogs/OrderEntrySvc.json), the catalog-uri is assumed to be relative to the location from which the app was loaded.If the mobile app from which you are logging in is a hybrid app that will be installed to run directly in a native device container, or if it is a web app deployed to a different web server from the web application to which the
JSDOSessionobject has already logged in, you must specify an absolute URI for the Catalog that includes the Tomcat server domain or host and port, for example,http://www.progress.com:8980/SportsMobileApp/static/OrderEntrySvc.json, or perhaps for testing,http://localhost:8980/SportsMobileApp/static/OrderEntrySvc.json.If the
JSDOSessionobject has already logged in and the mobile app is a web app deployed to the same Apache Tomcat server as the web application that hosts the Data Object Service, you can specify a URI that is relative to the deployment end point (Tomcat server domain or host and port), for example: /SportsMobileApp/static/OrderEntrySvc.json, where/SportsMobileAppis the location of the web application.Note: The default Catalog URI for a Catalog created for an OpenEdge Data Object Service, relative to the Apache Tomcat server domain or host and port where the session is logged in, is the following: /WebApplicationName/static/ServiceName.json, where WebApplicationName is the name of the web application and ServiceName is the name of the Data Object Service for which the Data Service Catalog is created. - catalog-uris
- An array of
stringexpressions, each of which is the URI for a Catalog as defined for the catalogURI parameter. If any of the Catalogs in the array are protected separately from the web application where theJSDOSessionobject is logged in, you can specify the additional credentials using cat-user-name and cat-password.Note: You can read thecatalogURIsproperty to return the URIs for all Catalogs previously loaded into theJSDOSessionobject. - cat-user-name
- A
stringexpression containing a user ID to authenticate access to a protected Catalog. If you do not specify cat-user-name, Catalog access is authorized using existing user credentials (if any). - cat-password
- A
stringexpression containing a password (if required) to authenticate the user specified by cat-user-name. - parameter-object
- An object that contains the following optional property:
iOSBasicAuthTimeout— Anumberthat specifies the time, in milliseconds, that theaddCatalog( )method waits for a response before returning an error. This error might mean that the user entered invalid credentials to access a protected Catalog URI. If you set this value to zero (0), no timeout is set, andaddCatalog( )can wait indefinitely before returning an error. If you do not set theiOSBasicAuthTimeoutproperty,addCatalog( )uses 4000 (4 seconds) as the default value.Note: Any non-zero timeout value (default or otherwise) for this parameter-object property operates only under certain conditions. Otherwise, any setting of this property has no effect. For more information, see the notes of the progress.data.JSDOSession class description.
JSDOSession object
is already logged in, you typically do not need to specify cat-user-name and cat-password. These
optional parameters are available primarily if the object is not yet logged in, or if you
store the Catalog someplace on the web other than the web application that hosts the Data
Object Service (where the JSDOSession object has a JSDO login
session).JSDOSession object to load
a Catalog that is stored somewhere on the web other than the web application that hosts the
Data Object Service, this typically works only if the Catalog is protected with Anonymous or
HTTP Basic authentication.Promise method signatures
jQuery Promise objects define methods that register a callback function
with a specific signature. The callback signatures depend on the method that returns the
Promise. Following are the signatures of callbacks registered by methods in any Promise
object that addCatalog( ) returns:
Syntax:
|
- promise
- A reference to the Promise object that is returned as the value of the
addCatalog( )method. For more information on Promises, see the notes on Promises in the description of the progress.data.JSDOSession class. - session
- A reference to the
JSDOSessionobject on whichaddCatalog( )was called. - result
- A constant indicating the overall result of the call that can have
one of the following values:
progress.data.Session.SUCCESS— Each Catalog specified by the catalogURI or catalogURIs parameter ofaddCatalog( )has been loaded successfully or has already been loaded.progress.data.Session.GENERAL_FAILURE— One or more of the specified Catalogs has failed to load successfully.
Note: It is not always necessary to test the value of result in a Promise method callback for theaddCatalog( )method, especially if the callback is registered usingpromise.done( )andpromise.fail( ), where each callback always executes with the same value for success (done( )) or failure (fail( )). - details
- An array of JavaScript objects that contain information on the Data
Service Catalogs that
addCatalog( )attempted to load. Each object has the following properties:catalogURI— The URI of a specified Catalog.result— A constant indicating the result of loading the Catalog that can have one of the following values:-
progress.data.Session.SUCCESS— The specified Catalog loaded successfully, or has previously been loaded. -
progress.data.Session.CATALOG_ALREADY_LOADED— The specified Catalog was previously loaded.Note: WhenaddCatalog( )is requested to load a Data Service Catalog that is already loaded, it does not load the Catalog again, but is considered a successful execution. That is, thepromise.done( )callback is called, although theresultvalue in the details object for the specified Catalog isprogress.data.Session.CATALOG_ALREADY_LOADED. -
progress.data.Session.AUTHENTICATION_FAILURE— The specified Catalog failed to load because of an authentication error. progress.data.Session.GENERAL_FAILURE— The specified Catalog failed to load because of an error other than an authentication failure.Note: This value can also be returned if invalid user credentials triggered a Catalog access timeout according to the value of the parameter-object.iOSBasicAuthTimeoutproperty.
-
errorObject— Any error object thrown while attempting to load the Catalog.Note: If this object is thrown because of a Catalog access timeout triggered according to the value of the parameter-object.iOSBasicAuthTimeoutproperty, themessageproperty of the error object is set to"addCatalog timeout expired".xhr— A reference to the XMLHttpRequest object used to load the Catalog from a web server.
Example
The following code fragment calls the addCatalog(myCatalogURIs) method on the JSDOSession object, mySession, to load
multiple Data Service Catalogs specified in myCatalogURIs.
This example uses try and catch blocks to check any error object thrown prior to requesting the Catalog,
and assembles an appropriate message to display in an alert box or does other processing for
each case:
|
See also:
catalogURIs property, getSession( ) stand-alone function, login( ) method (JSDOSession class)