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