* @throws WorkflowException if something goes wrong.
*/
public WorkflowInstanceImpl getInstance() throws WorkflowException {
if (this.instance == null) {
if (!isInitialized()) {
throw new WorkflowException(
"The workflow history has not been initialized: The file ["
+ getHistoryFile() + "] is missing.");
}
WorkflowInstanceImpl instance = createInstance();
NamespaceHelper helper = getNamespaceHelper();
String workflowId = getWorkflowId(helper);
if (null == workflowId) {
throw new WorkflowException("No workflow attribute set in history document!");
}
instance.setWorkflow(workflowId);
restoreState(instance, helper);