Search in sources :

Example 1 with RequestMessage

use of com.alliander.osgp.shared.infra.jms.RequestMessage in project Protocol-Adapter-IEC61850 by OSGP.

the class OsgpRequestMessageSender method send.

public void send(final RequestMessage requestMessage, final String messageType) {
    LOGGER.info("Sending request message to OSGP.");
    this.iec61850RequestsJmsTemplate.send(new MessageCreator() {

        @Override
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(requestMessage);
            objectMessage.setJMSType(messageType);
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, requestMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, requestMessage.getDeviceIdentification());
            return objectMessage;
        }
    });
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) RequestMessage(com.alliander.osgp.shared.infra.jms.RequestMessage) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) MessageCreator(org.springframework.jms.core.MessageCreator) Session(javax.jms.Session)

Example 2 with RequestMessage

use of com.alliander.osgp.shared.infra.jms.RequestMessage in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850ChannelHandlerServer method processRegistrationMessage.

private void processRegistrationMessage(final RegisterDeviceRequest message, final String correlationId) {
    this.logMessage(message);
    String deviceIdentification = message.getDeviceIdentification();
    String deviceType = Ssld.SSLD_TYPE;
    final IED ied = IED.FLEX_OVL;
    String ipAddress = message.getIpAddress();
    // set, the values will be used to set an IP address for a device.
    if (this.testDeviceId != null && this.testDeviceId.equals(deviceIdentification) && this.testDeviceIp != null) {
        LOGGER.info("Using testDeviceId: {} and testDeviceIp: {}", this.testDeviceId, this.testDeviceIp);
        deviceIdentification = this.testDeviceId;
        deviceType = Ssld.SSLD_TYPE;
        ipAddress = this.testDeviceIp;
    }
    final DeviceRegistrationDataDto deviceRegistrationData = new DeviceRegistrationDataDto(ipAddress, deviceType, true);
    final RequestMessage requestMessage = new RequestMessage(correlationId, "no-organisation", deviceIdentification, ipAddress, deviceRegistrationData);
    LOGGER.info("Sending register device request to OSGP with correlation ID: " + correlationId);
    this.osgpRequestMessageSender.send(requestMessage, DeviceFunctionDto.REGISTER_DEVICE.name());
    try {
        this.deviceRegistrationService.disableRegistration(deviceIdentification, InetAddress.getByName(ipAddress), ied, ied.getDescription());
        LOGGER.info("Disabled registration for device: {}, at IP address: {}", deviceIdentification, ipAddress);
    } catch (final Exception e) {
        LOGGER.error("Failed to disable registration for device: {}, at IP address: {}", deviceIdentification, ipAddress, e);
    }
}
Also used : RequestMessage(com.alliander.osgp.shared.infra.jms.RequestMessage) IED(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.IED) DeviceRegistrationDataDto(com.alliander.osgp.dto.valueobjects.DeviceRegistrationDataDto)

Example 3 with RequestMessage

use of com.alliander.osgp.shared.infra.jms.RequestMessage in project Protocol-Adapter-IEC61850 by OSGP.

the class DeviceManagementService method addEventNotifications.

/**
     * Send an event notification to OSGP Core.
     *
     * @param deviceIdentification
     *            The identification of the device.
     * @param eventNotifications
     *            The event notifications.
     *
     * @throws ProtocolAdapterException
     *             In case the device can not be found in the database.
     */
public void addEventNotifications(final String deviceIdentification, final List<EventNotificationDto> eventNotifications) throws ProtocolAdapterException {
    final Ssld ssldDevice = this.ssldDataRepository.findByDeviceIdentification(deviceIdentification);
    if (ssldDevice == null) {
        throw new ProtocolAdapterException("Unable to find device using deviceIdentification: " + deviceIdentification);
    }
    LOGGER.info("addEventNotifications called for device {}: {}", deviceIdentification, eventNotifications);
    final RequestMessage requestMessage = new RequestMessage("no-correlationUid", "no-organisation", deviceIdentification, new ArrayList<>(eventNotifications));
    this.osgpRequestMessageSender.send(requestMessage, DeviceFunctionDto.ADD_EVENT_NOTIFICATION.name());
}
Also used : RequestMessage(com.alliander.osgp.shared.infra.jms.RequestMessage) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) Ssld(com.alliander.osgp.core.db.api.iec61850.entities.Ssld)

Example 4 with RequestMessage

use of com.alliander.osgp.shared.infra.jms.RequestMessage in project Protocol-Adapter-OSLP by OSGP.

the class DeviceRegistrationService method sendDeviceRegisterRequest.

public void sendDeviceRegisterRequest(final InetAddress inetAddress, final String deviceType, final boolean hasSchedule, final String deviceIdentification) {
    final DeviceRegistrationDataDto deviceRegistrationData = new DeviceRegistrationDataDto(inetAddress.getHostAddress().toString(), deviceType, hasSchedule);
    final RequestMessage requestMessage = new RequestMessage("no-correlationUid", "no-organisation", deviceIdentification, deviceRegistrationData);
    this.osgpRequestMessageSender.send(requestMessage, "REGISTER_DEVICE");
}
Also used : RequestMessage(com.alliander.osgp.shared.infra.jms.RequestMessage) DeviceRegistrationDataDto(com.alliander.osgp.dto.valueobjects.DeviceRegistrationDataDto)

Example 5 with RequestMessage

use of com.alliander.osgp.shared.infra.jms.RequestMessage in project Protocol-Adapter-OSLP by OSGP.

the class OsgpRequestMessageSender method send.

public void send(final RequestMessage requestMessage, final String messageType) {
    LOGGER.info("Sending request message to OSGP.");
    this.osgpRequestsJmsTemplate.send(new MessageCreator() {

        @Override
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(requestMessage);
            objectMessage.setJMSType(messageType);
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, requestMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, requestMessage.getDeviceIdentification());
            return objectMessage;
        }
    });
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) RequestMessage(com.alliander.osgp.shared.infra.jms.RequestMessage) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) MessageCreator(org.springframework.jms.core.MessageCreator) Session(javax.jms.Session)

Aggregations

RequestMessage (com.alliander.osgp.shared.infra.jms.RequestMessage)10 JMSException (javax.jms.JMSException)4 ObjectMessage (javax.jms.ObjectMessage)4 UnsignedOslpEnvelopeDto (com.alliander.osgp.oslp.UnsignedOslpEnvelopeDto)3 Message (javax.jms.Message)3 Session (javax.jms.Session)3 MessageCreator (org.springframework.jms.core.MessageCreator)3 DeviceRegistrationDataDto (com.alliander.osgp.dto.valueobjects.DeviceRegistrationDataDto)2 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 IED (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.IED)1 OslpDevice (com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice)1 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)1 EventNotificationDto (com.alliander.osgp.dto.valueobjects.EventNotificationDto)1 Oslp (com.alliander.osgp.oslp.Oslp)1 ArrayList (java.util.ArrayList)1 Destination (javax.jms.Destination)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1