use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData in project open-smart-grid-platform by OSGP.
the class SmartMeteringAdhocEndpoint method getScanMbusChannelsResponse.
@PayloadRoot(localPart = "ScanMbusChannelsAsyncRequest", namespace = SMARTMETER_ADHOC_NAMESPACE)
@ResponsePayload
public ScanMbusChannelsResponse getScanMbusChannelsResponse(@RequestPayload final ScanMbusChannelsAsyncRequest request) throws OsgpException {
ScanMbusChannelsResponse response = null;
try {
response = new ScanMbusChannelsResponse();
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
this.throwExceptionIfResultNotOk(responseData, "retrieving the scan m-bus channels response");
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
final ScanMbusChannelsResponseData scanMbusChannelsResponse = (ScanMbusChannelsResponseData) responseData.getMessageData();
if (ResponseMessageResultType.OK == responseData.getResultType()) {
final List<MbusChannelShortEquipmentIdentifier> channelShortIds = response.getChannelShortIds();
channelShortIds.addAll(this.adhocMapper.mapAsList(scanMbusChannelsResponse.getChannelShortIds(), MbusChannelShortEquipmentIdentifier.class));
} else if (responseData.getMessageData() instanceof OsgpException) {
throw (OsgpException) responseData.getMessageData();
} else if (responseData.getMessageData() instanceof Exception) {
throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Scan M-Bus Channels", (Exception) responseData.getMessageData());
} else {
throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Scan M-Bus Channels", null);
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ScanMbusChannelsResponseData in project open-smart-grid-platform by OSGP.
the class AdhocService method handleScanMbusChannelsResponse.
public void handleScanMbusChannelsResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final ScanMbusChannelsResponseDto resultData) {
LOGGER.debug("handleScanMbusChannelsResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_UNEXPECTED_EXCEPTION, exception);
result = ResponseMessageResultType.NOT_OK;
}
final ScanMbusChannelsResponseData scanMbusChannelsResponseData = this.mapperFactory.getMapperFacade().map(resultData, ScanMbusChannelsResponseData.class);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(scanMbusChannelsResponseData).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Aggregations