Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AEM trigger workflow from Java - Create translation project | AEM Community Blog Seeding

kautuk_sahni
Community Manager
Community Manager

BlogImage.jpg

AEM trigger workflow from Java - Create translation project by Ravi Pampana

Abstract

Triggering workflow from Java and automate the process to create translation project using workflow.

Code snippet

import com.day.cq.workflow.model.WorkflowModel;
import com.day.cq.workflow.WorkflowService;


@Reference

private WorkflowService workflowService;

WorkflowSession wfSession = workflowService.getWorkflowSession(session);
// We can have any workflow model here - For creating language copy I am using create_language_copy workflow.

String workflowName = "/var/workflow/models/wcm-translation/create_language_copy";
// Get the workflow model

WorkflowModel wfModel = wfSession.getModel(workflowName);

String languageEnMasterPath = "master page path";
// Get the workflow data

// Workflow Data - Provide the master language page path from where the language copy to be created
WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", languageEnMasterPath);

// Add meta data values
final Map<String, Object> workflowMetadata = new HashMap<>();
workflowMetadata.put("model", "/etc/workflow/models/wcm-translation/create_language_copy/jcr:content/model");

// If parent pages to be auto created when not present - false to not create
workflowMetadata.put("createNonEmptyAncestors", true);

// Pass true if child pages to be created
workflowMetadata.put("deep", false);
workflowMetadata.put("projectFolderLanguageRefCount", "Count of total language masters available");

// Pass comma separated languages list like en,fr,es etc. For only 1 language pass workflowMetadata.put("language", "fr")
workflowMetadata.put("languageList", "comma separated language list");

//Pass project type - add_structure_only will create only structure no translation will happen
workflowMetadata.put("projectType", "add_structure_only");
workflowMetadata.put("projectTitle", "");

// Run the Workflow.
wfSession.startWorkflow(wfModel, wfData, workflowMetadata);

Read Full Blog

AEM trigger workflow from Java - Create translation project

Q&A

Please use this thread to ask the related questions.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies