package org.enhydra.shark;
import java.util.List;
import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
import org.enhydra.shark.api.client.wfservice.NotConnected;
import org.enhydra.shark.api.internal.eventaudit.EventAuditManagerInterface;
import org.enhydra.shark.api.internal.eventaudit.EventAuditPersistenceInterface;
import org.enhydra.shark.api.internal.eventaudit.StateEventAuditPersistenceObject;
import org.enhydra.shark.api.internal.working.WfExecutionObjectInternal;
import org.enhydra.shark.api.internal.working.WfStateEventAuditInternal;
/**
* WfStateEventAuditImpl - Workflow Event Audit implementation.
*
* @author Sasa Bojanic
*/
public class WfStateEventAuditWrapper extends WfEventAuditWrapper implements
WfStateEventAuditInternal {
protected String oldState;
protected String newState;
protected WfStateEventAuditWrapper(WMSessionHandle shandle,
WfExecutionObjectInternal object,
String eventType,
String oldState,
String newState) throws Exception {
super(shandle, object, eventType);
this.oldState = oldState;
this.newState = newState;
persist(shandle);
}
/**
* Used to create object when restoring it from database.
*/
protected WfStateEventAuditWrapper(WMSessionHandle shandle,
StateEventAuditPersistenceObject po) {
super(shandle, po);
}
public String old_state() throws Exception {
long tStamp = SharkEngineManager.getInstance()
.getCallbackUtilities()
.methodStart(shandle, "WfStateEventAuditWrapper.old_state");
try {
if (!SharkUtilities.checkSession(shandle)) {
throw new NotConnected("The session handle is not valid!");
}
checkSecurity("old_state", null);
return oldState;
} finally {
SharkEngineManager.getInstance()
.getCallbackUtilities()
.methodEnd(shandle, tStamp, "WfStateEventAuditWrapper.old_state", this);
}
}
public String new_state() throws Exception {
long tStamp = SharkEngineManager.getInstance()
.getCallbackUtilities()
.methodStart(shandle, "WfStateEventAuditWrapper.new_state");
try {
if (!SharkUtilities.checkSession(shandle)) {
throw new NotConnected("The session handle is not valid!");
}
checkSecurity("new_state", null);
return newState;
} finally {
SharkEngineManager.getInstance()
.getCallbackUtilities()
.methodEnd(shandle, tStamp, "WfStateEventAuditWrapper.new_state", this);
}
}
public void persist(WMSessionHandle sh) throws Exception {
List eams = SharkEngineManager.getInstance().getEventAuditManagers();
if (eams.size() == 0)
return;
StateEventAuditPersistenceObject po = new StateEventAuditPersistenceObject();
fillPersistentObject(po);
for (int i = 0; i < eams.size(); i++) {
EventAuditManagerInterface eam = (EventAuditManagerInterface) eams.get(i);
eam.persist(sh, po);
}
}
public void refresh() {
//
}
public void delete(WMSessionHandle sh) throws Exception {
//
}
protected void fillPersistentObject(EventAuditPersistenceInterface po) {
super.fillPersistentObject(po);
StateEventAuditPersistenceObject spo = (StateEventAuditPersistenceObject) po;
spo.setOldState(this.oldState);
spo.setNewState(this.newState);
}
protected void restore(EventAuditPersistenceInterface po) {
super.restore(po);
StateEventAuditPersistenceObject spo = (StateEventAuditPersistenceObject) po;
this.oldState = spo.getOldState();
this.newState = spo.getNewState();
}
}
|