Search in sources :

Example 1 with GetDevicesResponse

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;
}
Also used : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) Device(org.opensmartgridplatform.domain.core.entities.Device) ConstraintViolationException(javax.validation.ConstraintViolationException) DevicePage(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.DevicePage) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) GetDevicesResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.GetDevicesResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

ConstraintViolationException (javax.validation.ConstraintViolationException)1 DevicePage (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.DevicePage)1 GetDevicesResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.GetDevicesResponse)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1