Search in sources :

Example 11 with ResponseMessageResultType

use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-IEC61850 by OSGP.

the class DeviceRequestMessageListener method sendException.

private void sendException(final ObjectMessage objectMessage, final Exception exception) {
    try {
        final String domain = objectMessage.getStringProperty(Constants.DOMAIN);
        final String domainVersion = objectMessage.getStringProperty(Constants.DOMAIN_VERSION);
        final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
        final FunctionalException osgpException = new FunctionalException(FunctionalExceptionType.UNSUPPORTED_DEVICE_ACTION, ComponentType.PROTOCOL_IEC61850, exception);
        final Serializable dataObject = objectMessage.getObject();
        final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(objectMessage);
        final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().deviceMessageMetadata(deviceMessageMetadata).domain(domain).domainVersion(domainVersion).result(result).osgpException(osgpException).dataObject(dataObject).scheduled(false).build();
        this.deviceResponseMessageSender.send(protocolResponseMessage);
    } catch (final Exception e) {
        LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
    }
}
Also used : Serializable(java.io.Serializable) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) FunctionalException(com.alliander.osgp.shared.exceptionhandling.FunctionalException) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) FunctionalException(com.alliander.osgp.shared.exceptionhandling.FunctionalException) JMSException(javax.jms.JMSException) NotSupportedException(com.alliander.osgp.shared.exceptionhandling.NotSupportedException)

Example 12 with ResponseMessageResultType

use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-OSLP by OSGP.

the class DeviceRequestMessageListener method sendException.

private void sendException(final ObjectMessage objectMessage, final Exception exception, final String errorMessage) {
    try {
        final String domain = objectMessage.getStringProperty(Constants.DOMAIN);
        final String domainVersion = objectMessage.getStringProperty(Constants.DOMAIN_VERSION);
        final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
        final OsgpException osgpException = new OsgpException(ComponentType.PROTOCOL_OSLP, errorMessage, exception);
        final Serializable dataObject = objectMessage.getObject();
        final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(objectMessage);
        final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().deviceMessageMetadata(deviceMessageMetadata).domain(domain).domainVersion(domainVersion).result(result).osgpException(osgpException).dataObject(dataObject).scheduled(false).build();
        this.deviceResponseMessageSender.send(protocolResponseMessage);
    } catch (final Exception e) {
        LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
    }
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) Serializable(java.io.Serializable) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) 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) NotSupportedException(com.alliander.osgp.shared.exceptionhandling.NotSupportedException)

Example 13 with ResponseMessageResultType

use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-OSLP by OSGP.

the class DeviceRequestMessageProcessor method handleUnableToConnectDeviceResponse.

public void handleUnableToConnectDeviceResponse(final DeviceResponse deviceResponse, final Throwable t, final Serializable messageData, final DeviceResponseMessageSender responseMessageSender, final DeviceResponse deviceResponse2, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
    final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
    final OsgpException ex = new TechnicalException(ComponentType.PROTOCOL_OSLP, StringUtils.isBlank(t.getMessage()) ? UNEXPECTED_EXCEPTION : t.getMessage(), t);
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).dataObject(messageData).scheduled(isScheduled).retryCount(retryCount).build();
    this.responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)

Example 14 with ResponseMessageResultType

use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-OSLP by OSGP.

the class DeviceRequestMessageProcessor method handleScheduledEmptyDeviceResponse.

protected void handleScheduledEmptyDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    TechnicalException ex = null;
    try {
        final EmptyDeviceResponse response = (EmptyDeviceResponse) deviceResponse;
        this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
    } catch (final TechnicalException 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, MessagePriorityEnum.DEFAULT.getPriority());
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).scheduled(isScheduled).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Example 15 with ResponseMessageResultType

use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-OSLP by OSGP.

the class DeviceRequestMessageProcessor method handleEmptyDeviceResponse.

protected void handleEmptyDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    TechnicalException ex = null;
    try {
        final EmptyDeviceResponse response = (EmptyDeviceResponse) deviceResponse;
        this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
    } catch (final TechnicalException 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, MessagePriorityEnum.DEFAULT.getPriority());
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)

Aggregations

ResponseMessageResultType (com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)18 DeviceMessageMetadata (com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)17 ProtocolResponseMessage (com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage)17 OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)14 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)13 JMSException (javax.jms.JMSException)13 IOException (java.io.IOException)6 Serializable (java.io.Serializable)4 GetStatusDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)3 DeviceStatusDto (com.alliander.osgp.dto.valueobjects.DeviceStatusDto)3 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)2 ConfigurationDto (com.alliander.osgp.dto.valueobjects.ConfigurationDto)2 FirmwareVersionDto (com.alliander.osgp.dto.valueobjects.FirmwareVersionDto)2 PowerUsageHistoryResponseMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto)2 NotSupportedException (com.alliander.osgp.shared.exceptionhandling.NotSupportedException)2 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