Search in sources :

Example 6 with AsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.

the class DeviceManagementEndpoint method setEventNotifications.

@PayloadRoot(localPart = "SetEventNotificationsRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public SetEventNotificationsAsyncResponse setEventNotifications(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetEventNotificationsRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Set EventNotifications Request received from organisation: {} for event device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final SetEventNotificationsAsyncResponse response = new SetEventNotificationsAsyncResponse();
    try {
        final List<EventNotificationType> eventNotifications = new ArrayList<>(this.deviceManagementMapper.mapAsList(request.getEventNotifications(), EventNotificationType.class));
        final String correlationUid = this.deviceManagementService.enqueueSetEventNotificationsRequest(organisationIdentification, request.getDeviceIdentification(), eventNotifications, MessagePriorityEnum.getMessagePriority(messagePriority));
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SetEventNotificationsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetEventNotificationsAsyncResponse) ArrayList(java.util.ArrayList) EventNotificationType(org.opensmartgridplatform.domain.core.valueobjects.EventNotificationType) SetDeviceLifecycleStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceLifecycleStatusAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) SetDeviceVerificationKeyAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceVerificationKeyAsyncResponse) SetEventNotificationsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetEventNotificationsAsyncResponse) UpdateDeviceCdmaSettingsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse) UpdateDeviceSslCertificationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceSslCertificationAsyncResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) 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)

Example 7 with AsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.

the class DeviceManagementEndpoint method setDeviceAlias.

@PayloadRoot(localPart = "SetDeviceAliasRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public SetDeviceAliasResponse setDeviceAlias(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetDeviceAliasRequest request) throws OsgpException {
    LOGGER.info("Setting device alias for device: {} to: {}.", request.getDeviceIdentification(), request.getDeviceAlias());
    try {
        this.deviceManagementService.setDeviceAlias(organisationIdentification, request.getDeviceIdentification(), request.getDeviceAlias(), request.getDeviceOutputSettings());
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
    } catch (final Exception e) {
        LOGGER.error(EXCEPTION_WHILE_UPDATING_DEVICE, e.getMessage(), request.getDeviceIdentification(), organisationIdentification, e);
        this.handleException(e);
    }
    final SetDeviceAliasResponse setDeviceAliasResponse = new SetDeviceAliasResponse();
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, request.getDeviceIdentification());
    final AsyncResponse asyncResponse = new AsyncResponse();
    asyncResponse.setCorrelationUid(correlationUid);
    asyncResponse.setDeviceId(request.getDeviceIdentification());
    setDeviceAliasResponse.setAsyncResponse(asyncResponse);
    try {
        this.notificationService.sendNotification(organisationIdentification, request.getDeviceIdentification(), null, null, null, NotificationType.DEVICE_UPDATED);
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return setDeviceAliasResponse;
}
Also used : SetDeviceAliasResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceAliasResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) SetDeviceLifecycleStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceLifecycleStatusAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) SetDeviceVerificationKeyAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceVerificationKeyAsyncResponse) SetEventNotificationsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetEventNotificationsAsyncResponse) UpdateDeviceCdmaSettingsAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse) UpdateDeviceSslCertificationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceSslCertificationAsyncResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) 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)

Example 8 with AsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.

the class DeviceInstallationEndpoint method getStatus.

@PayloadRoot(localPart = "GetStatusRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public GetStatusAsyncResponse getStatus(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetStatusRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Get Status received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final GetStatusAsyncResponse response = new GetStatusAsyncResponse();
    try {
        final String correlationUid = this.deviceInstallationService.enqueueGetStatusRequest(organisationIdentification, request.getDeviceIdentification(), MessagePriorityEnum.getMessagePriority(messagePriority));
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : GetStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.GetStatusAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) StartDeviceTestAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StartDeviceTestAsyncResponse) GetStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.GetStatusAsyncResponse) StopDeviceTestAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StopDeviceTestAsyncResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) 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)

Example 9 with AsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.

the class FirmwareManagementEndpoint method switchFirmware.

@PayloadRoot(localPart = "SwitchFirmwareRequest", namespace = NAMESPACE)
@ResponsePayload
public SwitchFirmwareAsyncResponse switchFirmware(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SwitchFirmwareRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Switch Firmware Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final SwitchFirmwareAsyncResponse response = new SwitchFirmwareAsyncResponse();
    try {
        final String correlationUid = this.firmwareManagementService.enqueueSwitchFirmwareRequest(organisationIdentification, request.getDeviceIdentification(), String.valueOf(request.getVersion()), 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 switch firmware", e);
        this.handleException(e);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SwitchFirmwareAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.SwitchFirmwareAsyncResponse) ConstraintViolationException(javax.validation.ConstraintViolationException) 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) 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)

Example 10 with AsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.

the class FirmwareManagementEndpoint method getFirmwareVersion.

// === GET FIRMWARE VERSION ===
@PayloadRoot(localPart = "GetFirmwareVersionRequest", namespace = NAMESPACE)
@ResponsePayload
public GetFirmwareVersionAsyncResponse getFirmwareVersion(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetFirmwareVersionRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("GetFirmwareVersion Request received from organisation {} for device {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final GetFirmwareVersionAsyncResponse response = new GetFirmwareVersionAsyncResponse();
    try {
        final AsyncResponse asyncResponse = new AsyncResponse();
        final String correlationUid = this.firmwareManagementService.enqueueGetFirmwareRequest(organisationIdentification, request.getDeviceIdentification(), MessagePriorityEnum.getMessagePriority(messagePriority));
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final ConstraintViolationException e) {
        LOGGER.error("Exception getting firmware version", e);
        this.handleException(e);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : GetFirmwareVersionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionAsyncResponse) ConstraintViolationException(javax.validation.ConstraintViolationException) 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) 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

AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse)15 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)15 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)15 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)15 ConstraintViolationException (javax.validation.ConstraintViolationException)14 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)14 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)11 SetDeviceLifecycleStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceLifecycleStatusAsyncResponse)5 SetDeviceVerificationKeyAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceVerificationKeyAsyncResponse)5 SetEventNotificationsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetEventNotificationsAsyncResponse)5 UpdateDeviceCdmaSettingsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse)5 UpdateDeviceSslCertificationAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceSslCertificationAsyncResponse)5 GetConfigurationAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncResponse)3 SetConfigurationAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncResponse)3 SwitchConfigurationAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SwitchConfigurationAsyncResponse)3 GetStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.GetStatusAsyncResponse)3 StartDeviceTestAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StartDeviceTestAsyncResponse)3 StopDeviceTestAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StopDeviceTestAsyncResponse)3 GetFirmwareVersionAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionAsyncResponse)3 SwitchFirmwareAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.SwitchFirmwareAsyncResponse)3