Search in sources :

Example 1 with AsyncResponse

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

the class ConfigurationManagementEndpoint method switchConfiguration.

@PayloadRoot(localPart = "SwitchConfigurationRequest", namespace = NAMESPACE)
@ResponsePayload
public SwitchConfigurationAsyncResponse switchConfiguration(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SwitchConfigurationRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Switch Configuration Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final SwitchConfigurationAsyncResponse response = new SwitchConfigurationAsyncResponse();
    try {
        final String correlationUid = this.configurationManagementService.enqueueSwitchConfigurationRequest(organisationIdentification, request.getDeviceIdentification(), String.valueOf(request.getConfigurationBank()), MessagePriorityEnum.getMessagePriority(messagePriority));
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) SwitchConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SwitchConfigurationAsyncResponse) SetConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncResponse) GetConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncResponse) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) SwitchConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SwitchConfigurationAsyncResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with AsyncResponse

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

the class ConfigurationManagementEndpoint method setConfiguration.

@PayloadRoot(localPart = "SetConfigurationRequest", namespace = NAMESPACE)
@ResponsePayload
public SetConfigurationAsyncResponse setConfiguration(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetConfigurationRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Set Configuration Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final SetConfigurationAsyncResponse response = new SetConfigurationAsyncResponse();
    try {
        // Get the request parameters, make sure that they are in UTC.
        // Maybe add an adapter to the service, so that all date-time are
        // converted to UTC automatically.
        final DateTime scheduleTime = request.getScheduledTime() == null ? null : new DateTime(request.getScheduledTime().toGregorianCalendar()).toDateTime(DateTimeZone.UTC);
        final Configuration configuration = this.configurationManagementMapper.map(request.getConfiguration(), Configuration.class);
        final String correlationUid = this.configurationManagementService.enqueueSetConfigurationRequest(organisationIdentification, request.getDeviceIdentification(), configuration, scheduleTime, MessagePriorityEnum.getMessagePriority(messagePriority));
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SetConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) Configuration(org.opensmartgridplatform.domain.core.valueobjects.Configuration) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) SwitchConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SwitchConfigurationAsyncResponse) SetConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.SetConfigurationAsyncResponse) GetConfigurationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncResponse) DateTime(org.joda.time.DateTime) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) 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 3 with AsyncResponse

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

the class DeviceInstallationEndpoint method startDeviceTest.

// === START DEVICE TEST ===
@PayloadRoot(localPart = "StartDeviceTestRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public StartDeviceTestAsyncResponse startDeviceTest(@OrganisationIdentification final String organisationIdentification, @RequestPayload final StartDeviceTestRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Start Device Test Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final StartDeviceTestAsyncResponse response = new StartDeviceTestAsyncResponse();
    try {
        final AsyncResponse asyncResponse = new AsyncResponse();
        final String correlationUid = this.deviceInstallationService.enqueueStartDeviceTestRequest(organisationIdentification, request.getDeviceIdentification(), MessagePriorityEnum.getMessagePriority(messagePriority));
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) 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) StartDeviceTestAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StartDeviceTestAsyncResponse) 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 4 with AsyncResponse

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

the class AdHocManagementEndpoint method setReboot.

// === SET REBOOT ===
@PayloadRoot(localPart = "SetRebootRequest", namespace = NAMESPACE)
@ResponsePayload
public SetRebootAsyncResponse setReboot(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetRebootRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Set Reboot received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final SetRebootAsyncResponse response = new SetRebootAsyncResponse();
    try {
        final String correlationUid = this.adHocManagementService.enqueueSetRebootRequest(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 : SetRebootAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncResponse) SetRebootAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 5 with AsyncResponse

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

the class DeviceManagementEndpoint method updateDevice.

@PayloadRoot(localPart = "UpdateDeviceRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public UpdateDeviceResponse updateDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateDeviceRequest request) throws OsgpException {
    final String deviceToUpdateIdentification = request.getDeviceIdentification();
    LOGGER.info("UpdateDeviceRequest received for device: {} for organisation: {}.", deviceToUpdateIdentification, organisationIdentification);
    try {
        final org.opensmartgridplatform.domain.core.entities.Ssld ssld = this.deviceManagementMapper.map(request.getUpdatedDevice(), org.opensmartgridplatform.domain.core.entities.Ssld.class);
        this.deviceManagementService.updateDevice(organisationIdentification, deviceToUpdateIdentification, ssld);
    } 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(), deviceToUpdateIdentification, organisationIdentification, e);
        this.handleException(e);
    }
    final UpdateDeviceResponse updateDeviceResponse = new UpdateDeviceResponse();
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceToUpdateIdentification);
    final AsyncResponse asyncResponse = new AsyncResponse();
    asyncResponse.setCorrelationUid(correlationUid);
    asyncResponse.setDeviceId(deviceToUpdateIdentification);
    updateDeviceResponse.setAsyncResponse(asyncResponse);
    try {
        this.notificationService.sendNotification(organisationIdentification, deviceToUpdateIdentification, null, null, null, NotificationType.DEVICE_UPDATED);
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return updateDeviceResponse;
}
Also used : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) UpdateDeviceResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceResponse) 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)

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