agave-notifications/notifications-core/src/main/java/org/iplantc/service/notification/events/NotificationMessageProcessor.java
/**
	 * Converts a notification into a {@link NotificationAttempt} and attempts to send it. If
	 * unsuccessful, the returned {@link NotificationAttempt} will contain the next attempt time
	 * based on the {@link NotificationPolicy}. This will only throw an exception when the 
	 * {@link Notification} itself cannot be resolved to a valid event.
	 * 
	 * @param notification
	 * @param eventName
	 * @param owner
	 * @param associatedUuid
	 * @param customNotificationMessageContextData
	 * @return the result of attempting to deliver the notification
	 * @throws NotificationException
	 */
Converts a notification into a  NotificationAttempt and attempts to send it. If
unsuccessful, the returned  NotificationAttempt will contain the next attempt time
based on the  NotificationPolicy. This will only throw an exception when the
Notification itself cannot be resolved to a valid event.


Converts a notification into a NotificationAttempt and attempts to send it . If unsuccessful the returned NotificationAttempt will contain the next attempt time based on the NotificationPolicy . This will only throw an exception when the Notification itself cannot be resolved to a valid event .
public static NotificationAttempt process(Notification notification, String eventName, String owner, String associatedUuid, String customNotificationMessageContextData) 
	throws NotificationException
	{
		try 
		{
		    TenancyHelper.setCurrentEndUser(notification.getOwner());
            TenancyHelper.setCurrentTenantId(notification.getTenantId());
			String targetUuid = associatedUuid;
			if (StringUtils.isEmpty(associatedUuid) && !StringUtils.equalsIgnoreCase(notification.getAssociatedUuid(), "*")) {
				targetUuid = notification.getAssociatedUuid();
			}
			AgaveUUID uuid = new AgaveUUID(targetUuid);
			EventFilter eventFilter =
					EventFilterFactory.getInstance(uuid, notification, eventName, owner);
			eventFilter.setCustomNotificationMessageContextData(customNotificationMessageContextData);
			NotificationAttempt attempt = createNotificationAttemptFromEvent(eventFilter);
			log.debug(String.format("Attempt [%s]: Beginning to process notification %s for %s event on %s entity with associatedUuid %s", 
					attempt.getAttemptNumber(),
					attempt.getNotificationId(),
					attempt.getEventName(),
					uuid.getResourceType().name(),
					attempt.getAssociatedUuid()));
			NotificationAttemptProcessor processor = new NotificationAttemptProcessor(attempt);
			processor.fire();
			log.debug(String.format("Attempt [%s]: Completed attempt at notification %s for %s event on %s entity with associatedUuid %s", 
					attempt.getAttemptNumber(),
					attempt.getNotificationId(),
					processor.getAttempt().getEventName(),
					uuid.getResourceType().name(),
					processor.getAttempt().getAssociatedUuid()));
			return processor.getAttempt();
		}
		catch (UUIDException e) {
			throw new NotificationException("Could not identify associated resource from notification uuid. Trigger cannot be processed.");
		}
	}
public static NotificationAttempt process ( Notification notification , String eventName , String owner , String associatedUuid , String customNotificationMessageContextData ) throws NotificationException { try { TenancyHelper . setCurrentEndUser ( notification . getOwner ( ) ) ; TenancyHelper . setCurrentTenantId ( notification . getTenantId ( ) ) ; String targetUuid = associatedUuid ; if ( StringUtils . isEmpty ( associatedUuid ) && ! StringUtils . equalsIgnoreCase ( notification . getAssociatedUuid ( ) , "*" ) ) { targetUuid = notification . getAssociatedUuid ( ) ; } AgaveUUID uuid = new AgaveUUID ( targetUuid ) ; EventFilter eventFilter = EventFilterFactory . getInstance ( uuid , notification , eventName , owner ) ; eventFilter . setCustomNotificationMessageContextData ( customNotificationMessageContextData ) ; NotificationAttempt attempt = createNotificationAttemptFromEvent ( eventFilter ) ; log . debug ( String . format ( "Attempt [%s]: Beginning to process notification %s for %s event on %s entity with associatedUuid %s" , attempt . getAttemptNumber ( ) , attempt . getNotificationId ( ) , attempt . getEventName ( ) , uuid . getResourceType ( ) . name ( ) , attempt . getAssociatedUuid ( ) ) ) ; NotificationAttemptProcessor processor = new NotificationAttemptProcessor ( attempt ) ; processor . fire ( ) ; log . debug ( String . format ( "Attempt [%s]: Completed attempt at notification %s for %s event on %s entity with associatedUuid %s" , attempt . getAttemptNumber ( ) , attempt . getNotificationId ( ) , processor . getAttempt ( ) . getEventName ( ) , uuid . getResourceType ( ) . name ( ) , processor . getAttempt ( ) . getAssociatedUuid ( ) ) ) ; return processor . getAttempt ( ) ; } catch ( UUIDException e ) { throw new NotificationException ( "Could not identify associated resource from notification uuid. Trigger cannot be processed." ) ; } }
Converts a notification into a {@link NotificationAttempt} and attempts to send it.
Converts a notification into a { @link NotificationAttempt } and attempts to send it .
// we need to resolve the actual target uuid corresponding to the event because the // notification may have a wildcard associatedUuid and we would not otherwise be // able to resolve the webhook template variables. // Each UUIDType has an EventFilter defined which handles the serialization of the event body into // the various destination formats. Here we use a factory to get the instance for type of the associatedUuid // registered with the notification.