Search in sources :

Example 91 with MessageMetadata

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

the class CommonStopDeviceTestRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing common stop device test request message");
    MessageMetadata messageMetadata;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        return;
    }
    this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
    final DeviceRequest deviceRequest = DeviceRequest.newBuilder().messageMetaData(messageMetadata).build();
    this.deviceService.stopSelfTest(deviceRequest);
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) JMSException(javax.jms.JMSException) DeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceRequest)

Example 92 with MessageMetadata

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

the class CommonUpdateFirmwareRequestMessageProcessor method processMessage.

// IDEA: the FirmwareLocation class in domain and dto can/must be deleted!
// Or, this
// setup has to be changed in order to reuse the FirmwareLocation class in
// the domain!!
@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing common update firmware request message");
    MessageMetadata messageMetadata;
    FirmwareUpdateMessageDataContainer firmwareUpdateMessageDataContainer;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        firmwareUpdateMessageDataContainer = (FirmwareUpdateMessageDataContainer) message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        return;
    }
    try {
        final String firmwareIdentification = firmwareUpdateMessageDataContainer.getFirmwareUrl();
        this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
        final UpdateFirmwareDeviceRequest deviceRequest = new UpdateFirmwareDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), this.firmwareLocation.getDomain(), this.firmwareLocation.getFullPath(firmwareIdentification));
        this.deviceService.updateFirmware(deviceRequest);
    } catch (final RuntimeException e) {
        this.handleError(e, messageMetadata);
    }
}
Also used : UpdateFirmwareDeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.UpdateFirmwareDeviceRequest) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) FirmwareUpdateMessageDataContainer(org.opensmartgridplatform.dto.valueobjects.FirmwareUpdateMessageDataContainer) JMSException(javax.jms.JMSException)

Example 93 with MessageMetadata

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

the class DeviceRequestMessageListener method sendException.

private void sendException(final ObjectMessage objectMessage, final Exception exception, final String errorMessage) {
    try {
        final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
        final OsgpException osgpException = new OsgpException(ComponentType.PROTOCOL_OSLP, errorMessage, exception);
        final Serializable dataObject = objectMessage.getObject();
        final MessageMetadata messageMetadata = MessageMetadata.fromMessage(objectMessage).builder().withScheduled(false).build();
        final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(osgpException).dataObject(dataObject).build();
        this.deviceResponseMessageSender.send(protocolResponseMessage);
    } catch (final Exception e) {
        LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) Serializable(java.io.Serializable) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) NotSupportedException(org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException)

Example 94 with MessageMetadata

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

the class PublicLightingSetTransitionRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing public lighting set transition request message");
    MessageMetadata messageMetadata;
    TransitionMessageDataContainerDto transitionMessageDataContainer;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        transitionMessageDataContainer = (TransitionMessageDataContainerDto) message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        return;
    }
    try {
        this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
        final SetTransitionDeviceRequest deviceRequest = new SetTransitionDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), transitionMessageDataContainer);
        this.deviceService.setTransition(deviceRequest);
    } catch (final RuntimeException e) {
        this.handleError(e, messageMetadata);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) TransitionMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.TransitionMessageDataContainerDto) SetTransitionDeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetTransitionDeviceRequest) JMSException(javax.jms.JMSException)

Example 95 with MessageMetadata

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

the class TariffSwitchingSetScheduleRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing tariff switching set schedule request message");
    MessageMetadata messageMetadata;
    ScheduleDto schedule;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        schedule = (ScheduleDto) message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        return;
    }
    try {
        final ScheduleMessageDataContainerDto scheduleMessageDataContainer = new ScheduleMessageDataContainerDto.Builder(schedule).build();
        this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
        final SetScheduleDeviceRequest deviceRequest = new SetScheduleDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), scheduleMessageDataContainer, RelayTypeDto.TARIFF);
        this.deviceService.setSchedule(deviceRequest);
    } catch (final RuntimeException e) {
        this.handleError(e, messageMetadata);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ScheduleMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto) SetScheduleDeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetScheduleDeviceRequest) JMSException(javax.jms.JMSException) ScheduleDto(org.opensmartgridplatform.dto.valueobjects.ScheduleDto)

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