The GetPreferences command silently retrieves the site, user, or bootstrap preferences from the Workplace Application Server. The client application must use the IGetPreferencesCmd interface to specify the type of preferences to retrieve.
After the GetPreferences command has been executed by calling IAppIntCmd::Invoke, a GetPreferences response component is returned. Client applications may interact with the response component via the standard IAppIntRsp and custom IGetPreferencesRsp interfaces. For more information about working with command and response components and their COM interfaces, see Command and Response components.
DLL | FnAppIntGetPreferencesCmd.dll |
See Also | None |
The GetPreferences command uses the following interfaces:
Interface | Description |
---|---|
IGetPreferencesCmd |
This is a custom interface used to initialize the data contained in the GetPreferences command component. The client application can use this interface to specify the type of preferences to retrieve: site, user, or bootstrap. |
IGetPreferencesRsp |
This is a custom interface for the GetPreferences response component that is returned when the GetPreferences command is executed. This interface enables the client application to obtain the retrieved XML preferences, including using XPath syntax to locate a specific site preference. |
IAppIntCmd |
This is a standard interface which is automatically used by the GetPreferences command to invoke the GetPreferences command component. The client application executes the GetPreferences command by calling this interface and passing the AppIntSession component on which the GetPreferences command component is invoked. Each time the command is executed, an GetPreferences response component is returned. |
IAppIntRsp |
This is a standard interface that is automatically used by the GetPreferences command to determine the success or failure of the command, as well as retrieve any error code or messages. |
In the application's StdAfx.h header file:
#import"C:\Program Files\FileNet\AppInt\FnAppIntCmd.tlb" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntHttpRequest.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntBrowserDlg.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntHttpConnection.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntResources.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntClientRecordBase.tlb" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntClientStore.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntSession.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntSessionLogin.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntCmdComponents.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntGetPreferencesCmd.dll" named_guids no_namespace
In the application's primary .cpp source file:
// Instantiate the StdSessionLogin component
IStdSessionLoginPtr spIStdSessionLogin;
HRESULT hResult = spIStdSessionLogin.CreateInstance(__uuidof(StdSessionLogin));
if (FAILED(hResult)) { std::cout << "Could not create the StdSessionLogin component." << std::endl; _ASSERTE(0); } try {
// Initialize the StdSessionLogin component to create // a separate, non-unified login for the client application // by specifying the session / client application name. std::cout << "Initializing the StdSessionLogin component to use NON-unified login..." << std::endl; _bstr_t sessionName(_T("WordPerfect")); spIStdSessionLogin->InitializeViaSessionName(sessionName);
// Instantiate the AppIntSession component
IAppIntSessionPtr spIAppIntSession;
hResult = spIAppIntSession.CreateInstance(__uuidof(AppIntSession)); if (FAILED(hResult)) { std::cout << "Could not create the AppIntSession component." << std::endl; _ASSERTE(0); } // Initialize the AppIntSession component with the StdSessionLogin component
std::cout << "Initializing the AppIntSession component..." << std::endl;
spIAppIntSession->Initialize(spIStdSessionLogin); // * The Client Application may invoke a SessionLogin here; otherwise, // * it will automatically be invoked as needed when commands are executed. std::cout << "Checking Login Status..." << std::endl; VARIANT_BOOL bIsLoggedIn = spIAppIntSession->IsLoggedIn(); if (bIsLoggedIn == VARIANT_TRUE) { std::cout << "User is currently Logged In." << std::endl; } else {
std::cout << "User is NOT currently Logged In." << std::endl;
std::cout << "Attempting Login..." << std::endl;
hResult = spIAppIntSession->Login(); if (FAILED(hResult)) { std::cout << "Login failed." << std::endl; _ASSERTE(0); }
std::cout << "Login succeeded." << std::endl; } // Instantiate the custom GetPreferences command component IGetPreferencesCmdPtr spIGetPreferencesCmd;
hResult = spIGetPreferencesCmd.CreateInstance(__uuidof(GetPreferencesCmd));
if (FAILED(hResult)) {
std::cout << "Could not create the GetPreferences command component.\n"; _ASSERTE(0);
} // Initialize the custom GetPreferences command component // with the type of preferences to retrieve. PreferencesType enPrefType = ePreferencesTypeBootstrap; std::cout << "Initializing the GetPreferences command component..." << std::endl; spIGetPreferencesCmd->Initialize(enPrefType); // Execute the GetPreferences command and capture the response component std::cout << "Executing the GetPreferences command..." << std::endl; IAppIntCmdPtr spIAppIntCmd(spIGetPreferencesCmd);
IAppIntRspPtr spIAppIntRsp = spIAppIntCmd->Invoke(spIAppIntSession);// Determine if the command failed, before accessing response component data hResult = spIAppIntRsp->GetHResult(); if (FAILED(hResult)) { std::cout << "The GetPreferences command failed to execute." << std::endl; // Examine the error information provided in the standard response component _bstr_t bstrErrorName = spIAppIntRsp->GetErrorName(); std::cout << "ErrorName=" << ( bstrErrorName.length() ? (LPCSTR) bstrErrorName : _T( "" ) ) << std::endl; _bstr_t bstrErrorMsg = spIAppIntRsp->GetErrorMsg(); std::cout << "ErrorMsg=" << ( bstrErrorMsg.length() ? (LPCSTR) bstrErrorMsg : _T( "" ) ) << std::endl; _bstr_t bstrErrorDetails = spIAppIntRsp->GetErrorDetails(); std::cout << "ErrorDetails=" << ( bstrErrorDetails.length() ? (LPCSTR) bstrErrorDetails : _T( "" ) ) << std::endl; _ASSERTE(0); } else { std::cout << "The GetPreferences command succeeded." << std::endl; // Obtain the response name and description from the standard response component _bstr_t bstrResponseDescription = spIAppIntRsp->GetDescription(); std::cout << "ResponseDescription=" << ( bstrResponseDescription.length() ? (LPCSTR) bstrResponseDescription : _T( "" ) ) << std::endl; _bstr_t bstrResponseName = spIAppIntRsp->GetName(); std::cout << "ResponseName=" << ( bstrResponseName.length() ? (LPCSTR) bstrResponseName : _T( "" ) ) << std::endl; // Obtain the specific response information contained in the custom GetPreferencesRsp component IGetPreferencesRspPtr spIGetPreferencesRsp(spIAppIntRsp);
_ASSERTE(spIGetPreferencesRsp != 0);
std::cout << "PreferencesXML=" << (LPCSTR) spIGetPreferencesRsp->GetPreferencesXML() << std::endl; _bstr_t bstrXPathPreference = (_T("/Document Name")); _bstr_t bstrPreference = spIGetPreferencesRsp->GetPreference(bstrXPathPreference);
std::cout << "DocumentName=" << (LPCSTR) bstrPreference << std::endl; }} catch(...) { }