use of cern.laser.source.alarmsysteminterface.impl.message.FaultStates in project ACS by ACS-Community.
the class ASIMessageHelper method unmarshal.
/**
* DOCUMENT ME!
*
* @param asiMessage
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static Collection<FaultState> unmarshal(ASIMessage asiMessage) {
if (asiMessage == null) {
throw (new IllegalArgumentException("ASI message is null"));
}
Collection<FaultState> ret = new ArrayList<FaultState>();
FaultStates generated_states = asiMessage.getFaultStates();
if (generated_states != null) {
for (cern.laser.source.alarmsysteminterface.impl.message.FaultState generated_state : generated_states.getFaultState()) {
ret.add(FaultStateHelper.unmarshal(generated_state));
}
}
return ret;
}
use of cern.laser.source.alarmsysteminterface.impl.message.FaultStates 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;
}
use of cern.laser.source.alarmsysteminterface.impl.message.FaultStates in project ACS by ACS-Community.
the class ASIMessageHelper method marshal.
/**
* DOCUMENT ME!
*
* @param states DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static ASIMessage marshal(Collection states) {
if (states == null) {
throw (new IllegalArgumentException("states collection is null"));
}
ASIMessage asi_message = new ASIMessage();
Iterator iterator = states.iterator();
FaultStates fault_states = new FaultStates();
while (iterator.hasNext()) {
Object ref = iterator.next();
if (ref instanceof FaultState) {
fault_states.addFaultState(FaultStateHelper.marshal((FaultState) ref));
} else {
throw new IllegalArgumentException("collection does not contain FaultState instances");
}
}
asi_message.setFaultStates(fault_states);
return asi_message;
}
Aggregations