agave-apps/apps-core/src/main/java/org/iplantc/service/apps/managers/SoftwareEventProcessor.java
/**
	 * Propagates change of status events to associated objects and 
	 * writes an event to the app history. The events thrown here
	 * are rather broad since taking an app offline may impact active
	 * jobs, systems, workflows, etc. 
	 * 
	 * @param software
	 * @param oldStatus
	 * @param newStatus
	 * @param createdBy
	 */
Propagates change of status events to associated objects and
writes an event to the app history. The events thrown here
are rather broad since taking an app offline may impact active
jobs, systems, workflows, etc.


Propagates change of status events to associated objects and writes an event to the app history . The events thrown here are rather broad since taking an app offline may impact active jobs systems workflows etc .
public SoftwareEvent processStatusChangeEvent(Software software, SoftwareEventType oldStatus, SoftwareEventType newStatus, String createdBy) {
		SoftwareEvent event = null;
		try {
			if (software == null) {
				throw new EntityEventProcessingException("Valid app must be provided to process event.");
			}
			if (oldStatus == null) {
				throw new EntityEventProcessingException("Prior app status must be provided to process event.");
			}
			if (newStatus == null) {
				throw new EntityEventProcessingException("New app status must be provided to process event.");
			}
			ObjectNode json = null;
			try {
			    json = mapper.createObjectNode();
			    json.set("app", mapper.readTree(software.toJSON()));
			} catch (Throwable e) {
			    log.error(String.format("Failed to serialize app "
			            + "%s to json for %s event notification", 
			            software.getUuid(), newStatus.name()), e);
			    json = null;
			}
			event = new SoftwareEvent(software, 
									  newStatus,
									  String.format("App status changed from %s to %s", oldStatus.name(), newStatus.name()), 
									  createdBy);
			getEntityEventDao().persist(event);
			fireNotification(software.getUuid(), newStatus.name(), createdBy, json);
			doSystemEvents(software, newStatus.name(), createdBy, json);
			doJobEvents(software, newStatus.name(), createdBy, json);
		}
		catch (EntityEventProcessingException e) {
			log.error(e.getMessage());
		}
		catch (SoftwareEventPersistenceException e) {
			log.error("Failed to persist history event for app " + software.getUuid(), e);
		}
		return event;
	}
public SoftwareEvent processStatusChangeEvent ( Software software , SoftwareEventType oldStatus , SoftwareEventType newStatus , String createdBy ) { SoftwareEvent event = null ; try { if ( software == null ) { throw new EntityEventProcessingException ( "Valid app must be provided to process event." ) ; } if ( oldStatus == null ) { throw new EntityEventProcessingException ( "Prior app status must be provided to process event." ) ; } if ( newStatus == null ) { throw new EntityEventProcessingException ( "New app status must be provided to process event." ) ; } ObjectNode json = null ; try { json = mapper . createObjectNode ( ) ; json . set ( "app" , mapper . readTree ( software . toJSON ( ) ) ) ; } catch ( Throwable e ) { log . error ( String . format ( "Failed to serialize app " + "%s to json for %s event notification" , software . getUuid ( ) , newStatus . name ( ) ) , e ) ; json = null ; } event = new SoftwareEvent ( software , newStatus , String . format ( "App status changed from %s to %s" , oldStatus . name ( ) , newStatus . name ( ) ) , createdBy ) ; getEntityEventDao ( ) . persist ( event ) ; fireNotification ( software . getUuid ( ) , newStatus . name ( ) , createdBy , json ) ; doSystemEvents ( software , newStatus . name ( ) , createdBy , json ) ; doJobEvents ( software , newStatus . name ( ) , createdBy , json ) ; } catch ( EntityEventProcessingException e ) { log . error ( e . getMessage ( ) ) ; } catch ( SoftwareEventPersistenceException e ) { log . error ( "Failed to persist history event for app " + software . getUuid ( ) , e ) ; } return event ; }
Propagates change of status events to associated objects and
 writes an event to the app history.
Propagates change of status events to associated objects and writes an event to the app history .
// process the primary object event // process systems tied to the app. we don't take action here. we simply give users the info they need // to decide what they want their policy to be