use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method coupleLightMeasurementDeviceForSsld.
/**
* Send request message to domain component to couple an SSLD with a light measurement device.
*
* @param organisationIdentification Organization issuing the request.
* @param deviceIdentification The SSLD.
* @param lightMeasurementDeviceIdentification The light measurement device.
* @param messagePriority The priority of the message.
* @return Correlation UID.
* @throws FunctionalException In case the organization is not authorized or the SSLD or LMD can
* not be found.
*/
public String coupleLightMeasurementDeviceForSsld(final String organisationIdentification, final String deviceIdentification, final String lightMeasurementDeviceIdentification, final int messagePriority) throws FunctionalException {
final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
final Device device = this.domainHelperService.findDevice(deviceIdentification);
this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_LIGHT_MEASUREMENT_DEVICE);
final Device lightMeasurementDevice = this.domainHelperService.findDevice(lightMeasurementDeviceIdentification);
LOGGER.info("Found lightMeasurementDevice: {}", lightMeasurementDevice.getDeviceIdentification());
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final MessageMetadata deviceMessageMetadata = new Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_LIGHT_MEASUREMENT_DEVICE.name()).withMessagePriority(messagePriority).build();
final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(lightMeasurementDeviceIdentification).build();
this.messageSender.send(message);
return correlationUid;
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class ScheduleManagementService method enqueueSetLightSchedule.
public String enqueueSetLightSchedule(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Valid final Schedule schedule, final DateTime scheduledTime, final int messagePriority) throws FunctionalException {
final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_LIGHT_SCHEDULE);
this.domainHelperService.isInMaintenance(device);
LOGGER.debug("enqueueSetLightSchedule called with organisation {} and device {}", organisationIdentification, deviceIdentification);
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final MessageMetadata messageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_LIGHT_SCHEDULE.name()).withMessagePriority(messagePriority).withScheduleTime(scheduledTime == null ? null : scheduledTime.getMillis()).build();
final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(messageMetadata).request(schedule).build();
this.messageSender.send(message);
return correlationUid;
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class ConfigurationServiceTest method getKeys.
@Test
void getKeys() throws FunctionalException {
// SETUP
when(this.domainHelperService.findSmartMeter(DEVICE_IDENTIFICATION)).thenReturn(device);
// CALL
this.instance.getKeys(messageMetadata, getKeysRequestData);
// VERIFY
final GetKeysRequestDto expectedRequestDto = new GetKeysRequestDto(Arrays.asList(SecretTypeDto.E_METER_AUTHENTICATION_KEY, SecretTypeDto.E_METER_MASTER_KEY));
final MessageMetadata expectedMessageMetadata = messageMetadata.builder().withIpAddress(IP_ADDRESS).withNetworkSegmentIds(BASE_TRANSCEIVER_STATION_ID, CELL_ID).build();
verify(this.osgpCoreRequestMessageSender).send(this.requestMessageCaptor.capture(), this.messageMetadataCaptor.capture());
assertThat(this.requestMessageCaptor.getValue()).usingRecursiveComparison().isEqualTo(expectedRequestDto);
assertThat(this.messageMetadataCaptor.getValue()).isEqualToComparingFieldByField(expectedMessageMetadata);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class RequestService method enqueueAndSendRequest.
public AsyncResponse enqueueAndSendRequest(final RequestMessageMetadata requestMessageMetadata, final Serializable requestData) throws FunctionalException {
log.debug("{} called with organisation {} and device {}", requestMessageMetadata.getMessageType(), requestMessageMetadata.getOrganisationIdentification(), requestMessageMetadata.getDeviceIdentification());
if (requestMessageMetadata.getDeviceFunction() != null) {
this.checkAllowed(requestMessageMetadata.getOrganisationIdentification(), requestMessageMetadata.getDeviceIdentification(), requestMessageMetadata.getDeviceFunction());
}
final String correlationUid = this.correlationIdProviderService.getCorrelationId(requestMessageMetadata.getOrganisationIdentification(), requestMessageMetadata.getDeviceIdentification());
final MessageMetadata messageMetadata = requestMessageMetadata.newMessageMetadata(correlationUid);
final SmartMeteringRequestMessage message = SmartMeteringRequestMessage.newBuilder().messageMetadata(messageMetadata).request(requestData).build();
this.smartMeteringRequestMessageSender.send(message);
return this.createAsyncResponse(correlationUid, messageMetadata.getDeviceIdentification());
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class MicrogridsGetDataRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing microgrids get data request message");
final MessageMetadata messageMetadata;
final GetDataRequestDto getDataRequest;
try {
messageMetadata = MessageMetadata.fromMessage(message);
getDataRequest = (GetDataRequestDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
final RequestMessageData requestMessageData = RequestMessageData.newBuilder().messageMetadata(messageMetadata).build();
this.printDomainInfo(requestMessageData);
final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
final DeviceRequest.Builder deviceRequestBuilder = DeviceRequest.newBuilder().messageMetaData(messageMetadata);
this.deviceService.getData(new GetDataDeviceRequest(deviceRequestBuilder, getDataRequest), iec61850DeviceResponseHandler);
}
Aggregations