123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>JSDoc: Source: messaging/Connectors.js</title>
- <script src="scripts/prettify/prettify.js"> </script>
- <script src="scripts/prettify/lang-css.js"> </script>
- <!--[if lt IE 9]>
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
- </head>
- <body>
- <div id="main">
- <h1 class="page-title">Source: messaging/Connectors.js</h1>
-
-
- <section>
- <article>
- <pre class="prettyprint source linenums"><code>/**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Collaboration
- * (C) Copyright IBM Corp. 2017, 2018
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define([
- '../lib/@waca/core-client/js/core-client/ui/core/Class',
- './connectors/index'
- ], function (Class, connectors) {
- 'use strict';
- var Connectors = Class.extend( /** @lends Connectors */ {
- /**
- * @desc Constructor for Connectors.
- * @constructs Connectors
- * @extends Class
- * @public
- * @param {object} options Options
- * @param {object} options.glassContext The glass context
- * @param {function} options.errorHandler Function to call when an error occurs
- */
- init: function (options) {
- Connectors.inherited('init', this, arguments);
- this.glassContext = options.glassContext;
- if (!this.glassContext) {
- throw Error('Missing glassContext in options');
- }
- this.logger = this.glassContext.getCoreSvc('.Logger') || {
- log: console.log,
- error: console.error
- };
- this.errorHandler = options.errorHandler;
- // holds configured connectors
- this.connectors = [];
- },
- /**
- * Discovers all the providers' and returns their connector instances.
- * @instance
- * @returns {promise}
- */
- discover: function () {
- var ajaxSvc = this.glassContext.getCoreSvc('.Ajax');
- return ajaxSvc
- .ajax({
- type: 'GET',
- url: 'v1/collaboration/providers?flat=true'
- })
- .then(function (response) {
- return response.data.map(function (provider) {
- return this._handleSingleProvider(provider);
- }.bind(this));
- }.bind(this))
- .then(function (results) {
- return results
- // remove any unsupported/unknown connectors
- .filter(function (result) {
- return !!result;
- })
- // remove any connectors for which the user doesn't have the required capabilities
- .filter(function(result) {
- return result.checkUserCapabilities();
- });
- });
- },
- _handleSingleProvider: function (meta) {
- try {
- var Plugin = connectors[meta.type];
- if (Plugin) {
- var plugin = new Plugin({
- glassContext: this.glassContext,
- errorHandler: this.errorHandler,
- meta: meta
- });
- // ...and store it
- this.connectors.push(plugin);
- return plugin;
- } else {
- this.logger.error('Unable to load plugin: ' + meta.type);
- }
- } catch (error) {
- this.logger.error('Error while creating connector instance', error);
- }
- // null connectors will be removed below once all the promises are resolved
- return null;
- }
- });
- return Connectors;
- });</code></pre>
- </article>
- </section>
- </div>
- <nav>
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ConnectorBase.html">ConnectorBase</a></li><li><a href="Connectors.html">Connectors</a></li><li><a href="EmailClient.html">EmailClient</a></li><li><a href="EmailConnector.html">EmailConnector</a></li><li><a href="MSTeamsAuth.html">MSTeamsAuth</a></li><li><a href="MSTeamsClient.html">MSTeamsClient</a></li><li><a href="MSTeamsConnector.html">MSTeamsConnector</a></li><li><a href="ShareableItems.html">ShareableItems</a></li><li><a href="ShareController.html">ShareController</a></li><li><a href="ShareView.html">ShareView</a></li><li><a href="SlackAuth.html">SlackAuth</a></li><li><a href="SlackClient.html">SlackClient</a></li><li><a href="SlackConnector.html">SlackConnector</a></li></ul><h3>Interfaces</h3><ul><li><a href="ShareInterface.html">ShareInterface</a></li></ul>
- </nav>
- <br class="clear">
- <footer>
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed May 25 2022 13:54:53 GMT+0000 (UTC)
- </footer>
- <script> prettyPrint(); </script>
- <script src="scripts/linenumber.js"> </script>
- </body>
- </html>
|