DocumentWorkflowable workflowable = new DocumentWorkflowable(getSourceDocument(),
getLogger());
resolver = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
if (resolver.hasWorkflow(workflowable)) {
Workflow workflow = resolver.getWorkflowSchema(workflowable);
String[] variableNames = workflow.getVariableNames();
Version latestVersion = workflowable.getLatestVersion();
Boolean isLive = null;
if (latestVersion != null) {
setParameter(STATE, latestVersion.getState());
if (Arrays.asList(variableNames).contains(ISLIVE)) {
isLive = Boolean.valueOf(latestVersion.getValue(ISLIVE));
}
} else {
setParameter(STATE, workflow.getInitialState());
if (Arrays.asList(variableNames).contains(ISLIVE)) {
isLive = Boolean.valueOf(workflow.getInitialValue(ISLIVE));
}
}
setParameter(ISLIVE, isLive);
} else {
setParameter(STATE, "");