Search in sources :

Example 1 with DomainInfo

use of org.opensmartgridplatform.domain.core.entities.DomainInfo in project open-smart-grid-platform by OSGP.

the class DomainResponseMessageJmsTemplateFactory method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws SSLException {
    for (final DomainInfo domainInfo : this.domainInfos) {
        LOGGER.info("Initializing DomainResponseMessageJmsTemplate {}", domainInfo.getKey());
        this.init(domainInfo);
    }
}
Also used : DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo)

Example 2 with DomainInfo

use of org.opensmartgridplatform.domain.core.entities.DomainInfo in project open-smart-grid-platform by OSGP.

the class ProtocolRequestMessageListener method sendMessageToDomainAdapter.

/**
 * Send the RequestMessage to a domain adapter.
 *
 * @param requestMessage The RequestMessage to process.
 * @param messageType The MessageType of the RequestMessage to process.
 */
private void sendMessageToDomainAdapter(final RequestMessage requestMessage, final String messageType) {
    String domain;
    final String domainVersion;
    if (DeviceFunction.PUSH_NOTIFICATION_ALARM.name().equals(messageType)) {
        domain = "SMART_METERING";
        domainVersion = "1.0";
    } else {
        domain = "CORE";
        domainVersion = "1.0";
    }
    DomainInfo domainInfo = null;
    for (final DomainInfo di : this.domainInfos) {
        if (domain.equals(di.getDomain()) && domainVersion.equals(di.getDomainVersion())) {
            domainInfo = di;
        }
    }
    if (domainInfo == null) {
        LOGGER.error("No DomainInfo found, unable to send message of message type: {} to domain adapater. RequestMessage dropped.", messageType);
    } else {
        // Send message to domain adapter.
        this.domainRequestService.send(requestMessage, messageType, domainInfo);
    }
}
Also used : DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo)

Example 3 with DomainInfo

use of org.opensmartgridplatform.domain.core.entities.DomainInfo in project open-smart-grid-platform by OSGP.

the class EventNotificationMessageService method sendRequestMessageToDomainCore.

/**
 * Send a request message to OSGP-ADAPTER-DOMAIN-CORE.
 */
private void sendRequestMessageToDomainCore(final String messageType, final String deviceIdentification, final Serializable dataObject) {
    final String correlationUid = this.correlationIdProviderTimestampService.getCorrelationId(this.netmanagementOrganisation, deviceIdentification);
    final RequestMessage message = new RequestMessage(correlationUid, this.netmanagementOrganisation, deviceIdentification, dataObject);
    final DomainInfo domainInfo = this.eventNotificationHelperService.findDomainInfo("CORE", "1.0");
    this.domainRequestService.send(message, messageType, domainInfo);
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo)

Example 4 with DomainInfo

use of org.opensmartgridplatform.domain.core.entities.DomainInfo in project open-smart-grid-platform by OSGP.

the class PushNotificationAlarmMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    final MessageMetadata metadata = MessageMetadata.fromMessage(message);
    LOGGER.info("Received message of messageType: {} organisationIdentification: {} deviceIdentification: {}", this.messageType, metadata.getOrganisationIdentification(), metadata.getDeviceIdentification());
    final RequestMessage requestMessage = (RequestMessage) message.getObject();
    final Object dataObject = requestMessage.getRequest();
    try {
        final Device device = this.getDevice(metadata.getDeviceIdentification());
        final PushNotificationAlarmDto pushNotificationAlarm = (PushNotificationAlarmDto) dataObject;
        this.storeAlarmAsEvent(pushNotificationAlarm);
        final String ownerIdentification = this.getOrganisationIdentificationOfOwner(device);
        LOGGER.info("Matching owner {} with device {} handling {} from {}", ownerIdentification, metadata.getDeviceIdentification(), this.messageType, requestMessage.getIpAddress());
        final RequestMessage requestWithUpdatedOrganization = new RequestMessage(requestMessage.getCorrelationUid(), ownerIdentification, requestMessage.getDeviceIdentification(), requestMessage.getIpAddress(), requestMessage.getBaseTransceiverStationId(), requestMessage.getCellId(), pushNotificationAlarm);
        final Optional<DomainInfo> smartMeteringDomain = this.getDomainInfo();
        if (smartMeteringDomain.isPresent()) {
            this.domainRequestService.send(requestWithUpdatedOrganization, DeviceFunction.PUSH_NOTIFICATION_ALARM.name(), smartMeteringDomain.get());
            device.updateConnectionDetailsToSuccess();
            this.deviceRepository.save(device);
        } else {
            LOGGER.error("No DomainInfo found for SMART_METERING 1.0, unable to send message of message type: {} to " + "domain adapter. RequestMessage for {} dropped.", this.messageType, pushNotificationAlarm);
        }
    } catch (final OsgpException e) {
        final String errorMessage = String.format("%s occurred, reason: %s", e.getClass().getName(), e.getMessage());
        LOGGER.error(errorMessage, e);
        throw new JMSException(errorMessage);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) PushNotificationAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto) DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo) JMSException(javax.jms.JMSException)

Example 5 with DomainInfo

use of org.opensmartgridplatform.domain.core.entities.DomainInfo in project open-smart-grid-platform by OSGP.

the class DomainRequestMessageJmsTemplateFactory method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws SSLException {
    for (final DomainInfo domainInfo : this.domainInfos) {
        LOGGER.info("Initializing DomainRequestMessageJmsTemplate {}", domainInfo.getKey());
        this.init(domainInfo);
    }
}
Also used : DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo)

Aggregations

DomainInfo (org.opensmartgridplatform.domain.core.entities.DomainInfo)10 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)5 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 JMSException (javax.jms.JMSException)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 PushNotificationAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto)1 SystemEventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1