Search in sources :

Example 1 with AddFirmwareResponse

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

the class AddFirmwareSteps method theAddFirmwareResponseContains.

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

Example 2 with AddFirmwareResponse

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

the class FirmwareManagementEndpoint method addFirmware.

@PayloadRoot(localPart = "AddFirmwareRequest", namespace = NAMESPACE)
@ResponsePayload
public AddFirmwareResponse addFirmware(@OrganisationIdentification final String organisationIdentification, @RequestPayload final AddFirmwareRequest request) throws OsgpException {
    LOGGER.info("Adding firmware:{}.", request.getFirmware().getFilename());
    final AddFirmwareResponse addFirmwareResponse = new AddFirmwareResponse();
    try {
        final FirmwareModuleData firmwareModuleData = this.firmwareManagementMapper.map(request.getFirmware().getFirmwareModuleData(), FirmwareModuleData.class);
        // The AddFirmwareRequest 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());
        this.firmwareManagementService.addFirmware(organisationIdentification, this.firmwareFileRequestFor(request.getFirmware()), request.getFirmware().getFile(), manufacturer, modelCode, firmwareModuleData);
    } catch (final ConstraintViolationException e) {
        LOGGER.error("Exception adding firmware ", e);
        this.handleException(e);
    } catch (final FunctionalException e) {
        LOGGER.error("Exception adding firmware: {} ", e.getMessage(), e);
        if (FunctionalExceptionType.EXISTING_FIRMWARE == e.getExceptionType()) {
            addFirmwareResponse.setResult(OsgpResultType.NOT_OK);
            addFirmwareResponse.setDescription(ADD_FIRMWARE_EXISTING_FIRMWARE);
            return addFirmwareResponse;
        }
        this.handleException(e);
    } catch (final Exception e) {
        LOGGER.error("Exception: {} while adding firmware: {} for organisation {}", e.getMessage(), request.getFirmware().getFilename(), organisationIdentification, e);
        this.handleException(e);
    }
    addFirmwareResponse.setResult(OsgpResultType.OK);
    return addFirmwareResponse;
}
Also used : FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) AddFirmwareResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.AddFirmwareResponse) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

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