/** Licensed Materials - Property of IBM, 5724-U69, (C) Copyright IBM Corp. 2009, 2010 - All Rights reserved. **/ dojo.i18n._preloadLocalizations("federation.nls.FederatedDocumentsPickerLayer", ["ROOT","ar","ca","cs","da","de","el","en","es","fi","fr","he","hr","hu","it","ja","kk","ko","nl","no","pl","pt","pt-br","ro","ru","sk","sl","sv","th","tr","uk","xx","zh","zh-tw"]); if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsServiceBean"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsServiceBean"] = true; ////////////////////////////////////////////////// // Licensed Materials - Property of IBM // // 5724-E76, 5655-R17, 5655-M44 // // Copyright IBM Corp. 2011 All Rights reserved.// ////////////////////////////////////////////////// dojo.provide("com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsServiceBean"); dojo.require("com.ibm.widgets._Traceable"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsServiceBean", [com.ibm.widgets._Traceable], { // summary: // Bean that encapsulates configuration and runtime data required by client-side // components of the federated documents support in IBM Portal // customServiceSelectionEnabled: [private] Boolean // Specifies whether or not the selection of cuostom (i.e. not preconfigured) services // is supported _customServiceSelectionEnabled: true, // _federatedDocumentsServices: [private] Array // Array of JSON objects holding properties of configured federated documents services _federatedDocumentsServices: [], // _feedBaseURL: [private] String // Piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) feeds through the CMIS feed data source of IBM Portal _feedBaseURL: "", // _feedTypeBaseURL: [private] String // Piece of content (POC) base URL for accessing the feed type data source of IBM // Portal that determines type of an enterprise content management (ECM) feed. _feedTypeBaseURL: "", // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _portalContextPath: [private] String // Context path of the IBM Portal _portalContextPath: "/wps", // _qdsSupportEnabled: [private] Boolean // Specifies whether or not Quickr Document Services are supported in the federated // documents configuration of the IBM Portal _qdsSupportEnabled: true, // _serviceDocBaseURL: [private] String // Piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) service documents through the CMIS service document data source of // IBM Portal _serviceDocBaseURL: "", // _vaultMgmtDataSinkUrl: [private] String // Piece of content (POC) URL for accessing the Vault Management Datasink of // IBM Portal _vaultMgmtDataSinkUrl: "", // _vaultSelectionEnabledForPZN: [private] Boolean // Specifies whether or not the selection of credential vault slots for authentication // is supported when using the federated documents picker with Personalization _vaultSelectionEnabledForPZN: true, // _vaultSelectionEnabledForWCM: [private] Boolean // Specifies whether or not the selection of credential vault slots for authentication // is supported when using the federated documents picker with Web Content Management _vaultSelectionEnabledForWCM: true, // _vaultSlots: [private] Array // Array of JSON objects holding properties of available credential vault slots _vaultSlots: [], constructor: function(/*Object*/ p_params) { // summary: // Constructs this bean with the given JSON object // p_params.customServiceSelectionEnabled: Boolean // Specifies whether or not the selection of cuostom (i.e. not preconfigured) services // is supported // p_params.federatedDocumentsServices: Array // Array of JSON objects holding properties of configured federated documents services // p_params.feedBaseURL: String // Piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) feeds through the CMIS feed data source of IBM Portal // p_params.feedTypeBaseURL: String // Piece of content (POC) base URL for accessing the feed type data source of IBM // Portal that determines type of an enterprise content management (ECM) feed // p_params.portalContextPath: String // Context path of the IBM Portal // p_params.qdsSupportEnabled: Boolean // Specifies whether or not Quickr Document Services are supported in the federated // documents configuration of the IBM Portal // p_params.serviceDocBaseURL: String // Piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) service documents through the CMIS service document data source of // IBM Portal // p_params.vaultMgmtDataSinkUrl: String // Piece of content (POC) URL for accessing the Vault Management Datasink of // IBM Portal // p_params.vaultSelectionEnabledForPZN: Boolean // Specifies whether or not the selection of credential vault slots for authentication // is supported when using the federated documents picker with Personalization // p_params.vaultSelectionEnabledForWCM: Boolean // Specifies whether or not the selection of credential vault slots for authentication // is supported when using the federated documents picker with Web Content Management // p_params.vaultSlots: Array // Array of JSON objects holding properties of available credential vault slots // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, dojo.toJson(p_params)); } if (p_params && typeof p_params == 'object') { // federatedDocumentsServices if (p_params.federatedDocumentsServices && typeof p_params.federatedDocumentsServices == 'object') { this._federatedDocumentsServices = p_params.federatedDocumentsServices; } // customServiceSelectionEnabled if (typeof p_params.customServiceSelectionEnabled == 'boolean') { this._customServiceSelectionEnabled = p_params.customServiceSelectionEnabled; } // feedBaseURL if (typeof p_params.feedBaseURL == 'string') { this._feedBaseURL = p_params.feedBaseURL; } // feedTypeBaseURL if (typeof p_params.feedTypeBaseURL == 'string') { this._feedTypeBaseURL = p_params.feedTypeBaseURL; } // portalContextPath if (typeof p_params.portalContextPath == 'string') { this._portalContextPath = p_params.portalContextPath; } // qdsSupportEnabled if (typeof p_params.qdsSupportEnabled == 'boolean') { this._qdsSupportEnabled = p_params.qdsSupportEnabled; } // serviceDocBaseURL if (typeof p_params.serviceDocBaseURL == 'string') { this._serviceDocBaseURL = p_params.serviceDocBaseURL; } // vaultMgmtDataSinkUrl if (typeof p_params.vaultMgmtDataSinkUrl == 'string') { this._vaultMgmtDataSinkUrl = p_params.vaultMgmtDataSinkUrl; } // vaultSelectionEnabledForPZN if (typeof p_params.vaultSelectionEnabledForPZN == 'boolean') { this._vaultSelectionEnabledForPZN = p_params.vaultSelectionEnabledForPZN; } // vaultSelectionEnabledForWCM if (typeof p_params.vaultSelectionEnabledForWCM == 'boolean') { this._vaultSelectionEnabledForWCM = p_params.vaultSelectionEnabledForWCM; } // vaultSlots if (p_params.vaultSlots && typeof p_params.vaultSlots == 'object') { this._vaultSlots = p_params.vaultSlots; } } // exit trace if (this._isTracing) { this.traceExit(m); } }, getFederatedDocumentsServices: function() { // summary: // Returns an array of JSON objects holding properties of configured federated documents services // tags: // public // returns: // the federated documents services configuration return this._federatedDocumentsServices; // Array }, getFeedBaseURL: function() { // summary: // Returns the piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) feeds through the CMIS feed data source of IBM Portal // tags: // public // returns: // the feed base URL return this._feedBaseURL; // String }, getFeedTypeBaseURL: function() { // summary: // Returns the piece of content (POC) base URL for accessing the feed type data source of IBM // Portal that determines type of an enterprise content management (ECM) feed // tags: // public // returns: // the feed type base URL return this._feedTypeBaseURL; // String }, getPortalContextPath: function() { // summary: // Returns the context path of the IBM Portal // tags: // public // returns: // the context path return this._portalContextPath; // String }, getServiceDocumentBaseURL: function() { // summary: // Returns the piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) service documents through the CMIS service document data source of // IBM Portal // tags: // public // returns: // the service document base URL return this._serviceDocBaseURL; // String }, getVaultMgmtDataSinkUrl: function() { // summary // Returns the piece of content (POC) URL for accessing the Vault Management Datasink of // IBM Portal // tags: // public // returns: // the vault management datasink URL return this._vaultMgmtDataSinkUrl; // String }, getVaultSlots: function() { // summary: // Returns an array of JSON objects holding properties of available credential vault slots // tags: // public // returns: // the configuration of available credential vault slots return this._vaultSlots; // Array }, isCustomServiceSelectionEnabled: function() { // summary: // Returns an indicator as to whether or not the selection of custom (i.e. not predefined) // services is supported // tags: // public // returns: // true if custom service selection is supported, false otherwise return this._customServiceSelectionEnabled; // Boolean }, isQDSSupportEnabled: function() { // summary: // Returns an indicator as to whether or not Quickr Document Services are supported in the federated // documents configuration of the IBM Portal // tags: // public // returns: // true if Quickr Document Services are supported, false otherwise return this._qdsSupportEnabled; // Boolean }, isVaultSelectionEnabledForPZN: function() { // summary: // Returns an indicator as to whether or not the selection of credential vault slots for authentication // is supported when using the federated documents picker with Personalization // tags: // public // returns: // true if credential vault slot selection is supported for Personalization, false otherwise return this._vaultSelectionEnabledForPZN; // Boolean }, isVaultSelectionEnabledForWCM: function() { // summary: // Returns an indicator as to whether or not the selection of credential vault slots for authentication // is supported when using the federated documents picker with Web Content Management // tags: // public // returns: // true if credential vault slot selection is supported for Web Content Management, false otherwise return this._vaultSelectionEnabledForWCM; // Boolean } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions"] = true; dojo.provide("com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions"); dojo.declare('com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions', null, { // summary: // A class used as namespace for defining global contants for federated documents support }); //*** global constants for all dijit instances *** // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._atom: [const] [public] String // Constant indicating an Atom Syndication format document com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._atom = "atom"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeCMIS: [const] [public] String // Constant for the Resource Environment Server Type 'CMIS' com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeCMIS = "CMIS"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeQDS: [const] [public] String // Constant for the Resource Environment Server Type 'DocumentServices' com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeQDS = "DocumentServices"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeATOM: [const] [public] String // Constant for the Resource Environment Server Type 'ATOM' com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeATOM = "ATOM"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis: [const] [public] String // Constant indicating a Content Management Interoperability (CMIS) context com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis = "cmis"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._proxyVaultSlotParamName: [const] [public] String // AJAX Proxy specific name of the query parameter that identifies a vault slot com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._proxyVaultSlotParamName = "hpaa.slotid"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn: [const] [public] String // Identifier for Personalization as the context the Federated Documents Picker is used in com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn = "pzn"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds: [const] [public] String // Constant indicating a Quickr Document Services (QDS) context com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds = "qds"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qdsentry: [const] [public] String // Constant indicating a Quickr Document Services (QDS) entry Url com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qdsentry = "qdsentry"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._servicedoc: [const] [public] String // Constant indicating a CMIS Service Document document com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._servicedoc = "servicedoc"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._unknown: [const] [public] String // Constant indicating that a feed type detection was performed but the processed feed is not of a known type com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._unknown = "unknown"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm: [const] [public] String // Identifier for Web Content Management as the context the Federated Documents Picker is used in com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm = "wcm"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog: [const] [public] String // Value of the "pickerContext" parameter that indicates that the Federated Documents Picker is launched // as a fully fledged dialog of its own rather than as a dependent widget. The latter is the case of using // the Federated Documents Picker Portlet inside of a dialog that is created by the modal dialog framework // of the portal. com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog = "dialog"; // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._portlet: [const] [public] String // Value of the "pickerContext" parameter that indicates that the Federated Documents Picker is launched // as a dependent widget rather than a fully fledged dialog of its own. This is the case of using the // Federated Documents Picker Portlet inside of a dialog that is created by the modal dialog framework of // the portal. com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._portlet = "portlet"; } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724-E76, 5655-R17, 5655-M44 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget"); dojo.registerModulePath("com.ibm.workplace.wcm.ecm.picker.widget","../com/ibm/workplace/wcm/ecm/picker/widget"); dojo.require("dijit.form.RadioButton"); dojo.require("dijit.form.ComboBox"); dojo.require("com.ibm.widgets.GenericDialogWidget"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget", [com.ibm.widgets.GenericDialogWidget], { // summary: // This widget implementation facilitates the selection and configuration of // authentication methods to use when connecting to a federated documents repository // namespace: [protected] String // The namespace this widget uses for building its user interface elements namespace: "authWdgt_", // templatePath: // see dijit.Dialog templateString:"
\n
\n
\n \n
\n
\n
\n \n \n
\n
\n \n
\n
\n\t \n\t
\n\t \n\t
\n
\n
\n
\n \n \n
\n\t
\n\t \n\t \n\t
\n\t
\n\t \n\t \n\t
\n\t
\n
\n
\n
\n
\n\n", // widgetsInTemplate: // see dijit.Dialog widgetsInTemplate: true, // _allAuthTypes: [private] Array // Array which holds the constant values for all (theoretically) available authentication types. // Used internally, e.g. for preselecting an available authentication type _allAuthTypes: [], // _authProperties: [private] Object // JSON object which holds information about the authentication settings. // Objects of the same format are being used for passing in authentication information to the Picker dialog // and for receiving changed authentication settings back from the AuthenticationWidget when the user // made changes. // // Allowed Identifiers are: // authType: String // The type of authentication selected // username: String // The username for username/password authentication // password: String // The password for username/password authentication // vaultSlotID: String // The credential vault slot ID for credential vault based authentication // vaultSlotTitle: String // The title for the credential vault slot ID for credential vault based authentication _authProperties: null, // _authTypeAvailable: [private] Object // JSON object holding the supported authentication types _authTypeAvailable: { "authNone": false, "authUserPwd": false, "authSSO": false, "authVault": false }, // _defaultSlotValue: [private] String // First entry from the provided vaultSlotList to be set as the default in the Vault Slot // ComboBox _defaultSlotValue: "", // _errorState: [private] Boolean // Indicates whether an error occurred and whether this widget went into error state. // The error state persists, until _clearError() was called. _errorState: false, // _eventHandles: [private] Array // Array of handles created when connecting events to methods _eventHandles: [], // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _onChangeAuthenticationMode: [private] Function // Callback method that is triggered when the user either changes the method // for authentication or when parameters for an authentication method change _onChangeAuthenticationMode: null, // _onErrorStateChanged: [private] Function // Callback method that is triggered by this widget when an error condition // occurred and the associated error message needs to be displayed in the // owning dialog or if the widget was in error state previously and the // error was cleared. // // _onErrorStateChanged(/*Object*/ p_sender, /*Boolean*/ p_errorState, // /*String?*/p_errorMsg, /*String?*/p_errorDetails) _onErrorStateChanged: null, // _vaultSlots: [private] Array // Array of credential vault slots. Each slot is an object with the following properties: // vaultSlotTitle: String // The localized title which is being displayed in the DropDownList // vaultSlotID: String // The actual credential vault slot ID that is being added to the URL as a parameter _vaultSlots: [], // _vaultSlotStore: [private] Object // Instance of a FileItemWriteStore which holds the preconfigured vault slot titles _vaultSlotStore: null, buildRendering: function() { // summary: // Constructs the user interface of this widget // tags: // protected // entry trace var m = "buildRendering()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); this._setUpVaultDropDownList(); this._showHideAuthTypeSections(); // exit trace if (this._isTracing) { this.traceExit(m); } }, changeAuthType: function(/*String*/ p_authType) { // summary: // Changes the authentication method used to connect to a content repository // p_authType: // The authentication type to set // tags: // public // entry trace var m = "changeAuthType(p_authType)"; if (this._isTracing) { this.traceEntry(m, p_authType); } if (p_authType) { if (p_authType != this._authProperties.authType) { this._authProperties.authType = p_authType; this._selectPresetAuthType(); this._callbackAuthenticationChangedEvent(); this._clearError(); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, changeVaultSlotID: function(/*String*/ p_vaultSlotID) { // summary: // Changes the credential vault slot ID shown in the vault slot picker // drop-down list. A seperate method is needed for this setting, as the // ID might change when a different preconfigured URL is selected // p_vaultSlotID: String // The credential vault slot ID to set as selected // tags: // public // entry trace var m = "changeVaultSlotID(p_vaultSlotID)"; if (this._isTracing) { this.traceEntry(m, p_vaultSlotID); } // cannot set a null or undefined slot ID on the UI control if (p_vaultSlotID) { this.vaultDropDownList.attr('value', p_vaultSlotID); var _items = this._vaultSlotStore.fetchItemByIdentity(p_vaultSlotID); if (_items && (_items.length === 1)) { // if everything goes fine, clear any previous errors this._clearError(); } else { // required vault slot id is not available, show error message if (this._onErrorStateChanged && dojo.isFunction(this._onErrorStateChanged)) { this._onErrorStateChanged(this, true, this._nlsMessages.authWidget.errorVaultSlotNotAvailable); } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, constructor: function(/*Object*/ p_params) { // summary: // Constructs this widget // p_params.authProperties: Object // The JSON object holding the authentication settings to set for this widget // p_params.availableAuthTypes: Array // The JSON object holding the authentication types supported with this widget // namespace: String // The namespace this widget uses for building its user interface elements // p_params.onChangeAuthenticationMode: Function // The callback method that is triggered when the user either changes the method // for authentication or when parameters for an authentication method change // p_params.onErrorStateChanged: Function // Callback method that is triggered by this widget, when the error state // of the page changed and this change needs to be reported back to the // parent // p_params.vaultSlots: Array // The credential vault slots this widget adds to its user interface for selection // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.authProperties:", dojo.toJson(p_params.authProperties)); this.trace(m, "p_params.availableAuthTypes:", dojo.toJson(p_params.availableAuthTypes)); this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.onChangeAuthenticationMode:", p_params.onChangeAuthenticationMode); this.trace(m, "p_params.onErrorStateChanged:", p_params.onErrorStateChanged); this.trace(m, "p_params.vaultSlots:", dojo.toJson(p_params.vaultSlots)); } } // namespace if (typeof p_params.namespace == 'string') { this.namespace = p_params.namespace; } // setting up allAuthTypes array this._allAuthTypes.push(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd); this._allAuthTypes.push(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser); this._allAuthTypes.push(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault); // determine which settings from the Federated Documents Picker Dialog were passed in if (p_params) { if ((p_params.vaultSlots) && (dojo.isArray(p_params.vaultSlots))) { this._vaultSlots = p_params.vaultSlots; } // auth types get passed in as an array, which holds just the identifiers for the // auth types that should be visible/available if (p_params.availableAuthTypes && dojo.isArray(p_params.availableAuthTypes)) { // reset _authTypeAvailable this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd] = false; this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser] = false; this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault] = false; for (var i = 0; i < p_params.availableAuthTypes.length; i++) { var atype = p_params.availableAuthTypes[i]; if (atype == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) { this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd] = true; } if (atype == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser) { this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser] = true; } if (atype == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault) { this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault] = (this._vaultSlots.length > 0); } } } if (p_params.authProperties) { // clone the _authProperties object to avoid object sharing between Picker and Widget this._authProperties = dojo.clone(p_params.authProperties); } else { // create _authProperties object and fill with default data this._authProperties = { "authType": com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser }; } if (typeof p_params.onChangeAuthenticationMode == 'function') { this._onChangeAuthenticationMode = p_params.onChangeAuthenticationMode; } if ((p_params.onErrorStateChanged) && dojo.isFunction(p_params.onErrorStateChanged)) { this._onErrorStateChanged = p_params.onErrorStateChanged; } } // exit trace if (this._isTracing) { this.traceExit(m); } }, destroy: function() { // summary: // Destroys this widget // tags: // protected // entry trace var m = "destroy()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, doCancel: function() { // summary: // Called by the dialog consuming this widget (e.g., GenericDialog) to inform this widget // about the user having canceled the parent dialog. This widget decides whether it needs // to return a JSON object, although the parent dialog was canceled // returns: // The data this widget contributes to the parent dialog result upon cancellation // tags: // public // entry trace var m = "doCancel()"; if (this._isTracing) { this.traceEntry(m); } var result = { "returnCode": -1 }; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Object }, doConfirm: function() { // summary: // Called by the dialog consuming this widget (e.g., GenericDialog) to inform this widget // about the user having confirmed the parent dialog. This widget needs to collect its // result data and store it in a JSON object, which it needs to return with this function // returns: // The data this widget contributes to the parent dialog result upon confirmation // tags: // public // entry trace var m = "doConfirm()"; if (this._isTracing) { this.traceEntry(m); } var result = { "returnCode": 0 }; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Object }, getAuthenticationProperties: function() { // summary: // Returns the current selection from this widget, including the authentication type and any additional // data associated with it (e.g., username, password, or vault slot) // tags: // public // returns: // a reference to the internal _authProperties object // entry trace var m = "getAuthenticationProperties()"; if (this._isTracing) { this.traceEntry(m); } // retrieve settings from the UI elements and store them in _authProperties this._getAuthPropertiesFromUI(); // need to create a copy of the _authProperties object, as otherwise Picker and AuthWidget start // sharing the same object var result = dojo.clone(this._authProperties); // exit trace if (this._isTracing) { this.traceExit(m, dojo.toJson(result)); } return result; // Object }, getDialogTitle: function() { // summary: // Returns the title to show in the dialog that consumes this widget (see also // [com.ibm.widgets.GenericDialog]). // The dialog implementation is responsible of calling and honoring the title // defined by this widget. // tags: // public // entry trace var m = "getDialogTitle()"; if (this._isTracing) { this.traceEntry(m); } var result = this._nlsUserInterface.authWidget.title; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, isAuthTypeAvailable: function(/*String*/ p_authType) { // summary: // Returns an indicator as to whether or not the specified authentication type is supported // p_authType: // The authentication type to check // returns: // true if the given authentication type is supported, false otherwise // tags: // public // entry trace var m = "isAuthTypeAvailable(p_authType)"; if (this._isTracing) { this.traceEntry(m, p_authType); } var result = (this._authTypeAvailable[p_authType] === true); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, isVaultSlotAvailable: function(/*String*/ p_vaultSlotID) { // summary: // Checks whether the given vault slot id is a known Vault slot Id in the // portal system. // p_vaultSlotID: String // The vault slot ID to check for // returns: // true if the vault slot ID is a known value and therefore valid, false // otherwise // tags: // public var m = "_isVaultSlotAvailable(p_vaultSlotId)"; if (this._isTracing) { this.traceEntry(m, [p_vaultSlotID]); } var result = dojo.some(this._vaultSlots, function(slot) { if (slot) { if (slot.slotid) { return (slot.slotid === p_vaultSlotID); } else { return false; } } else { return false; } } ); if (this._isTracing) { this.traceExit(m, result); } return result; }, postCreate: function() { // summary: // Binds resources required by this widget after its DOM has been set up // tags: // protected // entry trace var m = "postCreate()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); this._initEventHandles(); // exit trace if (this._isTracing) { this.traceExit(m); } }, setAuthenticationProperties: function(/*Object*/ p_params) { // summary: // Sets the properties indicating the authentication type to select // and which fields to prefill, for example username, password, or vault slot // p_params.authProperties: // The JSON object holding the authentication settings to set for this widget // tags: // public // entry trace var m = "setAuthenticationProperties(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.authProperties:", dojo.toJson(p_params.authProperties)); } } if (p_params.authProperties) { var vaultSlot = this._authProperties.vaultSlotID; // clone the _authProperties object to avoid object sharing between Picker and Widget this._authProperties = dojo.clone(p_params.authProperties); // if we had set a vaultSlotID and now it's gone, we most probably have lost our // calculated default, so put it back if ((vaultSlot) && (!this._authProperties.vaultSlotID) && (this._vaultSlots.length > 0)) { this._authProperties.vaultSlotID = vaultSlot; } } this._setAuthPropertiesToUI(); this._callbackAuthenticationChangedEvent(); // exit trace if (this._isTracing) { this.traceExit(m); } }, startup: function() { // summary: // Called when the creation of this widget is completed to perform operations that require this widget to be fully rendered // tags: // protected // entry trace var m = "startup()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // set the default credential vault slot selection this.vaultDropDownList.attr('value', this._defaultSlotValue); // exit trace if (this._isTracing) { this.traceExit(m); } }, uninitialize: function() { // summary: // Releases the resources bound by this widget before it is destroyed // tags: // protected // entry trace var m = "uninitialize()"; if (this._isTracing) { this.traceEntry(m); } // disconnect the callbacks from their related events this._clearEventHandles(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, _callbackAuthenticationChangedEvent: function() { // summary: // Checks whether a callback for modified authentication properties is set and // calls it back with the current set of authentication properties // tags: // private callback // entry trace var m = "_callbackAuthenticationChangedEvent()"; if (this._isTracing) { this.traceEntry(m); } if (this._onChangeAuthenticationMode && (typeof this._onChangeAuthenticationMode == 'function')) { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function passing the authentication settings:", [ this._onCancelCallbackFn, dojo.toJson(this._authProperties) ]); } this._onChangeAuthenticationMode(this._authProperties); // also clear any previously displayed error message here, as the authentication was changed // and therefore the user interacted with the dialog this._clearError(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearError: function() { // summary: // Clears the error state (sets this._errorState to false) and notifies // listeners of the changed error state // tags: // private var m = "_clearError()"; if (this._isTracing) { this.traceEntry(m); } this._errorState = false; // notify registered listeners of the fact that we cleared the error if (this._onErrorStateChanged) { // no more parameters needed when clearing the error state this._onErrorStateChanged(this, false); } if (this._isTracing) { this.traceExit(m); } }, _clearEventHandles: function() { // summary: // Disconnects the events supported by this dialog from the corresponding callback methods // tags: // private // entry trace var m = "_clearEventHandles()"; if (this._isTracing) { this.traceEntry(m); } dojo.forEach(this._eventHandles, dojo.disconnect); this._eventHandles = []; // exit trace if (this._isTracing) { this.traceExit(m); } }, _correctPresetAuthType: function() { // summary: // Assuming that any of the 4 supported authTypes was set, it could still happen, that // this authType is unavailable, due to a configuration setting. To have an available // authType preset, this method automatically selects the next available authType. // tags: // private // entry trace var m = "_correctPresetAuthType()"; if (this._isTracing) { this.traceEntry(m); } if (!this.isAuthTypeAvailable(this._authProperties.authType)) { // preconfigured authType is not available, so find another one that is available instead for (var i = 0; i < this._allAuthTypes.length; i++) { var atype = this._allAuthTypes[i]; if (atype != this._authProperties.authType) { if (this.isAuthTypeAvailable(atype)) { this._authProperties.authType = atype; // exit trace if (this._isTracing) { this.traceExit(m); } return; } } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _disableVaultSlotPicker: function() { // summary: // Disables the drop-down list allowing users to select a credential vault slot for authentication // tags: // private // entry trace var m = "_disableVaultSlotPicker()"; if (this._isTracing) { this.traceEntry(m); } this.vaultDropDownList.attr('disabled', true); dojo.addClass(this.vaultDropDownListLabel, "lotusInactive"); // exit trace if (this._isTracing) { this.traceExit(m); } }, _disableUnamePwInputFields: function() { // summary: // Disables the username / password input fields // tags: // private // entry trace var m = "_disableUnamePwInputFields()"; if (this._isTracing) { this.traceEntry(m); } this.simpleAuthUser.attr("disabled", true); dojo.addClass(this.simpleAuthUserLabel, "lotusInactive"); this.simpleAuthPwd.attr("disabled", true); dojo.addClass(this.simpleAuthPwdLabel, "lotusInactive"); // exit trace if (this._isTracing) { this.traceExit(m); } }, _enableVaultSlotPicker: function() { // summary: // Enables the drop-down list allowing users to select a credential vault slot for authentication // tags: // private // entry trace var m = "_enableVaultSlotPicker()"; if (this._isTracing) { this.traceEntry(m); } this.vaultDropDownList.attr('disabled', false); dojo.removeClass(this.vaultDropDownListLabel, "lotusInactive"); // exit trace if (this._isTracing) { this.traceExit(m); } }, _enableUnamePwInputFields: function() { // summary: // Enables the username / password input fields // tags: // private // entry trace var m = "_enableUnamePwInputFields()"; if (this._isTracing) { this.traceEntry(m); } this.simpleAuthUser.attr("disabled", false); dojo.removeClass(this.simpleAuthUserLabel, "lotusInactive"); this.simpleAuthPwd.attr("disabled", false); dojo.removeClass(this.simpleAuthPwdLabel, "lotusInactive"); // exit trace if (this._isTracing) { this.traceExit(m); } }, _getAuthPropertiesFromUI: function() { // summary: // Transfers the authentication properties from the UI elements // back to the internal properties object // tags: // private // entry trace var m = "_getAuthPropertiesFromUI()"; if (this._isTracing) { this.traceEntry(m); } this._authProperties = { authType: this._authProperties.authType, // need to retrieve from variable, as there's no easy way to grab the info from the radiobuttons username: dojo.attr(this.simpleAuthUser, 'value'), password: dojo.attr(this.simpleAuthPwd, 'value'), vaultSlotID: this.vaultDropDownList.getValue(), vaultSlotTitle: dojo.attr(this.vaultDropDownList, 'title') }; // trace if (this._isTracing) { this.trace(m, "New authentication settings:", dojo.toJson(this._authProperties)); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _initEventHandles: function() { // summary: // Connects the events supported by this widget to the corresponding callback methods // and stores the handles in the _eventHandles array // tags: // private // entry trace var m = "_initEventHandles()"; if (this._isTracing) { this.traceEntry(m); } // connect generic onClick event handler for all radiobuttons this._eventHandles.push(dojo.connect(this.currentUserRadioButton.focusNode, "onclick", dojo.hitch(this, "_onSelectAuthType"))); this._eventHandles.push(dojo.connect(this.vaultRadioButton.focusNode, "onclick", dojo.hitch(this, "_onSelectAuthType"))); this._eventHandles.push(dojo.connect(this.userPwdRadioButton.focusNode, "onclick", dojo.hitch(this, "_onSelectAuthType"))); this._eventHandles.push(dojo.connect(this.vaultDropDownList, "onChange", dojo.hitch(this, "_onSelectVaultSlot"))); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onSelectAuthType: function(/*Event*/ p_evt) { // summary: // Event triggered whenever a radio button gets checked by the user // p_evt: // The event // tags: // private callback // entry trace var m = "_onSelectAuthType(p_evt)"; if (this._isTracing) { this.traceEntry(m, p_evt); } if (p_evt) { if (p_evt.target) { if (p_evt.target == this.currentUserRadioButton.focusNode) { this._authProperties.authType = com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser; this._disableVaultSlotPicker(); this._disableUnamePwInputFields(); this._callbackAuthenticationChangedEvent(); } else if (p_evt.target == this.vaultRadioButton.focusNode) { this._authProperties.authType = com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault; this._enableVaultSlotPicker(); this._disableUnamePwInputFields(); this._callbackAuthenticationChangedEvent(); } else if (p_evt.target == this.userPwdRadioButton.focusNode) { this._authProperties.authType = com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd; this._disableVaultSlotPicker(); this._enableUnamePwInputFields(); this._callbackAuthenticationChangedEvent(); } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onSelectVaultSlot: function() { // summary: // Called when the user selects a credential vault ID // tags: // private callback // entry trace var m = "_onSelectVaultSlot()"; if (this._isTracing) { this.traceEntry(m); } this._authProperties.vaultSlotID = this.vaultDropDownList.getValue(); // trace if (this._isTracing) { this.trace(m, "New credential vault slot ID:", this._authProperties.vaultSlotID); } this._callbackAuthenticationChangedEvent(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _selectPresetAuthType: function() { // summary: // Checks the radio button that is configured as the preset authentication type // tags: // private // entry trace var m = "_selectPresetAuthType()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Preset authentication type:", this._authProperties.authType); } if (this._authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser) { this.currentUserRadioButton.setChecked(true); this._disableVaultSlotPicker(); this._disableUnamePwInputFields(); } else if (this._authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) { this.userPwdRadioButton.setChecked(true); this._disableVaultSlotPicker(); this._enableUnamePwInputFields(); } else if (this._authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault) { this._disableUnamePwInputFields(); if (this._vaultSlots.length <= 0) { // error condition, no vault slots available, but vault slot configured this.warning(m, "There are no credential vault slots configured in this instance of Portal"); // ignore request to change authType } else { this.vaultRadioButton.setChecked(true); this._enableVaultSlotPicker(); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _setAuthPropertiesToUI: function() { // summary: // Helper method, which transfers the authentication properties from the settings object to // the UI elements of the widget // tags: // private // entry trace var m = "_setAuthPropertiesToUI()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Authentication settings:", dojo.toJson(this._authProperties)); } this._correctPresetAuthType(); this._selectPresetAuthType(); if (this._authProperties) { // can only do this, if the _authProperties object is present, otherwise, we'll // just select a default auth method and leave the fields empty if (this._authProperties.username) { dojo.attr(this.simpleAuthUser, 'value', this._authProperties.username); } if (this._authProperties.password) { dojo.attr(this.simpleAuthPwd, 'value', this._authProperties.password); } if (this._authProperties.vaultSlotID) { this.vaultDropDownList.setValue(this._authProperties.vaultSlotID); } } else { // make sure userid/pwd fields are empty dojo.attr(this.simpleAuthUser, 'value', ''); dojo.attr(this.simpleAuthPwd, 'value', ''); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _showHideAuthTypeSections: function() { // summary: // Initializes the authentication type options for rendering // tags: // private // entry trace var m = "_showHideAuthTypeSections()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Available authentication types:", dojo.toJson(this._authTypeAvailable)); } if (this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser] === false) { this.currentUserRadioButton.set('disabled', true); dojo.style(this.currentUserDIV, "display", "none"); dijit.setWaiState(this.currentUserDIV, 'hidden', true); } if (this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd] === false) { this.userPwdRadioButton.set('disabled', true); dojo.style(this.usernamePasswordDIV, "display", "none"); dijit.setWaiState(this.usernamePasswordDIV, 'hidden', true); } if (this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault] === false) { this.vaultRadioButton.set('disabled', true); dojo.style(this.credentialVaultDIV, "display", "none"); dijit.setWaiState(this.credentialVaultDIV, 'hidden', true); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _setUpVaultDropDownList: function() { // summary: // Initializes the credential vault drop-down list for rendering // tags: // private // entry trace var m = "_setUpVaultDropDownList()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Available credential vault slots:", dojo.toJson(this._vaultSlots)); } // IMPORTANT: there seems to be a bug in IE or DOJO which causes the ComboBox list to be displayed // as empty, if we choose something else than 'name' as the 'identifier' property. // Therefore, although the input data has 'slotid' as the identifier, we need to // rewrite it to be using 'name'. if (this._authTypeAvailable[com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault]) { // As a side-effect, while looping over all vaultSlot, we grab the first entry as the defaultValue for (var i = 0; i < this._vaultSlots.length; i++) { this._vaultSlots[i].name = decodeURIComponent(this._vaultSlots[i].slotid); if (this._defaultSlotValue === "") { this._defaultSlotValue = this._vaultSlots[i].name; } } } this._vaultSlotStore = new dojo.data.ItemFileReadStore( { data: { "label": "name", "identifier": "name", "items": this._vaultSlots } }); this.vaultDropDownList.attr('store', this._vaultSlotStore); // IMPORTANT: if _authProperties.vaultSlotID is empty and we have entries in this._vaultSlots, assign // the currently selected item to _authProperties.vaultSlotID, so UI and properties are // in sync if ((!this._authProperties.vaultSlotID) && (this._vaultSlots.length > 0)) { // grab actual value from the UI element, as the slots might be sorted and getting // it directly from the source array could yield wrong results this._authProperties.vaultSlotID = this.vaultDropDownList.getValue(); // trace if (this._isTracing) { this.trace(m, "Set default credential vault slot ID:", this._authProperties.vaultSlotID); } } // exit trace if (this._isTracing) { this.traceExit(m); } } }); //*** global constants for all dijit instances *** // com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeNoAuth: [const] String // ID for authType "No authentication" com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeNoAuth = "authNone"; // com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd: [const] String // ID for authType "Simple Auth (User + Pwd)" com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd = "authUserPwd"; // com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser: [const] String // ID for authType "Use current user" com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser = "authSSO"; // com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault: [const] String // ID for authType "Use credential vault" com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault = "authVault"; } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.ExpandableSectionWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.ExpandableSectionWidget"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.ExpandableSectionWidget"); dojo.registerModulePath("com.ibm.workplace.wcm.ecm.picker.widget","../com/ibm/workplace/wcm/ecm/picker/widget"); dojo.require("dijit._Widget"); dojo.require("dijit._Templated"); dojo.require("com.ibm.widgets._Traceable"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.widget.ExpandableSectionWidget", [dijit._Widget, dijit._Templated, com.ibm.widgets._Traceable], { // summary: // This widget wraps arbitrary instances of widgets to support different // visual states, such as being collapsed or expanded // blankImgUrl: Object // URL pointing to a blank image (1x1 transparent pixel) blankImgUrl: dojo.moduleUrl("dojo", "resources/blank.gif").toString(), // namespace: [protected] String // The namespace this widget uses for building its user interface elements namespace: "expSctWdgt_", // parseOnLoad: // see dijit.Dialog parseOnLoad: true, // templatePath: // see dijit.Dialog templateString:"
\n \n ${_sectionTitleText}\n
\n
\n
\n
\n
\n
\n
\n
\n", // _eventHandles: [private] Array // Array of handles created when connecting events to methods _eventHandles: [], // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _nlsMessages: [private] Object // Object holding localized strings used for providing localized messages _nlsMessages: {}, // _nlsUserInterface: [private] Object // Object holding localized strings used for providing localized user interface elements _nlsUserInterface: {}, // _onCollapsed: [private] Function // Callback method that is triggered when the wrapped widget section collapsed _onCollapsed: null, // _onExpanded: [private] Function // Callback method that is triggered when the wrapped widget section fully expanded _onExpanded: null, // _openHeight: [private] Integer // Height in ex of the section, when it is expanded _openHeight: 5.5, // 100px = 5.5ex // _openWidth: [private] Integer // Width in em of the section, when it is expanded _openWidth: 6.25, // 100px = 6.25em // _sectionID: [private] String // ID of the section holding the wrapped widget. It is used to support multiple instances of this // expandable section widget in one page _sectionID: "", // _sectionTitleText: [private] String // Text displayed as a clickable link next to the icon to expand or collapse the section showing the // wrapped widget _sectionTitleText: "", // _visible: [private] Boolean // Specifies whether or not the widget is visible by default _visible: false, // _widget: [private] Object // Instance of the widget that is wrapped by this expandable section widget _widget: null, buildRendering: function() { // summary: // Constructs the user interface of this widget // tags: // protected // entry trace var m = "buildRendering()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); if (this._widget) { this._widget.placeAt(this.widgetNode); } if ((this._visible) && (this._visible === true)) { this.showSection(); } else { this.hideSection(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, constructor: function(/*Object*/ p_params) { // summary: // Constructs this widget // p_params: Object // The parameters to instantiate this widget with // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { // do not use dojo.toJson with p_params, because it causes too much recursion errors this.traceEntry(m, p_params); if (p_params) { this.traceEntry(m, "p_params.namespace:", p_params.namespace); this.traceEntry(m, "p_params.nlsMessages:", dojo.toJson(p_params.nlsMessages)); this.traceEntry(m, "p_params.nlsUserInterface:", dojo.toJson(p_params.nlsUserInterface)); this.traceEntry(m, "p_params.onCollapsed:", p_params.onCollapsed); this.traceEntry(m, "p_params.onExpanded:", p_params.onExpanded); this.traceEntry(m, "p_params.openHeight:", p_params.openHeight); this.traceEntry(m, "p_params.openWidth:", p_params.openWidth); this.traceEntry(m, "p_params.sectionID:", p_params.sectionID); this.traceEntry(m, "p_params.sectionTitleText:", p_params.sectionTitleText); this.traceEntry(m, "p_params.visible:", p_params.visible); this.traceEntry(m, "p_params.widgetInstance:", p_params.widgetInstance); } } if (typeof p_params.namespace == 'string') { this.namespace = p_params.namespace; } if (p_params.nlsMessages && typeof p_params.nlsMessages == 'object') { this._nlsMessages = p_params.nlsMessages; } if (p_params.nlsUserInterface && typeof p_params.nlsUserInterface == 'object') { this._nlsUserInterface = p_params.nlsUserInterface; } if (p_params.widgetInstance && typeof p_params.widgetInstance == 'object') { this._widget = p_params.widgetInstance; } if (typeof p_params.openWidth == 'number') { this._openWidth = p_params.openWidth; } if (typeof p_params.openHeight == 'number') { this._openHeight = p_params.openHeight; } if (typeof p_params.sectionTitleText == 'string') { this._sectionTitleText = p_params.sectionTitleText; } if (typeof p_params.sectionID == 'string') { this._sectionID = p_params.sectionID; } if (typeof p_params.visible == 'boolean') { this._visible = p_params.visible; } if (typeof p_params.onExpanded == 'function') { this._onExpanded = p_params.onExpanded; } if (typeof p_params.onCollapsed == 'function') { this._onCollapsed = p_params.onCollapsed; } // exit trace if (this._isTracing) { this.traceExit(m); } }, hideSection: function() { // summary: // Hides the wrapped widget section // tags: // public // entry trace var m = "hideSection()"; if (this._isTracing) { this.traceEntry(m); } this._visible = false; dojo.style(this.SectionDIV, "display", "none"); dijit.setWaiState(this.SectionDIV, 'hidden', true); // exit trace if (this._isTracing) { this.traceExit(m); } }, isSectionCollapsed: function() { // summary: // Returns an indication as to whether the wrapped widget section is currently collapsed // returns: // true if the section is collapsed, false otherwise // tags: // public // entry trace var m = "isSectionCollapsed()"; if (this._isTracing) { this.traceEntry(m); } var result = dojo.hasClass(this.sectionTwisty, "lotusTwistyClosed"); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, isSectionExpanded: function() { // summary: // Returns an indication as to whether the wrapped widget section is currently expanded // returns: // true if the section is expanded, false otherwise // tags: // public // entry trace var m = "isSectionExpanded()"; if (this._isTracing) { this.traceEntry(m); } var result = dojo.hasClass(this.sectionTwisty, "lotusTwistyOpen"); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, postCreate: function() { // summary: // Binds resources required by this dialog after its DOM has been set up // tags: // protected // entry trace var m = "postCreate()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); this._initEventHandles(); this._setSectionClosed(); // exit trace if (this._isTracing) { this.traceExit(m); } }, postMixInProperties: function() { // summary: // Prepares the creation of the user interface of this dialog // tags: // protected // entry trace var m = "postMixInProperties()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // concat _sectionID (if set) to this.namespace to get unique identifiers if ((this._sectionID) && (this.namespace)) { this.namespace = this.namespace + this._sectionID; } // set sectionLinkTitle to the default this.sectionLinkTitle = this._nlsUserInterface.expSectionWidget.sectionLinkExpandTitle; // exit trace if (this._isTracing) { this.traceExit(m); } }, showSection: function() { // summary: // Makes the wrapped widget section visible // tags: // public // entry trace var m = "showSection()"; if (this._isTracing) { this.traceEntry(m); } this._visible = true; dojo.style(this.SectionDIV, "display", "block"); dijit.setWaiState(this.SectionDIV, 'hidden', false); // exit trace if (this._isTracing) { this.traceExit(m); } }, uninitialize: function() { // summary: // Releases the resources bound by this widget before it is destroyed // tags: // protected // entry trace var m = "uninitialize()"; if (this._isTracing) { this.traceEntry(m); } this._clearEventHandles(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearEventHandles: function() { // summary: // Disconnects the events supported by this dialog from the corresponding callback methods // tags: // private // entry trace var m = "_clearEventHandles()"; if (this._isTracing) { this.traceEntry(m); } // disconnect the callbacks from their related events dojo.forEach(this._eventHandles, dojo.disconnect); this._eventHandles = []; // exit trace if (this._isTracing) { this.traceExit(m); } }, _closeSection: function() { // summary: // Collapses the wrapped widget section in an animated manner before it becomes invisible // tags: // private // entry trace var m = "_closeSection()"; if (this._isTracing) { this.traceEntry(m); } dojo.animateProperty({ "node": dojo.byId(this.namespace + "sectionWidgetDIV"), "duration": 500, "properties": { //"width": { "end": 100, "units": "px"}, "height": { "end": 0, "units": "px" } }, "onEnd": dojo.hitch(this, function() { this._setSectionClosed(); dojo.style(dojo.byId(this.namespace + "sectionWidgetDIV"), "display", "none"); if ((this._onCollapsed) && (typeof this._onCollapsed == 'function')) { this._onCollapsed(); } }) }).play(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _initEventHandles: function() { // summary: // Connects the events supported by this widget to the corresponding callback methods // and stores the handles in the _eventHandles array // tags: // private // entry trace var m = "_initEventHandles()"; if (this._isTracing) { this.traceEntry(m); } this._eventHandles.push(dojo.connect(this.sectionTwisty, "onclick", dojo.hitch(this, "_onOpenCloseSection"))); this._eventHandles.push(dojo.connect(this.sectionLink, "onclick", dojo.hitch(this, "_onOpenCloseSection"))); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onOpenCloseSection: function() { // summary: // Callback method that is triggered when the wrapped widget section is to change // its state in terms of being collapsed or expanded // returns: // private callback // entry trace var m = "_onOpenCloseSection()"; if (this._isTracing) { this.traceEntry(m); } var isSectionOpen = dojo.hasClass(this.sectionTwisty, "lotusTwistyOpen"); // trace if (this._isTracing) { this.trace(m, "Is section open:", isSectionOpen); } if (isSectionOpen) { // close the section and modify the css classes of // the twisty tag this._closeSection(); } else { // open the section and modify the css classes of // the twisty tag this._openSection(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _openSection: function() { // summary: // Expands the wrapped widget section in an animated manner // tags: // private // entry trace var m = "_openSection()"; if (this._isTracing) { this.traceEntry(m); } this.sectionLinkTitle = this._nlsUserInterface.expSectionWidget.sectionLinkCollapseTitle; var domNode = dojo.byId(this.namespace + "sectionWidgetDIV"); dojo.style(domNode, "display", "block"); dojo.marginBox(domNode, { h: "0ex", w: "0em" }); // required, otherwise px values would be interpreted as ex values by the animation, causing weird visual errors dojo.style(domNode, 'height', '0ex'); dojo.style(domNode, 'width', '0em'); dojo.animateProperty({ "node": domNode, "duration": 500, "properties": { "width": { "end": this._openWidth, "units": "em"}, "height": { "end": this._openHeight, "units": "ex" } }, "onEnd": dojo.hitch(this, function() { dojo.removeClass(this.sectionTwisty, "lotusTwistyClosed"); dojo.addClass(this.sectionTwisty, "lotusTwistyOpen"); dojo.attr(this.sectionTwisty, "title", this.sectionLinkTitle); dojo.attr(this.sectionLink, "title", this._sectionTitleText); dijit.setWaiState(this.sectionTwisty, 'label', this.sectionLinkTitle); dijit.setWaiState(this.sectionLink, 'label', this._sectionTitleText); dijit.setWaiState(this.SectionDIV, 'expanded', true); dijit.setWaiState(this.sectionWidgetDIV, 'hidden', false); // update the non-image alternative Unicode character for the section open state. // This character is shared among RTL and LTR mode dojo.attr(this.sectionTwistySpan, "innerHTML", "▼"); dojo.style(domNode, 'height', 'auto'); if ((this._onExpanded) && (typeof this._onExpanded == 'function')) { this._onExpanded(); } }) }).play(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setSectionClosed: function() { // summary: // Sets the wrapped widget section into the collapsed state // tags: // private // entry trace var m = "_setSectionClosed()"; if (this._isTracing) { this.traceEntry(m); } this.sectionLinkTitle = this._nlsUserInterface.expSectionWidget.sectionLinkExpandTitle; dojo.removeClass(this.sectionTwisty, "lotusTwistyOpen"); dojo.addClass(this.sectionTwisty, "lotusTwistyClosed"); dojo.attr(this.sectionTwisty, "title", this.sectionLinkTitle); dojo.attr(this.sectionLink, "title", this._sectionTitleText); dijit.setWaiState(this.sectionTwisty, 'label', this.sectionLinkTitle); dijit.setWaiState(this.sectionLink, 'label', this._sectionTitleText); dijit.setWaiState(this.SectionDIV, 'expanded', false); dijit.setWaiState(this.sectionWidgetDIV, 'hidden', true); // update the non-image alternative character for the twisty, based on // the isRTL flag (the closed arrow needs to look different in RTL and LTR mode) if (this.isRTL) { dojo.attr(this.sectionTwistySpan, "innerHTML", "◄"); } else { dojo.attr(this.sectionTwistySpan, "innerHTML", "►"); } // exit trace if (this._isTracing) { this.traceExit(m); } } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget"); dojo.registerModulePath("com.ibm.workplace.wcm.ecm.picker.widget","../com/ibm/workplace/wcm/ecm/picker/widget"); dojo.require("dijit._Widget"); dojo.require("dijit._Templated"); dojo.require("com.ibm.widgets._Traceable"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget", [dijit._Widget, dijit._Templated, com.ibm.widgets._Traceable], { // summary: // This widget implementation serves as base dojo class for widgets that are // meant to be displayed as pages of the generic wizard dialog // namespace: [protected] String // The namespace this widget uses for building its user interface elements namespace: "genWzrdPgWdgt_", // virtualContainerNodeHeight: [private] Integer // Holds the height information for the surrounding container (DIV) of this widget. // This value is only defined, if the surrounding DIV does not have an explicit // height set on it's own, because it is being resized automatically based on it's // content. The height information is virtually traversing the container node, // allowing the widget to set it's size, which will then cause the surrounding // DIV to adapt to the modified size of it's content accordingly. // // Default is null virtualContainerNodeHeight: null, // _dialogTitle: [private] String // The title of the this wizard page widget. If the page is meant to // change the title of the dialog hosting the wizard, a non-null value must // be set. // Default is null _dialogTitle: null, // _errorState: [private] Boolean // Indicates whether an error occurred and whether this widget went into error state. // The error state persists, until _clearError() was called. _errorState: false, // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _onErrorStateChanged: [private] Function // Callback method that is triggered by this widget when an error condition // occurred and the associated error message needs to be displayed in the // owning dialog or if the widget was in error state previously and the // error was cleared. // // _onErrorStateChanged(/*Object*/ p_sender, /*Boolean*/ p_errorState, // /*String?*/p_errorMsg, /*String?*/p_errorDetails) _onErrorStateChanged: null, // _nlsMessages: [private] Object // Object holding localized strings used for providing localized messages _nlsMessages: {}, // _nlsUserInterface: [private] Object // Object holding localized strings used for providing localized user interface elements _nlsUserInterface: {}, // _onDefaultAction: [private] Function // Callback method that is triggered by this widget, whenever the user presses // ENTER on the keyboard. The wizard dialog is meant to determine whether // the default action is going forward to the next page, or whether it means // closing the dialog with the confirm action. // // No arguments are passed _onDefaultAction: null, // _onLayoutChanged: [private] Function // Callback method that is triggered by this widget when its layout changed. // The dialog hosting this widget can set this callback to receive a notification // about such layout modifications. // No arguments are passed _onLayoutChanged: null, // _onReadyStateChanged: [private] Function // Callback method that is triggered by this widget when it reached a state // that technically allows the user to proceed to the next step of a wizard // The current value of the ready state boolean is passed as an argument as // well as a reference to this widget _onReadyStateChanged: null, // _pickerContext: [private] String // Indicates whether or not the Federated Documents Picker is launched as a fully fledged dialog of its // own or as a dependent widget. The latter is the case of using the Federated Documents Picker Portlet // inside of a dialog that is created by the modal dialog framework of the portal. // Supported values are: // - com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog // - com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._portlet _pickerContext: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog, // _pickerManager: [private] Object // Reference to the [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerManager] // object instance that was used to launch the FederatedDocumentsPickerDialog. // Needed only for the QuickrPage for calling the launchQuickerPicker() function. _pickerManager: null, // _ready: [private] Boolean // Flag indicating the ready state of the widget. Being 'ready' means that the // user can either advance to the next wizard page widget or complete the wizard. // Wizard implementations can still decide to determine the ready state by other // means, for example, in case input from multiple panels needs to be considered. _ready: false, // _stepDescription: [private] String // A string that the wizard displays in its descriptive panel below the // step label. It describes the currently active step _stepDescription: "", // _stepLabel: [private] String // A string that the wizard displays in its descriptive panel showing the user // which step of the wizard is currently active _stepLabel: "", constructor: function(/*Object*/ p_params) { // summary: // Constructs this widget // p_params.nlsMessages: Object // Object holding localized strings used for providing localized messages // p_params.nlsUserInterface: Object // Object holding localized strings used for providing localized user interface elements // p_params.onDefaultAction: Function // Callback method that is triggered by this widget, whenever the user presses // ENTER on the keyboard. The wizard dialog is meant to determine whether // the default action is going forward to the next page, or whether it means // closing the dialog with the confirm action. // p_params.onErrorStateChanged: Function // Callback method that is triggered by this widget, when the error state // of the page changed and this change needs to be reported back to the // parent // p_params.onLayoutChanged: Function // Callback method that is triggered by this widget when its layout changed. // The dialog hosting this widget can set this callback to receive a notification // about such layout modifications. // No arguments are passed to this function // p_params.onReadyStateChanged: Function // Callback method that is triggered by this widget when it reached a state // that technically allows the user to proceed to the next step of a wizard // The current value of the ready state boolean is passed as an argument as // well as a reference to this widget // p_params.pickerContext: String // Indicates whether or not the Federated Documents Picker is launched as a fully fledged dialog of its // own or as a dependent widget. The latter is the case of using the Federated Documents Picker Portlet // inside of a dialog that is created by the modal dialog framework of the portal. // Supported values are: // - com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog // - com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._portlet // p_params.pickerManager: Object // Reference to the [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerManager] instance // which launched the current instance of the FederatedDocumentsPickerDialog // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { // do not use dojo.toJson with p_params, because it causes an error when trying to serialize a DOM node this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.nlsMessages:", dojo.toJson(p_params.nlsMessages)); this.trace(m, "p_params.nlsUserInterface:", dojo.toJson(p_params.nlsUserInterface)); this.trace(m, "p_params.onDefaultAction:", p_params.onDefaultAction); this.trace(m, "p_params.onErrorStateChanged", p_params.onErrorStateChanged); this.trace(m, "p_params.onLayoutChanged:", p_params.onLayoutChanged); this.trace(m, "p_params.onReadyStateChanged:", p_params.onReadyStateChanged); this.trace(m, "p_params.pickerContext:", p_params.pickerContext); this.trace(m, "p_params.pickerManager", p_params.pickerManager); } } if (typeof p_params.namespace == 'string') { this.namespace = p_params.namespace; } if (p_params.nlsMessages && dojo.isObject(p_params.nlsMessages)) { this._nlsMessages = p_params.nlsMessages; } if (p_params.nlsUserInterface && dojo.isObject(p_params.nlsUserInterface)) { this._nlsUserInterface = p_params.nlsUserInterface; } if ((p_params.onDefaultAction) && dojo.isFunction(p_params.onDefaultAction)) { this._onDefaultAction = p_params.onDefaultAction; } if ((p_params.onErrorStateChanged) && dojo.isFunction(p_params.onErrorStateChanged)) { this._onErrorStateChanged = p_params.onErrorStateChanged; } if ((p_params.onLayoutChanged) && dojo.isFunction(p_params.onLayoutChanged)) { this._onLayoutChanged = p_params.onLayoutChanged; } if ((p_params.onReadyStateChanged) && dojo.isFunction(p_params.onReadyStateChanged)) { this._onReadyStateChanged = p_params.onReadyStateChanged; } // picker context if (typeof p_params.pickerContext == 'string') { this._pickerContext = p_params.pickerContext; } if ((p_params.pickerManager) && dojo.isObject(p_params.pickerManager)) { this._pickerManager = p_params.pickerManager; } // exit trace if (this._isTracing) { this.traceExit(m); } }, getDialogTitle: function() { // summary: // Returns the title to show in the dialog that consumes this widget (see also // [com.ibm.widgets.GenericDialog]). // The dialog implementation is responsible of calling and honoring the title // defined by this widget // returns: // The title of this wizard page widget // tags: // public // entry trace var m = "getDialogTitle()"; if (this._isTracing) { this.traceEntry(m); } var result = this._dialogTitle; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getNlsMessages: function() { // summary: // Returns the NLS bundle for messages related to this wizard page widget // tags: // protected // returns: // the Object holding localized strings used for providing localized messages // entry trace var m = "getNlsMessages()"; if (this._isTracing) { this.traceEntry(m); } var result = this._nlsMessages; // exit trace if (this._isTracing) { this.traceExit(m, dojo.toJson(result)); } return result; // Object }, getNlsUserInterface: function() { // summary: // Returns the NLS bundle for user interface elements related to this wizard page widget // tags: // protected // returns: // the Object holding localized strings used for providing localized user interface elements // entry trace var m = "getNlsUserInterface()"; if (this._isTracing) { this.traceEntry(m); } var result = this._nlsUserInterface; // exit trace if (this._isTracing) { this.traceExit(m, dojo.toJson(result)); } return result; // Object }, getStepLabel: function() { // summary: // Returns the title of the wizard step implemented by this widget // returns: // The title of the current step represented by this widget // tags: // public // entry trace var m = "getStepLabel()"; if (this._isTracing) { this.traceEntry(m); } var result = this._stepLabel; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getStepDescription: function() { // summary: // Returns the description of the wizard step implemented by this widget // returns: // The description of the current step represented by this widget // tags: // public // entry trace var m = "getStepDescription()"; if (this._isTracing) { this.traceEntry(m); } var result = this._stepDescription; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, initializePage: function(/*Object*/ p_params) { // summary: // Method being called to initialize this wizard page widget for display // with data from the previous page (if needed) // p_params: // Parameters to initialize this page widget with // tags: // public // entry trace var m = "initializePage()"; if (this._isTracing) { this.traceEntry(m); } // instances need to override this method // exit trace if (this._isTracing) { this.traceExit(m); } }, isReady: function() { // summary: // Returns a boolean to indicate whether or not this widget considers itself as ready, // so that the wizard can move on to the next step (i.e., the next wizard page widget) // returns: // true if this wizard page widget is in ready state, false otherwise // tag: // public // entry trace var m = "isReady()"; if (this._isTracing) { this.traceEntry(m); } var result = this._ready; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, layout: function() { // summary: // Triggered by calling code to have this page widget perform layout operation, which // will cause the widget to align child widgets and markup to available space (horizontally and // vertically) // tags: // public abstract // to be implemented by derived classes }, setFocus: function() { // summary: // Finds the first element that can be tabbed to within the widget's domNode and focusses // it // tags: // public var m = "setFocus()"; if (this._isTracing) { this.traceEntry(m); } var elem = dijit.getFirstInTabbingOrder(this.domNode); if (elem) { dijit.focus(elem); } if (this._isTracing) { this.traceExit(m); } }, _clearError: function() { // summary: // Clears the error state (sets this._errorState to false) and notifies // listeners of the changed error state // tags: // private var m = "_clearError()"; if (this._isTracing) { this.traceEntry(m); } // only run down the notification chain once, if there's an error // condition. Doing so unconditionally, could cause dependent code // to run multiple times unnecessarily (e.g. like resizing code, etc) if (this._errorState === true) { this._errorState = false; // notify registered listeners of the fact that we cleared the error if (this._onErrorStateChanged) { // no more parameters needed when clearing the error state this._onErrorStateChanged(this, false); } } if (this._isTracing) { this.traceExit(m); } }, _layoutChanged: function() { // summary: // Called by this wizard page widget to notify the hosting dialog of a layout // modification using the onLayoutChanged callback function registered with // this widget // tag: // private // entry trace var m = "_layoutChanged()"; if (this._isTracing) { this.traceEntry(m); } if ((this._onLayoutChanged) && dojo.isFunction(this._onLayoutChanged)) { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function:", this._onLayoutChanged); } this._onLayoutChanged(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _setReadyValue: function(/*Boolean*/ p_isReady) { // summary: // Called by this wizard page widget to notify the hosting dialog of a ready // state change using the onReadyStateChanged callback function registered with // this widget // tag: // private // entry trace var m = "_setReadyValue(p_isReady)"; if (this._isTracing) { this.traceEntry(m, p_isReady); this.trace(m, "Current ready state:", this._ready); } if (this._ready != p_isReady) { this._ready = p_isReady; if ((this._onReadyStateChanged) && (dojo.isFunction(this._onReadyStateChanged))) { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function passing the new ready state:", [this._onReadyStateChanged, this._ready]); } this._onReadyStateChanged(this._ready, this); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _showError: function(/*String*/ p_errorMsg, /*String*/ p_errorDetails) { // summary: // Sends the provided error message to a registered listener (could be a // dialog) for display. Optionally, also sends a more detailed message // for the error. // p_errorMsg: String // The error message to display // p_errorDetails: String // Optional string with a more detailed description of the error // tags: // protected var m = "_showError(p_errorMsg, p_errorDetails)"; if (this._isTracing) { this.traceEntry(m, [p_errorMsg, p_errorDetails]); } this._errorState = true; // notify registered listeners of the error and have them e.g. display // the error message + details if (this._onErrorStateChanged) { this._onErrorStateChanged(this, true, p_errorMsg, p_errorDetails); } if (this._isTracing) { this.traceExit(m); } } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.URLUtils"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.URLUtils"] = true; ////////////////////////////////////////////////// // Licensed Materials - Property of IBM // // 5724-E76, 5655-R17, 5655-M44 // // Copyright IBM Corp. 2011 All Rights reserved.// ////////////////////////////////////////////////// dojo.provide("com.ibm.workplace.wcm.ecm.picker.util.URLUtils"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.util.URLUtils", [com.ibm.widgets._Traceable], { // summary: // Provides some utility helper function for URL handling // downloadAjaxProxyContext: [public] String // The web application context of the ajax proxy mapping for CMIS enclosure downloads downloadAjaxProxyContext: "/cmis_proxy", getProtocol: function(/*String*/ p_url) { // summary: // Get the protocol part from the passed URL // p_url: // The URL to get the protocol from // tags: // public // returns: // The protocol of the URL or null if the URL is not a absolute URL // entry trace var m = "getProtocol(p_url)"; if (this._isTracing) { this.traceEntry(m, [ p_url ]); } var result = null; if (p_url && p_url.length > 0) { var pos = p_url.indexOf("://"); if(pos > 0) { result = p_url.substring(0, pos); } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getAuthority: function(/*String*/ p_url) { // summary: // Get the authority part from the passed URL. // The authoriy is the host plus port part // p_url: // The URL to get the authority from // tags: // public // returns: // The authority of the URL or null if the URL is not a absolute URL // entry trace var m = "getAuthority(p_url)"; if (this._isTracing) { this.traceEntry(m, [ p_url ]); } var result = null; if (p_url && p_url.length > 0) { var start = p_url.indexOf("//"); if(start >= 0) { start = start+2; var end = p_url.indexOf("/", start); if(end >= start) { result = p_url.substring(start, end); } else { result = p_url.substring(start); } } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getHost: function(/*String*/ p_url) { // summary: // Get the host part from the passed URL // p_url: // The URL to get the host from // tags: // public // returns: // The host of the URL or null if the URL is not a absolute URL // entry trace var m = "getHost(p_url)"; if (this._isTracing) { this.traceEntry(m, [ p_url ]); } var result = null; var authority = this.getAuthority(p_url); if (authority && authority.length > 0) { var end = authority.indexOf(":"); if(end >= 0) { result = authority.substring(0, end); } else { result = authority; } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getPort: function(/*String*/ p_url) { // summary: // Get the port from the passed URL // p_url: // The URL to get the port from // tags: // public // returns: // The port of the URL or null if the URL is not a absolute URL // entry trace var m = "getPort(p_url)"; if (this._isTracing) { this.traceEntry(m, [ p_url ]); } var result = null; var authority = this.getAuthority(p_url); if (authority && authority.length > 0) { var start = authority.indexOf(":"); if(start > 0 && authority.length > start+1) { result = authority.substring(start+1); } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getFile: function(/*String*/ p_url) { // summary: // Get the file part from the passed URL. // The file is the path plus query string // p_url: // The URL to get the file from // tags: // public // returns: // The file of the URL or null if the URL is not a absolute or relative URL // entry trace var m = "getFile(p_url)"; if (this._isTracing) { this.traceEntry(m, [ p_url ]); } var result = null; if (p_url && p_url.length > 0) { var hostStart = p_url.indexOf("//"); if(hostStart >= 0) { // absolute URL hostStart = hostStart+2; var start = p_url.indexOf("/", hostStart); // every after the host:port is the file if(start > 0) { result = p_url.substring(start); } } else { // server relative or relative URL result = p_url; } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, addQueryParameter: function(/*String*/ p_url, /*String*/ p_name, /*String[]? | String?*/ p_value) { // summary: // Adds a query parameter with the given name and value to the specified URL and // returns the resulting URL // p_url: // The URL to add the query parameter to // p_name: // The name of the query parameter to add // p_value: // Value to add to the URL. // Can be a single value or array or null for an empty value // tags: // public // returns: // The URL with appended the query parameter // entry trace var m = "addQueryParameter(p_url, p_name, p_value)"; if (this._isTracing) { this.traceEntry(m, [ p_url, p_name, p_value ]); } var result = null; if (p_url && p_name) { // check if URL has fragment var fragmentPos = p_url.lastIndexOf("#"); var fragment = null; if (fragmentPos > -1) { fragment = p_url.substring(fragmentPos); result = p_url.substring(0, fragmentPos); } else { result = p_url; } // check if URL has existing query parameters var protocolExtParam = null; var queryPos = result.indexOf("?"); if (queryPos != -1) { // check if ; parameters like ;jsessionid=1234 exists after the ? var protocolExtParamPos = result.lastIndexOf(";", queryPos); if (protocolExtParamPos != -1) { // the query string part has a ; parameter protocolExtParam = result.substring(protocolExtParamPos); result = result.substring(0, protocolExtParamPos); } if (result.length - 1 > queryPos) { // some parameter exist already result = result + "&"; } } else { // new query string result = result + "?"; } // add parameter to URL if (p_value) { if (p_value instanceof Array) { // multi value parameter for (i = 0; i < p_value.length; i++) { result = result + encodeURIComponent(p_name) + "=" + encodeURIComponent(p_value[i]); if (i + 1 < p_value.length) { result = result + "&"; } } } else { // single value parameter result = result + encodeURIComponent(p_name) + "=" + encodeURIComponent(p_value); } } else { // empty value so simply add the parameter name result = result + encodeURIComponent(p_name) + "="; } // add protocol param back to URL if (protocolExtParam) { result = result + protocolExtParam; } // add fragment back to URL if (fragment) { result = result + fragment; } } else { // nothing to add result = p_url; } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, appendPath: function(/*String*/ p_url, /*String*/ p_path) { // summary: // Appends the given path to the URL. This method does not perform a // full URI resolution, but merely concatenates the input strings // p_url: // The URL to append the specified path to, must not include a query or fragment // p_path: // The path segments to add to the specified URL // tags: // private // entry trace var m = "appendPath(p_url, p_path)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_path]); } var result; if (p_path.length > 0) { if (p_url.length > 0) { var urlIndex = p_url.length - 1; // make sure the URL does not have a tailing slash var urlNoSlash; if (p_url.charAt(urlIndex) == "/") { urlNoSlash = p_url.substring(0, urlIndex); } else { urlNoSlash = p_url; } // append the path with a leading slash if (p_path.charAt(0) == "/") { result = urlNoSlash + p_path; } else { result = urlNoSlash + "/" + p_path; } } else { result = p_path; } } else { result = p_url; } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, generateProxiedUrl: function(/*String*/ p_url, /*String*/ p_wpsContext) { // summary: // Generate a URL to points to the ajax proxy servlet and that can be used // to retrieve the document addressed with the passed URL // p_url: // The URL get get via the proxy // p_wpsContext: // The context of the portal application e.g. /wps // tags: // public // returns: // The protocol of the URL or null if the URL is not a absolute URL // entry trace var m = "generateProxiedUrl(p_url, p_wpsContext)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_wpsContext]); } var result = p_url; if(p_wpsContext.length > 0) { var proxyUrl = null; // normalize wps context // to /wps if(p_wpsContext.charAt(0) == '/') { proxyUrl = p_wpsContext; } else { proxyUrl = "/" + p_wpsContext; } // append proxy context // /wps/cmis_proxy/ proxyUrl = proxyUrl + this.downloadAjaxProxyContext + "/"; var protocol = this.getProtocol(p_url); if(protocol && protocol.length > 0) { // append the protocol // /wps/cmis_proxy/http/ proxyUrl = proxyUrl + protocol + "/"; var host = this.getHost(p_url); if(host && host.length > 0) { // append the host // /wps/cmis_proxy/http/host proxyUrl = proxyUrl + host; var port = this.getPort(p_url); if(port && port.length > 0) { // append the port // /wps/cmis_proxy/http/host%3Aport proxyUrl = proxyUrl + "%3A" + port; } var file = this.getFile(p_url); if(file && file.length > 0) { // append the rest // /wps/cmis_proxy/http/host%3Aport/path?query proxyUrl = proxyUrl + file; } // this is the result result = proxyUrl; } } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, normalizePlaceholders: function(/*String*/ p_url) { // summary: // Normalizes the hexadecimal digits within percent-encoding triplets // of placeholders found in federated documents services related Portal // URIs. The actual placeholder names remain unchanged, for example: // "%7btypeFilter%7d" ---rfc3986---> "%7BtypeFilter%7D" // p_url: // The URL containing the percent-encoding triplets "%7b" and "%7d" to // normalize // tags: // public // returns: // The URL with "%7b" and "%7d" changed to "%7B" and "%7D", respectively // entry trace var m = "normalizePlaceholders(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } var result = p_url.replace(/%7b/g, "%7B").replace(/%7d/g, "%7D"); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String } }); //*** global constants for all dijit instances *** // com.ibm.workplace.wcm.ecm.picker.util.URLUtils._: [const] [public] String // Singleton instance for the URLUtils helper com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE = new com.ibm.workplace.wcm.ecm.picker.util.URLUtils(); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.ServerConnectionPageWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.ServerConnectionPageWidget"] = true; /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.ServerConnectionPageWidget"); dojo.registerModulePath("com.ibm.workplace.wcm.ecm.picker.widget","../com/ibm/workplace/wcm/ecm/picker/widget"); dojo.require("dijit.form.TextBox"); dojo.require("dojo.string"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.widget.ServerConnectionPageWidget", [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget], { // summary: // This widget implements the user interface for selecting a federated documents repository // blankImgUrl: Object // URL pointing to a blank image (1x1 transparent pixel) blankImgUrl: dojo.moduleUrl("dojo", "resources/blank.gif").toString(), // namespace: [protected] String // The namespace this widget uses for building its user interface elements namespace: "srvConnPgWdgt_", // templatePath: // see dijit.Dialog templateString:"
\n
\n\n
\n \n
\n
\n
\n \n \n
\n
\n \"${_nlsUserInterface.srvConnPage.altTextInformation}\"\n ${_nlsMessages.srvConnPage.noServersMessage}\n
\n
\n
    \n
\n
\n
\n
\n
\n \n \n \n
\n \n
\n
\n
\n
\n
\n
\n

\n \n

\n
\n \n \n \n
\n \n
\n \n
\n
\n", // widgetsInTemplate: // see dijit.Dialog widgetsInTemplate: true, // _allOverrideAuthenticationDisabled: [private] Boolean // Indicates whether authentication is disabled and vault slots are defined // for all preconfigured services _allOverrideAuthenticationDisabled: false, // _authenticationInfoMsg: [private] String // Informative message being displayed in the Federated Documents Picker // describing the selected authentication method _authenticationInfoMsg: "", // _authProperties: [private] Object // JSON object which holds information about the authentication settings. // Objects of the same format are being used for passing in authentication information to the Picker dialog // and for receiving changed authentication settings back from the AuthenticationWidget when the user // made changes. // // Allowed Identifiers are: // authType: String // The type of authentication selected // username: String // The username for username/password authentication // password: String // The password for username/password authentication // vaultSlotID: String // The credential vault slot ID for credential vault based authentication // vaultSlotTitle: String // The title for the credential vault slot ID for credential vault based authentication _authProperties: null, // _authWidget: [private] Object // The instance of [com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget] that is displayed along with this widget _authWidget: null, // _authWidgetSection: [private] Object // An instance of [com.ibm.workplace.wcm.ecm.picker.widget.ExpandableSectionWidget] for managing the _authWidget _authWidgetSection: null, // _authWidgetSectionArguments: [private] Object // Internal variable to pass on computed authentication widget parameters from constructor to postCreate _authWidgetSectionArguments: null, // _availableAuthTypes: [private] Array // Array which holds string identifiers of authentication types that are available to the user to choose from _availableAuthTypes: [], // _callingEnvironment: [private] String // Identifier of the context the Federated Documents Picker is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management // (default) _callingEnvironment: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm, // _customServerSectionHeight: [private] Integer // The height of the custom server selection section _customServerSectionHeight: 0, // _customServiceSelectionEnabled: [private] Boolean // Defines whether custom server selection (i.e. selection of non-preconfigured // services) is supported _customServiceSelectionEnabled: true, // _documentsServices: [private] Array // An array of JSON objects holding properties of configured federated documents services that // a user can choose from _documentsServices: [], // _eventHandles: [private] Array // Array of handles created when connecting events to methods _eventHandles: [], // _feedType: [private] String // Feed type of the selected server. This value gets set by Picker Dialog code which // triggers the auto-detection _feedType: String, // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _isAuthWidgetInitialized: [private] Boolean // Indicates whether the authentication widget has already been initialized _isAuthWidgetInitialized: false, // _presetServerSectionHeight: [private] Integer // The height of the preset server selection section _presetServerSectionHeight: 0, // _selectedUrl: [private] String // Variable holding the last URL that was selected in either the custom URL text box or the // list of preset servers. Used to determine when we have to update the authentication // data _selectedUrl: "", // _selPresetServerIndex: [private] String // Index of the currently selected preset server in the list of preset servers. Needed to handle // moving selection up/down when pressing the arrow keys or page up/down _selPresetServerIndex: -1, _focusedPresetServerIndex: -1, _quickSearchText: "", // presetFocus and presetBlur events handling background: // // We need to have an onBlur event support on the presetServerList, but we don't have // that, since it's a custom widget. The events are needed for clearing the _quickSearchText when // leaving the listbox. What we can do is, putting onblur and onfocus event handlers on each // preset server list item. By keeping track of the count of each event, we can determine when // the list was left by the user, no matter, whether he used the TAB key or clicked somewhere else. // // When the user enters the list, we have one onfocus event, but no onblur event. When the user // changes selection within the list, by using the arrow keys or the mouse, we'll always have // one more onfocus than onblur event. Only when the user leaves the list, the number of onfocus // and onblur events will be equal again. // // So, each event (onfocus, onblur) on any of the preset server list items triggers a delayed // method which will check the values. If they are found to be equal, the _quickSearchTerm gets cleared // and the event counters reset. // _numPresetFocusEvts: [private] String // Number of times a preset server list item has received input focus _numPresetFocusEvts: 0, // _numPresetBlurEvts: [private] String // Number of times a preset server list item has lost input focus _numPresetBlurEvts: 0, // _focusBlurEvtCountTimer: [private] Integer // Timer handle for the function that checks the # of onfocus events against the # of onblur events _focusBlurEvtCountTimer: null, // _selPresetServerPageSize: [private] String // Number of preset server entries per page. When user presses page up/down, the focus will be moved // by this amount of entries _selPresetServerPageSize: 5, // _selPresetType: [private] String // Variable holding the type of the preset server that was selected. Defaults to // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis] _selPresetType: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis, // _selPresetURL: [private] String // Variable holding the last URL that was selected from the list with preset federated documents servers _selPresetURL: "", // _selServiceId: [private] String // Variable holding the ID of the selected documents service from the list with preset federated documents servers _selServiceId: "", // _startUpWasCalled: [private] Boolean // Helper variable making sure that we only call startup on the Server Connection Page once, // because calling it again, for example, when switching back from another page would overwrite // previous authentication settings _startUpWasCalled: false, // _urlChangesDelay: [private] Integer // Time in milliseconds between an onChange event from the URL text field and a call to // _processURLChanges method for updating vault Slot information _urlChangesDelay: 250, // _urlSelectionMode: [private] String // String reflecting the current server selection option, which is either "preset" or "custom" _urlSelectionMode: "preset", // _urlStore: [private] Object // Instance of a FileItemWriteStore which holds the preconfigured server URLs and is attached to // the URL combobox _urlStore: null, // _urlTextChangedTimerHandle: [private] Object // Handle of a timer that is being used to trigger code that runs whenever // text is being typed into the URL text field. Since the associated action makes // updates in the UI, we need to slightly delay it. _urlTextChangedTimerHandle: null, // _vaultSelectionEnabled: [private] Boolean // Specifies whether or not the selection of credential vault slots for authentication // is supported. // Unlike the properties _vaultSelectionEnabledForPZN and _vaultSelectionEnabledForWCM, // this setting (if given) already contains the vaultSelection setting based on the // current calling environment, which can be either PZN or WCM. // If set, this variable overrides the specific variables for WCM and PZN. _vaultSelectionEnabled: true, // _vaultSlotsAvailable: [private] Boolean // Indicates whether one or more vault slots are available. _vaultSlotsAvailable: false, buildRendering: function() { // summary: // Constructs the user interface of this widget // tags: // protected // entry trace var m = "buildRendering()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, constructor: function(/*Object*/ p_params) { // summary: // Constructs this widget // p_params: Object // The parameters to instantiate this widget with // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.authProperties:", dojo.toJson(p_params.authProperties)); this.trace(m, "p_params.availableAuthTypes:", dojo.toJson(p_params.availableAuthTypes)); this.trace(m, "p_params.callingEnvironment:", p_params.callingEnvironment); this.trace(m, "p_params.customServiceSelectionEnabled:", p_params.customServiceSelectionEnabled); this.trace(m, "p_params.documentsServices:", dojo.toJson(p_params.documentsServices)); this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.vaultSelectionEnabled:", p_params.vaultSelectionEnabled); this.trace(m, "p_params.vaultSelectionEnabledForPZN:", p_params.vaultSelectionEnabledForPZN); this.trace(m, "p_params.vaultSelectionEnabledForWCM:", p_params.vaultSelectionEnabledForWCM); this.trace(m, "p_params.vaultSlots:", dojo.toJson(p_params.vaultSlots)); } } // clear global arrays that we only push elements into, as opening multiple widget instances // might keep the array content from previous instances this._eventHandles = []; // determine the context this widget is used if (typeof p_params.callingEnvironment == 'string') { this._callingEnvironment = p_params.callingEnvironment; } // determine whether custom service selection is supported if (typeof p_params.customServiceSelectionEnabled == 'boolean') { this._customServiceSelectionEnabled = p_params.customServiceSelectionEnabled; } // namespace if (typeof p_params.namespace == 'string') { this.namespace = p_params.namespace; } this._vaultSlotsAvailable = (p_params.vaultSlots) && (p_params.vaultSlots.length > 0); // determine whether the credential vault selection is enabled if (typeof p_params.vaultSelectionEnabled == 'boolean') { this._vaultSelectionEnabled = p_params.vaultSelectionEnabled; } else { // if the parameter wasn't set explicitly, calculate it based on this._callingEnvironment // and the respective vaultSelectionEnabledForXxx setting if (this._isCalledFromWCM()) { // determine credential vault support for this environment var vaultSelectionEnabledForWCM = true; if (typeof p_params.vaultSelectionEnabledForWCM == 'boolean') { vaultSelectionEnabledForWCM = p_params.vaultSelectionEnabledForWCM; } // set the general credential vault support this._vaultSelectionEnabled = this._vaultSelectionEnabledForWCM; } else { if (this._isCalledFromPZN()) { // determine credential vault support for this environment var vaultSelectionEnabledForPZN = true; if (typeof p_params.vaultSelectionEnabledForPZN == 'boolean') { vaultSelectionEnabledForPZN = p_params.vaultSelectionEnabledForPZN; } // set the general credential vault support this._vaultSelectionEnabled = vaultSelectionEnabledForPZN; } else { // default to false for unknown calling environments this._vaultSelectionEnabled = false; } } } // trace if (this._isTracing) { this.trace(m, "Determined credential vault selection support setting:", this._vaultSelectionEnabled); } this._authProperties = { "authType": com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser }; // process the document services argument if (p_params.documentsServices && dojo.isArray(p_params.documentsServices)) { this._documentsServices = p_params.documentsServices; this._allOverrideAuthenticationDisabled = (this._documentsServices.length > 0); for (var i = 0; i < this._documentsServices.length; i++) { if (this._allOverrideAuthenticationDisabled) { if (this._documentsServices[i].vaultslot) { this._allOverrideAuthenticationDisabled = !this._documentsServices[i].overrideAuthentication; } else { this._allOverrideAuthenticationDisabled = false; } } this._documentsServices[i].decodedurl = decodeURIComponent(this._documentsServices[i].url); this._documentsServices[i].decodedvaultslot = decodeURIComponent(this._documentsServices[i].vaultslot); this._documentsServices[i].decodedtype = this._mapResEnvTypeToJsType(this._documentsServices[i].type); var itemname; if (this._documentsServices[i].title) { this._documentsServices[i].decodedTitle = decodeURIComponent(this._documentsServices[i].title); this._documentsServices[i].tooltip = this._documentsServices[i].decodedurl; } else { this._documentsServices[i].decodedTitle = this._documentsServices[i].decodedurl; this._documentsServices[i].tooltip = this._documentsServices[i].decodedurl; } } } this._availableAuthTypes = []; // process the available authentication types argument if (p_params.availableAuthTypes) { this._availableAuthTypes = p_params.availableAuthTypes; } else { this._availableAuthTypes = [ com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser ]; // only WCM supports selection of username/pwd if(this._isCalledFromWCM()) { this._availableAuthTypes.push(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd); } // add Credential Vault Auth Type, if vault selection is enabled if (this._vaultSelectionEnabled) { this._availableAuthTypes.push(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault); } } // compose the initialization JSON object for the authentication widget var authWidgetArguments = { "authProperties": this._authProperties, "availableAuthTypes": this._availableAuthTypes, "namespace": this.namespace, "nlsMessages": this._nlsMessages, "nlsUserInterface": this._nlsUserInterface, "onChangeAuthenticationMode": dojo.hitch(this, "_onAuthenticationChange"), "onErrorStateChanged": dojo.hitch(this, "_onAuthWidgetErrorStateChanged"), "vaultSlots": p_params.vaultSlots }; // initialize the internal authWidget instance for placing it into the dialog markup during buildRendering this._authWidget = new com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget(authWidgetArguments); // we need to initialize the auth Widget when the section it lives in is being expanded for the first // time. Defaults passed in to the constructor won't be visually reflected as long as the widget // is hidden. this._isAuthWidgetInitialized = false; // determine the authentication section height var authSectionHeight = this._calculateAuthSectionHeight(); // compose the initialization JSON object for the expandable section widget holding the authentication widget this._authWidgetSectionArguments = { "namespace": this.namespace, "nlsMessages": this._nlsMessages, "nlsUserInterface": this._nlsUserInterface, "onCollapsed": dojo.hitch(this, "_onAuthenticationSectionCollapsed"), "onExpanded": dojo.hitch(this, "_onAuthenticationSectionExpanded"), "openHeight": authSectionHeight, "openWidth": 20, // 350px = 20em "sectionID": "auth", "sectionTitleText": this._nlsUserInterface.srvConnPage.authWidgetSectionTitle, "visible": true, "widgetInstance": this._authWidget }; // initialize the localized strings that are consumed by the parent dialog var nlsStrings = this._nlsUserInterface.srvConnPage; this._stepLabel = nlsStrings.stepLabel; this._stepDescription = nlsStrings.stepDescription; this._startUpWasCalled = false; // exit trace if (this._isTracing) { this.traceExit(m); } }, destroy: function() { // summary: // Destroys this widget // tags: // protected // entry trace var m = "destroy()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, getSettings: function() { // summary: // Returns a JSON object holding the settings the user made using this widget // returns: // The user input captured by this widget // tags: // public // entry trace var m = "getSettings()"; if (this._isTracing) { this.traceEntry(m); } var authenticationProperties = this._authWidget.getAuthenticationProperties(); // only use the serviceId of a selected predefined server, if the connection // is actually made to the predefined server var serviceId; if (this._urlSelectionMode == "preset") { serviceId = this._selServiceId; } else { serviceId = ""; } var result = { "authProperties": authenticationProperties, //this._authProperties, "authInfoMsg": this._authenticationInfoMsg, "feedType": this._feedType, "serverUrl": this._getUrl(), "serverType": this._determineServerType(), "serviceId": serviceId }; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Object }, layout: function() { // summary: // See layout() method stub of [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget] // tags: // public // entry trace var m = "layout()"; if (this._isTracing) { this.traceEntry(m); } // get the custom server URL text field DIV element that is added by Dojo and encapsulates the input element var customUrlTextBoxDiv = dijit.byId(this.namespace + "customUrlTextBox_id").domNode; // get the available width from the parent element of the custom server URL text field DIV element; // Note: The subtracted pixels relate to the margin, padding, and border of the custom server URL text field var customUrlTextBoxWidth = dojo.contentBox(this.customServerSection).w - 20; // set the new width if (customUrlTextBoxWidth >= 0) { dojo.style(customUrlTextBoxDiv, 'width', customUrlTextBoxWidth + "px"); } // exit trace if (this._isTracing) { this.traceExit(m); } }, postCreate: function() { // summary: // Binds resources required by this widget after its DOM has been set up // tags: // protected // entry trace var m = "postCreate()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // initialize the expandable section widget holding the authentication widget this._authWidgetSection = new com.ibm.workplace.wcm.ecm.picker.widget.ExpandableSectionWidget(this._authWidgetSectionArguments); if (this._authWidgetSection && (this._customServiceSelectionEnabled || !this._allOverrideAuthenticationDisabled)) { this._authWidgetSection.placeAt(this.authSelectionSection); } this._presetServerSectionHeight = 22.5; this._customServerSectionHeight = 8; // show preset server section by default this._setPresetServerSectionVisible(true, false); // set visibility of custom server section if (this._customServiceSelectionEnabled) { // hide custom server section by default this._setCustomServerSectionVisible(false, false); } else { // hide custom server div incl. custom server section and // custom server radio button this._setCustomServerDivVisible(false); } this._buildPresetServerList(); // hide the authentication selector DIV, if no authentication types // are available if (this._availableAuthTypes.length === 0) { dojo.style(this.authSelectionSection, 'display', 'none'); dijit.setWaiState(this.authSelectionSection, 'hidden', true); } this._initEventHandles(); // exit trace if (this._isTracing) { this.traceExit(m); } }, setFeedType: function(/*String*/ p_feedType) { // summary: // Sets the internal _feedType variable, which holds the feedType of the currently // selected (active) server. Based on this type information, the picker decides // whether to use the Quickr or CMIS page. // p_feedType: String // The feed type of the server (cmis, qds, qdsentry, servicedoc, atom) // tags: // public // entry trace var m = "setFeedType(p_feedType)"; if (this._isTracing) { this.traceEntry(m, p_feedType); } this._feedType = p_feedType; // exit trace if (this._isTracing) { this.traceExit(m); } }, startup: function() { // summary: // Called when the creation of this widget is completed to perform operations that require this widget to be fully rendered // tags: // protected // entry trace var m = "startup()"; if (this._isTracing) { this.traceEntry(m); } if (!this._startUpWasCalled) { this._authWidget.startup(); this._authWidgetSection.startup(); // initally run the UI updates directly from the authProperties we also set on the AuthWidget // any further changes will be updated in the UI automatically by the AuthWidget this._onAuthenticationChange(this._authProperties); // select the first server in the preset list if (this._documentsServices.length > 0) { this._selectPresetServerListIndex(0); } this._startUpWasCalled = true; } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, uninitialize: function() { // summary: // Releases the resources bound by this widget before it is destroyed // tags: // protected // entry trace var m = "uninitialize()"; if (this._isTracing) { this.traceEntry(m); } this._clearEventHandles(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, _animateCloseSection: function(/*DomNode*/ p_domNode) { // summary: // Animates the closing of the section represented by the given DOM node // p_domNode: // The DOM node to hide in an animated manner // tags: // private // entry trace var m = "_animateCloseSection(p_domNode)"; if (this._isTracing) { this.traceEntry(m, p_domNode); } if (!dojo.hasClass(p_domNode, 'lotusHidden')) { dojo.style(p_domNode, 'overflow', 'hidden'); dojo.animateProperty({ "node": p_domNode, "duration": 800, "properties": { "height": { "end": 0, "units": "px" } }, "onEnd": dojo.hitch(this, function() { dojo.addClass(p_domNode, 'lotusHidden'); dijit.setWaiState(p_domNode, 'hidden', true); dijit.removeWaiState(p_domNode, 'expanded'); // make sure the modal dialog framework notices the change in height once the // animation has finished, that is the full required height is reached this._layoutChanged(); }) }).play(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _animateOpenSection: function(/*DomNode*/ p_domNode, /*Integer*/ p_targetHeight) { // summary: // Animates the opening of the section represented by the given DOM node // p_domNode: // The DOM node to show in an animated manner // p_targetHeight: // The eventual height of the section at the end of the animation // tags: // private // entry trace var m = "_animateOpenSection(p_domNode, p_targetHeight)"; if (this._isTracing) { this.traceEntry(m, [p_domNode, p_targetHeight]); } if (dojo.hasClass(p_domNode, 'lotusHidden')) { dojo.style(p_domNode, 'overflow', 'hidden'); dojo.marginBox(p_domNode, { h: "0ex" }); // required, otherwise px values would be interpreted as ex values by the animation, causing weird visual errors dojo.style(p_domNode, 'height', '0ex'); dojo.removeClass(p_domNode, 'lotusHidden'); dijit.setWaiState(p_domNode, 'hidden', false); dijit.setWaiState(p_domNode, 'expanded', true); dojo.animateProperty({ "node": p_domNode, "duration": 800, "properties": { "height": { "end": p_targetHeight, "units": "ex" } }, "onEnd": dojo.hitch(this, function() { dojo.marginBox(p_domNode, { h: p_targetHeight + "ex" }); // make sure the modal dialog framework notices the change in height once the // animation has finished, that is the full required height is reached this._layoutChanged(); }) }).play(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _buildAuthenticationInfoMsg: function(/*Object*/ p_authProps) { // summary: // Build a string that displays information about the authentication // method currently chosen to connect to a content repository // p_authProps: // JSON object which holds information about the authentication settings // tags: // private // entry trace var m = "_buildAuthenticationInfoMsg(p_authProps)"; if (this._isTracing) { this.traceEntry(m, dojo.toJson(p_authProps)); } if (p_authProps) { if (p_authProps.authType) { switch(p_authProps.authType) { case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault: this._authenticationInfoMsg = dojo.string.substitute(this._nlsUserInterface.srvConnPage.authInfoMsgVault, [p_authProps.vaultSlotID]); break; case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd: this._authenticationInfoMsg = this._nlsUserInterface.srvConnPage.authInfoMsgUserPwd; break; case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser: this._authenticationInfoMsg = this._nlsUserInterface.srvConnPage.authInfoMsgCurrentUser; break; default: this._authenticationInfoMsg = this._nlsUserInterface.srvConnPage.authInfoMsgUnknown; break; } } else { this._authenticationInfoMsg = ""; } } else { this._authenticationInfoMsg = ""; } // exit trace if (this._isTracing) { this.trace(m, "New authentication information message:", this._authenticationInfoMsg); this.traceExit(m); } }, _countEventsTimerFn: function() { // summary: // Compares onfocus and onblur event count against each other and clears _quickSearchText, if // a blur on the presetServerList was detected if (this._numPresetBlurEvts == this._numPresetFocusEvts) { // onblur on the preset Server list condition detected this._quickSearchText = ""; this._numPresetBlurEvts = 0; this._numPresetFocusEvts = 0; } }, _buildPresetServerList: function() { // summary: // Constructs the list of preset federated documents servers the user can // choose from // tags: // private // entry trace var m = "_buildPresetServerList()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Preset document services:", this._documentsServices); } if (this._documentsServices) { for (var i = 0; i < this._documentsServices.length; i++) { var li = dojo.create("li", { "id": this.namespace + "_presetServer_" + i + "_item_id", "name": this.namespace + "_presetServer_" + i + "_item", "title": this._documentsServices[i].tooltip }, this.presetServersList); var span = dojo.create("span", { "id": this.namespace + "_presetServer_" + i + "_item_text_id", "name": this.namespace + "_presetServer_" + i + "_item_text", "innerHTML": this._documentsServices[i].decodedTitle, "tabindex": (i === 0) ? "0" : "-1" }, li); // make sure that screenreaders won't read the URL dijit.setWaiState(span, 'label', this._documentsServices[i].decodedTitle); dojo.place(li, this.presetServersList, "last"); dojo.place(span, li, "last"); dijit.setWaiRole(span, 'option'); dijit.setWaiState(span, 'selected', false); dijit.setWaiState(span, 'posinset', (i + 1)); dijit.setWaiState(span, 'setsize', this._documentsServices.length); // store reference of the domNode, so we can control item selection / deselection from // js code more easily this._documentsServices[i].domNode = li; // focus is being put onto the text span instead, so users can actually see the focus rect this._documentsServices[i].focusNode = span; this._eventHandles.push(dojo.connect( li, "onclick", dojo.hitch(this, function(i) { this._deselectPresetServerItem(); this._selectPresetServerItem(i); }, i))); this._eventHandles.push(dojo.connect( li, "onmouseover", dojo.hitch(this, function(i) { this._setHoverHighlightItem(i, true); }, i))); this._eventHandles.push(dojo.connect( li, "onmouseout", dojo.hitch(this, function(i) { this._setHoverHighlightItem(i, false); }, i))); this._eventHandles.push(dojo.connect( span, "onblur", dojo.hitch(this, function(i) { this._numPresetBlurEvts++; clearTimeout(this._focusBlurEvtCountTimer); this._focusBlurEvtCountTimer = setTimeout(dojo.hitch(this, "_countEventsTimerFn"), 20); }, i))); this._eventHandles.push(dojo.connect( span, "onfocus", dojo.hitch(this, function(i) { this._numPresetFocusEvts++; clearTimeout(this._focusBlurEvtCountTimer); }, i))); } } if (!this._documentsServices || (this._documentsServices.length === 0)) { this._presetServerSectionHeight = 8; this._showNoServersMessage(); } else { dijit.setWaiRole(this.presetServersList, 'listbox'); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _calculateAuthSectionHeight: function() { // summary: // Calculates the required height value for the Authentication Section in expanded // state // returns: // The height of the authentication section // tags: // private // entry trace var m = "_calculateAuthSectionHeight()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Available authentication types:", this._availableAuthTypes); } // iterate over the _availableAuthTypes array and add appropriate height values to // determine the actual section height // TODO: section height should either be set in points rather than pixels or we should // allow section to be autosized to accomodate for different font sizes var hv = 0; for (var i = 0; i < this._availableAuthTypes.length; i++) { switch(this._availableAuthTypes[i]) { case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault: if (this._vaultSlotsAvailable) { hv += 12; // ex units } break; case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd: hv += 19; // ex units break; case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser: hv += 3.5; // ex units break; default: // should never happen break; } } // exit trace if (this._isTracing) { this.traceExit(m, hv); } return hv; // Integer }, _clearEventHandles: function() { // summary: // Disconnects the events supported by this dialog from the corresponding callback methods // tags: // private // entry trace var m = "_clearEventHandles()"; if (this._isTracing) { this.traceEntry(m); } // disconnect the callbacks from their related events dojo.forEach(this._eventHandles, dojo.disconnect); this._eventHandles = []; // exit trace if (this._isTracing) { this.traceExit(m); } }, _unfocusPresetServerItem: function() { if (this._documentsServices) { if ((this._focusedPresetServerIndex >= 0) && (this._focusedPresetServerIndex < this._documentsServices.length)) { var ds = this._documentsServices[this._focusedPresetServerIndex]; if (ds) { if (ds.domNode) { dojo.attr(ds.focusNode, "tabindex", "-1"); this._focusedPresetServerIndex = -1; } } } } }, _deselectPresetServerItem: function() { // summary: // Removes the selection of a preset federated documents server // tags: // private // entry trace var m = "_deselectPresetServerItem()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Preset document services:", this._documentsServices); } if (this._documentsServices) { for (var i = 0; i < this._documentsServices.length; i++) { var ds = this._documentsServices[i]; if (ds.domNode) { if (dojo.hasClass(ds.domNode, 'lotusSelected')) { dojo.removeClass(ds.domNode, 'lotusSelected'); dijit.setWaiState(ds.focusNode, 'selected', false); // reset preselection data this._selPresetURL = ""; this._selPresetType = null; //com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis; this._selServiceId = ""; // set tabindex to -1 for this item dojo.attr(ds.focusNode, "tabindex", "-1"); this._selPresetServerIndex = -1; break; // we support single selection only, so no need to look any further } } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _determineReadyState: function() { // summary: // Checks whether this widget is ready in terms of allowing the user to proceed to the // next step of the wizard // tags: // private // entry trace var m = "_determineReadyState()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current authentication settings:", this._authProperties); } var authReady = false; var authProps = this._authWidget.getAuthenticationProperties(); if (authProps) { if (authProps.authType) { switch(authProps.authType) { case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault: authReady = (authProps.vaultSlotID !== ""); break; case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeNoAuth: authReady = true; break; case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd: authReady = true; break; case com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser: authReady = true; break; default: authReady = false; break; } } } // trace if (this._isTracing) { this.trace(m, "New authentication ready state:", authReady); this.trace(m, "Selected URL", this._getUrl()); } this._setReadyValue((this._getUrl() !== "") && authReady); // exit trace if (this._isTracing) { this.traceExit(m); } }, _determineServerType: function() { // summary: // Returns the feed type based on the settings of the predefined federated // documents services or an actual feed type detection that may have been // performed earlier. // Returns null if the feed type has not been predefined or detected earlier. // returns: // A string containing the server type, which is either // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis or // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds, or // null. // tags: // private // entry trace var m = "_determineServerType()"; if (this._isTracing) { this.traceEntry(m); } var result; if (this._feedType !== null) { // When user presses Next on the first page, this._feedType will be set to // either a quickr value (for predefined quickr servers) or the value that the // autodetection code returned. Now, when the user presses Finish at a later point // in time, this method is being called to attach the server type to the // returned URL. Therefore, once a _feedType was set, we need to return that value. // As long as _feedType is null, we run alternative code to return basic information // for predefined servers only (cmis vs. qds) result = this._feedType; } else if (this._urlSelectionMode == "preset") { // for predefined servers, we can simply grab the information from the // configuration data. result = this._selPresetType; } else { result = null; } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; }, _enableAuthSection: function(/*Boolean*/ isAuthEnabled) { // summary: // Enables / disables the authentication selection section. // isAuthEnabled: // true to enable the section // false to disable the section // tags: // private // entry trace var m = "_enableAuthSection()"; if (this._isTracing) { this.traceEntry(m, isAuthEnabled); } if (isAuthEnabled) { dojo.style(this.authSelectionSection, "display", "block"); dojo.removeClass(this.fedDocPickerAuthInfo, "lotusInactive"); } else { dojo.style(this.authSelectionSection, "display", "none"); dojo.addClass(this.fedDocPickerAuthInfo, "lotusInactive"); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _getConfiguredDocumentsService: function(/*String*/ p_url) { // summary: // Check the preset federated documents services for the given URL. // If a match is found, returns the index into the federated // documents services array for this entry. // Returns -1, if no match was found // p_url: // The URL of a federated documents server to check // returns: // The index of the service document in the federated documents // services array. -1, if no match was found. // tags: // private // entry trace var m = "_getConfiguredDocumentsService(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); this.trace(m, "Preset document services:", this._documentsServices); } // return -1 if nothing else applies var result = -1; for (var i = 0; i < this._documentsServices.length; i++) { if (p_url == this._documentsServices[i].decodedurl) { result = i; } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // integer }, _getUrl: function() { // summary: // Returns the URL of the federated documents server currently selected // returns: // The selected federated documents server URL // tags: // private // entry trace var m = "_getUrl()"; if (this._isTracing) { this.traceEntry(m); } // determine which URL to use: either the stored preset URL that was selected or // the custom one entered in the text box var value; if (this._urlSelectionMode == "preset") { value = this._selPresetURL; } else { value = this.customUrlTextBox.attr('value'); } if (this._isTracing) { this.trace(m, "Currently selected URL:", value); } // extract URL from the value, which either is a // literal URL entered by the user // or a string created by postCreate including both // the title and url var url; var urlparts = value.match("https?://.*"); if (urlparts && urlparts.length > 0) { url = dojo.trim(urlparts[0]); } else { // user entered plain URL url = dojo.trim(value); } // exit trace if (this._isTracing) { this.traceExit(m, url); } return url; // String }, _initEventHandles: function() { // summary: // Connects the events supported by this widget to the corresponding callback methods // and stores the handles in the _eventHandles array // tags: // private // entry trace var m = "_initEventHandles()"; if (this._isTracing) { this.traceEntry(m); } this._eventHandles.push(dojo.connect( this.presetServersList, "onkeypress", dojo.hitch(this, "_onPresetServerKeyPressed"))); this._eventHandles.push(dojo.connect( this.customUrlTextBox, "onChange", dojo.hitch(this, "_onUrlTextBoxChanged"))); this._eventHandles.push(dojo.connect( this.presetServerRadioButton, "onClick", dojo.hitch(this, "_onClickPresetServerButton"))); this._eventHandles.push(dojo.connect( this.customServerRadioButton, "onClick", dojo.hitch(this, "_onClickCustomServerButton"))); this._eventHandles.push(dojo.connect( this.serverConnectionPageForm, "onsubmit", dojo.hitch(this, "_onSubmit"))); // exit trace if (this._isTracing) { this.traceExit(m); } }, _isCalledFromPZN: function() { // summary: // Returns an indication as to whether this widget is rendered in the context of Personalization // returns: // true if the rendering context is Personalization, false otherwise // tags: // private // entry trace var m = "_isCalledFromPZN()"; if (this._isTracing) { this.traceEntry(m); } var result = this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _isCalledFromWCM: function() { // summary: // Returns an indication as to whether this widget is rendered in the context of Web Content Management // returns: // true if the rendering context is Web Content Management, false otherwise // tags: // private // entry trace var m = "_isCalledFromWCM()"; if (this._isTracing) { this.traceEntry(m); } var result = this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _mapResEnvTypeToJsType: function(/*String*/ p_serverType) { // summary: // Maps a given serverType string as defined in the Resource Environment provider to an internal // javascript code type constant // p_serverType: String // One of the following strings: 'CMIS', 'DocumentServices', 'ATOM', see // com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeXxx constants in // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions] // returns: // One of the following strings, if the input string could be mapped to a known (supported) // format, or com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis as the // default value for all unknown or unsupported input values. // tags: // private // entry trace var m = "_mapResEnvTypeToJsType(p_serverType)"; if (this._isTracing) { this.traceEntry(m, p_serverType); } var result = ""; if (typeof p_serverType == 'string') { switch(p_serverType) { case com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeCMIS: result = com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis; break; case com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions.resEnvTypeQDS: result = com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds; break; default: result = com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis; break; } } else { result = com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis; } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; }, _focusPresetServerListIndex: function(/*Integer*/ p_newIndex) { var _newIndex = p_newIndex; if (_newIndex < 0) { _newIndex = 0; } if (_newIndex > this._documentsServices.length - 1) { _newIndex = this._documentsServices.length - 1; } this._unfocusPresetServerItem(); this._focusPresetServerItem(_newIndex); }, _selectPresetServerListIndex: function(/*Integer*/ p_newIndex) { // summary: // Selects the preset server item from the list of preset servers identified by the // given p_newIndex parameter. If the index parameter exceeds the number of available // items, the index will be corrected to the next valid value (indexes below 0 will be // corrected to 0, indexes exceeding the number of entries in the list, will be corrected // to the maximum index (last entry of the list)) // p_newIndex: Integer // The index in the list of preset servers that should be selected. Is allowed to exceed // the list, but will be corrected in that case. // tags: // private // entry trace var m = "_selectPresetServerListIndex(p_newIndex)"; if (this._isTracing) { this.traceEntry(m, p_newIndex); } var _newIndex = p_newIndex; if (_newIndex < 0) { _newIndex = 0; } if (_newIndex > this._documentsServices.length - 1) { _newIndex = this._documentsServices.length - 1; } this._deselectPresetServerItem(); this._selectPresetServerItem(_newIndex); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onAuthWidgetErrorStateChanged: function(/*Object*/ p_sender, /*Boolean*/ p_errorState, /*String*/ p_errorMsg, /*String?*/ p_errorDetails) { // summary: // Callback function triggered by the Authentication widget // if it changed into an error state or changed back from // an error state. Used to report error/no error conditions // up the chain (have to use another name, as _onErrorStateChanged is already // the pointer back to the callback function of the dialog) // p_sender: Object // The widget instance sending this error to this dialog. // p_errorState: Boolean // The flag indicating whether the calling widget went into error state, or whether the // error state was left. // p_errorMsg: String // The error message to display // p_errorDetails: String // Optional string with a more detailed description of the error // tags: // private callback var m = "_onAuthWidgetErrorStateChanged(p_sender, p_errorState, p_errorMsg, p_errorDetails)"; if (this._isTracing) { this.traceEntry(m, [p_sender, p_errorState, p_errorMsg, p_errorDetails]); } if (p_errorState === true) { this._showError(p_errorMsg, p_errorDetails); } else { if (p_errorState === false) { this._clearError(); } else { // p_errorState is not a Boolean value } } if (this._isTracing) { this.traceExit(m); } }, _doSearchServerItem: function(/*Integer*/ fromIdx) { if (fromIdx < 0) { fromIdx = 0; } if (fromIdx > this._documentsServices.length - 1) { // wrap around search fromIdx = 0; } idx = fromIdx; var svc; // search documents list size - 1, because we don't need to match the entry we're coming from, since the selection // would stay on it anyway, if we cannot find another entry for (var i = 0; i < this._documentsServices.length; i++) { svc = this._documentsServices[idx]; if (svc.decodedTitle && svc.decodedTitle.toUpperCase().indexOf(this._quickSearchText) === 0) { // found matching entry, so select it and break this._selectPresetServerListIndex(idx); break; } idx++; if (idx > this._documentsServices.length - 1) { // wrap around search idx = 0; } } }, _searchNextServerItem: function() { this._doSearchServerItem(this._selPresetServerIndex + 1); }, _searchServerItem: function() { this._doSearchServerItem(0); }, _onPresetServerKeyPressed: function(/*Event*/ p_evt) { // summary: // Event handler triggered, when a key was pressed within the Preset Server Selection list // p_evt: Event // The key event that caused the submit method to be called // tags: // private callback // entry trace var m = "_onPresetServerKeyPressed(p_evt)"; if (this._isTracing) { this.traceEntry(m, [p_evt]); } // only allow space key to act as selection key, when there's no quick search in progress if ((p_evt.charCode == dojo.keys.SPACE) && (this._quickSearchText === "")) { dojo.stopEvent(p_evt); this._selectPresetServerListIndex(this._focusedPresetServerIndex); } if (p_evt.charCode && (!p_evt.ctrlKey) && String.fromCharCode) { var character = String.fromCharCode(p_evt.charCode); if (character) { character = character.toUpperCase(); } if ((this._quickSearchText.length == 1) && (character == this._quickSearchText)) { this._searchNextServerItem(); } else { this._quickSearchText = this._quickSearchText + character; this._searchServerItem(); } } if (p_evt.keyCode) { var node = p_evt.target; switch(p_evt.keyCode) { case dojo.keys.UP_ARROW: dojo.stopEvent(p_evt); this._quickSearchText = ""; if (p_evt.ctrlKey) { this._focusPresetServerListIndex(this._focusedPresetServerIndex - 1); } else { this._selectPresetServerListIndex(this._focusedPresetServerIndex - 1); } break; case dojo.keys.DOWN_ARROW: dojo.stopEvent(p_evt); this._quickSearchText = ""; if (p_evt.ctrlKey) { this._focusPresetServerListIndex(this._focusedPresetServerIndex + 1); } else { this._selectPresetServerListIndex(this._focusedPresetServerIndex + 1); } break; case dojo.keys.PAGE_UP: dojo.stopEvent(p_evt); this._quickSearchText = ""; if (p_evt.ctrlKey) { this._focusPresetServerListIndex(this._focusedPresetServerIndex - this._selPresetServerPageSize); } else { this._selectPresetServerListIndex(this._focusedPresetServerIndex - this._selPresetServerPageSize); } break; case dojo.keys.PAGE_DOWN: dojo.stopEvent(p_evt); this._quickSearchText = ""; if (p_evt.ctrlKey) { this._focusPresetServerListIndex(this._focusedPresetServerIndex + this._selPresetServerPageSize); } else { this._selectPresetServerListIndex(this._focusedPresetServerIndex + this._selPresetServerPageSize); } break; case dojo.keys.HOME: dojo.stopEvent(p_evt); this._quickSearchText = ""; if (p_evt.ctrlKey) { this._focusPresetServerListIndex(0); } else { this._selectPresetServerListIndex(0); } break; case dojo.keys.END: dojo.stopEvent(p_evt); this._quickSearchText = ""; if (p_evt.ctrlKey) { this._focusPresetServerListIndex(this._documentsServices.length - 1); } else { this._selectPresetServerListIndex(this._documentsServices.length - 1); } break; case dojo.keys.ENTER: // trigger default action, if Enter is pressed // make sure focusedIdx and selIdx are the same, if not, put focus back on // the selected entry this._quickSearchText = ""; if (this._focusedPresetServerIndex != this._selPresetServerIndex) { this._focusPresetServerListIndex(this._selPresetServerIndex); } this._onSubmit(p_evt); break; default: break; } } // exit trace if (this._isTracing) { this.traceExit(m, false); } }, _onSubmit: function(/*Event*/ p_evt) { // summary: // Callback that is triggered, when one of the submit buttons (BACK, NEXT, FINISH) // is clicked, or if ENTER is pressed. // p_evt: Event // The event that caused the submit method to be called // returns: Boolean // Always returns false, to cancel the default submit action (which would // reload the page) // tags: // private callback // entry trace var m = "_onSubmit(p_evt)"; if (this._isTracing) { this.traceEntry(m, [p_evt]); } dojo.stopEvent(p_evt); if (this._onDefaultAction && dojo.isFunction(this._onDefaultAction)) { this._onDefaultAction(); } // exit trace if (this._isTracing) { this.traceExit(m, false); } // prevent browser to actually submit a form (would cause a page refresh) return false; // Boolean }, _setAuthTypeForPresetServer: function() { // summary: // Updates the authentication type to 'Credential Vault' and sets the credential vault ID // if a credential vault slot is configured for the selected preset server // tags: // private // entry trace var m = "_setAuthTypeForPresetServer()"; if (this._isTracing) { this.traceEntry(m); } // assuming that _getUrl() returns the value of the preset server here var url = this._getUrl(); var isAuthDisabled = false; var vaultSlotID = ""; var vaultSlotIDAvailable = false; var overrideAuthentication = true; var i = this._getConfiguredDocumentsService(url); if (i>=0) { vaultSlotID = this._documentsServices[i].decodedvaultslot; vaultSlotIDAvailable = this._authWidget.isVaultSlotAvailable(vaultSlotID); overrideAuthentication = this._documentsServices[i].overrideAuthentication.toLowerCase() != "false"; } if ((vaultSlotID) && (vaultSlotID != 'undefined') && (vaultSlotID !== "")) { if (vaultSlotIDAvailable) { // auto change authType to Credential Vault this._authWidget.changeAuthType(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault); this._clearError(); isAuthDisabled = !overrideAuthentication; } else { // auto change authType to Current User, if an invalid vault slot was predefined this._authWidget.changeAuthType(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser); this._showError(dojo.string.substitute(this._nlsMessages.srvConnPage.errorVaultSlotMissing, [vaultSlotID])); } } else { // auto change authType to Current User, if no vaultSlotID was found this._authWidget.changeAuthType(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser); this._clearError(); } if (((vaultSlotID) && (vaultSlotID != this._authProperties.vaultSlotID)) && (vaultSlotIDAvailable)) { this._authProperties.vaultSlotID = vaultSlotID; this._authWidget.setAuthenticationProperties({ authProperties: this._authProperties }); } if (isAuthDisabled) { this._enableAuthSection(false); } else { this._enableAuthSection(true); } this._determineReadyState(); // make sure the modal dialog framework notices the change in height if another predefined // documents service with different authentication settings is selected this._layoutChanged(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setHoverHighlightItem: function(/*Integer*/ p_dsIndex, /*Boolean*/ p_isHover) { // summary: // Adds or removes a hovering CSS class to the given preset server item, based // on the value of p_isHover // p_dsIndex: Integer // Index to the item in the preset server list that needs to get/loose // hover state // p_isHover: Boolean // If true, hover style class will be added to the item, otherwise it is being removed // tags: // private // entry trace var m = "_setHoverHighlightItem(p_dsIndex, p_isHover)"; if (this._isTracing) { this.traceEntry(m, [p_dsIndex, p_isHover]); this.trace(m, "Preset document services:", this._documentsServices); } if (this._documentsServices) { var ds = this._documentsServices[p_dsIndex]; if (ds) { if (ds.domNode) { if (p_isHover) { // only add class, if this item is not also selected if (!dojo.hasClass(ds.domNode, 'lotusSelected')) { dojo.addClass(ds.domNode, 'feddocServerItemHover'); } } else { dojo.removeClass(ds.domNode, 'feddocServerItemHover'); } } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _focusPresetServerItem: function(/*Integer*/ p_dsIndex) { // summary: // Puts just the focus on the given preset server item, but does not select it if (this._documentsServices) { var ds = this._documentsServices[p_dsIndex]; if (ds) { if (ds.domNode) { // make this item the one focus is being put on when tabbing dojo.attr(ds.focusNode, "tabindex", "0"); dijit.focus(ds.focusNode); this._focusedPresetServerIndex = p_dsIndex; } } } }, _selectPresetServerItem: function(/*Integer*/ p_dsIndex) { // summary: // Sets the preset server to the new selection and updates the authentication method // according to the configuration of the selected server // p_dsIndex: // The index of the selected preset federated documents server from the server list // tags: // private // entry trace var m = "_selectPresetServerItem(p_dsIndex)"; if (this._isTracing) { this.traceEntry(m, [p_dsIndex]); this.trace(m, "Preset document services:", this._documentsServices); } if (this._documentsServices) { var ds = this._documentsServices[p_dsIndex]; if (ds) { if (ds.domNode) { dojo.addClass(ds.domNode, 'lotusSelected'); dijit.setWaiState(ds.focusNode, 'selected', true); // remove hover class, so that hover color doesn't overlay the selection color dojo.removeClass(ds.domNode, 'feddocServerItemHover'); // make this item the one focus is being put on when tabbing dojo.attr(ds.focusNode, "tabindex", "0"); dijit.focus(ds.focusNode); this._selPresetURL = ds.decodedurl; this._selPresetServerIndex = p_dsIndex; this._focusedPresetServerIndex = p_dsIndex; if (ds.decodedtype) { if ((ds.decodedtype == com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis) || (ds.decodedtype == com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds)) { this._selPresetType = ds.decodedtype; } else { // for unknown types, default to type CMIS this._selPresetType = com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis; } } else { // if not set at all, default to type CMIS this._selPresetType = com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis; } this._selServiceId = ds.serviceId; // trigger all the UI updates related to a URL change this._setAuthTypeForPresetServer(); } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onAuthenticationChange: function(/*Object*/ p_authProps) { // summary: // Callback method that is triggered when the authentication selection // in the child authentication widget changes (i.e., other authType selected, // or parameters for authType were changed). // Used for updating the authentication type information displayed by this widget // p_authProps: // JSON object which holds information about the authentication settings // tags: // private callback // entry trace var m = "_onAuthenticationChange(p_authProps)"; if (this._isTracing) { this.traceEntry(m, dojo.toJson(p_authProps)); } // update the FederatedDocPicker version of the authProperties object with new data this._authProperties = dojo.clone(p_authProps); this._buildAuthenticationInfoMsg(p_authProps); this._updateAuthenticationInfoMsg(); this._determineReadyState(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onAuthenticationSectionCollapsed: function() { // summary: // Callback method that is triggered when the authentication method section collapsed // tags: // private callback // entry trace var m = "_onAuthenticationSectionCollapsed()"; if (this._isTracing) { this.traceEntry(m); } this._layoutChanged(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onAuthenticationSectionExpanded: function() { // summary: // Callback method that is triggered when the authentication method section fully // expanded. Used to set the current security setting in the authentication widget // tags: // private callback // entry trace var m = "_onAuthenticationSectionExpanded()"; if (this._isTracing) { this.traceEntry(m); } // make sure to run this code only once, as otherwise, user-made settings will be overwritten by the // defaults again, if the auth section is being opened/closed multiple times if (!this._isAuthWidgetInitialized) { this._authWidget.setAuthenticationProperties({ "authProperties": this._authProperties }); this._isAuthWidgetInitialized = true; } this._layoutChanged(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onAuthPropertiesChanged: function(/*Object*/ p_authProperties) { // summary: // Callback method that is triggered by the authentication widget instance to pass // the current authentication settings // p_authProperties: // JSON object which holds information about the authentication settings // tags: // private callback // entry trace var m = "_onAuthPropertiesChanged(p_authProperties)"; if (this._isTracing) { this.traceEntry(m, dojo.toJson(p_authProperties)); } // handle changes to the credential vault slot ID if (p_authProperties) { if (p_authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault) { this._authProperties.vaultSlotID = p_authProperties.vaultSlotID; } } // exit trace if (this._isTracing) { this.traceEntry(m, "New credential vault slot ID:", this._authProperties.vaultSlotID); this.traceExit(m); } }, _onClickCustomServerButton: function() { // summary: // Callback method that is triggered when the user selects the custom server input option // tags: // private callback // entry trace var m = "_onClickCustomServerButton()"; if (this._isTracing) { this.traceEntry(m); } this._setPresetServerSectionVisible(false, true); this._setCustomServerSectionVisible(true, true); this._urlSelectionMode = "custom"; this._enableAuthSection(true); // set authType to Current User by default this._authWidget.changeAuthType(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser); this._clearError(); this._determineReadyState(); this.layout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onClickPresetServerButton: function() { // summary: // Callback method that is triggered when the user selects the preset server input option // tags: // private callback // entry trace var m = "_onClickPresetServerButton()"; if (this._isTracing) { this.traceEntry(m); } this._setPresetServerSectionVisible(true, true); this._setCustomServerSectionVisible(false, true); this._urlSelectionMode = "preset"; this._setAuthTypeForPresetServer(); // calls determineReadyState() already, so no need to call it again this.presetServerRadioButton.focus(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onUrlTextBoxChanged: function() { // summary: // Callback method that is triggered when the user changes the text in the custom server // input field // tags: // private callback // entry trace var m = "_onUrlTextBoxChanged()"; if (this._isTracing) { this.traceEntry(m); } this._clearError(); clearTimeout(this._urlTextChangedTimerHandle); this._urlTextChangedTimerHandle = setTimeout(dojo.hitch(this, "_determineReadyState"), this._urlChangesDelay); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setCustomServerDivVisible: function(/*Boolean*/ p_isVisible) { // summary: // Changes the visibility of the custom server div // p_isVisible: // Indicates whether the custom server section is to be shown // tags: // private // entry trace var m = "_setCustomServerDivVisible(p_isVisible)"; if (this._isTracing) { this.traceEntry(m, p_isVisible); } this._setSectionVisible(this.customServerDiv, p_isVisible, false, 0); // exit trace if (this._isTracing) { this.traceExit(m); } }, /* TODO: Important: need to add some more logic to allow closing or opening animations to be stopped in the middle and running the reverse animation, in case the user rapidly clicks on the various radiobuttons. Otherwise the section would probably be in a wrong state, not reflecting the radiobutton */ _setCustomServerSectionVisible: function(/*Boolean*/ p_isVisible, /*Boolean*/ p_animate) { // summary: // Changes the visibility of the custom server section // p_isVisible: // Indicates whether the custom server section is to be shown // p_animate: // Indicates whether a change of the visibility is animated // tags: // private // entry trace var m = "_setCustomServerSectionVisible(p_isVisible, p_animate)"; if (this._isTracing) { this.traceEntry(m, [ p_isVisible, p_animate ]); } this._setSectionVisible(this.customServerSection, p_isVisible, p_animate, this._customServerSectionHeight); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setPresetServerSectionVisible: function(/*Boolean*/ p_isVisible, /*Boolean*/ p_animate) { // summary: // Changes the visibility of the preset servers section // p_isVisible: // Indicates whether the custom server section is to be shown // p_animate: // Indicates whether a change of the visibility is animated // tags: // private // entry trace var m = "_setPresetServerSectionVisible(p_isVisible, p_animate)"; if (this._isTracing) { this.traceEntry(m, [ p_isVisible, p_animate ]); } this._setSectionVisible(this.presetServerSection, p_isVisible, p_animate, this._presetServerSectionHeight); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setSectionVisible: function(/*DomNode*/ p_sectionDomNode, /*Boolean*/ p_isVisible, /*Boolean*/ p_animate, /*Integer?*/ p_targetHeight) { // summary: // Changes the visibility of the section represented by the given DOM node // p_domNode: // The DOM node to hide or show // p_isVisible: // Indicates whether the section is to be shown // p_animate: // Indicates whether a change of the visibility is animated // p_targetHeight: // The eventual height of the section at the end of the animation // tags: // private // entry trace var m = "_setSectionVisible(p_sectionDomNode, p_isVisible, p_animate, p_targetHeight)"; if (this._isTracing) { this.traceEntry(m, [ p_sectionDomNode, p_isVisible, p_animate, p_targetHeight ]); } if ((p_animate) && (p_animate === true)) { if (p_isVisible === true) { this._animateOpenSection(p_sectionDomNode, p_targetHeight); } else { this._animateCloseSection(p_sectionDomNode); } } else { // non-animated update of element this._setVisible(p_sectionDomNode, p_isVisible); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _setVisible: function(/*DomNode*/ p_domNode, /*Boolean*/ p_isVisible) { // summary: // Changes the visibility of the section represented by the given DOM node // p_domNode: // The DOM node to hide or show // p_isVisible: // Indicates whether the section is to be shown // tags: // private // entry trace var m = "_setVisible(p_domNode, p_isVisible)"; if (this._isTracing) { this.traceEntry(m, [ p_domNode, p_isVisible ]); } if (p_isVisible === true) { if (dojo.hasClass(p_domNode, 'lotusHidden')) { dojo.removeClass(p_domNode, 'lotusHidden'); } dijit.setWaiState(p_domNode, 'hidden', false); dijit.setWaiState(p_domNode, 'expanded', true); } else { if (!dojo.hasClass(p_domNode, 'lotusHidden')) { dojo.addClass(p_domNode, 'lotusHidden'); } dijit.setWaiState(p_domNode, 'hidden', true); dijit.removeWaiState(p_domNode, 'expanded'); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _showNoServersMessage: function() { // summary: // Changes the visibility of the section represented by the given DOM node // tags: // private // entry trace var m = "_showNoServersMessage()"; if (this._isTracing) { this.traceEntry(m); } dojo.style(this.presetServersListDiv, 'display', 'none'); dojo.style(this.fedDocNoServersInfoDiv, 'display', 'block'); // exit trace if (this._isTracing) { this.traceExit(m); } }, _updateAuthenticationInfoMsg: function() { // summary: // Updates the informative message being displayed in the Federated Documents Picker // describing the selected authentication method // tags: // private // entry trace var m = "_updateAuthenticationInfoMsg()"; if (this._isTracing) { this.traceEntry(m); } // replace innerHTML of "fedDocPickerAuthInfo" dojo.attr(this.fedDocPickerAuthInfo, "innerHTML", this._authenticationInfoMsg); // exit trace if (this._isTracing) { this.traceExit(m); } } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter"); dojo.require("com.ibm.widgets._Traceable"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter", [com.ibm.widgets._Traceable], { // summary: // A class that basically just provides a callback method, which // can be used by a TreeModel to test whether an item should be // returned to the Tree widget for displaying it or not. // By assigning a filter instance to another filter instance, // a filter chain can be established. // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _itemFilter: [private] Object // [com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter] instance. // If set a non-null value, isItemAcceptable() of this filter will also ask the // chained filter instance, whether the item is acceptable. _itemFilter: null, constructor: function(/*Object*/ p_params) { // summary: // Constructs this filter with the given JSON object // p_params: Object // The arguments for initializing this filter // tags: // public // nothing here, see concrete implementations }, isItemAcceptable: function(/*Item*/ p_item, /*Object*/ p_store) { // summary: // Abstract method, needs to be implemented by implementation // classes. Needs to return 'true' if the given item is acceptable, // 'false' otherwise // p_item: item // Store item to be checked for acceptance. p_item needs to be // an item that is available in p_store. // p_store: Object // An instance of [com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore] // returns: // true if the given item is acceptable for this filter, false otherwise // tags: // protected // nothing here, see concrete implementations } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.filter.LibFolderTreeItemFilter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.filter.LibFolderTreeItemFilter"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.filter.LibFolderTreeItemFilter"); dojo.declare( "com.ibm.workplace.wcm.ecm.picker.widget.filter.LibFolderTreeItemFilter", [ com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter ], { // summary: // A class that basically just provides a callback method, which // can be used by a TreeModel to test whether an item should be // returned to the Tree widget for displaying it or not. // By assigning a filter instance to another filter instance, // a filter chain can be established. constructor: function(/*Object*/ p_params) { // summary: // Constructs this filter with the given JSON object // p_params.itemFilter: Object // An instance of [com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter]. // If set, isItemAcceptable() of this filter will also ask the chained filter instance // whether or not the item to check is acceptable // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.itemFilter:", p_params.itemFilter); } } if (p_params && (typeof p_params === 'object')) { // initialize the item filter for chaining if (p_params.itemFilter && (typeof p_params.itemFilter == 'object')) { this._itemFilter = p_params.itemFilter; } } // exit trace if (this._isTracing) { this.traceExit(m); } }, isItemAcceptable: function(/*Item*/ p_item, /*Object*/ p_store) { // For general information about this method, see // [com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter] // // Implementation specifics: // Ask the store (p_store), whether the given item is a library // or folder object // tags: // protected // entry trace var m = "isItemAcceptable(p_item, p_store)"; if (this._isTracing) { this.traceEntry(m, [ p_item, p_store ]); } // filter var result = (p_store.isFolderItem(p_item) || p_store.isRepositoryItem(p_item)); // this filter supports filter chaining if (result && this._itemFilter) { result = result && this._itemFilter.isItemAcceptable(p_item, p_store); } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.filter.QuickSearchTreeItemFilter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.filter.QuickSearchTreeItemFilter"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.filter.QuickSearchTreeItemFilter"); dojo.declare( "com.ibm.workplace.wcm.ecm.picker.widget.filter.QuickSearchTreeItemFilter", [ com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter ], { // summary: // A TreeItemFilter which only lets items through that contain a // given search term. // _labelContains: String // Search term that the item label that is compared against it contains at any position. // Comparison is case-sensitive. _labelContains: "", // _labelEndsWith: String // Search term that the item label that is compared against it ends with. // Comparison is case-sensitive. _labelEndsWith: "", // _labelStartsWith: String // Search term that the item label that is compared against it starts with. // Comparison is case-sensitive. _labelStartsWith: "", changeLabelContains: function(/*String*/ p_labelContains) { // summary: // Changes or adds the _labelContains private variable // p_labelContains: String // New String for the contains condition // tags: // public // entry trace var m = "changeLabelContains(p_labelContains)"; if (this._isTracing) { this.traceEntry(m, [ p_labelContains ]); } if (typeof p_labelContains == 'string' && p_labelContains !== "") { // we only support case in-sensitive search this._labelContains = p_labelContains.toLowerCase(); // now, check for the existence of a '*' within the search term var starPos = this._labelContains.indexOf('*'); if (starPos > -1) { // we found a star if (starPos > 0) { // there's text in front of the star this.changeLabelStartsWith(this._labelContains.substr(0, starPos)); } else { this.changeLabelStartsWith(""); } if (starPos < this._labelContains.length) { // if there's some text after the star, use it as endsWith condition this.changeLabelEndsWith(this._labelContains.substr(starPos + 1)); } else { this.changeLabelEndsWith(""); } } else { // no star found (or it was removed from a previous search string), so reset startsWith and endsWith this.changeLabelStartsWith(""); this.changeLabelEndsWith(""); } } else { this._labelContains = p_labelContains; } if (this._labelContains === "") { // make sure to clear out startsWith and endsWith conditions here as well this.changeLabelStartsWith(""); this.changeLabelEndsWith(""); } // exit trace if (this._isTracing) { this.traceExit(m); } }, changeLabelEndsWith: function(/*String*/ p_labelEndsWith) { // summary: // Changes or adds the _labelEndsWith private variable // p_labelEndsWith: String // New String for the endsWith condition // tags: // public // entry trace var m = "changeLabelEndsWith(p_labelEndsWith)"; if (this._isTracing) { this.traceEntry(m, [ p_labelEndsWith ]); } if (typeof p_labelEndsWith == 'string' && p_labelEndsWith !== "") { // we only support case in-sensitive search this._labelEndsWith = p_labelEndsWith.toLowerCase(); } else { this._labelEndsWith = p_labelEndsWith; } // exit trace if (this._isTracing) { this.traceExit(m); } }, changeLabelStartsWith: function(/*String*/ p_labelStartsWith) { // summary: // Changes or adds the _labelStartsWith private variable // p_labelStartsWith: String // New String for the startsWith condition // tags: // public // entry trace var m = "changeLabelStartsWith(p_labelStartsWith)"; if (this._isTracing) { this.traceEntry(m, [ p_labelStartsWith ]); } if (typeof p_labelStartsWith == 'string' && p_labelStartsWith !== "") { // we only support case in-sensitive search this._labelStartsWith = p_labelStartsWith.toLowerCase(); } else { this._labelStartsWith = p_labelStartsWith; } // exit trace if (this._isTracing) { this.traceExit(m); } }, constructor: function(/*Object*/ p_params) { // summary: // Initializes the filter object by setting the following condition // properties. Do not provide properties that you don't want the // filter to test for // p_params.labelStartsWith: String // If set, this filter will test whether the item label // starts with the given String // p_params.labelEndsWith: String // If set, this filter will test whether the item label // ends with the given String // p_params.labelContains: String // If set, this filter will test whether the item label // contains the given String // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.itemFilter:", p_params.itemFilter); this.trace(m, "p_params.labelStartsWith:", p_params.labelStartsWith); this.trace(m, "p_params.labelEndsWith:", p_params.labelEndsWith); this.trace(m, "p_params.labelContains:", p_params.labelContains); } } if (p_params && typeof p_params == 'object') { // initialize the item filter for chaining if (p_params.itemFilter && typeof p_params.itemFilter == 'object') { this._itemFilter = p_params.itemFilter; } if (typeof p_params.labelStartsWith == 'string') { this.changeLabelStartsWith(p_params.labelStartsWith); } if (typeof p_params.labelEndsWith == 'string') { this.changeLabelEndsWith(p_params.labelEndsWith); } if (typeof p_params.labelContains == 'string') { this.changeLabelContains(p_params.labelContains); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, isItemAcceptable: function(/*Item*/ p_item, /*Object*/ p_store) { // For general information about this method, see // com.ibm.workplace.wcm.ecm.picker.widget.filter._TreeItemFilter // // Implementation specifics: // This filter applies prefix, suffix and contains string matching // to test whether an item is acceptable for this filter or not. // If more than one condition is specified, all of them must be // true for the method to return true. Therefore, if you specify // a prefix and a suffix, both conditions need to be true for the // item to be acceptable. // tags: // protected // entry trace var m = "isItemAcceptable(p_item, p_store)"; if (this._isTracing) { this.traceEntry(m, [ p_item, p_store ]); } // filter var result = this._itemMatchesConditions(p_item, p_store); // this filter supports filter chaining if (result && this._itemFilter) { result = result && this._itemFilter.isItemAcceptable(p_item, p_store); } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _itemMatchesConditions: function(/*Item*/ p_item, /*Object*/ p_store) { // summary: // This method tests the label of the given p_item against the // defined prefix, suffix and contains strings of this filter. // Returns true, if all defined conditions produce a match. // p_item: Item // An item that is available in p_store // p_store: Object // An instance of [com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore] // returns: // true if all conditions are met, false otherwise // tags: // private // entry trace var m = "_itemMatchesConditions(p_item, p_store)"; if (this._isTracing) { this.traceEntry(m, [ p_item, p_store ]); } // init result with default value var result = true; var label = ""; var lcLabel = ""; var startsWithSet = false; var endsWithSet = false; if ((this._labelStartsWith) && (this._labelStartsWith !== "")) { startsWithSet = true; } if ((this._labelEndsWith) && (this._labelEndsWith !== "")) { endsWithSet = true; } if ((!startsWithSet) && (!endsWithSet)) { // we can only run the contains search, if there was no star within the search term this.trace(m, "Running 'contains' check"); if ((this._labelContains) && (this._labelContains !== "")) { if (this._labelContains == '*') { // special case, all we have is a star // a star matches everything and is the same, as if there was no search term at all result = true; } else { label = p_store.getLabel(p_item); if (label && (label !== "")) { // we want to do a case insensitive search lcLabel = label.toLowerCase(); this.trace(m, "Item label (lowercase): ", lcLabel); result = result && (lcLabel.indexOf(this._labelContains) >= 0); } else { result = false; } } } } else { var doesStartWith = false; var doesEndWith = false; // run the startsWith XOR endsWith or the startsWith AND endsWith checks here if (startsWithSet === true) { label = p_store.getLabel(p_item); if (label && (label !== "")) { this.trace(m, "Running 'startsWith' check"); // we want to do a case insensitive search lcLabel = label.toLowerCase(); this.trace(m, "Item label (lowercase): ", lcLabel); doesStartWith = (lcLabel.indexOf(this._labelStartsWith) === 0); } } if (endsWithSet === true) { label = p_store.getLabel(p_item); if (label && (label !== "")) { this.trace(m, "Running 'endsWith' check"); // we want to do a case insensitive search lcLabel = label.toLowerCase(); this.trace(m, "Item label (lowercase): ", lcLabel); var idx = lcLabel.lastIndexOf(this._labelEndsWith); doesEndWith = ((idx > -1) && (idx === (lcLabel.length - this._labelEndsWith.length))); } } if ((startsWithSet === true) && (endsWithSet === true)) { // startsWith AND endsWith set result = result && doesStartWith && doesEndWith; } else { // one condition (startsWith or endsWith) is set only, so simply OR the results result = result && (doesStartWith || doesEndWith); } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.model.FedDocTreeModel"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.model.FedDocTreeModel"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.model.FedDocTreeModel"); dojo.require("dojo.string"); dojo.require("dijit.tree.ForestStoreModel"); dojo.require("com.ibm.widgets._Traceable"); dojo.declare( "com.ibm.workplace.wcm.ecm.picker.widget.model.FedDocTreeModel", [ dijit.tree.ForestStoreModel, com.ibm.widgets._Traceable ], { // summary: // An inherited store model for use by dijit.Tree widgets. Overrides the mayHaveChildren(item) // method for better interaction with the store used by the federated documents support // (see also [com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore]. Also overrides // the getChildren() method to support item filtering. // // _allowSubItems: [private] Boolean // Boolean value defining whether items in this store may have subitems // or not. If not, mayHaveChildren will always report false, even if // the item is a folder and may have children though. _allowSubItems: true, // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _itemFilter: [private] Object // TreeItemFilter instance. If set, getChildren() function will only pass on // items that are acceptable for the filter _itemFilter: null, constructor : function(/*Object*/ p_params) { // summary: // Constructs this widget // p_params: Object // The parameters to instantiate this model with // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { // do not use dojo.toJson on the params JSON object, because this will fail // with a too much recursion error since the store is part of the arguments this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.itemFilter:", p_params.itemFilter); this.trace(m, "p_params.allowSubItems:", p_params.allowSubItems); } } if (p_params && typeof p_params == 'object') { if (p_params.itemFilter && typeof p_params.itemFilter == 'object') { this._itemFilter = p_params.itemFilter; } if (typeof p_params.allowSubItems != 'undefined') { this._allowSubItems = p_params.allowSubItems; } } // exit trace if (this._isTracing) { this.traceExit(m); } }, filterTreeItems: function(/*Item*/ parentItem) { // summary: // This method checks the given parentItem and if it is a folder, checks // all child items (and their child items, if they are folders) recursively // for being acceptable for the filter set on this model. // If an item is not yet loaded, child items won't be loaded automatically, // so only loaded items are taken into account (for performance reasons). // Triggers a tree update for the given item, by calling the onChildrenChange() // callback method. This ensures the tree is updated with the shortened list // of child items (if the filter caused items to disappear). // parentItem: item // The parent item. Needs to be available in the attached store. // returns: // Boolean - True, if at least one item in the folder tree matched the filter, // otherwise false (means the item itself needs to disappear from // the tree) // tags: // protected // entry trace var m = "filterTreeItems(parentItem)"; if (this._isTracing) { this.traceEntry(m, parentItem); } var result = []; var myCB = dojo.hitch(this, function(/*Item[]*/ items) { dojo.forEach(items, function(item) { if (this._itemFilter) { // check children of this item, if it is a folder var hasMatchingChildren = false; if (this._allowSubItems && (this.store.isFolderItem(item) || this.store.isRepositoryItem(item)) && (this.store.isItemLoaded(item)) && (this.store.isItemExpanded(item))) { hasMatchingChildren = this.filterTreeItems(item); } else { hasMatchingChildren = false; } if ((this._itemFilter.isItemAcceptable(item, this.store)) || (hasMatchingChildren)) { result.push(item); } } else { // always push the result, if there's no filter set result.push(item); } }, this); if ((this.onChildrenChange) && (dojo.isFunction(this.onChildrenChange))) { this.onChildrenChange(parentItem, result); } }); this.getChildren(parentItem, myCB, null, true); // return true, if at least one item matched the filter result = (result.length > 0); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, getChildren: function(/*Item*/ parentItem, /*Function*/ onComplete, /*Function*/ onError, /*Boolean*/ useOriginal) { // For general information about this method, see dijit.tree.ForestStoreModel // // Implementation specifics: // // Obtains the children of the given parent item and passes them to the specified // onComplete callback function. // Selectively overrides the original method from the ForestStoreModel, if useOriginal parameter // is not specified or set to false. This is necessary, to let the Model behave as normal, if no // filtering is being used. // The tricky part is that filtering takes place as part of the callback that the // original implementation triggers: // The method calls the inherited method getChildren() and then works on the returned // result, filters out items, and then calls the original callback method passed into // this method to report back the filtered result. // parentItem: item // A store item available in the attached store // onComplete: Function // Original callback function from the dijit.Tree calling this method to // retrieve children for the given parentItem // onError: Function // Original callback function from the dijit.Tree instance. Used for reporting // errors. // useOriginal: Boolean // Not set when dijit.Tree instance calls this method. Only used (and set to true) when // we explicitly call this method to force the tree to update displayed items in filterTreeItems(). // tags: // public // entry trace var m = "getChildren(parentItem, onComplete, onError, useOriginal)"; if (this._isTracing) { this.traceEntry(m, [ parentItem, onComplete, onError, useOriginal ]); } var result = []; var originalCB = onComplete; var myCB = dojo.hitch(this, function(/*Item[]*/ items) { dojo.forEach(items, function(item) { if (this._itemFilter) { if (this._itemFilter.isItemAcceptable(item, this.store)) { result.push(item); } } else { // always push the result, if there's no filter set result.push(item); } }, this); if ((originalCB) && (dojo.isFunction(originalCB))) { originalCB(result); } }); var useAdvancedLogic = ((!useOriginal) || (useOriginal && (useOriginal === false))); // trace if (this._isTracing) { this.trace(m, "Use advanced logic:", useAdvancedLogic); } if (useAdvancedLogic) { var myArguments = arguments; if (myArguments[1]) { myArguments[1] = myCB; } // default this.inherited(myArguments); } else { // default this.inherited(arguments); } // exit trace if (this._isTracing) { this.traceExit(m); } }, mayHaveChildren: function(/*Item*/ p_item) { // For general information about this method, see dijit.tree.ForestStoreModel // // Implementation specifics: // // Called when a dijit.Tree widget, which is connected // to this model, needs to know, whether a specific item // from the store may have children. This information is // used to decide whether to display an expand/collapse // icon or not, if lazy loading of child items is enabled // on the dijit.Tree widget instance. // // entry trace var m = "mayHaveChildren(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = this._allowSubItems && (this.store.isFolderItem(p_item) || this.store.isRepositoryItem(p_item) || this.inherited(arguments)); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils"] = true; //Licensed Materials - Property of IBM // //5724-E76, 5655-R17, 5655-M44 // //Copyright IBM Corp. 2011 All Rights reserved.// dojo.provide("com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils"); dojo.require("com.ibm.widgets._Traceable"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils", [com.ibm.widgets._Traceable], { // summary: // Provides some utility helper function for error messages related to XHR requests getErrorMessage: function(/*Object*/ioargs, /*Object*/ nlsMessages, /*boolean*/ httpsSpecialMsg) { // summary: // Creates the error message for the given XHR request // ioargs: // The ioargs of the XHR request // nlsMessages: // An object containing NLS messages // httpsSpecialMsg: // A boolean flag indicating whether the error relates to a HTTPS URL. // If true, getErrorMessage returns dedicated error details // (like e.g. "check your HTTPS setup") if available. // tags: // public // returns: // An array containing two String attributes: // message: The error message // details: The optional error details // entry trace var m = "getErrorMessage(ioargs, nlsMessages, httpsSpecialMsg)"; if (this._isTracing) { this.traceEntry(m, [ ioargs, nlsMessages, httpsSpecialMsg ]); } var result = []; if (ioargs.xhr.status >= 400) { var messageStr = 'errorHttp' + dojo.string.trim(ioargs.xhr.status + ''); var detailsStr = 'errorDetailsHttp' + dojo.string.trim(ioargs.xhr.status + ''); var detailsHttpsStr = 'errorDetailsHttps' + dojo.string.trim(ioargs.xhr.status + ''); if (nlsMessages[messageStr]) { if (ioargs.xhr.status == 500) { // trying to get the response string from the response object var _resp = ""; if (typeof ioargs.xhr.response == 'string') { _resp = ioargs.xhr.response; // response is a string already, so just use it } else { // response is a javascript object, so test for the response text if (typeof ioargs.xhr.responseText == 'string') { _resp = ioargs.xhr.responseText; } } result[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorMessage] = nlsMessages[messageStr]; if (_resp.length > 500) { _resp = _resp.substring(0, 499); } result[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorDetails] = _resp; } else { result[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorMessage] = nlsMessages[messageStr]; if ((httpsSpecialMsg) && (nlsMessages[detailsHttpsStr])) { result[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorDetails] = nlsMessages[detailsHttpsStr]; } else if (nlsMessages[detailsStr]) { result[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorDetails] = nlsMessages[detailsStr]; } } } else { // if we don't know the error, return a generic message result[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorMessage] = nlsMessages.errorFetchingData; } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; } }); //*** global constants *** //com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils._INSTANCE: [const] [public] Object //Singleton instance for the ErrorMsgUtils helper com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils._INSTANCE = new com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils(); //com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorMessage: [const] [public] String //The id of the attribute that contains the error message com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorMessage = "ErrorMessage"; //com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorDetails: [const] [public] String //The id of the attribute that contains the error details com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorDetails = "ErrorDetails"; } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore"); dojo.require("dojo.string"); dojo.declare( "com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore", [ com.ibm.widgets._Traceable ], { // summary: // Store implementing the [dojo.data.api.Read] and [dojo.data.api.Identity] // interfaces for providing CMIS server folder and documents information // in a way that it can be consumed by a dijit.Tree widget for display // and user selection purposes // _credentialVaultParamValue: [private] String // If set to a non null value, contains the vault slot name used for authenticating // at a remote CMIS server _credentialVaultParamValue: null, // _serviceId: [private] String // If set to a non-empty value, this member contains the ID of the selected pre-defined // federated documents service that requests are made to _serviceId: "", // _feedBaseURL: [private] String // POC Url for getting parsed CMIS feeds through the portal server. _feedBaseURL: "", // _feedSvcDocBaseURL: [private] String // POC Url for getting parsed CMIS service doc feeds through the portal server. // For non-servicedoc root Urls, _feedSvcDocBaseURL needs to be set to the same // value as _feedBaseURL _feedSvcDocBaseURL: "", // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _items: [private] Object // Object which holds references for each item in the store. The ID attribute of an item // works as a key/identifier in this object. _items: {}, // _nlsMessages: [private] Object // Object holding localized strings used for providing localized messages _nlsMessages: {}, // _nodeTypes: [private] Array // An array, which holds one or more identifiers (Strings) that define which node types // the tree widget will display in the picker dialog. Supported values are: 'folder', // 'repository' and 'document' _nodeTypes: [], // _onErrorStateChanged: [private] Function // Callback method that is triggered by this store when an error condition // occurred and the associated error message needs to be displayed in the // owning dialog or if the widget was in error state previously and the // error was cleared. // // _onErrorStateChanged(/*Object*/ p_sender, /*Boolean*/ p_errorState, // /*String?*/p_errorMsg, /*String?*/p_errorDetails) _onErrorStateChanged: null, // _onRootNodeChanged: [private] Function // Callback method that is triggered by this store when a response was // received that contained a 'root' item and toplevelelements where // queried by a fetch() function call. This allows the calling code // to update a root-node, which is not connected to the store otherwise, // in a dijit.Tree widget with appropriate data. // // _onRootNodeChanged(/*Item*/ p_item) _onRootNodeChanged: null, // _typeFilter: [private] String // Computed string which is generated based on the contents of the _nodeTypes array. // Allowed values are: 'folder', 'document', 'all' _typeFilter: "all", // _url: [private] String // The URL of the repository whose content is reflected by this store instance. This URL is // usually retrieved from the service document. _url: null, addNodeTypes: function(/*Array*/ p_nodeTypes) { // summary: // This method adds the given nodeTypes to the internal _nodeTypes array, computes // the nodetype filter again and marks all items as non-loaded, to force reloading // from the backend. // p_nodeTypes: // An array of string, with each string defining one node type that should be added // to the list. Allowed nodeTypes are 'folder', 'document' and 'repository' // tags: // public // entry trace var m = "addNodeTypes(p_nodeTypes)"; if (this._isTracing) { this.traceEntry(m, p_nodeTypes); } if (dojo.isArray(p_nodeTypes)) { dojo.forEach(p_nodeTypes, dojo.hitch(this, function(nodeType) { if (dojo.indexOf(this._nodeTypes, nodeType) == -1) { // nodeType does not yet exist, so add it this._nodeTypes.push(nodeType); }})); this._computeTypeFilter(); this._forceItemsReload(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, close: function(request) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "close(request)"; if (this._isTracing) { this.traceEntry(m, request); } this._items = {}; // exit trace if (this._isTracing) { this.traceExit(m); } return; }, constructor: function(/*Object*/ p_params) { // summary: // Constructs this widget // p_params: Object // The arguments for initializing this store // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.url:", p_params.url); this.trace(m, "p_params.feedBaseURL:", p_params.feedBaseURL); this.trace(m, "p_params.feedSvcDocBaseURL", p_params.feedSvcDocBaseURL); this.trace(m, "p_params.nodeTypes:", dojo.toJson(p_params.nodeTypes)); this.trace(m, "p_params.nlsMessages", p_params.nlsMessages); this.trace(m, "p_params.credentialVaultParamValue:", p_params.credentialVaultParamValue); this.trace(m, "p_params.serviceId:", p_params.serviceId); } } if (p_params && typeof p_params == 'object') { if (typeof p_params.url == 'string') { this._url = p_params.url; } if (typeof p_params.feedBaseURL == 'string') { this._feedBaseURL = p_params.feedBaseURL; } if (typeof p_params.feedSvcDocBaseURL == 'string') { this._feedSvcDocBaseURL = p_params.feedSvcDocBaseURL; } if (p_params.nodeTypes && typeof p_params.nodeTypes == 'object') { this._nodeTypes = p_params.nodeTypes; } if (typeof p_params.credentialVaultParamValue == 'string') { this._credentialVaultParamValue = p_params.credentialVaultParamValue; } if (typeof p_params.serviceId == 'string') { this._serviceId = p_params.serviceId; } if ((p_params.onErrorStateChanged) && dojo.isFunction(p_params.onErrorStateChanged)) { this._onErrorStateChanged = p_params.onErrorStateChanged; } if ((p_params.onRootNodeChanged) && dojo.isFunction(p_params.onRootNodeChanged)) { this._onRootNodeChanged = p_params.onRootNodeChanged; } if ((p_params.nlsMessages) && typeof p_params.nlsMessages == 'object') { this._nlsMessages = p_params.nlsMessages; } } this._computeTypeFilter(); // exit trace if (this._isTracing) { this.traceExit(m); } }, containsValue: function(/*Item*/ p_item, /*String*/ p_attribute, /*Object*/ p_value) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "containsValue(p_item, p_attribute, p_value)"; if (this._isTracing) { this.traceEntry(m, [ p_item, p_attribute, p_value ]); } var result = false; if (this.hasAttribute(p_item, p_attribute)) { result = dojo.some(this.getValues(p_item, p_attribute), function(val) { return val == p_value; // Boolean }, this); } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, fetch: function(/*Object*/ p_params) { // summary: // For a general description of the fetch() method, see dojo.data.api.Read // // Implementation specifics: // // This method supports loading a set of top-level items or loading a specific item // by providing a specific query ("itemID=Xxx"). Loading the top-level items either // happens when no query parameter is specified or the query matches "toplevelitems". // // The expected p_params object accepts the following properties // // p_params: Object // scope: Object - calling scope, needed when calling back an onItem() callback function passed // in as callback method for single item retrieval // item: Item - the item object that needs to be loaded, usually called for loading the child // items of a given item // onComplete: Function - callback method being triggered whenever the asynchronous fetch() // operation completed // query: String - Query string for defining the fetch() operation. Can be omitted for fetching // top-level items. Use itemID="id" query to fetch a specific item from the store. // // tags: // public // entry trace var m = "fetch(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); this.trace(m, "Scope:", p_params.scope); this.trace(m, "Scope:", p_params.scope); this.trace(m, "Scope:", p_params.scope); } var scope = dojo.global; if (p_params.scope) { scope = p_params.scope; } if (p_params.item) { // try to load a single item if (this._isTracing) { this.trace(m, "Remote fetching of items"); } this._asyncLoadItemsRemote( p_params.item, p_params.onComplete); } else { // use item as parent item for loading children if (!p_params.query || (typeof p_params.query == 'string' && p_params.query.match(/^toplevelitems$/i))) { // use query to load root elements // simulate asynchronous loading of top // level items by using a timer to trigger a // loading function if (this._isTracing) { this.trace(m, "Remote fetching of items"); } this._asyncLoadItemsRemote(null, p_params.onComplete); } else { // fetch the contents of a given URL (need to lookup item first) if (typeof p_params.query == 'string' && (p_params.query.match("^itemID=") == "itemID=")) { // extract item ID from query parameter var ID = p_params.query.substring(7, p_params.query.length); // trace if (this._isTracing) { this.trace(m, "Item identity from query:", ID); } if (ID !== "") { var item = this.fetchItemByIdentity({ "identity": ID }); // trace if (this._isTracing) { this.trace(m, "Item fetched by identity:", item); } if (item) { // check if item is already loaded, if yes, just return the children, instead of // sending an XHRGET to the remote server var isItemLoaded = this.isItemLoaded(item); // trace if (this._isTracing) { this.trace(m, "Is item already loaded:", isItemLoaded); } if (isItemLoaded) { this._clearError(); if ((p_params.onComplete) && (dojo.isFunction(p_params.onComplete))) { p_params.onComplete(this.getValues(item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr)); } } else { // pass on the data to the found item and run a simple loadItem on it this.loadItem({ "item": item, "onItem": p_params.onComplete, "topLevelCallback": true }); } } else { this.error(m, dojo.string.substitute("Item with ID ${0} was not found in the store.", [ID])); } } } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, fetchItemByIdentity: function(/*Object*/ p_params) { // see dojo.data.api.Identity // // tags: // public // entry trace var m = "fetchItemByIdentity(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); this.trace(m, "Identity:", p_params.identity); this.trace(m, "Scope:", p_params.scope); this.trace(m, "onItem callback:", p_params.onItem); } var id = p_params.identity; if (typeof id != 'string') { if (!dojo.isFunction(id.toString)) { throw new Error(dojo.string.substitute(this._nlsMessages.srvCommunication.attributeNotStringable, ["id", "fetchItemByIdentity"])); } id = id.toString(); } var item = this._items[id]; if (typeof item == 'undefined') { item = null; } var scope = dojo.global; if (p_params.scope) { scope = p_params.scope; } if (dojo.isFunction(p_params.onItem)) { p_params.onItem.call(scope, item); } // exit trace if (this._isTracing) { this.traceExit(m, item); } return item; // item }, getAttributes: function(/*Item*/ p_item) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "getAttributes(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var keys = []; var i = 0; for ( var attr in p_item) { if ((typeof (p_item[attr]) != 'undefined') && (typeof (p_item[attr]) != 'function')) { keys[i++] = attr; } } // exit trace if (this._isTracing) { this.traceExit(m, dojo.toJson(keys)); } return keys; // Array }, getDownloadURL: function(/*Item*/ p_item) { // summary: // Returns the attribute value for the given item containing it's download Url // p_item: item // A store item // returns: // String containing the download Url or an empty string, if the attribute // is not defined // tags: // public // entry trace var m = "getDownloadURL(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = this.getValue(p_item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._downloadURLAttr, ""); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getFeatures: function() { // see dojo.data.api.Read // // tags: // public // entry trace var m = "getFeatures()"; if (this._isTracing) { this.traceEntry(m); } var result = { "dojo.data.api.Read": true, // this store supports the dojo.data.api.Read Interface "dojo.data.api.Identity": true // this store supports the dojo.data.api.Identity Interface }; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Object }, getIdentity: function(/*Item*/ p_item) { // see dojo.data.api.Identity // // tags: // public // entry trace var m = "getIdentity(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = this.getValue(p_item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getIdentityAttributes: function(/*Item?*/ p_item) { // see dojo.data.api.Identity // // tags: // public // entry trace var m = "getIdentityAttributes(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } result = [ com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr ]; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Array }, getLabel: function(/*Item*/ p_item) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "getLabel(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = this.getValue(p_item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._labelAttr); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, getLabelAttributes: function(/*Item?*/ p_item) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "getLabelAttributes(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = [ com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._labelAttr ]; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Array }, getValue: function(/*Item*/ p_item, /*String*/ p_attribute, /*Object*/ p_defaultValue) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "getValue(p_item, p_attribute, p_defaultValue)"; if (this._isTracing) { this.traceEntry(m, [ p_item, p_attribute, p_defaultValue ]); } var result = p_defaultValue; if (typeof p_attribute != 'string') { throw new Error(dojo.string.substitute(this._nlsMessages.srvCommunication.attributeNotStringable, ["p_attribute", "getValue"])); } if (p_attribute == this.PATH) { result = this.getPath(p_item); // String } else if (!this.hasAttribute(p_item, p_attribute)) { result = p_defaultValue; // String | Object } else { result = p_item[p_attribute]; // String | Object } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String | Object }, getValues: function(/*Item*/ p_item, /*String*/ p_attribute) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "getValues(p_item, p_attribute)"; if (this._isTracing) { this.traceEntry(m, [ p_item, p_attribute ]); } if (typeof p_attribute != 'string') { throw new Error(dojo.string.substitute(this._nlsMessages.srvCommunication.attributeNotStringable, ["p_attribute", "getValues"])); } // make sure that we work on our own store copy of the item var _item = this._dereferenceItem(p_item); var result = []; if (p_attribute == com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr) { var tmp; if (_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr]) { tmp = []; if (_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr] === true) { tmp = _item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr]; } } if (typeof tmp != 'undefined') { result = tmp; } } else { var ret = this.getValue(_item, p_attribute); if (typeof ret != 'undefined') { result = [ ret ]; } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Array }, getViewURL: function(/*Item*/ p_item) { // summary: // Returns the attribute value for the given item containing it's view Url // p_item: item // A store item // returns: // String containing the view Url or an empty string, if the attribute // is not defined // tags: // public // entry trace var m = "getViewURL(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = this.getValue(p_item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._viewURLAttr, ""); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, hasAttribute: function(/*Item*/ p_item, /*String*/ p_attribute) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "hasAttribute(p_item, p_attribute)"; if (this._isTracing) { this.traceEntry(m, [ p_item, p_attribute ]); } if (typeof p_attribute != 'string') { throw new Error(dojo.string.substitute(this._nlsMessages.srvCommunication.attributeNotStringable, ["p_attribute", "hasAttribute"])); } var result = (typeof p_item[p_attribute] != 'undefined'); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, isRepositoryItem: function(/*Item*/ p_item) { // summary: // Checks whether the given item is or acts as a folder on the CMIS server. // Explicitly checks for the baseTypeAttr being one of the defined nodeTypes that // are known to be folders. // p_item: item // A store item to be checked for being a folder // returns: // Boolean, true if the item is a folder, false otherwise // entry trace var m = "isRepositoryItem(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = (this.getValue(p_item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr, 'document') == "repository"); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, isFolderItem: function(/*Item*/ p_item) { // summary: // Checks whether the given item is or acts as a folder on the CMIS server. // Explicitly checks for the baseTypeAttr being one of the defined nodeTypes that // are known to be folders. // p_item: item // A store item to be checked for being a folder // returns: // Boolean, true if the item is a folder, false otherwise // entry trace var m = "isFolderItem(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = (this.getValue(p_item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr, 'document') == "folder"); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, isItem: function(/*Object*/ p_obj) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "isItem(p_obj)"; if (this._isTracing) { this.traceEntry(m, p_obj); } var ret = false; if (p_obj && typeof p_obj != 'undefined') { ret = typeof p_obj[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr] == 'string'; if (ret) { var id = p_obj[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr]; ret = (typeof this._items[id] != 'undefined'); } else { throw new Error(dojo.string.substitute(this._nlsMessages.srvCommunication.attributeNotStringable, ["p_obj._idAttr", "isItem"])); } } // exit trace if (this._isTracing) { this.traceExit(m, ret); } return ret; // Boolean }, isItemExpanded: function(/*Item*/ p_item) { // Checks whether the given item is a folder and whether this folder is actually // expanded. If the expanded_attr is missing, it is considered being collapsed. // If the attribute is available, the value of the attribute defines the return // value. // // p_item: // The store item to check for the expanded_attr value // returns: // Boolean // tags: // public // entry trace var m = "isItemExpanded(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } // make sure we work on our own store copy of the item var _item = this._dereferenceItem(p_item); if (this.isItem(_item)) { result = (this.getValue(_item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._expandedAttr, false) === true); } else { // not a known item, return false result = false; } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, isItemLoaded: function(/*Item*/ p_item) { // see dojo.data.api.Read // // tags: // public // entry trace var m = "isItemLoaded(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } // make sure we work on our own store copy of the item var _item = this._dereferenceItem(p_item); var result = this.isItem(_item) && (this.getValue(_item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr) === true); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, loadItem: function(/*Object*/ p_params) { // For general information about this method, see dojo.data.api.Read // // Implementation specifics: // // Loading children of a given folder only produces an 'onItem()' callback // event. However, in some situations (e.g. when the children of an item act // as toplevel elements in a tree showing only child-items), it is necessary // to have the store trigger a callback (onComplete) like it is called when // loading top-level elements. To accomplish this, the p_params object offers // the ability to take an additional parameter 'topLevelCallback' which needs // to be a reference to an onComplete()-style callback method. This callback // method is triggered, when the loadItem() call completed. // // p_params: Object // Parameter object. For supported properties, see dojo.data.api.Read // This implementation supports one additional property // // topLevelCallback: Function // An callback function with a onComplete() style signature // tags: // public // entry trace var m = "loadItem(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); this.trace(m, "Top level callback:", p_params.topLevelCallback); this.trace(m, "Item:", p_params.item); this.trace(m, "onItem callback:", p_params.onItem); } var topLevelCallback = false; if (p_params.topLevelCallback) { topLevelCallback = p_params.topLevelCallback; } if (this._isTracing) { this.trace(m, "Remote fetching of items"); } this._asyncLoadItemsRemote(p_params.item, p_params.onItem, topLevelCallback); // exit trace if (this._isTracing) { this.traceExit(m); } }, removeNodeTypes: function(/*Array*/ p_nodeTypes) { // summary: // This method removes the given nodeTypes from the internal _nodeTypes array, computes // the nodetype filter again and marks all items as non-loaded, to force reloading // from the backend. // p_nodeTypes: // An array of string, with each string defining one node type that should be removed // from the list. Allowed nodeTypes are 'folder', 'document' and 'repository' // tags: // public // entry trace var m = "removeNodeTypes(p_nodeTypes)"; if (this._isTracing) { this.traceEntry(m, p_nodeTypes); } if (dojo.isArray(p_nodeTypes)) { var newNodeTypes = []; dojo.forEach(this._nodeTypes, dojo.hitch(this, function(nodeType) { if (dojo.indexOf(p_nodeTypes, nodeType) == -1) { // nodeType must not be removed, so keep it newNodeTypes.push(nodeType); }})); // replace old list with our new one this._nodeTypes = newNodeTypes; this._computeTypeFilter(); this._forceItemsReload(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, setItemExpanded: function(/*Item*/ p_item, /*Boolean*/ p_isExpanded) { // Creates the isExpanded attribute on the given item, if it does not already // exist, or changes the value to either true or false (value of p_isExpanded) // This is not a standard store method and the value is client-side only, so we // don't have to implement the dojo.data.Write API. // // p_item: // The store item whose expanded_attr value should be changed // p_isExpanded: // Either true or false, depending on whether an item is an expanded folder // or not // tags: // public // entry trace var m = "setItemExpanded(p_item, p_isExpanded)"; if (this._isTracing) { this.traceEntry(m, [p_item, p_isExpanded]); } // make sure we work on our own store copy of the item var _item = this._dereferenceItem(p_item); if (this.isItem(_item)) { // change or set the expandedAttr directly on the item within the store's own _items array. // this._items[_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr]][com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._expandedAttr] = p_isExpanded; // TODO, check if the below code has the same effect as the above line _item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._expandedAttr] = p_isExpanded; } // exit trace if (this._isTracing) { this.traceExit(m); } }, _asyncLoadItemsRemote: function(/*Item*/ p_parentItem, /*Function*/ p_callback, /*boolean*/ p_topLevelCallback) { // summary: // This method performs the actual loading of items from the remote backend server. // It is able to either request top-level items, child items for a given item or // child items for a given item with triggering a top-level item request like callback. // p_parentItem: // Parent item to load child items for. If null, top-level items will be requested. // p_callback: // Callback function reference. Based on the type of get request, the method either triggers // an onItem() or onComplete() compatible callback. If p_topLevelCallback is true, will always // trigger an onComplete() compatible callback. // p_topLevelCallback: // Defines whether calling this function with p_parentItem !== null will cause an onComplete() style // callback (true), or a standard onItem() style callback (false) // tags: // private // entry trace var m = "_asyncLoadItemsRemote(p_parentItem, p_callback, p_topLevelCallback)"; if (this._isTracing) { this.traceEntry(m, [ p_parentItem, p_callback, p_topLevelCallback ]); } this._clearError(); var targetUrl; if (p_parentItem === null) { // loading root elements requires to use the // base URL passed to this store for fetching // items targetUrl = this._generateTargetURL(this._url, true); } else { var url = p_parentItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._viewURLAttr]; // TODO: check for empty URL here. Code will work without // explicitly checking for empty URL, so this is a low // priority item // create the mypoc URL for the cmis feed targetUrl = this._generateTargetURL(url); } var cb = dojo.hitch( this, function(callb, response, ioArgs) { if (ioArgs.xhr.status == 200) { // trace if (this._isTracing) { this.trace(m, "XHR callback - response:", response); } var backenddata; if (response.length > 2) { backenddata = dojo.fromJson(response); } else { backenddata = null; } // trace if (this._isTracing) { this.trace(m, "XHR callback - backend data:", dojo.toJson(backenddata)); } var items; if (backenddata !== null) { items = backenddata.children; } else { items = []; } // make sure that the parent item gets the loaded items // associated as children. Otherwise the processLoadedItems // code won't work properly if (p_parentItem !== null) { p_parentItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr] = items; // now we have the items we need to insert into our // AtomStore in the 'items' variable already and // only need to process them this._processLoadedItems(p_parentItem, callb, items, null, p_topLevelCallback); } else { if (backenddata.root) { // if parentItem is not set, but we received a root element as part of the backenddata response, we // assume that the root item has got information about the folder that was we just loaded children // for. We need to put this top-folder item into our store and trigger the special onRootItemChanged() // callback, to allow calling code to fill in data of the root item into the Tree widget manually. // contentLink validation - if contentLink attribute is missing, set the link to the current // url of the store, as this will allow us to load the root element's children again later if (!backenddata.root[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._viewURLAttr]) { backenddata.root[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._viewURLAttr] = this._url; } // first, process the items as usual to get the items put into the store and appropriate callbacks // get fired this._processLoadedItems(null, callb, items, null, p_topLevelCallback); // then, set the parentItem to root, register it within our store and attach children to it var _parentItem = backenddata.root; // set baseType to folder, as a root element always needs to be a folder or repository _parentItem.baseType = "folder"; // register item in our store this._items[_parentItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr]] = _parentItem; _parentItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr] = items; // then, call processLoadedItems again, but don't pass in any callback, to cause the function // to operate silently this._processLoadedItems(_parentItem, null, items, null, p_topLevelCallback); // finally, trigger the onRootItemChanged() callback to allow the UI to be updated if (this._onRootNodeChanged && dojo.isFunction(this._onRootNodeChanged)) { this._onRootNodeChanged(_parentItem); } } else { // also notify UI that no root was received if (this._onRootNodeChanged && dojo.isFunction(this._onRootNodeChanged)) { this._onRootNodeChanged(null); } this._processLoadedItems(p_parentItem, callb, items, null, p_topLevelCallback); } } } else { var errorMsg = com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils._INSTANCE.getErrorMessage( ioArgs, this._nlsMessages.srvCommunication, (this._url.substring(0, 6).toLowerCase() === "https:") ); this._showError(errorMsg[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorMessage], errorMsg[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorDetails]); if (this._isTracing) { this.error(m, "Could not setup data backend store.", [ioArgs.xhr.status]); } // don't set the failed item to loaded. This keeps the loading animation spinning in the Tree widget, // however, it also doesn't stop doing that, if we were triggering an error callback. // this._processLoadedItems(p_parentItem, callb, [], null, p_topLevelCallback); } }, p_callback); // end of cb // trace if (this._isTracing) { this.trace(m, "Initiating XHR using target URL:", targetUrl); } dojo.xhrGet( { "url": targetUrl, "handle": cb, "sync": false }); // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearError: function() { // summary: // Clears the error state (sets this._errorState to false) and notifies // listeners of the changed error state // tags: // private this._errorState = false; // notify registered listeners of the fact that we cleared the error if (this._onErrorStateChanged) { // no more parameters needed when clearing the error state this._onErrorStateChanged(this, false); } }, _computeTypeFilter: function() { // summary: // This method computes the typeFilter Url parameter based on the supported nodeTypes // for this store. Repositories and Folders are always supported, so we check for // 'document' being available in the _nodeTypes array and use 'all' in this case, // 'folder' in all others. // tags: // private // entry trace var m = "_computeTypeFilter()"; if (this._isTracing) { this.traceEntry(m); } var showDocuments = (dojo.indexOf(this._nodeTypes, "document") != -1); if (showDocuments === true) { // WCM environment, show repositories, folders and documents this._typeFilter = "all"; } else { // PZN environment, show just repositories and folders this._typeFilter = "folder"; } // exit trace if (this._isTracing) { this.trace(m, "New type filer:", this._typeFilter); this.traceExit(m); } }, _dereferenceItem: function(/*Item*/ p_item) { // summary: // Returns a reference to an item in the internal items array. // Useful if you have cloned an item object at some point and need // to dereference it again based on the ID information. // p_item: item // Item that is known to this store. Will return the reference to this item // from the internal cache array. // returns: // item | null Returns the item reference or null, if the item is not known // to this store // tags: // private // entry trace var m = "_dereferenceItem(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } var result = null; if (this.isItem(p_item)) { // we know for sure here that 'item' is an item // in the cache and can therefore // return the reference without any further // checking var id = p_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr]; result = this._items[id]; } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Item }, _findItemForURL: function(/*String*/ p_url) { // summary: // Scans all registered items in this store for an item which has the given // ContentURL set and is a folder // p_url: String // View Url of an item to look for // returns: // item | null Returns reference to the item with the given View Url or null if the // item wasn't found // tags: // private // entry trace var m = "_findItemForURL(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } var foundItem = null; for (var id in this._items) { var item = this._items[id]; var url = this.getValue(item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._viewURLAttr, null); if (url == p_url) { // correct item found foundItem = item; break; } } // exit trace if (this._isTracing) { this.traceExit(m, foundItem); } return foundItem; // Item | null }, _forceItemsReload: function() { // summary: // Sets the 'loaded' attribute of all store items to false, even if they // have already been loaded. This forces the store to refetch these items // to get their children. Needed when switching from folders only to // folders and documents mode and the other way round. // tags: // private var m = "forceItemsReload()"; if (this._isTracing) { this.traceEntry(m); } for (var id in this._items) { var item = this._items[id]; if (this.getValue(item, com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr) === true) { item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr] = false; } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _generateTargetURL: function(/*String*/ p_url, /*Boolean?*/ p_useSvcDocUrl) { // summary: // Generates the full Url needed to load an item from the remote CMIS server // through Portal server code // p_url: String // The View Url of an item // p_useSvcDocUrl: Boolean // If set to true, use the _feedSvcDocURL to generate the target Url instead of the // _feedBaseURL // returns: // String Returns the generated target Url // tags: // private // entry trace var m = "_generateTargetURL(p_url, p_useSvcDocUrl)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_useSvcDocUrl]); } // encode the given feed URL var feedUrl = encodeURIComponent(this._encodeUrlIfNeeded(p_url)); // get the proper base URL depending on the type of the requested feed var baseUrl; if (p_useSvcDocUrl === true) { // request a CMIS service document baseUrl = this._feedSvcDocBaseURL; } else { // request a CMIS collection baseUrl = this._feedBaseURL; } // get the value for the credential vault slot ID query parameter to set when requesting the data source var vaultSlotId; if (typeof this._credentialVaultParamValue == 'string') { vaultSlotId = encodeURIComponent(this._credentialVaultParamValue); } else { // an empty string is neglected by the targeted data source, // i.e., it is interpreted as no vault slot vaultSlotId = ""; } // replace the placeholders from the CMIS feed base URL to construct the target URL var result = baseUrl.replace("%7BtypeFilter%7D", this._typeFilter).replace("%7BfeedUrl%7D", feedUrl).replace("%7BmimeType%7D", "application%2Fjson").replace("%7BvaultSlotId%7D", vaultSlotId).replace("%7BserviceId%7D", this._serviceId); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _encodeUrlIfNeeded: function(/*String*/ p_url) { // summary: // Detect whether the given URL contains URL encoded entities, by looking // for '%' characters. If none were found, run an encodeURI() on the URL // to encode values that might need encoding (like blanks, etc). // p_url: String // A string containing an item's Url parameter that might need encoding // before it can be added to the feedBaseUrl to produce the result Url // returns: // String The Url which does not need any further encoding // tags: // private // entry trace var m = "_encodeUrlIfNeeded(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } var result = p_url; if (p_url && typeof p_url == 'string' && p_url.indexOf("%") == -1) { // no encoded entities found, encodeURI() should do no harm to this URL result = encodeURI(p_url); // String } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _processLoadedItems: function(/*Item*/ p_parentItem, /*Function*/ p_callback, /*Item[]*/ p_items, /*Object*/ p_request, /*boolean*/ p_topLevelCallback) { // summary: // This is the core method of this store implementation. It processes loaded // items within several contexts. "Processing" means, it adds the loaded items // to the local this._items[] array, sets the loaded attribute and updates // parent items, once their children were loaded with an array to their children. // A special mode is when p_topLevelCallback is set to false while childMode is // set to true: in this case, child items for a parent item were loaded. Although // loading multiple items would cause an onComplete() style callback, setting // p_topLevelCallback to false in this case, will just trigger an onItem() callback // just passing on the parentItem that was updated and not an array with loaded // children. // p_parentItem: item | null // If null, method will process the array p_items as if they were top-level items and will // trigger the appropriate callback // p_callback: Function // Callback function triggered in either onComplete() or onItem() style based on value // of p_parentItem and p_topLevelCallback // p_items: Array // Array of items to be processed (i.e. being put into the store cache and triggering // fetch() method compatible callback events // p_request: Object // Request object used for the XHRGet command // p_topLevelCallback: Boolean // If set to false, callback will even be triggered for the parentItem only if child items // were processed. // tags: // private callback // entry trace var m = "_processLoadedItems(p_parentItem, p_callback, p_items, p_request, p_topLevelCallback)"; if (this._isTracing) { this.traceEntry(m, [ p_parentItem, p_callback, p_items, p_request, p_topLevelCallback ]); } var processedItems = []; var childMode = false; if (p_parentItem && this.isItem(p_parentItem)) { p_parentItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr] = true; // work on child items and make sure the // isFolder and loadAttr values are set to // correct values dojo.forEach( p_parentItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr], function(childItem) { var isFolder = false; if ((typeof childItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr] != 'undefined') && ((childItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr] == 'folder') || (childItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr] == 'repository'))) { isFolder = true; } if (isFolder) { childItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr] = false; } else { childItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr] = true; } // register the item as a // known item to this store, // otherwise a lot of // methods won't work // properly processedItems.push(this._items[childItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr]] = childItem); }, this); this._items[p_parentItem[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr]] = p_parentItem; childMode = true; } else { // process items dojo.forEach(p_items, function(/*Item*/ p_item) { // initially set isLoaded // value on item to false, // if it is a folder, to // true otherwise var isFolder = false; if ((typeof p_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr] != 'undefined') && ((p_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr] == 'folder') || (p_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr] == 'repository'))) { isFolder = true; } if (isFolder) { p_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr] = false; } else { p_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr] = true; } // not here, as this setting refers to the children of an item, not the item itself processedItems.push( this._items[p_item[com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr]] = p_item); }, this); } if (p_callback && dojo.isFunction(p_callback)) { // need to distinguish between loadItem and fetch call for many items here if ((childMode === true) && (p_topLevelCallback === false)) { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function passing parent item:", p_parentItem); } // children are just put into the item's childrenAttr field, but not returned here p_callback(p_parentItem); } else { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function passing processed items and request:", [ p_parentItem, p_request ]); } p_callback(processedItems, p_request); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _showError: function(/*String*/ p_errorMsg, /*String*/ p_errorDetails) { // summary: // Sends the provided error message to a registered listener (could be a // dialog) for display. Optionally, also sends a more detailed message // for the error. // p_errorMsg: String // The error message to display // p_errorDetails: String // Optional string with a more detailed description of the error // tags: // private this._errorState = true; // notify registered listeners of the error and have them e.g. display // the error message + details if (this._onErrorStateChanged) { this._onErrorStateChanged(this, true, p_errorMsg, p_errorDetails); } } }); // *** define global constants for all dijit instances *** // com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._labelAttr: [const] String // Key of 'Label' attribute on FedDocAtomStore items com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._labelAttr = "title"; // com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr: [const] String // Key of 'Children' attribute on FedDocAtomStore items com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._childrenAttr = "children"; // com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr: [const] String // Key of 'ID' attribute on FedDocAtomStore items com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._idAttr = "id"; // com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr: [const] String // Key of 'baseType' attribute on FedDocAtomStore items com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._baseTypeAttr = "baseType"; // com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._expandedAttr: [const] String // Key of 'Expanded' attribute on FedDocAtomStore items com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._expandedAttr = "isExpanded"; // com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr: [const] String // Key of 'Loaded' attribute on FedDocAtomStore items com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._loadAttr = "isLoaded"; // com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._viewURLAttr: [const] String // Key of 'viewURL' attribute on FedDocAtomStore items com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._viewURLAttr = "contentLink"; // com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._downloadURLAttr: [const] String // Key of 'downloadURL' attribute on FedDocAtomStore items com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore._downloadURLAttr = "contentLink"; } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.CmisDocumentPickerPageWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.CmisDocumentPickerPageWidget"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.CmisDocumentPickerPageWidget"); dojo.registerModulePath("com.ibm.workplace.wcm.ecm.picker.widget","../com/ibm/workplace/wcm/ecm/picker/widget"); dojo.require("dijit.form.ToggleButton"); dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit.Tree"); dojo.declare('com.ibm.workplace.wcm.ecm.picker.widget.CmisDocumentPickerPageWidget', [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget], { // summary: // This widget implements the user interface for selecting documents and folders // from a federated documents repository // blankImgUrl: Object // URL pointing to a blank image (1x1 transparent pixel) blankImgUrl: dojo.moduleUrl("dojo", "resources/blank.gif").toString(), // minTreePaneWidth: [protected] Integer // The minimum width of a tree pane in pixels. If not enough space is available to have both // tree panes have the minimum size, they'll share the available space 50%/50%. minTreePaneWidth: 100, // namespace: [protected] String // The namespace this widget uses for building its user interface elements namespace: "cmisDocPckrPgWdgt_", // templatePath: // see dijit.Dialog templateString:"
\n
\n

\n \n

\n
\n \n \n \n
\n
\n
\n

\n \n

\n
\n \n \n \n
\n
\n
\n \"${_nlsUserInterface.docPickerPage.connectingToServerImgAlt}\"\n  ${_nlsUserInterface.docPickerPage.connectingToServerDivText}\n \n
\n
\n
\n
\n
\n
\n
\n ${_nlsUserInterface.docPickerPage.fedDocLibTreeHeaderText}\n \n \n \n \n \n \n
\n
\n \n \n
\n
\n
\n
\n
\n
\n ${_nlsUserInterface.docPickerPage.fedDocTreeHeaderText}\n \n \n \n
\n
\n \n
\n
\n
\n \"${_nlsUserInterface.docPickerPage.fedDocNoItemsInfoImgAlt}\"\n ${_nlsMessages.docPickerPage.noItemsMessage}\n
\n
\n
\n
\n
\n
\n

\n \n

\n
\n \n \n \n \n \n \n
\n
\n
\n
\n", // widgetsInTemplate: // see dijit.Dialog widgetsInTemplate: true, // _authenticationInfoMsg: [private] String // Informative message being displayed in the Federated Documents Picker // describing the selected authentication method _authenticationInfoMsg: "", // _authProperties: [private] Object // JSON object which holds information about the authentication settings. // Objects of the same format are being used for passing in authentication information to the Picker dialog // and for receiving changed authentication settings back from the AuthenticationWidget when the user // made changes. // // Allowed Identifiers are: // authType: String // The type of authentication selected // username: String // The username for username/password authentication // password: String // The password for username/password authentication // vaultSlotID: String // The credential vault slot ID for credential vault based authentication // vaultSlotTitle: String // The title for the credential vault slot ID for credential vault based authentication _authProperties: null, // _callingEnvironment: [private] String // Identifier of the context the Federated Documents Picker is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management // (default) _callingEnvironment: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm, // _containerWidthAtLastAutoTreeResize: [private] Integer // Variable holding the width in pixels of the BorderContainer that the tree widgets live in at the time // when the ContentPanes holding the tree widgets were auto-resized. This is needed to run auto-resize // only if the container size has changed and not every time the layout() method is called, which would // override manual changes by the user made using the splitter. _containerWidthAtLastAutoTreeResize: -1, // _docTreeSelectedItem: [private] Object // Variable holding the item, which is currently selected in the right-hand doctree widget. // Helper variable to keep track of the doctree selected item specifically to properly build // selected node path _docTreeSelectedItem: null, // _docTree: [private] Object // Instance of a dijit.Tree widget _docTree: null, // _eventHandles: [private] Array // Array of handles created when connecting events to methods _eventHandles: [], // _feedBaseURL: [private] String // Base URL (POC URL) from Portal, used for routing the requests through Portal Server to the // target CMIS server _feedBaseURL: null, // _feedType: [private] String // Feed type of the selected server. This value gets set by Picker Dialog code which // triggers the auto-detection _feedType: String, // _isA11yMode: [private] Boolean // Indicates whether or not the high-contrast mode (a11y) is enabled for the webpage this widget // is being shown in. _isA11yMode: false, // _isFolderPreviewOn: [private] Boolean // Indicates whether or not the right-hand tree view is being shown with the folder content // preview in PZN mode _isFolderPreviewOn: false, // _isRTLMode: [private] Boolean // Indicates whether or not a Right-To-Left language is active in the browser this widget // is being shown in. _isRTLMode: false, // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _libFolderItemFilter: [private] Object // Instance of a TreeItemFilter object which filters out documents in a tree view _libFolderItemFilter: null, // _libTree: [private] Object // Instance of a dijit.Tree widget _libTree: null, // _libTree: [private] Object // Instance of a dijit.Tree widget _libTreeModel: null, // _libTreeSelectedItem: [private] Object // Variable holding the item, which is currently selected in the left-hand libtree widget. // Helper variable to keep track of the libtree selected item specifically to properly build // selected node path _libTreeSelectedItem: null, // _nodeTypes: [private] Array // An array holding one or more string identifiers that define which node types // the tree widget displays in the picker dialog. Supported values are: 'folder', // 'repository' and 'document' _nodeTypes: [ "document", "folder" ], // _quickFilterDoc: [private] Object // QuickSearchTreeItemFilter instance which is used by the quick filter function of // the picker dialog to filter out any items in the doc tree that do not match the given // search term _quickFilterDoc: null, // _quickFilterLib: [private] Object // QuickSearchTreeItemFilter instance which is used by the quick filter function of // the picker dialog to filter out any items in the lib tree that do not match the given // search term _quickFilterLib: null, // _selectedItem: [private] Object // Variable holding the item that is currently selected in the tree widget. The tree widget // does not allow to retrieve the selected item at random. The value needs to be recorded by // registering an onSelectItem() callback. The callback function stores the value in this // variable for later use // This variable holds the selected item regardless of whether the selection was made in the // left-hand lib tree or right-hand doc tree. Since both trees use the same store, we do not // need to care about which tree was used (with the exception of building the path info). _selectedItem: null, //Selected folder path. RME requires the tree to open to a previously selected folder path. _selectedPath: [], // _serverUrl: [private] String // The server to connect to. Being passed in by the wizard from the server connection // widget. _serverUrl: "", // _serviceId: [private] String // Variable holding the ID of the selected documents service from the list with preset // federated documents servers _serviceId: "", // _serviceDocBaseURL: [private] String // Base URL (POC URL) from Portal, used for routing the requests through Portal Server to the // target CMIS server, in case the used CMIS Url points to a service document and therefore // needs different parsing. See _feedBaseUrl, which is used for all other types of CMIS // Urls. _serviceDocBaseURL: "", // _store: [private] Object // Instance of a FedDocAtomStore object, which interacts with Portal to retrieve information // about CMIS folders and documents that it displays in the tree widget for selection _store: null, // _treeModel: [private] Object // Instance of a dijit.tree.ForestStoreModel _treeModel: null, buildRendering: function() { // summary: // Constructs the user interface of this widget // tags: // protected // entry trace var m = "buildRendering()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, constructor: function(/*Object*/ p_params) { // summary: // Constructs this widget // p_params: Object // The parameters to instantiate this widget with // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.nodeTypes:", dojo.toJson(p_params.nodeTypes)); this.trace(m, "p_params.feedBaseURL:", p_params.feedBaseURL); this.trace(m, "p_params.callingEnvironment:", p_params.callingEnvironment); } } // namespace if (typeof p_params.namespace == 'string') { this.namespace = p_params.namespace; } // clear global arrays that we only push elements into, as opening multiple widget instances // might keep the array content from previous instances this._eventHandles = []; this._nodeTypes = ["document", "folder"]; if (dojo.isObject(p_params.nodeTypes)) { this._nodeTypes = p_params.nodeTypes; } if (typeof p_params.feedBaseURL == 'string') { this._feedBaseURL = p_params.feedBaseURL; } else { // Widget cannot work without the feedBaseURL if (this._isTracing) { this.error(m, "Parameter 'feedBaseURL' parameter missing on constructor arguments"); } } if (typeof p_params.serviceDocBaseURL == 'string') { this._serviceDocBaseURL = p_params.serviceDocBaseURL; } else { // Widget cannot work without the feedBaseURL if (this._isTracing) { this.error(m, "Parameter 'serviceDocBaseURL' parameter missing on constructor arguments"); } } // first, try to determine the environment, so we can compute the vaultSelectionEnabled // value ourselves, if it was not passed in as an argument if (p_params.callingEnvironment) { this._callingEnvironment = p_params.callingEnvironment; } // override folderPreview setting and set it to true for WCM env. as there's no way to switch it off in // this mode if (this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm) { this._isFolderPreviewOn = true; } // initialize the localized strings that are consumed by the parent dialog var nlsStrings = this._nlsUserInterface.docPickerPage; this._stepLabel = nlsStrings.stepLabel; // initialize the step description based on the context if (this._isCalledFromPZN()) { this._stepDescription = nlsStrings.stepDescriptionPZN; if(p_params.selectedPath){ this._selectedPath = p_params.selectedPath; } } else { this._stepDescription = nlsStrings.stepDescriptionWCM; } // exit trace if (this._isTracing) { this.traceExit(m); } }, destroyRecursive: function() { if (!this._isFolderPreviewOn) { // add the hidden DocTreePane back to the container to allow it to be // properly destroyed this.fedDocPickerBorderContainer.addChild(this.fedDocTreePane); } this.inherited(arguments); }, destroy: function() { // summary: // Destroys this widget // tags: // protected // entry trace var m = "destroy()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, getLibTree: function(){ var m = "getLibTree()"; if (this._isTracing) { this.traceEntry(m); } // exit trace if (this._isTracing) { this.traceExit(m, this._libTree); } return this._libTree; // Object }, getSelectedItem: function() { // summary: // Returns the item that is currently selected in the tree widget // returns: // The selected item // tags: // public // entry trace var m = "getSelectedItem()"; if (this._isTracing) { this.traceEntry(m); } // exit trace if (this._isTracing) { this.traceExit(m, this._selectedItem); } return this._selectedItem; // Object }, getSelectedItemJSON: function() { // summary: // Returns the item that is currently selected in the tree widget as a JSON object // returns: // The selected item as a JSON object // tags: // public // entry trace var m = "getSelectedItemJSON()"; if (this._isTracing) { this.traceEntry(m); } var result = { "title": this._store.getLabel(this._selectedItem), "url": this._store.getViewURL(this._selectedItem) }; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Object }, initializePage: function(/*Object*/ p_params) { // summary: // Method being called to initialize this "wizard page widget" for display // with data from the previous page (if needed) // p_params: // The parameters to initialize this widget // tags: // public // entry trace var m = "initializePage(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.authProperties: ", dojo.toJson(p_params.authProperties)); this.trace(m, "p_params.authInfoMsg: ", p_params.authInfoMsg); this.trace(m, "p_params.feedType: ", p_params.feedType); this.trace(m, "p_params.serverUrl: ", p_params.serverUrl); this.trace(m, "p_params.serviceId: ", p_params.serviceId); } } // detect high-contrast mode (a11y) var bodyElem = dojo.query("body")[0]; if (dojo.hasClass(bodyElem, "dijit_a11y")) { this._isA11yMode = true; } else { this._isA11yMode = false; } if (dojo.hasClass(bodyElem, "lotus_rtl")) { this._isRTLMode = true; } else { this._isRTLMode = false; } if (this._isTracing) { this.trace(m, "dijit_a11y mode: ", this._isA11yMode); this.trace(m, "lotus_rtl mode: ", this._isRTLMode); } if (this._isRTLMode) { // change floating of 'Filter:' label in RTL mode dojo.style(this.fedDocLibTreeFilterLabel, 'float', 'right'); dojo.style(this.fedDocTreeFilterLabel, 'float', 'right'); } this._clearSelectedItem(); // call with no parameter to let it render the default "Nothing selected" message if (p_params) { if (p_params.authProperties) { this._authProperties = p_params.authProperties; } if (p_params.authInfoMsg) { this._authInfoMsg = p_params.authInfoMsg; dojo.attr(this.pickerAuthInfo, 'innerHTML', this._authInfoMsg); } else { dojo.attr(this.pickerAuthInfo, 'innerHTML', ""); } if (p_params.serverUrl) { this._serverUrl = p_params.serverUrl; dojo.attr(this.pickerServerUrl, 'innerHTML', this._serverUrl); } else { dojo.attr(this.pickerServerUrl, 'innerHTML', ""); } if (p_params.feedType) { this._feedType = p_params.feedType; } else { this._feedType = null; } if (p_params.serviceId) { this._serviceId = p_params.serviceId; } else { this._serviceId = ""; } this._connectToServer(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, layout: function() { // see com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget.layout() // entry trace var m = "layout()"; if (this._isTracing) { this.traceEntry(m); } if (this.fedDocTreePane && (this._isFolderPreviewOn === true)) { // align tree panes 50% / 50% horizontally, so that none of the two panes is either fully invisible // or very small / large after resize. // we can only resize the right pane, which is the libTreePane, as trying to resize the left-hand // auto-sized pane wouldn't work var availableWidth = dojo.contentBox(this.fedDocPickerBorderContainer.domNode).w; if (availableWidth !== this._containerWidthAtLastAutoTreeResize) { this._containerWidthAtLastAutoTreeResize = availableWidth; dojo.marginBox(this.fedDocTreePane.domNode, { "w": (availableWidth * 0.5) }); // force BorderContainer to update it's internal _borderBox variable, as it's domNode was // resized this.fedDocPickerBorderContainer.resize(); // have the BorderContainer layout it's children this.fedDocPickerBorderContainer.layout(); } } // make the fedDocPickerBorderContainer use as much space as possible vertically, in case the // dialog was resized in height // first get the height of all static parts of the CMIS Picker page, then assign the available // space as height value to the fedDocPickerBorderContainer if (this.virtualContainerNodeHeight) { var staticHeight = dojo.marginBox(this.pickerServerSectionDiv).h + dojo.marginBox(this.pickerAuthenticationSectionDiv).h + dojo.marginBox(this.pickerSelectedItemDiv).h + 30; // take paddings and margins into account var availableHeight = this.virtualContainerNodeHeight; var minHeight = dojo.style(this.fedDocPickerResponseContainer, "min-height"); var newHeight = Math.max(minHeight, availableHeight - staticHeight); // set new height on BorderContainer dojo.style(this.fedDocPickerResponseContainer, "height", newHeight + "px"); } // update the trees so that they always fully use the available space within their BorderContainer this._updateTreeLayout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, onShow: function() { // summary: // Defined by dijit._Widget. // Callback that is executed when this widget becomes the selected pane in the dijit.layout.StackContainer // of the [com.ibm.workplace.wcm.ecm.picker.dialog.FederatedDocumentsPickerDialog] // tags: // protected // entry trace var m = "onShow()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // ensure the BorderContainer is resized to display the two contained // content panes next to each other and properly sized this.fedDocPickerBorderContainer.resize(); // exit trace if (this._isTracing) { this.traceExit(m); } }, postCreate: function() { // summary: // Binds resources required by this widget after its DOM has been set up // tags: // protected // entry trace var m = "postCreate()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // by default, hide the two filter DIVs this._setFilterSectionVisible(this.fedDocLibTreeFilterDiv, null, false, false); this._setFilterSectionVisible(this.fedDocTreeFilterDiv, null, false, false); this._initEventHandles(); this._quickFilterDoc = new com.ibm.workplace.wcm.ecm.picker.widget.filter.QuickSearchTreeItemFilter({}); this._quickFilterLib = new com.ibm.workplace.wcm.ecm.picker.widget.filter.QuickSearchTreeItemFilter({}); this._libFolderItemFilter = new com.ibm.workplace.wcm.ecm.picker.widget.filter.LibFolderTreeItemFilter({ "itemFilter": this._quickFilterLib }); if (this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn) { // if in PZN env, display the "Preview on/off" link in the column header dojo.style(this.fedDocPreviewLinkSpan, 'display', 'inline'); dijit.setWaiState(this.fedDocPreviewLinkSpan, 'hidden', false); // act on the default value of _isFolderPreviewOn and hide the Doc Tree Pane, if necessary if (!this._isFolderPreviewOn) { this._hideDocTreePane(); } } // initialize Hover/Title texts of all togglebuttons on the page this._changeNodeTitleText(this.fedDocQuickFilterToggleButton, this._nlsUserInterface.docPickerPage.docFilterToggleBtnOffTitle); this._changeNodeTitleText(this.fedDocLibQuickFilterToggleButton, this._nlsUserInterface.docPickerPage.libFilterToggleBtnOffTitle); this._changeNodeTitleText(this.fedDocPreviewLink, this._nlsUserInterface.docPickerPage.previewOffTitle); // exit trace if (this._isTracing) { this.traceExit(m); } }, startup: function() { // summary: // Called when the creation of this widget is completed to perform operations that require this widget to be fully rendered // tags: // protected // entry trace var m = "startup()"; if (this._isTracing) { this.traceEntry(m); } // Important: make sure to call the BorderContainer startup method, so // the split panes get correctly set up this.fedDocPickerBorderContainer.startup(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, uninitialize: function() { // summary: // Releases the resources bound by this widget before it is destroyed // tags: // protected // entry trace var m = "uninitialize()"; if (this._isTracing) { this.traceEntry(m); } // disconnect the callbacks from their related events this._clearEventHandles(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, _adjustTreePaneHeight: function(/*DomNode*/ p_domNode, /*DomNode?*/ p_otherDomNode, /*Integer?*/ p_otherDomNodesHeight) { // summary: // Animates the closing of the section represented by the given DOM node // p_domNode: // The static size domNode // p_otherDomNode: // The dynamically sized domNode referenced. Size of this domNode will be adapted. // p_otherDomNodesHeight: // If there are more other domNodes that are static in height and don't have to // be adjusted, but decrease the available vertical space in the parent domNode of // p_domNode, provide the combined height of those domNodes in pixels here // tags: // private // entry trace var m = "_adjustTreePaneHeight(p_domNode, p_otherDomNode, p_otherDomNodesHeight)"; if (this._isTracing) { this.traceEntry(m, [p_domNode, p_otherDomNode, p_otherDomNodesHeight]); } if (p_otherDomNode && (typeof p_otherDomNode == 'object')) { // adjust the height of the other DomNode, to match parent's height - p_sectionDomNode's height // check for the parentNode, as code won't work, if this is a top-level node if (p_domNode.parentNode) { var parentDomNode = p_domNode.parentNode; // if parentNode is a dijit, use the domNode property to work with // the actual domNode, not the dijit instance if (p_domNode.parentNode.domNode) { parentDomNode = p_domNode.parentNode.domNode; } var parentHeight = dojo.marginBox(p_domNode.parentNode).h; var sectionHeight = dojo.marginBox(p_domNode).h; // check if section is visible at all (if it is hidden, contentBox will report a height of // zero). If it is hidden, use the sectionHeight (0) instead of the marginBox height if (dojo.contentBox(p_domNode).h === 0) { sectionHeight = 0; } if (p_otherDomNodesHeight) { dojo.marginBox(p_otherDomNode, { "h": parentHeight - sectionHeight - p_otherDomNodesHeight}); } else { dojo.marginBox(p_otherDomNode, { "h": parentHeight - sectionHeight }); } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _animateCloseFilterSection: function(/*DomNode*/ p_domNode, /*DomNode?*/ p_otherDomNode, /*Integer?*/ p_otherDomNodesHeight) { // summary: // Animates the closing of the section represented by the given DOM node // p_domNode: // The DOM node to hide in an animated manner // p_otherDomNode: // If set, this parameter points to another domNode is are also present in the // same container as p_domNode and whose size needs to be adjusted accordingly // p_otherDomNodesHeight: // If there are more other domNodes that are static in height and don't have to // be adjusted, but decrease the available vertical space in the parent domNode of // p_domNode, provide the combined height of those domNodes in pixels here // tags: // private // entry trace var m = "_animateCloseFilterSection(p_domNode, p_otherDomNode, p_otherDomNodesHeight)"; if (this._isTracing) { this.traceEntry(m, [p_domNode, p_otherDomNode, p_otherDomNodesHeight]); } if (!dojo.hasClass(p_domNode, 'lotusHidden')) { dojo.style(p_domNode, 'overflow', 'hidden'); dojo.animateProperty({ "node": p_domNode, "duration": 500, "properties": { "height": { "end": 0, "units": "px" } }, "onEnd": dojo.hitch(this, function() { dojo.addClass(p_domNode, 'lotusHidden'); dijit.setWaiState(p_domNode, 'hidden', true); dijit.removeWaiState(p_domNode, 'expanded'); if (p_otherDomNode && (typeof p_otherDomNode == 'object')) { // adjust the height of the other DomNode, to match parent's height - p_sectionDomNode's height this._adjustTreePaneHeight(p_domNode, p_otherDomNode, p_otherDomNodesHeight); } }) }).play(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _animateOpenFilterSection: function(/*DomNode*/ p_domNode, /*DomNode?*/ p_otherDomNode, /*Integer*/ p_targetHeight, /*Integer?*/ p_otherDomNodesHeight) { // summary: // Animates the opening of the section represented by the given DOM node // p_domNode: // The DOM node to show in an animated manner // p_otherDomNode: // If set, this parameter points to another domNode that is also present in the // same container as p_domNode and whose size needs to be adjusted accordingly // p_targetHeight: // The eventual height of the section at the end of the animation // p_otherDomNodesHeight: // If there are more other domNodes that are static in height and don't have to // be adjusted, but decrease the available vertical space in the parent domNode of // p_domNode, provide the combined height of those domNodes in pixels here // tags: // private // entry trace var m = "_animateOpenFilterSection(p_domNode, p_otherDomNode, p_targetHeight, p_otherDomNodesHeight)"; if (this._isTracing) { this.traceEntry(m, [p_domNode, p_otherDomNode, p_targetHeight, p_otherDomNodesHeight]); } if (dojo.hasClass(p_domNode, 'lotusHidden')) { dojo.style(p_domNode, 'overflow', 'hidden'); dojo.style(p_domNode, 'height', '0ex'); dojo.removeClass(p_domNode, 'lotusHidden'); dojo.marginBox(p_domNode, { h: 0 }); dijit.setWaiState(p_domNode, 'hidden', false); dijit.setWaiState(p_domNode, 'expanded', true); dojo.animateProperty({ "node": p_domNode, "duration": 500, "properties": { "height": { "end": p_targetHeight, "units": "ex" } }, "onEnd": dojo.hitch(this, function() { dojo.marginBox(p_domNode, { h: p_targetHeight }); dojo.style(p_domNode, 'height', p_targetHeight + "ex"); if (p_otherDomNode && (typeof p_otherDomNode == 'object')) { // adjust the height of the other DomNode, to match parent's height - p_sectionDomNode's height this._adjustTreePaneHeight(p_domNode, p_otherDomNode, p_otherDomNodesHeight); } this._updateFilterLayout(); }) }).play(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _autoResizeLabelAndInput: function(/*Object*/ p_newContainerSize, /*DomNode*/ p_labelNode, /*DomNode*/ p_inputNode, /*Integer*/ p_minInputWidth) { // summary: // // p_newContainerSize: Object // A json object, containing at least one property 'w' holding the new width of the parent // container of the given p_labelNode and p_inputNode tag // p_labelNode: DomNode // // p_inputNode: DomNode // // p_minInputWidth: Integer // // tags: // private // entry trace var m = "_autoResizeLabelAndInput(p_newContainerSize, p_labelNode, p_inputNode, p_minInputWidth)"; if (this._isTracing) { this.traceEntry(m, [p_newContainerSize, p_labelNode, p_inputNode, p_minInputWidth]); } if (p_newContainerSize && p_newContainerSize.w) { var availableWidth = Math.max(0, p_newContainerSize.w); // arrange the filter nodes, so they won't wrap, if the ContentPane gets too small var neededLabelWidth = Math.max(p_labelNode.scrollWidth, p_labelNode.offsetWidth); var labelWidth = dojo.marginBox(p_labelNode).w; var inputWidth = dojo.marginBox(p_inputNode).w; var marginWidth = 16; if (availableWidth < neededLabelWidth + p_minInputWidth + marginWidth) { // not enough space for labe text + minimum size of input box, so cut off text var newLabelWidth = Math.max(0, availableWidth - p_minInputWidth - marginWidth); if (newLabelWidth >= 0) { dojo.style(p_labelNode, 'width', newLabelWidth + "px"); } dojo.style(p_labelNode, 'overflow', 'hidden'); if (availableWidth < p_minInputWidth + marginWidth) { // also decrease the inputNode's width, as the label is invisible (fully cut) // already anyway if (availableWidth >= 0) { dojo.style(p_inputNode, 'width', availableWidth + "px"); } dojo.style(p_inputNode, 'overflow', 'hidden'); } else { // set the input field to it's minimum size here dojo.style(p_inputNode, 'width', p_minInputWidth + "px"); dojo.style(p_inputNode, 'overflow', 'none'); } } else { // there seems to be enough space for at least the minimum size input box + the fully // shown label, so set the label width to auto and size the input box to a width that // fills the remaining space dojo.style(p_labelNode, 'width', 'auto'); dojo.style(p_labelNode, 'overflow', 'visible'); // calculate available space for input box var availableSpaceForInputBox = availableWidth - neededLabelWidth - marginWidth; if (availableSpaceForInputBox >= 0) { dojo.style(p_inputNode, 'width', availableSpaceForInputBox + "px"); } dojo.style(p_inputNode, 'overflow', 'visible'); } } }, _autoResizeTextAndControl: function(/*Object*/ p_newContainerSize, /*DomNode*/ p_textNode, /*DomNode*/ p_controlNode) { // summary: // Resizes the given p_textNode and p_controlNode (could be a DIV or floating SPAN, inline SPANs // do not work) in a way that will allow them to still show within their parent container that // has been resized to p_newContainerSize.w (this is an object, as it is being passed in into // the resize(changeSize, resultSize) method (resultSize object). // p_newContainerSize: Object // A json object, containing at least one property 'w' holding the new width of the parent // container of the given p_textNode and p_controlNode tag // p_textNode: DomNode // DomNode for the text being shown. Could be a DIV or floating SPAN. Spans without float // won't work, as their width cannot be set. // p_controlNode: DomNode // DomNode for the controls being shown. Could be a DIV or floating SPAN. Spans without float // won't work, as their width cannot be set. If you have more controls floating on the right // or left, make sure to surround them with a wrapping SPAN/DIV that you pass into this method // to resize that container for all controls at once. // tags: // private // entry trace var m = "_autoResizeTextAndControl(p_newContainerSize, p_textNode, p_controlNode)"; if (this._isTracing) { this.traceEntry(m, [p_newContainerSize, p_textNode, p_controlNode]); } if (p_newContainerSize && p_newContainerSize.w) { var availableWidth = Math.max(0, p_newContainerSize.w); // arrange the column header, so it won't wrap, if the ContentPane gets too small var neededTextSpanWidth = Math.max(p_textNode.scrollWidth, p_textNode.offsetWidth); var neededButtonSpanWidth = Math.max(p_controlNode.scrollWidth, p_controlNode.offsetWidth); var textSpanWidth = dojo.marginBox(p_textNode).w; var buttonSpanWidth = dojo.marginBox(p_controlNode).w; var marginWidth = 10; if (availableWidth < neededTextSpanWidth + neededButtonSpanWidth + marginWidth) { // not enough space to show everything, so cut down the text length to keep buttons // visible var newTextSpanWidth = Math.max(0, availableWidth - neededButtonSpanWidth - marginWidth); if (newTextSpanWidth >= 0) { dojo.style(p_textNode, 'width', newTextSpanWidth + "px"); } dojo.style(p_textNode, 'overflow', 'hidden'); } else { dojo.style(p_textNode, 'width', 'auto'); dojo.style(p_textNode, 'overflow', 'visible'); } } }, _buildLibTreePath: function() { // summary: // Returns the full path of the item currently selected in the library tree as string // returns: // JSON object which contains the path, file and fullpath information for the currently // selected item in the libTree. // tags: // private // entry trace var m = "_buildLibTreePath()"; if (this._isTracing) { this.traceEntry(m); } var items = this._libTree.attr('path'); // the path without the last element (could be doc or folder) var path = ""; // the last element of the path only var file = ""; // the full path, including the last element var fullpath = ""; var result = ""; var startIndex = 0; // check whether tree's root node item has 'root' attribute set to true and omit // first path part in this case var rootNode = this._libTree.rootNode; if (rootNode && rootNode.item && (rootNode.item.root === true)) { startIndex = 1; } // omit the invisible root item for (var i = startIndex; i < items.length; i++) { var itemLabel = this._store.getLabel(items[i]); // trace if (this._isTracing) { this.trace(m, i + ". item on path:", itemLabel); } // always replace file with the current label, so that it contains // the last element at the end only file = itemLabel; fullpath += itemLabel; if (i < items.length - 1) { fullpath += " / "; } // path handling, like for fullpath, but omit the last element if (i < items.length - 1) { path += itemLabel; path += " / "; } } result = { "path": path, "file": file, "fullpath": fullpath }; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _buildPathForSelectedItem: function() { // summary: // Returns the full path of the currently selected item as string regardless // of whether the selection occurs in the library or document tree // returns: // JSON object with the path and leaf element (could be a folder itself or a document) // as separate values (for filling path and filename spans) and a combined value // for filling an HTML title/alt text field // tags: // private // entry trace var m = "_buildPathForSelectedItem()"; if (this._isTracing) { this.traceEntry(m); } var result = null; // easy in pzn environment, as we only have the libTree in this case if (this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn) { result = this._buildLibTreePath(); } else { // wcm environment // Check, which tree the user selected the entry in by comparing // the tree specific selected items with the global selected item // variable, which holds the 'actual' user selection // trace if (this._isTracing) { this.trace(m, "Selected item from library tree:", this._libTreeSelectedItem); this.trace(m, "Selected item from document tree:", this._docTreeSelectedItem); this.trace(m, "Currently selected item:", this._selectedItem); } var libTreePath = this._buildLibTreePath(); if (this._docTreeSelectedItem == this._selectedItem) { // user made selection in the doc tree, so concat path from libTree with // the selected item from docTree result = { "path": libTreePath.fullpath + " / ", "file": this._store.getLabel(this._docTreeSelectedItem), "fullpath": libTreePath.fullpath + " / " + this._store.getLabel(this._docTreeSelectedItem) }; } else { // user made selection in the lib tree, so grab path from there only result = libTreePath; } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _calcDomNodesHeight: function(/*DomNode[]*/ p_domNodes) { // summary: // Sums up the margin-box height values of all the given domNodes in the p_domNodes // array and returns the sum as the result // p_domNodes: // Array of domNode elements // returns: Integer // The sumed up height (in px) of all given domNodes as a pixel value // tags: // private // entry trace var m = "_calcDomNodesHeight(p_domNodes)"; if (this._isTracing) { this.traceEntry(m, p_domNodes); } var heightSum = 0; if (p_domNodes && dojo.isArray(p_domNodes)) { dojo.forEach(p_domNodes, function(domNode) { if (domNode) { if (domNode.domNode) { // in case the given domNode is actually a dijit reference, use it's // domNode reference instead heightSum += dojo.marginBox(domNode.domNode).h; } else { heightSum += dojo.marginBox(domNode).h; } } }); } // exit trace if (this._isTracing) { this.traceExit(m, heightSum); } return heightSum; }, _changeNodeTitleText: function(/*Object*/ p_domNode, /*String*/ p_newTitleText) { // summary: // // tags: // private // entry trace var m = "_changeNodeTitleText(p_domNode, p_newTitleText)"; if (this._isTracing) { this.traceEntry(m, [p_domNode, p_newTitleText]); } dojo.attr(p_domNode, 'title', p_newTitleText); // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearEventHandles: function() { // summary: // Disconnects the events supported by this dialog from the corresponding callback methods // tags: // private // entry trace var m = "_clearEventHandles()"; if (this._isTracing) { this.traceEntry(m); } dojo.forEach(this._eventHandles, dojo.disconnect); this._eventHandles = []; // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearSelectedItem: function() { // summary: // Clears the _selectedItem property, as well as specific _docTreeSelectedItem and // _libTreeSelected item properties. Renders the default 'Nothing selected' message // at the bottom of the tree views. // tags: // private // entry trace var m = "_clearSelectedItem()"; if (this._isTracing) { this.traceEntry(m); } this._selectedItem = null; this._docTreeSelectedItem = null; this._libTreeSelectedItem = null; var _title = this._nlsUserInterface.docPickerPage.nothingSelectedText; dojo.addClass(this.pickerSelectedItem, 'feddocNoSelection'); dojo.attr(this.pickerSelectedItem, 'innerHTML', _title); dojo.attr(this.pickerSelectedItem, 'title', _title); dojo.attr(this.pickerSelectedItemPath, 'innerHTML', ""); dojo.attr(this.pickerSelectedItemPath, 'title', ""); // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearTree: function() { // summary: // Removes the Document Tree from the DOMTree, either as a preparation for recreating it with // a new parent reference, or to clear it, if no selection is made in the lib tree // tags: // private // entry trace var m = "_clearTree()"; if (this._isTracing) { this.traceEntry(m); } var treeID = this.id + '_docTree'; // first, some housekeeping (destroy the tree widget, if it already // exists) var tree = dijit.byId(treeID); if (tree) { tree.destroyRecursive(false); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _connectToServer: function() { // summary: // Performs the actual server connection. Showing a 'Connecting to server' pop-up DIV with // loading animation that is removed once the store comes back from its initial asynchronous // request (be it successful or not) // tags: // private // entry trace var m = "_connectToServer()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Server URL:", this._serverUrl); this.trace(m, "Authentication settings:", dojo.toJson(this._authProperties)); } this._setupLibTree(this._serverUrl); // exit trace if (this._isTracing) { this.traceExit(m); } }, _getLibTreeIconClass: function(/*Item*/ p_item, /*Boolean?*/ p_opened) { // summary: // Returns the icon class to use for the specified item in the right dijit.Tree on // the left side that shows the folders and repositories. // This is particularly important for folders displayed in the document tree, where // we don't want to '+' expand icon to be displayed by the tree widget but // still want the folder to use a folder icon // p_item: // The item to return the icon class for // p_opened: // The indicator as to whether the given item is open or closed in case the item // is identified to be a folder // returns: // The icon class to use for the given item as string // tags: // private // entry trace var m = "_getLibTreeIconClass(p_item, p_opened)"; if (this._isTracing) { this.traceEntry(m, [p_item, p_opened]); } var result = ""; if (p_item) { if (this._store.isRepositoryItem(p_item)) { result = p_opened ? "dijitRepositoryOpened" : "dijitRepositoryClosed"; } else { result = p_opened ? "dijitFolderOpened" : "dijitFolderClosed"; } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _getDocTreeIconClass: function(/*Item*/ p_item, /*Boolean?*/ p_opened) { // summary: // Returns the icon class to use for the specified item in the right dijit.Tree on // the right side that shows the folders and documents. // This is particularly important for folders displayed in the document tree, where // we don't want to '+' expand icon to be displayed by the tree widget but // still want the folder to use a folder icon // p_item: // The item to return the icon class for // p_opened: // The indicator as to whether the given item is open or closed in case the item // is identified to be a folder // returns: // The icon class to use for the given item as string // tags: // private // entry trace var m = "_getDocTreeIconClass(p_item, p_opened)"; if (this._isTracing) { this.traceEntry(m, [p_item, p_opened]); } var result = ""; if (p_item) { if (this._store.isFolderItem(p_item)) { result = p_opened ? "dijitFolderOpened" : "dijitFolderClosed"; } else { result = "dijitLeaf"; } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _hideConnectingBox: function() { // summary: // Hides the element showing a message indicating that a server // connection is about to be established // tags: // private // entry trace var m = "_hideConnectingBox()"; if (this._isTracing) { this.traceEntry(m); } dojo.style(this.fedDocPickerConnectingDiv, 'display', 'none'); dijit.setWaiState(this.fedDocPickerConnectingDiv, 'hidden', true); dijit.setWaiState(this.fedDocPickerResponseContainer, 'busy', false); // exit trace if (this._isTracing) { this.traceExit(m); } }, _hideDocTreePane: function() { // summary: // Hides the ContentPane in the TreeContainer which shows the Document Tree // as well as the splitter between the two ContentPanes // tags: // private // entry trace var m = "_hideDocTreePane()"; if (this._isTracing) { this.traceEntry(m); } this.fedDocPickerBorderContainer.removeChild(this.fedDocTreePane); this.fedDocPickerBorderContainer.layout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _hideNoItemsInfo: function() { // entry trace var m = "_hideNoItemsInfo()"; if (this._isTracing) { this.traceEntry(m); } dojo.style(this.fedDocNoItemsInfoDiv, 'display', 'none'); dijit.setWaiState(this.fedDocNoItemsInfoDiv, 'hidden', true); // exit trace if (this._isTracing) { this.traceExit(m); } }, _initEventHandles: function() { // summary: // Connects the events supported by this widget to the corresponding callback methods // and stores the handles in the _eventHandles array // tags: // private // entry trace var m = "_initEventHandles()"; if (this._isTracing) { this.traceEntry(m); } this._eventHandles.push(dojo.connect( this.fedDocQuickFilterToggleButton, "onChange", dojo.hitch(this, "_onQuickFilterDocToggle"))); this._eventHandles.push(dojo.connect( this.fedDocLibQuickFilterToggleButton, "onChange", dojo.hitch(this, "_onQuickFilterLibToggle"))); this._eventHandles.push(dojo.connect( this.fedDocTreeFilterTextBox, "onChange", dojo.hitch(this, "_onQuickFilterDocTextChanged"))); this._eventHandles.push(dojo.connect( this.fedDocLibTreeFilterTextBox, "onChange", dojo.hitch(this, "_onQuickFilterLibTextChanged"))); this._eventHandles.push(dojo.connect( this.fedDocPreviewLink, "onChange", dojo.hitch(this, "_onPreviewLinkClicked"))); this._eventHandles.push(dojo.connect( this.feddocResponseForm, "onsubmit", dojo.hitch(this, "_onSubmit"))); // connect to resize() calls on the two tree panes, so we can re-arrange the column headers this._eventHandles.push(dojo.connect( this.fedDocLibTreePane, "resize", dojo.hitch(this, "_onLibTreePaneResized"))); this._eventHandles.push(dojo.connect( this.fedDocTreePane, "resize", dojo.hitch(this, "_onTreePaneResized"))); // exit trace if (this._isTracing) { this.traceExit(m); } }, _isCalledFromPZN: function() { // summary: // Returns an indication as to whether this widget is rendered in the context of Personalization // returns: // true if the rendering context is Personalization, false otherwise // tags: // private // entry trace var m = "_isCalledFromPZN()"; if (this._isTracing) { this.traceEntry(m); } var result = this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _isCalledFromWCM: function() { // summary: // Returns an indication as to whether this widget is rendered in the context of Web Content Management // returns: // true if the rendering context is Web Content Management, false otherwise // tags: // private // entry trace var m = "_isCalledFromWCM()"; if (this._isTracing) { this.traceEntry(m); } var result = this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _onCmisPageErrorStateChanged: function(/*Object*/ p_sender, /*Boolean*/ p_errorState, /*String*/ p_errorMsg, /*String?*/ p_errorDetails) { // summary: // Callback function triggered by the Authentication widget // if it changed into an error state or changed back from // an error state. Used to report error/no error conditions // up the chain (have to use another name, as _onErrorStateChanged is already // the pointer back to the callback function of the dialog) // p_sender: Object // The widget instance sending this error to this dialog. // p_errorState: Boolean // The flag indicating whether the calling widget went into error state, or whether the // error state was left. // p_errorMsg: String // The error message to display // p_errorDetails: String // Optional string with a more detailed description of the error // tags: // private callback var m = "_onCmisPageErrorStateChanged(p_sender, p_errorState, p_errorMsg, p_errorDetails)"; if (this._isTracing) { this.traceEntry(m, [p_sender, p_errorState, p_errorMsg, p_errorDetails]); } if (p_errorState === true) { this._showError(p_errorMsg, p_errorDetails); } else { if (p_errorState === false) { this._clearError(); } else { // p_errorState is not a Boolean value } } if (this._isTracing) { this.traceExit(m); } }, _onLibTreeFocused: function() { // summary: // Callback method that is triggered when the libTree receives the input // focus. Primarily used to update the aria-activedescendant property on // the BorderContainer. // tags: // private callback // entry trace var m = "_onLibTreeFocused()"; if (this._isTracing) { this.traceEntry(m, []); } dijit.setWaiState(this.fedDocPickerBorderContainer.domNode, 'activedescendant', this._libTree.get('id')); if (this._isTracing) { this.traceExit(m); } }, _onLibTreeLoaded: function() { // summary: // Callback method that is triggered when the libTree finishes loading // the topLevel nodes // tags: // private callback // entry trace var m = "_onLibTreeLoaded()"; if (this._isTracing) { this.traceEntry(m, [p_item, p_node]); } this._hideConnectingBox(); if(this._selectedPath && this._selectedPath.length >0){ this._libTree.set('path',this._selectedPath); }else{ dijit.focus(dijit.getFirstInTabbingOrder(this._libTree.domNode/*this.domNode*/)); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onLibTreeNodeClick: function(/*Item*/ p_item, /*DomNode*/ p_node) { // summary: // Callback method that is triggered when the user selects an item in the // library tree // p_item: // The item in the dojo data store connected to the library tree // p_node: // The TreeNode of the selected item // tags: // private callback // entry trace var m = "_onLibTreeNodeClick(p_item, p_node)"; if (this._isTracing) { this.traceEntry(m, [p_item, p_node]); } // hide connecting box here to be sure it disappears // when user works with the tree this._hideConnectingBox(); if (this._store.isFolderItem(p_item) || this._store.isRepositoryItem(p_item)) { this._setSelectedItem(p_item); // set selected item to the folder selected, as folders can be // selected in the libTree in both calling environments this._libTreeSelectedItem = p_item; // only set up the doctree, if it is shown in the dialog. // this._isFolderPreviewOn is always true for WCM environments, but only true in PZN environment // if the preview pane is on if (this._isFolderPreviewOn) { this._setupTree(this._store.getIdentity(p_item)); } } else { this._clearSelectedItem(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onLibTreeNodeClose: function(/*Item*/ p_item, /*DomNode*/ p_node) { // summary: // Callback method that is triggered when the user closes a folder in the // library tree // p_item: // The item in the dojo data store connected to the library tree // p_node: // The TreeNode of the closed item // tags: // private callback var m = "_onLibTreeNodeClose(p_item, p_node)"; if (this._isTracing) { this.traceEntry(m, [p_item, p_node]); } // hide connecting box here to be sure it disappears // when user works with the tree this._hideConnectingBox(); if (this._store.isFolderItem(p_item) || this._store.isRepositoryItem(p_item)) { // mark this item as expanded in the FedDocAtomStore, so we can decide on filtering // child items based on the expanded=true|false state this._store.setItemExpanded(p_item, false); } // we need to trigger the _onLibTreeNodeClick method here, because otherwise clicking just // on the minus symbol on a folder, would close it, move visual selection to that entry // but the selection in the right-hand doc tree would not be updated. this._onLibTreeNodeClick(p_item, p_node); if (this._isTracing) { this.traceExit(m); } }, _onLibTreeNodeOpen: function(/*Item*/ p_item, /*DomNode*/ p_node) { // summary: // Callback method that is triggered when the user opens a folder in the // library tree // p_item: // The item in the dojo data store connected to the library tree // p_node: // The TreeNode of the opened item // tags: // private callback var m = "_onLibTreeNodeOpen(p_item, p_node)"; if (this._isTracing) { this.traceEntry(m, [p_item, p_node]); } // hide connecting box here to be sure it disappears // when user works with the tree this._hideConnectingBox(); if (this._store.isFolderItem(p_item) || this._store.isRepositoryItem(p_item)) { // check whether the selected item in the library tree is still the item // that was opened. If not, don't react on this event var selItem = this._libTree.attr('selectedItem'); if (selItem === p_item) { this._setSelectedItem(p_item); // set selected item to the folder selected, as folders can be // selected in the libTree in both calling environments this._libTreeSelectedItem = p_item; this._setupTree(this._store.getIdentity(p_item)); } // mark this item as expanded in the FedDocAtomStore, so we can decide on filtering // child items based on the expanded=true|false state this._store.setItemExpanded(p_item, true); } if (this._isTracing) { this.traceExit(m); } }, _onLibTreePaneResized: function(/*Object*/ p_changeSize, /*Object*/ p_resultSize) { // summary: // This method is being called, when the libTree ContentPane was resized. // p_changeSize is always null and the parameter p_resultSize is an // object with two properties h (height) and w (width), which contain // the width/height of the ContentPane after the resize took place. // p_changeSize: Object // If set, this method has to change the size of the libTree Pane to the // provided size value. However, since we just hitch this method additionally // to the default implementation of the method, this parameter is always // null and will be ignored. // p_resultSize: Object // This objects holds the width and height information of the libTree ContentPane // after a resize took place (by using the splitter for example). // tags: // private callback var m = "_onLibTreePaneResized(p_changeSize, p_resultSize)"; if (this._isTracing) { this.traceEntry(m, [p_changeSize, p_resultSize]); } var dimLibTreePane = dojo.marginBox(this.fedDocLibTreePane.domNode); if (p_resultSize && p_resultSize.w) { // there's a dojo bug that seems to send wrong width information, if the dialog got resized. // Therefore, we need to get the actual width ourselves here. p_resultSize.h = dimLibTreePane.h; p_resultSize.w = dimLibTreePane.w; } else { p_resultSize = { w: dimLibTreePane.w, h: dimLibTreePane.h }; } this._autoResizeTextAndControl(p_resultSize, this.fedDocLibTreeHeaderText, this.fedDocLibTreeHeaderButtons); this._autoResizeLabelAndInput(p_resultSize, this.fedDocLibTreeFilterLabel, this.fedDocLibTreeFilterTextBox.domNode, 40); // do nothing, if the p_resultSize parameter is not set if (this._isTracing) { this.traceExit(m); } }, _onQuickFilterDocTextChanged : function() { // summary: // Callback method that is triggered when the user changes the quick filter text for the documents tree // tags: // private callback // entry trace var m = "_onQuickFilterDocTextChanged()"; if (this._isTracing) { this.traceEntry(m); } this._onQuickFilterTextChanged(this._docTree, this._treeModel, this._quickFilterDoc, this.fedDocTreeFilterTextBox.attr("value")); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onQuickFilterDocToggle: function(/*Boolean*/ p_newValue) { // summary: // Called when the toggle button for showing/hiding the Quick Filter bar for documents // changes state // p_newValue: // New state of the toggle-button (true == pressed, false == released) // tags: // private callback // entry trace var m = "_onQuickFilterDocToggle(p_newValue)"; if (this._isTracing) { this.traceEntry(m, p_newValue); } // open/close the filter DIV, according to the boolean value if (p_newValue === true) { var sectionHeight = 5; this._setFilterSectionVisible(this.fedDocTreeFilterDiv, this.fedDocTreeContainer, true, true, sectionHeight, this._calcDomNodesHeight([this.fedDocTreeHeader]) + 2); this._onQuickFilterTextChanged(this._docTree, this._treeModel, this._quickFilterDoc, this.fedDocTreeFilterTextBox.attr("value")); // toggle button pressed ('On'), changing hover text this._changeNodeTitleText(this.fedDocQuickFilterToggleButton, this._nlsUserInterface.docPickerPage.docFilterToggleBtnOnTitle); } else { this._setFilterSectionVisible(this.fedDocTreeFilterDiv, this.fedDocTreeContainer, false, true, 0, this._calcDomNodesHeight([this.fedDocTreeHeader]) + 2); this._onQuickFilterTextChanged(this._docTree, this._treeModel, this._quickFilterDoc, ""); this._changeNodeTitleText(this.fedDocQuickFilterToggleButton, this._nlsUserInterface.docPickerPage.docFilterToggleBtnOffTitle); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onQuickFilterLibTextChanged: function() { // summary: // Callback method that is triggered when the user changes the quick filter text // tags: // private callback // entry trace var m = "_onQuickFilterLibTextChanged()"; if (this._isTracing) { this.traceEntry(m); } this._onQuickFilterTextChanged(this._libTree, this._libTreeModel, this._quickFilterLib, this.fedDocLibTreeFilterTextBox.attr("value")); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onQuickFilterLibToggle: function(/*Boolean*/ p_newValue) { // summary: // Called when the toggle button for showing/hiding the Quick Filter bar for folders // changes state // p_newValue: // New state of the toggle-button (true == pressed, false == released) // tags: // private callback // entry trace var m = "_onQuickFilterLibToggle(p_newValue)"; if (this._isTracing) { this.traceEntry(m, p_newValue); } var sectionHeight = 5; // open/close the filter DIV, according to the boolean value if (p_newValue === true) { this._setFilterSectionVisible(this.fedDocLibTreeFilterDiv, this.fedDocLibTreeContainer, true, true, sectionHeight, this._calcDomNodesHeight([this.fedDocLibTreeHeader]) + 2); this._onQuickFilterTextChanged(this._libTree, this._libTreeModel, this._quickFilterLib, this.fedDocLibTreeFilterTextBox.attr("value")); // toggle button pressed ('On'), changing hover text this._changeNodeTitleText(this.fedDocLibQuickFilterToggleButton, this._nlsUserInterface.docPickerPage.libFilterToggleBtnOnTitle); } else { this._setFilterSectionVisible(this.fedDocLibTreeFilterDiv, this.fedDocLibTreeContainer, false, true, 0, this._calcDomNodesHeight([this.fedDocLibTreeHeader]) + 2); this._onQuickFilterTextChanged(this._libTree, this._libTreeModel, this._quickFilterLib, ""); // toggle button released ('Off'), changing hover text this._changeNodeTitleText(this.fedDocLibQuickFilterToggleButton, this._nlsUserInterface.docPickerPage.libFilterToggleBtnOffTitle); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onQuickFilterTextChanged: function(/*Tree*/ p_tree, /*TreeModel*/ p_model, /*Object*/ p_filter, /*String*/ p_searchTerm) { // summary: // Callback method that is triggered when the user changes the quick filter text // p_tree: // A [dijit.Tree] widget instance to apply the filter on // p_model: // A [dijit.tree.ForestTreeModel] instance associated with the given tree to // do the filtering on // p_filter: // A [com.ibm.workplace.wcm.ecm.picker.widget.filter.QuickSearchTreeItemFilter] instance to // set the search term on and which is being used by the model for item filtering // p_searchTerm: // A string containing the search term for the quickfilter // tags: // private callback // entry trace var m = "_onQuickFilterTextChanged(p_tree, p_model, p_filter, p_searchTerm)"; if (this._isTracing) { this.traceEntry(m, [p_tree, p_model, p_filter, p_searchTerm]); } p_filter.changeLabelContains(p_searchTerm); // fix for the "multiple items selected at the same time"-problem which appears // in the dijit.Tree widget, if items disappear while filtering and items come // back later (e.g. when changing the filter conditions) // lastFocused not supported in Dojo 1.9 any longer var _supportsLastFocused = dojo.version.minor < 8; var selectedNode = null; if (p_tree) { if (_supportsLastFocused) { // save information about the currently focused node selectedNode = p_tree.lastFocused; // deselect it, if available to clear selection if (p_tree.lastFocused !== null) { p_tree.lastFocused.setSelected(false); } p_tree.lastFocused = null; } // do the filtering, domNodes will disappear from the tree widget, // if they do not match the given filter criteria p_model.filterTreeItems(p_model.root); if (_supportsLastFocused) { // now, check whether the selectedNode item, which we saved earlier, // still exists and whether it is still being displayed in the tree // (which is the case, if domNode.parent !== null) if (selectedNode) { if (selectedNode.domNode) { if (selectedNode.domNode.parentNode !== null) { // node is still part of the tree, so put focus back on it p_tree.lastFocused.setSelected(false); selectedNode.setSelected(true); p_tree.lastFocused = selectedNode; } else { // node seems to have been filtered out, so leave it alone } } } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onPreviewLinkClicked: function(/*Boolean*/ p_newValue) { // summary: // Callback method that is triggered when the user clicks the 'Preview: On/Off' // link in the Folder Column Header in PZN environment. // p_newValue: // The new state of the button (true == pressed == preview on, false == released == preview off) // tags: // private callback // entry trace var m = "_onPreviewLinkClicked()"; if (this._isTracing) { this.traceEntry(m); } if ((this._isFolderPreviewOn === true) && (p_newValue === false)) { // disable folder content preview this._hideDocTreePane(); // remove documents from the list of nodetypes and just have the store load folders this._store.removeNodeTypes(["document"]); // update link label // not needed for ToggleButton dojo.attr(this.fedDocPreviewLink, 'innerHTML', this._nlsUserInterface.docPickerPage.previewOffLabel); this._changeNodeTitleText(this.fedDocPreviewLink, this._nlsUserInterface.docPickerPage.previewOffTitle); this._isFolderPreviewOn = false; // remove the tree, as it is not needed while the doc previous is off this._clearTree(); } else { if ((this._isFolderPreviewOn === false) && (p_newValue === true)) { // enable folder content preview this._showDocTreePane(); // add "document" to the list of nodetypes and have the store load folders and documents again this._store.addNodeTypes(["document"]); // update link label // not needed for ToggleButton dojo.attr(this.fedDocPreviewLink, 'innerHTML', this._nlsUserInterface.docPickerPage.previewOnLabel); this._changeNodeTitleText(this.fedDocPreviewLink, this._nlsUserInterface.docPickerPage.previewOnTitle); this._isFolderPreviewOn = true; // re-initialize the DocTree, once the tree pane is shown again with the selected item // from the libTree var _item = this._libTreeSelectedItem; if (_item) { this._setupTree(this._store.getIdentity(_item)); } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onRootNodeChanged: function(/*Item*/ p_item) { // summary: // Callback method that is triggered when the store receives information // about a root node while loading toplevel items. In this case, we // need to update the virtual root node in our libTree to show // Information about the root item instead of the generic 'Repositories' // label. // p_item: // The item that was received by the store as the new root item for all other // items in the store // tags: // private callback // entry trace var m = "_onRootNodeChanged(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } if (p_item && p_item.title) { this._libTree.showRoot = true; this._libTree.rootNode.attr('label', p_item.title); this._libTree.rootNode.attr('item', p_item); } else { this._libTree.showRoot = false; this._libTree.resize(); dojo.style(this._libTree.rootNode.rowNode, 'display', 'none'); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onSubmit: function(/*Event*/ p_evt) { dojo.stopEvent(p_evt); if (this._onDefaultAction && dojo.isFunction(this._onDefaultAction)) { this._onDefaultAction(); } // prevent browser to actually submit a form (would cause a page refresh) return false; }, _onTreeFocused: function() { // summary: // Callback method that is triggered when the docTree receives the input // focus. Primarily used to update the aria-activedescendant property on // the BorderContainer. // tags: // private callback // entry trace var m = "_onTreeFocused()"; if (this._isTracing) { this.traceEntry(m, []); } dijit.setWaiState(this.fedDocPickerBorderContainer.domNode, 'activedescendant', this._docTree.get('id')); if (this._isTracing) { this.traceExit(m); } }, _onTreeLoaded: function() { // summary: // Callback method that is triggered when the tree widget finished // loading and we need to decide whether or not to show the NoItems // Info Box. // tags: // private callback // entry trace var m = "_onTreeLoaded()"; if (this._isTracing) { this.traceEntry(m); } // hide connecting box here to be sure it disappears // when user works with the tree this._hideConnectingBox(); this._treeModel.getChildren(this._libTreeSelectedItem, dojo.hitch(this, function(items) { if (items && items.length <= 0) { this._showNoItemsInfo(); } else { this._hideNoItemsInfo(); } })); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onTreeNodeClick: function(/*Item*/ p_item, /*DomNode*/ p_node) { // summary: // Callback method that is triggered when the user selects an item in the // document tree // p_item: // The item in the dojo data store connected to the document tree // p_node: // The TreeNode of the selected item // tags: // private callback // entry trace var m = "_onTreeNodeClick(p_item, p_node)"; if (this._isTracing) { this.traceEntry(m, [p_item, p_node]); } // hide connecting box here to be sure it disappears // when user works with the tree this._hideConnectingBox(); // only accept item clicks from the DocTree, if we are in WCM mode if (this._isCalledFromWCM()) { // trace if (this._isTracing) { this.trace(m, "Setting selected item and document tree selected item to the same value"); } this._docTreeSelectedItem = p_item; this._setSelectedItem(p_item); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onTreePaneResized: function(/*Object*/ p_changeSize, /*Object*/ p_resultSize) { // summary: // This method is being called, when the tree ContentPane was resized. // p_changeSize is always null and the parameter p_resultSize is an // object with two properties h (height) and w (width), which contain // the width/height of the ContentPane after the resize took place. // p_changeSize: Object // If set, this method has to change the size of the tree Pane to the // provided size value. However, since we just hitch this method additionally // to the default implementation of the method, this parameter is always // null and will be ignored. // p_resultSize: Object // This objects holds the width and height information of the tree ContentPane // after a resize took place (by using the splitter for example). // tags: // private callback var m = "_onTreePaneResized(p_changeSize, p_resultSize)"; if (this._isTracing) { this.traceEntry(m, [p_changeSize, p_resultSize]); } var dimTreePane = dojo.marginBox(this.fedDocTreePane.domNode); if (p_resultSize && p_resultSize.w) { // there's a dojo bug that seems to send wrong width information, if the dialog got resized. // Therefore, we need to get the actual width ourselves here. p_resultSize.h = dimTreePane.h; p_resultSize.w = dimTreePane.w; } else { p_resultSize = { w: dimTreePane.w, h: dimTreePane.h }; } this._autoResizeTextAndControl(p_resultSize, this.fedDocTreeHeaderText, this.fedDocTreeHeaderButtons); this._autoResizeLabelAndInput(p_resultSize, this.fedDocTreeFilterLabel, this.fedDocTreeFilterTextBox.domNode, 40); if (this._isTracing) { this.traceExit(m); } }, _setFilterSectionVisible: function(/*DomNode*/ p_sectionDomNode, /*DomNode?*/ p_otherDomNode, /*Boolean*/ p_isVisible, /*Boolean*/ p_animate, /*Integer?*/ p_targetHeight, /*Integer?*/ p_otherDomNodesHeight) { // summary: // Changes the visibility of the section represented by the given DOM node // p_domNode: // The DOM node to hide or show // p_otherDomNode: // If there is another DomNode (DIV for example) within the same container, the method // can automatically decrease/increase it's height, so both domNodes still fit into // their container after opening/closing the section. Simply provide null, if p_sectionDomNode // is the only DomNode in it's parent container. // p_isVisible: // Indicates whether the section is to be shown // p_animate: // Indicates whether a change of the visibility is animated // p_targetHeight: // The eventual height of the section at the end of the animation // p_otherDomNodesHeight: // If there are more other domNodes that are static in height and don't have to // be adjusted, but decrease the available vertical space in the parent domNode of // p_sectionDomNode, provide the combined height of those domNodes in pixels here // tags: // private // entry trace var m = "_setFilterSectionVisible(p_sectionDomNode, p_otherDomNode, p_isVisible, p_animate, p_targetHeight)"; if (this._isTracing) { this.traceEntry(m, [ p_sectionDomNode, p_otherDomNode, p_isVisible, p_animate, p_targetHeight ]); } if ((p_animate) && (p_animate === true)) { if (p_isVisible === true) { this._animateOpenFilterSection(p_sectionDomNode, p_otherDomNode, p_targetHeight, p_otherDomNodesHeight); } else { this._animateCloseFilterSection(p_sectionDomNode, p_otherDomNode, p_otherDomNodesHeight); } } else { // non-animated update of element this._setVisible(p_sectionDomNode, p_isVisible); if (p_otherDomNode && (typeof p_otherDomNode == 'object')) { // adjust the height of the other DomNode, to match parent's height - p_sectionDomNode's height // check for the parentNode, as code won't work, if this is a top-level node if (p_sectionDomNode.parentNode) { var parentDomNode = p_sectionDomNode.parentNode; // if parentNode is a dijit, use the domNode property to work with // the actual domNode, not the dijit instance if (p_sectionDomNode.parentNode.domNode) { parentDomNode = p_sectionDomNode.parentNode.domNode; } var parentHeight = dojo.marginBox(p_sectionDomNode.parentNode).h; var sectionHeight = dojo.marginBox(p_sectionDomNode).h; // check if section is visible at all (if it is hidden, contentBox will report a height of // zero). If it is hidden, use the sectionHeight (0) instead of the marginBox height if (dojo.contentBox(p_domNode).h === 0) { sectionHeight = 0; } if (p_otherDomNodesHeight) { dojo.marginBox(p_otherDomNode, { "h": parentHeight - sectionHeight - p_otherDomNodesHeight}); } else { dojo.marginBox(p_otherDomNode, { "h": parentHeight - sectionHeight }); } } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _setSelectedItem: function(/*Item*/ p_item) { // summary: // Sets the selected item of this widget to the passed argument and notifies // the parent dialog wizard about the state the selection step // p_item: // The item in the dojo data store connected to the document tree // tags: // private // entry trace var m = "_setSelectedItem(p_item)"; if (this._isTracing) { this.traceEntry(m, p_item); } // only set the selected item, if // - the item passed in here is defined // - is not the 'virtual' root node of the tree, which is not known to our store if ((p_item) && (typeof p_item != "undefined") && ((!p_item.root) || (p_item.root === false))) { this._selectedItem = p_item; var pathInfo = this._buildPathForSelectedItem(); dojo.removeClass(this.pickerSelectedItem, 'feddocNoSelection'); dojo.attr(this.pickerSelectedItemPath, 'innerHTML', pathInfo.path); dojo.attr(this.pickerSelectedItemPath, 'title', pathInfo.fullpath); dojo.attr(this.pickerSelectedItem, 'innerHTML', pathInfo.file); dojo.attr(this.pickerSelectedItem, 'title', pathInfo.fullpath); // Ready state will only change to 'true' in WCM environments, if a document was selected // A folder won't allow the 'Finish' button to turn enabled if (this._isCalledFromWCM()) { this._setReadyValue(!(this._store.isFolderItem(this._selectedItem) || this._store.isRepositoryItem(this._selectedItem))); } else { this._setReadyValue(true); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _setupLibTree: function(/*String*/ p_url) { // summary: // Initializes the library tree of this widget // p_url: // The URL of the Content Management Interoperability Services (CMIS) // repository whose content is reflected by the tree // tags: // private // entry trace var m = "_setupLibTree(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } var libTreeID = this.id + '_libTree'; var libTree = dijit.byId(libTreeID); if (libTree) { libTree.destroyRecursive(false); } // also clear the right-hand tree, as it might display unavailable resources // from another server, until user clicks into the left-hand tree this._clearTree(); this._showConnectingBox(); // always add the 'document' nodetype, even if it was not passed in here // as we need to request and display documents in both supported environments // (WCM and PZN), however, documents will only be shown in PZN env. and not // be selectable. We clone the nodeTypes array to be sure, we don't modify // the original data, just in case, the information is needed for other // purposes. var viewNodeTypes = dojo.clone(this.nodeTypes); viewNodeTypes.push("document"); // default to the feedBaseUrl var feedBaseUrl = this._feedBaseURL; var feedSvcDocBaseUrl = this._feedBaseURL; if (this._feedType && this._feedType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._servicedoc) { // if feed type tells us that the Url points to a service doc, use the // servicedocBaseUrl instead feedSvcDocBaseUrl = this._serviceDocBaseURL; } var storeArgs = { "url": p_url, "feedBaseURL": feedBaseUrl, "feedSvcDocBaseURL": feedSvcDocBaseUrl, "nlsMessages": this._nlsMessages, "nodeTypes": viewNodeTypes, "onErrorStateChanged": dojo.hitch(this, "_onCmisPageErrorStateChanged"), "onRootNodeChanged": dojo.hitch(this, "_onRootNodeChanged"), "serviceId": this._serviceId }; // add credential vault slot ID, if current authentication method chosen is Credential Vault or Userid / PW if (this._authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault || this._authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) { storeArgs.credentialVaultParamValue = this._authProperties.vaultSlotID; } this._store = new com.ibm.workplace.wcm.ecm.picker.widget.store.FedDocAtomStore(storeArgs); // remove document from the store's typefilter again, if the folderPreview is off. if (!this._isFolderPreviewOn) { this._store.removeNodeTypes(["document"]); } var libModelArgs = { "store": this._store, "deferItemLoadingUntilExpand": true, "itemFilter": this._libFolderItemFilter, "rootLabel": "Folders", "rootId" : "folders" }; this._libTreeModel = new com.ibm.workplace.wcm.ecm.picker.widget.model.FedDocTreeModel(libModelArgs); var libTreeArgs = { "id": libTreeID, "model": this._libTreeModel, "showRoot": true, "filteredNodes": [], "adjustFirstNodeForIE": this.adjustFirstNodeForIE, "dir": this._isRTLMode ? "rtl" : "ltr", "persist": false, "onClick": dojo.hitch(this, "_onLibTreeNodeClick"), // dojo automatically focuses a node when it was expanded or closed, // so we need to make sure to update the selectedItem Info in this case "onOpen": dojo.hitch(this, "_onLibTreeNodeOpen"), "onClose": dojo.hitch(this, "_onLibTreeNodeClose"), "onLoad": dojo.hitch(this, "_onLibTreeLoaded"), "onFocus": dojo.hitch(this, "_onLibTreeFocused"), //"tabIndex": "1", "getIconClass": dojo.hitch(this, "_getLibTreeIconClass") }; this._libTree = new dijit.Tree(libTreeArgs); // ensure that the overflow is visible to have horizontal scrollbars on the // container of the tree rather than on the tree itself if appropriate dojo.style(this._libTree.domNode, "overflow", "visible"); dojo.place(this._libTree.domNode, this.fedDocLibTreeContainer, "last"); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setupTree: function(/*String*/ p_id) { // summary: // Initializes the document tree of this widget // p_id: // The identifier of the item whose children are reflected by the tree // tags: // private // entry trace var m = "_setupTree(p_id)"; if (this._isTracing) { this.traceEntry(m, p_id); } this._clearTree(); var treeID = this.id + '_docTree'; var modelArgs = { store: this._store, query: "itemID=" + p_id, deferItemLoadingUntilExpand: true, itemFilter: this._quickFilterDoc, allowSubItems: false }; this._treeModel = new com.ibm.workplace.wcm.ecm.picker.widget.model.FedDocTreeModel(modelArgs); var treeArgs = { "id": treeID, "model": this._treeModel, "showRoot": false, "filteredNodes": [], "adjustFirstNodeForIE": this.adjustFirstNodeForIE, "dir": this._isRTLMode ? "rtl" : "ltr", "persist": false, "onClick": dojo.hitch(this, "_onTreeNodeClick"), // dojo automatically focuses a node when it was expanded or closed, // so we need to make sure to update the selectedItem Info in this case "onOpen": dojo.hitch(this, "_onTreeNodeClick"), "onClose": dojo.hitch(this, "_onTreeNodeClick"), "onFocus": dojo.hitch(this, "_onTreeFocused"), "onLoad": dojo.hitch(this, "_onTreeLoaded"), "getIconClass": dojo.hitch(this, "_getDocTreeIconClass")//, //"tabIndex": "2" }; // in PZN environment, disallow item selection in the doc tree if (this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn) { dojo.addClass(this.fedDocTreeContainer, 'disabledTree'); dijit.setWaiState(this.fedDocTreeContainer, 'disabled', true); } this._docTree = new dijit.Tree(treeArgs); // ensure that the overflow is visible to have horizontal scrollbars on the // container of the tree rather than on the tree itself if appropriate dojo.style(this._docTree.domNode, "overflow", "visible"); dojo.place(this._docTree.domNode, this.fedDocTreeContainer, "last"); // make sure that the docTree fills the available vertical space, so that // the horizontal scrollbar (should it be needed) appears right at the bottom // of the pane and not any higher this._updateTreeLayout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, // TODO: externalize to Utils class _setVisible: function(/*DomNode*/ p_domNode, /*Boolean*/ p_isVisible) { // summary: // Changes the visibility of the section represented by the given DOM node // p_domNode: // The DOM node to hide or show // p_isVisible: // Indicates whether the section is to be shown // tags: // private // entry trace var m = "_setVisible(p_domNode, p_isVisible)"; if (this._isTracing) { this.traceEntry(m, [ p_domNode, p_isVisible ]); } if (p_isVisible === true) { if (dojo.hasClass(p_domNode, 'lotusHidden')) { dojo.removeClass(p_domNode, 'lotusHidden'); } dijit.setWaiState(p_domNode, 'hidden', false); dijit.setWaiState(p_domNode, 'expanded', true); } else { if (!dojo.hasClass(p_domNode, 'lotusHidden')) { dojo.addClass(p_domNode, 'lotusHidden'); } dijit.setWaiState(p_domNode, 'hidden', true); dijit.removeWaiState(p_domNode, 'expanded'); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _showConnectingBox: function() { // summary: // Displays the element showing a message indicating that a server // connection is about to be established // tags: // private // entry trace var m = "_showConnectingBox()"; if (this._isTracing) { this.traceEntry(m); } if (dojo.style(this.fedDocPickerConnectingDiv, 'display') != 'block') { dojo.style(this.fedDocPickerConnectingDiv, 'display', 'block'); } dijit.setWaiState(this.fedDocPickerConnectingDiv, 'hidden', false); dijit.setWaiState(this.fedDocPickerResponseContainer, 'busy', true); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showDocTreePane: function() { // summary: // Shows the ContentPane in the TreeContainer which shows the Document Tree // as well as the splitter between the two ContentPanes // tags: // private // entry trace var m = "_showDocTreePane()"; if (this._isTracing) { this.traceEntry(m); } this.fedDocPickerBorderContainer.addChild(this.fedDocTreePane); this.fedDocPickerBorderContainer.layout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showError: function(/*String*/ p_errorMsg, /*String*/ p_errorDetails) { // summary: // Overridden version of GenericWizardPageWidget._showError() to // be able to hide the connecting box in case of an error during // fetches. // // For parameter descriptions see // [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget] // tags: // protected var m = "_showError(p_errorMsg, p_errorDetails)"; if (this._isTracing) { this.traceEntry(m, [p_errorMsg, p_errorDetails]); } this._hideConnectingBox(); this.inherited(arguments); if (this._isTracing) { this.traceExit(m); } }, _showNoItemsInfo: function() { // entry trace var m = "_showNoItemsInfo()"; if (this._isTracing) { this.traceEntry(m); } dojo.style(this.fedDocNoItemsInfoDiv, 'display', 'block'); dijit.setWaiState(this.fedDocNoItemsInfoDiv, 'hidden', false); // exit trace if (this._isTracing) { this.traceExit(m); } }, _updateAuthenticationInfoMsg: function() { // summary: // Updates the element informing the user about the authentication // method used to connect to the content repository // tags: // private // entry trace var m = "_updateAuthenticationInfoMsg()"; if (this._isTracing) { this.traceEntry(m, p_id); } // replace innerHTML of "fedDocPickerAuthInfo" dojo.attr(this.fedDocPickerAuthInfo, "innerHTML", this._authenticationInfoMsg); // exit trace if (this._isTracing) { this.traceExit(m); } }, _updateFilterLayout: function() { // summary: // Tests which QuickFilter sections are open and call _on*TreePaneResized() method // to force layout update on these sections (making sure that Label + Input Box are // always on the same line) // tags: // private // entry trace var m = "_updateFilterLayout()"; if (this._isTracing) { this.traceEntry(m); } if (!dojo.hasClass(this.fedDocLibTreeFilterDiv, 'lotusHidden')) { // get width of libTree Pane, so we can pass it to the resize() method var libTreePaneWidth = dojo.marginBox(this.fedDocLibTreePane.domNode).w; this._onLibTreePaneResized(null, { w: libTreePaneWidth }); } if (!dojo.hasClass(this.fedDocTreeFilterDiv, 'lotusHidden')) { // get width of docTree Pane, so we can pass it to the resize() method var treePaneWidth = dojo.marginBox(this.fedDocTreePane.domNode).w; this._onTreePaneResized(null, { w: treePaneWidth }); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _updateTreeLayout: function() { // summary: // Tests which Trees are available and performs the same size calculation that the // onFilterSectionOpen event handlers are performing to recalculate the height of // each tree. This method is necessarily to be called on each Dialog resize, as // opening/closing the filter section causes the height of each tree to be explicitly // set. Therefore, trees won't automatically be resized when the available space // shrinks or expands during dialog resize. // tags: // private // entry trace var m = "_updateTreeLayout()"; if (this._isTracing) { this.traceEntry(m); } // force BorderContainer to update it's internal _borderBox variable, just in case it's domNode was resized this.fedDocPickerBorderContainer.resize(); if (this._libTree) { this._adjustTreePaneHeight(this.fedDocLibTreeFilterDiv, this.fedDocLibTreeContainer, this._calcDomNodesHeight([this.fedDocLibTreeHeader]) + 2); } if (this._docTree) { this._adjustTreePaneHeight(this.fedDocTreeFilterDiv, this.fedDocTreeContainer, this._calcDomNodesHeight([this.fedDocTreeHeader]) + 2); } this._updateFilterLayout(); // exit trace if (this._isTracing) { this.traceExit(m); } } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.QuickrDocumentPickerPageWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.QuickrDocumentPickerPageWidget"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.QuickrDocumentPickerPageWidget"); dojo.registerModulePath("com.ibm.workplace.wcm.ecm.picker.widget","../com/ibm/workplace/wcm/ecm/picker/widget"); dojo.declare('com.ibm.workplace.wcm.ecm.picker.widget.QuickrDocumentPickerPageWidget', [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget], { // summary: // This widget inherits from GenericWizardPageWidget and implements a Wizard page // for launching the Quickr Picker Dialog from within the wizard. The return value // is then displayed on the page and needs to be confirmed by the user by clicking // 'Finish'. // namespace: [protected] String // The namespace this widget uses for building its user interface elements namespace: "qckrDocPckrPgWdgt_", // templatePath: [protected] String // see dijit.Dialog templateString:"
\n
\n ${_nlsUserInterface.quickrLaunchPage.stepDetailedInfoText}\n
\n
\n

\n

\n

\n \n \n
${_nlsUserInterface.quickrLaunchPage.selectButtonLabel}\n \n
\n
\n", // widgetsInTemplate: [protected] Boolean // see dijit._Templated widgetsInTemplate: true, // _authenticationInfoMsg: [private] String // Informative message being displayed in the Federated Documents Picker Dialog // describing the selected authentication mechanism _authenticationInfoMsg: "", // _authProperties: [private] Object // JSON object which holds information about the authentication settings. // Objects of the same format are being used for passing in authentication information to the Picker dialog // and for receiving changed authentication settings back from the AuthenticationWidget when the user // made changes. // // Allowed Identifiers are: // authType: String // The type of authentication selected // username: String // The username for username/password authentication // password: String // The password for username/password authentication // vaultSlotID: String // The credential vault slot ID for credential vault based authentication // vaultSlotTitle: String // The title for the credential vault slot ID for credential vault based authentication _authProperties: null, // _callingEnvId: [private] String // Identifier of the context the Federated Documents Picker is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management // (default) _callingEnvId: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm, // _dsPickerArgs: [private] Object // JSON object holding properties to pass to the picker supporting Quickr Document Services _dsPickerArgs: {}, // _eventHandles: Array // An array which holds all event connection handles. Used for easy disconnects during uninitialization // of the widget. _eventHandles: [], // _fedDocsPickerArgs: [private] Object // JSON object holding properties to pass to the Federated Documents Picker _fedDocsPickerArgs: {}, // _federatedDocumentsServiceBean: [private] Object // Bean holding configuration and runtime data of the federated documents support _federatedDocumentsServiceBean: null, // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _selectedUrl: [private] String // Url of the selected item returned by the Quickr Picker dialog _selectedUrl: null, // _serverUrl: [private] String // Feed Url of the selected server that is being passed on to the QuickrPicker _serverUrl: "", // _portalContextPath: [private] String // Context path of the IBM Portal _portalContextPath: "/wps", constructor: function(/*Object*/ p_params) { // summary: // Constructs this widget // p_params: Object // The arguments for initializing this widget // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { // do not use dojo.toJson with p_params, because it causes an error when trying to serialize a DOM node this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.callingEnvId:", p_params.callingEnvironment); this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.portalContextPath:", p_params.portalContextPath); } } // determine the context this widget is used if (typeof p_params.callingEnvironment == 'string') { this._callingEnvId = p_params.callingEnvironment; } // namespace if (typeof p_params.namespace == 'string') { this.namespace = p_params.namespace; } // initialize the localized strings that are read by the parent dialog var nlsStrings = this._nlsUserInterface.quickrLaunchPage; this._stepLabel = nlsStrings.stepLabel; if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm) { // WCM this._stepDescription = nlsStrings.stepDescriptionWCM; } else { // PZN this._stepDescription = nlsStrings.stepDescription; } // portal context path this._portalContextPath = p_params.portalContextPath; // exit trace if (this._isTracing) { this.traceExit(m); } }, getSelectedItemJSON: function() { // summary: // Returns information about the item that was selected in the Quickr Document Picker // dialog as a JSON object // returns: // The JSON object holding information on the selected item. The particular JSON members // are: // title: String // The display title of the selected item // url: String // The URL of the selected item // entry trace var m = "getSelectedItemJSON()"; if (this._isTracing) { this.traceEntry(m); } var result = { "title": "", // no title for quickr URLs "url": this._selectedUrl }; // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Object }, initializePage: function(/*Object*/ p_params) { // summary: // Method being called to initialize this "wizard page widget" for display // with data from the previous page (if needed) // p_params: // The parameters to initialize this widget // tags: // public // entry trace var m = "initializePage(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.serverUrl:", p_params.serverUrl); } } // clear internal Url variable holding the result for this page this._selectedUrl = null; // clear any result URL being displayed in the textbox this._showSelectedUrl(""); if (p_params) { if (p_params.serverUrl) { this._serverUrl = p_params.serverUrl; } else { this._serverUrl = ""; } } // setup page information based on calling environment if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm) { // WCM dojo.attr(this.quickrPickerInfoMsgDiv, 'innerHTML', this._nlsUserInterface.quickrLaunchPage.stepDetailedInfoTextWCM); dojo.attr(this.quickrPickerUrlLabel, 'innerHTML', "" + this._nlsUserInterface.quickrLaunchPage.selectedDocumentLabel + ""); } else { // PZN dojo.attr(this.quickrPickerInfoMsgDiv, 'innerHTML', this._nlsUserInterface.quickrLaunchPage.stepDetailedInfoText); dojo.attr(this.quickrPickerUrlLabel, 'innerHTML', "" + this._nlsUserInterface.quickrLaunchPage.selectedFolderLabel + ""); } // exit trace if (this._isTracing) { this.traceExit(m); } }, layout: function() { // see com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget.layout() // entry trace var m = "layout()"; if (this._isTracing) { this.traceEntry(m); } var availableWidth = dojo.marginBox(this.domNode).w; var msgWidth = availableWidth - 30; // subtracting margins dojo.marginBox(this.quickrPickerInfoMsgDiv, { w: msgWidth }); var btnWidth = dojo.marginBox(this.quickrPickerLaunchBtn).w; var textBoxWidth = availableWidth - btnWidth - 30; // subtracting margins and Launch QuickrPicker button width if (textBoxWidth >= 0) { dojo.style(this.quickrUrlTextBox.domNode, 'width', textBoxWidth + "px"); } // exit trace if (this._isTracing) { this.traceExit(m); } }, postCreate: function() { // summary: // Binds resources required by this widget after its DOM has been set up // tags: // protected // entry trace var m = "postCreate()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); this._initEventHandles(); // exit trace if (this._isTracing) { this.traceExit(m); } }, uninitialize: function() { // summary: // Releases the resources bound by this widget before it is destroyed // tags: // protected // entry trace var m = "uninitialize()"; if (this._isTracing) { this.traceEntry(m); } this._clearEventHandles(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearEventHandles: function() { // summary: // Disconnects the events supported by this dialog from the corresponding callback methods // tags: // private // entry trace var m = "_clearEventHandles()"; if (this._isTracing) { this.traceEntry(m); } // disconnect the callbacks from their related events dojo.forEach(this._eventHandles, dojo.disconnect); this._eventHandles = []; // exit trace if (this._isTracing) { this.traceExit(m); } }, _fixUpDlgUnderlay: function() { // summary: // Basically a hack for fixing up the single dialog underlay instance in the DomTree that // is left with a wrong z-index after the QuickrPicker Dialog was closed. The modified // underlay would show on top of our CMIS Dialog, unless we decrease the z-index manually. // Also, the Dialog close method hides the underlay, so we need to show it again. // tags: // private // entry trace var m = "_fixUpDlgUnderlay()"; if (this._isTracing) { this.traceEntry(m); } if (dijit._underlay) { // decrease z-index of underlay, so it will show properly behind the CMIS Picker dialog // after the QuickrPicker Dialog was shown var zIdx = dojo.style(dijit._underlay.domNode, 'zIndex'); if (zIdx) { dojo.style(dijit._underlay.domNode, 'zIndex', zIdx - 2); } dojo.style(dijit._underlay.domNode, 'display', 'block'); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _initEventHandles: function() { // summary: // Connects the events supported by this widget to the corresponding callback methods // and stores the handles in the _eventHandles array // tags: // private // entry trace var m = "_initEventHandles()"; if (this._isTracing) { this.traceEntry(m); } this._eventHandles.push(dojo.connect( this.quickrPickerLaunchBtn, "onclick", dojo.hitch(this, "_onLaunchButtonClicked"))); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onConfirmQuickrPicker: function(/*String*/ p_title, /*String*/ p_url, /*String*/ p_linkType) { // entry trace var m = "_onConfirmQuickrPicker(p_title, p_url)"; if (this._isTracing) { this.traceEntry(m, [p_title, p_url]); } // ignore the title, we just need the URL if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm && p_linkType != "view") { // for download URLs create a URL that proxies the downloads this._selectedUrl = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.generateProxiedUrl(p_url, this._portalContextPath); } else { this._selectedUrl = p_url; } this._showSelectedUrl(this._selectedUrl); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onLaunchButtonClicked: function() { // summary: // Invoked when user clicks on the 'Select folder...' button. // Launches the Quickr Picker dialog and stores the result for // further processing. // tags: // private // entry trace var m = "_onLaunchButtonClicked()"; if (this._isTracing) { this.traceEntry(m); } // check for an instance of picker manager, and if it is available launch the Quickr Document Picker if (this._pickerManager && dojo.isFunction(this._pickerManager.launchDocumentServicesPickerDialog)) { // hitch the callback functions var onConfirmCallbackFn = dojo.hitch(this, "_onConfirmQuickrPicker"); // the dialog underlay fix must not be called if the Federated Documents Picker is launched by the // Federated Document Picker portlet var onCloseCallbackFn; if (this._pickerContext === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog) { onCloseCallbackFn = dojo.hitch(this, "_fixUpDlgUnderlay"); } else if (this._pickerContext === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._portlet) { onCloseCallbackFn = this._prepareDialog(); } // remove trailing / as this causes the quickr picker to fail var quickrUrl = this._serverUrl; if(quickrUrl && quickrUrl.charAt(quickrUrl.length-1) == '/') { quickrUrl = quickrUrl.substring(0, quickrUrl.length-1); } var pickerDialog = this._pickerManager.launchDocumentServicesPickerDialog(quickrUrl, onConfirmCallbackFn, onCloseCallbackFn); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _resizeWindow: function(/*String*/ p_height) { // summary: // Resizes the modal dialog framework window. // p_height: // The height of this widget to set before resizing the modal dialog framework window. // tags: // private if (this.domNode && this.domNode.style && typeof p_height == "string") { // set the new height of this widget this.domNode.style.height = p_height; // make sure the modal dialog surrounding this widget resizes as well if (window.resize) { window.resize(); } } }, _prepareDialog: function() { // summary: // Changes the size of the Federated Documents Picker Dialog to accommodate the Quickr Document Picker. // return: // Returns a callback function that reverts the changing of the size. // tags: // private // entry trace var m = "_prepareDialog()"; if (this._isTracing) { this.traceEntry(m, p_url); } var revertFn; if (this.domNode && this.domNode.style) { var prevHeight = this.domNode.style.height; this._resizeWindow("500px"); // resize this widget and the surrounding dialog to the previous // dimensions when the Quickr Document Picker dialog is closed revertFn = dojo.hitch(this, function() { this._resizeWindow(prevHeight); }); } // exit trace if (this._isTracing) { this.traceExit(m); } return revertFn }, _showSelectedUrl: function(/*String*/ p_url) { // summary: // Shows the given Url on the Quickr Picker Page, so the user can review it // before closing the dialog. // p_url: String // The Url that was returned by the Quickr Picker dialog // tags: // private // entry trace var m = "_showSelectedUrl(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } // map undefined values to an empty string if (((typeof p_url) == 'undefined') || (p_url === null)) { p_url = ""; } // set the value, be it an empty string or a non-empty string this.quickrUrlTextBox.attr('value', p_url); // ready value is only set to true, if the string set was non-empty if (p_url !== "") { this._setReadyValue(true); } // exit trace if (this._isTracing) { this.traceExit(m); } } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.dialog.FederatedDocumentsPickerDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.dialog.FederatedDocumentsPickerDialog"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.dialog.FederatedDocumentsPickerDialog"); dojo.registerModulePath("com.ibm.workplace.wcm.ecm.picker.dialog","../com/ibm/workplace/wcm/ecm/picker/dialog"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit.layout.StackContainer"); dojo.require("com.ibm.widgets.GenericDialog"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.dialog.FederatedDocumentsPickerDialog", [com.ibm.widgets.GenericDialog], { // summary: // CMIS Picker Dialog in Wizard style, inherited from GenericDialog, providing // additional buttons and functions for handling page transition. Multiple pages // are supported, each containing a separate widget. // lotusui_id: String // The ID for the global dijitDialog lotusui related wrapper DIV // The container needs to be specific to the FedDocPickerDlg, as the labelledby // aria attribute is specific to this dialog. lotusui_id: "dijitDialog_lotusui30_fedDocDlg_container", // lotusui_class: String // The lotusui class to assign to the wrapper DIV, if it gets created lotusui_class: "lotusui30", // namespace: [protected] String // The namespace this dialog uses for building its user interface elements namespace: "fedDocsPckrDlg_", // templateString: // see dijit.Dialog templateString: dojo.cache("com.ibm.workplace.wcm.ecm.picker.dialog", "template/FederatedDocumentsPickerDialog.html", "
\n\n
\n
\n

\n ${title}\n

\n \n \"\"\n X\n \n
\n\n
\n
\n \"${_nlsUserInterface.docPickerDialog.errorImgAlt}\"\n \n
\n \n
\n
\n
\n

\n
\n
\n
\n \"${_nlsUserInterface.docPickerDialog.detectingFeedTypeImgAlt}\"\n  ${_nlsUserInterface.docPickerDialog.detectingFeedTypeDivText}\n \n
\n
\n \"${_nlsUserInterface.docPickerDialog.gettingVaultImgAlt}\"\n  ${_nlsUserInterface.docPickerDialog.gettingVaultDivText}\n \n
\n
\n
\n
\n\n
\n
\n \n \n \n \n
\n
\n
\n
\n"), // widgetsInTemplate: [protected] Boolean // see dijit._Templated widgetsInTemplate: true, // _callingEnvironment: [private] String // Identifier of the context the Federated Documents Picker is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management // (default) _callingEnvironment: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm, // _currentPage: [private] Integer // Index to the current page. 0 based value, which means, Page 1 has index 0, Page 2 has index 1 and so forth. // Default value is '-1', which means no page is selected. Will be set to first page (0) once the // page was loaded. _currentPage: -1, // _defaultButton: [private] DomNode // Reference to a domNode pointing to either the NEXT or FINISH button. This // is the button whose action will be triggered, whenever the user presses // the ENTER key on the keyboard. _defaultButton: null, // _dialogBorderWidth: [private] Integer // Width of the dialog border (left + right side) in pixels. Used to calculate the available // horizontal space for the ContainerNode on resize _dialogBorderWidth: 2, // _errorState: [private] Boolean // Indicates whether an error occurred and whether this dialog went into error state. // The error is displayed (and the user cannot advance within or finish the dialog) // until _clearError() was called. _errorState: false, // _nlsMessages: [protected] Object // see com.ibm.widgets.GenericDialog _nlsMessages: {}, // _nlsUserInterface: [protected] Object // see com.ibm.widgets.GenericDialog _nlsUserInterface: {}, // _maxErrorChars: [private] Integer // Maximum number of characters that will be shown for an error message. The rest will // be truncated. _maxErrorChars: 768, // _pageParams: [private] Object // JSON object holding the parameters that are passed to the wizard page widgets that // represent the single steps of the federated documents picker dialog _pageParams: {}, // _pages: [private] Array // Internal array holding references to [dijit.layout.ContentPane] instances within the // dijit.layout.StackContainer used to manage Wizard pages _pages: [], // _pickerContext: [private] String // Indicates whether or not the Federated Documents Picker is launched as a fully fledged dialog of its // own or as a dependent widget. The latter is the case of using the Federated Documents Picker Portlet // inside of a dialog that is created by the modal dialog framework of the portal. // Supported values are: // - com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog // - com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._portlet _pickerContext: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog, // _qdsSupportEnabled: [private] Boolean // Indicates whether Quickr Document Services support is enabled, hence, the Quickr // Document Picker dialog is available and shall be launched to access QDS feeds _qdsSupportEnabled: true, // _serverTypeMap: [private] Object // Internal associative array, which maps any given URL (key) to a // known feedType (value) _serverTypeMap: {}, //_selectedPath: [private] Array // Array holding the ids of tree nodes starting from the root node and going down to the selected node _selectedPath: [], // _transientSlotId: [private] String // The slot id of the transient credential vault slot that is used to // store the username / password in case of username / pw authentication. _transientSlotId: String, // _vaultMgmtDataSinkUrl: [private] String // Piece of content (POC) URL for accessing the Vault Management Datasink of // IBM Portal _vaultMgmtDataSinkUrl: String, // _widgets: [private] Array // Internal array holding references to instances of // [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget] compatible widgets // (one instance for each page of the wizard) _widgets: [], // _usePresetUrl: [private] Boolean // Indicates whether to use preset server url and skip the connection page and opens with second page directly _usePresetUrl: false, buildRendering: function() { // summary: // Constructs the user interface of this dialog // tags: // protected // entry trace var m = "buildRendering()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // initialize the dialog title based on the context // Note: the inherited buildRendering method will only update the title automatically // if there is one child widget implementing the getDialogTitle() method var title; if (this._isCalledFromPZN()) { title = this._nlsUserInterface.docPickerDialog.titlePZN; } else { title = this._nlsUserInterface.docPickerDialog.titleWCM; } this.title = title; this._hideDetectingBox(); this._hideGettingVaultBox(); // exit trace if (this._isTracing) { this.traceExit(m); } }, constructor: function(/*Object*/ p_params) { // summary: // Constructs this dialog // p_params.availableAuthTypes: Array // Array of String. Each string defines one authentication type that is available for selection // by the user. Allowed values are: // [com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd] // [com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser] // [com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault] // p_params.callingEnvironment: String // Defines the calling environment. Allowed values are // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] // p_params.customServiceSelectionEnabled: Boolean // Defines whether custom server selection (i.e. selection of non-preconfigured // services is supported) // p_params.documentsServices: Array // Array of JSON Objects. Each object describes one preconfigured documents service. // { url: String holding the Url of the service document of a remote Document Server // type: String describing the type of the Document Server // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis] or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds] // vaultslot: String [optional] holding the name of a credential vault slot that should // be used when connecting to this Document Server // title: String [optional] holding the display name for this Server. } // p_params.feedBaseURL: String // Piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) feeds through the CMIS feed data source of IBM Portal // p_params.feedType: String // The exact feed type of the server to connect to (on either the CMIS or Quickr page) // Especially needed for determining which URL needs to be passed to the FedDocAtomStore // as the feedBaseUrl. // p_params.feedTypeBaseURL: String // Piece of content (POC) base URL for accessing the feed type data source of IBM // Portal that determines type of an enterprise content management (ECM) feed // p_params.nodeTypes: Array // Array of String. Each string represents one nodeType that the Picker dialog // will display // p_params.namespace: String // Namespace of Federated Documents Picker and its user interface elements etc. // p_params.onCancelCallbackFn: Function // Callback function to execute when the user cancels or closes this dialog // p_params.onConfirmCallbackFn: Function // Callback function to execute when the user confirms this dialog // p_params.pickerManager: Object // Reference to the [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerManager] instance // which launched this instance of the FederatedDocumentsPickerDialog. Used to launch the Quickr Picker // from within the Quickr Page // p_params.qdsSupportEnabled: Boolean // Defines whether Quickr Documents Services support is available in the Picker dialog // p_params.serviceDocBaseURL: String // Piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) service documents through the CMIS service document data source of // IBM Portal // p_params.vaultMgmtDataSinkUrl: String // Piece of content (POC) URL for accessing the Vault Management Datasink of // IBM Portal // p_params.vaultSelectionEnabled: Boolean [optional] // Defines whether credential vault slot selection is available (regardless of the calling // environment). This setting overrides the calling environment specific settings above // p_params.vaultSelectionEnabledForPZN: Boolean // Defines whether credential vault slot selection will be available in PZN calling environment // p_params.vaultSelectionEnabledForWCM: Boolean // Defines whether credential vault slot selection will be available in WCM calling environment // p_params.vaultSlots: Array // Array of credential vault slots. Each slot is an object with the following properties: // { vaultSlotTitle: String // The localized title which is being displayed in the DropDownList // vaultSlotID: String // The actual credential vault slot ID that is being added to the URL as a parameter // } // tags: // public //p_params.usePresetUrl: boolean // If true, the dialog connects to the preset server url and skips the connection page. // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor"; if (this._isTracing) { this.traceEntry(m, p_params); if(p_params) { this.trace(m, "p_params.availableAuthTypes", p_params.availableAuthTypes); this.trace(m, "p_params.callingEnvironment", p_params.callingEnvironment); this.trace(m, "p_params.customServiceSelectionEnabled", p_params.customServiceSelectionEnabled); this.trace(m, "p_params.documentsServices", p_params.documentsServices); this.trace(m, "p_params.feedBaseURL", p_params.feedBaseURL); this.trace(m, "p_params.feedType", p_params.feedType); this.trace(m, "p_params.feedTypeBaseURL", p_params.feedTypeBaseURL); this.trace(m, "p_params.namespace", p_params.namespace); this.trace(m, "p_params.nodeTypes", dojo.toJson(p_params.nodeTypes)); this.trace(m, "p_params.pickerManager", p_params.pickerManager); this.trace(m, "p_params.portalContextPath", p_params.portalContextPath); this.trace(m, "p_params.qdsSupportEnabled", p_params.qdsSupportEnabled); this.trace(m, "p_params.selectedPath", p_params.selectedPath); this.trace(m, "p_params.serviceDocBaseURL", p_params.serviceDocBaseURL); this.trace(m, "p_params.vaultSelectionEnabled", p_params.vaultSelectionEnabled); this.trace(m, "p_params.vaultSelectionEnabledForPZN", p_params.vaultSelectionEnabledForPZN); this.trace(m, "p_params.vaultSelectionEnabledForWCM", p_params.vaultSelectionEnabledForWCM); this.trace(m, "p_params.vaultSlots", p_params.vaultSlots); this.trace(m, "p_params.usePresetUrl", p_params.usePresetUrl); } } // clear global arrays that we only push elements into, as opening multiple widget instances // might keep the array content from previous instances this._eventHandles = []; this._widgets = []; this._pages = []; this._serverTypeMap = {}; this._defaultButton = null; this._transientSlotId = null; // first, try to determine the context this dialog is used in if (typeof p_params.callingEnvironment == 'string') { this._callingEnvironment = p_params.callingEnvironment; } // namespace if (typeof p_params.namespace == 'string') { this.namespace = p_params.namespace; } // remember whether Quickr Document Services are supported if (typeof p_params.qdsSupportEnabled == 'boolean') { this._qdsSupportEnabled = p_params.qdsSupportEnabled; } if (typeof p_params.vaultMgmtDataSinkUrl == 'string') { this._vaultMgmtDataSinkUrl = p_params.vaultMgmtDataSinkUrl; } if (typeof p_params.usePresetUrl == 'boolean') { this._usePresetUrl = p_params.usePresetUrl; } if(p_params.selectedPath){ this._selectedPath = p_params.selectedPath; } // normalize the percent-encoded triplets in given base URLs var feedBaseURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.normalizePlaceholders(p_params.feedBaseURL); var feedTypeBaseURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.normalizePlaceholders(p_params.feedTypeBaseURL); var serviceDocBaseURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.normalizePlaceholders(p_params.serviceDocBaseURL); // pass-through selected arguments from the constructor to the child-widgets this._pageParams = { "availableAuthTypes": p_params.availableAuthTypes, "callingEnvironment": p_params.callingEnvironment, "customServiceSelectionEnabled": p_params.customServiceSelectionEnabled, "documentsServices": p_params.documentsServices, "feedBaseURL": feedBaseURL, "feedType": null, // will be set when switching to either the CMIS or Quickr Page "feedTypeBaseURL": feedTypeBaseURL, "namespace": this.namespace, "nlsMessages": this._nlsMessages, "nlsUserInterface": this._nlsUserInterface, "nodeTypes": p_params.nodeTypes, "onDefaultAction": dojo.hitch(this, "_onDefaultAction"), "onErrorStateChanged": dojo.hitch(this, "_onErrorStateChanged"), "onLayoutChanged": dojo.hitch(this, "layout"), "onReadyStateChanged": dojo.hitch(this, "_onReadyStateChanged"), "pickerContext": this._pickerContext, "portalContextPath": p_params.portalContextPath, "pickerManager": p_params.pickerManager, "selectedPath" : p_params.selectedPath, "serviceDocBaseURL": serviceDocBaseURL, "vaultSelectionEnabled": p_params.vaultSelectionEnabled, "vaultSelectionEnabledForPZN": p_params.vaultSelectionEnabledForPZN, "vaultSelectionEnabledForWCM": p_params.vaultSelectionEnabledForWCM, "vaultSlots": p_params.vaultSlots }; // Dojo 1.6: make sure we don't allow dijit.Dialog to automatically assign any hover classes to our // buttons/attachpoints this.cssStateNodes = {}; // exit trace if (this._isTracing) { this.traceExit(m); } }, getSelectedItemJSON: function() { // summary: // Get the selected item from either page1 (CMIS) or page2 (Quickr) // as a JSON object, containing title and url attributes // returns: // Object { title: String - display title of the selected item, // url: String - Url of the selected item } // tags: // public // entry trace var m = "getSelectedItemJSON()"; if (this._isTracing) { this.traceEntry(m); } var result = null; if (this._currentPage == 1) { result = this._widgets[1].getSelectedItemJSON(); // Object } else { if (this._currentPage == 2) { result = this._widgets[2].getSelectedItemJSON(); // Object } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Object }, layout: function() { // summary: // Makes sure that the dialog is always fully visible on screen. // Calculates the available viewport + the current dialog height // and determines whether a specific height needs to be set, or // whether the height style can be set to 'auto' again. // tags: // protected // entry trace var m = "layout()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // determine the maximum height of the dialog to allow var maxAllowedHeight = Math.round(dijit.getViewport().h * 0.9); // determine the maximum width of the dialog to allow var maxAllowedWidth = Math.round(dijit.getViewport().w * 0.9); // height of the wizard page header containing the dialog title and close icon var headerHeight = dojo.marginBox(this.titleBar).h; // height of the wizard page footer containing the dialog buttons and links var footerHeight = dojo.marginBox(this.dialogFooter).h; // trace if (this._isTracing) { this.trace(m, "headerHeight: ", headerHeight); this.trace(m, "footerHeight: ", footerHeight); this.trace(m, "maxAllowedHeight: ", maxAllowedHeight); this.trace(m, "maxAllowedWidth: ", maxAllowedWidth); } if (this.isResized === true) { // once the dialog has been resized manually, only make sure // the most crucial dialog sections are guaranteed to be shown this._layoutManualResize(headerHeight, footerHeight, maxAllowedHeight, maxAllowedWidth); } else { this._layoutAutoResize(headerHeight, footerHeight, maxAllowedHeight, maxAllowedWidth); } // get the width added by padding and margin var errorDivPaddingMarginWidth = dojo.marginBox(this.wizardErrorDiv).w - dojo.contentBox(this.wizardErrorDiv).w; // get the new content width of the error message div that stretches over the full available width of the parent element var errorDivWidth = dojo.contentBox(this.containerNode).w - errorDivPaddingMarginWidth; // update error div width (need to update width first, so that height, which we ask for below, // will already have been updated) if (errorDivWidth >= 0) { dojo.style(this.wizardErrorDiv, 'width', errorDivWidth + "px"); } //dojo.marginBox(this.wizardErrorDiv, { w: errorDivWidth}); // calculate height of wizardPageContainer (width seems to be calculated automatically) var staticHeight = dojo.marginBox(this.wizardErrorDiv).h + dojo.marginBox(this.wizardStepHeader).h + 20; var availableHeight = dojo.marginBox(this.containerNode).h; // make sure that the wizard page container layout is also updated, when the dialog // size changes if (this.wizardPageContainer) { this.wizardPageContainer.layout(); } // run layout method on the currently active page widget, to allow it for adapting to // available space if ((this._currentPage > -1) && (this._currentPage < this._widgets.length)) { // do, as if we had set an actual height on the containerNode (which doesn't work, as it is // an auto-sized DIV, so the child widget's layout method can work with the desired height // value this._widgets[this._currentPage].virtualContainerNodeHeight = Math.max(availableHeight - staticHeight, 300); this._widgets[this._currentPage].layout(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, postCreate: function() { // summary: // Binds resources required by this dialog after its DOM has been set up // tags: // protected // entry trace var m = "postCreate()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); this._initializePages(this._pageParams); if (this._widgets.length < 3) { throw new Error(this._nlsMessages.docPickerDialog.errorNotAllWidgetsDefined); } else { for (var i = 0; i < 3; i++) { this._addPageForWidget(i); } } // create lotusui surrounding DIV for this dialog and place this.domNode into it dojo.place(this.domNode, this._findOrCreateLotusUIDIV(), "last"); // exit trace if (this._isTracing) { this.traceExit(m); } }, postMixInProperties : function() { // summary: // Prepares the creation of the user interface of this dialog // tags: // protected // entry trace var m = "postMixInProperties()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, show: function() { // summary: // Overridden show() method of [dijit.Dialog], allowing us to trigger the startup // method // tags: // protected // entry trace var m = "show()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // allow fade-in animation of the dialog to complete, then focus the first tabbable item in the // currently active page setTimeout(dojo.hitch(this, "_onFocusFirstItem"), this.duration + 200); // exit trace if (this._isTracing) { this.traceExit(m); } }, startup: function() { // summary: // Called once all child widgets and the widgets from within the template have been // fully initialized and put into the DOM Tree. Used to initialize some of the // widgets and performing layout related tasks. // tags: // protected // entry trace var m = "startup()"; if (this._isTracing) { this.traceEntry(m); } if (this.wizardPageContainer) { this.wizardPageContainer.startup(); this._currentPage = -1; if(this._usePresetUrl){ this._widgets[0]._authWidget.changeAuthType(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd); this._widgets[0]._authWidget.setAuthenticationProperties({authProperties:this.authProperties}); this._widgets[0]._authWidget._authProperties.authType = com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd; this._onGoFwdPrep(); }else{ // reset _feedType variable on ServerConnectionPageWidget, to make sure it doesn't // return false values this._widgets[0].setFeedType(null); this._switchToPage(0); // StackContainer defaults to first child page (_currentPage will be set by _switchToPage) } } this.layout(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, uninitialize: function() { // summary: // Releases the resources bound by this dialog before it is destroyed // tags: // protected // entry trace var m = "uninitialize()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, _addPageForWidget: function(/*Integer*/ p_widgetIndex) { // summary: // Creates a [dijit.layout.ContentPane] instance for the given // page widget and adds it to the StackContainer // p_widgetIndex: Integer // Index to a widget in the this._widgets Array // tags: // private // entry trace var m = "_addPageForWidget(p_widgetIndex)"; if (this._isTracing) { this.traceEntry(m, p_widgetIndex); } var widget = this._widgets[p_widgetIndex]; // trace if (this._isTracing) { this.trace(m, "Widget for index:", widget); } if (widget) { page = new dijit.layout.ContentPane(); // 283953: With Dojo 1.6, the startup() call on a stack container causes startup() calls // on every single child node. Therefore, calling startup() when a page becomes visible // does not yield the desired result for resize operations, because it is a second startup() // call. Therefore, delegate to the onShow() method instead. // In contrast to the Dojo 1.6 API documentation, the onShow() method of widgets managed // by a StackContainer is not called automatically. Therefore, establish the link to call // the onShow() method on the particular wizard page widget when is becomes visible. // Note: The widgets need to implement onShow() if any specific resizing is required. page.onShow = dojo.hitch(this, function() { widget.onShow(); }); this._pages.push(page); this.wizardPageContainer.addChild(page); widget.placeAt(page.domNode); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearError: function() { // summary: // Clears the error state (sets this._errorState to false) and hides the // error DIV showing the error message. // tags: // private // entry trace var m = "_clearError()"; if (this._isTracing) { this.traceEntry(m); } // clear the error state and hide the error div this._errorState = false; dojo.style(this.wizardErrorDetailsDiv, 'display', 'none'); dojo.style(this.wizardErrorDiv, 'display', 'none'); dijit.setWaiState(this.wizardErrorDiv, 'hidden', true); dijit.setWaiState(this.wizardErrorDetailsDiv, 'hidden', true); /* // now, fade out the error DIV var fArgs = { node: this.wizardErrorDiv, duration: 500, onEnd: dojo.hitch(this, function(node) { // make sure that the errorState is still false (i.e. no other showError call interrupted the clear fadeout) if (this._errorState === false) { dojo.style(this.wizardErrorDetailsDiv, 'display', 'none'); dojo.style(this.wizardErrorDiv, 'display', 'none'); } else { // restore visibility of div, if it is still shown console.log("Dialog._clearError() - resetting opacity to 1"); dojo.style(this.wizardErrorDiv, 'opacity', '1'); } }) }; dojo.fadeOut(fArgs).play(); */ // re-enable buttons in case they were disabled, because of an error this._enableDisableButtons(); // make sure the dialog looks 'good' after closing the box this.layout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _deleteTransientSlot: function() { // summary: // Deletes the transient credential slot // tags: // private // entry trace var m = "_deleteTransientSlot()"; if (this._isTracing) { this.traceEntry(m); } if (this._transientSlotId !== null) { postData = "slotid=" + this._encodePostDataItem(this._transientSlotId); var headers = { "Content-Type": "text/plain", "Accept": "text/plain"}; dojo.xhrPost( { "url": this._vaultMgmtDataSinkUrl, "postData": postData, "handleAs": "text", "headers": headers, "sync": false }); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _enableDisableButtons: function() { // summary: // Enables and disables buttons of the picker dialog based on the internal state. // tags: // private // entry trace var m = "_enableDisableButtons()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } // update Wizard button states if (this._currentPage === 0) { this._setBackBtnEnabled(false); this._setFinishBtnEnabled(false); if (this._isCurrentPageReady() && (!this._errorState)) { this._setNextBtnEnabled(true); } else { this._setNextBtnEnabled(false); } } else { this._setBackBtnEnabled(true); // Finish and Next button handling // if current page is ready and no error occurred if (this._isCurrentPageReady() && (!this._errorState)) { this._setNextBtnEnabled(false); this._setFinishBtnEnabled(true); } else { this._setNextBtnEnabled(false); this._setFinishBtnEnabled(false); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _encodePostDataItem: function(/*String*/ string) { // summary: // Encodes a post data item included // userid: String // The string to encode // returns: String // The encoded string // tags: // private // entry trace var m = "_encodePostDataItem(string)"; if (this._isTracing) { this.traceEntry(m, string); } var ret = encodeURIComponent(string); // exit trace if (this._isTracing) { this.traceExit(m, ret); } return ret; }, _encodeUrlIfNeeded: function(/*String*/ p_url) { // summary: // Detect whether the given URL contains URL encoded entities, by looking // for '%' characters. If none were found, run an encodeURI() on the URL // to encode values that might need encoding (like blanks, etc). // p_url: String // A string containing an item's Url parameter that might need encoding // before it can be added to the feedBaseUrl to produce the result Url // returns: // String The Url which does not need any further encoding // tags: // private // entry trace var m = "_encodeUrlIfNeeded(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } var result = p_url; if (p_url && typeof p_url == 'string' && p_url.indexOf("%") == -1) { // no encoded entities found, encodeURI() should do no harm to this URL result = encodeURI(p_url); // String } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _fetchServerType: function(/*String*/ p_url) { // summary: // Fires an XHRGet request against the feedType detection Datasource // and switches to the correct page according to the returned type. // Stores the result in the serverTypeMap array for later reuse. // p_url: // The url of the feed that we need to determine the type of // tags: // private // entry trace var m = "_fetchServerType(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } // build url for the feedType detection datasource var feedTypeDetectionUrl = this._generateDetectionURL(p_url); this._showDetectingBox(); try { dojo.xhrGet( { "url": feedTypeDetectionUrl, "handleAs": "json", "sync": false, "load": dojo.hitch(this, function(/*Object*/ p_data) { this._fetchServerTypeLoadCallback(p_url, p_data); }), "error": dojo.hitch(this, function(/*Object*/ p_error, /*Object*/ p_ioargs) { this._fetchServerTypeErrorCallback(p_url, p_error, p_ioargs); }) }); } catch(e) { if (e.name && e.message) { this._showError(e.name, e.message); } else { this._showError(this._nlsMessages.docPickerDialog.errorGenericException, e); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _fetchServerTypeErrorCallback: function(/*String*/ p_url, /*Object*/ p_error, /*Object*/ p_ioargs) { // summary: // Callback function to execute when detection of the feed type using a XHR fails // p_url: // The URL employed in the XHR // p_error: // The error that occurred when issuing the XHR // p_ioargs: // The ioargs of the XHR // tags: // private // entry trace var m = "_fetchServerTypeErrorCallback(p_url, p_error, p_ioargs)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_error, p_ioargs]); } this._hideDetectingBox(); if (p_ioargs.xhr.status == 404) { if (p_url.indexOf("/dm/atom/libraries/feed") == -1) { // give it a second try, because the failing initial request might be using a URL // that points to a Quickr server rather than to an actual feed var quickrUrl = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.appendPath(p_url, "/dm/atom/libraries/feed"); this._fetchServerType(quickrUrl); } else { this._showErrorForXHRRequest(p_ioargs); } } else { this._showErrorForXHRRequest(p_ioargs); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _fetchServerTypeLoadCallback: function(/*String*/ p_url, /*Object*/ p_data) { // summary: // Callback function to execute when detection of the feed type using a XHR succeeds // p_url: // The URL employed in the XHR // p_data: // The result of the XHR // tags: // private // entry trace var m = "_fetchServerTypeLoadCallback(p_url, p_data)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_data]); } this._hideDetectingBox(); var feedType = p_data.feedType; if (feedType) { if (feedType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._unknown) { if (p_url.indexOf("/dm/atom/libraries/feed") == -1) { // give it a second try, because the failing initial request might be using a URL // that points to a Quickr server rather than to an actual feed var quickrUrl = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.appendPath(p_url, "/dm/atom/libraries/feed"); this._fetchServerType(quickrUrl); } else { this._showError(this._nlsMessages.docPickerDialog.errorUnknownFeedType, feedType); } } else { // store feedType of current url into serverTypeMap[] this._serverTypeMap[p_url] = feedType; // set feedType on first page this._widgets[0].setFeedType(feedType); // if serverType is a Quickr compatible type, go to quickr picker page instead if (this._isQuickrFeedType(feedType)) { this._switchToQuickrPage(); } else { // make sure to enable auto resizing before performing the page switch, // because a user might have resized the previous page manually this.isResized = false; this._switchToPage(1); } } } else { this._showError(this._nlsMessages.docPickerDialog.errorCouldNotDetectFeedType, ""); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _findOrCreateLotusUIDIV: function() { // summary: // Tries to find an existing dijit.Dialog lotusui30 container DIV in the current page // and if it doesn't find one, creates it. // // Used to avoid flooding the DomTree with lotusui30 related wrapper DIVs, if dialogs // are opened and closed many times. // returns: // The domNode reference of the found or created dijit.Dialog lotusui30 container DIV // tags: // private // entry trace var m = "_findOrCreateLotusUIDIV()"; if (this._isTracing) { this.traceEntry(m); } var lotusui_div = dojo.byId(this.lotusui_id); if (!lotusui_div) { lotusui_div = dojo.create("div", { "id": this.lotusui_id, "class": this.lotusui_class, "wairole": "region", "role": "region" }, dojo.body()); } // set wai state in any case (whether we re-use an existing or newly created // wrapping div) to not break Accessibility dijit.setWaiState(lotusui_div, "labelledby", this.namespace + "GenericDialogTitleSpan_id"); this._lotusui_div = lotusui_div; // exit trace if (this._isTracing) { this.traceExit(m, lotusui_div); } return lotusui_div; }, _generateDetectionURL: function(/*String*/ p_url) { // summary: // Generates the full Url needed to run the feedType detection call // against the server // p_url: String // The Url of the feed to detect the type of // returns: // String Returns the generated detection Url // tags: // private // entry trace var m = "_generateDetectionURL(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } var url = p_url; // encode the given URL and add authentication data as needed url = encodeURIComponent(this._encodeUrlIfNeeded(url)); // get the vault slot ID only if one is set and the vault auth type is used var vaultSlotId; var settings = this._widgets[0].getSettings(); if ((settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault) && (settings.authProperties.vaultSlotID)) { vaultSlotId = encodeURIComponent(settings.authProperties.vaultSlotID); } else if ((settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) && (this._transientSlotId)) { vaultSlotId = encodeURIComponent(this._transientSlotId); } else { vaultSlotId = ""; } // replace the placeholders from the CMIS feed base URL to construct the target URL var result = this._pageParams.feedTypeBaseURL.replace("%7BtypeFilter%7D", "all").replace("%7BfeedUrl%7D", url).replace("%7BmimeType%7D", "application%2Fjson").replace("%7BvaultSlotId%7D", vaultSlotId).replace("%7BserviceId%7D", settings.serviceId); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _getDefaultButton: function() { // summary: // Determines whether the NEXT or FINISH button is the default button // in the current Wizard state. Sets _defaultButton to null, if // both buttons are disabled. // returns: // The domNode reference to the default button, or null, if no button // will react on ENTER // tags: // private // entry trace var m = "_getDefaultButton()"; if (this._isTracing) { this.traceEntry(m); } var finishDisabled = dojo.hasClass(this.dialogConfirm, 'lotusBtnDisabled'); var nextDisabled = dojo.hasClass(this.dialogNext, 'lotusBtnDisabled'); if (finishDisabled && nextDisabled) { this._defaultButton = null; } else { if (nextDisabled) { this._defaultButton = this.dialogConfirm; } else { this._defaultButton = this.dialogNext; } } // exit trace if (this._isTracing) { this.traceExit(m, this._defaultButton); } return this._defaultButton; // domNode }, _getTransientSlot: function(/*String*/ userid, /*String*/ password) { // summary: // Gets the transient credential slot to store the the userid and password // userid: String // The userid // password: String // The password // tags: // private // entry trace var m = "_getTransientSlot(userid, password)"; if (this._isTracing) { this.traceEntry(m, userid, password); } var postData = "name="+this._encodePostDataItem(userid); if (password !== null) { postData = postData + "&pw="+this._encodePostDataItem(password); } if (this._transientSlotId !== null) { postData = postData + "&slotid="+this._encodePostDataItem(this._transientSlotId); } var headers = { "Content-Type": "text/plain", "Accept": "text/plain"}; this._showGettingVaultBox(); dojo.xhrPost( { "url": this._vaultMgmtDataSinkUrl, "postData": postData, "handleAs": "text", "headers": headers, "sync": false, "load": dojo.hitch(this, function(/*Object*/ p_data) { this._hideGettingVaultBox(); this._transientSlotId = p_data; if(this.usePresetUrl){ var settings = this._widgets[0].getSettings(); var url = settings.serverUrl; this._fetchServerType(url);//Need to set actual _feedType before making server connection }else{ this._onGoFwd(); } }), "error": dojo.hitch(this, function(/*Object*/ p_error) { this._hideGettingVaultBox(); this._showError(this._nlsMessages.docPickerDialog.errorCouldNotGetVault, p_error); }) }); // exit trace if (this._isTracing) { this.traceExit(m); } }, _hideDetectingBox: function() { // summary: // Hides the element showing a message indicating that the feed type // detection is running // tags: // private // entry trace var m = "_hideDetectingBox()"; if (this._isTracing) { this.traceEntry(m); } dojo.style(this.fedDocPickerDetectingDiv, 'display', 'none'); dijit.setWaiState(this.fedDocPickerDetectingDiv, 'hidden', true); dijit.setWaiState(this.wizardPageContainer, 'busy', false); // exit trace if (this._isTracing) { this.traceExit(m); } }, _hideGettingVaultBox: function() { // summary: // Hides the element showing a message indicating that the // request for getting a transient vault slot is running // tags: // private // entry trace var m = "_hideGettingVaultBox()"; if (this._isTracing) { this.traceEntry(m); } dojo.style(this.fedDocPickerGettingVaultDiv, 'display', 'none'); dijit.setWaiState(this.fedDocPickerGettingVaultDiv, 'hidden', true); dijit.setWaiState(this.wizardPageContainer, 'busy', false); // exit trace if (this._isTracing) { this.traceExit(m); } }, _initEventHandles: function() { // summary: // Connects the events supported by this dialog to the corresponding callback methods // and stores the handles in the _eventHandles array // tags: // private // entry trace var m = "_initEventHandles()"; if (this._isTracing) { this.traceEntry(m); } // connect standard dialog events this.inherited(arguments); // connect additional wizard events this._eventHandles.push(dojo.connect(this.dialogPrevious, "onclick", this, "_onGoBack")); this._eventHandles.push(dojo.connect(this.dialogFooterForm, "onsubmit", this, "_onSubmit")); // exit trace if (this._isTracing) { this.traceExit(m); } }, _initializePages: function(/*Object*/ p_params) { // summary: // Instantiates widgets for each page and places. Widgets are placed into the // DOM-Tree in buildRendering() // p_params: // see constructor() comment // tags: // private // entry trace var m = "_initializePages(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { // list all arguments passed from constructor this.trace(m, "p_params.authProperties:", dojo.toJson(p_params.authProperties)); this.trace(m, "p_params.availableAuthTypes:", dojo.toJson(p_params.availableAuthTypes)); this.trace(m, "p_params.callingEnvironment:", p_params.callingEnvironment); this.trace(m, "p_params.customServiceSelectionEnabled:", p_params.customServiceSelectionEnabled); this.trace(m, "p_params.documentsServices:", dojo.toJson(p_params.documentsServices)); this.trace(m, "p_params.feedBaseURL:", p_params.feedBaseURL); this.trace(m, "p_params.feedTypeBaseURL:", p_params.feedTypeBaseURL); this.trace(m, "p_params.nlsMessages:", dojo.toJson(p_params.nlsMessages)); this.trace(m, "p_params.nlsUserInterface:", dojo.toJson(p_params.nlsUserInterface)); this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.nodeTypes:", dojo.toJson(p_params.nodeTypes)); this.trace(m, "p_params.onErrorStateChanged", p_params.onErrorStateChanged); this.trace(m, "p_params.onLayoutChanged:", p_params.onLayoutChanged); this.trace(m, "p_params.onReadyStateChanged:", p_params.onReadyStateChanged); this.trace(m, "p_params.pickerContext:", p_params.pickerContext); this.trace(m, "p_params.portalContextPath:", p_params.portalContextPath); this.trace(m, "p_params.pickerManager:", p_params.pickerManager); this.trace(m, "p_params.serviceDocBaseURL:", p_params.serviceDocBaseURL); this.trace(m, "p_params.vaultMgmtDataSinkUrl:", p_params.vaultMgmtDataSinkUrl); this.trace(m, "p_params.vaultSelectionEnabled:", p_params.vaultSelectionEnabled); this.trace(m, "p_params.vaultSelectionEnabledForPZN:", p_params.vaultSelectionEnabledForPZN); this.trace(m, "p_params.vaultSelectionEnabledForWCM:", p_params.vaultSelectionEnabledForWCM); this.trace(m, "p_params.vaultSlots:", dojo.toJson(p_params.vaultSlots)); } } // init the wizard page widgets and make sure to pass on constructor arguments, // so that each child widget can grab the information it needs var widRef; // init page 1 widget widRef = new com.ibm.workplace.wcm.ecm.picker.widget.ServerConnectionPageWidget(p_params); this._widgets.push(widRef); // init page 2 widget widRef = new com.ibm.workplace.wcm.ecm.picker.widget.CmisDocumentPickerPageWidget(p_params); this._widgets.push(widRef); // init page 3 widget widRef = new com.ibm.workplace.wcm.ecm.picker.widget.QuickrDocumentPickerPageWidget(p_params); this._widgets.push(widRef); // exit trace if (this._isTracing) { this.traceExit(m); } }, _initNLS: function() { // summary: // Initializes the aspects for supporting localization, for example, by loading the required NLS bundle(s). // Overrides the implementation from [com.ibm.widgets.GenericDialog], but leaves it up to the super to ensure // that it is called // tags: // protected // entry trace var m = "_initNLS()"; if (this._isTracing) { this.traceEntry(m); } this._nlsUserInterface = dojo.i18n.getLocalization("com.ibm.workplace.wcm.ecm.picker", 'FederatedDocumentsPickerUserInterface'); this._nlsMessages = dojo.i18n.getLocalization("com.ibm.workplace.wcm.ecm.picker", 'FederatedDocumentsPickerMessages'); // exit trace if (this._isTracing) { this.trace(m, "Initialized NLS object for user interface elements:", dojo.toJson(this._nlsUserInterface)); this.trace(m, "Initialized NLS object for messages:", dojo.toJson(this._nlsMessages)); this.traceExit(m); } }, _isCalledFromPZN: function() { // summary: // Returns an indication as to whether this widget is rendered in the context of Personalization // returns: // true if the rendering context is Personalization, false otherwise // tags: // private // entry trace var m = "_isCalledFromPZN()"; if (this._isTracing) { this.traceEntry(m); } var result = (this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _isCalledFromWCM: function() { // summary: // Returns an indication as to whether this widget is rendered in the context of Web Content Management // returns: // true if the rendering context is Web Content Management, false otherwise // tags: // private // entry trace var m = "_isCalledFromWCM()"; if (this._isTracing) { this.traceEntry(m); } var result = (this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _isCurrentPageReady: function() { // summary: // Checks whether the page currently active in the dialog is in ready state. // Being in the ready state means that all data was collected on the page which // is either necessary to advance to the next page or to finish the dialog. // returns: // true, if the current page is in ready state, false otherwise // tags: // private // entry trace var m = "_isCurrentPageReady()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } // init the result var result = false; if ((this._currentPage > -1) && (this._currentPage < this._pages.length)) { var widRef = this._widgets[this._currentPage]; result = widRef.isReady(); } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _isQuickrFeedType: function(/*String*/ p_feedType) { // summary: // Determines whether the passed in feedType identifier is a Quickr type or not // returns: Boolean // true if the given type is a Quickr type, false if not // tags: // private var result; if ((p_feedType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds) || (p_feedType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qdsentry)) { result = true; } else { result = false; } return result; }, _layoutAutoResize: function(/*Integer*/ p_headerHeight, /*Integer*/ p_footerHeight, /*Integer*/ p_maxAllowedHeight, /*Integer*/ p_maxAllowedWidth) { // summary: // Resizes the dialog considering the size of its content and the maximum available space in the viewport. // This method should be used for adapting the layout of the dialog as long as the dialog size has not been // changed manually by the user // p_headerHeight: Integer // The height of the header section of this dialog in pixels // p_footerHeight: Integer // The height of the footer section of this dialog in pixels // p_maxAllowedHeight: Integer // The maximum height allowed for this dialog in pixels // p_maxAllowedWidth: Integer // The maximum width allowed for this dialog in pixels // tags: // private // entry trace var m = "_layoutAutoResize(p_headerHeight, p_footerHeight, p_maxAllowedHeight, p_maxAllowedWidth)"; if (this._isTracing) { this.traceEntry(m, [p_headerHeight, p_footerHeight, p_maxAllowedHeight, p_maxAllowedWidth]); } // height of the content, including invisible parts (due to overflow) var contentHeight = Math.max(this.containerNode.scrollHeight, this.containerNode.offsetHeight); var contentWidth = Math.max(this.containerNode.scrollWidth, this.containerNode.offsetWidth); // currently visible height of the content (height of the wizard page content container) var currentContentHeight = dojo.marginBox(this.containerNode).h; // height of the dialog with no vertical scrollbar needed var dialogHeight = p_headerHeight + contentHeight + p_footerHeight; // width of the dialog with no horizontal scrollbar needed var dialogWidth = this._dialogBorderWidth + contentWidth; // current height of the dialog, showing a vertical scrollbar if smaller than 'dialogHeight' var currentDialogHeight = p_headerHeight + currentContentHeight + p_footerHeight; // currently visible height of the content (height of the wizard page content container) var currentContentWidth = dojo.marginBox(this.containerNode).w; var currentDialogWidth = currentContentWidth + this._dialogBorderWidth; // trace if (this._isTracing) { this.trace(m, "contentHeight:", contentHeight); this.trace(m, "currentContentHeight:", currentContentHeight); this.trace(m, "currentContentWidth:", currentContentWidth); this.trace(m, "dialogHeight:", dialogHeight); this.trace(m, "currentDialogHeight:", currentDialogHeight); this.trace(m, "currentDialogWidth:", currentDialogWidth); } // only reset height/width to value 'auto', if the user hasn't resized the // dialog manually yet if (this.isResized === false) { // make sure the most outer dialog div adapts to its content, // in particular in cases when switching a page after having // manually resized the dialog dojo.style(this.GenericDialogDiv, "height", "auto"); // make sure the most outer dialog div adapts to its content, // in particular in cases when switching a page after having // manually resized the dialog dojo.style(this.GenericDialogDiv, "width", "auto"); // if the dialog has not been resized manually, guarantee that // the dialog admits the whole content to fit into it (HEIGHT) if (currentDialogHeight > p_maxAllowedHeight) { var reducedHeight = p_maxAllowedHeight - p_headerHeight - p_footerHeight; // trace if (this._isTracing) { this.trace(m, "Reducing the dialog container node height to:", reducedHeight); } dojo.marginBox(this.containerNode, { "h": reducedHeight }); } else if (currentDialogHeight >= dialogHeight) { // trace if (this._isTracing) { this.trace(m, "Setting the dialog container node height 'auto'"); } dojo.style(this.containerNode, 'height', 'auto'); } else if ((currentDialogHeight < p_maxAllowedHeight) && (currentDialogHeight < dialogHeight)) { // when using the dialog height, add one additional pixel, because the new height is applied // to the container surrounding the content and needs to be larger to avoid scroll-bars var increasedHeight = Math.min(p_maxAllowedHeight - p_headerHeight - p_footerHeight, dialogHeight + 1 - p_headerHeight - p_footerHeight); // trace if (this._isTracing) { this.trace(m, "Increasing the dialog container node height to:", increasedHeight); } dojo.marginBox(this.containerNode, { "h": increasedHeight }); } // if the dialog has not been resized manually, guarantee that // the dialog admits the whole content to fit into it (WIDTH) if (currentDialogWidth > p_maxAllowedWidth) { var reducedWidth = p_maxAllowedWidth - this._dialogBorderWidth; // trace if (this._isTracing) { this.trace(m, "Reducing the dialog container node width to:", reducedWidth); } dojo.marginBox(this.containerNode, { "w": reducedWidth }); } else if (currentDialogWidth >= dialogWidth) { // trace if (this._isTracing) { this.trace(m, "Setting the dialog container node Width 'auto'"); } dojo.style(this.containerNode, 'width', 'auto'); } else if ((currentDialogWidth < p_maxAllowedWidth) && (currentDialogWidth < dialogWidth)) { // when using the dialog width, add one additional pixel, because the new width is applied // to the container surrounding the content and needs to be larger to avoid scroll-bars var increasedWidth = Math.min(p_maxAllowedWidth - this._dialogBorderWidth, dialogWidth + 1 - this._dialogBorderWidth); // trace if (this._isTracing) { this.trace(m, "Increasing the dialog container node width to:", increasedWidth); } dojo.marginBox(this.containerNode, { "w": increasedWidth }); } // make sure that the wizard page container layout is also updated, when the dialog // size changes if (this.wizardPageContainer) { this.wizardPageContainer.layout(); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _layoutManualResize: function(/*Integer*/ p_headerHeight, /*Integer*/ p_footerHeight, /*Integer*/ p_maxAllowedHeight, /*Integer*/ p_maxAllowedWidth) { // summary: // Resizes the dialog considering the size of its content and the maximum available space in the viewport. // This method should be used for adapting the layout of the dialog from the moment of manually changing // the dialog size onwards // p_headerHeight: Integer // The height of the header section of this dialog in pixels // p_footerHeight: Integer // The height of the footer section of this dialog in pixels // p_maxAllowedHeight: Integer // The maximum height allowed for this dialog in pixels // p_maxAllowedWidth: Integer // The maximum width allowed for this dialog in pixels // tags: // private // entry trace var m = "_layoutManualResize(p_headerHeight, p_footerHeight, p_maxAllowedHeight, p_maxAllowedWidth)"; if (this._isTracing) { this.traceEntry(m, [p_headerHeight, p_footerHeight, p_maxAllowedHeight, p_maxAllowedWidth]); } // Adjusting the HEIGHT // height of the error message box var errorHeight = Math.max(dojo.contentBox(this.wizardErrorDiv).h, 0); // height of the wizard page step header var stepHeaderHeight = p_headerHeight; // height of the most crucial dialog sections that should always be visible var minAllowedHeight = p_headerHeight + errorHeight + stepHeaderHeight + p_footerHeight; // get the dialog box height, which changes when the user changes // the dialog size using the resize handle var dialogBoxHeight = dojo.marginBox(this.GenericDialogDiv).h; // make sure the most crucial dialog sections are guaranteed to be shown var dialogBoxHeightNew = Math.max(dialogBoxHeight, minAllowedHeight); // make sure the dialog box height is less than the viewport height dialogBoxHeightNew = Math.min(dialogBoxHeightNew, p_maxAllowedHeight); // make sure the dialog content container height adapts to the new dialog box height var contentHeightNew = dialogBoxHeightNew - p_headerHeight - p_footerHeight - this._dialogBorderWidth; // trace if (this._isTracing) { this.trace(m, "errorHeight:", errorHeight); this.trace(m, "stepHeaderHeight:", stepHeaderHeight); this.trace(m, "dialogBoxHeight:", dialogBoxHeight); this.trace(m, "dialogBoxHeightNew:", dialogBoxHeightNew); this.trace(m, "contentHeightNew:", contentHeightNew); } // Adjusting the HEIGHT // set the new box height of the element containing all of what makes up the dialog dojo.marginBox(this.GenericDialogDiv, { h: dialogBoxHeightNew }); // set the dialog content container height to suit the dialog box height dojo.marginBox(this.containerNode, { h: contentHeightNew }); // make sure that the wizard page container layout is also updated, when the dialog // size changes this.wizardPageContainer.layout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _normalizeFeedTypeParam: function(/*String*/ p_feedType) { // summary: // Normalizes the given feedType String to either 'cmis' or 'qds' for attaching it to // the result Url in PZN case. // returns: String // The normalized feedType ('cmis' or 'qds') or the value of p_feedType, if it is an unknown // feedType. If p_feedType is undefined or not a string, the method returns an empty string. // tags: // private // entry trace var m = "_normalizeFeedTypeParam(p_feedType)"; if (this._isTracing) { this.traceEntry(m); } var result = ""; if (typeof p_feedType == 'string') { var lcFeedType = p_feedType.toLowerCase(); if ((lcFeedType === 'cmis') || (lcFeedType === 'servicedoc')) { result = 'cmis'; } else if ((lcFeedType === 'qds') || (lcFeedType === 'qdsentry')) { result = 'qds'; } // TODO: what about 'atom' as the feedType? } else { result = ""; } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _onCancel: function() { // summary: // Overridden GenericDialog _onCancel method. We need to do this as we're not using // the GenericDialog with a single _widget instance // tags: // private callback // entry trace var m = "_onCancel()"; if (this._isTracing) { this.traceEntry(m); } this._deleteTransientSlot(); if (this._onCancelCallbackFn && dojo.isFunction(this._onCancelCallbackFn)) { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function:", this._onCancelCallbackFn); } this._onCancelCallbackFn(); } if (this.autoClose) { // destroy this dialog (but allow the hide animation to complete before) this.hide(); setTimeout(dojo.hitch(this, "destroyDialog"), this.duration + 200); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onConfirm: function() { // summary: // Overridden default GenericDialog _onConfirm method. We need to do this as we're not using // the GenericDialog with a single _widget instance // tags: // private callback // entry trace var m = "_onConfirm()"; if (this._isTracing) { this.traceEntry(m); } this._deleteTransientSlot(); if (!dojo.hasClass(this.dialogConfirm, 'lotusBtnDisabled')) { var returnURL = ""; var title = ""; var url = ""; var selItem = this.getSelectedItemJSON(); // trace if (this._isTracing) { this.trace(m, "Selected item:", selItem); } if (selItem !== null) { title = selItem.title; url = selItem.url; if (this._isCalledFromPZN()) { // grab authProperties from the server connection widget var settings = this._widgets[0].getSettings(); // grab the feedType from the server connection widget returnURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.addQueryParameter(url, "feedType", this._normalizeFeedTypeParam(settings.serverType)); // authentication information is only attached for PZN calling environment // attach vault Slot only if one is set and the vault auth type is used if ((settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault) && (settings.authProperties.vaultSlotID)) { returnURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.addQueryParameter(returnURL, com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._proxyVaultSlotParamName, settings.authProperties.vaultSlotID); } // Set the _selectedPath with the array of ids of tree nodes starting from the root node and going down to the selected node var dlg = this; this._widgets[1].getLibTree().path.forEach(function(node,i){ dlg._selectedPath[i++]=node.id; }); } else { // URL is returned as-is in WCM environment returnURL = url; } } if (this._onConfirmCallbackFn && dojo.isFunction(this._onConfirmCallbackFn)) { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function passing title and URL of selection:", [this._onConfirmCallbackFn, title, returnURL]); } this._onConfirmCallbackFn(title, returnURL, this._selectedPath); } if (this.autoClose) { // hide and destroy this dialog this.hide(); setTimeout(dojo.hitch(this, "destroyDialog"), this.duration + 200); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onDefaultAction: function() { // summary: // Callback triggered by one or more onKeypress handlers to trigger the default // action currently assigned to the ENTER key. Based on the page selected, this // could either be clicking the NEXT or the FINISH button. // tags: // private callback // entry trace var m = "_onDefaultAction()"; if (this._isTracing) { this.traceEntry(m); } var defBtn = this._getDefaultButton(); if (defBtn === this.dialogConfirm) { this._onConfirm(); } else if (defBtn === this.dialogNext) { this._onGoFwdPrep(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onErrorStateChanged: function(/*Object*/ p_sender, /*Boolean*/ p_errorState, /*String*/ p_errorMsg, /*String?*/ p_errorDetails) { // summary: // Shows the given error message in the red error message box within // the dialog. Optionally, also shows details for the error // in a white box. // p_sender: Object // The widget instance sending this error to this dialog. // p_errorState: Boolean // The flag indicating whether the calling widget went into error state, or whether the // error state was left. // p_errorMsg: String // The error message to display // p_errorDetails: String // Optional string with a more detailed description of the error // tags: // private callback var m = "_onErrorStateChanged(p_sender, p_errorState, p_errorMsg, p_errorDetails)"; if (this._isTracing) { this.traceEntry(m, [p_sender, p_errorState, p_errorMsg, p_errorDetails]); } if (p_errorState === true) { this._showError(p_errorMsg, p_errorDetails); } else { if (p_errorState === false) { this._clearError(); } else { // p_errorState is not a Boolean value } } if (this._isTracing) { this.traceExit(m); } }, _onFocusFirstItem: function() { // summary: // Callback method triggered when the dialog finished showing for the first time and // used to delegate focusing to the respective active page (if there is one) // tags: // private callback // entry trace var m = "_onFocusFirstItem()"; if (this._isTracing) { this.traceEntry(m); } if ((this._currentPage > -1) && (this._currentPage < 3)) { if (this._widgets[this._currentPage] && dojo.isFunction(this._widgets[this._currentPage].setFocus)) { this._widgets[this._currentPage].setFocus(); } } if (this._isTracing) { this.traceExit(m); } }, _onGoBack: function(/*Event*/ p_evt) { // summary: // Callback method triggered when the 'Back' button was clicked. First checks whether // the button is enabled (i.e. the click needs to be processed) and then selects the // previous page of the currently selected one (if available). // tags: // private callback // entry trace var m = "_onGoBack()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } dojo.stopEvent(p_evt); if (!dojo.hasClass(this.dialogPrevious, 'lotusBtnDisabled')) { if (this._currentPage > 0) { // make sure to enable auto resizing before performing the page switch, // because a user might have resized the previous page manually this.isResized = false; // reset _feedType variable on ServerConnectionPageWidget, to make sure it doesn't // return false values this._widgets[0].setFeedType(null); // always go back to first page this._switchToPage(0); } } // exit trace if (this._isTracing) { this.traceExit(m); } return false; }, _onGoFwdPrep: function() { // summary: // Callback method triggered when the 'Next' button was clicked. In case of // username / password authentication it gets the transient slot and invokes // onGoFwd through _getTransientSlot. In the other cases it invokes onGoFwd directly. // tags: // private callback // entry trace var m = "_onGoFwdPrep()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } if (this.usePresetUrl || (!dojo.hasClass(this.dialogNext, 'lotusBtnDisabled')) && (this._currentPage < this._pages.length - 1)) { var settings = this._widgets[0].getSettings(); if (settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) { var userid = settings.authProperties.username; var password = settings.authProperties.password; this._getTransientSlot(userid, password); } else { this._onGoFwd(); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onGoFwd: function() { // summary: // Callback method triggered indirectly by onGoFwdPrep when the 'Next' button was clicked. // First checks whether the button is enabled (i.e. the click needs to be processed) // and then selects the next page of the currently selected one (if available). // tags: // private callback // entry trace var m = "_onGoFwd()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } if (!dojo.hasClass(this.dialogNext, 'lotusBtnDisabled')) { if (this._currentPage < this._pages.length - 1) { var settings = this._widgets[0].getSettings(); var url = settings.serverUrl; // try to find the feedTyp of the current server Url in our local // type map array var feedType = this._serverTypeMap[url]; if (feedType) { // use the buffered type info and switch to the correct page directly // set feedType on first page this._widgets[0].setFeedType(feedType); // if serverType is a Quickr compatible type, go to quickr picker page instead if (this._isQuickrFeedType(feedType)) { this._switchToQuickrPage(); } else { // make sure to enable auto resizing before performing the page switch, // because a user might have resized the previous page manually this.isResized = false; this._switchToPage(1); } } else { // no buffered info found // To avoid calling the remote feed detection datasource for predefined Quickr // Servers, call _determineServerType() to find out, whether it's a Quickr // server. if not, we have to run the feed type detection code, as a predefined // CMIS server could always be either a service doc or a folder/repository Url var serverType = settings.serverType; if (serverType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds) { // fast path for predefined Quickr Servers. Go directly to the Quickr page without // running remote feed type detection // buffer type information this._serverTypeMap[url] = serverType; // set feedType on first page this._widgets[0].setFeedType(serverType); this._switchToQuickrPage(); } else { // this is not a predefined Quickr type server, so it's either a predefined // CMIS server that we need to scan for the exact type, or a custom server that needs // to get auto-detected anyway this._fetchServerType(url); } } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onReadyStateChanged: function(/*Boolean*/ p_readyState, /*Object*/ p_widgetRef) { // summary: // Callback triggered by any of the available page widget instances, whenever their // ready state changes. The dialog uses this information to update the enabled/disabled // state of it's buttons. // p_readyState: Boolean // Indicates whether the calling widget is ready (true) or not (false) // p_widgetRef: Object // [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget] instance of the page // widget calling this method // tags: // private callback // entry trace var m = "_onReadyStateChanged(p_readyState, p_widgetRef)"; if (this._isTracing) { this.traceEntry(m, [p_readyState, p_widgetRef]); } /* No need to double-check whether the calling widget is the active one, as only the * active one could be changed and therefore is the only one that could trigger this method * * if (p_widgetRef == this._widgets[this._currentPage]) { // ready state change is for the current page }*/ this._enableDisableButtons(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onSubmit: function(/*Event*/ p_evt) { // summary: // Callback that is triggered, when one of the submit buttons (BACK, NEXT, FINISH) // is clicked, or if ENTER is pressed. // p_evt: Event // The event that caused the submit method to be called // returns: Boolean // Always returns false, to cancel the default submit action (which would // reload the page) // tags: // private callback // entry trace var m = "_onSubmit(p_evt)"; if (this._isTracing) { this.traceEntry(m, [p_evt]); } dojo.stopEvent(p_evt); this._onDefaultAction(); // exit trace if (this._isTracing) { this.traceExit(m, false); } // prevent browser to actually submit a form (would cause a page refresh) return false; // Boolean }, _setBackBtnEnabled: function(/*Boolean*/ p_isEnabled) { // summary: // Helper method for setting the enabled/disabled state of the Back button // p_isEnabled: Boolean // Defines the enabled state of the button. If set to true, the disabled CSS classes are // removed from the DOM node. Otherwise, they get added to it. // tags: // private // entry trace var m = "_setBackBtnEnabled(p_isEnabled)"; if (this._isTracing) { this.traceEntry(m, [p_isEnabled]); } this._setBtnEnabled(this.dialogPrevious, p_isEnabled); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setBtnEnabled: function(/*DomNode*/ p_Btn, /*Boolean*/ p_isEnabled) { // summary: // Helper method for setting the enabled/disabled state of the given button // p_Btn: DOMNode // DOMNode of the button that needs to be updated // p_isEnabled: Boolean // Defines the enabled state of the button. If set to true, the disabled CSS classes are // removed from the DOM node. Otherwise, they get added to it. // tags: // private // entry trace var m = "_setBtnEnabled(p_Btn, p_isEnabled)"; if (this._isTracing) { this.traceEntry(m, [p_Btn, p_isEnabled]); } if (p_isEnabled) { dojo.removeClass(p_Btn, 'lotusBtnDisabled'); dojo.removeAttr(p_Btn, 'disabled'); dijit.removeWaiState(p_Btn, 'disabled'); } else { dojo.addClass(p_Btn, 'lotusBtnDisabled'); dojo.attr(p_Btn, 'disabled', 'disabled'); dijit.setWaiState(p_Btn, 'disabled', true); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _setFinishBtnEnabled: function(/*Boolean*/ p_isEnabled) { // summary: // Helper method for setting the enabled/disabled state of the Finish button // p_isEnabled: Boolean // Defines the enabled state of the button. If set to true, the disabled CSS classes are // removed from the DOM node. Otherwise, they get added to it. // tags: // private // entry trace var m = "_setFinishBtnEnabled(p_isEnabled)"; if (this._isTracing) { this.traceEntry(m, [p_isEnabled]); } this._setBtnEnabled(this.dialogConfirm, p_isEnabled); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setNextBtnEnabled: function(/*Boolean*/ p_isEnabled) { // summary: // Helper method for setting the enabled/disabled state of the Next button // p_isEnabled: Boolean // Defines the enabled state of the button. If set to true, the disabled CSS classes are // removed from the DOM node. Otherwise, they get added to it. // tags: // private // entry trace var m = "_setNextBtnEnabled(p_isEnabled)"; if (this._isTracing) { this.traceEntry(m, [p_isEnabled]); } this._setBtnEnabled(this.dialogNext, p_isEnabled); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showDetectingBox: function() { // summary: // Displays the element showing a message indicating that the feed type // detection is running (which is an asynchronous operation that involves // a server connection) // tags: // private // entry trace var m = "_showDetectingBox()"; if (this._isTracing) { this.traceEntry(m); } if (dojo.style(this.fedDocPickerDetectingDiv, 'display') != 'block') { dojo.style(this.fedDocPickerDetectingDiv, 'display', 'block'); } dijit.setWaiState(this.fedDocPickerDetectingDiv, 'hidden', false); dijit.setWaiState(this.wizardPageContainer, 'busy', true); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showError: function(/*String*/ p_errorMsg, /*String?*/ p_errorDetails) { // summary: // Shows the given error message in the red error message box within // the dialog. Optionally, also shows details for the error // in a white box. // p_errorMsg: String // The error message to display // p_errorDetails: String // Optional string with a more detailed description of the error // tags: // private callback // entry trace var m = "_showError(p_errorMsg, p_errorDetails)"; if (this._isTracing) { this.traceEntry(m, [p_errorMsg, p_errorDetails]); } this._hideDetectingBox(); this._hideGettingVaultBox(); if (typeof p_errorMsg == 'string') { var _errMsg = p_errorMsg.substring(0, Math.min(this._maxErrorChars, p_errorMsg.length)); dojo.attr(this.wizardErrorSpan, 'innerHTML', _errMsg); dojo.style(this.wizardErrorDiv, 'opacity', '1'); dojo.style(this.wizardErrorDiv, 'display', 'block'); dijit.setWaiState(this.wizardErrorDiv, 'hidden', false); if (typeof p_errorDetails == 'string') { var _errDetails = p_errorDetails.substring(0, Math.min(this._maxErrorChars, p_errorDetails.length)); dojo.attr(this.wizardErrorDetailsSpan, 'innerHTML', _errDetails); dojo.style(this.wizardErrorDetailsDiv, 'display', 'block'); dijit.setWaiState(this.wizardErrorDetailsDiv, 'hidden', false); } /* // now, fade in the error DIV var fArgs = { node: this.wizardErrorDiv, duration: 500, onEnd: dojo.hitch(this, function() { console.log("Dialog.showError().anim.play.onEnd(), opacity 1, display: block"); }) }; dojo.fadeIn(fArgs).play(); */ } else { this.trace(m, '_showError was called with an undefined error message.'); } // record error and set error state to true. Need to call _clearError() to // get out of error state again. this._errorState = true; // also set the errorState on the currently active page widget to allow their error // handling code to function correctly. Otherwise, code that clears errors wouldn't be // effective afterwards if ((this._currentPage >= 0) && (this._currentPage <= 2)) { this._widgets[this._currentPage]._errorState = true; } // disable buttons, in case they were showing enabled, but user cannot continue // because of an error that occurred this._enableDisableButtons(); // make sure the dialog looks 'good' after opening the error box this.layout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showErrorForXHRRequest: function(/*Object*/ioargs) { // summary: // Shows the error message for a failed XHR request // ioargs: // The ioargs of the XHR request // tags: // private // entry trace var m = "_showErrorForXHRRequest()"; if (this._isTracing) { this.traceEntry(m, ioargs); } var errorMsg = com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils._INSTANCE.getErrorMessage( ioargs, this._nlsMessages.srvCommunication, (this._widgets[0].getSettings().serverUrl.substring(0, 6).toLowerCase() === "https:") ); this._showError(errorMsg[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorMessage], errorMsg[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorDetails]); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showGettingVaultBox: function() { // summary: // Displays the element showing a message indicating that the request for // the transient vault slot is running (which is an asynchronous operation that involves // a server connection) // tags: // private // entry trace var m = "_showGettingVaultBox()"; if (this._isTracing) { this.traceEntry(m); } if (dojo.style(this.fedDocPickerGettingVaultDiv, 'display') != 'block') { dojo.style(this.fedDocPickerGettingVaultDiv, 'display', 'block'); } dijit.setWaiState(this.fedDocPickerGettingVaultDiv, 'hidden', false); dijit.setWaiState(this.wizardPageContainer, 'busy', true); // exit trace if (this._isTracing) { this.traceExit(m); } }, _switchToPage: function(/*Integer*/ p_pageIndex, /*String?*/ p_feedType) { // summary: // Switches to the given page by looking the page instance up in the _pages[] array, // setting it as the active page on the StackContainer widget and running any related // update methods (e.g. updating labels in the dialog). // p_pageIndex: Integer // Index to the page in this._pages[] array that should become active // p_feedType: String [optional] // Type of the selected server. This is a required parameter when switching // to Page 1 (Cmis page). Switching back to page 0 (Server connection page) or // Page 2 (Quickr Page), this parameter is not needed. // tags: // private // entry trace var m = "_switchToPage(p_pageIndex)"; if (this._isTracing) { this.traceEntry(m, [p_pageIndex]); this.trace(m, "Current page:", this._currentPage); } if ((p_pageIndex > -1) && (p_pageIndex < this._pages.length)) { // when switching pages, clear error message this._clearError(); // and hide the detecting box this._hideDetectingBox(); this._hideGettingVaultBox(); this._currentPage = p_pageIndex; // update wizard step and description information var widRef = this._widgets[this._currentPage]; this._updateStepLabel(widRef.getStepLabel()); this._updateStepDescription(widRef.getStepDescription()); this.wizardPageContainer.selectChild(this._pages[this._currentPage]); if (this._currentPage > 0) { // CMIS or Quickr picker page (transition from page 1 to page 2 or 3) var settings = this._widgets[0].getSettings(); if ((settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) && (this._transientSlotId)) { settings.authProperties.vaultSlotID = this._transientSlotId; } this._widgets[this._currentPage].initializePage(settings); } else { // do anything that needs to be done when going back to first page } this._enableDisableButtons(); // process the layout of the dialog this.layout(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _switchToQuickrPage: function() { // summary: // Checks whether Quickr Document Services support is enabled. Depending on the result // this method either switches to the Quickr page of this dialog or displays an error // message. // tags: // private // entry trace var m = "_switchToQuickrPage()"; if (this._isTracing) { this.traceEntry(m); } if (this._qdsSupportEnabled) { // make sure to enable auto resizing before performing the page switch, // because a user might have resized the previous page manually this.isResized = false; // go to Quickr Page this._switchToPage(2); } else { this._showError(this._nlsMessages.docPickerDialog.errorQDSNotEnabled, ""); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _updateStepDescription: function(/*String*/ p_descrText) { // summary: // Updates the step description text in the dialog. // p_descrText: String // The descriptive text for this wizard step (describing what needs to be done with // the active page widget) // tags: // private // entry trace var m = "_updateStepDescription(p_descrText)"; if (this._isTracing) { this.traceEntry(m, p_descrText); } dojo.attr(this.wizardStepDescription, 'innerHTML', p_descrText); // exit trace if (this._isTracing) { this.traceExit(m); } }, _updateStepLabel: function(/*String*/ p_labelText) { // summary: // Updates the step label in the dialog. The step label indicates which step // of a total number of steps is currently active in the dialog. // p_labelText: String // The new text for the step label // tags: // private // entry trace var m = "_updateStepLabel(p_labelText)"; if (this._isTracing) { this.traceEntry(m, p_labelText); } dojo.attr(this.wizardStepLabel, 'innerHTML', "" + p_labelText + ""); // exit trace if (this._isTracing) { this.traceExit(m); } } }); } if(!dojo._hasResource['com.ibm.workplace.wcm.ecm.quickr.picker.launcher.DocPickerLauncher']){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource['com.ibm.workplace.wcm.ecm.quickr.picker.launcher.DocPickerLauncher'] = true; /*********************************************************************/ /* Licensed Materials - Property of IBM */ /* */ /* 5724-S31 */ /* */ /* Copyright IBM Corp. 2009 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /*********************************************************************/ dojo.provide('com.ibm.workplace.wcm.ecm.quickr.picker.launcher.DocPickerLauncher'); dojo.declare('com.ibm.workplace.wcm.ecm.quickr.picker.launcher.DocPickerLauncher', null, { _onConfirmCallbackFn: null, _onCloseCallbackFn: null, _dialogTitleKey: "dialogTitleDefault", _locale: null, _showPlaces: false, _showNodePath: true, _nodeTypes: [], _downloadTypes: [], _viewTypes: [], _forceSSO: false, _isMovable: true, _allowCustomServers: true, _allowedHosts: [], _cookieName: "QuickrPickerRecentHosts", _lastHostCookie: "qkrMRHU", _proxyUrl : "/wps/proxy", _pageSize: 10, _timeout: 15000, _linkType: null, _currentItem: null, _nodeType2Selector: { place: "new quickr.picker.data.filter.PlaceSelector()", library: "new quickr.picker.data.filter.LibrarySelector()", folder: "new quickr.picker.data.filter.FolderSelector()", doclink: "new quickr.picker.data.filter.DocLinkSelector()", document: "new quickr.picker.data.filter.DocumentSelector()" }, _nlsStrings: null, _onCloseHdl: null, _onShowHdl: null, _pickerDialog: null, _feedUrl: "", // summary: // Constructor of DocPickerLauncher. // p_onConfirmCallbackFn: // Javascript function to call when the selection of an item is confirmed pressing 'OK' in the document picker dialog. // p_onCloseCallbackFn: // Javascript function to call when the document picker dialog is closed. (optional) // p_args: // Arguments to initialize the DocPickerLauncher with. (optional) constructor: function(/*function*/ p_onConfirmCallbackFn, /*function?*/ p_onCloseCallbackFn, /*object?*/ p_args) { if (typeof p_onConfirmCallbackFn == 'function') { this._onConfirmCallbackFn = p_onConfirmCallbackFn; } if (typeof p_onCloseCallbackFn == 'function') { this._onCloseCallbackFn = p_onCloseCallbackFn; } this._evalArgs(p_args); this._loadPrereqs(); }, // summary: // Launches the document picker. launchDocumentPicker: function(/*String*/ p_url) { var insertLinkAction; // store URL as instance variable to have access to it from the _injectUrl method this._feedUrl = p_url; // explicitly bind 'inst' to 'this' because this will be bound to the JS global object when the anonymous fn for the onItemSelected event gets called inst = this; if (this._downloadTypes.length > 0 && this._viewTypes.length > 0) { this._linkType = 'any'; var viewLinkAction = { displayText: this._nlsStrings.menuItemViewLink, onClick: function(p_dialog) { inst._confirmSelection(p_dialog, 'view'); }, onItemSelected: function(p_button, p_dialog, p_picker) { inst._onItemSelected(p_button, p_dialog, p_picker); } }; var downloadLinkAction = { displayText: this._nlsStrings.menuItemDownloadLink, onClick: function(p_dialog) { inst._confirmSelection(p_dialog, 'download'); }, onItemSelected: function(p_button, p_dialog, p_picker) { inst._onItemSelected(p_button, p_dialog, p_picker); } }; insertLinkAction = { displayType: 'menubutton', displayText: this._nlsStrings.menuInsertLink, menuItems: [ viewLinkAction, downloadLinkAction ] }; } else { if (this._downloadTypes.length > 0) { this._linkType = 'download'; } else if (this._viewTypes.length > 0) { this._linkType = 'view'; } if (this._linkType) { insertLinkAction = { displayType: 'button', displayText: this._nlsStrings.buttonOk, onClick: function(p_dialog) { inst._confirmSelection(p_dialog, inst._linkType); }, onItemSelected: function(p_button, p_dialog, p_picker) { inst._onItemSelected(p_button, p_dialog, p_picker); } }; } } var cancelAction = quickr.picker.widgets.PickerDialog.getCancelAction(); var actions; if (typeof insertLinkAction != 'undefined') { actions = [insertLinkAction, cancelAction]; } else { actions = [cancelAction]; } var filters = { filterAttribute: "category" }; if (this._nodeTypes.length === 0) { filters.place = [new quickr.picker.data.filter.PlaceSelector()]; filters.library = [new quickr.picker.data.filter.LibrarySelector()]; filters.folder = [new quickr.picker.data.filter.FolderSelector()]; filters.doclink = [new quickr.picker.data.filter.DocLinkSelector()]; filters.document = [new quickr.picker.data.filter.DocumentSelector()]; } else { for (i = 0; i < this._nodeTypes.length; i++) { var nodeType = this._nodeTypes[i]; var selector = this._nodeType2Selector[nodeType]; if (typeof selector == 'string') { filters[nodeType] = eval("[" + selector + "]"); } } } var args = { title: this._nlsStrings[this._dialogTitleKey], pickerfilters: filters, isBrowseLocalOnly: false, showSummary: this._showNodePath, showPlaces: this._showPlaces, isMovable: this._isMovable, actions: actions, forceSSO: this._forceSSO, allowCustomServers: this._allowCustomServers, allowedHosts: this._allowedHosts, cookieName: this._cookieName, lastHostCookie: this._lastHostCookie, proxyUrl: this._proxyUrl, pageSize: this._pageSize, timeout: this._timeout, useInternalProxy: false, fillLastHost: false, // required for our injectUrl() code to work properly portalContext: true }; this._pickerDialog = new quickr.picker.widgets.PickerDialog(args); // make sure to get notified when the document picker dialog is closed this._onCloseHdl = dojo.connect(this._pickerDialog, "hide", this, "_onClose"); this._onShowHdl = dojo.connect(this._pickerDialog, "onShow", this, "_injectUrl"); var _this = this; setTimeout(function() { _this._pickerDialog.show(); }, 150); return this._pickerDialog; }, // summary: // Notifies the caller of DocPickerLauncher about the closing of the document picker dialog by calling the corresponding callback function. _onClose: function() { if (this._onCloseHdl) { dojo.disconnect(this._onCloseHdl); } this._onCloseHdl = null; if (this._onShowHdl) { dojo.disconnect(this._onShowHdl); } this._onShowHdl = null; this._currentItem = null; if (this._onCloseCallbackFn) { this._onCloseCallbackFn(); } }, // summary: // Completes an item selection operation and closes the document picker dialog. Executes the client callback function providing the title and the URL of the selected node. // p_dialog: // Current instance of PickerDialog. // p_linkType: // Determines which type of URL to pass on to the client callback function - either 'view' or 'download' (default). (optional) _confirmSelection: function(/*object*/ p_dialog, /*string?*/ p_linkType) { if (this._currentItem) { var url; if (p_linkType == 'view') { url = this._currentItem.viewUrl; } else { url = this._currentItem.downloadUrl; } if (this._onConfirmCallbackFn) { this._onConfirmCallbackFn(this._currentItem.title, url, p_linkType); } } p_dialog.hide(); p_dialog.destroy(); }, _injectUrl: function() { // summary: // Used to inject this._feedUrl into this._pickerDialog's Markup // Called by the onShow event to make sure the dialog was already added // to the DomTree // tags: // private if (this._pickerDialog && this._feedUrl && dojo.isString(this._feedUrl)) { // fail gracefully, if the picker reference or the // recentHosts element could not be found (i.e. the Picker // dialog internas have changed) if (this._pickerDialog.picker) { if (this._pickerDialog.picker.recentHosts && dojo.isFunction(this._pickerDialog.picker.recentHosts.attr)) { this._pickerDialog.picker.recentHosts.attr('value', this._feedUrl); } } } }, // summary: // Upon selecting an item, disables or enables the button(s) used to confirm a selection in dependence of the type of the selected item. // p_button: // Current link, button, or menu item that receives the onItemSelected event. // p_dialog: // Current instance of PickerDialog. // p_picker: // Current instance of DocumentPicker. _onItemSelected: function(/*object*/ p_button, /*object*/ p_dialog, /*object*/ p_picker) { var item = p_picker.getCurrentItem(); var title = p_picker.store.getLabel(item); var path = p_picker.store.getPath(item); var category = p_picker.store.getValue(item, "category"); var downloadUrl = p_picker.store.getValue(item, "downloadurl"); var viewUrl = p_picker.store.getValue(item, "viewurl"); this._currentItem = { title: title, path: path, category: category[0], downloadUrl: downloadUrl, viewUrl: viewUrl }; var enableButton = true; if (this._linkType == 'view' || (this._linkType == 'any' && p_button.label == this._nlsStrings.menuItemViewLink)) { enableButton = this._containsString(this._viewTypes, category[0]); } else if (this._linkType == 'download' || (this._linkType == 'any' && p_button.label == this._nlsStrings.menuItemDownloadLink)) { enableButton = this._containsString(this._downloadTypes, category[0]); } p_button.setDisabled(!enableButton); }, // summary: // Evaluates the arguments passed in and initializes the DocPickerLauncher instance accordingly. // p_args: // Arguments to initialize the DocPickerLauncher with. (optional) _evalArgs: function(/*object?*/ p_args) { if (typeof p_args != "undefined" && p_args) { if (typeof p_args.dialogTitleKey == 'string') { this._dialogTitleKey = p_args.dialogTitleKey; } if (typeof p_args.locale == 'string') { this._locale = p_args.locale; } else { this._locale = dojo.config.locale; } if (typeof p_args.showPlaces == 'boolean') { this._showPlaces = p_args.showPlaces; } if (typeof p_args.showNodePath == 'boolean') { this._showNodePath = p_args.showNodePath; } if (typeof p_args.nodeTypes == 'object' && p_args.nodeTypes) { this._nodeTypes = p_args.nodeTypes; } if (typeof p_args.downloadTypes == 'object' && p_args.downloadTypes) { this._downloadTypes = p_args.downloadTypes; } if (typeof p_args.viewTypes == 'object' && p_args.viewTypes) { this._viewTypes = p_args.viewTypes; } if (typeof p_args.forceSSO == 'boolean') { this._forceSSO = p_args.forceSSO; } if (typeof p_args.isMovable == 'boolean') { this._isMovable = p_args.isMovable; } if (typeof p_args.allowCustomServers == 'boolean') { this._allowCustomServers = p_args.allowCustomServers; } if (typeof p_args.allowedHosts == 'object' && p_args.allowedHosts) { this._allowedHosts = p_args.allowedHosts; } if (typeof p_args.cookieName == 'string') { this._cookieName = p_args.cookieName; } if (typeof p_args.proxyUrl == 'string') { this._proxyUrl = p_args.proxyUrl; } if (typeof p_args.lastHostCookie == 'string') { this._lastHostCookie = p_args.lastHostCookie; } if (typeof p_args.pageSize == 'integer') { this._pageSize = p_args.pageSize; } if (typeof p_args.timeout == 'integer') { this._timeout = p_args.timeout; } } }, // summary: // Dynamically loads any pre-requisite Dojo or other Javascript components required by DocPickerLauncher. _loadPrereqs: function() { dojo.require('dojo.i18n'); this._nlsStrings = dojo.i18n.getLocalization('com.ibm.workplace.wcm.ecm.quickr.picker.launcher', 'DocPickerLauncher'); //dojo.config.styleUrl = '/wps/themes/html/css'; }, // summary: // Checks whether p_array contains p_string. // p_array: // The string array to search in for p_string. // p_string: // The string to search for in p_array. // return: // A boolean to indicate whether p_string is found in p_array. _containsString: function(/*object*/ p_array, /*string*/ p_string) { if ((typeof p_array == 'object') && (p_array !== null) && (typeof p_string == 'string')) { for (i = 0; i < p_array.length; i++) { if (p_array[i] == p_string) { return true; } } } return false; } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerManager"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerManager"] = true; ////////////////////////////////////////////////// // Licensed Materials - Property of IBM // // 5724-E76, 5655-R17, 5655-M44 // // Copyright IBM Corp. 2011 All Rights reserved.// ////////////////////////////////////////////////// dojo.provide("com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerManager"); dojo.require("com.ibm.widgets._Traceable"); dojo.declare('com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerManager', [com.ibm.widgets._Traceable], { // summary: // Manages the launching of the Federated Documents Picker and the Quickr Document Picker. // _callingEnvId: [private] String // Identifier of the context the Federated Documents Picker is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management // (default) _callingEnvId: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm, // _dsPickerArgs: [private] Object // JSON object holding properties to pass to the picker supporting Quickr Document Services _dsPickerArgs: {}, // _fedDocsPickerArgs: [private] Object // JSON object holding properties to pass to the Federated Documents Picker _fedDocsPickerArgs: {}, // _federatedDocumentsServiceBean: [private] Object // Bean holding configuration and runtime data of the federated documents support _federatedDocumentsServiceBean: null, // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _namespace: [private] String // Namespace to pass to the Federated Documents Picker for its user interface elements etc. _namespace: "fedDocsPckrDlg_", // _onCancelCallbackFn: [private] Function // Callback function to execute when the user cancels the selection of a resource in the Federated Documents // Picker or Quickr Document Picker or when the user closes the Federated Documents Picker or Quickr Document // Picker _onCancelCallbackFn: null, // _onConfirmCallbackFn: [private] Function // Callback function to execute when the user confirms the selection of a resource in the Federated Documents // Picker or Quickr Document Picker _onConfirmCallbackFn: null, constructor: function(/*Object*/ p_params) { // summary: // Constructs this federated documents picker manager with the given JSON object // p_params.callingEnvId: String // Identifier of the context this manager is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management (default) // (optional) // p_params.documentServicesPickerArgs: Object // JSON object holding additional arguments to initialize the Quickr Document Picker with (optional) // p_params.federatedDocumentsPickerArgs: Object // JSON object holding additional arguments to initialize the Federated Documents Picker with (optional) // p_params.federatedDocumentsServiceBean: Object // Instance of [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsServiceBean] holding configuration // and runtime data of the federated documents support // p_params.namespace: String // Namespace to use for user interface elements etc. // p_params.onCancelCallbackFn: Function // Callback function to execute when the user cancels the selection of a resource in the Federated Documents // Picker or Quickr Document Picker or when the user closes the Federated Documents Picker or Quickr Document // Picker (optional) // p_params.onConfirmCallbackFn: Function // Callback function to execute when the user confirms the selection of a resource in the Federated Documents // Picker or Quickr Document Picker (optional) // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.callingEnvId:", p_params.callingEnvId); this.trace(m, "p_params.documentServicesPickerArgs:", p_params.documentServicesPickerArgs); this.trace(m, "p_params.federatedDocumentsPickerArgs:", p_params.federatedDocumentsPickerArgs); this.trace(m, "p_params.federatedDocumentsServiceBean:", p_params.federatedDocumentsServiceBean); this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.onCancelCallbackFn:", p_params.onCancelCallbackFn); this.trace(m, "p_params.onConfirmCallbackFn:", p_params.onConfirmCallbackFn); } } // callingEnvId if (typeof p_params.callingEnvId == 'string') { this._callingEnvId = p_params.callingEnvId; } // federatedDocumentsServiceBean if (p_params.federatedDocumentsServiceBean && typeof p_params.federatedDocumentsServiceBean == 'object') { this._federatedDocumentsServiceBean = p_params.federatedDocumentsServiceBean; } // namespace if (typeof p_params.namespace == 'string') { this._namespace = p_params.namespace; } // onCancelCallbackFn if (typeof p_params.onCancelCallbackFn == 'function') { this._onCancelCallbackFn = p_params.onCancelCallbackFn; } // onConfirmCallbackFn if (typeof p_params.onConfirmCallbackFn == 'function') { this._onConfirmCallbackFn = p_params.onConfirmCallbackFn; } // initialize the arguments to initialize the document pickers with if (this._federatedDocumentsServiceBean.isQDSSupportEnabled()) { this._initFederatedDocumentsPickerArgs(p_params.federatedDocumentsPickerArgs); this._initDocumentServicesPickerArgs(p_params.documentServicesPickerArgs); } else { this._initFederatedDocumentsPickerArgs(p_params.federatedDocumentsPickerArgs); } // exit trace if (this._isTracing) { this.traceExit(m); } }, launchDocumentServicesPickerDialog: function(/*String*/ p_url, /*Function?*/ p_onConfirmCallbackFn, /*Function?*/ p_onCloseCallbackFn) { // summary: // Launches the Quickr Document Picker with the option to pass a custom confirm and cancel callback // function. // p_url: String // The server URL that will be passed on to the QuickrPicker to avoid that users have // to type it in again // p_onConfirmCallbackFn: Function // Confirm Callback function being called by the QuickrPicker on dialog confirmation // p_onCloseCallbackFn: Function // Close Callback function being called by the QuickrPicker on dialog close/hide (also being called // when closing the dialog after 'confirm' action // tags: // public // entry trace var m = "launchDocumentServicesPickerDialog(p_url, p_onConfirmCallbackFn, p_onCloseCallbackFn)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_onConfirmCallbackFn, p_onCloseCallbackFn]); } var confirmCallbackFn = null; var closeCallbackFn = null; if (typeof p_onConfirmCallbackFn == 'function') { confirmCallbackFn = p_onConfirmCallbackFn; } if (typeof p_onCloseCallbackFn == 'function') { closeCallbackFn = p_onCloseCallbackFn; } // trace if (this._isTracing) { this.trace(m, "Confirm callback function: ", confirmCallbackFn); this.trace(m, "Close callback function: ", closeCallbackFn); } var launcher = new com.ibm.workplace.wcm.ecm.quickr.picker.launcher.DocPickerLauncher(confirmCallbackFn, closeCallbackFn, this._dsPickerArgs); launcher.launchDocumentPicker(p_url); // exit trace if (this._isTracing) { this.traceExit(m); } }, launchFederatedDocumentsPickerDialog: function() { // summary: // Launches the Federated Documents Picker and passes along expected arguments, // such as, a reference to this manager instance to allow the picker to bring // up the Quickr Document Picker if necessary // tags: // public // entry trace var m = "launchFederatedDocumentsPickerDialog()"; if (this._isTracing) { this.traceEntry(m); } var fedDocsPicker = new com.ibm.workplace.wcm.ecm.picker.dialog.FederatedDocumentsPickerDialog(this._fedDocsPickerArgs); fedDocsPicker.show(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _initDocumentServicesPickerArgs: function(/*Object?*/ p_dsPickerArgs) { // summary: // Initializes the arguments to initialize the Quickr Document Picker with // p_dsPickerArgs: Object // JSON object holding additional arguments to initialize the Quickr Document Picker with (optional) // tags: // private // entry trace var m = "_initDocumentServicesPickerArgs(p_dsPickerArgs)"; if (this._isTracing) { this.traceEntry(m, p_dsPickerArgs); if(p_dsPickerArgs) { this.trace(m, "p_dsPickerArgs.dialogTitleKey", p_dsPickerArgs.dialogTitleKey); this.trace(m, "p_dsPickerArgs.showNodePath", p_dsPickerArgs.showNodePath); this.trace(m, "p_dsPickerArgs.showPlaces", p_dsPickerArgs.showPlaces); this.trace(m, "p_dsPickerArgs.nodeTypes", dojo.toJson(p_dsPickerArgs.nodeTypes)); this.trace(m, "p_dsPickerArgs.downloadTypes", dojo.toJson(p_dsPickerArgs.downloadTypes)); this.trace(m, "p_dsPickerArgs.viewTypes", dojo.toJson(p_dsPickerArgs.viewTypes)); this.trace(m, "p_dsPickerArgs.proxyUrl",p_dsPickerArgs.proxyUrl); } } // assemble the URL of the Ajax proxy used by the document picker to connect to remote servers // this uses the standard ajax proxy mapping and not the cmis_proxy mapping var ajaxProxyUrl = this._federatedDocumentsServiceBean.getPortalContextPath() + "/proxy"; if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn) { // prepare the arguments to initialize the document services federated documents picker // when launched in PZN this._dsPickerArgs = { "dialogTitleKey": "dialogTitleSelectFolder", "showNodePath": true, "showPlaces": true, "nodeTypes": ["place", "library", "folder"], "downloadTypes": ["library", "folder"], "viewTypes": [], "proxyUrl": ajaxProxyUrl }; } else if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm) { // prepare the arguments to initialize the document services federated documents picker // when launched in the WCM RTE this._dsPickerArgs = { "dialogTitleKey": "dialogTitleSelectDocument", "showNodePath": true, "showPlaces": true, "nodeTypes": ["place", "library", "folder", "document", "doclink"], "downloadTypes": ["document"], "viewTypes": ["library", "folder", "document", "doclink"], "proxyUrl": ajaxProxyUrl }; } if (p_dsPickerArgs && typeof p_dsPickerArgs == 'object') { this._mergeArguments(p_dsPickerArgs, this._dsPickerArgs); } // exit trace if (this._isTracing) { this.trace(m, "Document services picker arguments initialized:", this._dsPickerArgs); if(this._dsPickerArgs) { this.trace(m, "_dsPickerArgs.dialogTitleKey", this._dsPickerArgs.dialogTitleKey); this.trace(m, "_dsPickerArgs.showNodePath", this._dsPickerArgs.showNodePath); this.trace(m, "_dsPickerArgs.showPlaces", this._dsPickerArgs.showPlaces); this.trace(m, "_dsPickerArgs.nodeTypes", dojo.toJson(this._dsPickerArgs.nodeTypes)); this.trace(m, "_dsPickerArgs.downloadTypes", dojo.toJson(this._dsPickerArgs.downloadTypes)); this.trace(m, "_dsPickerArgs.viewTypes", dojo.toJson(this._dsPickerArgs.viewTypes)); this.trace(m, "_dsPickerArgs.proxyUrl", this._dsPickerArgs.proxyUrl); } this.traceExit(m); } }, _initFederatedDocumentsPickerArgs: function(/*Object?*/ p_fedDocsPickerArgs) { // summary: // Initializes the arguments to initialize the Federated Documents Picker with // p_fedDocsPickerArgs: Object // JSON object holding additional arguments to initialize the Federated Documents Picker with (optional) // tags: // private // entry trace var m = "_initFederatedDocumentsPickerArgs(p_fedDocsPickerArgs)"; if (this._isTracing) { this.traceEntry(m, p_fedDocsPickerArgs); if(p_fedDocsPickerArgs) { this.trace(m, "p_fedDocsPickerArgs.callingEnvironment", p_fedDocsPickerArgs.callingEnvironment); this.trace(m, "p_fedDocsPickerArgs.customServiceSelectionEnabled", p_fedDocsPickerArgs.customServiceSelectionEnabled); this.trace(m, "p_fedDocsPickerArgs.documentsServices", p_fedDocsPickerArgs.documentsServices); this.trace(m, "p_fedDocsPickerArgs.feedBaseURL",p_fedDocsPickerArgs.feedBaseURL); this.trace(m, "p_fedDocsPickerArgs.feedTypeBaseURL", p_fedDocsPickerArgs.feedTypeBaseURL); this.trace(m, "p_fedDocsPickerArgs.nodeTypes", dojo.toJson(p_fedDocsPickerArgs.nodeTypes)); this.trace(m, "p_fedDocsPickerArgs.onCancelCallbackFn", p_fedDocsPickerArgs.onCancelCallbackFn); this.trace(m, "p_fedDocsPickerArgs.onConfirmCallbackFn", p_fedDocsPickerArgs.onConfirmCallbackFn); this.trace(m, "p_fedDocsPickerArgs.pickerManager", p_fedDocsPickerArgs.pickerManager); this.trace(m, "p_fedDocsPickerArgs.qdsSupportEnabled", p_fedDocsPickerArgs.qdsSupportEnabled); this.trace(m, "p_fedDocsPickerArgs.serviceDocBaseURL", p_fedDocsPickerArgs.serviceDocBaseURL); this.trace(m, "p_fedDocsPickerArgs.vaultMgmtDataSinkUrl", p_fedDocsPickerArgs.vaultMgmtDataSinkUrl); this.trace(m, "p_fedDocsPickerArgs.vaultSelectionEnabled", p_fedDocsPickerArgs.vaultSelectionEnabled); this.trace(m, "p_fedDocsPickerArgs.vaultSelectionEnabledForPZN", p_fedDocsPickerArgs.vaultSelectionEnabledForPZN); this.trace(m, "p_fedDocsPickerArgs.vaultSelectionEnabledForWCM", p_fedDocsPickerArgs.vaultSelectionEnabledForWCM); this.trace(m, "p_fedDocsPickerArgs.vaultSlots", p_fedDocsPickerArgs.vaultSlots); this.trace(m, "p_fedDocsPickerArgs.portalContextPath", p_fedDocsPickerArgs.portalContextPath); this.trace(m, "p_fedDocsPickerArgs.usePresetUrl", p_fedDocsPickerArgs.usePresetUrl); } } // query the federated documents service bean for the configuration var customServiceSelectionEnabled = this._federatedDocumentsServiceBean.isCustomServiceSelectionEnabled(); var federatedDocumentsServices = this._federatedDocumentsServiceBean.getFederatedDocumentsServices(); var feedBaseURL = this._federatedDocumentsServiceBean.getFeedBaseURL(); var feedTypeBaseURL = this._federatedDocumentsServiceBean.getFeedTypeBaseURL(); var isQDSSupportEnabled = this._federatedDocumentsServiceBean.isQDSSupportEnabled(); var isVaultSelectionEnabledForPZN = this._federatedDocumentsServiceBean.isVaultSelectionEnabledForPZN(); var isVaultSelectionEnabledForWCM = this._federatedDocumentsServiceBean.isVaultSelectionEnabledForWCM(); var serviceDocBaseURL = this._federatedDocumentsServiceBean.getServiceDocumentBaseURL(); var vaultMgmtDataSinkUrl = this._federatedDocumentsServiceBean.getVaultMgmtDataSinkUrl(); var vaultSlots = this._federatedDocumentsServiceBean.getVaultSlots(); var portalContextPath = this._federatedDocumentsServiceBean.getPortalContextPath(); var usePresetUrl = false; if(p_fedDocsPickerArgs && p_fedDocsPickerArgs.usePresetUrl) usePresetUrl = p_fedDocsPickerArgs.usePresetUrl; if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn) { // prepare the arguments to initialize the universal federated documents picker // when launched from PZN this._fedDocsPickerArgs = { "callingEnvironment": this._callingEnvId, "customServiceSelectionEnabled": customServiceSelectionEnabled, "documentsServices": federatedDocumentsServices, "feedBaseURL": feedBaseURL, "feedTypeBaseURL": feedTypeBaseURL, "namespace": this._namespace, "nodeTypes": ["repository", "folder"], "onCancelCallbackFn": this._onCancelCallbackFn, "onConfirmCallbackFn": this._onConfirmCallbackFn, "pickerManager": this, "qdsSupportEnabled": isQDSSupportEnabled, "serviceDocBaseURL": serviceDocBaseURL, "vaultMgmtDataSinkUrl": vaultMgmtDataSinkUrl, "vaultSelectionEnabled": isVaultSelectionEnabledForPZN, "vaultSelectionEnabledForPZN": isVaultSelectionEnabledForPZN, "vaultSelectionEnabledForWCM": isVaultSelectionEnabledForWCM, "vaultSlots": vaultSlots, "portalContextPath": portalContextPath, "usePresetUrl" : usePresetUrl }; } else if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm) { // prepare the arguments to initialize the universal federated documents picker // when launched from PZN this._fedDocsPickerArgs = { "callingEnvironment": this._callingEnvId, "customServiceSelectionEnabled": customServiceSelectionEnabled, "documentsServices": federatedDocumentsServices, "feedBaseURL": feedBaseURL, "feedTypeBaseURL": feedTypeBaseURL, "namespace": this._namespace, "nodeTypes": ["repository", "folder", "document"], "onCancelCallbackFn": this._onCancelCallbackFn, "onConfirmCallbackFn": this._onConfirmCallbackFn, "pickerManager": this, "qdsSupportEnabled": isQDSSupportEnabled, "serviceDocBaseURL": serviceDocBaseURL, "vaultMgmtDataSinkUrl": vaultMgmtDataSinkUrl, "vaultSelectionEnabled": isVaultSelectionEnabledForWCM, "vaultSelectionEnabledForPZN": isVaultSelectionEnabledForPZN, "vaultSelectionEnabledForWCM": isVaultSelectionEnabledForWCM, "vaultSlots": vaultSlots, "portalContextPath": portalContextPath, "usePresetUrl" : usePresetUrl }; } if (p_fedDocsPickerArgs && typeof p_fedDocsPickerArgs == 'object') { this._mergeArguments(p_fedDocsPickerArgs, this._fedDocsPickerArgs); } // exit trace if (this._isTracing) { this.trace(m, "Federated documents picker arguments initialized:", this._fedDocsPickerArgs); if(this._fedDocsPickerArgs) { this.trace(m, "this._fedDocsPickerArgs.callingEnvironment", this._fedDocsPickerArgs.callingEnvironment); this.trace(m, "this._fedDocsPickerArgs.customServiceSelectionEnabled", this._fedDocsPickerArgs.customServiceSelectionEnabled); this.trace(m, "this._fedDocsPickerArgs.documentsServices", this._fedDocsPickerArgs.documentsServices); this.trace(m, "this._fedDocsPickerArgs.feedBaseURL",this._fedDocsPickerArgs.feedBaseURL); this.trace(m, "this._fedDocsPickerArgs.feedTypeBaseURL", this._fedDocsPickerArgs.feedTypeBaseURL); this.trace(m, "this._fedDocsPickerArgs.namespace", this._fedDocsPickerArgs.namespace); this.trace(m, "this._fedDocsPickerArgs.nodeTypes", dojo.toJson(this._fedDocsPickerArgs.nodeTypes)); this.trace(m, "this._fedDocsPickerArgs.onCancelCallbackFn", this._fedDocsPickerArgs.onCancelCallbackFn); this.trace(m, "this._fedDocsPickerArgs.onConfirmCallbackFn", this._fedDocsPickerArgs.onConfirmCallbackFn); this.trace(m, "this._fedDocsPickerArgs.pickerManager", this._fedDocsPickerArgs.pickerManager); this.trace(m, "this._fedDocsPickerArgs.qdsSupportEnabled", this._fedDocsPickerArgs.qdsSupportEnabled); this.trace(m, "this._fedDocsPickerArgs.serviceDocBaseURL", this._fedDocsPickerArgs.serviceDocBaseURL); this.trace(m, "this._fedDocsPickerArgs.vaultMgmtDataSinkUrl", this._fedDocsPickerArgs.vaultMgmtDataSinkUrl); this.trace(m, "this._fedDocsPickerArgs.vaultSelectionEnabled", this._fedDocsPickerArgs.vaultSelectionEnabled); this.trace(m, "this._fedDocsPickerArgs.vaultSelectionEnabledForPZN", this._fedDocsPickerArgs.vaultSelectionEnabledForPZN); this.trace(m, "this._fedDocsPickerArgs.vaultSelectionEnabledForWCM", this._fedDocsPickerArgs.vaultSelectionEnabledForWCM); this.trace(m, "this._fedDocsPickerArgs.vaultSlots", this._fedDocsPickerArgs.vaultSlots); this.trace(m, "this._fedDocsPickerArgs.portalContextPath", this._fedDocsPickerArgs.portalContextPath); this.trace(m, "this._fedDocsPickerArgs.usePresetUrl", this._fedDocsPickerArgs.usePresetUrl); } this.traceExit(m); } }, _mergeArguments: function(/*Object*/ p_sourceArgs, /*Object*/ p_targetArgs) { // summary: // Merges the properties from the given source into the target; overwrites properties from // the target if they have the same name in the given source // p_sourceArgs: Object // JSON object holding the properties to merge into the given targets // p_targetArgs: Object // JSON object that serves as the target of the merge operation // tags: // private // entry trace var m = "_mergeArguments(p_sourceArgs, p_targetArgs)"; if (this._isTracing) { this.traceEntry(m, [ p_sourceArgs, p_targetArgs ]); } for (var propertyName in p_sourceArgs) { // add properties from the source and overwrite properties by the same name on the target p_targetArgs[propertyName] = p_sourceArgs[propertyName]; } // exit trace if (this._isTracing) { this.trace(m, "New set of target arguments:", p_targetArgs); this.traceExit(m); } } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.FederatedDocumentsPickerDialogWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.widget.FederatedDocumentsPickerDialogWidget"] = true; /** ****************************************************************** */ /* Licensed Materials - Property of IBM */ /* */ /* 5724Z67 */ /* */ /* Copyright IBM Corp. 2011 All Rights Reserved. */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** ****************************************************************** */ dojo.provide("com.ibm.workplace.wcm.ecm.picker.widget.FederatedDocumentsPickerDialogWidget"); dojo.registerModulePath("com.ibm.workplace.wcm.ecm.picker.widget","../com/ibm/workplace/wcm/ecm/picker/widget"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit.layout.StackContainer"); dojo.require("com.ibm.widgets.GenericDialogWidget"); dojo.declare("com.ibm.workplace.wcm.ecm.picker.widget.FederatedDocumentsPickerDialogWidget", [com.ibm.widgets.GenericDialogWidget], { // summary: // CMIS Picker Dialog in Wizard style, inherited from GenericDialog, providing // additional buttons and functions for handling page transition. Multiple pages // are supported, each containing a separate widget. // blankImgUrl: Object // URL pointing to a blank image (1x1 transparent pixel) blankImgUrl: dojo.moduleUrl("dojo", "resources/blank.gif").toString(), // lotusui_id: String // The ID for the global dijitDialog lotusui related wrapper DIV // The container needs to be specific to the FedDocPickerDlg, as the labelledby // aria attribute is specific to this dialog. lotusui_id: "dijitDialog_lotusui30_fedDocDlg_container", // lotusui_class: String // The lotusui class to assign to the wrapper DIV, if it gets created lotusui_class: "lotusui30", // namespace: [protected] String // The namespace this dialog uses for building its user interface elements namespace: "fedDocsPckrDlg_", // templateString: // see dijit.Dialog templateString: dojo.cache("com.ibm.workplace.wcm.ecm.picker.widget", "template/FederatedDocumentsPickerDialogWidget.html", "
\n\n
\n
\n \"${_nlsUserInterface.docPickerDialog.errorImgAlt}\"\n \n
\n \n
\n
\n
\n

\n
\n
\n
\n \"${_nlsUserInterface.docPickerDialog.detectingFeedTypeImgAlt}\"\n  ${_nlsUserInterface.docPickerDialog.detectingFeedTypeDivText}\n \n
\n
\n \"${_nlsUserInterface.docPickerDialog.gettingVaultImgAlt}\"\n  ${_nlsUserInterface.docPickerDialog.gettingVaultDivText}\n \n
\n
\n
\n
\n\n
\n
\n \n \n \n \n
\n
\n
\n"), // widgetsInTemplate: [protected] Boolean // see dijit._Templated widgetsInTemplate: true, // _callingEnvironment: [private] String // Identifier of the context the Federated Documents Picker is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management // (default) _callingEnvironment: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm, // _currentPage: [private] Integer // Index to the current page. 0 based value, which means, Page 1 has index 0, Page 2 has index 1 and so forth. // Default value is '-1', which means no page is selected. Will be set to first page (0) once the // page was loaded. _currentPage: -1, // _defaultButton: [private] DomNode // Reference to a domNode pointing to either the NEXT or FINISH button. This // is the button whose action will be triggered, whenever the user presses // the ENTER key on the keyboard. _defaultButton: null, // _dialogBorderWidth: [private] Integer // Width of the dialog border (left + right side) in pixels. Used to calculate the available // horizontal space for the ContainerNode on resize _dialogBorderWidth: 2, // _errorState: [private] Boolean // Indicates whether an error occurred and whether this dialog went into error state. // The error is displayed (and the user cannot advance within or finish the dialog) // until _clearError() was called. _errorState: false, // _eventHandles: [private] Array // Array of handles created when connecting events to methods _eventHandles: [], // _nlsMessages: [protected] Object // see com.ibm.widgets.GenericDialog _nlsMessages: {}, // _nlsUserInterface: [protected] Object // see com.ibm.widgets.GenericDialog _nlsUserInterface: {}, // _maxErrorChars: [private] Integer // Maximum number of characters that will be shown for an error message. The rest will // be truncated. _maxErrorChars: 768, // _onCancelCallbackFn: [private] Function // Callback function to execute when the user cancels or closes this dialog _onCancelCallbackFn: null, // _onConfirmCallbackFn: [private] Function // Callback function to execute when the user confirms this dialog _onConfirmCallbackFn: null, // _pageParams: [private] Object // JSON object holding the parameters that are passed to the wizard page widgets that // represent the single steps of the federated documents picker dialog _pageParams: {}, // _pages: [private] Array // Internal array holding references to [dijit.layout.ContentPane] instances within the // dijit.layout.StackContainer used to manage Wizard pages _pages: [], // _pickerContext: [private] String // Indicates whether or not the Federated Documents Picker is launched as a fully fledged dialog of its // own or as a dependent widget. The latter is the case of using the Federated Documents Picker Portlet // inside of a dialog that is created by the modal dialog framework of the portal. // Supported values are: // - com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._dialog // - com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._portlet _pickerContext: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._portlet, // _qdsSupportEnabled: [private] Boolean // Indicates whether Quickr Document Services support is enabled, hence, the Quickr // Document Picker dialog is available and shall be launched to access QDS feeds _qdsSupportEnabled: true, // _serverTypeMap: [private] Object // Internal associative array, which maps any given URL (key) to a // known feedType (value) _serverTypeMap: {}, //_selectedPath: [private] Array // Array holding the ids of tree nodes starting from the root node and going down to the selected node _selectedPath: [], // _transientSlotId: [private] String // The slot id of the transient credential vault slot that is used to // store the username / password in case of username / pw authentication. _transientSlotId: String, // _vaultMgmtDataSinkUrl: [private] String // Piece of content (POC) URL for accessing the Vault Management Datasink of // IBM Portal _vaultMgmtDataSinkUrl: String, // _widgets: [private] Array // Internal array holding references to instances of // [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget] compatible widgets // (one instance for each page of the wizard) _widgets: [], // _usePresetUrl: [private] Boolean // Indicates whether to use preset server url and skip the connection page and opens with second page directly _usePresetUrl: false, buildRendering: function() { // summary: // Constructs the user interface of this dialog // tags: // protected // entry trace var m = "buildRendering()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // initialize the dialog title based on the context // Note: the inherited buildRendering method will only update the title automatically // if there is one child widget implementing the getDialogTitle() method var title; if (this._isCalledFromPZN()) { title = this._nlsUserInterface.docPickerDialog.titlePZN; } else { title = this._nlsUserInterface.docPickerDialog.titleWCM; } this.title = title; this._hideDetectingBox(); this._hideGettingVaultBox(); // exit trace if (this._isTracing) { this.traceExit(m); } }, constructor: function(/*Object*/ p_params) { // summary: // Constructs this dialog // p_params.availableAuthTypes: Array // Array of String. Each string defines one authentication type that is available for selection // by the user. Allowed values are: // [com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd] // [com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeCurrentUser] // [com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault] // p_params.callingEnvironment: String // Defines the calling environment. Allowed values are // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] // p_params.customServiceSelectionEnabled: Boolean // Defines whether custom server selection (i.e. selection of non-preconfigured // services is supported) // p_params.documentsServices: Array // Array of JSON Objects. Each object describes one preconfigured documents service. // { url: String holding the Url of the service document of a remote Document Server // type: String describing the type of the Document Server // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._cmis] or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds] // vaultslot: String [optional] holding the name of a credential vault slot that should // be used when connecting to this Document Server // title: String [optional] holding the display name for this Server. } // p_params.feedBaseURL: String // Piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) feeds through the CMIS feed data source of IBM Portal // p_params.feedType: String // The exact feed type of the server to connect to (on either the CMIS or Quickr page) // Especially needed for determining which URL needs to be passed to the FedDocAtomStore // as the feedBaseUrl. // p_params.feedTypeBaseURL: String // Piece of content (POC) base URL for accessing the feed type data source of IBM // Portal that determines type of an enterprise content management (ECM) feed // p_params.nodeTypes: Array // Array of String. Each string represents one nodeType that the Picker dialog // will display // p_params.namespace: String // Namespace of Federated Documents Picker and its user interface elements etc. // p_params.onCancelCallbackFn: Function // Callback function to execute when the user cancels or closes this dialog // p_params.onConfirmCallbackFn: Function // Callback function to execute when the user confirms this dialog // p_params.pickerManager: Object // Reference to the [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerManager] instance // which launched this instance of the FederatedDocumentsPickerDialog. Used to launch the Quickr Picker // from within the Quickr Page // p_params.qdsSupportEnabled: Boolean // Defines whether Quickr Documents Services support is available in the Picker dialog // p_params.serviceDocBaseURL: String // Piece of content (POC) base URL for accessing Content Management Interoperability // Services (CMIS) service documents through the CMIS service document data source of // IBM Portal // p_params.vaultMgmtDataSinkUrl: String // Piece of content (POC) URL for accessing the Vault Management Datasink of // IBM Portal // p_params.vaultSelectionEnabled: Boolean [optional] // Defines whether credential vault slot selection is available (regardless of the calling // environment). This setting overrides the calling environment specific settings above // p_params.vaultSelectionEnabledForPZN: Boolean // Defines whether credential vault slot selection will be available in PZN calling environment // p_params.vaultSelectionEnabledForWCM: Boolean // Defines whether credential vault slot selection will be available in WCM calling environment // p_params.vaultSlots: Array // Array of credential vault slots. Each slot is an object with the following properties: // { vaultSlotTitle: String // The localized title which is being displayed in the DropDownList // vaultSlotID: String // The actual credential vault slot ID that is being added to the URL as a parameter // } // tags: // public //p_params.usePresetUrl: boolean // If true, the dialog connects to the preset server url and skips the connection page. // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor"; if (this._isTracing) { this.traceEntry(m, p_params); if(p_params) { this.trace(m, "p_params.availableAuthTypes", p_params.availableAuthTypes); this.trace(m, "p_params.callingEnvironment", p_params.callingEnvironment); this.trace(m, "p_params.customServiceSelectionEnabled", p_params.customServiceSelectionEnabled); this.trace(m, "p_params.documentsServices", p_params.documentsServices); this.trace(m, "p_params.feedBaseURL", p_params.feedBaseURL); this.trace(m, "p_params.feedType", p_params.feedType); this.trace(m, "p_params.feedTypeBaseURL", p_params.feedTypeBaseURL); this.trace(m, "p_params.namespace", p_params.namespace); this.trace(m, "p_params.nodeTypes", dojo.toJson(p_params.nodeTypes)); this.trace(m, "p_params.onCancelCallbackFn:", p_params.onCancelCallbackFn); this.trace(m, "p_params.onConfirmCallbackFn:", p_params.onConfirmCallbackFn); this.trace(m, "p_params.pickerManager", p_params.pickerManager); this.trace(m, "p_params.portalContextPath", p_params.portalContextPath); this.trace(m, "p_params.qdsSupportEnabled", p_params.qdsSupportEnabled); this.trace(m, "p_params.selectedPath", p_params.selectedPath); this.trace(m, "p_params.serviceDocBaseURL", p_params.serviceDocBaseURL); this.trace(m, "p_params.vaultSelectionEnabled", p_params.vaultSelectionEnabled); this.trace(m, "p_params.vaultSelectionEnabledForPZN", p_params.vaultSelectionEnabledForPZN); this.trace(m, "p_params.vaultSelectionEnabledForWCM", p_params.vaultSelectionEnabledForWCM); this.trace(m, "p_params.vaultSlots", p_params.vaultSlots); this.trace(m, "p_params.usePresetUrl", p_params.usePresetUrl); } } // initialize the resource bundles for localization this._initNLS(); // clear global arrays that we only push elements into, as opening multiple widget instances // might keep the array content from previous instances this._eventHandles = []; this._widgets = []; this._pages = []; this._serverTypeMap = {}; this._defaultButton = null; this._transientSlotId = null; // first, try to determine the context this dialog is used in if (typeof p_params.callingEnvironment == 'string') { this._callingEnvironment = p_params.callingEnvironment; } // namespace if (typeof p_params.namespace == 'string') { this.namespace = p_params.namespace; } // callback function called when confirming a selection made in the dialog if (typeof p_params.onConfirmCallbackFn == 'function') { this._onConfirmCallbackFn = p_params.onConfirmCallbackFn; } // callback function called when canceling the dialog if (typeof p_params.onCancelCallbackFn == 'function') { this._onCancelCallbackFn = p_params.onCancelCallbackFn; } // remember whether Quickr Document Services are supported if (typeof p_params.qdsSupportEnabled == 'boolean') { this._qdsSupportEnabled = p_params.qdsSupportEnabled; } if (typeof p_params.vaultMgmtDataSinkUrl == 'string') { this._vaultMgmtDataSinkUrl = p_params.vaultMgmtDataSinkUrl; } if (typeof p_params.usePresetUrl == 'boolean') { this._usePresetUrl = p_params.usePresetUrl; } if(p_params.selectedPath){ this._selectedPath = p_params.selectedPath; } // normalize the percent-encoded triplets in given base URLs var feedBaseURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.normalizePlaceholders(p_params.feedBaseURL); var feedTypeBaseURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.normalizePlaceholders(p_params.feedTypeBaseURL); var serviceDocBaseURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.normalizePlaceholders(p_params.serviceDocBaseURL); // pass-through selected arguments from the constructor to the child-widgets this._pageParams = { "availableAuthTypes": p_params.availableAuthTypes, "callingEnvironment": p_params.callingEnvironment, "customServiceSelectionEnabled": p_params.customServiceSelectionEnabled, "documentsServices": p_params.documentsServices, "feedBaseURL": feedBaseURL, "feedType": null, // will be set when switching to either the CMIS or Quickr Page "feedTypeBaseURL": feedTypeBaseURL, "namespace": this.namespace, "nlsMessages": this._nlsMessages, "nlsUserInterface": this._nlsUserInterface, "nodeTypes": p_params.nodeTypes, "onDefaultAction": dojo.hitch(this, "_onDefaultAction"), "onErrorStateChanged": dojo.hitch(this, "_onErrorStateChanged"), "onLayoutChanged": dojo.hitch(this, "layout"), "onReadyStateChanged": dojo.hitch(this, "_onReadyStateChanged"), "pickerContext": this._pickerContext, "pickerManager": p_params.pickerManager, "portalContextPath": p_params.portalContextPath, "selectedPath" : p_params.selectedPath, "serviceDocBaseURL": serviceDocBaseURL, "vaultSelectionEnabled": p_params.vaultSelectionEnabled, "vaultSelectionEnabledForPZN": p_params.vaultSelectionEnabledForPZN, "vaultSelectionEnabledForWCM": p_params.vaultSelectionEnabledForWCM, "vaultSlots": p_params.vaultSlots }; // Dojo 1.6: make sure we don't allow dijit.Dialog to automatically assign any hover classes to our // buttons/attachpoints this.cssStateNodes = {}; // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, getSelectedItemJSON: function() { // summary: // Get the selected item from either page1 (CMIS) or page2 (Quickr) // as a JSON object, containing title and url attributes // returns: // Object { title: String - display title of the selected item, // url: String - Url of the selected item } // tags: // public // entry trace var m = "getSelectedItemJSON()"; if (this._isTracing) { this.traceEntry(m); } var result = null; if (this._currentPage == 1) { result = this._widgets[1].getSelectedItemJSON(); // Object } else { if (this._currentPage == 2) { result = this._widgets[2].getSelectedItemJSON(); // Object } } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Object }, layout: function() { // summary: // Makes sure that the dialog is always fully visible on screen. // Calculates the available viewport + the current dialog height // and determines whether a specific height needs to be set, or // whether the height style can be set to 'auto' again. // tags: // protected // entry trace var m = "layout()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // get the width added by padding and margin var errorDivPaddingMarginWidth = dojo.marginBox(this.wizardErrorDiv).w - dojo.contentBox(this.wizardErrorDiv).w; // get the new content width of the error message div that stretches over the full available width of the parent element var errorDivWidth = dojo.contentBox(this.containerNode).w - errorDivPaddingMarginWidth; // update error div width (need to update width first, so that height, which we ask for below, // will already have been updated) if (errorDivWidth >= 0) { dojo.style(this.wizardErrorDiv, 'width', errorDivWidth + "px"); } // calculate height of wizardPageContainer (width seems to be calculated automatically) var staticHeight = dojo.marginBox(this.wizardErrorDiv).h + dojo.marginBox(this.wizardStepHeader).h + 20; var availableHeight = dojo.marginBox(this.containerNode).h; // make sure that the wizard page container layout is also updated, when the dialog // size changes if (this.wizardPageContainer) { this.wizardPageContainer.layout(); } // run layout method on the currently active page widget, to allow it for adapting to // available space if ((this._currentPage > -1) && (this._currentPage < this._widgets.length)) { // do, as if we had set an actual height on the containerNode (which doesn't work, as it is // an auto-sized DIV, so the child widget's layout method can work with the desired height // value this._widgets[this._currentPage].virtualContainerNodeHeight = Math.max(availableHeight - staticHeight, 300); this._widgets[this._currentPage].layout(); } // make sure the modal dialog surrounding this widget resizes as well if (window.resize) { window.resize(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, postCreate: function() { // summary: // Binds resources required by this dialog after its DOM has been set up // tags: // protected // entry trace var m = "postCreate()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // initialize the event handlers that are connected to the buttons of the widget this._initEventHandles(); this._initializePages(this._pageParams); if (this._widgets.length < 3) { throw new Error(this._nlsMessages.docPickerDialog.errorNotAllWidgetsDefined); } else { for (var i = 0; i < 3; i++) { this._addPageForWidget(i); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, postMixInProperties : function() { // summary: // Prepares the creation of the user interface of this dialog // tags: // protected // entry trace var m = "postMixInProperties()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, show: function() { // summary: // Overridden show() method of [dijit.Dialog], allowing us to trigger the startup // method // tags: // protected // entry trace var m = "show()"; if (this._isTracing) { this.traceEntry(m); } this.startup(); // default this.inherited(arguments); // allow fade-in animation of the dialog to complete, then focus the first tabbable item in the // currently active page setTimeout(dojo.hitch(this, "_onFocusFirstItem"), this.duration + 200); // exit trace if (this._isTracing) { this.traceExit(m); } }, startup: function() { // summary: // Called once all child widgets and the widgets from within the template have been // fully initialized and put into the DOM Tree. Used to initialize some of the // widgets and performing layout related tasks. // tags: // protected // entry trace var m = "startup()"; if (this._isTracing) { this.traceEntry(m); } if (this.wizardPageContainer) { this.wizardPageContainer.startup(); this._currentPage = -1; if(this._usePresetUrl){ this._widgets[0]._authWidget.changeAuthType(com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd); this._widgets[0]._authWidget.setAuthenticationProperties({authProperties:this.authProperties}); this._widgets[0]._authWidget._authProperties.authType = com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd; this._onGoFwdPrep(); }else{ // reset _feedType variable on ServerConnectionPageWidget, to make sure it doesn't // return false values this._widgets[0].setFeedType(null); this._switchToPage(0); // StackContainer defaults to first child page (_currentPage will be set by _switchToPage) } } this.layout(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, uninitialize: function() { // summary: // Releases the resources bound by this dialog before it is destroyed // tags: // protected // entry trace var m = "uninitialize()"; if (this._isTracing) { this.traceEntry(m); } // disconnect the callbacks from their related events this._clearEventHandles(); // default this.inherited(arguments); // exit trace if (this._isTracing) { this.traceExit(m); } }, _addPageForWidget: function(/*Integer*/ p_widgetIndex) { // summary: // Creates a [dijit.layout.ContentPane] instance for the given // page widget and adds it to the StackContainer // p_widgetIndex: Integer // Index to a widget in the this._widgets Array // tags: // private // entry trace var m = "_addPageForWidget(p_widgetIndex)"; if (this._isTracing) { this.traceEntry(m, p_widgetIndex); } var widget = this._widgets[p_widgetIndex]; // trace if (this._isTracing) { this.trace(m, "Widget for index:", widget); } if (widget) { page = new dijit.layout.ContentPane(); // 283953: With Dojo 1.6, the startup() call on a stack container causes startup() calls // on every single child node. Therefore, calling startup() when a page becomes visible // does not yield the desired result for resize operations, because it is a second startup() // call. Therefore, delegate to the onShow() method instead. // In contrast to the Dojo 1.6 API documentation, the onShow() method of widgets managed // by a StackContainer is not called automatically. Therefore, establish the link to call // the onShow() method on the particular wizard page widget when is becomes visible. // Note: The widgets need to implement onShow() if any specific resizing is required. page.onShow = dojo.hitch(this, function() { widget.onShow(); }); this._pages.push(page); this.wizardPageContainer.addChild(page); widget.placeAt(page.domNode); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _clearError: function() { // summary: // Clears the error state (sets this._errorState to false) and hides the // error DIV showing the error message. // tags: // private // entry trace var m = "_clearError()"; if (this._isTracing) { this.traceEntry(m); } // clear the error state and hide the error div this._errorState = false; dojo.style(this.wizardErrorDetailsDiv, 'display', 'none'); dojo.style(this.wizardErrorDiv, 'display', 'none'); dijit.setWaiState(this.wizardErrorDiv, 'hidden', true); dijit.setWaiState(this.wizardErrorDetailsDiv, 'hidden', true); // re-enable buttons in case they were disabled, because of an error this._enableDisableButtons(); // make sure the dialog looks 'good' after closing the box this.layout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _deleteTransientSlot: function() { // summary: // Deletes the transient credential slot // tags: // private // entry trace var m = "_deleteTransientSlot()"; if (this._isTracing) { this.traceEntry(m); } if (this._transientSlotId !== null) { postData = "slotid=" + this._encodePostDataItem(this._transientSlotId); var headers = { "Content-Type": "text/plain", "Accept": "text/plain"}; dojo.xhrPost( { "url": this._vaultMgmtDataSinkUrl, "postData": postData, "handleAs": "text", "headers": headers, "sync": false }); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _enableDisableButtons: function() { // summary: // Enables and disables buttons of the picker dialog based on the internal state. // tags: // private // entry trace var m = "_enableDisableButtons()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } // update Wizard button states if (this._currentPage === 0) { this._setBackBtnEnabled(false); this._setFinishBtnEnabled(false); if (this._isCurrentPageReady() && (!this._errorState)) { this._setNextBtnEnabled(true); } else { this._setNextBtnEnabled(false); } } else { this._setBackBtnEnabled(true); // Finish and Next button handling // if current page is ready and no error occurred if (this._isCurrentPageReady() && (!this._errorState)) { this._setNextBtnEnabled(false); this._setFinishBtnEnabled(true); } else { this._setNextBtnEnabled(false); this._setFinishBtnEnabled(false); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _encodePostDataItem: function(/*String*/ string) { // summary: // Encodes a post data item included // userid: String // The string to encode // returns: String // The encoded string // tags: // private // entry trace var m = "_encodePostDataItem(string)"; if (this._isTracing) { this.traceEntry(m, string); } var ret = encodeURIComponent(string); // exit trace if (this._isTracing) { this.traceExit(m, ret); } return ret; }, _encodeUrlIfNeeded: function(/*String*/ p_url) { // summary: // Detect whether the given URL contains URL encoded entities, by looking // for '%' characters. If none were found, run an encodeURI() on the URL // to encode values that might need encoding (like blanks, etc). // p_url: String // A string containing an item's Url parameter that might need encoding // before it can be added to the feedBaseUrl to produce the result Url // returns: // String The Url which does not need any further encoding // tags: // private // entry trace var m = "_encodeUrlIfNeeded(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } var result = p_url; if (p_url && typeof p_url == 'string' && p_url.indexOf("%") == -1) { // no encoded entities found, encodeURI() should do no harm to this URL result = encodeURI(p_url); // String } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _fetchServerType: function(/*String*/ p_url) { // summary: // Fires an XHRGet request against the feedType detection Datasource // and switches to the correct page according to the returned type. // Stores the result in the serverTypeMap array for later reuse. // p_url: // The url of the feed that we need to determine the type of // tags: // private // entry trace var m = "_fetchServerType(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } // build url for the feedType detection datasource var feedTypeDetectionUrl = this._generateDetectionURL(p_url); this._showDetectingBox(); try { dojo.xhrGet( { "url": feedTypeDetectionUrl, "handleAs": "json", "sync": false, "load": dojo.hitch(this, function(/*Object*/ p_data) { this._fetchServerTypeLoadCallback(p_url, p_data); }), "error": dojo.hitch(this, function(/*Object*/ p_error, /*Object*/ p_ioargs) { this._fetchServerTypeErrorCallback(p_url, p_error, p_ioargs); }) }); } catch(e) { if (e.name && e.message) { this._showError(e.name, e.message); } else { this._showError(this._nlsMessages.docPickerDialog.errorGenericException, e); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _fetchServerTypeErrorCallback: function(/*String*/ p_url, /*Object*/ p_error, /*Object*/ p_ioargs) { // summary: // Callback function to execute when detection of the feed type using a XHR fails // p_url: // The URL employed in the XHR // p_error: // The error that occurred when issuing the XHR // p_ioargs: // The ioargs of the XHR // tags: // private // entry trace var m = "_fetchServerTypeErrorCallback(p_url, p_error, p_ioargs)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_error, p_ioargs]); } this._hideDetectingBox(); if (p_ioargs.xhr.status == 404) { if (p_url.indexOf("/dm/atom/libraries/feed") == -1) { // give it a second try, because the failing initial request might be using a URL // that points to a Quickr server rather than to an actual feed var quickrUrl = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.appendPath(p_url, "/dm/atom/libraries/feed"); this._fetchServerType(quickrUrl); } else { this._showErrorForXHRRequest(p_ioargs); } } else { this._showErrorForXHRRequest(p_ioargs); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _fetchServerTypeLoadCallback: function(/*String*/ p_url, /*Object*/ p_data) { // summary: // Callback function to execute when detection of the feed type using a XHR succeeds // p_url: // The URL employed in the XHR // p_data: // The result of the XHR // tags: // private // entry trace var m = "_fetchServerTypeLoadCallback(p_url, p_data)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_data]); } this._hideDetectingBox(); var feedType = p_data.feedType; if (feedType) { if (feedType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._unknown) { if (p_url.indexOf("/dm/atom/libraries/feed") == -1) { // give it a second try, because the failing initial request might be using a URL // that points to a Quickr server rather than to an actual feed var quickrUrl = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.appendPath(p_url, "/dm/atom/libraries/feed"); this._fetchServerType(quickrUrl); } else { this._showError(this._nlsMessages.docPickerDialog.errorUnknownFeedType, feedType); } } else { // store feedType of current url into serverTypeMap[] this._serverTypeMap[p_url] = feedType; // set feedType on first page this._widgets[0].setFeedType(feedType); // if serverType is a Quickr compatible type, go to quickr picker page instead if (this._isQuickrFeedType(feedType)) { this._switchToQuickrPage(); } else { this._switchToPage(1); } } } else { this._showError(this._nlsMessages.docPickerDialog.errorCouldNotDetectFeedType, ""); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _generateDetectionURL: function(/*String*/ p_url) { // summary: // Generates the full Url needed to run the feedType detection call // against the server // p_url: String // The Url of the feed to detect the type of // returns: // String Returns the generated detection Url // tags: // private // entry trace var m = "_generateDetectionURL(p_url)"; if (this._isTracing) { this.traceEntry(m, p_url); } var url = p_url; // encode the given URL and add authentication data as needed url = encodeURIComponent(this._encodeUrlIfNeeded(url)); // get the vault slot ID only if one is set and the vault auth type is used var vaultSlotId; var settings = this._widgets[0].getSettings(); if ((settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault) && (settings.authProperties.vaultSlotID)) { vaultSlotId = encodeURIComponent(settings.authProperties.vaultSlotID); } else if ((settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) && (this._transientSlotId)) { vaultSlotId = encodeURIComponent(this._transientSlotId); } else { vaultSlotId = ""; } // replace the placeholders from the CMIS feed base URL to construct the target URL var result = this._pageParams.feedTypeBaseURL.replace("%7BtypeFilter%7D", "all").replace("%7BfeedUrl%7D", url).replace("%7BmimeType%7D", "application%2Fjson").replace("%7BvaultSlotId%7D", vaultSlotId).replace("%7BserviceId%7D", settings.serviceId); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _getDefaultButton: function() { // summary: // Determines whether the NEXT or FINISH button is the default button // in the current Wizard state. Sets _defaultButton to null, if // both buttons are disabled. // returns: // The domNode reference to the default button, or null, if no button // will react on ENTER // tags: // private // entry trace var m = "_getDefaultButton()"; if (this._isTracing) { this.traceEntry(m); } var finishDisabled = dojo.hasClass(this.dialogConfirm, 'lotusBtnDisabled'); var nextDisabled = dojo.hasClass(this.dialogNext, 'lotusBtnDisabled'); if (finishDisabled && nextDisabled) { this._defaultButton = null; } else { if (nextDisabled) { this._defaultButton = this.dialogConfirm; } else { this._defaultButton = this.dialogNext; } } // exit trace if (this._isTracing) { this.traceExit(m, this._defaultButton); } return this._defaultButton; // domNode }, _getTransientSlot: function(/*String*/ userid, /*String*/ password) { // summary: // Gets the transient credential slot to store the the userid and password // userid: String // The userid // password: String // The password // tags: // private // entry trace var m = "_getTransientSlot(userid, password)"; if (this._isTracing) { this.traceEntry(m, userid, password); } var postData = "name="+this._encodePostDataItem(userid); if (password !== null) { postData = postData + "&pw="+this._encodePostDataItem(password); } if (this._transientSlotId !== null) { postData = postData + "&slotid="+this._encodePostDataItem(this._transientSlotId); } var headers = { "Content-Type": "text/plain", "Accept": "text/plain"}; this._showGettingVaultBox(); dojo.xhrPost( { "url": this._vaultMgmtDataSinkUrl, "postData": postData, "handleAs": "text", "headers": headers, "sync": false, "load": dojo.hitch(this, function(/*Object*/ p_data) { this._hideGettingVaultBox(); this._transientSlotId = p_data; if(this.usePresetUrl){ var settings = this._widgets[0].getSettings(); var url = settings.serverUrl; this._fetchServerType(url);//Need to set actual _feedType before making server connection }else{ this._onGoFwd(); } }), "error": dojo.hitch(this, function(/*Object*/ p_error) { this._hideGettingVaultBox(); this._showError(this._nlsMessages.docPickerDialog.errorCouldNotGetVault, p_error); }) }); // exit trace if (this._isTracing) { this.traceExit(m); } }, _hideDetectingBox: function() { // summary: // Hides the element showing a message indicating that the feed type // detection is running // tags: // private // entry trace var m = "_hideDetectingBox()"; if (this._isTracing) { this.traceEntry(m); } dojo.style(this.fedDocPickerDetectingDiv, 'display', 'none'); dijit.setWaiState(this.fedDocPickerDetectingDiv, 'hidden', true); dijit.setWaiState(this.wizardPageContainer, 'busy', false); // exit trace if (this._isTracing) { this.traceExit(m); } }, _hideGettingVaultBox: function() { // summary: // Hides the element showing a message indicating that the // request for getting a transient vault slot is running // tags: // private // entry trace var m = "_hideGettingVaultBox()"; if (this._isTracing) { this.traceEntry(m); } dojo.style(this.fedDocPickerGettingVaultDiv, 'display', 'none'); dijit.setWaiState(this.fedDocPickerGettingVaultDiv, 'hidden', true); dijit.setWaiState(this.wizardPageContainer, 'busy', false); // exit trace if (this._isTracing) { this.traceExit(m); } }, _initEventHandles: function() { // summary: // Connects the events supported by this dialog to the corresponding callback methods // and stores the handles in the _eventHandles array // tags: // private // entry trace var m = "_initEventHandles()"; if (this._isTracing) { this.traceEntry(m); } // default this.inherited(arguments); // connect additional wizard events this._eventHandles.push(dojo.connect(this.dialogPrevious, "onclick", this, "_onGoBack")); this._eventHandles.push(dojo.connect(this.dialogFooterForm, "onsubmit", this, "_onSubmit")); this._eventHandles.push(dojo.connect(this.dialogCancel, "onclick", this, "_onCancel")); // define the dialog close event (i.e., X, ESC, mouse click outside of dialog) var dialogWidget = this; window.onTerminateDialog = function() { dialogWidget._onCancel(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _initializePages: function(/*Object*/ p_params) { // summary: // Instantiates widgets for each page and places. Widgets are placed into the // DOM-Tree in buildRendering() // p_params: // see constructor() comment // tags: // private // entry trace var m = "_initializePages(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { // list all arguments passed from constructor this.trace(m, "p_params.authProperties:", dojo.toJson(p_params.authProperties)); this.trace(m, "p_params.availableAuthTypes:", dojo.toJson(p_params.availableAuthTypes)); this.trace(m, "p_params.callingEnvironment:", p_params.callingEnvironment); this.trace(m, "p_params.customServiceSelectionEnabled:", p_params.customServiceSelectionEnabled); this.trace(m, "p_params.documentsServices:", dojo.toJson(p_params.documentsServices)); this.trace(m, "p_params.feedBaseURL:", p_params.feedBaseURL); this.trace(m, "p_params.feedTypeBaseURL:", p_params.feedTypeBaseURL); this.trace(m, "p_params.nlsMessages:", dojo.toJson(p_params.nlsMessages)); this.trace(m, "p_params.nlsUserInterface:", dojo.toJson(p_params.nlsUserInterface)); this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.nodeTypes:", dojo.toJson(p_params.nodeTypes)); this.trace(m, "p_params.onErrorStateChanged", p_params.onErrorStateChanged); this.trace(m, "p_params.onLayoutChanged:", p_params.onLayoutChanged); this.trace(m, "p_params.onReadyStateChanged:", p_params.onReadyStateChanged); this.trace(m, "p_params.pickerContext:", p_params.pickerContext); this.trace(m, "p_params.portalContextPath:", p_params.portalContextPath); this.trace(m, "p_params.pickerManager:", p_params.pickerManager); this.trace(m, "p_params.serviceDocBaseURL:", p_params.serviceDocBaseURL); this.trace(m, "p_params.vaultMgmtDataSinkUrl:", p_params.vaultMgmtDataSinkUrl); this.trace(m, "p_params.vaultSelectionEnabled:", p_params.vaultSelectionEnabled); this.trace(m, "p_params.vaultSelectionEnabledForPZN:", p_params.vaultSelectionEnabledForPZN); this.trace(m, "p_params.vaultSelectionEnabledForWCM:", p_params.vaultSelectionEnabledForWCM); this.trace(m, "p_params.vaultSlots:", dojo.toJson(p_params.vaultSlots)); } } // init the wizard page widgets and make sure to pass on constructor arguments, // so that each child widget can grab the information it needs var widRef; // init page 1 widget widRef = new com.ibm.workplace.wcm.ecm.picker.widget.ServerConnectionPageWidget(p_params); this._widgets.push(widRef); // init page 2 widget widRef = new com.ibm.workplace.wcm.ecm.picker.widget.CmisDocumentPickerPageWidget(p_params); this._widgets.push(widRef); // init page 3 widget widRef = new com.ibm.workplace.wcm.ecm.picker.widget.QuickrDocumentPickerPageWidget(p_params); this._widgets.push(widRef); // exit trace if (this._isTracing) { this.traceExit(m); } }, _initNLS: function() { // summary: // Initializes the aspects for supporting localization, for example, by loading the required NLS bundle(s). // Overrides the implementation from [com.ibm.widgets.GenericDialog], but leaves it up to the super to ensure // that it is called // tags: // protected // entry trace var m = "_initNLS()"; if (this._isTracing) { this.traceEntry(m); } this._nlsUserInterface = dojo.i18n.getLocalization("com.ibm.workplace.wcm.ecm.picker", 'FederatedDocumentsPickerUserInterface'); this._nlsMessages = dojo.i18n.getLocalization("com.ibm.workplace.wcm.ecm.picker", 'FederatedDocumentsPickerMessages'); // exit trace if (this._isTracing) { this.trace(m, "Initialized NLS object for user interface elements:", dojo.toJson(this._nlsUserInterface)); this.trace(m, "Initialized NLS object for messages:", dojo.toJson(this._nlsMessages)); this.traceExit(m); } }, _isCalledFromPZN: function() { // summary: // Returns an indication as to whether this widget is rendered in the context of Personalization // returns: // true if the rendering context is Personalization, false otherwise // tags: // private // entry trace var m = "_isCalledFromPZN()"; if (this._isTracing) { this.traceEntry(m); } var result = (this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _isCalledFromWCM: function() { // summary: // Returns an indication as to whether this widget is rendered in the context of Web Content Management // returns: // true if the rendering context is Web Content Management, false otherwise // tags: // private // entry trace var m = "_isCalledFromWCM()"; if (this._isTracing) { this.traceEntry(m); } var result = (this._callingEnvironment === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm); // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _isCurrentPageReady: function() { // summary: // Checks whether the page currently active in the dialog is in ready state. // Being in the ready state means that all data was collected on the page which // is either necessary to advance to the next page or to finish the dialog. // returns: // true, if the current page is in ready state, false otherwise // tags: // private // entry trace var m = "_isCurrentPageReady()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } // init the result var result = false; if ((this._currentPage > -1) && (this._currentPage < this._pages.length)) { var widRef = this._widgets[this._currentPage]; result = widRef.isReady(); } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // Boolean }, _isQuickrFeedType: function(/*String*/ p_feedType) { // summary: // Determines whether the passed in feedType identifier is a Quickr type or not // returns: Boolean // true if the given type is a Quickr type, false if not // tags: // private var result; if ((p_feedType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds) || (p_feedType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qdsentry)) { result = true; } else { result = false; } return result; }, _normalizeFeedTypeParam: function(/*String*/ p_feedType) { // summary: // Normalizes the given feedType String to either 'cmis' or 'qds' for attaching it to // the result Url in PZN case. // returns: String // The normalized feedType ('cmis' or 'qds') or the value of p_feedType, if it is an unknown // feedType. If p_feedType is undefined or not a string, the method returns an empty string. // tags: // private // entry trace var m = "_normalizeFeedTypeParam(p_feedType)"; if (this._isTracing) { this.traceEntry(m); } var result = ""; if (typeof p_feedType == 'string') { var lcFeedType = p_feedType.toLowerCase(); if ((lcFeedType === 'cmis') || (lcFeedType === 'servicedoc')) { result = 'cmis'; } else if ((lcFeedType === 'qds') || (lcFeedType === 'qdsentry')) { result = 'qds'; } } else { result = ""; } // exit trace if (this._isTracing) { this.traceExit(m, result); } return result; // String }, _onCancel: function() { // summary: // Overridden GenericDialog _onCancel method. We need to do this as we're not using // the GenericDialog with a single _widget instance // tags: // private callback // entry trace var m = "_onCancel()"; if (this._isTracing) { this.traceEntry(m); } this._deleteTransientSlot(); if (this._onCancelCallbackFn && dojo.isFunction(this._onCancelCallbackFn)) { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function:", this._onCancelCallbackFn); } this._onCancelCallbackFn(); } if (this.autoClose) { // destroy this dialog (but allow the hide animation to complete before) this.hide(); setTimeout(dojo.hitch(this, "destroyDialog"), this.duration + 200); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onConfirm: function() { // summary: // Overridden default GenericDialog _onConfirm method. We need to do this as we're not using // the GenericDialog with a single _widget instance // tags: // private callback // entry trace var m = "_onConfirm()"; if (this._isTracing) { this.traceEntry(m); } this._deleteTransientSlot(); if (!dojo.hasClass(this.dialogConfirm, 'lotusBtnDisabled')) { var returnURL = ""; var title = ""; var url = ""; var selItem = this.getSelectedItemJSON(); // trace if (this._isTracing) { this.trace(m, "Selected item:", selItem); } if (selItem !== null) { title = selItem.title; url = selItem.url; if (this._isCalledFromPZN()) { // grab authProperties from the server connection widget var settings = this._widgets[0].getSettings(); // grab the feedType from the server connection widget returnURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.addQueryParameter(url, "feedType", this._normalizeFeedTypeParam(settings.serverType)); // authentication information is only attached for PZN calling environment // attach vault Slot only if one is set and the vault auth type is used if ((settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeVault) && (settings.authProperties.vaultSlotID)) { returnURL = com.ibm.workplace.wcm.ecm.picker.util.URLUtils._INSTANCE.addQueryParameter(returnURL, com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._proxyVaultSlotParamName, settings.authProperties.vaultSlotID); } // Set the _selectedPath with the array of ids of tree nodes starting from the root node and going down to the selected node var dlg = this; this._widgets[1].getLibTree().path.forEach(function(node,i){ dlg._selectedPath[i++]=node.id; }); } else { // URL is returned as-is in WCM environment returnURL = url; } } if (this._onConfirmCallbackFn && dojo.isFunction(this._onConfirmCallbackFn)) { // trace if (this._isTracing) { this.trace(m, "Dispatching to callback function passing title and URL of selection:", [this._onConfirmCallbackFn, title, returnURL]); } this._onConfirmCallbackFn(title, returnURL, this._selectedPath); } if (this.autoClose) { // hide and destroy this dialog this.hide(); setTimeout(dojo.hitch(this, "destroyDialog"), this.duration + 200); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onDefaultAction: function() { // summary: // Callback triggered by one or more onKeypress handlers to trigger the default // action currently assigned to the ENTER key. Based on the page selected, this // could either be clicking the NEXT or the FINISH button. // tags: // private callback // entry trace var m = "_onDefaultAction()"; if (this._isTracing) { this.traceEntry(m); } var defBtn = this._getDefaultButton(); if (defBtn === this.dialogConfirm) { this._onConfirm(); } else if (defBtn === this.dialogNext) { this._onGoFwdPrep(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onErrorStateChanged: function(/*Object*/ p_sender, /*Boolean*/ p_errorState, /*String*/ p_errorMsg, /*String?*/ p_errorDetails) { // summary: // Shows the given error message in the red error message box within // the dialog. Optionally, also shows details for the error // in a white box. // p_sender: Object // The widget instance sending this error to this dialog. // p_errorState: Boolean // The flag indicating whether the calling widget went into error state, or whether the // error state was left. // p_errorMsg: String // The error message to display // p_errorDetails: String // Optional string with a more detailed description of the error // tags: // private callback var m = "_onErrorStateChanged(p_sender, p_errorState, p_errorMsg, p_errorDetails)"; if (this._isTracing) { this.traceEntry(m, [p_sender, p_errorState, p_errorMsg, p_errorDetails]); } if (p_errorState === true) { this._showError(p_errorMsg, p_errorDetails); } else { if (p_errorState === false) { this._clearError(); } else { // p_errorState is not a Boolean value } } if (this._isTracing) { this.traceExit(m); } }, _onFocusFirstItem: function() { // summary: // Callback method triggered when the dialog finished showing for the first time and // used to delegate focusing to the respective active page (if there is one) // tags: // private callback // entry trace var m = "_onFocusFirstItem()"; if (this._isTracing) { this.traceEntry(m); } if ((this._currentPage > -1) && (this._currentPage < 3)) { if (this._widgets[this._currentPage] && dojo.isFunction(this._widgets[this._currentPage].setFocus)) { this._widgets[this._currentPage].setFocus(); } } if (this._isTracing) { this.traceExit(m); } }, _onGoBack: function(/*Event*/ p_evt) { // summary: // Callback method triggered when the 'Back' button was clicked. First checks whether // the button is enabled (i.e. the click needs to be processed) and then selects the // previous page of the currently selected one (if available). // tags: // private callback // entry trace var m = "_onGoBack()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } dojo.stopEvent(p_evt); if (!dojo.hasClass(this.dialogPrevious, 'lotusBtnDisabled')) { if (this._currentPage > 0) { // reset _feedType variable on ServerConnectionPageWidget, to make sure it doesn't // return false values this._widgets[0].setFeedType(null); // always go back to first page this._switchToPage(0); } } // exit trace if (this._isTracing) { this.traceExit(m); } return false; }, _onGoFwdPrep: function() { // summary: // Callback method triggered when the 'Next' button was clicked. In case of // username / password authentication it gets the transient slot and invokes // onGoFwd through _getTransientSlot. In the other cases it invokes onGoFwd directly. // tags: // private callback // entry trace var m = "_onGoFwdPrep()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } if (this.usePresetUrl || (!dojo.hasClass(this.dialogNext, 'lotusBtnDisabled')) && (this._currentPage < this._pages.length - 1)) { var settings = this._widgets[0].getSettings(); if (settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) { var userid = settings.authProperties.username; var password = settings.authProperties.password; this._getTransientSlot(userid, password); } else { this._onGoFwd(); } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onGoFwd: function() { // summary: // Callback method triggered indirectly by onGoFwdPrep when the 'Next' button was clicked. // First checks whether the button is enabled (i.e. the click needs to be processed) // and then selects the next page of the currently selected one (if available). // tags: // private callback // entry trace var m = "_onGoFwd()"; if (this._isTracing) { this.traceEntry(m); this.trace(m, "Current page:", this._currentPage); } if (!dojo.hasClass(this.dialogNext, 'lotusBtnDisabled')) { if (this._currentPage < this._pages.length - 1) { var settings = this._widgets[0].getSettings(); var url = settings.serverUrl; // try to find the feedTyp of the current server Url in our local // type map array var feedType = this._serverTypeMap[url]; if (feedType) { // use the buffered type info and switch to the correct page directly // set feedType on first page this._widgets[0].setFeedType(feedType); // if serverType is a Quickr compatible type, go to quickr picker page instead if (this._isQuickrFeedType(feedType)) { this._switchToQuickrPage(); } else { this._switchToPage(1); } } else { // no buffered info found // To avoid calling the remote feed detection datasource for predefined Quickr // Servers, call _determineServerType() to find out, whether it's a Quickr // server. if not, we have to run the feed type detection code, as a predefined // CMIS server could always be either a service doc or a folder/repository Url var serverType = settings.serverType; if (serverType === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._qds) { // fast path for predefined Quickr Servers. Go directly to the Quickr page without // running remote feed type detection // buffer type information this._serverTypeMap[url] = serverType; // set feedType on first page this._widgets[0].setFeedType(serverType); this._switchToQuickrPage(); } else { // this is not a predefined Quickr type server, so it's either a predefined // CMIS server that we need to scan for the exact type, or a custom server that needs // to get auto-detected anyway this._fetchServerType(url); } } } } // exit trace if (this._isTracing) { this.traceExit(m); } }, _onReadyStateChanged: function(/*Boolean*/ p_readyState, /*Object*/ p_widgetRef) { // summary: // Callback triggered by any of the available page widget instances, whenever their // ready state changes. The dialog uses this information to update the enabled/disabled // state of it's buttons. // p_readyState: Boolean // Indicates whether the calling widget is ready (true) or not (false) // p_widgetRef: Object // [com.ibm.workplace.wcm.ecm.picker.widget.GenericWizardPageWidget] instance of the page // widget calling this method // tags: // private callback // entry trace var m = "_onReadyStateChanged(p_readyState, p_widgetRef)"; if (this._isTracing) { this.traceEntry(m, [p_readyState, p_widgetRef]); } /* No need to double-check whether the calling widget is the active one, as only the * active one could be changed and therefore is the only one that could trigger this method * * if (p_widgetRef == this._widgets[this._currentPage]) { // ready state change is for the current page }*/ this._enableDisableButtons(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _onSubmit: function(/*Event*/ p_evt) { // summary: // Callback that is triggered, when one of the submit buttons (BACK, NEXT, FINISH) // is clicked, or if ENTER is pressed. // p_evt: Event // The event that caused the submit method to be called // returns: Boolean // Always returns false, to cancel the default submit action (which would // reload the page) // tags: // private callback // entry trace var m = "_onSubmit(p_evt)"; if (this._isTracing) { this.traceEntry(m, [p_evt]); } dojo.stopEvent(p_evt); this._onDefaultAction(); // exit trace if (this._isTracing) { this.traceExit(m, false); } // prevent browser to actually submit a form (would cause a page refresh) return false; // Boolean }, _setBackBtnEnabled: function(/*Boolean*/ p_isEnabled) { // summary: // Helper method for setting the enabled/disabled state of the Back button // p_isEnabled: Boolean // Defines the enabled state of the button. If set to true, the disabled CSS classes are // removed from the DOM node. Otherwise, they get added to it. // tags: // private // entry trace var m = "_setBackBtnEnabled(p_isEnabled)"; if (this._isTracing) { this.traceEntry(m, [p_isEnabled]); } this._setBtnEnabled(this.dialogPrevious, p_isEnabled); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setBtnEnabled: function(/*DomNode*/ p_Btn, /*Boolean*/ p_isEnabled) { // summary: // Helper method for setting the enabled/disabled state of the given button // p_Btn: DOMNode // DOMNode of the button that needs to be updated // p_isEnabled: Boolean // Defines the enabled state of the button. If set to true, the disabled CSS classes are // removed from the DOM node. Otherwise, they get added to it. // tags: // private // entry trace var m = "_setBtnEnabled(p_Btn, p_isEnabled)"; if (this._isTracing) { this.traceEntry(m, [p_Btn, p_isEnabled]); } if (p_isEnabled) { dojo.removeClass(p_Btn, 'lotusBtnDisabled'); dojo.removeAttr(p_Btn, 'disabled'); dijit.removeWaiState(p_Btn, 'disabled'); } else { dojo.addClass(p_Btn, 'lotusBtnDisabled'); dojo.attr(p_Btn, 'disabled', 'disabled'); dijit.setWaiState(p_Btn, 'disabled', true); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _setFinishBtnEnabled: function(/*Boolean*/ p_isEnabled) { // summary: // Helper method for setting the enabled/disabled state of the Finish button // p_isEnabled: Boolean // Defines the enabled state of the button. If set to true, the disabled CSS classes are // removed from the DOM node. Otherwise, they get added to it. // tags: // private // entry trace var m = "_setFinishBtnEnabled(p_isEnabled)"; if (this._isTracing) { this.traceEntry(m, [p_isEnabled]); } this._setBtnEnabled(this.dialogConfirm, p_isEnabled); // exit trace if (this._isTracing) { this.traceExit(m); } }, _setNextBtnEnabled: function(/*Boolean*/ p_isEnabled) { // summary: // Helper method for setting the enabled/disabled state of the Next button // p_isEnabled: Boolean // Defines the enabled state of the button. If set to true, the disabled CSS classes are // removed from the DOM node. Otherwise, they get added to it. // tags: // private // entry trace var m = "_setNextBtnEnabled(p_isEnabled)"; if (this._isTracing) { this.traceEntry(m, [p_isEnabled]); } this._setBtnEnabled(this.dialogNext, p_isEnabled); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showDetectingBox: function() { // summary: // Displays the element showing a message indicating that the feed type // detection is running (which is an asynchronous operation that involves // a server connection) // tags: // private // entry trace var m = "_showDetectingBox()"; if (this._isTracing) { this.traceEntry(m); } if (dojo.style(this.fedDocPickerDetectingDiv, 'display') != 'block') { dojo.style(this.fedDocPickerDetectingDiv, 'display', 'block'); } dijit.setWaiState(this.fedDocPickerDetectingDiv, 'hidden', false); dijit.setWaiState(this.wizardPageContainer, 'busy', true); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showError: function(/*String*/ p_errorMsg, /*String?*/ p_errorDetails) { // summary: // Shows the given error message in the red error message box within // the dialog. Optionally, also shows details for the error // in a white box. // p_errorMsg: String // The error message to display // p_errorDetails: String // Optional string with a more detailed description of the error // tags: // private callback // entry trace var m = "_showError(p_errorMsg, p_errorDetails)"; if (this._isTracing) { this.traceEntry(m, [p_errorMsg, p_errorDetails]); } this._hideDetectingBox(); this._hideGettingVaultBox(); if (typeof p_errorMsg == 'string') { var _errMsg = p_errorMsg.substring(0, Math.min(this._maxErrorChars, p_errorMsg.length)); dojo.attr(this.wizardErrorSpan, 'innerHTML', _errMsg); dojo.style(this.wizardErrorDiv, 'opacity', '1'); dojo.style(this.wizardErrorDiv, 'display', 'block'); dijit.setWaiState(this.wizardErrorDiv, 'hidden', false); if (typeof p_errorDetails == 'string') { var _errDetails = p_errorDetails.substring(0, Math.min(this._maxErrorChars, p_errorDetails.length)); dojo.attr(this.wizardErrorDetailsSpan, 'innerHTML', _errDetails); dojo.style(this.wizardErrorDetailsDiv, 'display', 'block'); dijit.setWaiState(this.wizardErrorDetailsDiv, 'hidden', false); } /* // now, fade in the error DIV var fArgs = { node: this.wizardErrorDiv, duration: 500, onEnd: dojo.hitch(this, function() { console.log("Dialog.showError().anim.play.onEnd(), opacity 1, display: block"); }) }; dojo.fadeIn(fArgs).play(); */ } else { this.trace(m, '_showError was called with an undefined error message.'); } // record error and set error state to true. Need to call _clearError() to // get out of error state again. this._errorState = true; // also set the errorState on the currently active page widget to allow their error // handling code to function correctly. Otherwise, code that clears errors wouldn't be // effective afterwards if ((this._currentPage >= 0) && (this._currentPage <= 2)) { this._widgets[this._currentPage]._errorState = true; } // disable buttons, in case they were showing enabled, but user cannot continue // because of an error that occurred this._enableDisableButtons(); // make sure the dialog looks 'good' after opening the error box this.layout(); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showErrorForXHRRequest: function(/*Object*/ioargs) { // summary: // Shows the error message for a failed XHR request // ioargs: // The ioargs of the XHR request // tags: // private // entry trace var m = "_showErrorForXHRRequest()"; if (this._isTracing) { this.traceEntry(m, ioargs); } var errorMsg = com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils._INSTANCE.getErrorMessage( ioargs, this._nlsMessages.srvCommunication, (this._widgets[0].getSettings().serverUrl.substring(0, 6).toLowerCase() === "https:") ); this._showError(errorMsg[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorMessage], errorMsg[com.ibm.workplace.wcm.ecm.picker.util.ErrorMsgUtils.ErrorDetails]); // exit trace if (this._isTracing) { this.traceExit(m); } }, _showGettingVaultBox: function() { // summary: // Displays the element showing a message indicating that the request for // the transient vault slot is running (which is an asynchronous operation that involves // a server connection) // tags: // private // entry trace var m = "_showGettingVaultBox()"; if (this._isTracing) { this.traceEntry(m); } if (dojo.style(this.fedDocPickerGettingVaultDiv, 'display') != 'block') { dojo.style(this.fedDocPickerGettingVaultDiv, 'display', 'block'); } dijit.setWaiState(this.fedDocPickerGettingVaultDiv, 'hidden', false); dijit.setWaiState(this.wizardPageContainer, 'busy', true); // exit trace if (this._isTracing) { this.traceExit(m); } }, _switchToPage: function(/*Integer*/ p_pageIndex, /*String?*/ p_feedType) { // summary: // Switches to the given page by looking the page instance up in the _pages[] array, // setting it as the active page on the StackContainer widget and running any related // update methods (e.g. updating labels in the dialog). // p_pageIndex: Integer // Index to the page in this._pages[] array that should become active // p_feedType: String [optional] // Type of the selected server. This is a required parameter when switching // to Page 1 (Cmis page). Switching back to page 0 (Server connection page) or // Page 2 (Quickr Page), this parameter is not needed. // tags: // private // entry trace var m = "_switchToPage(p_pageIndex)"; if (this._isTracing) { this.traceEntry(m, [p_pageIndex]); this.trace(m, "Current page:", this._currentPage); } if ((p_pageIndex > -1) && (p_pageIndex < this._pages.length)) { // when switching pages, clear error message this._clearError(); // and hide the detecting box this._hideDetectingBox(); this._hideGettingVaultBox(); this._currentPage = p_pageIndex; // update wizard step and description information var widRef = this._widgets[this._currentPage]; this._updateStepLabel(widRef.getStepLabel()); this._updateStepDescription(widRef.getStepDescription()); this.wizardPageContainer.selectChild(this._pages[this._currentPage]); if (this._currentPage > 0) { // CMIS or Quickr picker page (transition from page 1 to page 2 or 3) var settings = this._widgets[0].getSettings(); if ((settings.authProperties.authType == com.ibm.workplace.wcm.ecm.picker.widget.AuthenticationWidget._authTypeUserPwd) && (this._transientSlotId)) { settings.authProperties.vaultSlotID = this._transientSlotId; } this._widgets[this._currentPage].initializePage(settings); } else { // do anything that needs to be done when going back to first page } this._enableDisableButtons(); // process the layout of the dialog this.layout(); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _switchToQuickrPage: function() { // summary: // Checks whether Quickr Document Services support is enabled. Depending on the result // this method either switches to the Quickr page of this dialog or displays an error // message. // tags: // private // entry trace var m = "_switchToQuickrPage()"; if (this._isTracing) { this.traceEntry(m); } if (this._qdsSupportEnabled) { // go to Quickr Page this._switchToPage(2); } else { this._showError(this._nlsMessages.docPickerDialog.errorQDSNotEnabled, ""); } // exit trace if (this._isTracing) { this.traceExit(m); } }, _updateStepDescription: function(/*String*/ p_descrText) { // summary: // Updates the step description text in the dialog. // p_descrText: String // The descriptive text for this wizard step (describing what needs to be done with // the active page widget) // tags: // private // entry trace var m = "_updateStepDescription(p_descrText)"; if (this._isTracing) { this.traceEntry(m, p_descrText); } dojo.attr(this.wizardStepDescription, 'innerHTML', p_descrText); // exit trace if (this._isTracing) { this.traceExit(m); } }, _updateStepLabel: function(/*String*/ p_labelText) { // summary: // Updates the step label in the dialog. The step label indicates which step // of a total number of steps is currently active in the dialog. // p_labelText: String // The new text for the step label // tags: // private // entry trace var m = "_updateStepLabel(p_labelText)"; if (this._isTracing) { this.traceEntry(m, p_labelText); } dojo.attr(this.wizardStepLabel, 'innerHTML', "" + p_labelText + ""); // exit trace if (this._isTracing) { this.traceExit(m); } } }); } if(!dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerWidgetManager"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. dojo._hasResource["com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerWidgetManager"] = true; ////////////////////////////////////////////////// // Licensed Materials - Property of IBM // // 5724-E76, 5655-R17, 5655-M44 // // Copyright IBM Corp. 2015 All Rights reserved.// ////////////////////////////////////////////////// dojo.provide("com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerWidgetManager"); dojo.require("com.ibm.widgets._Traceable"); dojo.declare('com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsPickerWidgetManager', [com.ibm.widgets._Traceable], { // summary: // Manages the launching of the Federated Documents Picker and the Quickr Document Picker. // _callingEnvId: [private] String // Identifier of the context the Federated Documents Picker is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management // (default) _callingEnvId: com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm, // _dsPickerArgs: [private] Object // JSON object holding properties to pass to the picker supporting Quickr Document Services _dsPickerArgs: {}, // _fedDocsPickerArgs: [private] Object // JSON object holding properties to pass to the Federated Documents Picker _fedDocsPickerArgs: {}, // _federatedDocumentsServiceBean: [private] Object // Bean holding configuration and runtime data of the federated documents support _federatedDocumentsServiceBean: null, // _isTracing: [private] Boolean // Indicates whether or not this class writes trace messages to the console _isTracing: false, // _namespace: [private] String // Namespace to pass to the Federated Documents Picker for its user interface elements etc. _namespace: "fedDocsPckrDlg_", // _onCancelCallbackFn: [private] Function // Callback function to execute when the user cancels the selection of a resource in the Federated Documents // Picker or Quickr Document Picker or when the user closes the Federated Documents Picker or Quickr Document // Picker _onCancelCallbackFn: null, // _onConfirmCallbackFn: [private] Function // Callback function to execute when the user confirms the selection of a resource in the Federated Documents // Picker or Quickr Document Picker _onConfirmCallbackFn: null, constructor: function(/*Object*/ p_params) { // summary: // Constructs this federated documents picker manager with the given JSON object // p_params.callingEnvId: String // Identifier of the context this manager is used in, for example, // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn] for Personalization or // [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm] for Web Content Management (default) // (optional) // p_params.documentServicesPickerArgs: Object // JSON object holding additional arguments to initialize the Quickr Document Picker with (optional) // p_params.federatedDocumentsPickerArgs: Object // JSON object holding additional arguments to initialize the Federated Documents Picker with (optional) // p_params.federatedDocumentsServiceBean: Object // Instance of [com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsServiceBean] holding configuration // and runtime data of the federated documents support // p_params.namespace: String // Namespace to use for user interface elements etc. // p_params.onCancelCallbackFn: Function // Callback function to execute when the user cancels the selection of a resource in the Federated Documents // Picker or Quickr Document Picker or when the user closes the Federated Documents Picker or Quickr Document // Picker (optional) // p_params.onConfirmCallbackFn: Function // Callback function to execute when the user confirms the selection of a resource in the Federated Documents // Picker or Quickr Document Picker (optional) // tags: // public // set instance trace support flag this._isTracing = this.isTracing(); // entry trace var m = "constructor(p_params)"; if (this._isTracing) { this.traceEntry(m, p_params); if (p_params) { this.trace(m, "p_params.callingEnvId:", p_params.callingEnvId); this.trace(m, "p_params.documentServicesPickerArgs:", p_params.documentServicesPickerArgs); this.trace(m, "p_params.federatedDocumentsPickerArgs:", p_params.federatedDocumentsPickerArgs); this.trace(m, "p_params.federatedDocumentsServiceBean:", p_params.federatedDocumentsServiceBean); this.trace(m, "p_params.namespace:", p_params.namespace); this.trace(m, "p_params.onCancelCallbackFn:", p_params.onCancelCallbackFn); this.trace(m, "p_params.onConfirmCallbackFn:", p_params.onConfirmCallbackFn); } } // callingEnvId if (typeof p_params.callingEnvId == 'string') { this._callingEnvId = p_params.callingEnvId; } // federatedDocumentsServiceBean if (p_params.federatedDocumentsServiceBean && typeof p_params.federatedDocumentsServiceBean == 'object') { this._federatedDocumentsServiceBean = p_params.federatedDocumentsServiceBean; } // namespace if (typeof p_params.namespace == 'string') { this._namespace = p_params.namespace; } // onCancelCallbackFn if (typeof p_params.onCancelCallbackFn == 'function') { this._onCancelCallbackFn = p_params.onCancelCallbackFn; } // onConfirmCallbackFn if (typeof p_params.onConfirmCallbackFn == 'function') { this._onConfirmCallbackFn = p_params.onConfirmCallbackFn; } // initialize the arguments to initialize the document pickers with if (this._federatedDocumentsServiceBean.isQDSSupportEnabled()) { this._initFederatedDocumentsPickerArgs(p_params.federatedDocumentsPickerArgs); this._initDocumentServicesPickerArgs(p_params.documentServicesPickerArgs); } else { this._initFederatedDocumentsPickerArgs(p_params.federatedDocumentsPickerArgs); } // exit trace if (this._isTracing) { this.traceExit(m); } }, launchDocumentServicesPickerDialog: function(/*String*/ p_url, /*Function?*/ p_onConfirmCallbackFn, /*Function?*/ p_onCloseCallbackFn) { // summary: // Launches the Quickr Document Picker with the option to pass a custom confirm and cancel callback // function. // p_url: String // The server URL that will be passed on to the QuickrPicker to avoid that users have // to type it in again // p_onConfirmCallbackFn: Function // Confirm Callback function being called by the QuickrPicker on dialog confirmation // p_onCloseCallbackFn: Function // Close Callback function being called by the QuickrPicker on dialog close/hide (also being called // when closing the dialog after 'confirm' action // tags: // public // entry trace var m = "launchDocumentServicesPickerDialog(p_url, p_onConfirmCallbackFn, p_onCloseCallbackFn)"; if (this._isTracing) { this.traceEntry(m, [p_url, p_onConfirmCallbackFn, p_onCloseCallbackFn]); } var confirmCallbackFn = null; var closeCallbackFn = null; if (typeof p_onConfirmCallbackFn == 'function') { confirmCallbackFn = p_onConfirmCallbackFn; } if (typeof p_onCloseCallbackFn == 'function') { closeCallbackFn = p_onCloseCallbackFn; } // trace if (this._isTracing) { this.trace(m, "Confirm callback function: ", confirmCallbackFn); this.trace(m, "Close callback function: ", closeCallbackFn); } var launcher = new com.ibm.workplace.wcm.ecm.quickr.picker.launcher.DocPickerLauncher(confirmCallbackFn, closeCallbackFn, this._dsPickerArgs); var pickerDialog = launcher.launchDocumentPicker(p_url); // exit trace if (this._isTracing) { this.traceExit(m); } return pickerDialog; }, launchFederatedDocumentsPickerDialog: function() { // summary: // Launches the Federated Documents Picker and passes along expected arguments, // such as, a reference to this manager instance to allow the picker to bring // up the Quickr Document Picker if necessary // tags: // public // entry trace var m = "launchFederatedDocumentsPickerDialog()"; if (this._isTracing) { this.traceEntry(m); } var fedDocsPicker = new com.ibm.workplace.wcm.ecm.picker.widget.FederatedDocumentsPickerDialogWidget(this._fedDocsPickerArgs); fedDocsPicker.show(); // exit trace if (this._isTracing) { this.traceExit(m); } return fedDocsPicker; }, _initDocumentServicesPickerArgs: function(/*Object?*/ p_dsPickerArgs) { // summary: // Initializes the arguments to initialize the Quickr Document Picker with // p_dsPickerArgs: Object // JSON object holding additional arguments to initialize the Quickr Document Picker with (optional) // tags: // private // entry trace var m = "_initDocumentServicesPickerArgs(p_dsPickerArgs)"; if (this._isTracing) { this.traceEntry(m, p_dsPickerArgs); if(p_dsPickerArgs) { this.trace(m, "p_dsPickerArgs.dialogTitleKey", p_dsPickerArgs.dialogTitleKey); this.trace(m, "p_dsPickerArgs.showNodePath", p_dsPickerArgs.showNodePath); this.trace(m, "p_dsPickerArgs.showPlaces", p_dsPickerArgs.showPlaces); this.trace(m, "p_dsPickerArgs.nodeTypes", dojo.toJson(p_dsPickerArgs.nodeTypes)); this.trace(m, "p_dsPickerArgs.downloadTypes", dojo.toJson(p_dsPickerArgs.downloadTypes)); this.trace(m, "p_dsPickerArgs.viewTypes", dojo.toJson(p_dsPickerArgs.viewTypes)); this.trace(m, "p_dsPickerArgs.proxyUrl",p_dsPickerArgs.proxyUrl); } } // assemble the URL of the Ajax proxy used by the document picker to connect to remote servers // this uses the standard ajax proxy mapping and not the cmis_proxy mapping var ajaxProxyUrl = this._federatedDocumentsServiceBean.getPortalContextPath() + "/proxy"; if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn) { // prepare the arguments to initialize the document services federated documents picker // when launched in PZN this._dsPickerArgs = { "dialogTitleKey": "dialogTitleSelectFolder", "showNodePath": true, "showPlaces": true, "nodeTypes": ["place", "library", "folder"], "downloadTypes": ["library", "folder"], "viewTypes": [], "proxyUrl": ajaxProxyUrl }; } else if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm) { // prepare the arguments to initialize the document services federated documents picker // when launched in the WCM RTE this._dsPickerArgs = { "dialogTitleKey": "dialogTitleSelectDocument", "showNodePath": true, "showPlaces": true, "nodeTypes": ["place", "library", "folder", "document", "doclink"], "downloadTypes": ["document"], "viewTypes": ["library", "folder", "document", "doclink"], "proxyUrl": ajaxProxyUrl }; } if (p_dsPickerArgs && typeof p_dsPickerArgs == 'object') { this._mergeArguments(p_dsPickerArgs, this._dsPickerArgs); } // exit trace if (this._isTracing) { this.trace(m, "Document services picker arguments initialized:", this._dsPickerArgs); if(this._dsPickerArgs) { this.trace(m, "_dsPickerArgs.dialogTitleKey", this._dsPickerArgs.dialogTitleKey); this.trace(m, "_dsPickerArgs.showNodePath", this._dsPickerArgs.showNodePath); this.trace(m, "_dsPickerArgs.showPlaces", this._dsPickerArgs.showPlaces); this.trace(m, "_dsPickerArgs.nodeTypes", dojo.toJson(this._dsPickerArgs.nodeTypes)); this.trace(m, "_dsPickerArgs.downloadTypes", dojo.toJson(this._dsPickerArgs.downloadTypes)); this.trace(m, "_dsPickerArgs.viewTypes", dojo.toJson(this._dsPickerArgs.viewTypes)); this.trace(m, "_dsPickerArgs.proxyUrl", this._dsPickerArgs.proxyUrl); } this.traceExit(m); } }, _initFederatedDocumentsPickerArgs: function(/*Object?*/ p_fedDocsPickerArgs) { // summary: // Initializes the arguments to initialize the Federated Documents Picker with // p_fedDocsPickerArgs: Object // JSON object holding additional arguments to initialize the Federated Documents Picker with (optional) // tags: // private // entry trace var m = "_initFederatedDocumentsPickerArgs(p_fedDocsPickerArgs)"; if (this._isTracing) { this.traceEntry(m, p_fedDocsPickerArgs); if(p_fedDocsPickerArgs) { this.trace(m, "p_fedDocsPickerArgs.callingEnvironment", p_fedDocsPickerArgs.callingEnvironment); this.trace(m, "p_fedDocsPickerArgs.customServiceSelectionEnabled", p_fedDocsPickerArgs.customServiceSelectionEnabled); this.trace(m, "p_fedDocsPickerArgs.documentsServices", p_fedDocsPickerArgs.documentsServices); this.trace(m, "p_fedDocsPickerArgs.feedBaseURL",p_fedDocsPickerArgs.feedBaseURL); this.trace(m, "p_fedDocsPickerArgs.feedTypeBaseURL", p_fedDocsPickerArgs.feedTypeBaseURL); this.trace(m, "p_fedDocsPickerArgs.nodeTypes", dojo.toJson(p_fedDocsPickerArgs.nodeTypes)); this.trace(m, "p_fedDocsPickerArgs.onCancelCallbackFn", p_fedDocsPickerArgs.onCancelCallbackFn); this.trace(m, "p_fedDocsPickerArgs.onConfirmCallbackFn", p_fedDocsPickerArgs.onConfirmCallbackFn); this.trace(m, "p_fedDocsPickerArgs.pickerManager", p_fedDocsPickerArgs.pickerManager); this.trace(m, "p_fedDocsPickerArgs.qdsSupportEnabled", p_fedDocsPickerArgs.qdsSupportEnabled); this.trace(m, "p_fedDocsPickerArgs.serviceDocBaseURL", p_fedDocsPickerArgs.serviceDocBaseURL); this.trace(m, "p_fedDocsPickerArgs.vaultMgmtDataSinkUrl", p_fedDocsPickerArgs.vaultMgmtDataSinkUrl); this.trace(m, "p_fedDocsPickerArgs.vaultSelectionEnabled", p_fedDocsPickerArgs.vaultSelectionEnabled); this.trace(m, "p_fedDocsPickerArgs.vaultSelectionEnabledForPZN", p_fedDocsPickerArgs.vaultSelectionEnabledForPZN); this.trace(m, "p_fedDocsPickerArgs.vaultSelectionEnabledForWCM", p_fedDocsPickerArgs.vaultSelectionEnabledForWCM); this.trace(m, "p_fedDocsPickerArgs.vaultSlots", p_fedDocsPickerArgs.vaultSlots); this.trace(m, "p_fedDocsPickerArgs.portalContextPath", p_fedDocsPickerArgs.portalContextPath); this.trace(m, "p_fedDocsPickerArgs.usePresetUrl", p_fedDocsPickerArgs.usePresetUrl); } } // query the federated documents service bean for the configuration var customServiceSelectionEnabled = this._federatedDocumentsServiceBean.isCustomServiceSelectionEnabled(); var federatedDocumentsServices = this._federatedDocumentsServiceBean.getFederatedDocumentsServices(); var feedBaseURL = this._federatedDocumentsServiceBean.getFeedBaseURL(); var feedTypeBaseURL = this._federatedDocumentsServiceBean.getFeedTypeBaseURL(); var isQDSSupportEnabled = this._federatedDocumentsServiceBean.isQDSSupportEnabled(); var isVaultSelectionEnabledForPZN = this._federatedDocumentsServiceBean.isVaultSelectionEnabledForPZN(); var isVaultSelectionEnabledForWCM = this._federatedDocumentsServiceBean.isVaultSelectionEnabledForWCM(); var serviceDocBaseURL = this._federatedDocumentsServiceBean.getServiceDocumentBaseURL(); var vaultMgmtDataSinkUrl = this._federatedDocumentsServiceBean.getVaultMgmtDataSinkUrl(); var vaultSlots = this._federatedDocumentsServiceBean.getVaultSlots(); var portalContextPath = this._federatedDocumentsServiceBean.getPortalContextPath(); var usePresetUrl = false; if(p_fedDocsPickerArgs && p_fedDocsPickerArgs.usePresetUrl) usePresetUrl = p_fedDocsPickerArgs.usePresetUrl; if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._pzn) { // prepare the arguments to initialize the universal federated documents picker // when launched from PZN this._fedDocsPickerArgs = { "callingEnvironment": this._callingEnvId, "customServiceSelectionEnabled": customServiceSelectionEnabled, "documentsServices": federatedDocumentsServices, "feedBaseURL": feedBaseURL, "feedTypeBaseURL": feedTypeBaseURL, "namespace": this._namespace, "nodeTypes": ["repository", "folder"], "onCancelCallbackFn": this._onCancelCallbackFn, "onConfirmCallbackFn": this._onConfirmCallbackFn, "pickerManager": this, "qdsSupportEnabled": isQDSSupportEnabled, "serviceDocBaseURL": serviceDocBaseURL, "vaultMgmtDataSinkUrl": vaultMgmtDataSinkUrl, "vaultSelectionEnabled": isVaultSelectionEnabledForPZN, "vaultSelectionEnabledForPZN": isVaultSelectionEnabledForPZN, "vaultSelectionEnabledForWCM": isVaultSelectionEnabledForWCM, "vaultSlots": vaultSlots, "portalContextPath": portalContextPath, "usePresetUrl" : usePresetUrl }; } else if (this._callingEnvId === com.ibm.workplace.wcm.ecm.picker.util.FederatedDocumentsDefinitions._wcm) { // prepare the arguments to initialize the universal federated documents picker // when launched from PZN this._fedDocsPickerArgs = { "callingEnvironment": this._callingEnvId, "customServiceSelectionEnabled": customServiceSelectionEnabled, "documentsServices": federatedDocumentsServices, "feedBaseURL": feedBaseURL, "feedTypeBaseURL": feedTypeBaseURL, "namespace": this._namespace, "nodeTypes": ["repository", "folder", "document"], "onCancelCallbackFn": this._onCancelCallbackFn, "onConfirmCallbackFn": this._onConfirmCallbackFn, "pickerManager": this, "qdsSupportEnabled": isQDSSupportEnabled, "serviceDocBaseURL": serviceDocBaseURL, "vaultMgmtDataSinkUrl": vaultMgmtDataSinkUrl, "vaultSelectionEnabled": isVaultSelectionEnabledForWCM, "vaultSelectionEnabledForPZN": isVaultSelectionEnabledForPZN, "vaultSelectionEnabledForWCM": isVaultSelectionEnabledForWCM, "vaultSlots": vaultSlots, "portalContextPath": portalContextPath, "usePresetUrl" : usePresetUrl }; } if (p_fedDocsPickerArgs && typeof p_fedDocsPickerArgs == 'object') { this._mergeArguments(p_fedDocsPickerArgs, this._fedDocsPickerArgs); } // exit trace if (this._isTracing) { this.trace(m, "Federated documents picker arguments initialized:", this._fedDocsPickerArgs); if(this._fedDocsPickerArgs) { this.trace(m, "this._fedDocsPickerArgs.callingEnvironment", this._fedDocsPickerArgs.callingEnvironment); this.trace(m, "this._fedDocsPickerArgs.customServiceSelectionEnabled", this._fedDocsPickerArgs.customServiceSelectionEnabled); this.trace(m, "this._fedDocsPickerArgs.documentsServices", this._fedDocsPickerArgs.documentsServices); this.trace(m, "this._fedDocsPickerArgs.feedBaseURL",this._fedDocsPickerArgs.feedBaseURL); this.trace(m, "this._fedDocsPickerArgs.feedTypeBaseURL", this._fedDocsPickerArgs.feedTypeBaseURL); this.trace(m, "this._fedDocsPickerArgs.namespace", this._fedDocsPickerArgs.namespace); this.trace(m, "this._fedDocsPickerArgs.nodeTypes", dojo.toJson(this._fedDocsPickerArgs.nodeTypes)); this.trace(m, "this._fedDocsPickerArgs.onCancelCallbackFn", this._fedDocsPickerArgs.onCancelCallbackFn); this.trace(m, "this._fedDocsPickerArgs.onConfirmCallbackFn", this._fedDocsPickerArgs.onConfirmCallbackFn); this.trace(m, "this._fedDocsPickerArgs.pickerManager", this._fedDocsPickerArgs.pickerManager); this.trace(m, "this._fedDocsPickerArgs.qdsSupportEnabled", this._fedDocsPickerArgs.qdsSupportEnabled); this.trace(m, "this._fedDocsPickerArgs.serviceDocBaseURL", this._fedDocsPickerArgs.serviceDocBaseURL); this.trace(m, "this._fedDocsPickerArgs.vaultMgmtDataSinkUrl", this._fedDocsPickerArgs.vaultMgmtDataSinkUrl); this.trace(m, "this._fedDocsPickerArgs.vaultSelectionEnabled", this._fedDocsPickerArgs.vaultSelectionEnabled); this.trace(m, "this._fedDocsPickerArgs.vaultSelectionEnabledForPZN", this._fedDocsPickerArgs.vaultSelectionEnabledForPZN); this.trace(m, "this._fedDocsPickerArgs.vaultSelectionEnabledForWCM", this._fedDocsPickerArgs.vaultSelectionEnabledForWCM); this.trace(m, "this._fedDocsPickerArgs.vaultSlots", this._fedDocsPickerArgs.vaultSlots); this.trace(m, "this._fedDocsPickerArgs.portalContextPath", this._fedDocsPickerArgs.portalContextPath); this.trace(m, "this._fedDocsPickerArgs.usePresetUrl", this._fedDocsPickerArgs.usePresetUrl); } this.traceExit(m); } }, _mergeArguments: function(/*Object*/ p_sourceArgs, /*Object*/ p_targetArgs) { // summary: // Merges the properties from the given source into the target; overwrites properties from // the target if they have the same name in the given source // p_sourceArgs: Object // JSON object holding the properties to merge into the given targets // p_targetArgs: Object // JSON object that serves as the target of the merge operation // tags: // private // entry trace var m = "_mergeArguments(p_sourceArgs, p_targetArgs)"; if (this._isTracing) { this.traceEntry(m, [ p_sourceArgs, p_targetArgs ]); } for (var propertyName in p_sourceArgs) { // add properties from the source and overwrite properties by the same name on the target p_targetArgs[propertyName] = p_sourceArgs[propertyName]; } // exit trace if (this._isTracing) { this.trace(m, "New set of target arguments:", p_targetArgs); this.traceExit(m); } } }); }