use of org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.
the class AdHocManagementEndpoint method getGetDataResponse.
@PayloadRoot(localPart = "GetDataAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetDataResponse getGetDataResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetDataAsyncRequest request) throws OsgpException {
LOGGER.info("Get Data Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
GetDataResponse response = new GetDataResponse();
try {
final org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataResponse dataResponse = this.service.dequeueGetDataResponse(request.getAsyncRequest().getCorrelationUid());
if (dataResponse != null) {
response = this.mapper.map(dataResponse, GetDataResponse.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(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.
the class AdHocManagementEndpoint method getSetDataResponse.
@PayloadRoot(localPart = "SetDataAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetDataResponse getSetDataResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetDataAsyncRequest request) throws OsgpException {
LOGGER.info("Get Set Data Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
final SetDataResponse response = new SetDataResponse();
try {
final EmptyResponse setDataResponse = this.service.dequeueSetDataResponse(request.getAsyncRequest().getCorrelationUid());
if (setDataResponse != null) {
response.setResult(OsgpResultType.OK);
} else {
response.setResult(OsgpResultType.NOT_FOUND);
}
} catch (final ResponseNotFoundException e) {
LOGGER.warn("ResponseNotFoundException for getSetDataResponse", e);
response.setResult(OsgpResultType.NOT_FOUND);
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.
the class MicrogridsService method dequeueSetDataResponse.
public EmptyResponse dequeueSetDataResponse(final String correlationUid) throws OsgpException {
LOGGER.debug("dequeueSetDataRequest called with correlation uid {}", correlationUid);
final ResponseData responseData = this.responseDataService.dequeue(correlationUid, ResponseMessage.class, ComponentType.WS_MICROGRIDS);
final ResponseMessage response = (ResponseMessage) responseData.getMessageData();
switch(response.getResult()) {
case NOT_FOUND:
throw new ResponseNotFoundException(ComponentType.WS_MICROGRIDS, "Response message not found.");
case NOT_OK:
if (response.getOsgpException() != null) {
throw response.getOsgpException();
}
throw new TechnicalException(ComponentType.WS_MICROGRIDS, "Response message not ok.");
case OK:
return new EmptyResponse();
default:
// Should not get here
throw new TechnicalException(ComponentType.WS_MICROGRIDS, "Response message contains invalid result.");
}
}
use of org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.
the class MicrogridsService method dequeueGetDataResponse.
public GetDataResponse dequeueGetDataResponse(final String correlationUid) throws OsgpException {
LOGGER.debug("dequeueGetDataRequest called with correlation uid {}", correlationUid);
final ResponseData responseData = this.responseDataService.dequeue(correlationUid, ResponseMessage.class, ComponentType.WS_MICROGRIDS);
final ResponseMessage response = (ResponseMessage) responseData.getMessageData();
switch(response.getResult()) {
case NOT_FOUND:
throw new ResponseNotFoundException(ComponentType.WS_MICROGRIDS, "Response message not found.");
case NOT_OK:
if (response.getOsgpException() != null) {
throw response.getOsgpException();
}
throw new TechnicalException(ComponentType.WS_MICROGRIDS, "Response message not ok.");
case OK:
return (GetDataResponse) response.getDataObject();
default:
// Should not get here
throw new TechnicalException(ComponentType.WS_MICROGRIDS, "Response message contains invalid result.");
}
}
Aggregations