use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable response) throws OsgpException {
if (!(response instanceof ResponseMessage)) {
throw new ProtocolAdapterException("Invalid response type, expected ResponseMessage object.");
}
final ResponseMessage responseMessage = (ResponseMessage) response;
if (ResponseMessageResultType.OK.equals(responseMessage.getResult())) {
final FirmwareFileDto firmwareFileDto = (FirmwareFileDto) responseMessage.getDataObject();
final MessageMetadata messageMetadata = this.messageMetadataFromResponseMessage(responseMessage);
return this.firmwareService.updateFirmware(conn, device, firmwareFileDto, messageMetadata);
} else {
throw new ProtocolAdapterException("Get Firmware File failed.", responseMessage.getOsgpException());
}
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method setsIpAddressFromMessageMetadataIfIpAddressIsStatic.
@Test
void setsIpAddressFromMessageMetadataIfIpAddressIsStatic() throws Exception {
final String ipAddress = IP_ADDRESS;
final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withIpAddress(null).withIpAddressStatic(true).build();
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withIpAddress(ipAddress).build();
this.domainHelperService.setIpAddressFromMessageMetadataOrSessionProvider(dlmsDevice, messageMetadata);
assertThat(dlmsDevice.getIpAddress()).isEqualTo(ipAddress);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DlmsChannelHandlerServer method processPushedAlarm.
private void processPushedAlarm(final DlmsPushNotification message, final String correlationId, final String deviceIdentification, final String ipAddress) {
this.logMessage(message);
final PushNotificationAlarmDto pushNotificationAlarm = new PushNotificationAlarmDto(deviceIdentification, message.getAlarms(), message.toByteArray());
final RequestMessage requestMessage = new RequestMessage(correlationId, "no-organisation", deviceIdentification, ipAddress, null, null, pushNotificationAlarm);
final MessageMetadata messageMetadata = new Builder().withMessagePriority(MessagePriorityEnum.HIGH.getPriority()).build();
log.info("Sending push notification alarm to GXF with correlation ID: {}", correlationId);
this.osgpRequestMessageSender.send(requestMessage, MessageType.PUSH_NOTIFICATION_ALARM.name(), messageMetadata);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DeviceRegistrationCompletedMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
final MessageMetadata metadata = MessageMetadata.fromMessage(message);
LOGGER.info("Received message of messageType: {} organisationIdentification: {} deviceIdentification: {}", this.messageType, metadata.getOrganisationIdentification(), metadata.getDeviceIdentification());
this.deviceRegistrationMessageService.sendRequestMessageToDomainCore(metadata.getDeviceIdentification(), metadata.getOrganisationIdentification(), metadata.getCorrelationUid(), MessageType.DEVICE_REGISTRATION_COMPLETED);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
MessageMetadata metadata = null;
Device device = null;
String firmwareFileIdentification = StringUtils.EMPTY;
try {
metadata = MessageMetadata.fromMessage(message);
LOGGER.info("[{}] - Received message of messageType: {}, organisationIdentification: {}, deviceIdentification: {}", metadata.getCorrelationUid(), metadata.getMessageType(), metadata.getOrganisationIdentification(), metadata.getDeviceIdentification());
device = this.deviceRepository.findByDeviceIdentification(metadata.getDeviceIdentification());
final RequestMessage requestMessage = (RequestMessage) message.getObject();
final UpdateFirmwareRequestDto updateFirmwareRequestDto = (UpdateFirmwareRequestDto) requestMessage.getRequest();
firmwareFileIdentification = updateFirmwareRequestDto.getFirmwareIdentification();
final FirmwareFile firmwareFile = this.firmwareFileRepository.findByIdentificationOnly(firmwareFileIdentification);
final FirmwareFileDto firmwareFileDto = new FirmwareFileDto(firmwareFileIdentification, updateFirmwareRequestDto.getDeviceIdentification(), firmwareFile.getFile(), firmwareFile.getImageIdentifier());
this.sendSuccesResponse(metadata, device.getProtocolInfo(), firmwareFileDto);
} catch (final Exception e) {
LOGGER.error("Exception while retrieving firmware file: {}", firmwareFileIdentification);
final OsgpException osgpException = new OsgpException(ComponentType.OSGP_CORE, "Exception while retrieving firmware file.", e);
this.sendFailureResponse(metadata, device.getProtocolInfo(), osgpException);
}
}
Aggregations