use of org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageListener method sendNotSupportedException.
private void sendNotSupportedException(final ObjectMessage objectMessage, final MessageMetadata messageMetadata) {
try {
final Exception exception = new NotSupportedException(ComponentType.PROTOCOL_IEC60870, messageMetadata.getMessageType());
final FunctionalException osgpException = new FunctionalException(FunctionalExceptionType.UNSUPPORTED_DEVICE_ACTION, ComponentType.PROTOCOL_IEC60870, exception);
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata.builder().withScheduled(false).build()).result(ResponseMessageResultType.NOT_OK).osgpException(osgpException).dataObject(objectMessage.getObject()).build();
this.deviceResponseMessageSender.send(protocolResponseMessage);
} catch (final Exception e) {
LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageListener method onMessage.
@Override
public void onMessage(final Message message) {
final ObjectMessage objectMessage = (ObjectMessage) message;
String messageType = null;
final int messagePriority;
try {
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
LOGGER.info("Received message of type: {} with message priority: {}", messageType, messagePriority);
final MessageProcessor processor = this.oslpRequestMessageProcessorMap.getMessageProcessor(objectMessage);
processor.processMessage(objectMessage);
} catch (final JMSException ex) {
LOGGER.error("Unexpected JMSException during onMessage(Message)", ex);
this.sendException(objectMessage, ex, "JMSException while processing message");
} catch (final IllegalArgumentException e) {
LOGGER.error("Unexpected IllegalArgumentException during onMessage(Message)", e);
this.sendException(objectMessage, new NotSupportedException(ComponentType.PROTOCOL_OSLP, messageType), "Unsupported device function: " + messageType);
}
}
Aggregations