session,
getLogger(),
document);
if (wfManager.hasWorkflow(workflowable)) {
Version latestVersion = workflowable.getLatestVersion();
if (name.equals(STATE)) {
if (latestVersion == null) {
Workflow workflow = wfManager.getWorkflowSchema(workflowable);
value = workflow.getInitialState();
} else {
value = latestVersion.getState();
}
} else if (name.startsWith(VARIABLE_PREFIX)) {
String variableName = name.substring(VARIABLE_PREFIX.length());
Workflow workflow = wfManager.getWorkflowSchema(workflowable);
String[] variableNames = workflow.getVariableNames();
if (Arrays.asList(variableNames).contains(variableName)) {
if (latestVersion == null) {
value = Boolean.valueOf(workflow.getInitialValue(variableName));
} else {
value = Boolean.valueOf(latestVersion.getValue(variableName));
}
}
} else if (name.startsWith(LAST_USER_PREFIX)) {
String event = name.substring(LAST_USER_PREFIX.length());
Version latestEventVersion = getLatestVersion(workflowable, event);
if (latestEventVersion != null) {
value = latestEventVersion.getUserId();
}
} else if (name.startsWith(LAST_DATE_PREFIX)) {
String event = name.substring(LAST_DATE_PREFIX.length());
Version latestEventVersion = getLatestVersion(workflowable, event);
if (latestEventVersion != null) {
synchronized(lock) {
value = this.DATE_FORMAT.format(latestEventVersion.getDate());
}
}
} else {
throw new ConfigurationException("The attribute [" + name
+ "] is not supported!");