123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- /*
- IBM Confidential
- OCO Source Materials
- IBM Cognos Products: uipe
- (C) Copyright IBM Corp. 2014
- The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office.
- */
- /**
- * Query the name and store id of all the UI Profiles in CM
- *
- * @constructor
- * @extends C_BusRequest
- * @param {I_RequestListener} v_oListener The listener for this request. If null, then no events will be fired.
- */
- function C_UIProfileQueryRequest( v_oListener )
- {
- var v_aBusRequest = [];
- v_aBusRequest.push("<bus:query><requests>");
- v_aBusRequest.push(
- '<item xsi:type="bus:queryRequest">' +
- '<search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">/catalog/catalogFolder[@name="User Interface Profiles"]/catalogFolder[@name="Report Studio Profiles"]/userInterfaceProfile</search>' +
- '<properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SOAP-ENC:Array" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENC:arrayType="bus:propEnum[3]">' +
- ' <item xsi:type="bus:propEnum">defaultName</item>' +
- ' <item xsi:type="bus:propEnum">storeID</item>' +
- ' <item xsi:type="bus:propEnum">permissions</item>' +
- '</properties>' +
- '</item>' +
- '<item xsi:type="bus:queryRequest">' +
- '<search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">/catalog/catalogFolder[@name="User Interface Profiles"]/catalogFolder[@name="Cognos Workspace Do More Profiles"]/userInterfaceProfile</search>' +
- '<properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SOAP-ENC:Array" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENC:arrayType="bus:propEnum[3]">' +
- ' <item xsi:type="bus:propEnum">defaultName</item>' +
- ' <item xsi:type="bus:propEnum">storeID</item>' +
- ' <item xsi:type="bus:propEnum">permissions</item>' +
- '</properties>' +
- '</item>'
- );
-
- v_aBusRequest.push("</requests></bus:query>");
- this.F_ConstructBaseClass( v_oListener, C_BusRequest.K_sSOAPAction_contentManagerService, v_aBusRequest.join("") );
- };
- C_UIProfileQueryRequest.F_Extends( C_BusRequest );
- C_UIProfileQueryRequest.prototype.F_ProcessResponse = function()
- {
- this.m_oNameMap = {};
-
- C_UIProfileQueryRequest.superClass.F_ProcessResponse.call( this );
- var v_docSoapResponse = this.F_GetResponse();
- if ( !v_docSoapResponse )
- {
- return;
- }
- var v_nlProfiles = v_docSoapResponse.selectNodes( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/returns/item/queryResult/item" );
- if (v_nlProfiles.length == 0)
- {
- this.F_SetNewErrorRes( "IDS_BAD_PROFILES_RESPONSE", v_docSoapResponse.xml );
- return;
- }
-
- for( var i = 0; i < v_nlProfiles.length; i++ )
- {
- var v_nItem = v_nlProfiles.item( i );
- var v_sProfileName = v_nItem.selectSingleNode( "defaultName/value" ) ? v_nItem.selectSingleNode( "defaultName/value" ).text : "";
- var v_sStoreID = v_nItem.selectSingleNode( "storeID/value" ) ? v_nItem.selectSingleNode( "storeID/value" ).text : "";
-
- if ( v_sProfileName && v_sStoreID )
- {
- this.m_oNameMap[v_sProfileName] = v_sStoreID;
- }
- }
- };
- C_UIProfileQueryRequest.prototype.F_GetNameMap = function( )
- {
- return this.m_oNameMap;
- };
- /**
- * Save the UI Profile to CM
- *
- * @constructor
- * @extends C_BusRequest
- * @param {I_RequestListener} v_oListener The listener for this request. If null, then no events will be fired.
- */
- function C_UIProfileSaveRequest( v_oListener, v_sStoreID, v_nProfile, v_bReloadUI )
- {
- this.m_sStoreID = v_sStoreID;
- this.m_nProfile = v_nProfile;
- this.m_bReloadUI = v_bReloadUI;
- var v_sXML = this.f_applyNameSpace( this.m_nProfile.xml );
- var v_oBase64Encode = new C_Base64Codec();
- var v_sBase64Doc = v_oBase64Encode.F_Encode( v_sXML );
- var v_sBusRequest =
- '<bus:update>' +
- '<objects xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:baseClass[1]">' +
- '<item xsi:type="bus:userInterfaceProfile">' +
- '<searchPath xsi:type="bus:stringProp">' +
- '<value xsi:type="xsd:string">storeID("' + this.m_sStoreID + '")</value>' +
- '</searchPath>' +
- '<data xsi:type="bus:base64BinaryMIMEProp">' +
- '<value xsi:type="xsd:base64Binary">' + v_sBase64Doc + '</value>' +
- '</data>' +
- '<dataType xsi:type="cm:stringProp">' +
- '<value xsi:type="xsd:string" xml:space="preserve">application/xml</value>' +
- '</dataType>' +
- '</item>' +
- '</objects>' +
- '<options xsi:type="bus:updateOptions">' +
-
- '</options>' +
- '</bus:update>';
-
- this.F_ConstructBaseClass( v_oListener, C_BusRequest.K_sSOAPAction_contentManagerService, v_sBusRequest );
- };
- C_UIProfileSaveRequest.F_Extends( C_BusRequest );
- C_UIProfileSaveRequest.prototype.f_applyNameSpace = function( s )
- {
- return s.replace( '<RSProfile', '<RSProfile xmlns="' + G_UIPE.M_sProfileVersion + '"' );
- };
- C_UIProfileSaveRequest.prototype.F_ProcessResponse = function()
- {
-
- };
- C_UIProfileSaveRequest.prototype.F_GetProfile = function()
- {
- return this.m_nProfile;
- };
- C_UIProfileSaveRequest.prototype.F_IsReloadUI = function()
- {
- return this.m_bReloadUI;
- };
- /**
- * Load the UI Profile from CM
- *
- * @constructor
- * @extends C_BusRequest
- * @param {I_RequestListener} v_oListener The listener for this request. If null, then no events will be fired.
- */
- function C_UIProfileLoadRequest( v_oListener, v_sStoreID )
- {
- var v_sBusRequest =
- '<bus:query><requests>' +
- '<item xsi:type="bus:queryRequest">' +
- '<search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">storeID("' + v_sStoreID + '")</search>' +
- '<properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SOAP-ENC:Array" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENC:arrayType="bus:propEnum[3]">' +
- '<item xsi:type="bus:propEnum">data</item>' +
- '</properties>' +
- '</item>' +
- '</requests></bus:query>';
- this.F_ConstructBaseClass( v_oListener, C_BusRequest.K_sSOAPAction_contentManagerService, v_sBusRequest );
- };
- C_UIProfileLoadRequest.F_Extends( C_BusRequest );
- C_UIProfileLoadRequest.prototype.F_ProcessResponse = function()
- {
- C_UIProfileLoadRequest.superClass.F_ProcessResponse.call( this );
- var v_docSoapResponse = this.F_GetResponse();
- if ( !v_docSoapResponse )
- {
- return;
- }
- var v_nlProfiles = v_docSoapResponse.selectNodes( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/returns/item/queryResult/item" );
- if (v_nlProfiles.length == 0)
- {
- this.F_SetNewErrorRes( "IDS_BAD_PROFILES_RESPONSE", v_docSoapResponse.xml );
- return;
- }
-
- var v_nItem = v_nlProfiles.item( 0 );
- var v_sProfileData = v_nItem.selectSingleNode( "data/value" ) ? v_nItem.selectSingleNode( "data/value" ).text : "";
-
- var v_oBase64Codec = new C_Base64Codec();
- var v_sProfile = v_oBase64Codec.F_Decode( v_sProfileData );
- // remove any namespace for now
- var re = /\s+xmlns\s*=\s*["'](.+?)["']/;
- if (v_sProfile.search(re) == -1)
- {
- alert('Profile is missing the xmlns attribute.');
- }
- else
- {
- var v_sVersion = RegExp.$1;
- if ( v_sVersion == G_UIPE.M_sProfileVersion )
- {
- var v_docProfile = U_XML.F_LoadString( null, G_UIPE.F_GetInlineProfileDTD() + v_sProfile.replace(re, "") );
- if ( v_docProfile )
- {
- this.m_docUIProfile = v_docProfile;
- }
- else
- {
- alert("Profile does not pass profile DTD validation.");
- window.close();
- }
- }
- else
- {
- alert('Profile has xmlns of "' + v_sVersion + '" expected "' + G_UIPE.M_sProfileVersion + '"');
- }
- }
- };
- C_UIProfileLoadRequest.prototype.F_GetUIProfile = function( )
- {
- return this.m_docUIProfile ? this.m_docUIProfile.documentElement : null;
- };
|