Search in sources :

Example 6 with OsgpException

use of com.alliander.osgp.shared.exceptionhandling.OsgpException in project Protocol-Adapter-IEC61850 by OSGP.

the class OsgpResponseMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        LOGGER.info("Received message of type: {}", message.getJMSType());
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final String messageType = objectMessage.getJMSType();
        final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        final ResponseMessage responseMessage = (ResponseMessage) objectMessage.getObject();
        final String result = responseMessage == null ? null : responseMessage.getResult().toString();
        final OsgpException osgpException = responseMessage == null ? null : responseMessage.getOsgpException();
        if (DeviceFunctionDto.valueOf(messageType).equals(DeviceFunctionDto.REGISTER_DEVICE)) {
            this.handleDeviceRegistration(result, deviceIdentification, messageType, osgpException);
        } else {
            throw new UnknownMessageTypeException("Unknown JMSType: " + messageType);
        }
    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    } catch (final ProtocolAdapterException e) {
        LOGGER.error("ProtocolAdapterException", e);
    } catch (final UnknownMessageTypeException e) {
        LOGGER.error("UnknownMessageTypeException", e);
    }
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) ResponseMessage(com.alliander.osgp.shared.infra.jms.ResponseMessage) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) UnknownMessageTypeException(com.alliander.osgp.shared.infra.jms.UnknownMessageTypeException)

Example 7 with OsgpException

use of com.alliander.osgp.shared.exceptionhandling.OsgpException in project Protocol-Adapter-IEC61850 by OSGP.

the class BaseMessageProcessor method handleUnExpectedError.

public void handleUnExpectedError(final DeviceResponse deviceResponse, final Throwable t, final Serializable messageData, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
    final OsgpException ex = this.ensureOsgpException(t);
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(ex).retryCount(retryCount).dataObject(messageData).scheduled(isScheduled).build();
    this.responseMessageSender.send(protocolResponseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)

Example 8 with OsgpException

use of com.alliander.osgp.shared.exceptionhandling.OsgpException in project Protocol-Adapter-IEC61850 by OSGP.

the class MicrogridsGetDataRequestMessageProcessor method handleGetDataDeviceResponse.

private void handleGetDataDeviceResponse(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;
    GetDataResponseDto dataResponse = null;
    try {
        final GetDataDeviceResponse response = (GetDataDeviceResponse) deviceResponse;
        dataResponse = response.getDataResponse();
    } 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(dataResponse).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) GetDataDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) GetDataResponseDto(com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Aggregations

OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)8 DeviceMessageMetadata (com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)7 ProtocolResponseMessage (com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage)7 ResponseMessageResultType (com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)6 JMSException (javax.jms.JMSException)5 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)4 DaDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.da.rtu.DaDeviceResponse)1 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)1 GetConfigurationDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse)1 GetDataDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse)1 GetPowerUsageHistoryDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetPowerUsageHistoryDeviceResponse)1 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 ConfigurationDto (com.alliander.osgp.dto.valueobjects.ConfigurationDto)1 FirmwareVersionDto (com.alliander.osgp.dto.valueobjects.FirmwareVersionDto)1 PowerUsageHistoryResponseMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto)1 GetDataResponseDto (com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto)1 ResponseMessage (com.alliander.osgp.shared.infra.jms.ResponseMessage)1 UnknownMessageTypeException (com.alliander.osgp.shared.infra.jms.UnknownMessageTypeException)1 Serializable (java.io.Serializable)1 ObjectMessage (javax.jms.ObjectMessage)1