Search in sources :

Example 1 with ChangeFirmwareResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.ChangeFirmwareResponse in project open-smart-grid-platform by OSGP.

the class ChangeFirmwareSteps method theChangeFirmwareResponseContains.

@Then("^the change firmware response contains$")
public void theChangeFirmwareResponseContains(final Map<String, String> expectedResponseData) throws Throwable {
    final ChangeFirmwareResponse response = (ChangeFirmwareResponse) ScenarioContext.current().get(PlatformCommonKeys.RESPONSE);
    assertThat(response.getResult()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_RESULT, OsgpResultType.class));
}
Also used : OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType) ChangeFirmwareResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.ChangeFirmwareResponse) Then(io.cucumber.java.en.Then)

Example 2 with ChangeFirmwareResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.ChangeFirmwareResponse in project open-smart-grid-platform by OSGP.

the class FirmwareManagementEndpoint method changeFirmware.

@PayloadRoot(localPart = "ChangeFirmwareRequest", namespace = NAMESPACE)
@ResponsePayload
public ChangeFirmwareResponse changeFirmware(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ChangeFirmwareRequest request) throws OsgpException {
    LOGGER.info("Changing firmware:{}.", request.getFirmware().getFilename());
    final FirmwareModuleData firmwareModuleData = this.firmwareManagementMapper.map(request.getFirmware().getFirmwareModuleData(), FirmwareModuleData.class);
    // The ChangeFirmwareRequest accepts multiple DeviceModels to be related to a Firmware.
    // This FirmwareManagementService only accepts ONE for now
    final String manufacturer = this.getManufacturerFromFirmware(request.getFirmware());
    final String modelCode = this.getModelCodeFromFirmware(request.getFirmware());
    try {
        this.firmwareManagementService.changeFirmware(organisationIdentification, request.getId(), this.firmwareFileRequestFor(request.getFirmware()), manufacturer, modelCode, firmwareModuleData);
    } catch (final ConstraintViolationException e) {
        LOGGER.error("Exception Changing firmware", e);
        this.handleException(e);
    } catch (final Exception e) {
        LOGGER.error("Exception: {} while Changing firmware: {} for organisation {}", e.getMessage(), request.getFirmware().getFilename(), organisationIdentification, e);
        this.handleException(e);
    }
    final ChangeFirmwareResponse changeFirmwareResponse = new ChangeFirmwareResponse();
    changeFirmwareResponse.setResult(OsgpResultType.OK);
    return changeFirmwareResponse;
}
Also used : FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ChangeFirmwareResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.ChangeFirmwareResponse) AddOrChangeFirmwareResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.AddOrChangeFirmwareResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

ChangeFirmwareResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.ChangeFirmwareResponse)2 Then (io.cucumber.java.en.Then)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType)1 AddOrChangeFirmwareResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.AddOrChangeFirmwareResponse)1 FirmwareModuleData (org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1