use of org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.UpdateDeviceResponse in project open-smart-grid-platform by OSGP.
the class DeviceInstallationEndpoint method updateDevice.
@PayloadRoot(localPart = "UpdateDeviceRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public UpdateDeviceResponse updateDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateDeviceRequest request) throws OsgpException {
LOGGER.info("Updating device: {}.", request.getDeviceIdentification());
try {
final Ssld device = this.deviceInstallationMapper.map(request.getUpdatedDevice(), Ssld.class);
this.deviceInstallationService.updateDevice(organisationIdentification, device);
} 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.getUpdatedDevice().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 UpdateDeviceResponse();
}
Aggregations