DataHandler result = null;
try
{
RepositoryService repoService = processEngine.getRepositoryService();
// check if a template exists
String startFormResourceName = getStartFormName(ref.getReferenceId());
if(null==startFormResourceName)
throw new IllegalArgumentException("Process " +ref.getReferenceId() + " doesn't provide a start form");
ProcessDefinition procDef =
repoService
.createProcessDefinitionQuery()
.processDefinitionId(ref.getReferenceId())
.uniqueResult();
InputStream template = repoService.getResourceAsStream(
procDef.getDeploymentId(), startFormResourceName
);
// merge template with process variables
if(template!=null)