*
* @param newState new state.
* @see #typedState
*/
protected void updateState(State newState) {
State oldState = getPaTypedState();
setPaLastStateTime (new Date());
setPaTypedState (newState);
int auditSel = getPaAuditEventSelection();
// base event information
WfAuditEvent event = auditEventBase
((this instanceof AbstractProcess)
? WfAuditEvent.PROCESS_STATE_CHANGED
: WfAuditEvent.ACTIVITY_STATE_CHANGED);
// Now add general or specific information to the event. Note that we
// must always fire a state audit event if a process closes (see below),
// but we have to add result information only if the event is to be
// published.
if ((this instanceof AbstractProcess)
&& newState.isSameOrSubState(State.CLOSED)
&& (auditSel == ProcessDefinition.AUDIT_SELECTION_ALL_EVENTS
|| auditSel == ProcessDefinition
.AUDIT_SELECTION_STATE_EVENTS_ONLY
|| auditSel == ProcessDefinition
.AUDIT_SELECTION_PROCESS_CLOSED_EVENTS_ONLY)) {
try {
event = new DefaultProcessClosedAuditEvent
(event, oldState.toString(), newState.toString(),
((AbstractProcess)this).result());
} catch (ResultNotAvailableException e) {
// Cannot happen, see implementation
logger.debug ("Unexpected exception: " + e.getMessage(), e);
}
} else {
event = new DefaultStateAuditEvent
(event, oldState.toString(), newState.toString());
}
// Note that process closed events
// (case AUDIT_SELECTION_PROCESS_CLOSED_EVENTS_ONLY) are fired
// because they are handled by the process
if (auditSel == ProcessDefinition.AUDIT_SELECTION_ALL_EVENTS