use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.UpdateLightMeasurementDeviceResponse 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();
}
Aggregations