Search in sources :

Example 1 with AddOrChangeFirmwareResponse

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

the class AddOrChangeFirmwareSteps method theAddOrChangeFirmwareResponseContains.

@Then("^the add or change firmware response contains$")
public void theAddOrChangeFirmwareResponseContains(final Map<String, String> expectedResponseData) throws Throwable {
    final AddOrChangeFirmwareResponse response = (AddOrChangeFirmwareResponse) 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) AddOrChangeFirmwareResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.AddOrChangeFirmwareResponse) Then(io.cucumber.java.en.Then)

Example 2 with AddOrChangeFirmwareResponse

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

the class FirmwareManagementEndpoint method addOrChangeFirmware.

@PayloadRoot(localPart = "AddOrChangeFirmwareRequest", namespace = NAMESPACE)
@ResponsePayload
public AddOrChangeFirmwareResponse addOrChangeFirmware(@OrganisationIdentification final String organisationIdentification, @RequestPayload final AddOrChangeFirmwareRequest request) throws OsgpException {
    LOGGER.info("Adding Or changing firmware:{}.", request.getFirmware().getFilename());
    final AddOrChangeFirmwareResponse addOrChangeFirmwareResponse = new AddOrChangeFirmwareResponse();
    try {
        final FirmwareModuleData firmwareModuleData = this.firmwareManagementMapper.map(request.getFirmware().getFirmwareModuleData(), FirmwareModuleData.class);
        final List<org.opensmartgridplatform.domain.core.valueobjects.DeviceModel> deviceModels = new ArrayList<>();
        for (final org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.DeviceModel wsDeviceModel : request.getFirmware().getDeviceModels()) {
            final org.opensmartgridplatform.domain.core.valueobjects.DeviceModel deviceModel = this.firmwareManagementMapper.map(wsDeviceModel, org.opensmartgridplatform.domain.core.valueobjects.DeviceModel.class);
            deviceModels.add(deviceModel);
        }
        this.firmwareManagementService.addOrChangeFirmware(organisationIdentification, this.firmwareFileRequestFor(request.getFirmware()), request.getFirmware().getFile(), deviceModels, firmwareModuleData);
    } catch (final ConstraintViolationException e) {
        LOGGER.error("Exception adding or changing firmware ", e);
        this.handleException(e);
    } catch (final FunctionalException e) {
        LOGGER.error("Exception adding or changing firmware: {} ", e.getMessage(), e);
        if (FunctionalExceptionType.EXISTING_FIRMWARE == e.getExceptionType()) {
            addOrChangeFirmwareResponse.setResult(OsgpResultType.NOT_OK);
            addOrChangeFirmwareResponse.setDescription(ADD_FIRMWARE_EXISTING_FIRMWARE);
            return addOrChangeFirmwareResponse;
        }
        this.handleException(e);
    } catch (final Exception e) {
        LOGGER.error("Exception: {} while adding or changing firmware: {} for organisation {}", e.getMessage(), request.getFirmware().getFilename(), organisationIdentification, e);
        this.handleException(e);
    }
    addOrChangeFirmwareResponse.setResult(OsgpResultType.OK);
    return addOrChangeFirmwareResponse;
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) ArrayList(java.util.ArrayList) AddOrChangeFirmwareResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.AddOrChangeFirmwareResponse) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

AddOrChangeFirmwareResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.AddOrChangeFirmwareResponse)2 Then (io.cucumber.java.en.Then)1 ArrayList (java.util.ArrayList)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType)1 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)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