agave-systems/systems-core/src/main/java/org/iplantc/service/systems/events/RemoteSystemEventProcessor.java
/**
	 * Generates notification events for permission-related changes to a 
	 * {@link RemoteSystem}. Permission changes are not propagated to the associated
	 * resources.
	 * 
	 * @param system the system receiving the role update
	 * @param systemRole the role being applied
	 * @param createdBy the owner of the permission event
	 * @return the {@link RemoteSystemEvent}
	 */
Generates notification events for permission-related changes to a
RemoteSystem. Permission changes are not propagated to the associated
resources.

@param system the system receiving the role update
@param systemRole the role being applied
@param createdBy the owner of the permission event
@return the  RemoteSystemEvent
Generates notification events for permission - related changes to a RemoteSystem . Permission changes are not propagated to the associated resources . @param system the system receiving the role update @param systemRole the role being applied @param createdBy the owner of the permission event @return the RemoteSystemEvent
public SystemHistoryEvent processPermissionEvent(RemoteSystem system, SystemRole systemRole, String createdBy) 
	{
		SystemHistoryEvent event = null;
		try {
			if (system == null) {
				throw new EntityEventProcessingException("Valid system must be provided to process event.");
			}
			if (systemRole == null) {
				throw new EntityEventProcessingException("Valid system role must be provided to process event.");
			}
			if (StringUtils.isEmpty(createdBy)) {
				throw new EntityEventProcessingException("Valid username must be provided to process event.");
			}
			SystemEventType eventType = null;
			String eventMessage = null;
			if (systemRole.getRole() == RoleType.NONE) { 
				eventType = SystemEventType.ROLES_REVOKE;
				eventMessage = String.format("User %s had their roles revoked by %s",
						systemRole.getUsername(),
						createdBy);
			} else {
				eventType = SystemEventType.ROLES_GRANT;
				eventMessage = String.format("User %s was granted the role of %s by %s", 
						systemRole.getUsername(), 
						systemRole.getRole().name(),
						createdBy);
			}
			ObjectNode json = null;
			try {
			    json = mapper.createObjectNode();
		    	json.set("system", mapper.readTree(system.toJSON()));
			    json.set("role", systemRole.toJsonNode(system));
			} catch (Throwable e) {
			    log.error(String.format("Failed to serialize system "
			            + "%s to json for %s event notification", 
			            system.getUuid(), eventType.name()), e);
			    json = null;
			}
			event = new SystemHistoryEvent(system.getUuid(), 
					  eventType, 
					  eventMessage,
					  createdBy);
			getEntityEventDao().persist(event);
			fireNotification(system.getUuid(), eventType.name(), createdBy, json);
			doSoftwareEvents(system, eventType.name(), systemRole.getUsername(), 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 processPermissionEvent ( RemoteSystem system , SystemRole systemRole , String createdBy ) { SystemHistoryEvent event = null ; try { if ( system == null ) { throw new EntityEventProcessingException ( "Valid system must be provided to process event." ) ; } if ( systemRole == null ) { throw new EntityEventProcessingException ( "Valid system role must be provided to process event." ) ; } if ( StringUtils . isEmpty ( createdBy ) ) { throw new EntityEventProcessingException ( "Valid username must be provided to process event." ) ; } SystemEventType eventType = null ; String eventMessage = null ; if ( systemRole . getRole ( ) == RoleType . NONE ) { eventType = SystemEventType . ROLES_REVOKE ; eventMessage = String . format ( "User %s had their roles revoked by %s" , systemRole . getUsername ( ) , createdBy ) ; } else { eventType = SystemEventType . ROLES_GRANT ; eventMessage = String . format ( "User %s was granted the role of %s by %s" , systemRole . getUsername ( ) , systemRole . getRole ( ) . name ( ) , createdBy ) ; } ObjectNode json = null ; try { json = mapper . createObjectNode ( ) ; json . set ( "system" , mapper . readTree ( system . toJSON ( ) ) ) ; json . set ( "role" , systemRole . toJsonNode ( system ) ) ; } catch ( Throwable e ) { log . error ( String . format ( "Failed to serialize system " + "%s to json for %s event notification" , system . getUuid ( ) , eventType . name ( ) ) , e ) ; json = null ; } event = new SystemHistoryEvent ( system . getUuid ( ) , eventType , eventMessage , createdBy ) ; getEntityEventDao ( ) . persist ( event ) ; fireNotification ( system . getUuid ( ) , eventType . name ( ) , createdBy , json ) ; doSoftwareEvents ( system , eventType . name ( ) , systemRole . getUsername ( ) , 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 ; }
Generates notification events for permission-related changes to a
 {@link RemoteSystem}.
Generates notification events for permission - related changes to a { @link RemoteSystem } .
// send update notifications to each software item on the system // TODO: send event to the user // We do not fire delegated system permission events on associated uuids