Search in sources :

Example 1 with FirmwareVersionResponse

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionResponse in project open-smart-grid-platform by OSGP.

the class ConfigurationService method handleGetFirmwareVersionResponse.

/**
 * Maps the firmware Dto's to value objects and sends it back to the ws-adapter layer
 *
 * @param messageMetadata contains the message meta data
 * @param deviceResult indicates whether the execution was successful
 * @param exception contains the exception if one was thrown
 * @param firmwareVersionList contains the firmware result list
 */
public void handleGetFirmwareVersionResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final List<FirmwareVersionDto> firmwareVersionList) {
    log.info("handleGetFirmwareVersionResponse for MessageType: {}", messageMetadata.getMessageType());
    ResponseMessageResultType result = deviceResult;
    if (exception != null) {
        log.error("Get firmware version response not ok. Unexpected Exception", exception);
        result = ResponseMessageResultType.NOT_OK;
    }
    final List<FirmwareVersion> firmwareVersions = this.configurationMapper.mapAsList(firmwareVersionList, FirmwareVersion.class);
    final FirmwareVersionResponse firmwareVersionResponse = new FirmwareVersionResponse(firmwareVersions);
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(firmwareVersionResponse).build();
    this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
    this.firmwareService.saveFirmwareVersionsReturnedFromDevice(messageMetadata.getDeviceIdentification(), firmwareVersions);
}
Also used : FirmwareVersionResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionResponse) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) FirmwareVersion(org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)

Example 2 with FirmwareVersionResponse

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionResponse in project open-smart-grid-platform by OSGP.

the class SmartMeteringConfigurationEndpoint method getGetFirmwareVersionResponse.

/**
 * Gets the Firmware version response from the database (if it is there) and returns {@link
 * GetFirmwareVersionResponse} containing those firmware versions.
 *
 * @param organisationIdentification {@link String} containing the identification of the
 *     organization
 * @param request {@link GetFirmwareVersionAsyncRequest} containing the correlation id as the
 *     response identifier
 * @return {@link GetFirmwareVersionResponse} containing the firmware version(s) for the device.
 * @throws OsgpException is thrown when the correlationId cannot be found in the database
 */
@PayloadRoot(localPart = "GetFirmwareVersionAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public GetFirmwareVersionResponse getGetFirmwareVersionResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetFirmwareVersionAsyncRequest request) throws OsgpException {
    log.info("GetFirmwareVersionResponse Request received from organisation {} for device: {}.", organisationIdentification, request.getDeviceIdentification());
    final GetFirmwareVersionResponse response = new GetFirmwareVersionResponse();
    try {
        final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
        if (responseData != null) {
            response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
            if (responseData.getMessageData() != null) {
                final List<FirmwareVersion> target = response.getFirmwareVersion();
                final FirmwareVersionResponse firmwareVersionResponse = (FirmwareVersionResponse) responseData.getMessageData();
                target.addAll(this.configurationMapper.mapAsList(firmwareVersionResponse.getFirmwareVersions(), FirmwareVersion.class));
            } else {
                log.info("Get Firmware Version firmware is null");
            }
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : GetFirmwareVersionResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionResponse) GetKeysResponseData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) GetFirmwareVersionResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionResponse) FirmwareVersionResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionResponse) FirmwareVersion(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.FirmwareVersion) IOException(java.io.IOException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

FirmwareVersionResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionResponse)2 IOException (java.io.IOException)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 FirmwareVersion (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.FirmwareVersion)1 GetFirmwareVersionResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionResponse)1 GetKeysResponseData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData)1 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1