Search in sources :

Example 1 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.

the class MonitoringEndpoint method getMeasurementReport.

@PayloadRoot(localPart = "GetMeasurementReportRequest", namespace = NAMESPACE)
@ResponsePayload
public GetMeasurementReportResponse getMeasurementReport(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetMeasurementReportRequest request) throws OsgpException {
    LOGGER.info("Get Measurement Report Request received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getCorrelationUid());
    final GetMeasurementReportResponse response = new GetMeasurementReportResponse();
    try {
        final org.opensmartgridplatform.domain.da.measurements.MeasurementReport dataResponse = this.service.dequeueMeasurementReport(request.getCorrelationUid());
        if (dataResponse != null) {
            final MeasurementReport report = this.mapper.map(dataResponse, MeasurementReport.class);
            response.setMeasurementReport(report);
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getMeasurementReport", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(LOGGER, e);
    }
    return response;
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) MeasurementReport(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.MeasurementReport) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) GetMeasurementReportResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetMeasurementReportResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.

the class MonitoringEndpoint method getPQValuesPeriodicAsync.

@PayloadRoot(localPart = "GetPQValuesPeriodicAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetPQValuesPeriodicResponse getPQValuesPeriodicAsync(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetPQValuesPeriodicAsyncRequest request) throws OsgpException {
    LOGGER.info("Get PQ Values Periodic Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    GetPQValuesPeriodicResponse response = new GetPQValuesPeriodicResponse();
    try {
        final org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesResponse dataResponse = this.service.dequeueGetPQValuesPeriodicResponse(request.getAsyncRequest().getCorrelationUid());
        if (dataResponse != null) {
            response = this.mapper.map(dataResponse, GetPQValuesPeriodicResponse.class);
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getPQValuesPeriodicAsync", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(LOGGER, e);
    }
    response.setDeviceIdentification(request.getAsyncRequest().getDeviceId());
    return response;
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) GetPQValuesPeriodicResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesPeriodicResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 3 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.

the class MonitoringEndpoint method getPQValuesAsync.

@PayloadRoot(localPart = "GetPQValuesAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetPQValuesResponse getPQValuesAsync(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetPQValuesAsyncRequest request) throws OsgpException {
    LOGGER.info("Get PQ Values Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    GetPQValuesResponse response = new GetPQValuesResponse();
    try {
        final org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesResponse dataResponse = this.service.dequeueGetPQValuesResponse(request.getAsyncRequest().getCorrelationUid());
        if (dataResponse != null) {
            response = this.mapper.map(dataResponse, GetPQValuesResponse.class);
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getGetDataResponse", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(LOGGER, e);
    }
    response.setDeviceIdentification(request.getAsyncRequest().getDeviceId());
    return response;
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) GetPQValuesResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesResponse) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 4 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.

the class AdHocManagementEndpoint method getDeviceModelResponse.

@PayloadRoot(localPart = "GetDeviceModelAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetDeviceModelResponse getDeviceModelResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetDeviceModelAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Device Model Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    GetDeviceModelResponse response = new GetDeviceModelResponse();
    try {
        final org.opensmartgridplatform.domain.da.valueobjects.GetDeviceModelResponse dataResponse = this.service.dequeueGetDeviceModelResponse(request.getAsyncRequest().getCorrelationUid());
        if (dataResponse != null) {
            response = this.mapper.map(dataResponse, GetDeviceModelResponse.class);
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getDeviceModel", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(LOGGER, e);
    }
    response.setDeviceIdentification(request.getAsyncRequest().getDeviceId());
    return response;
}
Also used : GetDeviceModelResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetDeviceModelResponse) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 5 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.

the class DistributionAutomationService method processResponse.

private Serializable processResponse(final String correlationUid) throws OsgpException {
    final ResponseData responseData = this.responseDataService.dequeue(correlationUid, ResponseMessage.class, ComponentType.WS_DISTRIBUTION_AUTOMATION);
    final ResponseMessage response = (ResponseMessage) responseData.getMessageData();
    switch(response.getResult()) {
        case OK:
            if (response.getDataObject() != null) {
                return response.getDataObject();
            }
            // Should not get here
            throw new TechnicalException(ComponentType.WS_DISTRIBUTION_AUTOMATION, "Response message contains no data.");
        case NOT_FOUND:
            throw new ResponseNotFoundException(ComponentType.WS_DISTRIBUTION_AUTOMATION, "Response message not found.");
        case NOT_OK:
            if (response.getOsgpException() != null) {
                throw response.getOsgpException();
            }
            throw new TechnicalException(ComponentType.WS_DISTRIBUTION_AUTOMATION, "Response message not ok.");
        default:
            // Should not get here
            throw new TechnicalException(ComponentType.WS_DISTRIBUTION_AUTOMATION, "Response message contains invalid result.");
    }
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage)

Aggregations

ResponseNotFoundException (org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException)6 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)5 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)5 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)5 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 GetDeviceModelResponse (org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetDeviceModelResponse)1 GetHealthStatusResponse (org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetHealthStatusResponse)1 GetMeasurementReportResponse (org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetMeasurementReportResponse)1 GetPQValuesPeriodicResponse (org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesPeriodicResponse)1 GetPQValuesResponse (org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesResponse)1 MeasurementReport (org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.MeasurementReport)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1