Search in sources :

Example 26 with OslpEnvelope

use of com.alliander.osgp.oslp.OslpEnvelope in project Protocol-Adapter-OSLP by OSGP.

the class CommonUpdateDeviceSslCertificationRequestMessageProcessor 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) {
            CommonUpdateDeviceSslCertificationRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonUpdateDeviceSslCertificationRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            CommonUpdateDeviceSslCertificationRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, null, CommonUpdateDeviceSslCertificationRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid);
    try {
        this.deviceService.doUpdateDeviceSslCertification(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) UpdateDeviceSslCertificationDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.UpdateDeviceSslCertificationDeviceRequest) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest) IOException(java.io.IOException) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope)

Example 27 with OslpEnvelope

use of com.alliander.osgp.oslp.OslpEnvelope in project Protocol-Adapter-OSLP by OSGP.

the class CommonUpdateFirmwareRequestMessageProcessor 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) {
            CommonUpdateFirmwareRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonUpdateFirmwareRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            CommonUpdateFirmwareRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, null, CommonUpdateFirmwareRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid);
    try {
        this.deviceService.doUpdateFirmware(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) UpdateFirmwareDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.UpdateFirmwareDeviceRequest) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest) IOException(java.io.IOException) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope)

Example 28 with OslpEnvelope

use of com.alliander.osgp.oslp.OslpEnvelope in project Protocol-Adapter-OSLP by OSGP.

the class PublicLightingGetPowerUsageHistoryRequestMessageProcessor 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) {
            PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.handleGetPowerUsageHistoryDeviceResponse(deviceResponse, null, PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, isScheduled, retryCount);
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, ((PowerUsageHistoryResponseMessageDataContainerDto) unsignedOslpEnvelopeDto.getExtraData()).getRequestContainer(), PublicLightingGetPowerUsageHistoryRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    try {
        final PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainer = (PowerUsageHistoryResponseMessageDataContainerDto) unsignedOslpEnvelopeDto.getExtraData();
        final TimePeriodDto timePeriod = new TimePeriodDto(powerUsageHistoryResponseMessageDataContainer.getStartTime(), powerUsageHistoryResponseMessageDataContainer.getEndTime());
        final HistoryTermTypeDto historyTermType = powerUsageHistoryResponseMessageDataContainer.getHistoryTermType();
        final GetPowerUsageHistoryDeviceRequest deviceRequest = new GetPowerUsageHistoryDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, new PowerUsageHistoryMessageDataContainerDto(timePeriod, historyTermType), domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
        this.deviceService.doGetPowerUsageHistory(oslpEnvelope, powerUsageHistoryResponseMessageDataContainer, deviceRequest, deviceResponseHandler, ipAddress, domain, domainVersion, messageType, retryCount, isScheduled);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto) IOException(java.io.IOException) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope) PowerUsageHistoryResponseMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) GetPowerUsageHistoryDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetPowerUsageHistoryDeviceResponse) GetPowerUsageHistoryDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetPowerUsageHistoryDeviceRequest) DeviceResponseHandler(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler) HistoryTermTypeDto(com.alliander.osgp.dto.valueobjects.HistoryTermTypeDto) PowerUsageHistoryMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.PowerUsageHistoryMessageDataContainerDto) TimePeriodDto(com.alliander.osgp.dto.valueobjects.TimePeriodDto)

Example 29 with OslpEnvelope

use of com.alliander.osgp.oslp.OslpEnvelope in project Protocol-Adapter-OSLP by OSGP.

the class PublicLightingResumeScheduleRequestMessageProcessor 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 = this.createResumeScheduleDeviceResponseHandler(domain, domainVersion, messageType, retryCount, unsignedOslpEnvelopeDto.getExtraData(), isScheduled);
    final GetStatusDeviceRequest deviceRequest = new GetStatusDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, DomainTypeDto.PUBLIC_LIGHTING);
    try {
        this.deviceService.doResumeSchedule(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) DeviceResponseHandler(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler) IOException(java.io.IOException) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope) GetStatusDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetStatusDeviceRequest)

Example 30 with OslpEnvelope

use of com.alliander.osgp.oslp.OslpEnvelope in project Protocol-Adapter-OSLP by OSGP.

the class PublicLightingSetLightRequestMessageProcessor 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 setLightDeviceResponseHandler = new DeviceResponseHandler() {

        @Override
        public void handleResponse(final DeviceResponse deviceResponse) {
            if (((EmptyDeviceResponse) deviceResponse).getStatus().equals(DeviceMessageStatus.OK)) {
                // If the response is OK, just log it. The resumeSchedule()
                // function will be called next.
                LOGGER.info("setLight() successful for device : {}", deviceResponse.getDeviceIdentification());
            } else {
                // If the response is not OK, send a response message to the
                // responses queue.
                PublicLightingSetLightRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, PublicLightingSetLightRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
            }
        }

        @Override
        public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
            PublicLightingSetLightRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, unsignedOslpEnvelopeDto.getExtraData(), PublicLightingSetLightRequestMessageProcessor.this.responseMessageSender, deviceResponse, domain, domainVersion, messageType, isScheduled, retryCount);
        }
    };
    final DeviceRequest setLightdeviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
    // Execute a ResumeSchedule call with 'immediate = false' and 'index
    // = 0' as arguments.
    final ResumeScheduleMessageDataContainerDto resumeScheduleMessageDataContainer = new ResumeScheduleMessageDataContainerDto(0, false);
    final DeviceResponseHandler resumeScheduleDeviceResponseHandler = this.publicLightingResumeScheduleRequestMessageProcessor.createResumeScheduleDeviceResponseHandler(domain, domainVersion, DeviceRequestMessageType.RESUME_SCHEDULE.name(), retryCount, resumeScheduleMessageDataContainer, isScheduled);
    // The data of the setLightdeviceRequest can be reused
    final ResumeScheduleDeviceRequest resumeScheduleDeviceRequest = new ResumeScheduleDeviceRequest(setLightdeviceRequest.getOrganisationIdentification(), setLightdeviceRequest.getDeviceIdentification(), setLightdeviceRequest.getCorrelationUid(), resumeScheduleMessageDataContainer, setLightdeviceRequest.getDomain(), setLightdeviceRequest.getDomainVersion(), DeviceRequestMessageType.RESUME_SCHEDULE.name(), setLightdeviceRequest.getIpAddress(), setLightdeviceRequest.getRetryCount(), setLightdeviceRequest.isScheduled());
    try {
        this.deviceService.doSetLight(oslpEnvelope, setLightdeviceRequest, resumeScheduleDeviceRequest, setLightDeviceResponseHandler, resumeScheduleDeviceResponseHandler, ipAddress);
    } catch (final IOException e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, retryCount);
    }
}
Also used : UnsignedOslpEnvelopeDto(com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse) DeviceResponse(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse) DeviceResponseHandler(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler) SetLightDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetLightDeviceRequest) DeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest) ResumeScheduleDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.ResumeScheduleDeviceRequest) IOException(java.io.IOException) ResumeScheduleMessageDataContainerDto(com.alliander.osgp.dto.valueobjects.ResumeScheduleMessageDataContainerDto) ResumeScheduleDeviceRequest(com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.ResumeScheduleDeviceRequest) OslpEnvelope(com.alliander.osgp.oslp.OslpEnvelope)

Aggregations

OslpEnvelope (com.alliander.osgp.oslp.OslpEnvelope)40 IOException (java.io.IOException)25 UnsignedOslpEnvelopeDto (com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto)23 DeviceResponseHandler (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponseHandler)21 DeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse)20 DeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceRequest)15 GetStatusDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetStatusDeviceRequest)4 DeviceSimulatorException (com.alliander.osgp.webdevicesimulator.exceptions.DeviceSimulatorException)4 GetStatusDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)3 Device (com.alliander.osgp.webdevicesimulator.domain.entities.Device)3 UnknownHostException (java.net.UnknownHostException)3 SetScheduleDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.SetScheduleDeviceRequest)2 ScheduleMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.ScheduleMessageDataContainerDto)2 Message (com.alliander.osgp.oslp.Oslp.Message)2 GetPowerUsageHistoryDeviceRequest (com.alliander.osgp.adapter.protocol.oslp.elster.device.requests.GetPowerUsageHistoryDeviceRequest)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