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;
}
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;
}
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;
}
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;
}
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.");
}
}
Aggregations