/* * Copyright (c) Blue Fish Development Group 1996-2005. All rights reserved. * * This version: * $Author: jduke $ * $Date: 2006/01/02 19:26:31 $ * $Id: BfLogService.java,v 1.1 2006/01/02 19:26:31 jduke Exp $ */ /** * */ package com.bluefishgroup.sample.bof.sbo.spi; import com.documentum.fc.client.DfService; import com.documentum.fc.client.IDfDocument; 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.bluefishgroup.sample.bof.sbo.IBfLogService; /** * SBO logs messages using DfLogger. * * @author Jason Duke * @version $Revision: 1.1 $ */ public class BfLogService extends DfService implements IBfLogService { /* (non-Javadoc) * @see com.documentum.fc.client.DfService#getVersion() */ public String getVersion() { return "1.0"; } /* (non-Javadoc) * @see com.documentum.fc.client.DfService#getVendorString() */ public String getVendorString() { return "Copyright 2006 Blue Fish Development Group. All rights reserved."; } /* (non-Javadoc) * @see com.documentum.fc.client.DfService#isCompatible(java.lang.String) */ public boolean isCompatible(String arg0) { return true; } /* (non-Javadoc) * @see com.bluefishgroup.sample.bof.sbo.IBfLogService#logCheckout(String, com.documentum.fc.client.IDfDocument) */ public void logCheckout(String docbase, IDfDocument document) throws DfException { String objectId = document.getObjectId().getId(); String objectName = document.getObjectName(); String lockOwner = document.getLockOwner(); String lockOwnerEmailAddress = getEmailAddress(docbase, lockOwner); // Log the warning. DfLogger.warn(this, "Document {0} ({1}) was checked out by {2} ({3}).", new String[] { objectName, objectId, lockOwner, lockOwnerEmailAddress }, null); } /** * Returns the email address of the user with the specified username. * * @param docbase the docbase to look the user up in * @param username the user's documentum username * @return the 'user address' stored for that user in the docbase * @throws DfException if anything goes wrong */ protected String getEmailAddress(String docbase, String username) throws DfException { if (username == null) { return null; } IDfSession session = null; try { session = getSession(docbase); IDfUser user = session.getUser(username); if (user == null) { return null; } String emailAddress = user.getUserAddress(); return emailAddress; } finally { releaseSession(session); } } }