Search in sources :

Example 1 with SilentException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.SilentException in project open-smart-grid-platform by OSGP.

the class GetFirmwareFileResponseMessageProcessor method processMessageTasks.

@SuppressWarnings(// SilentException cannot be caught since it does not extend Exception.
"squid:S1193")
void processMessageTasks(final Serializable messageObject, final MessageMetadata messageMetadata, final DlmsConnectionManager conn) throws OsgpException {
    try {
        final DlmsDevice device = this.domainHelperService.findDlmsDevice(messageMetadata);
        LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification());
        final Serializable response;
        response = this.handleMessage(conn, device, messageObject);
        // Send response
        this.sendResponseMessage(messageMetadata, ResponseMessageResultType.OK, null, this.responseMessageSender, response);
    } catch (final Exception exception) {
        // Return original request + exception
        if (!(exception instanceof SilentException)) {
            LOGGER.error("Unexpected exception during {}", this.messageType.name(), exception);
        }
        this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, exception, this.responseMessageSender, this.createUpdateFirmwareRequestDto(messageObject));
    } finally {
        final DlmsDevice device = this.domainHelperService.findDlmsDevice(messageMetadata);
        this.doConnectionPostProcessing(device, conn, messageMetadata);
    }
}
Also used : Serializable(java.io.Serializable) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) SilentException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.SilentException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) SilentException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.SilentException)

Example 2 with SilentException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.SilentException in project open-smart-grid-platform by OSGP.

the class OsgpResponseMessageProcessor method processMessageTask.

// SilentException cannot be caught since
@SuppressWarnings("squid:S1193")
private // it does not extend Exception.
void processMessageTask(final Serializable messageObject, final MessageMetadata messageMetadata, final DlmsConnectionManager conn) throws OsgpException {
    try {
        final DlmsDevice device = this.domainHelperService.findDlmsDevice(messageMetadata);
        LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification());
        if (this.usesDeviceConnection()) {
            this.handleMessage(conn, this.domainHelperService.findDlmsDevice(messageMetadata), messageObject);
        } else {
            this.handleMessage(device, messageObject);
        }
    } catch (final Exception exception) {
        // Return original request + exception
        if (!(exception instanceof SilentException)) {
            LOGGER.error("Unexpected exception during {}", this.messageType.name(), exception);
        }
        this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, exception, this.responseMessageSender, messageObject);
    } finally {
        final DlmsDevice device = this.domainHelperService.findDlmsDevice(messageMetadata);
        this.doConnectionPostProcessing(device, conn, messageMetadata);
    }
}
Also used : DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) SilentException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.SilentException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) SilentException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.SilentException)

Aggregations

JMSException (javax.jms.JMSException)2 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)2 SilentException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.SilentException)2 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)2 Serializable (java.io.Serializable)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1