Search in sources :

Example 16 with ResponseMessage

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());
}
Also used : ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) GetGsmDiagnosticResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetGsmDiagnosticResponseData)

Example 17 with ResponseMessage

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());
}
Also used : ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) SetDeviceLifecycleStatusByChannelResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetDeviceLifecycleStatusByChannelResponseData)

Example 18 with ResponseMessage

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);
}
Also used : GetKeysResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponseData) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) GetKeysResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponse) Test(org.junit.jupiter.api.Test)

Example 19 with ResponseMessage

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);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) UnknownMessageTypeException(org.opensmartgridplatform.shared.infra.jms.UnknownMessageTypeException)

Example 20 with ResponseMessage

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());
}
Also used : EncryptionKeyStatusType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EncryptionKeyStatusType) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage)

Aggregations

ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)144 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)78 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)66 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)33 JMSException (javax.jms.JMSException)29 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)23 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)20 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)20 ConstraintViolationException (javax.validation.ConstraintViolationException)19 Test (org.junit.jupiter.api.Test)19 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)18 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)16 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)12 ObjectMessage (javax.jms.ObjectMessage)9 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)8 Transactional (org.springframework.transaction.annotation.Transactional)5 ArrayList (java.util.ArrayList)4 Device (org.opensmartgridplatform.domain.core.entities.Device)4 UnknownEntityException (org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException)4 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)4