Extra Arguments with Lifecycle Entry Condition Custom Method check D2

Hello!

I wrote a custom method to check certain attributes and prerequisites and I'm giving couple of arguments with values but when I submit the documents through this Lifecycle, method does trigger but it's not able to read these arguments which I'm passing.

I cleared JMS cache, D2 app server cache and restarted docbase with no luck.

Is there anything that I'm missing ? Is it so that during the entry validation checks arguments with $value(r_object_id) is not passed ?

Hope to find some answers.

D2 version is 4.5 running on 7.3 CS.

Comments

  • Pedro Maia
    edited December 5, 2018 #2

    In the D2 Lifecycle action, you can set the 'Extra arguments' to pass parameters - for example:

    -id $value(r_object_id) -login_user "$USER"
    

    It is possible then to read it in the JMS Method class with code similar to:

    public class ABC_MyMethod implements IDfModule, ID2Method
    {
        private IDfId objectId = null;
        private String userName = null;
    
        @Override
        public D2methodBean execute(IDfSession idfSession, IDfSysObject idfSysobject, Locale locale,
            ArgumentParser argumentParser) throws Exception
        {
           try
           {
               // Read the JMS Method parameters set on the Lifecycle action
               this.objectId = argumentParser.getIdArgument("-d", null);
               this.userName = argumentParser.getStringArgument("-login_user", null);
    ...
    

    Pedro Maia
    Senior Consultant
    OpenText

  • Hi Pedro!

    Thanks for the input!

    This is something new to me and it'd be great if you let me know which libraries are necessary for ID2Method to implement ?

    I was implementing it this way:

    public class MyClass extends DfSingleDocbaseModule implements IDfMethod {
    
        /**
         * 
         */
    
        private IDfClientX clientX = null;
        private IDfClient client = null;
    
        private IDfSession initializeSession() throws DfException {
            if (this.clientX == null)
                this.clientX = new DfClientX();
    
            if (this.client == null)
                this.client = clientX.getLocalClient();
    
            return getSession();
    
        }
    
        @Override
        public int execute(Map parameters, PrintWriter out) throws Exception {
            // TODO Auto-generated method stub
            LOG.info("Executing Pre Digital Delivery Check Execute Method");
    
            int result = 0;
    
            IDfSession session = initializeSession();
            String docID = getParameterValue(parameters,"id");
            String AttributeName = getParameterValue(parameters,"AttrName");
    
  • To be able to compile the JMS Method which extends ID2Method you need:

    • DFC
    • D2 Jars (found in the Application Server at 'webapps\D2\WEB-INF\lib')

    Pedro Maia
    Senior Consultant
    OpenText

  • Update:
    I found the d2-API.jar which is necessary for it.

    I'm having problems with ArgumentParser though :(

  • 'ArgumentParser' is in 'C6-Common-4.7.0.jar', which is located at 'webapps\D2\WEB-INF\lib' as stated above.

    Pedro Maia
    Senior Consultant
    OpenText

  • Got it!

    Thank you!

    I'll try implementing it and let you know :smile:

  • By the way, what is the return value that's expected from this method ?

  • Pedro Maia
    edited December 5, 2018 #9

    On success return:

    D2methodBean methodResult = new D2methodBean(D2Method.RETURN_SUCCESS_STR, null);
    

    On failure return something like:

    methodResult = new D2methodBean(D2Method.RETURN_FATAL_STR, e.getMessage());
    

    Pedro Maia
    Senior Consultant
    OpenText

  • Thank you, Pedro!

    I implemented this method and deployed it for the lifecycle.

    Even though the transition seem to be carried forward, I don't see any messages that I had written as system.out.println in the method in JMS log.

    And even though the condition is not met, I don't see the failed message.

  • Some quick notes:

    • You should not be using System.out.println() to send messages to the logs - try using the DfLogger class
    • You need to deploy the ID2Method in Composer with:
    method_verb = com.emc.d2.api.methods.D2Method -class_name my.package.MyConditionMethod
    
    • You should remote debug the code to see if it is being executed and working as expected.

    Pedro Maia
    Senior Consultant
    OpenText

  • Alright!

    I just quickly wanted to check by using println statements and I know that it's a bad practice :neutral:

    Yeah, I've added Id2Method in Composer and then deployed it. I'll try adding DfLogger statements to see if i can see these statements in JMS logs

  • Update: Even with DfLogger statements I couldn't see any output to JMS log :(

    I tried to run this method through DA and I could at least see these messages in JMS:

    ERROR [default task-18] com.documentum.mthdservlet.DoMethod - Exception invoking com.emc.d2.api.methods.D2Method.
    java.lang.ClassNotFoundException:
    2018-12-05 15:13:27,666 ERROR [io.undertow.request] (default task-18) UT005023: Exception handling request to /DmMethods/servlet/DoMethod: javax.servlet.ServletException:
    

    But nothing when initiating this method through lifecycle

  • I know nothing of the setup in your environment, but check if the D2 JAR files are placed in the JMS server at:
    ..\wildfly9.0.1\server\DctmServer_MethodServer\deployments\ServerApps.ear\lib

    Regarding the logs, I'm afraid it is not a simple subject - take at these articles which might help you:
    https://blog.dbi-services.com/documentum-story-documentum-jms-log-configuration/
    https://blog.dbi-services.com/documentum-how-to-really-configure-the-d2-jms-logs-starting-with-jbosswildfly/

    Pedro Maia
    Senior Consultant
    OpenText

  • I'm able to see all the necessary D2 libraries under that location:

    I'm now doubting the way I deployed this method using Composer, as when I add this JAR definition and necessary module, when I tried to add the class name it complained about missing D2 API interface, as such I had to add D2-API to the JAR definition as well to be able to pick the class name. Is there a different procedure to deploy this kind of D2 methods ?

  • As I explained above, this is the correct way of adding your D2 Method in Composer:

    Pedro Maia
    Senior Consultant
    OpenText

  • Thanks Pedro!

    But I always have deployed my methods in Module format and this is something new. I've done something like this and I used Eclipse (not composer) to develop method and I exported my method class in the form of JAR and then added it under JAR definition.

    By following your way, is it so that I've to write code right into Composer Class and then deploy it ?

  • Pedro Maia
    edited December 6, 2018 #18

    It is correct to create the JAR in Eclipse and then use Composer to create the DAR (I do the same). The problem is that creating the JMS Method with command com.emc.d2.api.methods.D2Method doesn't allow to deploy the Method as a Module. You have to deploy the JAR manually in the JMS Server at:
    ../jboss7.1.1/server/DctmServer_MethodServer/deployments/ServerApps.ear/lib
    If you manage to deploy as a Module, let me know as I couldn't make it work either.

    Pedro Maia
    Senior Consultant
    OpenText

  • Hi Pedro!

    It doesn't work if its module. I had to copy that JAR file to > ../jboss7.1.1/server/DctmServer_MethodServer/deployments/ServerApps.ear/lib

    It'd have been good if these can be deployed as Modules as it'll reduce the dependency on the libraries to be copied on the CS :neutral:

    Anyway, thank you for all the help and if you happen to find any way around for making it a module in future, please let me know.

  • Hi @PedroMaia

    Just revisiting this code today due to no more sessions available issue on our repository, I happen to see that there's no easy way to release session after this method.

    Is it so that the IDFsession passed as an argument needs t o be released or will be managed by the user session as it's D2 Method ?

  • Have you looked at IDfSession.killSession()?

    Not sure why you are initializing session this way. You should be using SessionManager to get a session. SessionManager allows you to re-use session, so you don't have issue with running out of sessions.

  • Hi Johnny

    I think it's the way how ID2Method handles the session. Usually when a method is triggered, SessionManager is used to create and release sessions, but these methods doesn't need one as we're passing the session directly to the execute method from the user session. This is my understanding.

  • If sessions are being passed from D2 (and you are not creating them in your code), then you should submit a ticket. You should haven't to increase your session limits b/c ID2Method is managing sessions incorrectly.

  • We're still trying to figure out the cause for running out of sessions and while I was revisiting all custom jobs/ code, I happen to observe that we're not releasing any session post running this custom D2 method, so it now is under suspicion that if this could be a reason for high consumption of the sessions

  • How are you getting the session? It would help you paste your code.

  • imranganath
    edited July 29, 2019 #26

    it's exactly how Pedro has mentioned in this post:

    public class ABC_MyMethod implements IDfModule, ID2Method
    {
        private IDfId objectId = null;
        private String userName = null;
    
        @Override
        public D2methodBean execute(> **IDfSession idfSession**, IDfSysObject idfSysobject, Locale locale,
            ArgumentParser argumentParser) throws Exception
        {
           try
           {
               // Read the JMS Method parameters set on the Lifecycle action
               this.objectId = argumentParser.getIdArgument("-d", null);
               this.userName = argumentParser.getStringArgument("-login_user", null);
    ...
    
  • Well if D2 is passing in the session into your code, its hard to understand how new sessions would be created. I do not expect them to be released if D2 is passing in existing session. Do you see session increase while running OOTB D2 jobs? This would isolate whether the issue is the ID2Method constructor or something related to that.

  • I have a requirement to attach the incoming documents to a workflow and D2 workflow needs to be started. I have created the workflow using the Process Builder and configured the workflow in the D-Config. I have created the Job and the ID2Method and deployed as method to the docbase. But when I ran the Job it throwed an error for the ParameterParser parameterParser as it is null. could you let me know how to attach a document to the particular Workflow. Kindly if you could provide me the code which is running successfully so I can modify according to requirement.

    public interface ITTibTaxScannedWfInitJob extends IDfModule, ID2Method {

    }

    public class TTibScannedWfInitJob implements ITTibTaxScannedWfInitJob {

    /*
    private static Logger logger = DfLogger.getLogger("com.hilton.fna.dms.methods.HafsTaxScannedWfInitJob");
    
    public D2methodBean execute(IDfSession session, IDfSysObject job, Locale locale, ArgumentParser argumentParser)
            throws Exception {
         List listTrackers;
        System.out.println("************TaxScanned Workflow Job Initiated New**********");
        logger.info("************TaxScanned Workflow Job Initiated New**********");
        System.out.println("Launched by job : {}"+ job.getObjectName());
        D2WorkflowLaunch.ARG_CONFIG_NAME = "Tax: Exemption Support";
        D2WorkflowLaunch workflowLaunch = new D2WorkflowLaunch();
        D2fsContext context;
        **ParameterParser parameterParser = null;
        parameterParser.setParameter(D2WorkflowLaunch.ARG_CONFIG_NAME, "Workflow Name passed here");**
        //workflowLaunch.process(context.setParameterParser(parameters));
    
        D2WorkflowConfig workflowConfig = new D2WorkflowConfig();
        System.out.println("Workflow Obejct Name is: "+workflowConfig.getObjectName());     
        listTrackers = D2cWorkflowTracker.getScheduledTrackers(session);
    
        ID2cWorkflowTracker tracker;
        IDfSession sessUser;
        IDfSessionManager sessManagUser;
        tracker = (ID2cWorkflowTracker)listTrackers.get(0);
        System.out.println("Found tracker :{} (ID:{})"+ tracker.getObjectName()+ tracker.getObjectId().getId());
        System.out.println("Scheduled start :{}"+ tracker.getString("scheduled_start_date"));        
        System.out.println("Starting workflow...");
        sessUser = null;
        sessManagUser = null;
        com.documentum.fc.client.IDfUser user = session.getUser(tracker.getOwnerName());
        sessManagUser = connectAsUser(session, DfUserUtil.getUserLogin(user), session.getDocbaseName());
        sessUser = sessManagUser.getSession(session.getDocbaseName());
        D2Session.initTBO(sessUser);
        ID2cWorkflowTracker trackerUser = (ID2cWorkflowTracker)sessUser.getObject(tracker.getObjectId());
        trackerUser.startWorkflow(session, trackerUser.getScheduledStartNote());
        System.out.println("Workflow started :{}"+ trackerUser.getWorkflow().getObjectId().getId());
    

    Thanks
    Ram.

  • Hello!

    Was there a reason why this implementation was done in ID2Method ? These ID2Methods will run in tandem with the D2- UI and will depend on arguments passed as part of it.

    If i understood your requirements correctly, it should be IDfModule.

  • maturi_123
    edited December 16, 2019 #30

    Hi Ranganath,
    when I implemented the IDfModule and deployed and when I ran the job the workflow got initiated but the thing is the workflow has autoactivities where we execute the D2WFLifeCycleMethod and it fails at this point and throws below error and it continues to the next activity and it doesn't apply the lifecycle. It works When you attach the document to the workflow through the D2 client and it applies the lifecycle and promotes and finished the workflow.

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) 20:00:00.501 [default task-22] INFO 331 - ERROR occured: Workflow tracker not found.

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) 20:00:00.501 [default task-22] ERROR 331 - {}

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) java.lang.Exception: Workflow tracker not found.

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) at com.emc.d2.api.methods.D2WFLifeCycleMethod.execute(D2WFLifeCycleMethod.java:259) [D2-API.jar:na]

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) at com.emc.d2.api.methods.D2Method.callExecute(D2Method.java:919) [D2-API.jar:na]

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) at com.emc.d2.api.methods.D2Method.main(D2Method.java:1191) [D2-API.jar:na]

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) at com.emc.d2.api.methods.D2Method.execute(D2Method.java:1244) [D2-API.jar:na]

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) at com.documentum.mthdservlet.DfMethodRunner.runIt(Unknown Source) [mthdservlet.jar:na]

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) at com.documentum.mthdservlet.AMethodRunner.runAndReturnStatus(Unknown Source) [mthdservlet.jar:na]

    2019-12-12 20:00:00,501 INFO [stdout] (default task-22) at com.documentum.mthdservlet.DoMethod.invokeMethod(Unknown Source) [mthdservlet.jar:na]

    Thanks & Regards,
    Ram.