Search in sources :

Example 1 with UpdateFirmwareAsyncResponse

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) + "]");
}
Also used : UpdateFirmwareAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.UpdateFirmwareAsyncResponse) Then(io.cucumber.java.en.Then)

Example 2 with UpdateFirmwareAsyncResponse

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;
}
Also used : FirmwareUpdateMessageDataContainer(org.opensmartgridplatform.domain.core.valueobjects.FirmwareUpdateMessageDataContainer) ConstraintViolationException(javax.validation.ConstraintViolationException) UpdateFirmwareAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.UpdateFirmwareAsyncResponse) SwitchFirmwareAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.SwitchFirmwareAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) GetFirmwareVersionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionAsyncResponse) UpdateFirmwareAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.UpdateFirmwareAsyncResponse) DateTime(org.joda.time.DateTime) 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

UpdateFirmwareAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.UpdateFirmwareAsyncResponse)2 Then (io.cucumber.java.en.Then)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 DateTime (org.joda.time.DateTime)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse)1 GetFirmwareVersionAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionAsyncResponse)1 SwitchFirmwareAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.SwitchFirmwareAsyncResponse)1 FirmwareUpdateMessageDataContainer (org.opensmartgridplatform.domain.core.valueobjects.FirmwareUpdateMessageDataContainer)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