agave-systems/systems-core/src/main/java/org/iplantc/service/systems/events/RemoteSystemEventProcessor.java
/**
	 * Propagates change of status events to associated objects and 
	 * writes an event to the system history. The events thrown here
	 * are rather broad since taking a system offline may impact active
	 * transfers, jobs, apps, monitors, scheduled tasks, files, etc. 
	 * 
	 * @param system system the system receiving the event
	 * @param oldStatus the previous system status
	 * @param newStatus the new system status
	 * @param createdBy the owner responsible for changing the system status
	 * @return a SystemHistoryEvent recording the event
	 */
Propagates change of status events to associated objects and
writes an event to the system history. The events thrown here
are rather broad since taking a system offline may impact active
transfers, jobs, apps, monitors, scheduled tasks, files, etc.


Propagates change of status events to associated objects and writes an event to the system history . The events thrown here are rather broad since taking a system offline may impact active transfers jobs apps monitors scheduled tasks files etc .
public SystemHistoryEvent processStatusChangeEvent(RemoteSystem system, SystemStatusType oldStatus, SystemStatusType newStatus, String createdBy) {
		SystemHistoryEvent event = null;
		try {
			if (system == null) {
				throw new EntityEventProcessingException("Valid system must be provided to process event.");
			}
			if (oldStatus == null) {
				throw new EntityEventProcessingException("Prior system status must be provided to process event.");
			}
			if (newStatus == null) {
				throw new EntityEventProcessingException("New system status must be provided to process event.");
			}
			ObjectNode json = null;
			try {
			    json = mapper.createObjectNode();
			    json.set("system", mapper.readTree(system.toJSON()));
			} catch (Throwable e) {
			    log.error(String.format("Failed to serialize system "
			            + "%s to json for %s event notification", 
			            system.getUuid(), SystemEventType.STATUS_UPDATE.name()), e);
			    json = null;
			}
			event = new SystemHistoryEvent(system.getUuid(), 
										  SystemEventType.STATUS_UPDATE, 
										  String.format("System status changed from %s to %s", oldStatus.name(), newStatus.name()), 
										  createdBy);
			getEntityEventDao().persist(event);
			fireNotification(system.getUuid(), SystemEventType.STATUS_UPDATE.name(), createdBy, json);
			doSoftwareEvents(system, SystemEventType.STATUS_UPDATE.name(), createdBy, json);
		}
		catch (EntityEventProcessingException e) {
			log.error(e.getMessage());
		}
		catch (EntityEventPersistenceException e) {
			log.error("Failed to persist history event for system " + system.getUuid(), e);
		}
		return event;
	}
public SystemHistoryEvent processStatusChangeEvent ( RemoteSystem system , SystemStatusType oldStatus , SystemStatusType newStatus , String createdBy ) { SystemHistoryEvent event = null ; try { if ( system == null ) { throw new EntityEventProcessingException ( "Valid system must be provided to process event." ) ; } if ( oldStatus == null ) { throw new EntityEventProcessingException ( "Prior system status must be provided to process event." ) ; } if ( newStatus == null ) { throw new EntityEventProcessingException ( "New system status must be provided to process event." ) ; } ObjectNode json = null ; try { json = mapper . createObjectNode ( ) ; json . set ( "system" , mapper . readTree ( system . toJSON ( ) ) ) ; } catch ( Throwable e ) { log . error ( String . format ( "Failed to serialize system " + "%s to json for %s event notification" , system . getUuid ( ) , SystemEventType . STATUS_UPDATE . name ( ) ) , e ) ; json = null ; } event = new SystemHistoryEvent ( system . getUuid ( ) , SystemEventType . STATUS_UPDATE , String . format ( "System status changed from %s to %s" , oldStatus . name ( ) , newStatus . name ( ) ) , createdBy ) ; getEntityEventDao ( ) . persist ( event ) ; fireNotification ( system . getUuid ( ) , SystemEventType . STATUS_UPDATE . name ( ) , createdBy , json ) ; doSoftwareEvents ( system , SystemEventType . STATUS_UPDATE . name ( ) , createdBy , json ) ; } catch ( EntityEventProcessingException e ) { log . error ( e . getMessage ( ) ) ; } catch ( EntityEventPersistenceException e ) { log . error ( "Failed to persist history event for system " + system . getUuid ( ) , e ) ; } return event ; }
Propagates change of status events to associated objects and
 writes an event to the system history.
Propagates change of status events to associated objects and writes an event to the system history .
// process the primary object event // process software tied to the system. we don't take action here. we simply give users the info they need // to decide what they want their policy to be // process the content change events tied to the status field changing. Queues should know when a system goes down //			processBatchQueueEvents(system, systemStatus, createdBy); // process jobs tied to the system.  //			doJobEvents(system, systemStatus, createdBy, json); // process transfers tied to the system.  //			doTransferEvents(system, systemStatus, createdBy, json);