Chapter 17. Implementing event notification 285
17.4 Implementing the setEventStatus() method
The setEventStatus() method sets the status of an event in the event store. It:
Checks that the status value is valid and throws the
InvalidStatusChangeException exception if it is not.
Changes the status of the event that is identified by eventID in the event store.
Example 17-5 shows the setEventStatus() method implementation for the
RMEventStore.
Example 17-5 The setEventStatus() method
public void setEventStatus(String eventID, int status) throws
InvalidStatusChangeException {
RMLogger.trace(CWConnectorUtil.LEVEL4, "Entering setEventStatus");
// obtain connection from connection pool
RMServerRMIInterface connection;
try {
connection = (RMServerRMIInterface) connectionPool.getConnection();
} catch (Exception e) {
CWConnectorExceptionObject c = new CWConnectorExceptionObject();
c.setMsg("Unable to obtain connection to the application");
c.setStatus(CWConnectorConstant.APPRESPONSETIMEOUT);
throw new InvalidStatusChangeException(c);
}
try {
// set status of event in event table to the status provided
RMDataImplementation aDataImpl =
getRMDataImplementationInstance(eventID, status);
connection.updateObject(aDataImpl);
// free up connection from connection pool
connectionPool.releaseConnection(connection);
} catch (Exception e) {
CWConnectorExceptionObject c = new CWConnectorExceptionObject();
c.setMsg("Unable to delete event from the event table");
c.setStatus(CWConnectorConstant.APPRESPONSETIMEOUT);
throw new InvalidStatusChangeException(c);
}
RMLogger.trace(CWConnectorUtil.LEVEL4, "Exiting setEventStatus");
}