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