DFC DfOperations Classes – Part 4

This post will build upon the last post and demonstrate how to reverse the Checkout operation with either a Checkin operation or a Cancel Checkout operation.

Checkin Operation

The checkin operation does all the things you would expect it to:  versions the content file appropriately, transfers content, unlocks objects, patches XML files, updates the registry, and cleans up local files.


private void doCheckinOp(ArrayList objList) {

 try {

   // #1 - manufacture an operation
   IDfCheckinOperation CheckinOpObj = cx.getCheckinOperation();

   // #2 - add objects to the operation for processing
   for (IDfSysObject sObj : objList) {
     CheckinOpObj.add(sObj);
   }

   // #3 - set operation params
   CheckinOpObj.setCheckinVersion(DfCheckinOperation.NEXT_MINOR);
   CheckinOpObj.setKeepLocalFile(false);

   // #4 - execute the operation
   boolean result = CheckinOpObj.execute();

   // #5 - check for errors
   if (!result) {
     IDfList errors = CheckinOpObj.getErrors();
       for (int i=0; i<errors.getCount(); i++) {
	IDfOperationError err = (IDfOperationError) errors.get(i);
	System.out.println("Error in Checkin operation: " + err.getErrorCode() + " - " + err.getMessage());
       }
   }

   // #6 - get new obj ids
   IDfList newObjs = CheckinOpObj.getNewObjects();
   for (int i=0; i<newObjs.getCount(); i++) {
     IDfSysObject sObj = (IDfSysObject) newObjs.get(i);
     System.out.println("\tchecked in " + sObj.getObjectId().toString());
   }

 } catch(Exception e) {
   System.out.println("Exception in Checkin operation: " + e.getMessage());
   e.printStackTrace();
 }

}

The Checkin operation does not depart from the basic form of the operation code discussed previously, but look at its power and simplicity. Only two notes to make:

  • #3 – set the Checkin operation-specific parameters.  In this case, indicate how to handle versioning. (Versioning behavior is defined by an integer constant;  see the DFC Javadocs.)  And second, indicate what to do with the local content, keep it or delete it.
  • # 6 – Notice here that I use the getNewObjects() method to get the object ids of the newly checked in objects.  To get the original object ids, use the getObjects() method.

Take a look back at some of the code you have written for doing checkins and see how it compares with the compactness and verbosity of these 40 lines of code. The DfCheckinOperation offers a ton of function and capability in a compact space.

CancelCheckout Operation

The Cancel Checkout operation completely nullifies a check out by unlocking objects in the Docbase (including virtual document children and XML nodes), removing local content, and updating the registry.


private void doCancelCheckoutOp(ArrayList objList) {

  try {

    // #1 - manufacture an operation
    IDfCancelCheckoutOperation cancelCheckoutOpObj = cx.getCancelCheckoutOperation();

    // #2 - add objects to the operation for processing
    for (IDfSysObject sObj : objList) {
    	cancelCheckoutOpObj.add(sObj);
    }

    // #3 - set operation params
    cancelCheckoutOpObj.setKeepLocalFile(false);

    // #4 - execute the operation
    boolean result = cancelCheckoutOpObj.execute();

    // #5 - check for errors
   if (!result) {
     IDfList errors = CheckinOpObj.getErrors();
       for (int i=0; i<errors.getCount(); i++) {
	IDfOperationError err = (IDfOperationError) errors.get(i);
	System.out.println("Error in Cancel Checkout operation: " + err.getErrorCode() + " - " + err.getMessage());
       }
   }

   // #6 - get new obj ids
   IDfList newObjs = CheckinOpObj.getObjects();
   for (int i=0; i<newObjs.getCount(); i++) {
       IDfSysObject sObj = (IDfSysObject) newObjs.get(i);
       System.out.println("\tcancelled checkout " + sObj.getObjectId().toString());
   }

  } catch(Exception e) {
    System.out.println("Exception in Cancel Checkout operation: " + e.getMessage());
    e.printStackTrace();
  }

}

Again, the only thing of note about this operation is the operation-specific parameter set at #3.

The next post will look at copying and moving objects in the Docbase.

Advertisements

About Scott
I have been implementing Documentum solutions since 1997. In 2005, I published a book about developing Documentum solutions for the Documentum Desktop Client (ISBN 0595339689). In 2010, I began this blog as a record of interesting and (hopefully) helpful bits of information related to Documentum, and as a creative outlet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: