use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.
the class SmartMeteringConfigurationEndpoint method retrieveSetAdministrativeStatusResponse.
@PayloadRoot(localPart = "SetAdministrativeStatusAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public SetAdministrativeStatusResponse retrieveSetAdministrativeStatusResponse(@RequestPayload final SetAdministrativeStatusAsyncRequest request) throws OsgpException {
SetAdministrativeStatusResponse response = null;
try {
response = new SetAdministrativeStatusResponse();
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
if (responseData.getMessageData() instanceof String) {
response.setDescription((String) responseData.getMessageData());
}
} 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 SmartMeteringConfigurationEndpoint method getSetClockConfigurationResponse.
@PayloadRoot(localPart = "SetClockConfigurationAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public SetClockConfigurationResponse getSetClockConfigurationResponse(@RequestPayload final SetClockConfigurationAsyncRequest request) throws OsgpException {
SetClockConfigurationResponse response = null;
try {
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
response = new SetClockConfigurationResponse();
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
if (responseData.getMessageData() instanceof String) {
response.setDescription((String) responseData.getMessageData());
}
} 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 SmartMeteringManagementEndpoint method getDevices.
@PayloadRoot(localPart = "GetDevicesRequest", namespace = NAMESPACE)
@ResponsePayload
public GetDevicesResponse getDevices(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetDevicesRequest request) throws OsgpException {
log.info("Get Devices Request received from organisation: {}.", organisationIdentification);
GetDevicesResponse response = null;
try {
response = new GetDevicesResponse();
final Page<Device> page = this.managementService.findAllDevices(organisationIdentification, request.getPage());
final DevicePage devicePage = new DevicePage();
devicePage.setTotalPages(page.getTotalPages());
devicePage.getDevices().addAll(this.managementMapper.mapAsList(page.getContent(), org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.Device.class));
response.setDevicePage(devicePage);
} catch (final ConstraintViolationException e) {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, COMPONENT_WS_SMART_METERING, 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 SmartMeteringManagementEndpoint method getDisableDebuggingResponse.
@PayloadRoot(localPart = "DisableDebuggingAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public DisableDebuggingResponse getDisableDebuggingResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final DisableDebuggingAsyncRequest request) throws OsgpException {
log.info("DisableDebugging response for organisation: {} and device: {}.", organisationIdentification, request.getDeviceIdentification());
DisableDebuggingResponse response = null;
try {
response = new DisableDebuggingResponse();
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
this.throwExceptionIfResultNotOk(responseData, "Disable Debugging");
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
if (responseData.getMessageData() instanceof String) {
response.setDescription((String) responseData.getMessageData());
}
} catch (final ConstraintViolationException e) {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_SMART_METERING, 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 SmartMeteringManagementEndpoint method clearMBusStatusOnAllChannelsResponse.
@PayloadRoot(localPart = "ClearMBusStatusOnAllChannelsAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public ClearMBusStatusOnAllChannelsResponse clearMBusStatusOnAllChannelsResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ClearMBusStatusOnAllChannelsAsyncRequest request) throws OsgpException {
log.info("Clear M-Bus Status On All Channels response for organisation: {} and device: {}.", organisationIdentification, request.getDeviceIdentification());
ClearMBusStatusOnAllChannelsResponse response = null;
try {
response = new ClearMBusStatusOnAllChannelsResponse();
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
this.throwExceptionIfResultNotOk(responseData, "Clear M-Bus Status On All Channels");
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
if (responseData.getMessageData() instanceof String) {
response.setDescription((String) responseData.getMessageData());
}
} catch (final ConstraintViolationException e) {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_SMART_METERING, new ValidationException(e.getConstraintViolations()));
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations