Search in sources :

Example 1 with FirmwareUpdateMessageDataContainer

use of org.opensmartgridplatform.dto.valueobjects.FirmwareUpdateMessageDataContainer 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 2 with FirmwareUpdateMessageDataContainer

use of org.opensmartgridplatform.dto.valueobjects.FirmwareUpdateMessageDataContainer in project open-smart-grid-platform by OSGP.

the class CommonUpdateFirmwareRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    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;
    }
    final RequestMessageData requestMessageData = RequestMessageData.newBuilder().messageMetadata(messageMetadata).build();
    this.printDomainInfo(requestMessageData);
    final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
    final DeviceRequest.Builder deviceRequestBuilder = DeviceRequest.newBuilder().messageMetaData(messageMetadata);
    this.deviceService.updateFirmware(new UpdateFirmwareDeviceRequest(deviceRequestBuilder, this.firmwareLocation.getDomain(), this.firmwareLocation.getFullPath(firmwareUpdateMessageDataContainer.getFirmwareUrl()), firmwareUpdateMessageDataContainer.getFirmwareModuleData()), iec61850DeviceResponseHandler);
}
Also used : UpdateFirmwareDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.UpdateFirmwareDeviceRequest) Iec61850DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) FirmwareUpdateMessageDataContainer(org.opensmartgridplatform.dto.valueobjects.FirmwareUpdateMessageDataContainer) JMSException(javax.jms.JMSException) DeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest) UpdateFirmwareDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.UpdateFirmwareDeviceRequest) RequestMessageData(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Aggregations

JMSException (javax.jms.JMSException)2 FirmwareUpdateMessageDataContainer (org.opensmartgridplatform.dto.valueobjects.FirmwareUpdateMessageDataContainer)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)1 UpdateFirmwareDeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.UpdateFirmwareDeviceRequest)1 RequestMessageData (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)1 Iec61850DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)1 UpdateFirmwareDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.UpdateFirmwareDeviceRequest)1