debugging the workflow

Avatar

Avatar

AdobeID24

Avatar

AdobeID24

AdobeID24

20-09-2019

I am creating a simple workflow which would e able to create sonme node inside /cotent when i trigger that workflow.

I created a process step (a service ) and added that steps in my workflow and saved .

no new node has been created inside my /content.

code is like that :

=============

package amitsample.core.filters;

import com.day.cq.workflow.WorkflowException;
import com.day.cq.workflow.WorkflowSession;
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.exec.WorkflowProcess;
import com.day.cq.workflow.metadata.MetaDataMap;
import org.apache.felix.scr.annotations.*;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.osgi.framework.Constants;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
import java.util.HashMap;
import java.util.Map;
@Component

@Service

@Properties({

   @Property(name = Constants.SERVICE_DESCRIPTION, value = "Sample Workflow Process implementation amit"),

   @Property(name = "process.label", value = "my first workflow process step") ,

   @Property(name = "service.pid",value = "amitsample.core.filters.WorkflowSamplefilter")

})

public class WorkflowSamplefilter implements WorkflowProcess {

   @Reference
   ResourceResolverFactory resourceResolverFactory;

   @Override
   public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {

  Map<String, Object> usermap = new HashMap<String, Object>();
   usermap.put(ResourceResolverFactory.SUBSERVICE,"kuchbhi");
   ResourceResolver resourceResolver = null;
  try {

  resourceResolver = resourceResolverFactory.getServiceResourceResolver(usermap);
   } catch (LoginException e) {

  e.printStackTrace();
   }

  String nodepath="/content/amitsample";
   Session session=resourceResolver.adaptTo(Session.class);

   Node planetNodeList= resourceResolver.getResource(nodepath).adaptTo(Node.class);

   Node planetNameListNode = null;
  try {

  planetNameListNode = planetNodeList.addNode("testingworkflow1", "cq:Page");
   Node planetNameListJcrNode= null;
   planetNameListJcrNode = planetNameListNode.addNode(Node.JCR_CONTENT, NodeType.NT_UNSTRUCTURED);
   planetNameListJcrNode.setProperty(javax.jcr.Property.JCR_TITLE,"testingworkflow_title");
   session.save();
   } catch (RepositoryException e) {

  e.printStackTrace();
   }

  }

}

==============================

1835930_pastedImage_9.png

Any idea how I can debug my workflow ?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

dvnSudheer

Avatar

dvnSudheer

dvnSudheer

20-09-2019

AdobeID24​, Please check the workflow model, if the "Handler Advance" is checked in the before step. That should be checked-in, else it will not move to the next step. If it is checked-in and still not going to the next step, please check the error logs once

What is your actual requirement, if it is only simply page creations or node creations you can always use some standalone scripts to create the hierarchy, if it is like creating a different node based on some action, workflow is fine.

You can find a couple of standalone scripts here

Answers (5)

Answers (5)

Avatar

Avatar

hamidk92094312

Employee

Avatar

hamidk92094312

Employee

hamidk92094312
Employee

22-09-2019

I would suggest you to check ths following doc where you can see how to create a workflow, invoke it, and monitor it.

Adobe Experience Manager Help | Using Adobe Experience Manager Workflows

Avatar

Avatar

AdobeID24

Avatar

AdobeID24

AdobeID24

20-09-2019

1836038_pastedImage_0.png

It seems my workflow is not going to 2nd step which is process step? is that so ?

Avatar

Avatar

AdobeID24

Avatar

AdobeID24

AdobeID24

20-09-2019

I did not get any entry in any of those log files ...I m still confused my workflow is ruunning or not because action which i wrote inside execute methodis not happening but when i check instance i can see my workflow instance is ruuning.

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.1K

Likes

1.1K

Correct Reply

1.1K

Avatar

Jörg_Hoh

Employee

Total Posts

3.1K

Likes

1.1K

Correct Reply

1.1K
Jörg_Hoh
Employee

20-09-2019

Check your console for exceptions (unfortunately you use e.printStackTrace() instead of proper logging).

Jörg

Avatar

Avatar

jbrar

Employee

Avatar

jbrar

Employee

jbrar
Employee

20-09-2019

Add some DEBUG statements to the code and then setup a DEBUG logger on the following classes:

com.adobe.granite.workflow

com.day.cq.workflow

amitsample.core

This will provide the backend details on whats happening.