use of org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification in project open-smart-grid-platform by OSGP.
the class NotificationServiceWsTest method testMappingToGenericSendNotificationRequest.
@Test
public void testMappingToGenericSendNotificationRequest() {
final SendNotificationRequest sendNotificationRequest = new SendNotificationRequest();
sendNotificationRequest.setNotification(this.createNotification());
final GenericSendNotificationRequest genericRequest = this.mapperFactory.getMapperFacade().map(sendNotificationRequest, GenericSendNotificationRequest.class);
final GenericNotification genericNotification = genericRequest.getNotification();
assertThat(genericNotification.getMessage()).isEqualTo(MESSAGE);
assertThat(genericNotification.getResult()).isEqualTo(RESULT);
assertThat(genericNotification.getDeviceIdentification()).isEqualTo(DEVICEIDENTIFICATION);
assertThat(genericNotification.getCorrelationUid()).isEqualTo(CORRELATION_UID);
assertThat(genericNotification.getNotificationType()).isEqualTo(NOTIFICATION_TYPE.name());
}
use of org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification in project open-smart-grid-platform by OSGP.
the class DomainResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
log.debug("Processing response message");
String correlationUid = null;
String actualMessageType = null;
String organisationIdentification = null;
String deviceIdentification = null;
final String notificationMessage;
final NotificationType notificationType;
final ResponseMessageResultType resultType;
final String resultDescription;
final Serializable dataObject;
try {
correlationUid = message.getJMSCorrelationID();
actualMessageType = message.getJMSType();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT));
resultDescription = message.getStringProperty(Constants.DESCRIPTION);
notificationMessage = message.getStringProperty(Constants.DESCRIPTION);
notificationType = NotificationType.valueOf(actualMessageType);
dataObject = message.getObject();
} catch (final JMSException e) {
log.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
log.debug("correlationUid: {}", correlationUid);
log.debug("messageType: {}", actualMessageType);
log.debug("organisationIdentification: {}", organisationIdentification);
log.debug("deviceIdentification: {}", deviceIdentification);
return;
}
log.info("Calling application service function to handle response: {} with correlationUid: {}", actualMessageType, correlationUid);
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.handleMessage(ids, actualMessageType, resultType, resultDescription, dataObject);
try {
log.info("Send notification for correlationUid: {}", correlationUid);
// Send notification indicating data is available.
this.notificationService.sendNotification(new ApplicationDataLookupKey(organisationIdentification, this.webserviceNotificationApplicationName), new GenericNotification(notificationMessage, resultType.name(), deviceIdentification, correlationUid, String.valueOf(notificationType)));
log.info("Notification sent for correlationUid: {}", correlationUid);
} catch (final Exception e) {
// Logging is enough, sending the notification will be done
// automatically by the resend notification job
log.warn("Delivering notification with correlationUid: {} and notification type: {} did not complete successfully.", correlationUid, notificationType, e);
}
}
use of org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification in project open-smart-grid-platform by OSGP.
the class AbstractResendNotificationService method resendNotification.
public void resendNotification(final ResponseData responseData) {
if (!EnumUtils.isValidEnum(this.notificationClass, responseData.getMessageType())) {
this.logUnknownNotificationTypeError(responseData.getCorrelationUid(), responseData.getMessageType(), this.notificationServiceReference.getClass().getName());
return;
}
final ApplicationDataLookupKey notificationWebServiceLookupKey = new ApplicationDataLookupKey(responseData.getOrganisationIdentification(), this.applicationName);
final String notificationMessage = this.getNotificationMessage(responseData.getMessageType());
final GenericNotification genericNotification = new GenericNotification(notificationMessage, responseData.getResultType().name(), responseData.getDeviceIdentification(), responseData.getCorrelationUid(), responseData.getMessageType());
this.notificationServiceReference.sendNotification(notificationWebServiceLookupKey, genericNotification);
}
use of org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification in project open-smart-grid-platform by OSGP.
the class DomainResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
log.debug("Processing response message");
String correlationUid = null;
String actualMessageType = null;
String organisationIdentification = null;
String deviceIdentification = null;
final String notificationMessage;
final NotificationType notificationType;
final ResponseMessageResultType resultType;
final String resultDescription;
final Serializable dataObject;
try {
correlationUid = message.getJMSCorrelationID();
actualMessageType = message.getJMSType();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT));
resultDescription = message.getStringProperty(Constants.DESCRIPTION);
notificationMessage = message.getStringProperty(Constants.DESCRIPTION);
notificationType = NotificationType.valueOf(actualMessageType);
dataObject = message.getObject();
} catch (final JMSException e) {
log.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
log.debug("correlationUid: {}", correlationUid);
log.debug("messageType: {}", actualMessageType);
log.debug("organisationIdentification: {}", organisationIdentification);
log.debug("deviceIdentification: {}", deviceIdentification);
return;
}
log.info("Calling application service function to handle response: {} with correlationUid: {}", actualMessageType, correlationUid);
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.handleMessage(ids, actualMessageType, resultType, resultDescription, dataObject);
try {
log.info("Send notification for correlationUid: {}", correlationUid);
// Send notification indicating data is available.
this.notificationService.sendNotification(new ApplicationDataLookupKey(organisationIdentification, this.webserviceNotificationApplicationName), new GenericNotification(notificationMessage, resultType.name(), deviceIdentification, correlationUid, String.valueOf(notificationType)));
log.info("Notification sent for correlationUid: {}", correlationUid);
} catch (final Exception e) {
// Logging is enough, sending the notification will be done
// automatically by the resend notification job
log.warn("Delivering notification with correlationUid: {} and notification type: {} did not complete successfully.", correlationUid, notificationType, e);
}
}
Aggregations