Search in sources :

Example 71 with MessageMetadata

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

the class UpdateFirmwareRequestMessageProcessorTest method processMessageTaskShouldNotUpdateFirmwareWhenFirmwareFileNotAvailable.

@Test
void processMessageTaskShouldNotUpdateFirmwareWhenFirmwareFileNotAvailable() throws JMSException, OsgpException {
    // Arrange
    final String firmwareIdentification = "unavailable";
    final String deviceIdentification = "unavailableEither";
    final UpdateFirmwareRequestDto updateFirmwareRequestDto = new UpdateFirmwareRequestDto(firmwareIdentification, deviceIdentification);
    final ObjectMessage message = new ObjectMessageBuilder().withObject(updateFirmwareRequestDto).withCorrelationUid("123456").build();
    final MessageMetadata messageMetadata = MessageMetadata.fromMessage(message);
    when(this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)).thenReturn(false);
    // Act
    this.processor.processMessageTasks(message.getObject(), messageMetadata, this.dlmsConnectionManagerMock, this.device);
    // Assert
    verify(this.firmwareService, times(0)).updateFirmware(nullable(DlmsConnectionManager.class), same(this.device), same(updateFirmwareRequestDto), any(MessageMetadata.class));
}
Also used : UpdateFirmwareRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ObjectMessage(javax.jms.ObjectMessage) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) Test(org.junit.jupiter.api.Test)

Example 72 with MessageMetadata

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

the class AdHocManagementService method enqueueSetLightRequest.

public String enqueueSetLightRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Size(min = 1, max = 6) @Valid final List<LightValue> lightValues, final int messagePriority) throws FunctionalException {
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_LIGHT);
    this.domainHelperService.isInMaintenance(device);
    LOGGER.debug("enqueueSetLightRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final LightValueMessageDataContainer lightValueMessageDataContainer = new LightValueMessageDataContainer(lightValues);
    final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_LIGHT.name()).withMessagePriority(messagePriority).build();
    final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(lightValueMessageDataContainer).build();
    this.messageSender.send(message);
    return correlationUid;
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) LightValueMessageDataContainer(org.opensmartgridplatform.domain.core.valueobjects.LightValueMessageDataContainer) Device(org.opensmartgridplatform.domain.core.entities.Device) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) PublicLightingRequestMessage(org.opensmartgridplatform.adapter.ws.publiclighting.infra.jms.PublicLightingRequestMessage)

Example 73 with MessageMetadata

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

the class AdHocManagementService method enqueueResumeScheduleRequest.

public String enqueueResumeScheduleRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Valid final ResumeScheduleData resumeScheduleData, final int messagePriority) throws FunctionalException {
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.RESUME_SCHEDULE);
    this.domainHelperService.isInMaintenance(device);
    LOGGER.debug("enqueueResumeScheduleRequest called with organisation {}, device {} and resumeScheduleData {} ", organisationIdentification, deviceIdentification, resumeScheduleData);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final MessageMetadata deviceMessageMetadata = new Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.RESUME_SCHEDULE.name()).withMessagePriority(messagePriority).build();
    final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(resumeScheduleData).build();
    this.messageSender.send(message);
    return correlationUid;
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) Device(org.opensmartgridplatform.domain.core.entities.Device) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) PublicLightingRequestMessage(org.opensmartgridplatform.adapter.ws.publiclighting.infra.jms.PublicLightingRequestMessage)

Example 74 with MessageMetadata

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

the class SystemEventService method verifySystemEventThresholdReachedEvent.

public void verifySystemEventThresholdReachedEvent(final DlmsDevice device, final MessageMetadata sourceMessageMetadata) {
    if (device.getInvocationCounter() == null || device.getInvocationCounter() < this.invocationCounterEventThreshold) {
        return;
    }
    final String message = String.format("Invocation counter for device %s, has a higher value %s than the threshold configured %s, an event will be published", device.getDeviceIdentification(), device.getInvocationCounter(), this.invocationCounterEventThreshold);
    log.info(message);
    final SystemEventDto systemEventDto = new SystemEventDto(device.getDeviceIdentification(), SystemEventTypeDto.INVOCATION_COUNTER_THRESHOLD_REACHED, new Date(), message);
    final String correlationId = this.correlationIdProviderService.getCorrelationId(sourceMessageMetadata.getOrganisationIdentification(), device.getDeviceIdentification());
    final MessageMetadata messageMetadata = new Builder().withDeviceIdentification(device.getDeviceIdentification()).withCorrelationUid(correlationId).withOrganisationIdentification(sourceMessageMetadata.getOrganisationIdentification()).withIpAddress(sourceMessageMetadata.getIpAddress()).withMessagePriority(MessagePriorityEnum.HIGH.getPriority()).withMessageType(MessageType.SYSTEM_EVENT.name()).withDomain(sourceMessageMetadata.getDomain()).withDomainVersion(sourceMessageMetadata.getDomainVersion()).build();
    final RequestMessage requestMessage = new RequestMessage(messageMetadata, systemEventDto);
    log.info("Sending system event to GXF with correlation ID: {}", correlationId);
    this.osgpRequestMessageSender.send(requestMessage, MessageType.SYSTEM_EVENT.name(), messageMetadata);
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) SystemEventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto) Date(java.util.Date)

Example 75 with MessageMetadata

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

the class ConfigurationService method getKeys.

public void getKeys(final MessageMetadata messageMetadata, final GetKeysRequestData getKeysRequestData) throws FunctionalException {
    log.info("getKeys for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    final List<SecretTypeDto> secretTypes = getKeysRequestData.getSecretTypes().stream().map(secretType -> SecretTypeDto.valueOf(secretType.name())).collect(Collectors.toList());
    final GetKeysRequestDto requestDto = new GetKeysRequestDto(secretTypes);
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
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) GetKeysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetKeysRequestDto) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) SecretTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SecretTypeDto)

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