The Add command launches the FileNet Workplace Add Wizard, which enables a user to add a specified file on their local machine to an object store. The client application must use the IAddCmd interface to specify the item to add and to initialize the Add command. Once the user has completed the Add operation, an IObjectStoreItem interface is returned which may be queried to obtain a pointer to the added item. The client is responsible for deleting the local file, if desired.
After the Add command has been executed by calling IAppIntCmd::Invoke, an Add response component is returned. Client applications may interact with the Response component via the standard IAppIntRsp and custom IAddRsp interfaces. For more information about working with command and response components and their COM interfaces, see Command and Response components.
DLL | FnAppIntAddCmd.dll |
See Also | AddFolder and AddViaTemplate commands |
The Add command uses the following interfaces:
Interface | Description |
---|---|
IAddCmd |
This is a custom interface used to initialize the data contained in the Add command component. The client application can use the methods in this interface to customize the dialog title, identify the item to add, define XML properties for the added item, and specify the link relationship to establish between the added item and other items already in the object store. When Records Manager is enabled for the Application Engine, this method can also be used to specify whether the Declare Record operation should be made available for the specified object store. |
IAddRsp |
This is a custom interface for the Add response component that is returned when the Add command is executed. This interface enables the client application to obtain information about the item that was added to the object store. |
IAppIntCmd |
This is a standard interface which is automatically used by the Add command to invoke the Add command component. The client application executes the Add command by calling this interface and passing the AppIntSession component on which the Add command component is invoked. Each time the command is executed, an Add response component is returned. |
IAppIntRsp |
This is a standard interface that is automatically used by the Add 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\Apppnt\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\FnAppIntAddCmd.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 Add command component IAddCmdPtr spIAddCmd;
hResult = spIAddCmd.CreateInstance(__uuidof(AddCmd));
if (FAILED(hResult)) {
std::cout << "Could not create the Add command component.\n"; _ASSERTE(0);
} // Create the LinkDescriptors for the item to Add const DWORD cNumElements = 2; long lCount = 0; COleSafeArray saLinks(VT_DISPATCH, cNumElements); { // Instantiate a LinkDescriptor component
ILinkDescriptorPtr spILinkDescriptor0(__uuidof(LinkDescriptor)); _ASSERTE(spILinkDescriptor != 0); // Instantiate the ObjectStoreItem component IObjectStoreItemPtr spIObjectStoreItem0; hResult = spIObjectStoreItem0.CreateInstance(__uuidof(ObjectStoreItem));
if (FAILED(hResult)) {
std::cout << "Could not create the ObjectStoreItem component.\n"; _ASSERTE(0);
} // Initialize the ObjectStoreItem component with // the items' type, name, version series ID and version ID. ItemType eItemType = eItemTypeDocument; _bstr_t bstrObjectStoreName = (_T("Alaska")); _bstr_t bstrVersionSeriesID = (_T("{6BC064A2-2D58-4B0A-AEF2-B2F8A1100000}")); _bstr_t bstrVersionID = (_T("{DDE54469-36D9-4fe9-8676-445E4994DE1F}")); std::cout << "Initializing the ObjectStoreItem component..." << std::endl;
spIObjectStoreItem0->Initialize(eItemType, bstrObjectStoreName, bstrVersionSeriesID, bstrVersionID); _bstr_t bstrLinkClassID = (_T("{C91111A9-CE9C-43e6-8548-8A08F43F9726}")); RelationshipType enLinkType = eTypeLinkTo; // Define the XML properties for the item to Link std::cout << "Defining the XML item properties..." << std::endl; _bstr_t bstrLinkPropertiesXml = _T( "" ); bstrLinkPropertiesXml += _T("<properties>");
bstrLinkPropertiesXml += _T("<property>");
bstrLinkPropertiesXml += _T("<symname>DocumentTitle</symname>"); bstrLinkPropertiesXml += _T("<values>");
bstrLinkPropertiesXml += _T("<value>LinkedDocument.doc</value></values>");
bstrLinkPropertiesXml += _T("</property>");
bstrLinkPropertiesXml += _T("<property>");
bstrLinkPropertiesXml += _T("<symname>CommentReq</symname>"); bstrLinkPropertiesXml += _T("<values>");
bstrLinkPropertiesXml += _T("<value>This will be a linked document.</value></values>");
bstrLinkPropertiesXml += _T("</property>");
bstrLinkPropertiesXml += _T("<property>");
bstrLinkPropertiesXml += _T("<symname>SVCPStr</symname>"); bstrLinkPropertiesXml += _T("<values>");
bstrLinkPropertiesXml += _T("<value>This is the SVCPStr property</value></values>");
bstrLinkPropertiesXml += _T("</property>");
bstrLinkPropertiesXml += _T("</properties>");
// Initialize the LinkDescriptor component to hold the link std::cout << "Initializing LinkDescriptor component 1..." << std::endl; spILinkDescriptor0->Initialize(spIObjectStoreItem0, bstrLinkClassID, enLinkType, bstrLinkPropertiesXml); if(spILinkDescriptor0) { saLinks.PutElement(&lCount, spILinkDescriptor0); } } { lCount++; // Instantiate a LinkDescriptor component
ILinkDescriptorPtr spILinkDescriptor1(__uuidof(LinkDescriptor)); _ASSERTE(spILinkDescriptor != 0); // Instantiate the ObjectStoreItem component IObjectStoreItemPtr spIObjectStoreItem1; hResult = spIObjectStoreItem1.CreateInstance(__uuidof(ObjectStoreItem));
if (FAILED(hResult)) {
std::cout << "Could not create the ObjectStoreItem component.\n"; _ASSERTE(0);
} // Initialize the ObjectStoreItem component with // the items' type, name, version series ID and version ID. ItemType eItemType = eItemTypeDocument; _bstr_t bstrObjectStoreName = (_T("Alaska")); _bstr_t bstrVersionSeriesID = (_T("{2400406D-68FE-4d5c-81FD-AC01F7186119}")); _bstr_t bstrVersionID = (_T("{6D770D89-497C-40be-B300-E646FC12DE8A}")); std::cout << "Initializing the ObjectStoreItem component..." << std::endl;
spIObjectStoreItem1->Initialize(eItemType, bstrObjectStoreName, bstrVersionSeriesID, bstrVersionID); _bstr_t bstrLinkClassID = (_T("{C91111A9-CE9C-43e6-8548-8A08F43F9726}")); RelationshipType enLinkType = eTypeLinkTo; // No XML properties for this Link item _bstr_t bstrLinkPropertiesXml = VT_EMPTY; // Initialize the LinkDescriptor component to hold the link std::cout << "Initializing LinkDescriptor component 2..." << std::endl; spILinkDescriptor1->Initialize(spIObjectStoreItem1, bstrLinkClassID, enLinkType, bstrLinkPropertiesXml); if(spILinkDescriptor1) { saLinks.PutElement(&lCount, spILinkDescriptor1); } } _variant_t vLinkDescriptors(saLinks); // Define the XML properties for the item to Add std::cout << "Defining the XML item properties..." << std::endl; _bstr_t bstrPropertiesXml = _T( "" ); bstrPropertiesXml += _T("<properties>");
bstrPropertiesXml += _T("<property>");
bstrPropertiesXml += _T("<symname>DocumentTitle</symname>"); bstrPropertiesXml += _T("<values>");
bstrPropertiesXml += _T("<value>AddedDocument.doc</value></values>");
bstrPropertiesXml += _T("</property>");
bstrPropertiesXml += _T("<property>");
bstrPropertiesXml += _T("<symname>CommentReq</symname>"); bstrPropertiesXml += _T("<values>");
bstrPropertiesXml += _T("<value>This document 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 Add command component with the dialog title, // name and directory location of the file on the local machine, // a specific root document class ID, the class ID choice restriction, // as well as the XML properties and LinkDescriptors. _bstr_t bstrDialogTitle = (_T("Customized Add Operation")); _bstr_t bstrPathName = (_T("C:\Temp\DocumentToBeAdded.doc")); _bstr_t bstrRootDocClass = (_T("{379B665E-1BBA-4BEA-AA4A-BE678369F2CC}")); VARIANT_BOOL bRestrictClass = VARIANT_TRUE; VARIANT_BOOL bDeclareRecordOn = VARIANT_FALSE; _variant_t vDocumentIDs(); std::cout << "Initializing the Add command component..." << std::endl; spIAddCmd->Initialize(bstrDialogTitle, bstrPathName, bstrRootDocClass, bRestrictClass, bstrPropertiesXml, vLinkDescriptors, bDeclareRecordOn, vDocumentIDs);
// Execute the Add command and capture the response component std::cout << "Executing the Add command..." << std::endl; IAppIntCmdPtr spIAppIntCmd(spIAddCmd);
IAppIntRspPtr spIAppIntRsp = spIAppIntCmd->Invoke(spIAppIntSession); // Determine if the command failed, before accessing response component data hResult = spIAppIntRsp->GetHResult(); if (FAILED(hResult)) { std::cout << "The Add 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 Add 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 AddRsp component IAddRspPtr spIAddRsp(spIAppIntRsp);
_ASSERTE(spIAddRsp != 0);
IObjectStoreItemPtr spIObjectStoreItemAdded = spIAddRsp->GetObjectStoreItem();
_ASSERTE(spIObjectStoreItemAdded != 0);
std::cout << "ObjectStoreName=" << (LPCSTR) spIObjectStoreItemAdded->GetObjectStoreName() << std::endl;
std::cout << "ItemType=" << (LPCSTR) CItemTypeConverter::EnumToBSTR(spIObjectStoreItemAdded->GetItemType()) << std::endl;
std::cout << "VersionSeriesID=" << (LPCSTR) spIObjectStoreItemAdded->GetVersionSeriesID() << std::endl;
std::cout << "VersionID=" << (LPCSTR) spIObjectStoreItemAdded->GetVersionID() << std::endl; } } catch(...) { }