agave-monitors/monitors-core/src/main/java/org/iplantc/service/monitor/events/MonitorEventProcessor.java
/**
	 * Generates notification events for content-related changes to a 
	 * {@link Monitor}. This could be a CRUD operation or a change
	 * to the credentials.
	 * 
	 * @param monitor the monitor on which the even is triggered
	 * @param eventType the event being triggered
	 * @param createdBy the user who caused this event
	 * @return the {@link MontiorEvent} updated with the association to the {@link Monitor}
	 */
Generates notification events for content-related changes to a
Monitor. This could be a CRUD operation or a change
to the credentials.

@param monitor the monitor on which the even is triggered
@param eventType the event being triggered
@param createdBy the user who caused this event
@return the  MontiorEvent updated with the association to the  Monitor
Generates notification events for content - related changes to a Monitor . This could be a CRUD operation or a change to the credentials . @param monitor the monitor on which the even is triggered @param eventType the event being triggered @param createdBy the user who caused this event @return the MontiorEvent updated with the association to the Monitor
public DomainEntityEvent processContentEvent(Monitor monitor, MonitorEventType eventType, String createdBy) {
		DomainEntityEvent event = null;
		try {
			if (monitor == null) {
				throw new EntityEventProcessingException("Valid monitor must be provided to process event.");
			}
			if (eventType == null) {
				throw new EntityEventProcessingException("Valid monitor event type must be provided to process event.");
			}
			if (StringUtils.isEmpty(createdBy)) {
				throw new EntityEventProcessingException("Valid monitor creator username must be provided to process event.");
			}
			String sJson = null;
			try {
				ObjectNode json = mapper.createObjectNode();
			    json.set("monitor", mapper.readTree(monitor.toJSON()));
			    json.set("system", mapper.readTree(monitor.getSystem().toJSON()));
			    sJson = json.toString();
			} catch (Throwable e) {
			    log.error(String.format("Failed to serialize monitor "
			            + "%s to json for %s event notification", 
			            monitor.getUuid(), eventType.name()), e);
			}
			processNotification(monitor.getUuid(), eventType.name(), createdBy, sJson);
			processNotification(monitor.getSystem().getUuid(), "MONITOR_" + eventType.name(), createdBy, sJson);
			event = new DomainEntityEvent(monitor.getUuid(), eventType, eventType.getDescription() + " by " + createdBy, createdBy);
			try {
				new DomainEntityEventDao().persist(event);
			}
			catch (EntityEventPersistenceException e) {
				log.error(String.format("Failed to persist %s monitor event "
			            + "to history for %s", 
			            eventType.name(), monitor.getUuid()), e);
			}
		}
		catch (EntityEventProcessingException e) {
			log.error(e.getMessage());
		}
		return event;
	}
public DomainEntityEvent processContentEvent ( Monitor monitor , MonitorEventType eventType , String createdBy ) { DomainEntityEvent event = null ; try { if ( monitor == null ) { throw new EntityEventProcessingException ( "Valid monitor must be provided to process event." ) ; } if ( eventType == null ) { throw new EntityEventProcessingException ( "Valid monitor event type must be provided to process event." ) ; } if ( StringUtils . isEmpty ( createdBy ) ) { throw new EntityEventProcessingException ( "Valid monitor creator username must be provided to process event." ) ; } String sJson = null ; try { ObjectNode json = mapper . createObjectNode ( ) ; json . set ( "monitor" , mapper . readTree ( monitor . toJSON ( ) ) ) ; json . set ( "system" , mapper . readTree ( monitor . getSystem ( ) . toJSON ( ) ) ) ; sJson = json . toString ( ) ; } catch ( Throwable e ) { log . error ( String . format ( "Failed to serialize monitor " + "%s to json for %s event notification" , monitor . getUuid ( ) , eventType . name ( ) ) , e ) ; } processNotification ( monitor . getUuid ( ) , eventType . name ( ) , createdBy , sJson ) ; processNotification ( monitor . getSystem ( ) . getUuid ( ) , "MONITOR_" + eventType . name ( ) , createdBy , sJson ) ; event = new DomainEntityEvent ( monitor . getUuid ( ) , eventType , eventType . getDescription ( ) + " by " + createdBy , createdBy ) ; try { new DomainEntityEventDao ( ) . persist ( event ) ; } catch ( EntityEventPersistenceException e ) { log . error ( String . format ( "Failed to persist %s monitor event " + "to history for %s" , eventType . name ( ) , monitor . getUuid ( ) ) , e ) ; } } catch ( EntityEventProcessingException e ) { log . error ( e . getMessage ( ) ) ; } return event ; }
Generates notification events for content-related changes to a
 {@link Monitor}.
Generates notification events for content - related changes to a { @link Monitor } .
// fire event on monitor // We fire delegated monitor chec events on the system being monitored.