Search in sources :

Example 76 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class ConfigurationService method handleGetKeysResponse.

public void handleGetKeysResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType resultType, final OsgpException exception, final GetKeysResponseDto getKeysResponseDto) {
    log.info("handleGetKeysResponse for MessageType: {}", messageMetadata.getMessageType());
    final List<KeyDto> keys = getKeysResponseDto.getKeys();
    final List<GetKeysResponseData> getKeysResponseData = keys.stream().map(key -> new GetKeysResponseData(SecretType.valueOf(key.getSecretType().name()), key.getSecret())).collect(Collectors.toList());
    final GetKeysResponse getKeysResponse = new GetKeysResponse(getKeysResponseData);
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(resultType).withOsgpException(exception).withDataObject(getKeysResponse).build();
    this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Also used : Arrays(java.util.Arrays) AdministrativeStatusType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AdministrativeStatusType) SpecialDaysRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SpecialDaysRequest) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) SetKeysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Autowired(org.springframework.beans.factory.annotation.Autowired) GetKeysRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysRequestData) SetRandomisationSettingsRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetRandomisationSettingsRequestData) GetConfigurationObjectResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetConfigurationObjectResponse) ChannelDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelDto) AlarmNotifications(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AlarmNotifications) SetKeysRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData) UpdateFirmwareResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.UpdateFirmwareResponse) GetKeysResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponseData) DefinableLoadProfileConfigurationDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DefinableLoadProfileConfigurationDto) GetMbusEncryptionKeyStatusRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMbusEncryptionKeyStatusRequestDto) SetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto) GetMbusEncryptionKeyStatusByChannelRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetMbusEncryptionKeyStatusByChannelRequestData) AdministrativeStatusTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AdministrativeStatusTypeDto) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) GetKeysResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponse) PushSetupSmsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto) FirmwareVersionGasResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionGasResponse) UpdateFirmwareRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.UpdateFirmwareRequestData) FirmwareVersionGasDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionGasDto) Collectors(java.util.stream.Collectors) ActivityCalendar(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActivityCalendar) GetMbusEncryptionKeyStatusByChannelRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMbusEncryptionKeyStatusByChannelRequestDataDto) PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) ConfigurationMapper(org.opensmartgridplatform.adapter.domain.smartmetering.application.mapping.ConfigurationMapper) GetKeysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetKeysRequestDto) SetRandomisationSettingsRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetRandomisationSettingsRequestDataDto) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) AlarmNotificationsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AlarmNotificationsDto) JmsMessageSender(org.opensmartgridplatform.adapter.domain.smartmetering.infra.jms.core.JmsMessageSender) GetMbusEncryptionKeyStatusResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMbusEncryptionKeyStatusResponseDto) GMeterInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto) GetMbusEncryptionKeyStatusByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMbusEncryptionKeyStatusByChannelResponseDto) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) SecretType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SecretType) FunctionalExceptionType(org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType) GetFirmwareVersionQueryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetFirmwareVersionQueryDto) WebServiceResponseMessageSender(org.opensmartgridplatform.adapter.domain.smartmetering.infra.jms.ws.WebServiceResponseMessageSender) SetConfigurationObjectRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest) DefinableLoadProfileConfigurationData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DefinableLoadProfileConfigurationData) Service(org.springframework.stereotype.Service) GetFirmwareVersionQuery(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetFirmwareVersionQuery) Qualifier(org.springframework.beans.factory.annotation.Qualifier) GetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetConfigurationObjectRequestDto) KeyDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.KeyDto) UpdateFirmwareResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareResponseDto) ComponentType(org.opensmartgridplatform.shared.exceptionhandling.ComponentType) EncryptionKeyStatusType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EncryptionKeyStatusType) SetClockConfigurationRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetClockConfigurationRequestDto) UpdateFirmwareRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto) GetConfigurationObjectRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetConfigurationObjectRequest) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto) GatewayDeviceNotSetForMbusDeviceException(org.opensmartgridplatform.domain.smartmetering.exceptions.GatewayDeviceNotSetForMbusDeviceException) SpecialDaysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDaysRequestDto) SecretTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SecretTypeDto) SetClockConfigurationRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetClockConfigurationRequestData) FirmwareVersion(org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion) GetConfigurationObjectResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetConfigurationObjectResponseDto) Device(org.opensmartgridplatform.domain.core.entities.Device) FirmwareVersionResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionResponse) GetKeysResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetKeysResponseDto) SetMbusUserKeyByChannelRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetMbusUserKeyByChannelRequestData) PushSetupSms(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms) SetMbusUserKeyByChannelRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetMbusUserKeyByChannelRequestDataDto) ActivityCalendarDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto) Transactional(org.springframework.transaction.annotation.Transactional) KeyDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.KeyDto) GetKeysResponseData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponseData) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) GetKeysResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponse)

Example 77 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class BaseRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    Object dataObject = null;
    final MessageMetadata messageMetadata = MessageMetadata.fromMessage(message);
    try {
        dataObject = message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("message metadata: {}", messageMetadata);
        return;
    }
    try {
        LOGGER.info("Calling application service function: {}", messageMetadata.getMessageType());
        if (this.messageContainsDataObject()) {
            this.handleMessage(messageMetadata, dataObject);
        } else {
            this.handleMessage(messageMetadata);
        }
    } catch (final Exception e) {
        this.handleError(e, messageMetadata);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) JMSException(javax.jms.JMSException) JMSException(javax.jms.JMSException)

Example 78 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class DomainHelperServiceTest method setsIpAddressFromSessionProviderIfIpAddressIsNotStatic.

@Test
void setsIpAddressFromSessionProviderIfIpAddressIsNotStatic() throws Exception {
    final String communicationProvider = "comm-prov";
    final String iccId = "icc-id";
    final String ipAddress = IP_ADDRESS;
    this.whenSessionProviderReturnsIpAddressAfterWakeUp(communicationProvider, iccId, ipAddress);
    final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withIpAddressStatic(false).withCommunicationProvider(communicationProvider).setIccId(iccId).build();
    final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withIpAddress(null).build();
    this.domainHelperService.setIpAddressFromMessageMetadataOrSessionProvider(dlmsDevice, messageMetadata);
    assertThat(dlmsDevice.getIpAddress()).isEqualTo(ipAddress);
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Test(org.junit.jupiter.api.Test)

Example 79 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class DomainHelperServiceTest method findDlmsDeviceMetadataNotFound.

@Test
void findDlmsDeviceMetadataNotFound() {
    final MessageMetadata messageMetadata = mock(MessageMetadata.class);
    when(messageMetadata.getDeviceIdentification()).thenReturn(DEVICE_IDENTIFICATION);
    when(this.dlmsDeviceRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(null);
    final FunctionalException exception = assertThrows(FunctionalException.class, () -> {
        this.domainHelperService.findDlmsDevice(messageMetadata);
    });
    assertThat(exception.getExceptionType()).isEqualTo(FunctionalExceptionType.UNKNOWN_DEVICE);
    assertThat(exception.getComponentType()).isEqualTo(ComponentType.PROTOCOL_DLMS);
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Test(org.junit.jupiter.api.Test)

Example 80 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class SystemEventServiceTest method verifyMaxValueNotReachedEvent.

@Test
void verifyMaxValueNotReachedEvent() {
    final DlmsDevice device = new DlmsDeviceBuilder().withInvocationCounter(this.invocationCounterEventThreshold - 1).build();
    final MessageMetadata messageMetadata = new Builder().withOrganisationIdentification("org-id").build();
    this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
    verifyNoInteractions(this.correlationIdProviderService);
    verify(this.osgpRequestMessageSender, never()).send(any(RequestMessage.class), eq(MessageType.SYSTEM_EVENT.name()), any(MessageMetadata.class));
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) DlmsDeviceBuilder(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)147 JMSException (javax.jms.JMSException)65 Device (org.opensmartgridplatform.domain.core.entities.Device)29 Test (org.junit.jupiter.api.Test)25 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)23 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)22 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)20 RequestMessageData (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)20 Iec61850DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)20 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)19 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)18 CommonRequestMessage (org.opensmartgridplatform.adapter.ws.core.infra.jms.CommonRequestMessage)15 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)14 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)14 ObjectMessage (javax.jms.ObjectMessage)13 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)13 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)13 Serializable (java.io.Serializable)12 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)12 UpdateFirmwareRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto)10