Search in sources :

Example 1 with ConnectionFailureException

use of org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException in project open-smart-grid-platform by OSGP.

the class DetailSoapFaultMappingExceptionResolver method customizeFault.

@Override
protected void customizeFault(final Object endpoint, final Exception ex, final SoapFault fault) {
    final SoapFaultDetail detail = fault.addFaultDetail();
    final Result result = detail.getResult();
    FunctionalException fex = null;
    TechnicalException tex = null;
    ConnectionFailureException cex = null;
    if (ex instanceof FunctionalException) {
        fex = (FunctionalException) ex;
    } else if (ex instanceof TechnicalException) {
        tex = (TechnicalException) ex;
    } else if (ex instanceof ConnectionFailureException) {
        cex = (ConnectionFailureException) ex;
    }
    if (fex != null) {
        try {
            this.marshalFunctionalException(fex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Functional Exception", e);
        }
    }
    if (tex != null) {
        try {
            this.marshalTechnicalException(tex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Technical Exception", e);
        }
    }
    if (cex != null) {
        try {
            this.marshalConnectionFailureException(cex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Connection Failure Exception", e);
        }
    }
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) SoapFaultDetail(org.springframework.ws.soap.SoapFaultDetail) ConnectionFailureException(org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException) JAXBException(javax.xml.bind.JAXBException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Result(javax.xml.transform.Result)

Example 2 with ConnectionFailureException

use of org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException in project open-smart-grid-platform by OSGP.

the class DetailSoapFaultMappingExceptionResolver method customizeFault.

@Override
protected void customizeFault(final Object endpoint, final Exception ex, final SoapFault fault) {
    final SoapFaultDetail detail = fault.addFaultDetail();
    final Result result = detail.getResult();
    FunctionalException fex = null;
    TechnicalException tex = null;
    ConnectionFailureException cex = null;
    if (ex instanceof FunctionalException) {
        fex = (FunctionalException) ex;
    } else if (ex instanceof TechnicalException) {
        tex = (TechnicalException) ex;
    } else if (ex instanceof ConnectionFailureException) {
        cex = (ConnectionFailureException) ex;
    }
    if (fex != null) {
        try {
            this.marshalFunctionalException(fex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Functional Exception", e);
        }
    }
    if (tex != null) {
        try {
            this.marshalTechnicalException(tex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Technical Exception", e);
        }
    }
    if (cex != null) {
        try {
            this.marshalConnectionFailureException(cex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Connection Failure Exception", e);
        }
    }
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) SoapFaultDetail(org.springframework.ws.soap.SoapFaultDetail) ConnectionFailureException(org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException) JAXBException(javax.xml.bind.JAXBException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Result(javax.xml.transform.Result)

Example 3 with ConnectionFailureException

use of org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException in project open-smart-grid-platform by OSGP.

the class DetailSoapFaultMappingExceptionResolver method customizeFault.

@Override
protected void customizeFault(final Object endpoint, final Exception ex, final SoapFault fault) {
    final SoapFaultDetail detail = fault.addFaultDetail();
    final Result result = detail.getResult();
    FunctionalException fex = null;
    TechnicalException tex = null;
    ConnectionFailureException cex = null;
    if (ex instanceof FunctionalException) {
        fex = (FunctionalException) ex;
    } else if (ex instanceof TechnicalException) {
        tex = (TechnicalException) ex;
    } else if (ex instanceof ConnectionFailureException) {
        cex = (ConnectionFailureException) ex;
    }
    if (fex != null) {
        try {
            this.marshalFunctionalException(fex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Functional Exception", e);
        }
    }
    if (tex != null) {
        try {
            this.marshalTechnicalException(tex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Technical Exception", e);
        }
    }
    if (cex != null) {
        try {
            this.marshalConnectionFailureException(cex, result);
        } catch (final JAXBException e) {
            LOGGER.error("Unable to marshal the Connection Failure Exception", e);
        }
    }
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) SoapFaultDetail(org.springframework.ws.soap.SoapFaultDetail) ConnectionFailureException(org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException) JAXBException(javax.xml.bind.JAXBException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) Result(javax.xml.transform.Result)

Example 4 with ConnectionFailureException

use of org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException in project open-smart-grid-platform by OSGP.

the class Iec60870Client method connect.

@Override
public ClientConnection connect(final ConnectionParameters connectionParameters, final ConnectionEventListener asduListener) throws ConnectionFailureException {
    final InetAddress address = this.convertIpAddress(connectionParameters.getIpAddress());
    final String deviceIdentification = connectionParameters.getDeviceIdentification();
    final int port = connectionParameters.getPort() == null ? IEC60870_DEFAULT_PORT : connectionParameters.getPort();
    final ClientConnectionBuilder clientConnectionBuilder = new ClientConnectionBuilder(address).setPort(port).setConnectionTimeout(this.connectionTimeout);
    try {
        LOGGER.info("Connecting to device: {}...", deviceIdentification);
        final Connection connection = clientConnectionBuilder.build();
        connection.startDataTransfer(asduListener);
        LOGGER.info("Connected to device: {}", deviceIdentification);
        return new DeviceConnection(connection, connectionParameters);
    } catch (final IOException e) {
        final String errorMessage = "Unable to connect to remote host: " + connectionParameters.getIpAddress();
        LOGGER.error(errorMessage, e);
        throw new ConnectionFailureException(ComponentType.PROTOCOL_IEC60870, errorMessage);
    }
}
Also used : ClientConnectionBuilder(org.openmuc.j60870.ClientConnectionBuilder) ConnectionFailureException(org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException) ClientConnection(org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnection) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection) Connection(org.openmuc.j60870.Connection) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection) IOException(java.io.IOException) InetAddress(java.net.InetAddress)

Example 5 with ConnectionFailureException

use of org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException in project open-smart-grid-platform by OSGP.

the class OslpDeviceService method handleException.

protected void handleException(final Throwable t, final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) {
    Metrics.counter(this.failedMessagesMetric).increment();
    final DeviceResponse deviceResponse = new DeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceRequest.getMessagePriority());
    if (t instanceof IOException) {
        // Replace t by an OSGP Exception
        final ConnectionFailureException ex = new ConnectionFailureException(ComponentType.PROTOCOL_OSLP, "Connection failure");
        deviceResponseHandler.handleException(ex, deviceResponse);
    } else {
        deviceResponseHandler.handleException(t, deviceResponse);
    }
}
Also used : EmptyDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse) GetStatusDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse) GetFirmwareVersionDeviceResponse(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse) ConnectionFailureException(org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException) IOException(java.io.IOException)

Aggregations

ConnectionFailureException (org.opensmartgridplatform.shared.exceptionhandling.ConnectionFailureException)6 JAXBException (javax.xml.bind.JAXBException)3 Result (javax.xml.transform.Result)3 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)3 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)3 SoapFaultDetail (org.springframework.ws.soap.SoapFaultDetail)3 IOException (java.io.IOException)2 InetAddress (java.net.InetAddress)1 ClientConnectionBuilder (org.openmuc.j60870.ClientConnectionBuilder)1 Connection (org.openmuc.j60870.Connection)1 ClientConnection (org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnection)1 DeviceConnection (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection)1 DeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceResponse)1 EmptyDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)1 GetConfigurationDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)1 GetFirmwareVersionDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse)1 GetStatusDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)1