3 Replies Latest reply on Feb 28, 2013 5:41 AM by Sreek545

    Creating folders automatically using workflow




      We have a requirement to create a folder structure upon creation of a root folder in DAM.




      Folder ABC created manually in DAM.


      Under that 2folders XY, XYZ are to be created upon triggering of workflow.


      Can anyone throw some light on this.



        • 1. Re: Creating folders automatically using workflow
          Davide G Adobe Employee

          Create a workflow listener on /content/dam/yoursite. Register your custom workflow to it. In this workflow you'll perform your business logic.


          To keep it simple you can barely post the node you want to create using the sling post servlet




          You can do it with an ecma script.


          Perform a couple of tests on multiple node creation (the same node more than once) to double check about Sling behaviours.




          • 3. Re: Creating folders automatically using workflow
            Sreek545 Level 1



            I was able to create a workflow listener and associate that with a workflow.


            I have implemented  a custom process step where in am trying to create folders programatically on launch of this workflow. But some how there is an error coming up when workflow is launched.


            Please let us know if any pointers on the below.


            @Property(name = Constants.SERVICE_DESCRIPTION, value = "A sample workflow process implementation."),
            @Property(name = Constants.SERVICE_VENDOR, value = "asd"),
            @Property(name = "process.label", value = "My Sample Workflow Process")})

            public class CreateAssetWorkflow implements WorkflowProcess {

            private static final Logger log = LoggerFactory.getLogger(CreateAssetWorkflow.class);

            //private SlingRepository repository;
                private SlingRepository repository;

              public void execute(WorkItem item, WorkflowSession arg1, MetaDataMap arg2)
               throws WorkflowException {


              // TODO Auto-generated method stub
               Session session = null;
               log.info("In Execute metod after session::");
                 session = this.repository.loginAdministrative(null);
                 System.out.println("Session Obtained::"+session.getUserID());

                  Node node=session.getNode("/content/dam/abc");


                  node.addNode("xyz","sling:OrdererdFolder"); //name of the node & primary type 
                  node.addNode("123","sling:OrdererdFolder"); //name of the node &primary type


                  catch(Exception e)



            The error message in the inbox is

            Process implementation not found com.abc.CreateAssetWorkflow


            Also from the error log below is the msg


            bundle FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory returned null.) org.osgi.framework.ServiceException: Service factory returned null.

            at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistratio nImpl.java:341)

            at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.jav a:219)

            at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:310)

            at org.apache.felix.framework.Felix.getService(Felix.java:3490)