/*
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("");
v_aBusRequest.push(
'- ' +
'/catalog/catalogFolder[@name="User Interface Profiles"]/catalogFolder[@name="Report Studio Profiles"]/userInterfaceProfile' +
'' +
'
- defaultName
' +
' - storeID
' +
' - permissions
' +
'' +
' ' +
'- ' +
'/catalog/catalogFolder[@name="User Interface Profiles"]/catalogFolder[@name="Cognos Workspace Do More Profiles"]/userInterfaceProfile' +
'' +
'
- defaultName
' +
' - storeID
' +
' - permissions
' +
'' +
' '
);
v_aBusRequest.push("");
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 =
'' +
'' +
'- ' +
'' +
'storeID("' + this.m_sStoreID + '")' +
'' +
'' +
'' + v_sBase64Doc + '' +
'' +
'' +
'application/xml' +
'' +
'
' +
'' +
'' +
'' +
'';
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( '' +
'storeID("' + v_sStoreID + '")' +
'' +
'- data
' +
'' +
'' +
'';
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;
};