Search in sources :

Example 1 with UpdateFirmwareDeviceRequest

use of org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.UpdateFirmwareDeviceRequest 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)

Aggregations

JMSException (javax.jms.JMSException)1 UpdateFirmwareDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.UpdateFirmwareDeviceRequest)1 FirmwareUpdateMessageDataContainer (org.opensmartgridplatform.dto.valueobjects.FirmwareUpdateMessageDataContainer)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1