Note: The sample does not provide multi-tenancy (only one organization can be serviced by an instance of this webapp).
Handling Connection Data Changes
The sample CredentialsChangedListener is implemented in ManagementContextListener.java, and its logic is crucial to ensure your application's connection data is up to date. Connection data is renewed every 270 days, so if you do not have a listener registered in your application to update it, the SDK will not initialize successfully if the connection data has expired.
You can find an example CredentialsChangedListener in the sample's ManagementContextListener class, which stores the connection data in a properties file in the local file system. This is just an example, and it is recommended to store the connection data more securely and perhaps centrally (for instance, shared DB) in the case where your SDK webapp is hosted on multiple machines.
Note: Connection data should not be shared as it contains sensitive data.
The sample also demonstrates how to implement registration in your application. First you call RegisteringApplication.createRegistrationRequest() to get a URL (see RegistrationService.java). Your application should then direct the user to this URL (see app.js). After an organization admin authenticates, the user's browser is redirected back to the callback URL. In the sample, the RegistrationService saveConnectionData() method handles the callback to 1) save the connection data, and 2) initialize the management connector via ManagementConnector.init().
The sample provides create/retrieve/update/delete/search via REST. (Custom fields and field sets to be used by context objects can be managed in the Cisco Spark Administration webapp by organization admins.)
For example, to create a new activity (pod), execute a POST request like this:
Note: No authentication is provided on this REST API. Depending on where the application is hosted, it is recommended that you include authentication (such as basic auth) in your implementation.
Deployment to Tomcat
Sample scripts make it easy to get started quickly. The sample has a script prepareTomcats.sh that configures 2 instances of Tomcat, one to host the REST API, and the other to host the Management Connector webapp.
Note: The scripts are intended for Mac/Linux, but could be adapted for Windows.
Once the Tomcat instances are prepared properly, two scripts can be used to start and stop Tomcat (startTomcats.sh and stopTomcats.sh). The application can be accessed at the following URLs: