use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class ManagementService method handleGetGsmDiagnosticResponse.
public void handleGetGsmDiagnosticResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType result, final OsgpException osgpException, final GetGsmDiagnosticResponseDto responseDto) {
LOGGER.info("handleGetGsmDiagnosticResponse for MessageType: {}", messageMetadata.getMessageType());
final GetGsmDiagnosticResponseData responseData = this.managementMapper.map(responseDto, GetGsmDiagnosticResponseData.class);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(osgpException).withDataObject(responseData).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class ManagementService method handleSetDeviceLifecycleStatusByChannelResponse.
public void handleSetDeviceLifecycleStatusByChannelResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType result, final OsgpException osgpException, final SetDeviceLifecycleStatusByChannelResponseDto responseDto) {
LOGGER.info("handleSetDeviceLifecycleStatusByChannelResponse for MessageType: {}", messageMetadata.getMessageType());
this.setDeviceLifecycleStatusByChannel(responseDto);
final SetDeviceLifecycleStatusByChannelResponseData responseData = this.managementMapper.map(responseDto, SetDeviceLifecycleStatusByChannelResponseData.class);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(osgpException).withDataObject(responseData).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class ConfigurationServiceTest method handleGetKeysResponse.
@Test
void handleGetKeysResponse() {
// CALL
this.instance.handleGetKeysResponse(messageMetadata, ResponseMessageResultType.OK, null, getKeysResponseDto);
// VERIFY
final GetKeysResponse expectedGetKeysResponse = new GetKeysResponse(Arrays.asList(new GetKeysResponseData(SecretType.E_METER_AUTHENTICATION_KEY, KEY_1), new GetKeysResponseData(SecretType.E_METER_MASTER_KEY, KEY_2)));
final ResponseMessage expectedResponseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withDataObject(expectedGetKeysResponse).withResult(ResponseMessageResultType.OK).build();
verify(this.webServiceResponseMessageSender).send(this.responseMessageCaptor.capture(), eq(MESSAGE_TYPE));
assertThat(this.responseMessageCaptor.getValue()).usingRecursiveComparison().isEqualTo(expectedResponseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class OsgpResponseMessageListener method onMessage.
@Override
public void onMessage(final Message message) {
try {
LOGGER.info("Received message of type: {}", message.getJMSType());
final ObjectMessage objectMessage = (ObjectMessage) message;
final String messageType = objectMessage.getJMSType();
final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
final ResponseMessage responseMessage = (ResponseMessage) objectMessage.getObject();
final String result = responseMessage == null ? null : responseMessage.getResult().toString();
final OsgpException osgpException = responseMessage == null ? null : responseMessage.getOsgpException();
if (MessageType.valueOf(messageType) == (MessageType.REGISTER_DEVICE)) {
handleDeviceRegistration(result, deviceIdentification, messageType, osgpException);
} else {
throw new UnknownMessageTypeException("Unknown JMSType: " + messageType);
}
} catch (final JMSException ex) {
LOGGER.error("Exception: {} ", ex.getMessage(), ex);
} catch (final ProtocolAdapterException e) {
LOGGER.error("ProtocolAdapterException", e);
} catch (final UnknownMessageTypeException e) {
LOGGER.error("UnknownMessageTypeException", e);
}
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class ConfigurationService method handleGetMbusEncryptionKeyStatusResponse.
public void handleGetMbusEncryptionKeyStatusResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType resultType, final OsgpException exception, final GetMbusEncryptionKeyStatusResponseDto getMbusEncryptionKeyStatusResponseDto) {
log.info("handleGetMbusEncryptionKeyStatusResponse for MessageType: {}", messageMetadata.getMessageType());
final String mbusDeviceIdentification = getMbusEncryptionKeyStatusResponseDto.getMbusDeviceIdentification();
final EncryptionKeyStatusType encryptionKeyStatusType = EncryptionKeyStatusType.valueOf(getMbusEncryptionKeyStatusResponseDto.getEncryptionKeyStatus().name());
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata.builder().withDeviceIdentification(mbusDeviceIdentification).build()).withResult(resultType).withOsgpException(exception).withDataObject(encryptionKeyStatusType).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Aggregations