com.senn.magic.util
Class DFCUtils

java.lang.Object
  extended by com.senn.magic.util.DFCUtils

public final class DFCUtils
extends Object

This class contains useful methods for DFC (Documentum Foundation Classes) actions.
You need to include the necessary DFC jars in your classpath to be able to use these methods.

Since:
3.0
Author:
Bart Thierens
Last modification: 23/01/2011
See Also:
"Documentum Foundation Classes, v6.5 API Specification"

Method Summary
static Object callService(String serviceName, String method, com.documentum.fc.client.IDfSession session, Object... args)
          Method to call an SBO (Service-Based Business Object) without having to: add the interface jar to your Java classpath import the SBO interface in your class
static void closeCollection(com.documentum.fc.client.IDfCollection collection)
          Tries to close a collection if the collection is not null and the state of the collection is not equal to IDfCollection.DF_CLOSED_STATE.
static com.documentum.fc.client.IDfSession createSession(String userName, String password, String docbase, String domain)
          This method creates a Documentum session for the provided credentials.
static String decryptPassword(String encryptedPassword)
          Decrypts a password using RegistryPasswordUtils.
static String encryptPassword(String password)
          Encrypts a password using RegistryPasswordUtils.
static com.documentum.fc.client.IDfCollection executeExecQuery(String dql, com.documentum.fc.client.IDfSession session)
          This method executes a DQL query (DfQuery.DF_EXEC_QUERY) with the provided session
static com.documentum.fc.client.IDfCollection executeReadQuery(String dql, com.documentum.fc.client.IDfSession session)
          This method executes a DQL query (DfQuery.DF_EXECREAD_QUERY) with the provided session
static void forceSave(com.documentum.fc.client.IDfSysObject sysObj, com.documentum.fc.client.IDfSession session)
          Try to force a save() operation on a sysobject.
static com.documentum.fc.client.IDfFolder getParent(com.documentum.fc.client.IDfSysObject sysObj, com.documentum.fc.client.IDfSession session)
          Gets the first parent of the provided IDfSysObject (= at position 0).
static com.documentum.fc.client.IDfFolder getParentAt(com.documentum.fc.client.IDfSysObject sysObj, int index, com.documentum.fc.client.IDfSession session)
          Gets the parent of the provided IDfSysObject at the provided position.
static List<com.documentum.fc.client.IDfFolder> getParents(com.documentum.fc.client.IDfSysObject sysObj, com.documentum.fc.client.IDfSession session)
          Gets all parents associated with the IDfSysObject.
static boolean objectExists(com.documentum.fc.common.IDfId objectId, com.documentum.fc.client.IDfSession session)
          This method checks if an object with the specified objectId exists
static boolean objectExists(String objectId, com.documentum.fc.client.IDfSession session)
          This method checks if an object with the specified objectId exists
static void replacePrimaryRendition(File newPrimRend, String newContentType, com.documentum.fc.client.IDfDocument doc, com.documentum.fc.client.IDfSession session)
          Sets the primary rendition of a document to the new file and adds the old primary rendition as a normal rendition.
static void replacePrimaryRendition(String newPrimRendPath, String newContentType, com.documentum.fc.client.IDfDocument doc, com.documentum.fc.client.IDfSession session)
          Sets the primary rendition of a document to the new file and adds the old primary rendition as a normal rendition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

executeReadQuery

public static com.documentum.fc.client.IDfCollection executeReadQuery(String dql,
                                                                      com.documentum.fc.client.IDfSession session)
                                                               throws com.documentum.fc.common.DfException
This method executes a DQL query (DfQuery.DF_EXECREAD_QUERY) with the provided session

Parameters:
dql - the DQL query to be executed
session - the current Documentum session
Returns:
IDfCollection a collection with the results
Throws:
com.documentum.fc.common.DfException

executeExecQuery

public static com.documentum.fc.client.IDfCollection executeExecQuery(String dql,
                                                                      com.documentum.fc.client.IDfSession session)
                                                               throws com.documentum.fc.common.DfException
This method executes a DQL query (DfQuery.DF_EXEC_QUERY) with the provided session

Parameters:
dql - the DQL query to be executed
session - the current Documentum session
Returns:
IDfCollection a collection with the results
Throws:
com.documentum.fc.common.DfException

createSession

public static com.documentum.fc.client.IDfSession createSession(String userName,
                                                                String password,
                                                                String docbase,
                                                                String domain)
                                                         throws com.documentum.fc.common.DfException
This method creates a Documentum session for the provided credentials.

Parameters:
userName - the Documentum username
password - the Documentum password
docbase - the Documentum docbase/repository
domain - the Documentum domain, may be left null if not needed
Returns:
IDfSession a Documentum session for the provided credentials
Throws:
com.documentum.fc.common.DfException

objectExists

public static boolean objectExists(String objectId,
                                   com.documentum.fc.client.IDfSession session)
                            throws com.documentum.fc.common.DfException
This method checks if an object with the specified objectId exists

Parameters:
objectId - the objectId as a string
session - the Documentum session
Returns:
boolean true if the object exists, false if it doesn't
Throws:
com.documentum.fc.common.DfException
See Also:
objectExists(IDfId, IDfSession)

objectExists

public static boolean objectExists(com.documentum.fc.common.IDfId objectId,
                                   com.documentum.fc.client.IDfSession session)
                            throws com.documentum.fc.common.DfException
This method checks if an object with the specified objectId exists

Parameters:
objectId - the objectId as an implementation of IDfId
session - the Documentum session
Returns:
boolean true if the object exists, false if it doesn't
Throws:
com.documentum.fc.common.DfException
See Also:
objectExists(String, IDfSession)

callService

public static Object callService(String serviceName,
                                 String method,
                                 com.documentum.fc.client.IDfSession session,
                                 Object... args)
                          throws com.documentum.fc.common.DfException
Method to call an SBO (Service-Based Business Object) without having to:

Parameters:
serviceName - the name of the SBO service
method - the name of the method
session - a valid Documentum session
args - the arguments to pass to the SBO-method
Returns:
Object - the return value as an object. null is returned when the method has no return value.
Throws:
com.documentum.fc.common.DfException
See Also:
ReflectionUtils.invoke(Object, String, Object...)

getParent

public static com.documentum.fc.client.IDfFolder getParent(com.documentum.fc.client.IDfSysObject sysObj,
                                                           com.documentum.fc.client.IDfSession session)
                                                    throws com.documentum.fc.common.DfException
Gets the first parent of the provided IDfSysObject (= at position 0).

Parameters:
sysObj - the sysobject
session - a valid Documentum session
Returns:
IDfFolder - the parent folder of the sysobject
Throws:
com.documentum.fc.common.DfException
See Also:
getParentAt(IDfSysObject, int, IDfSession)

getParentAt

public static com.documentum.fc.client.IDfFolder getParentAt(com.documentum.fc.client.IDfSysObject sysObj,
                                                             int index,
                                                             com.documentum.fc.client.IDfSession session)
                                                      throws com.documentum.fc.common.DfException
Gets the parent of the provided IDfSysObject at the provided position.

Parameters:
sysObj - the sysobject
index - the index to get the parent
session - a valid Documentum session
Returns:
IDfFolder - the parent folder of the sysobject
Throws:
com.documentum.fc.common.DfException

getParents

public static List<com.documentum.fc.client.IDfFolder> getParents(com.documentum.fc.client.IDfSysObject sysObj,
                                                                  com.documentum.fc.client.IDfSession session)
                                                           throws com.documentum.fc.common.DfException
Gets all parents associated with the IDfSysObject.

Parameters:
sysObj - the sysobject
session - a valid Documentum session
Returns:
List - a list of IDfFolder instances
Throws:
com.documentum.fc.common.DfException

replacePrimaryRendition

public static void replacePrimaryRendition(File newPrimRend,
                                           String newContentType,
                                           com.documentum.fc.client.IDfDocument doc,
                                           com.documentum.fc.client.IDfSession session)
                                    throws com.documentum.fc.common.DfException
Sets the primary rendition of a document to the new file and adds the old primary rendition as a normal rendition.

Parameters:
newPrimRend - the new primary rendition
doc - the document
session - a valid Documentum session
Throws:
com.documentum.fc.common.DfException
See Also:
replacePrimaryRendition(String, String, IDfDocument, IDfSession)

replacePrimaryRendition

public static void replacePrimaryRendition(String newPrimRendPath,
                                           String newContentType,
                                           com.documentum.fc.client.IDfDocument doc,
                                           com.documentum.fc.client.IDfSession session)
                                    throws com.documentum.fc.common.DfException
Sets the primary rendition of a document to the new file and adds the old primary rendition as a normal rendition.

Parameters:
newPrimRendPath - the path to the new primary rendition
doc - the document
session - a valid Documentum session
Throws:
com.documentum.fc.common.DfException
See Also:
replacePrimaryRendition(File, String, IDfDocument, IDfSession)

forceSave

public static void forceSave(com.documentum.fc.client.IDfSysObject sysObj,
                             com.documentum.fc.client.IDfSession session)
                      throws com.documentum.fc.common.DfException
Try to force a save() operation on a sysobject.
Be careful with this method! The method tries the following operations in this order:
  1. save
  2. (if 1. fails) fetch & save
  3. (if 1. and 2. fail) revert & save
In the rare event that the last step is executed, it is possible that changes made to the sysobject will be lost!

Parameters:
sysObj - the sysobject
session - a valid Documentum session
Throws:
com.documentum.fc.common.DfException

closeCollection

public static void closeCollection(com.documentum.fc.client.IDfCollection collection)
                            throws com.documentum.fc.common.DfException
Tries to close a collection if the collection is not null and the state of the collection is not equal to IDfCollection.DF_CLOSED_STATE.

Parameters:
collection - the collection to close
Throws:
com.documentum.fc.common.DfException

encryptPassword

public static String encryptPassword(String password)
                              throws com.documentum.fc.common.DfException
Encrypts a password using RegistryPasswordUtils.

Parameters:
password - the password to encrypt
Returns:
String - the encrypted password
Throws:
com.documentum.fc.common.DfException

decryptPassword

public static String decryptPassword(String encryptedPassword)
                              throws com.documentum.fc.common.DfException
Decrypts a password using RegistryPasswordUtils.

Parameters:
encryptedPassword - the password to decrypt
Returns:
String - the decrypted password
Throws:
com.documentum.fc.common.DfException