public void addDynamicTask(String containerId, String caseId, String stageId, String payload, String marshallingType) { verifyContainerId(containerId, caseId); logger.debug("About to unmarshal task specification content from payload: '{}'", payload); Map<String, Object> taskSpecificationMap = marshallerHelper.unmarshal(containerId, payload, marshallingType, Map.class, new ByCaseIdContainerLocator(caseId)); TaskSpecification taskSpecification = null; if (taskSpecificationMap == null || taskSpecificationMap.isEmpty()) { throw new IllegalArgumentException("Task specification must be given"); } String nodeType = (String) taskSpecificationMap.get(CASE_DYNAMIC_NODE_TYPE_PROP); if (nodeType != null) { logger.debug("Creating dynamic task of typ {} within case {}", nodeType, caseId); taskSpecification = caseService.newTaskSpec(nodeType, (String) taskSpecificationMap.get(CASE_DYNAMIC_NAME_PROP), (Map<String, Object>) taskSpecificationMap.get(CASE_DYNAMIC_DATA_PROP)); } else { logger.debug("Creating dynamic user task for case {}", caseId); taskSpecification = caseService.newHumanTaskSpec((String) taskSpecificationMap.get(CASE_DYNAMIC_NAME_PROP), (String) taskSpecificationMap.get(CASE_DYNAMIC_DESC_PROP), (String) taskSpecificationMap.get(CASE_DYNAMIC_ACTORS_PROP), (String) taskSpecificationMap.get(CASE_DYNAMIC_GROUPS_PROP), (Map<String, Object>) taskSpecificationMap.get(CASE_DYNAMIC_DATA_PROP)); } logger.debug("Complete task specification is '{}'", taskSpecification); if (stageId != null && !stageId.isEmpty()) { logger.debug("Adding dynamic task to stage {} within case {}", stageId, caseId); caseService.addDynamicTaskToStage(caseId, stageId, taskSpecification); } else { logger.debug("Adding dynamic task to case {}", caseId); caseService.addDynamicTask(caseId, taskSpecification); } }