use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class DeviceManagementEndpoint method setEventNotifications.
@PayloadRoot(localPart = "SetEventNotificationsRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public SetEventNotificationsAsyncResponse setEventNotifications(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetEventNotificationsRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Set EventNotifications Request received from organisation: {} for event device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final SetEventNotificationsAsyncResponse response = new SetEventNotificationsAsyncResponse();
try {
final List<EventNotificationType> eventNotifications = new ArrayList<>(this.deviceManagementMapper.mapAsList(request.getEventNotifications(), EventNotificationType.class));
final String correlationUid = this.deviceManagementService.enqueueSetEventNotificationsRequest(organisationIdentification, request.getDeviceIdentification(), eventNotifications, 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;
}
use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class DeviceManagementEndpoint method setDeviceAlias.
@PayloadRoot(localPart = "SetDeviceAliasRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public SetDeviceAliasResponse setDeviceAlias(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetDeviceAliasRequest request) throws OsgpException {
LOGGER.info("Setting device alias for device: {} to: {}.", request.getDeviceIdentification(), request.getDeviceAlias());
try {
this.deviceManagementService.setDeviceAlias(organisationIdentification, request.getDeviceIdentification(), request.getDeviceAlias(), request.getDeviceOutputSettings());
} 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.getDeviceIdentification(), organisationIdentification, e);
this.handleException(e);
}
final SetDeviceAliasResponse setDeviceAliasResponse = new SetDeviceAliasResponse();
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, request.getDeviceIdentification());
final AsyncResponse asyncResponse = new AsyncResponse();
asyncResponse.setCorrelationUid(correlationUid);
asyncResponse.setDeviceId(request.getDeviceIdentification());
setDeviceAliasResponse.setAsyncResponse(asyncResponse);
try {
this.notificationService.sendNotification(organisationIdentification, request.getDeviceIdentification(), null, null, null, NotificationType.DEVICE_UPDATED);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return setDeviceAliasResponse;
}
use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class DeviceInstallationEndpoint method getStatus.
@PayloadRoot(localPart = "GetStatusRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public GetStatusAsyncResponse getStatus(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetStatusRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Get Status received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final GetStatusAsyncResponse response = new GetStatusAsyncResponse();
try {
final String correlationUid = this.deviceInstallationService.enqueueGetStatusRequest(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;
}
use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class FirmwareManagementEndpoint method switchFirmware.
@PayloadRoot(localPart = "SwitchFirmwareRequest", namespace = NAMESPACE)
@ResponsePayload
public SwitchFirmwareAsyncResponse switchFirmware(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SwitchFirmwareRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Switch Firmware Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final SwitchFirmwareAsyncResponse response = new SwitchFirmwareAsyncResponse();
try {
final String correlationUid = this.firmwareManagementService.enqueueSwitchFirmwareRequest(organisationIdentification, request.getDeviceIdentification(), String.valueOf(request.getVersion()), MessagePriorityEnum.getMessagePriority(messagePriority));
final AsyncResponse asyncResponse = new AsyncResponse();
asyncResponse.setCorrelationUid(correlationUid);
asyncResponse.setDeviceId(request.getDeviceIdentification());
response.setAsyncResponse(asyncResponse);
} catch (final ConstraintViolationException e) {
LOGGER.error("Exception switch firmware", e);
this.handleException(e);
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class FirmwareManagementEndpoint method getFirmwareVersion.
// === GET FIRMWARE VERSION ===
@PayloadRoot(localPart = "GetFirmwareVersionRequest", namespace = NAMESPACE)
@ResponsePayload
public GetFirmwareVersionAsyncResponse getFirmwareVersion(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetFirmwareVersionRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("GetFirmwareVersion Request received from organisation {} for device {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final GetFirmwareVersionAsyncResponse response = new GetFirmwareVersionAsyncResponse();
try {
final AsyncResponse asyncResponse = new AsyncResponse();
final String correlationUid = this.firmwareManagementService.enqueueGetFirmwareRequest(organisationIdentification, request.getDeviceIdentification(), MessagePriorityEnum.getMessagePriority(messagePriority));
asyncResponse.setCorrelationUid(correlationUid);
asyncResponse.setDeviceId(request.getDeviceIdentification());
response.setAsyncResponse(asyncResponse);
} catch (final ConstraintViolationException e) {
LOGGER.error("Exception getting firmware version", e);
this.handleException(e);
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations