Documentum 21.2 Lifecycle custom Java Module Product version: Date: Documentum Content Server 21.2 Documentum Composer 21.2 Document Administrator 21.2 August 2021 The purpose of this article is to showcase creating custom Java module to be used in Documentum lifecycle. The custom Java code don’t do much, except to append some keyword to the document when the document enters the lifecycle state, in the lifecycle state and post processed in the lifecycle state. The steps in involved: a) Write Java code to implement IDfModule, IDfLifecycleUserEntryCriteria, IDfLifecycleUserAction and IDfLifecycleUserPostProcessing, export as Jar. b) Create Jar definition, module, lifecycle artifacts and install Documentum Project in Documentum Composer. c) Attach document to lifecycle for testing in Documentum Administrator. Reference used in this article: https://forums.opentext.com/forums/developer/discussion/160880/example-steps-foridflifecycleuserpostprocessing-module https://bluefishgroup.com/insights/ecm/custom-java-lifecycle-modules/ 1. Write Java code to implement IDfModule, IDfLifecycleUserEntryCriteria, IDfLifecycleUserAction and IDfLifecycleUserPostProcessing, export as Jar Crate Java project Start Eclipse (Eclipse version used in this example is Eclipse 2021-06). Click File – New – Java Project menu. Key in TestLifecycle as the Project Name, click Finish button. Add dfc.jar to project build path Click to select the project, in this example TestLifecyle, right mouse click, select Build Path – Configure Build Path. Click Libraries tab in the Properties for TestLifecycle popup window. Click to select Modulepath, click Add External JARs button. Browse to where locate dfc.jar, in this example, it is located in C:\Documentum\Shared folder, click Open button. Click Apply and Close button to close the Properties for TestLifecycle popup window. Create class for TestIDfLifecycleUserEntryCriteria, IDfLifecycleUserAction and IDfLifecycleUserPostProcessing Click to expand the project, in this example, TestLifecycle. Click to select src folder, right mouse click, select New – Class. Type com.documentum.lifecyle in the Package filed, type TestIDfLifecycleUserEntryCriteria in the Name field, click Finish button. Click to select src folder, right mouse click, select New – Class. Type com.documentum.lifecyle in the Package filed, type TestIDfLifecycleUserEntryCriteria in the Name field, click Finish button. Click to select src folder, right mouse click, select New – Class. Type com.documentum.lifecyle in the Package filed, type TestIDfLifecycleUserEntryCriteria in the Name field, click Finish button. TestIDfLifecycleUserEntryCriteria.java Double click to open IDfLifecycleUserEntryCriteria.java and type in the code, after that click Control-S to save the code. package com.documentum.lifecyle; import com.documentum.fc.client.IDfModule; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfException; import com.documentum.fc.common.DfLogger; import com.documentum.fc.lifecycle.IDfLifecycleUserEntryCriteria; public class TestIDfLifecycleUserEntryCriteria implements IDfModule, IDfLifecycleUserEntryCriteria{ @Override public boolean userEntryCriteria(IDfSysObject sysObject, String userName, String targetState) throws DfException { try { String messageStr = "sysObject.getTypeName(),userName,targetState =" + sysObject + "," + userName + "," + targetState + ","; System.out.println(messageStr); DfLogger.info(null, messageStr, null, null); sysObject.appendString("keywords", "TestIDfLifecycleUserEntryCriteria"); sysObject.save(); } catch (Exception e) { System.out.println("An exception has occured …." + e); DfLogger.error(null, "An exception has occured ….", null, e); DfException ex = new DfException(); ex.setMessage("Hello this is a problem"); throw ex; } finally { } } } return true; IDfLifecycleUserAction.java Double click to open IDfLifecycleUserAction.java and type in the code, after that click Control-S to save the code. package com.documentum.lifecyle; import com.documentum.fc.client.IDfModule; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfException; import com.documentum.fc.common.DfLogger; import com.documentum.fc.lifecycle.IDfLifecycleUserAction; public class TestIDfLifecycleUserAction implements IDfModule, IDfLifecycleUserAction{ @Override public void userAction(IDfSysObject sysObject, String userName, String targetState) throws DfException { try { String messageStr = "sysObject.getTypeName(),userName,targetState =" + sysObject + "," + userName + "," + targetState + ","; System.out.println(messageStr); DfLogger.info(null, messageStr, null, null); sysObject.appendString("keywords", "TestIDfLifecycleUserAction"); sysObject.save(); } catch (Exception e) { System.out.println("An exception has occured …." + e); DfLogger.error(null, "An exception has occured ….", null, e); } DfException ex = new DfException(); ex.setMessage("Hello this is a problem"); throw ex; } finally { } } TestIDfLifecycleUserPostProcessing.java Double click to open TestIDfLifecycleUserPostProcessing.java and type in the code, after that click Control-S to save the code. package com.documentum.lifecyle; import com.documentum.fc.client.IDfModule; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfException; import com.documentum.fc.common.DfLogger; import com.documentum.fc.lifecycle.IDfLifecycleUserPostProcessing; public class TestIDfLifecycleUserPostProcessing implements IDfModule, IDfLifecycleUserPostProcessing{ @Override public void userPostProcessing(IDfSysObject sysObject, String userName, String targetState) throws DfException { try { String messageStr = "sysObject.getTypeName(),userName,targetState =" + sysObject + "," + userName + "," + targetState + ","; System.out.println(messageStr); DfLogger.info(null, messageStr, null, null); sysObject.appendString("keywords", "TestIDfLifecycleUserPostProcessing"); sysObject.save(); } catch (Exception e) { System.out.println("An exception has occured …." + e); DfLogger.error(null, "An exception has occured ….", null, e); DfException ex = new DfException(); ex.setMessage("Hello this is a problem"); throw ex; } finally { } } } Export as TestLifecycle.jar Click to select the project, in this example TestLifecyle, right mouse click, select Export. In the Export popup window, click to expand Java, click to select JAR file, click Next button. Type C:\Testing\TestLifecycle.jar in the JAR file field, click Finish button. 2. Create Jar definition, module, lifecycle artifacts and install Documentum Project in Documentum Composer Create a Documentum project Start Documentum Composer, in this example Documentum Composer 21.2. Click File – New – Documentum Project menu. Key in TestLifecycle as the Project Name, click Finish button. Create TestLifecyle Jar definition artifact Click to select the project, in this example TestLifecyle, right mouse click, select New – JAR definition. Type TestLifecycle in the Artifact name field, click Finish button. In the newly opened testlifecycle.jardef tab, click to select Implementation in the Type drop down. Click Browse button, to select C:\Testing\TestLifecycle.jar, click Open button. Click File – Save menu. In this example, there is no need to copy C:\Testing\TestLifecycle.jar to C:\Documentum\dba\java_methods folder. Defining a Jar definition is enough for the Java code to be activated by the lifecycle. Create com.documentum.lifecyle.IDfLifecycleUserEntryCriteria module artifact Click to select the project, in this example TestLifecyle, right mouse click, select New – Module. Type com.documentum.lifecyle.IDfLifecycleUserEntryCriteria in the Artifact name field, click Finish button. In the newly open com.documentum.lifecyle.IDfLifecycleUserEntryCriteria.module tab, click Add button in the Implementation JARs section, click to select Lifecycle, click OK button. Click Select button, click to select com.documentum.lifecyle.IDfLifecycleUserEntryCriteria, click Open button. Click File – Save menu. Create com.documentum.lifecyle.IDfLifecycleUserAction module artifact Click to select the project, in this example TestLifecyle, right mouse click, select New – Module. Type com.documentum.lifecyle.IDfLifecycleUserAction in the Artifact name field, click Finish button. In the newly open com.documentum.lifecyle.IDfLifecycleUserAction.module tab, click Add button in the Implementation JARs section, click to select Lifecycle, click OK button. Click Select button, click to select com.documentum.lifecyle.IDfLifecycleUserAction, click Open button. Click File – Save menu. Create com.documentum.lifecyle.IDfLifecycleUserPostProcessing module artifact Click to select the project, in this example TestLifecyle, right mouse click, select New – Module. Type com.documentum.lifecyle.IDfLifecycleUserPostProcessing in the Artifact name field, click Finish button. In the newly open com.documentum.lifecyle.IDfLifecycleUserPostProcessing.module tab, click Add button in the Implementation JARs section, click to select Lifecycle, click OK button. Click Select button, click to select com.documentum.lifecyle.IDfLifecycleUserPostProcessing, click Open button. Click File – Save menu. Create Test_Lifecycle_1 lifecycle artifact Click to select the project, in this example TestLifecyle, right mouse click, select New – Lifecycle. Type Test_Lifecycle_1 in Artifact name field, click Finish button. In the newly opened test_lifecycle_1.lifecycle tab, click to select Normal State, click to the Canvas on the right, a new button NEW_STATE will be shown. Click to select the newly create NEW_STATE button. In the General tab below. Click Select button in Primary type, select dm_document, click OK button. Click to select Java in the Implementation type drop down. Click Overview tab below, type In Progress in the Name field, click to select Allow attachments directly to this state. Click Entry Criteria tab, click Select button in the Module, select to select com.documentum.lifecyle.IDfLifecycleUserEntryCriteria, click OK button. Click Actions tab, click Select button in the Module, select to select com.documentum.lifecyle.IDfLifecycleUserAction, click OK button. Click o Post change ab, click Select button in the Module, select to select com.documentum.lifecyle.IDfLifecycleUserPostProcessing, click OK button. Click on the Canvas. Click Normal State, click on canvas, a NEW_STATE button will be created. Click on the newly created NEW_STATE, click Overview tab, type Reviewed in the Name field. Click Connection. Click to connect In Progress button to Reviewed button. Click File – Save. Install TestLifecycle Documentum Project Click to select the project, in this example TestLifecyle, right mouse click, select Install Documentum Project. Select the repository from the Repository name drop down, in this example, it is DocBase1. Type the User name and Password, in this example, it is dmadmin. Click Login button. After login is successful, click on the Finish button. 3. Attach document to lifecycle for testing in Documentum Administrator Attach document to lifecycle Start Documentum Administrator, in this example it is http://localhost:8080/da/component/main. Login as user dmadmin. Click to select existing document, in this example, it is Testing1.txt in Testing Folder 1 folder. Click to select this Testing1.txt document, right mouse click, select Properties. Click Show all properties check box. Scroll down to Keywords field, notice the field is blank. Click Cancel button Click to select this Testing1.txt document, right mouse click, select Lifecycle - Apply. Click to select Test_Lifecycle_1, click OK button. Click to select this Testing1.txt document, right mouse click, select Properties. Click Show all properties check box. Scroll down to Keywords field, notice the field has the values TestIDfLifecycleUserEntryCriteria, TestIDfLifecycleUserAction, TestIDfLifecycleUserPostProcessing, which are appended by the custom Java module. Click Cancel button.