use of org.kie.internal.task.api.TaskContentService in project jbpm by kiegroup.
the class GetTaskContentCommand method execute.
@SuppressWarnings("unchecked")
public Map<String, Object> execute(Context cntxt) {
TaskContext context = (TaskContext) cntxt;
Task taskById = context.getTaskQueryService().getTaskInstanceById(taskId);
if (taskById == null) {
throw new IllegalStateException("Unable to find task with id " + taskId);
}
TaskContentService contentService = context.getTaskContentService();
Content contentById = contentService.getContentById(taskById.getTaskData().getDocumentContentId());
ContentMarshallerContext mContext = contentService.getMarshallerContext(taskById);
Object unmarshalledObject = ContentMarshallerHelper.unmarshall(contentById.getContent(), mContext.getEnvironment(), mContext.getClassloader());
if (!(unmarshalledObject instanceof Map)) {
logger.debug(" The Task Content is not of type Map, it was: {} so packaging it into new map under Content key ", unmarshalledObject.getClass());
Map<String, Object> content = new HashMap<String, Object>();
content.put("Content", unmarshalledObject);
return content;
}
Map<String, Object> content = (Map<String, Object>) unmarshalledObject;
return content;
}
Aggregations