/* * Copyright (c) Blue Fish Development Group 1996-2005. All rights reserved. * * This version: * $Author: jduke $ * $Date: 2006/01/02 19:26:31 $ * $Id: BfExampleOneTbo.java,v 1.1 2006/01/02 19:26:31 jduke Exp $ */ package com.bluefishgroup.sample.bof.tbo; import com.documentum.fc.client.DfDocument; import com.documentum.fc.client.IDfBusinessObject; import com.documentum.fc.client.IDfSession; import com.documentum.fc.client.IDfUser; import com.documentum.fc.common.DfException; import com.documentum.fc.common.DfLogger; import com.documentum.fc.common.IDfDynamicInheritance; import com.documentum.fc.common.IDfId; /** * Overrides doCheckout method in order to log a warning message when a document is checked out. * * @author Jason Duke * @version $Revision: 1.1 $ */ public class BfExampleOneTbo extends DfDocument implements IDfBusinessObject, IDfDynamicInheritance { /* * (non-Javadoc) * * @see com.documentum.fc.client.IDfBusinessObject#getVersion() */ public String getVersion() { return "1.0"; } /* * (non-Javadoc) * * @see com.documentum.fc.client.IDfBusinessObject#getVendorString() */ public String getVendorString() { return "Copyright 2006 Blue Fish Development Group. All rights reserved."; } /* * (non-Javadoc) * * @see com.documentum.fc.client.IDfBusinessObject#isCompatible(java.lang.String) */ public boolean isCompatible(String arg0) { return true; } /* * (non-Javadoc) * * @see com.documentum.fc.client.IDfBusinessObject#supportsFeature(java.lang.String) */ public boolean supportsFeature(String arg0) { return true; } /* * (non-Javadoc) * * @see com.documentum.fc.client.IDfPersistentObject#validateAllRules(int) */ public void validateAllRules(int arg0) throws DfException { } /* * (non-Javadoc) * * @see com.documentum.fc.client.DfSysObject#doCheckout(java.lang.String, java.lang.String, * java.lang.String, java.lang.Object[]) */ protected IDfId doCheckout(String versionLabel, String compoundArchValue, String specialAppValue, Object[] extendedArgs) throws DfException { // Let the superclass perform the actual checkout. IDfId newId = super.doCheckout(versionLabel, compoundArchValue, specialAppValue, extendedArgs); // Get a session; it will be released automatically. IDfSession session = getSession(); // Get some info off the object. String objectId = getObjectId().getId(); String objectName = getObjectName(); String lockOwner = getLockOwner(); String lockOwnerEmailAddress = getEmailAddress(lockOwner); // Log the warning. DfLogger.warn(this, "{0} ({1}) was checked out by {2} ({3}).", new String[] { objectName, objectId, lockOwner, lockOwnerEmailAddress }, null); // Return the ID. return newId; } /** * Returns the email address of the user with the specified username; returns null * if no user could be found with that username. * * @param username the user's documentum username * @return the 'user address' stored for that user in the docbase; or null if * that user could not be found * @throws DfException if anything goes wrong */ protected String getEmailAddress(String username) throws DfException { if (username == null) { return null; } // Get a session; it will be released automatically. IDfSession session = getSession(); // Look up the user's email address. IDfUser user = session.getUser(username); if (user == null) { return null; } String emailAddress = user.getUserAddress(); return emailAddress; } }