use of cern.laser.source.alarmsysteminterface.impl.configuration.ASIConfiguration in project ACS by ACS-Community.
the class LaserComponent method buildMessage.
/**
* Build the {@link ACSJMSTextMessage} for a given fault state
*
* @param state The fault state
* @param hostName The host name
*
* @see AlarmSystemInterfaceProxy#publish
*/
private TextMessage buildMessage(cern.laser.source.alarmsysteminterface.impl.message.FaultState state, String hostName, String sourceName) throws Exception {
if (state == null) {
throw new IllegalArgumentException("The fault state can't be null");
}
if (hostName == null || hostName.isEmpty()) {
throw new IllegalArgumentException("Invalid host name");
}
if (sourceName == null || sourceName.isEmpty()) {
throw new IllegalArgumentException("Invalid source name");
}
Collection<FaultStateImpl> tempStates = new Vector<FaultStateImpl>();
cern.laser.source.alarmsysteminterface.impl.message.FaultState tempState = new FaultState();
ASIMessage asi_message = ASIMessageHelper.marshal(tempStates);
FaultStates states = new FaultStates();
states.addFaultState(state);
asi_message.setFaultStates(states);
asi_message.setSourceName("ALARM_SYSTEM_SOURCES");
asi_message.setSourceHostname(hostName);
asi_message.setSourceTimestamp(IsoDateFormat.formatCurrentDate());
asi_message.setBackup(false);
Configurator configurator = new Configurator();
ASIConfiguration configuration = configurator.getConfiguration();
asi_message.setVersion(configuration.getASIVersion());
ACSJMSTextMessage tm = new ACSJMSTextMessage(alSysContSvcs);
tm.setText(XMLMessageHelper.marshal(asi_message));
tm.setStringProperty(configuration.getSourceNameProperty(), sourceName);
tm.setStringProperty(configuration.getSourceHostnameProperty(), hostName);
tm.setStringProperty(configuration.getBackupProperty(), String.valueOf(false));
tm.setStringProperty(configuration.getAlarmsNumberProperty(), String.valueOf(1));
return tm;
}
Aggregations