IBM Content Manager, Version 8.5           

Adding contents to a folder example: C++

To add the contents to a folder:
  1. Create the items that will be added to the folder.
    DKDDO * ddoDocument = dsICM->createDDO("book", DK_CM_DOCUMENT);
    DKDDO * ddoFolder2  = dsICM->createDDO("book", DK_CM_FOLDER);
    DKDDO * ddoItem     = dsICM->createDDO("book", DK_CM_ITEM);
  2. Persist the created items to the datastore.
    ddoDocument->add();
    ddoItem->add();
    ddoFolder2->add();
  3. Get the DKFolder attribute for the folder.
    DKFolder * dkFolder;
    short dataid = ddoFolder->dataId(DK_CM_NAMESPACE_ATTR,DK_CM_DKFOLDER);
    if (dataid!=0) dkFolder = 
      (DKFolder*)(dkCollection*) ddoFolder->getData(dataid);
  4. Check out the folder.
    Important: You do not need to lock an item before updating it if you are only adding or removing links to the item without making any other changes in the DDO. However, if you need to change anything else in the DDO, such as modifying an attribute, you must checkout the item before updating it.
    dsICM->checkOut(ddoFolder); 
  5. Add the created items to the folder.
    dkFolder->addElement(ddoDocument);
    dkFolder->addElement(ddoItem);
    dkFolder->addElement(ddoFolder2); // Folders can contain sub-folders.
  6. Update the folder. This also checks in the folder (unlocks it).
    ddoFolder->update();
  7. Check in the folder.
    dsICM->checkIn(ddoFolder);
    Important: Alternatively, you can combine the checkin request with your update call in Step 6 by using the DK_CM_CHECKIN(DKConstan.h) update option.


Feedback

Last updated: December 2013
dcmcm095.htm

© Copyright IBM Corporation 2013.