use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException 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();
}
use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException 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;
}
use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.
the class DeviceInstallationEndpoint method getStartDeviceTestResponse.
@PayloadRoot(localPart = "StartDeviceTestAsyncRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public StartDeviceTestResponse getStartDeviceTestResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final StartDeviceTestAsyncRequest request) throws OsgpException {
LOGGER.info("Get Start Device Test Response received from organisation: {} for device: {}.", organisationIdentification, request.getAsyncRequest().getDeviceId());
final StartDeviceTestResponse response = new StartDeviceTestResponse();
try {
final ResponseMessage responseMessage = this.getResponseMessage(request.getAsyncRequest());
if (responseMessage != null) {
throwExceptionIfResultNotOk(responseMessage, "starting device test");
response.setResult(OsgpResultType.fromValue(responseMessage.getResult().getValue()));
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.
the class AdHocManagementEndpoint method getSetRebootResponse.
@PayloadRoot(localPart = "SetRebootAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetRebootResponse getSetRebootResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetRebootAsyncRequest request) throws OsgpException {
LOGGER.info("Get Set Reboot Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
final SetRebootResponse response = new SetRebootResponse();
try {
final ResponseMessage responseMessage = this.getResponseMessage(request.getAsyncRequest());
if (responseMessage != null) {
throwExceptionIfResultNotOk(responseMessage, "rebooting");
response.setResult(OsgpResultType.fromValue(responseMessage.getResult().getValue()));
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException 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;
}
Aggregations