use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.GetDevicesResponse 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;
}
Aggregations