Search in sources :

Example 1 with ProtocolAdapterException

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

the class GetHealthStatusRequestMessageProcessor method process.

@Override
public void process(final ClientConnection deviceConnection, final RequestMetadata requestMetadata) throws ProtocolAdapterException {
    final String deviceIdentification = requestMetadata.getDeviceIdentification();
    final String organisationIdentification = requestMetadata.getOrganisationIdentification();
    LOGGER.info("getHealthStatus for IEC60870 device {} for organisation {}", deviceIdentification, organisationIdentification);
    try {
        this.generalInterrogationService.sendGeneralInterrogation(deviceConnection, requestMetadata);
    } catch (final IOException | RuntimeException e) {
        final String message = String.format("Requesting the health status for device %s failed", deviceIdentification);
        throw new ProtocolAdapterException(ComponentType.PROTOCOL_IEC60870, message, e);
    }
}
Also used : IOException(java.io.IOException) ProtocolAdapterException(org.opensmartgridplatform.shared.exceptionhandling.ProtocolAdapterException)

Example 2 with ProtocolAdapterException

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

the class GetLightSensorStatusRequestMessageProcessor method process.

@Override
public void process(final ClientConnection deviceConnection, final RequestMetadata requestMetadata) throws ProtocolAdapterException {
    final String deviceIdentification = requestMetadata.getDeviceIdentification();
    final String organisationIdentification = requestMetadata.getOrganisationIdentification();
    LOGGER.info("Get light sensor status request for IEC60870 device {} for organisation {}", deviceIdentification, organisationIdentification);
    try {
        this.generalInterrogationService.sendGeneralInterrogation(deviceConnection, requestMetadata);
    } catch (final IOException | RuntimeException e) {
        final String message = String.format("Requesting the light sensor status for device %s failed", deviceIdentification);
        throw new ProtocolAdapterException(ComponentType.PROTOCOL_IEC60870, message, e);
    }
}
Also used : IOException(java.io.IOException) ProtocolAdapterException(org.opensmartgridplatform.shared.exceptionhandling.ProtocolAdapterException)

Example 3 with ProtocolAdapterException

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

the class ConnectRequestMessageProcessor method process.

@Override
public void process(final ClientConnection deviceConnection, final RequestMetadata requestMetadata) throws ProtocolAdapterException {
    final String deviceIdentification = requestMetadata.getDeviceIdentification();
    final String organisationIdentification = requestMetadata.getOrganisationIdentification();
    LOGGER.info("Connect request for IEC60870 device {} for organisation {}", deviceIdentification, organisationIdentification);
    LOGGER.info("Starting general interrogation for IEC60870 device {}", deviceIdentification);
    try {
        this.generalInterrogationService.sendGeneralInterrogation(deviceConnection, requestMetadata);
    } catch (final IOException | RuntimeException e) {
        final String message = String.format("Interrogation after connect request for device %s failed.", deviceIdentification);
        throw new ProtocolAdapterException(ComponentType.PROTOCOL_IEC60870, message, e);
    }
}
Also used : IOException(java.io.IOException) ProtocolAdapterException(org.opensmartgridplatform.shared.exceptionhandling.ProtocolAdapterException)

Example 4 with ProtocolAdapterException

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

the class AbstractMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.info("Processing message.");
    MessageMetadata messageMetadata = null;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
        final RequestMetadata requestMetadata = RequestMetadata.newBuilder().messageMetadata(messageMetadata).build();
        final ClientConnection deviceConnection = this.iec60870DeviceConnectionService.getConnection(requestMetadata);
        this.process(deviceConnection, requestMetadata);
    } catch (final ProtocolAdapterException e) {
        this.handleError(messageMetadata, e);
    } catch (final Exception e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ClientConnection(org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnection) ProtocolAdapterException(org.opensmartgridplatform.shared.exceptionhandling.ProtocolAdapterException) ProtocolAdapterException(org.opensmartgridplatform.shared.exceptionhandling.ProtocolAdapterException) JMSException(javax.jms.JMSException) RequestMetadata(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.RequestMetadata)

Aggregations

ProtocolAdapterException (org.opensmartgridplatform.shared.exceptionhandling.ProtocolAdapterException)4 IOException (java.io.IOException)3 JMSException (javax.jms.JMSException)1 ClientConnection (org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnection)1 RequestMetadata (org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.RequestMetadata)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1