use of com.alliander.osgp.shared.exceptionhandling.OsgpException in project Protocol-Adapter-IEC61850 by OSGP.
the class PublicLightingGetPowerUsageHistoryRequestMessageProcessor method handleGetPowerUsageHistoryDeviceResponse.
private void handleGetPowerUsageHistoryDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount, final int messagePriority, final Long scheduleTime) {
final GetPowerUsageHistoryDeviceResponse getPowerUsageHistoryDeviceResponse = (GetPowerUsageHistoryDeviceResponse) deviceResponse;
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainer = null;
try {
powerUsageHistoryResponseMessageDataContainer = new PowerUsageHistoryResponseMessageDataContainerDto(getPowerUsageHistoryDeviceResponse.getPowerUsageHistoryData());
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.PROTOCOL_IEC61850, "Unexpected exception while retrieving response message", e);
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, messagePriority, scheduleTime);
final ProtocolResponseMessage.Builder builder = new ProtocolResponseMessage.Builder();
final ProtocolResponseMessage responseMessage = builder.domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(powerUsageHistoryResponseMessageDataContainer).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.exceptionhandling.OsgpException in project Protocol-Adapter-IEC61850 by OSGP.
the class CommonGetConfigurationRequestMessageProcessor method handleGetConfigurationDeviceResponse.
private void handleGetConfigurationDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
ConfigurationDto configuration = null;
try {
final GetConfigurationDeviceResponse response = (GetConfigurationDeviceResponse) deviceResponse;
configuration = response.getConfiguration();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.PROTOCOL_IEC61850, "Unexpected exception while retrieving response message", e);
}
final DeviceMessageMetadata deviceMessageMetaData = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
final ProtocolResponseMessage responseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetaData).result(result).osgpException(osgpException).dataObject(configuration).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.exceptionhandling.OsgpException in project Protocol-Adapter-IEC61850 by OSGP.
the class CommonGetFirmwareRequestMessageProcessor method handleGetFirmwareVersionDeviceResponse.
private void handleGetFirmwareVersionDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
List<FirmwareVersionDto> firmwareVersions = null;
try {
firmwareVersions = ((GetFirmwareVersionDeviceResponse) deviceResponse).getFirmwareVersions();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Unexpected exception while retrieving response message", e);
}
final DeviceMessageMetadata deviceMessageMetaData = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
final ProtocolResponseMessage responseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetaData).result(result).osgpException(osgpException).dataObject((Serializable) firmwareVersions).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.exceptionhandling.OsgpException in project Protocol-Adapter-IEC61850 by OSGP.
the class BaseMessageProcessor method handleDeviceResponse.
/**
* Handles {@link EmptyDeviceResponse} by default. MessageProcessor
* implementations can override this function to handle responses containing
* data.
*/
public void handleDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount, final int messagePriority, final Long scheduleTime) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException ex = null;
try {
final EmptyDeviceResponse response = (EmptyDeviceResponse) deviceResponse;
this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
} catch (final OsgpException e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
ex = e;
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, messagePriority, scheduleTime);
final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).retryCount(retryCount).build();
responseMessageSender.send(protocolResponseMessage);
}
use of com.alliander.osgp.shared.exceptionhandling.OsgpException in project Protocol-Adapter-IEC61850 by OSGP.
the class DaRtuDeviceRequestMessageProcessor method handleDeviceResponse.
/**
* Override to include the data in the response
*/
@Override
public void handleDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount, final int messagePriority, final Long scheduleTime) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException ex = null;
Serializable dataObject = null;
try {
final DaDeviceResponse response = (DaDeviceResponse) deviceResponse;
this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
dataObject = response.getDataResponse();
} catch (final OsgpException e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
ex = e;
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, messagePriority, scheduleTime);
final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).dataObject(dataObject).retryCount(retryCount).build();
responseMessageSender.send(protocolResponseMessage);
}
Aggregations