Search in sources :

Example 46 with ValidationException

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

the class DeviceManagementEndpoint method updateDeviceSslCertification.

@PayloadRoot(localPart = "UpdateDeviceSslCertificationRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public UpdateDeviceSslCertificationAsyncResponse updateDeviceSslCertification(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateDeviceSslCertificationRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Update Device Ssl Certification Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final UpdateDeviceSslCertificationAsyncResponse response = new UpdateDeviceSslCertificationAsyncResponse();
    try {
        final Certification certification = this.deviceManagementMapper.map(request.getCertification(), Certification.class);
        final String correlationUid = this.deviceManagementService.enqueueUpdateDeviceSslCertificationRequest(organisationIdentification, request.getDeviceIdentification(), certification, 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) 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) UpdateDeviceSslCertificationAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdateDeviceSslCertificationAsyncResponse) Certification(org.opensmartgridplatform.domain.core.valueobjects.Certification) 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 47 with ValidationException

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

the class DeviceManagementEndpoint method setDeviceVerificationKey.

@PayloadRoot(localPart = "SetDeviceVerificationKeyRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public SetDeviceVerificationKeyAsyncResponse setDeviceVerificationKey(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetDeviceVerificationKeyRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Set Device Verification Key Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final SetDeviceVerificationKeyAsyncResponse response = new SetDeviceVerificationKeyAsyncResponse();
    try {
        final String correlationUid = this.deviceManagementService.enqueueSetDeviceVerificationKeyRequest(organisationIdentification, request.getDeviceIdentification(), request.getVerificationKey(), 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) SetDeviceVerificationKeyAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.SetDeviceVerificationKeyAsyncResponse) 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)

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