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));
}
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;
}
Aggregations