DFCOperations Whitepaper
DFCOperations Whitepaper
DFC Operations
Umair Nauman
Date 7/30/2007
Copyright © 2005 EMC Corporation. All rights reserved.
EMC believes the information in this publication is accurate as of its publication date. The information is subject to change without
notice.
THE INFORMATION IN THIS PUBLICATION IS PROVIDED “AS IS.” EMC CORPORATION MAKES NO
REPRESENTATIONS OR WARRANTIES OF ANY KIND WITH RESPECT TO THE INFORMATION IN THIS PUBLICATION,
AND SPECIFICALLY DISCLAIMS IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE.
Use, copying, and distribution of any EMC software described in this publication requires an applicable software license.
EMC2, EMC, and EMC Documentum product names are trademarks of EMC Corporation. All other trademarks used herein are the
property of their respective owners. All other brand names are trademarks or registered trademarks of their respective owners.
DFC Operations 2
Introduction to DFC
DFC is a key part of the Documentum software platform. While the main user of DFC is other
Documentum software, you can use DFC in any of the following ways:
• Access Documentum functionality from within one of your company’s enterprise applications.
For example, your corporate purchasing application can retrieve a contract from your
Documentum system.
• Customize or extend products like Documentum Desktop or Webtop. For example, you can
modify Webtop functionality to implement one of your company’s business rules.
• Write a method or procedure for Content Server to execute as part of a workflow or document
lifecycle.
DFC is Java based. As a result, client programs that are Java based can interface directly with DFC. DFC
provides the Documentum Java-COM bridge (DJCB) to make most DFC interfaces available in Microsoft’s
Component Object Model (COM) environment. The DFC primary interop assembly (PIA) provides access
to DFC from the Microsoft .NET environment. When application developers use DFC, it is usually within
the customization model of a Documentum client, though you can also use DFC to develop the methods
associated with intrinsic Content Server functionality, such as document lifecycles.
For more details about DFC please refer to the DFC User Guide. The rest of this paper will concentrate on
DFC Operations.
Introduction to operations
To manipulate documents in Documentum, you must understand operations. Operations are like the
document carriers you use to put small pieces of paper through the feeder of a copying machine. Operations
provide interfaces and a processing environment to ensure that Documentum can handle a variety of
documents and collections of documents in a standard way. You obtain an operation of the appropriate
kind, place one or more documents into it, and “run it through the machine,” that is, execute the operation.
All of the examples in this chapter pertain only to documents, but operations apply to objects of type
IDfSysObject, not just the subtype IDfDocument. For example, to check out a document, take the following
steps:
Standard Documentum Functionality like a checkin operation requires several API calls in a certain order.
Operations hide this complexity and may execute several API calls in the correct order. The main purpose
of Operations package is to provide a standard framework for processing common repository actions.
Without the facilities provided in the Operation interface, a programmer might accidentally ignore a vital
step for processing certain kinds of documents. By using the Operations interfaces, you ensure that all vital
steps are performed and achieve the greatest level of portability and performance, especially when it
involves compound and XML documents.
DFC Operations 3
The Operations package provides support for any combination of simple documents, Virtual Documents,
XML Documents, compound documents, Assemblies, related documents, and even deep folder contents.
Operations manage compound document linked both in the repository and in the file system. They account
for and manage object relationships. They ensure adherence to client conventions such as the registration of
checked out objects.
Operations provide seamless distributed support. For example, you can set the destination folder of the
IDfCopyOperation to a folder in another repository, and the operation will perform as expected, as long as
the user is authenticated in both repositories.
DFC carries out the behind-the-scenes tasks associated with checking out a document. For a virtual
document, for example, DFC adds all of its components to the operation and ensures that links between
them are still valid when it stores the documents into the checkout directory on the file system. It corrects
filename conflicts, and it keeps a local record of which documents it checks out. This is only a partial
description of what DFC does when you check out a document. Because of the number and complexity of
the underlying tasks, DFC wraps seemingly elementary document-manipulation tasks in operations.
An IDfClientX object provides factory methods for creating operations. Once you have an IDfClientX
object (say cX) and a SysObject (say doc) representing the document,
the code for the checkout looks like this:
In a real application, you would add code to handle a null returned by the add method
or errors produced by the execute method.
Operation – the embodiment of content-centric processing. An operation acts upon one or more nodes
according to specified operational parameters—for the entire operation and/or for a specific node. An
operation executes one or more steps in a specified order.
o Inbound operation – an operation that applies to content entering a Documentum-controlled
repository (e.g. import, checkin)
Node – An Operation “Node” is a “thing” that is operated upon during the operation’s execute() method
and is created at the point of adding an object to the Operation. The node interfaces provide access to the
properties and settings to allow a programmer to parameterize the processing of the same operational steps
to individual nodes. These interfaces allow the node to set properties that are particular to the
corresponding Operation for that node.
DFC Operations 4
A key point to notice is that for each Operation type there is a corresponding Node type. When you add
objects to an operation of one type, the operation generates nodes of its corresponding type. For example,
all of the objects you add to an IDfImportOperation object will ALWAYS generate one or more
IDfImportNode objects. There is no way that the IDfImportOperation.add() method could return any other
type than IDfImportNode (e.g. it will never return IDfExportNode, or IDfDeleteNode).
A node is an abstract representation of a sysobject or a file (i.e. the actionable essence of an operation,
which contains a structure of nodes and descendants). More than one node can point to the same sysobject
or file. For an import operation, node representation corresponds to a file; otherwise, it corresponds to
sysobject.
Each Operation has one or more root nodes. Each node can have zero or more child nodes, and thus an
Operation can incorporate multiple “graphs” of objects. The Operations account for an object appearing
more than once through different paths, for example an object appearing more than once in a Checkin
Operation will only actually check in once.
A single add() can create many Nodes. For example, adding once Virtual Document will create a Node for
each child in the Virtual Document.
Step – a logical unit of execution. An operation is executed as a series of steps, and each step may have a
corresponding node action.
Node action – a logical unit of execution. A node action is independently performed on each node in an
operation. Some steps may not have corresponding node action (e.g. DfPreDelete). In such cases, the step
will go through all the nodes and perform the necessary action.
Populator – mechanism that supports the creation of nodes against which an operation is applied. An
operation contains a structure of nodes and descendants. When you obtain an operation, it has no nodes (i.e.
DFC does not regard the operation itself as a node). When you use an operation’s add method to add
documents (or other content items) to the operation, it creates new root nodes. The add method is basically
the populator for the operation. There are various populators for adding sysobjects, virtual documents, files,
etc. In the current implementation, populators are passive, not active, entities.
Package (and package item) – mechanism that supports more efficient (“one shot” per se) operations by
supplying all the necessary information up front (versus in two phases). For example, prior to the notion of
content packages and content package items, there was no mechanism to specify the attributes that one
would want to set on the newly created object during import operation. As a result, user had to obtain the
newly created object after the import operation had been executed, set the necessary attributes and then
save the object. With content package APIs, one can create an import package (which will result in creation
of import package item(s)) and specify all the attributes information up front. The information is then set on
the newly created object as part of the execution of the import operation.
Content packages have affinity to operations (e.g. IDfImportContentPackage for IDfImportOperation).
Once the content package is created, a file or a sysobject (depending on the type of operation) is then added
to the content package. A corresponding package item is created for the added file or sysobject. One can
then set all the necessary information on the content package and/or content package item(s). Once all the
information is set, content package should be added to the operation. The populator for content package
iterates over all the content package items in the content package and creates node(s) for the corresponding
content package item(s). Operation then executes on the nodes.
DFC Operations 5
o Inbound package – a package entering a Documentum-controlled repository
Edge – an abstract representation that depicts the relationship between two nodes (e.g. in the case of VDM,
an edge corresponds to dmr_containment)
Monitor – mechanism that supports operation progress indication. An operation monitor provides access to
operation errors as they occur and allows for abort/continue decisions in real time.
Types of operations
DFC provides operation types and corresponding nodes (to be explained in subsequent
sections) for many tasks you might wish to perform on documents or, where appropriate,
files or folders. The following table summarizes these.
DFC Operations 6
IDfImportOperation or IDfXMLTransformOperation to set a repository session before adding nodes to
either of these types of operation. No other operation type has a setSession method.
DFC Operations 7
of the corresponding document. IDfOperationNode does not have a method for obtaining the object ID of
the corresponding object. Each operation node type (for example, IDfCheckinNode) has its own
getObjectID method. You must cast the IDfOperationNode object to a node of the specific type before
obtaining the object ID.
You can undo most operations by calling an operation’s abort method. The abort method is specific to each
operation, but generally undoes repository actions and cleans up registry entries and local content files.
Some operations (for example, delete) cannot be undone.
If you know an operation only contains objects from a single repository, and the number of objects being
processed is small enough to ensure sufficient database resources, you can wrap the operation execution in
a session transaction. You can also include operations in session manager transactions. Session manager
transactions can include operations on objects in different repositories, but you must still pay attention to
database resources. Session manager transactions are not completely atomic, because they do not use a two-
phase commit.
Operation Examples
In this section I have listed the source code for various operations as a reference. You can also find these
Operations Samples in the DFC API Docs.
public static void doImport( String srcFileOrDir, String destFolderPath, IDfSession session)
throws DfException {
IDfClientX clientx = new DfClientX();
IDfImportOperation operation = clientx.getImportOperation();
//the Import Opertion requires a session
operation.setSession( session );
DFC Operations 8
}
operation.setDestinationFolderId( folder.getObjectId() );
public static void doCheckout( String strPath, IDfSession session ) throws DfException {
if (sysObj.isCheckedOut() == true) {
System.out.println("Object " + strPath + " is already checked out.");
return;
}
IDfCheckoutNode node;
if( sysObj.isVirtualDocument() ) {
IDfVirtualDocument vDoc = sysObj.asVirtualDocument( "CURRENT", false );
DFC Operations 9
node = (IDfCheckoutNode)operation.add(vDoc);
} else {
node = (IDfCheckoutNode)operation.add(sysObj);
}
Please note that for traversing virtual documents, you must navigate by using a Virtual Document
instance and not the IDfOperation node. Please refer to DFC javadocs for code samples of traversing
Virtual documents.
Operations- Checkin (Java)
Checks in a document, virtual document or XML document using IDfCheckinOperation
Notes: Example call: Operations.doCheckin( "/DFCCab/test", session );
public static void doCheckin( String strPath, IDfSession session ) throws DfException {
IDfClientX clientx = new DfClientX();
IDfCheckinOperation operation = clientx.getCheckinOperation();
if (sysObj.isCheckedOut() == false) {
System.out.println("Object " + strPath + " is not checked out.");
return;
}
IDfCheckinNode node;
if( sysObj.isVirtualDocument() ) {
IDfVirtualDocument vDoc = sysObj.asVirtualDocument( "CURRENT", false );
node = (IDfCheckinNode)operation.add(vDoc);
} else {
node = (IDfCheckinNode)operation.add(sysObj);
}
DFC Operations 10
Operations- CancelCheckout (Java)
The execute method of an IDfCancelCheckoutOperation object cancels the checkout of documents by
releasing locks, deleting local files if appropriate, and removing registry entries. This also applies to XML
documents that are Virtual Documents (chunked)
If the operation’s add method receives a virtual document as an argument, it also adds all of the document’s
descendants (determined by applying the applicable binding rules), creating a separate operation node for
each.
public static void doCancelCheckout( String strPath, IDfSession session ) throws DfException {
IDfClientX clientx = new DfClientX();
IDfCancelCheckoutOperation operation = clientx.getCancelCheckoutOperation();
operation.setKeepLocalFile( false );
if (sysObj.isCheckedOut() == false) {
System.out.println("Object " + strPath + " is not checked out.");
return;
}
IDfCancelCheckoutNode node;
if( sysObj.isVirtualDocument() ) {
IDfVirtualDocument vDoc = sysObj.asVirtualDocument( "CURRENT", false );
node = (IDfCancelCheckoutNode)operation.add(vDoc);
} else {
node = (IDfCancelCheckoutNode)operation.add(sysObj);
}
DFC Operations 11
public static void doExport( String strPath, String destDir,
String exportName, String exportFormat, IDfSession session )
throws DfException {
IDfClientX clientx = new DfClientX();
IDfSysObject sysObj = (IDfSysObject) session.getObjectByPath( strPath );
if( sysObj == null ) {
System.out.println("Object " + strPath + " can not be found.");
return;
}
sysObj.setObjectName(exportName);
operation.setDestinationDirectory( destDir );
node.setFormat( exportFormat );
public static void doExportMultipleObjects( String strFolderPath, String destDir, IDfSession session )
throws DfException {
IDfClientX clientx = new DfClientX();
IDfFolder folder = null;
folder = session.getFolderByPath( strFolderPath );
if( folder == null ) {
System.out.println("Folder or cabinet " + strFolderPath + " does not exist in the Docbase!");
return;
}
IDfExportOperation operation = clientx.getExportOperation();
operation.setDestinationDirectory( destDir );
DFC Operations 12
q.setDQL(qualification); //Give it the query
col = q.execute(session, IDfQuery.DF_READ_QUERY); //Execute synchronously
while (col.next()) {
String name = col.getString("object_name");
IDfFile destFile = clientx.getFile( destDir + name );
//check if the file has been exported (exists) to avoid another export
if (! destFile.exists()){
//Create an IDfSysObject representing the object in the collection
String id = col.getString("r_object_id");
IDfId idObj = clientx.getId(id);
IDfSysObject myObj = (IDfSysObject) session.getObject(idObj);
// add the IDfSysObject to the operation
IDfExportNode node = (IDfExportNode)operation.add(myObj);
}
}
System.out.println("The objects in " + strFolderPath + " have been exported to " + destDir);
}
finally {
if (col!= null)
col.close();
}
}
public static void doCopy( String strSourcePath, String strDestFolderPath, IDfSession session )
throws DfException {
IDfClientX clientx = new DfClientX();
IDfSysObject sysObj = (IDfSysObject) session.getObjectByPath( strSourcePath );
if( sysObj == null ) {
System.out.println("Source object " + strSourcePath + " can not be found.");
return;
}
DFC Operations 13
System.out.println("Destination folder or cabinet " + strDestFolderPath + " does not exist in the Docbase!");
return;
}
//obtain an IDfCopyOperation and set parameters
IDfCopyOperation operation = clientx.getCopyOperation();
operation.setDestinationFolderId( destFolder.getObjectId() );
operation.setDeepFolders( true );
Notes: Must pass in the source folder (strSourceFolder), source object(s) (strSourceObject) and the
destination folder (strDestFolder). To move a folder, set strSourceObject to the folder and strSourceFolder
to the folder's parent. If a folder is passed into this method (as strSourceObject), any subfolders will also be
moved.
public static void doMove( String strSourceFolder, String strSourceObject, String strDestFolder, IDfSession session )
throws DfException {
IDfClientX clientx = new DfClientX();
DFC Operations 14
System.out.println("Source object " + strSourceObject + " can not be found.");
return;
}
if( sysObj.isVirtualDocument() ) {
DFC Operations 15
IDfVirtualDocument vDoc = sysObj.asVirtualDocument( "CURRENT", false );
IDfDeleteNode node = (IDfDeleteNode)operation.add(vDoc);
} else {
IDfDeleteNode node = (IDfDeleteNode)operation.add(sysObj);
}
Operations- Validate
public static void doValidationFromDocbase( String strObject , String tempDir, IDfSession session )
throws DfException {
IDfClientX clientx = new DfClientX();
Use the object’s setSession method to specify a repository session and the object’s setDestinationFolderId
method to specify the repository cabinet or folder into which the operation should import documents. You
must set the session before adding files to the operation. You can set the destination folder, either on the
operation or on each node. The node setting overrides the operation setting. If you set neither, DFC uses its
default destination folder. You can add an IDfFile object or specify a file system path. You can also specify
whether to keep the file on the file system (the default choice) or delete it after the operation is successful.
If you add a file system directory to the operation, DFC imports all files in that directory and proceeds
recursively to add each subdirectory to the operation. The resulting repository folder hierarchy mirrors the
DFC Operations 16
file system directory hierarchy. You can also control version labels, object names, object types and formats
of the imported objects.
Following is a list of Support Notes you can refer to for more information on DFC Operations:
Support Note 7639 - How do I use IdfOperations to Checkout / Checkin / CancelCheckout a document?
Support Note 19060 - Is there an example of how to delete a (Virtual) document using the
IDfDeleteOperation?
Support Note 7195 - How do I use the IDfOperations interface to import documents?
Support Note 15277 - Why do you get an error when running the DFC package
"com.documentum.operations" class using Borland JBuilder?
Support Note 24035 - What is an example of exporting a rendition using IDfExportOperation?
Support Note 15454 - Does the IDfImportOperation method scan for OLE links?
Support Note 30117 - Is there an example of how to use the delete operation to delete an object using DFC
?
Support Note 4624 - What functionalities are provided with the IDfOperations Class?
Support Note 16535 - Can you export a folder recursively using the DFC export operation?
Support Note 20901 - Is there a workaround to bug 50524 - Cannot populate the transform operation with a
virtual document?
Questionnaire:
1) How would you define an Operation?
2) List some of the entity components that exist within an operations
3) What is the advantage of using Operations?
4) List a few of the common DFC Operations.
References
DFC 6.0 Combined “Functional-Design” Specification Operations Customization Model by Craig Randall
DFC Development Guide
DFC Operations 17