Search in sources :

Example 11 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest in project Protocol-Adapter-OSLP by OSGP.

the class CommonSetConfigurationRequestMessageProcessor method processSignedOslpEnvelope.

@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
    final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
    final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
    final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
    final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
    final String domain = unsignedOslpEnvelopeDto.getDomain();
    final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
    final String messageType = unsignedOslpEnvelopeDto.getMessageType();
    final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
    final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
    final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
    final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            CommonSetConfigurationRequestMessageProcessor.this.handleScheduledEmptyDeviceResponse(deviceResponse, CommonSetConfigurationRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, isScheduled, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            CommonSetConfigurationRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, unsignedOslpEnvelopeDto.getExtraData(), CommonSetConfigurationRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid);
    try {
        this.deviceService.doSetConfiguration(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) DeviceResponseHandler(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest) SetConfigurationDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetConfigurationDeviceRequest) IOException(java.io.IOException) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope)

Example 12 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest in project Protocol-Adapter-OSLP by OSGP.

the class CommonSetEventNotificationsRequestMessageProcessor method processSignedOslpEnvelope.

@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
    final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
    final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
    final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
    final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
    final String domain = unsignedOslpEnvelopeDto.getDomain();
    final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
    final String messageType = unsignedOslpEnvelopeDto.getMessageType();
    final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
    final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
    final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
    final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            CommonSetEventNotificationsRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonSetEventNotificationsRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            CommonSetEventNotificationsRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, unsignedOslpEnvelopeDto.getExtraData(), CommonSetEventNotificationsRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid);
    try {
        this.deviceService.doSetEventNotifications(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) DeviceResponseHandler(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler) SetEventNotificationsDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetEventNotificationsDeviceRequest) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest) IOException(java.io.IOException) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope)

Example 13 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest in project Protocol-Adapter-OSLP by OSGP.

the class CommonStartDeviceTestRequestMessageProcessor method processSignedOslpEnvelope.

@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
    final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
    final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
    final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
    final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
    final String domain = unsignedOslpEnvelopeDto.getDomain();
    final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
    final String messageType = unsignedOslpEnvelopeDto.getMessageType();
    final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
    final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
    final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
    final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            CommonStartDeviceTestRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonStartDeviceTestRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            CommonStartDeviceTestRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, null, CommonStartDeviceTestRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid);
    try {
        this.deviceService.doStartSelfTest(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) DeviceResponseHandler(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest) IOException(java.io.IOException) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope)

Example 14 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest in project Protocol-Adapter-OSLP by OSGP.

the class CommonStartDeviceTestRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing common start device test request message");
    String correlationUid = null;
    String domain = null;
    String domainVersion = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    String ipAddress = null;
    int retryCount = 0;
    boolean isScheduled = false;
    try {
        correlationUid = message.getJMSCorrelationID();
        domain = message.getStringProperty(Constants.DOMAIN);
        domainVersion = message.getStringProperty(Constants.DOMAIN_VERSION);
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        ipAddress = message.getStringProperty(Constants.IP_ADDRESS);
        retryCount = message.getIntProperty(Constants.RETRY_COUNT);
        isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false;
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("domain: {}", domain);
        LOGGER.debug("domainVersion: {}", domainVersion);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("ipAddress: {}", ipAddress);
        return;
    }
    LOGGER.info("Calling DeviceService function: {} for domain: {} {}", messageType, domain, domainVersion);
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    this.deviceService.startSelfTest(deviceRequest);
}
Also used : JMSException(javax.jms.JMSException) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest)

Example 15 with DeviceRequest

use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest in project Protocol-Adapter-OSLP by OSGP.

the class CommonStopDeviceTestRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing common stop device test request message");
    String correlationUid = null;
    String domain = null;
    String domainVersion = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    String ipAddress = null;
    int retryCount = 0;
    boolean isScheduled = false;
    try {
        correlationUid = message.getJMSCorrelationID();
        domain = message.getStringProperty(Constants.DOMAIN);
        domainVersion = message.getStringProperty(Constants.DOMAIN_VERSION);
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        ipAddress = message.getStringProperty(Constants.IP_ADDRESS);
        retryCount = message.getIntProperty(Constants.RETRY_COUNT);
        isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false;
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("domain: {}", domain);
        LOGGER.debug("domainVersion: {}", domainVersion);
        LOGGER.debug("messageType: {}", messageType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        LOGGER.debug("ipAddress: {}", ipAddress);
        return;
    }
    LOGGER.info("Calling DeviceService function: {} for domain: {} {}", messageType, domain, domainVersion);
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    this.deviceService.stopSelfTest(deviceRequest);
}
Also used : JMSException(javax.jms.JMSException) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest)

Aggregations

DeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest)20 DeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse)15 DeviceResponseHandler (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler)15 OslpEnvelope (com.alliander.osgp.oslp.OslpEnvelope)15 UnsignedOslpEnvelopeDto (com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto)15 IOException (java.io.IOException)15 JMSException (javax.jms.JMSException)5 GetStatusDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetStatusDeviceRequest)1 ResumeScheduleDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.ResumeScheduleDeviceRequest)1 SetConfigurationDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetConfigurationDeviceRequest)1 SetDeviceVerificationKeyDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetDeviceVerificationKeyDeviceRequest)1 SetEventNotificationsDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetEventNotificationsDeviceRequest)1 SetLightDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetLightDeviceRequest)1 SetTransitionDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetTransitionDeviceRequest)1 SwitchFirmwareDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SwitchFirmwareDeviceRequest)1 UpdateDeviceSslCertificationDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.UpdateDeviceSslCertificationDeviceRequest)1 UpdateFirmwareDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.UpdateFirmwareDeviceRequest)1 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)1 GetConfigurationDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetConfigurationDeviceResponse)1 GetFirmwareVersionDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetFirmwareVersionDeviceResponse)1