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);
}
}
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);
}
}
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);
}
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);
}
}
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);
}
}
Aggregations