Search in sources :

Example 1 with ProtocolResponseMessage

use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.

the class DeviceRequestMessageListener method sendNotSupportedException.

private void sendNotSupportedException(final ObjectMessage objectMessage, final MessageMetadata messageMetadata) {
    try {
        final Exception exception = new NotSupportedException(ComponentType.PROTOCOL_IEC60870, messageMetadata.getMessageType());
        final FunctionalException osgpException = new FunctionalException(FunctionalExceptionType.UNSUPPORTED_DEVICE_ACTION, ComponentType.PROTOCOL_IEC60870, exception);
        final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata.builder().withScheduled(false).build()).result(ResponseMessageResultType.NOT_OK).osgpException(osgpException).dataObject(objectMessage.getObject()).build();
        this.deviceResponseMessageSender.send(protocolResponseMessage);
    } catch (final Exception e) {
        LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
    }
}
Also used : ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) NotSupportedException(org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) JMSException(javax.jms.JMSException) NotSupportedException(org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException)

Example 2 with ProtocolResponseMessage

use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.

the class Iec60870ConnectResponseService method sendConnectResponse.

private void sendConnectResponse(final ResponseMetadata responseMetadata) {
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(responseMetadata.asMessageMetadata()).result(ResponseMessageResultType.OK).build();
    this.deviceResponseMessageSender.send(responseMessage);
}
Also used : ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)

Example 3 with ProtocolResponseMessage

use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.

the class Iec60870LightMeasurementService method sendSensorStatus.

@Override
public void sendSensorStatus(final LightSensorStatusDto lightSensorSatusDto, final ResponseMetadata responseMetadata) {
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(responseMetadata.asMessageMetadata()).dataObject(lightSensorSatusDto).result(ResponseMessageResultType.OK).build();
    this.deviceResponseMessageSender.send(responseMessage);
}
Also used : ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)

Example 4 with ProtocolResponseMessage

use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.

the class Iec60870MeasurementReportingService method send.

@Override
public void send(final MeasurementReportDto measurementReportDto, final ResponseMetadata responseMetadata) {
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(responseMetadata.asMessageMetadata().builder().withMessageType(MESSAGE_TYPE).withDomain(responseMetadata.getDomainInfo().getDomain()).withDomainVersion(responseMetadata.getDomainInfo().getDomainVersion()).build()).dataObject(measurementReportDto).result(ResponseMessageResultType.OK).build();
    this.deviceResponseMessageSender.send(responseMessage);
}
Also used : ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)

Example 5 with ProtocolResponseMessage

use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.

the class CommonGetConfigurationRequestMessageProcessor method handleGetConfigurationDeviceResponse.

private void handleGetConfigurationDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final DomainInformation domainInformation, final String messageType, final int retryCount, final boolean isScheduled) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException osgpException = null;
    ConfigurationDto configuration = null;
    try {
        final GetConfigurationDeviceResponse response = (GetConfigurationDeviceResponse) deviceResponse;
        configuration = response.getConfiguration();
    } 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 MessageMetadata messageMetadata = MessageMetadata.newBuilder().withDeviceIdentification(deviceResponse.getDeviceIdentification()).withOrganisationIdentification(deviceResponse.getOrganisationIdentification()).withCorrelationUid(deviceResponse.getCorrelationUid()).withMessageType(messageType).withDomain(domainInformation.getDomain()).withDomainVersion(domainInformation.getDomainVersion()).withMessagePriority(deviceResponse.getMessagePriority()).withScheduled(isScheduled).withRetryCount(retryCount).build();
    final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(osgpException).dataObject(configuration).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage) ConfigurationDto(org.opensmartgridplatform.dto.valueobjects.ConfigurationDto) GetConfigurationDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)

Aggregations

ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)47 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)18 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)17 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)14 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)13 JMSException (javax.jms.JMSException)12 Serializable (java.io.Serializable)6 IOException (java.io.IOException)5 Test (org.junit.jupiter.api.Test)5 DeviceStatusDto (org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto)4 GetStatusDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)3 ScheduledTask (org.opensmartgridplatform.domain.core.entities.ScheduledTask)3 NotSupportedException (org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException)3 RetryHeader (org.opensmartgridplatform.shared.infra.jms.RetryHeader)3 Calendar (java.util.Calendar)2 Date (java.util.Date)2 EmptyDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)2 ConfigurationDto (org.opensmartgridplatform.dto.valueobjects.ConfigurationDto)2 FirmwareFileDto (org.opensmartgridplatform.dto.valueobjects.FirmwareFileDto)2 FirmwareVersionDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)2