Search in sources :

Example 11 with ValidationException

use of org.opensmartgridplatform.domain.core.exceptions.ValidationException in project open-smart-grid-platform by OSGP.

the class DeviceManagementEndpoint method setCommunicationNetworkInformation.

@PayloadRoot(localPart = "SetCommunicationNetworkInformationRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public SetCommunicationNetworkInformationResponse setCommunicationNetworkInformation(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetCommunicationNetworkInformationRequest request) throws OsgpException {
    LOGGER.info("SetCommunicationNetworkInformation for organisation: {} and device: {}.", organisationIdentification, request.getDeviceIdentification());
    SetCommunicationNetworkInformationResponse response = null;
    try {
        response = new SetCommunicationNetworkInformationResponse();
        final org.opensmartgridplatform.domain.core.entities.Device updatedDevice = this.deviceManagementService.updateCommunicationNetworkInformation(organisationIdentification, request.getDeviceIdentification(), request.getIpAddress(), request.getBtsId(), request.getCellId());
        response.setResult(OsgpResultType.OK);
        response.setIpAddress(updatedDevice.getIpAddress());
        response.setBtsId(updatedDevice.getBtsId());
        response.setCellId(updatedDevice.getCellId());
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, COMPONENT_TYPE_WS_ADMIN, 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) SetCommunicationNetworkInformationResponse(org.opensmartgridplatform.adapter.ws.schema.admin.devicemanagement.SetCommunicationNetworkInformationResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TransactionSystemException(org.springframework.transaction.TransactionSystemException) 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 12 with ValidationException

use of org.opensmartgridplatform.domain.core.exceptions.ValidationException in project open-smart-grid-platform by OSGP.

the class DeviceManagementEndpoint method findDevicesWhichHaveNoOwner.

@PayloadRoot(localPart = "FindDevicesWhichHaveNoOwnerRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public FindDevicesWhichHaveNoOwnerResponse findDevicesWhichHaveNoOwner(@OrganisationIdentification final String organisationIdentification, @RequestPayload final FindDevicesWhichHaveNoOwnerRequest request) throws OsgpException {
    LOGGER.info("Finding devices which have no owner for organisation: {}.", organisationIdentification);
    final FindDevicesWhichHaveNoOwnerResponse response = new FindDevicesWhichHaveNoOwnerResponse();
    try {
        final List<org.opensmartgridplatform.domain.core.entities.Device> devicesWithoutOwner = this.deviceManagementService.findDevicesWhichHaveNoOwner(organisationIdentification);
        response.getDevices().addAll(this.deviceManagementMapper.mapAsList(devicesWithoutOwner, org.opensmartgridplatform.adapter.ws.schema.admin.devicemanagement.Device.class));
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, COMPONENT_TYPE_WS_ADMIN, 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) FindDevicesWhichHaveNoOwnerResponse(org.opensmartgridplatform.adapter.ws.schema.admin.devicemanagement.FindDevicesWhichHaveNoOwnerResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TransactionSystemException(org.springframework.transaction.TransactionSystemException) 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 13 with ValidationException

use of org.opensmartgridplatform.domain.core.exceptions.ValidationException 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 14 with ValidationException

use of org.opensmartgridplatform.domain.core.exceptions.ValidationException 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 15 with ValidationException

use of org.opensmartgridplatform.domain.core.exceptions.ValidationException in project open-smart-grid-platform by OSGP.

the class DeviceInstallationEndpoint method updateLightMeasurementDevice.

@PayloadRoot(localPart = "UpdateLightMeasurementDeviceRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public UpdateLightMeasurementDeviceResponse updateLightMeasurementDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateLightMeasurementDeviceRequest request) throws OsgpException {
    LOGGER.info("Updating light measurement device: {}.", request.getDeviceIdentification());
    try {
        final LightMeasurementDevice device = this.deviceInstallationMapper.map(request.getUpdatedLightMeasurementDevice(), LightMeasurementDevice.class);
        this.deviceInstallationService.updateLightMeasurementDevice(organisationIdentification, device);
    } catch (final ConstraintViolationException e) {
        LOGGER.error("Exception update Device: {} ", e.getMessage(), 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.getUpdatedLightMeasurementDevice().getDeviceIdentification(), organisationIdentification, e);
        this.handleException(e);
    }
    try {
        this.notificationService.sendNotification(organisationIdentification, request.getDeviceIdentification(), null, null, null, NotificationType.DEVICE_UPDATED);
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return new UpdateLightMeasurementDeviceResponse();
}
Also used : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) LightMeasurementDevice(org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) 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) UpdateLightMeasurementDeviceResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.UpdateLightMeasurementDeviceResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)47 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)47 ConstraintViolationException (javax.validation.ConstraintViolationException)44 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)44 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)44 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)44 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)21 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse)9 TransactionSystemException (org.springframework.transaction.TransactionSystemException)8 Device (org.opensmartgridplatform.domain.core.entities.Device)7 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)6 GetGsmDiagnosticResponseData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.GetGsmDiagnosticResponseData)6 SetDeviceLifecycleStatusByChannelResponseData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.SetDeviceLifecycleStatusByChannelResponseData)6 LightMeasurementDevice (org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice)6 DateTime (org.joda.time.DateTime)4 SetDeviceLifecycleStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceLifecycleStatusAsyncResponse)4 SetDeviceVerificationKeyAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceVerificationKeyAsyncResponse)4 SetEventNotificationsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetEventNotificationsAsyncResponse)4 UpdateDeviceCdmaSettingsAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceCdmaSettingsAsyncResponse)4 UpdateDeviceSslCertificationAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceSslCertificationAsyncResponse)4