use of org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.UpdateFirmwareAsyncResponse in project open-smart-grid-platform by OSGP.
the class UpdateFirmwareSteps method theUpdateFirmwareAsyncResponseContains.
@Then("^the update firmware async response contains$")
public void theUpdateFirmwareAsyncResponseContains(final Map<String, String> expectedResponseData) throws Throwable {
final UpdateFirmwareAsyncResponse asyncResponse = (UpdateFirmwareAsyncResponse) ScenarioContext.current().get(PlatformPubliclightingKeys.RESPONSE);
assertThat(asyncResponse.getAsyncResponse().getCorrelationUid()).isNotNull();
assertThat(asyncResponse.getAsyncResponse().getDeviceId()).isEqualTo(getString(expectedResponseData, PlatformPubliclightingKeys.KEY_DEVICE_IDENTIFICATION));
// Save the returned CorrelationUid in the Scenario related context for
// further use.
saveCorrelationUidInScenarioContext(asyncResponse.getAsyncResponse().getCorrelationUid(), getString(expectedResponseData, PlatformPubliclightingKeys.KEY_ORGANIZATION_IDENTIFICATION, PlatformPubliclightingDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION));
LOGGER.info("Got CorrelationUid: [" + ScenarioContext.current().get(PlatformPubliclightingKeys.KEY_CORRELATION_UID) + "]");
}
use of org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.UpdateFirmwareAsyncResponse in project open-smart-grid-platform by OSGP.
the class FirmwareManagementEndpoint method updateFirmware.
// === UPDATE FIRMWARE ===
@PayloadRoot(localPart = "UpdateFirmwareRequest", namespace = NAMESPACE)
@ResponsePayload
public UpdateFirmwareAsyncResponse updateFirmware(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateFirmwareRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("UpdateFirmware Request received from organisation {} for device {} with firmware name {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), request.getFirmwareIdentification(), messagePriority);
final UpdateFirmwareAsyncResponse response = new UpdateFirmwareAsyncResponse();
try {
final FirmwareUpdateMessageDataContainer firmwareUpdateMessageDataContainer = this.mapFirmwareModuleTypes(request.getFirmwareIdentification(), request.getFirmwareModuleType());
// Get the request parameters, make sure that they are in UTC.
// Maybe add an adapter to the service, so that all datetime are
// converted to utc automatically.
final DateTime scheduleTime = request.getScheduledTime() == null ? null : new DateTime(request.getScheduledTime().toGregorianCalendar()).toDateTime(DateTimeZone.UTC);
final String correlationUid = this.firmwareManagementService.enqueueUpdateFirmwareRequest(organisationIdentification, request.getDeviceIdentification(), firmwareUpdateMessageDataContainer, scheduleTime, MessagePriorityEnum.getMessagePriority(messagePriority));
final AsyncResponse asyncResponse = new AsyncResponse();
asyncResponse.setCorrelationUid(correlationUid);
asyncResponse.setDeviceId(request.getDeviceIdentification());
response.setAsyncResponse(asyncResponse);
} catch (final ConstraintViolationException e) {
LOGGER.error("Exception updating firmware", e);
this.handleException(e);
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations