use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageListener method sendException.
private void sendException(final ObjectMessage objectMessage, final Exception exception) {
try {
final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
final FunctionalException osgpException = new FunctionalException(FunctionalExceptionType.UNSUPPORTED_DEVICE_ACTION, ComponentType.PROTOCOL_IEC61850, exception);
final Serializable dataObject = objectMessage.getObject();
final MessageMetadata messageMetadata = MessageMetadata.fromMessage(objectMessage);
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata.builder().withScheduled(false).build()).result(result).osgpException(osgpException).dataObject(dataObject).build();
this.deviceResponseMessageSender.send(protocolResponseMessage);
} catch (final Exception e) {
LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
}
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceResponseMessageService method handleMaxScheduleTimeExceeded.
private void handleMaxScheduleTimeExceeded(final ProtocolResponseMessage message, final FunctionalException maxScheduleTimeExceededException) {
final ProtocolResponseMessage maxScheduleTimeExceededResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(message.messageMetadata()).result(ResponseMessageResultType.NOT_OK).osgpException(maxScheduleTimeExceededException).dataObject(message.getDataObject()).build();
this.domainResponseMessageSender.send(maxScheduleTimeExceededResponseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessor method createUpdateFirmwareRequestDto.
private UpdateFirmwareRequestDto createUpdateFirmwareRequestDto(final Serializable messageObject) {
if (messageObject instanceof ProtocolResponseMessage) {
final ProtocolResponseMessage protocolResponseMessage = (ProtocolResponseMessage) messageObject;
final Serializable dataObject = protocolResponseMessage.getDataObject();
if (dataObject instanceof FirmwareFileDto) {
final FirmwareFileDto firmwareFileDto = (FirmwareFileDto) dataObject;
return new UpdateFirmwareRequestDto(firmwareFileDto.getFirmwareIdentification(), protocolResponseMessage.getDeviceIdentification());
}
}
LOGGER.warn("Firmware Identification not present.");
return null;
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileMessageProcessor method sendSuccesResponse.
private void sendSuccesResponse(final MessageMetadata metadata, final ProtocolInfo protocolInfo, final FirmwareFileDto firmwareFileDto) {
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(metadata).result(ResponseMessageResultType.OK).osgpException(null).dataObject(firmwareFileDto).build();
this.protocolResponseMessageSender.send(responseMessage, DeviceFunction.GET_FIRMWARE_FILE.name(), protocolInfo, metadata);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceResponseMessageServiceTest method testProcessScheduledMessageSuccess.
/**
* test processMessage with a scheduled task that has been successful
*/
@Test
public void testProcessScheduledMessageSuccess() {
final ProtocolResponseMessage message = new ProtocolResponseMessage.Builder().messageMetadata(MESSAGE_METADATA.builder().withScheduled(true).build()).result(ResponseMessageResultType.OK).dataObject(DATA_OBJECT).build();
final ScheduledTask scheduledTask = new ScheduledTask(MESSAGE_METADATA, DOMAIN, DOMAIN_VERSION, DATA_OBJECT, SCHEDULED_TIME);
scheduledTask.setPending();
when(this.scheduledTaskService.findByCorrelationUid(anyString())).thenReturn(scheduledTask);
this.deviceResponseMessageService.processMessage(message);
// check if message is send and task is deleted
verify(this.domainResponseMessageSender).send(message);
verify(this.scheduledTaskService).deleteScheduledTask(scheduledTask);
}
Aggregations