AddFolder Command

The AddFolder command launches the FileNet Workplace Add Folder Wizard, which enables a user to add a folder to a specified object store. The client application must use the IAddFolderCmd interface to specify the folder to add. Once the user has completed the AddFolder operation, an IObjectStoreItem interface is returned which may be queried to obtain a pointer to the added folder.

After the AddFolder command has been executed by calling IAppIntCmd::Invoke, an AddFolder response component is returned. Client applications may interact with the Response component via the standard IAppIntRsp and custom IAddFolderRsp interfaces. For more information about working with command and response components and their COM interfaces, see Command and Response components.

Reference

DLL FnAppIntAddFolderCmd.dll
See Also Add command

Interfaces

The AddFolder command uses the following interfaces:

Interface Description
IAddFolderCmd

This is a custom interface used to initialize the data contained in the AddFolder command component. The client application can use the method in this interface to customize the dialog title, identify the folder to add and the parent folder, define XML properties and class behavior for the added folder, and specify which object store to contain the folder.

IAddFolderRsp

This is a custom interface for the AddFolder response component that is returned when the AddFolder command is executed. This interface enables the client application to obtain information about the folder that was added to the object store.

IAppIntCmd

This is a standard interface which is automatically used by the AddFolder command to invoke the AddFolder command component. The client application executes the AddFolder command by calling this interface and passing the AppIntSession component on which the AddFolder command component is invoked. Each time the command is executed, an AddFolder response component is returned.

IAppIntRsp

This is a standard interface that is automatically used by the AddFolder command to determine the success or failure of the command, as well as retrieve any error code or messages.

Example

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\FnAppIntAddFolderCmd.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 AddFolder command component IAddFolderCmdPtr spIAddFolderCmd;
hResult = spIAddFolderCmd.CreateInstance(__uuidof(AddFolderCmd));
if (FAILED(hResult)) {
std::cout << "Could not create the AddFolder command component.\n"; _ASSERTE(0);
} // Define the XML properties for the folder to Add std::cout << "Defining the XML folder properties..." << std::endl; _bstr_t bstrPropertiesXml = _T( "" ); bstrPropertiesXml += _T("<properties>");
bstrPropertiesXml += _T("<property>");
bstrPropertiesXml += _T("<symname>Name</symname>"); bstrPropertiesXml += _T("<values>");
bstrPropertiesXml += _T("<value>Newly Added Folder</value></values>");
bstrPropertiesXml += _T("</property>");
bstrPropertiesXml += _T("<property>");
bstrPropertiesXml += _T("<symname>CommentReq</symname>"); bstrPropertiesXml += _T("<values>");
bstrPropertiesXml += _T("<value>This folder contains new information to be added.</value></values>");
bstrPropertiesXml += _T("</property>");
bstrPropertiesXml += _T("<property>");
bstrPropertiesXml += _T("<symname>SVCPStr</symname>"); bstrPropertiesXml += _T("<values>");
bstrPropertiesXml += _T("<value>This is the SVCPStr property</value></values>");
bstrPropertiesXml += _T("</property>");
bstrPropertiesXml += _T("</properties>");
// Initialize the custom AddFolder command component with the dialog title, // parent folder dislpay name and ID, object store, // as well as the XML properties and class behavior for the folder. _bstr_t bstrDialogTitle = (_T("Customized AddFolder Operation")); _bstr_t bstrRootFolderClass = (_T("{379B665E-1BBA-4BEA-AA4A-BE678369F2CC}")); VARIANT_BOOL bRestrictClass = VARIANT_TRUE; _bstr_t bstrObjectStoreName = (_T("Alaska")); _bstr_t bstrParentFolderDisplayName = (_T("Parent Folder Name")); _bstr_t bstrParentFolderID = (_T("01928938")); std::cout << "Initializing the AddFolder command component..." << std::endl; spIAddFolderCmd->Initialize(bstrDialogTitle, bstrRootFolderClass, bRestrictClass, bstrPropertiesXml, bstrObjectStoreName, bstrParentFolderDisplayName, bstrParentFolderID); // Execute the AddFolder command and capture the response component std::cout << "Executing the AddFolder command..." << std::endl; IAppIntCmdPtr spIAppIntCmd(spIAddFolderCmd);
IAppIntRspPtr spIAppIntRsp = spIAppIntCmd->Invoke(spIAppIntSession); // Determine if the command failed, before accessing response component data hResult = spIAppIntRsp->GetHResult(); if (FAILED(hResult)) { std::cout << "The AddFolder 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 AddFolder 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 AddFolderRsp component IAddFolderRspPtr spIAddFolderRsp(spIAppIntRsp);
_ASSERTE(spIAddFolderRsp != 0);
IObjectStoreItemPtr spIObjectStoreFolderAdded = spIAddFolderRsp->GetObjectStoreItem();
_ASSERTE(spIObjectStoreFolderAdded != 0);
std::cout << "ObjectStoreName=" << (LPCSTR) spIObjectStoreFolderAdded->GetObjectStoreName() << std::endl;
std::cout << "ItemType=" << (LPCSTR) CItemTypeConverter::EnumToBSTR(spIObjectStoreFolderAdded->GetItemType()) << std::endl;
std::cout << "VersionSeriesID=" << (LPCSTR) spIObjectStoreFolderAdded->GetVersionSeriesID() << std::endl;
std::cout << "VersionID=" << (LPCSTR) spIObjectStoreFolderAdded->GetVersionID() << std::endl; } } catch(...) { }