use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class FirmwareManagementServiceTest method checkSsldPendingFirmwareUpdateReturnsTrueAndDeletesPendingUpdateWithMatchingCorrelationUid.
@Test
void checkSsldPendingFirmwareUpdateReturnsTrueAndDeletesPendingUpdateWithMatchingCorrelationUid() {
final String correlationUid = "correlation-uid-matching-pending-update";
final CorrelationIds ids = new CorrelationIds(ORGANISATION_IDENTIFICATION, DEVICE_IDENTIFICATION, correlationUid);
final List<FirmwareVersion> firmwareVersions = Collections.singletonList(new FirmwareVersion(FirmwareModuleType.FUNCTIONAL, VERSION_2));
final SsldPendingFirmwareUpdate matchingPendingFirmwareUpdate = this.anSsldPendingFirmwareUpdate(437L, new Date(), DEVICE_IDENTIFICATION, correlationUid);
when(this.ssldPendingFirmwareUpdateRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(Arrays.asList(this.anSsldPendingFirmwareUpdate(457198L, new Date(), DEVICE_IDENTIFICATION, "some-other-correlation-uid"), matchingPendingFirmwareUpdate, this.anSsldPendingFirmwareUpdate(94085089L, new Date(), DEVICE_IDENTIFICATION, "yet-another-correlation-uid")));
final boolean hasPendingFirmwareUpdate = this.firmwareManagementService.checkSsldPendingFirmwareUpdate(ids, firmwareVersions);
assertThat(hasPendingFirmwareUpdate).isTrue();
verify(this.ssldPendingFirmwareUpdateRepository).delete(matchingPendingFirmwareUpdate);
}
use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class PublicLightingDefaultResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing public lighting default response message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.defaultDeviceResponseService.handleDefaultDeviceResponse(ids, messageType, messagePriority, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class PublicLightingGetStatusResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing public lighting get status response message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
Object dataObject;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
dataObject = responseMessage.getDataObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
if (OsgpSystemCorrelationUid.CORRELATION_UID.equals(correlationUid)) {
LOGGER.info("Received message for device: {} of type: {} with correlation UID: {} and result: {}.", deviceIdentification, messageType, correlationUid, responseMessageResultType.name());
this.adHocManagementService.updateLastCommunicationTime(deviceIdentification);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
final DeviceStatusDto deviceLightStatus = (DeviceStatusDto) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.adHocManagementService.handleGetStatusResponse(deviceLightStatus, ids, messageType, messagePriority, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class PublicLightingSetTransitionResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing public lighting set transition response message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
if (this.isSetTransitionResponseLoggingEnabled) {
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.adHocManagementService.handleSetTransitionResponse(ids, messageType, messagePriority, responseMessageResultType, osgpException);
} else {
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.defaultDeviceResponseService.handleDefaultDeviceResponse(ids, messageType, messagePriority, responseMessageResultType, osgpException);
}
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class PublicLightingResumeScheduleRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing public lighting resume schedule request message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
Object dataObject;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
dataObject = message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
return;
}
try {
LOGGER.info("Calling application service function: {}", messageType);
final ResumeScheduleData resumeScheduleData = (ResumeScheduleData) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.adHocManagementService.resumeSchedule(ids, resumeScheduleData.getIndex(), resumeScheduleData.getIsImmediate(), messageType, messagePriority);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
Aggregations