agave-apps/apps-core/src/main/java/org/iplantc/service/apps/managers/SoftwareEventProcessor.java
/**
	 * Raises events and records history of an app being cloned. This is
	 * useful for documenting the origin of apps and alerting users to 
	 * new versions and revisions. The events thrown here
	 * are rather broad since cloning an app may impact active
	 * transfers, jobs, other apps, monitors, scheduled tasks, files, etc. 
	 *
	 * @param originalSoftware
	 * @param clonedSoftware
	 * @param createdBy
	 * @return
	 */
Raises events and records history of an app being cloned. This is
useful for documenting the origin of apps and alerting users to
new versions and revisions. The events thrown here
are rather broad since cloning an app may impact active
transfers, jobs, other apps, monitors, scheduled tasks, files, etc.


Raises events and records history of an app being cloned . This is useful for documenting the origin of apps and alerting users to new versions and revisions . The events thrown here are rather broad since cloning an app may impact active transfers jobs other apps monitors scheduled tasks files etc .
public SoftwareEvent processCloneEvent(Software originalSoftware, Software clonedSoftware, String createdBy) {
		SoftwareEvent event = null;
		try {
			if (originalSoftware == null) {
				throw new EntityEventProcessingException("Valid original app must be provided to process event.");
			}
			if (clonedSoftware == null) {
				throw new EntityEventProcessingException("Valid published app must be provided to process event.");
			}
			if (StringUtils.isEmpty(createdBy)) {
				throw new EntityEventProcessingException("Valid username of must be provided to process event.");
			}
			String description = String.format("App was cloned by %s as %s", 
					createdBy, clonedSoftware.getUniqueName());
    		processSoftwareContentEvent(originalSoftware, SoftwareEventType.CLONED, description, createdBy);
    		description = String.format("App was created by %s as a result of cloning %s", 
    				createdBy, originalSoftware.getUniqueName());
    		processSoftwareContentEvent(clonedSoftware, SoftwareEventType.CREATED, description, createdBy);
    		ObjectNode clonedAppJson = null;
			try {
				clonedAppJson = (ObjectNode)mapper.createObjectNode().set("app", mapper.readTree(clonedSoftware.toJSON()));
			} catch (IOException | JSONException e) {
				log.error(String.format("Failed to serialize app "
			            + "%s to json for %s event notification", 
			            clonedSoftware.getUniqueName(), SoftwareEventType.CLONED.name()), e);
			}
    		doSystemEvents(clonedSoftware, SoftwareEventType.CLONED.name(), createdBy, clonedAppJson);
		}
		catch (EntityEventProcessingException e) {
			log.error(e.getMessage());
		}
		return event;
	}
public SoftwareEvent processCloneEvent ( Software originalSoftware , Software clonedSoftware , String createdBy ) { SoftwareEvent event = null ; try { if ( originalSoftware == null ) { throw new EntityEventProcessingException ( "Valid original app must be provided to process event." ) ; } if ( clonedSoftware == null ) { throw new EntityEventProcessingException ( "Valid published app must be provided to process event." ) ; } if ( StringUtils . isEmpty ( createdBy ) ) { throw new EntityEventProcessingException ( "Valid username of must be provided to process event." ) ; } String description = String . format ( "App was cloned by %s as %s" , createdBy , clonedSoftware . getUniqueName ( ) ) ; processSoftwareContentEvent ( originalSoftware , SoftwareEventType . CLONED , description , createdBy ) ; description = String . format ( "App was created by %s as a result of cloning %s" , createdBy , originalSoftware . getUniqueName ( ) ) ; processSoftwareContentEvent ( clonedSoftware , SoftwareEventType . CREATED , description , createdBy ) ; ObjectNode clonedAppJson = null ; try { clonedAppJson = ( ObjectNode ) mapper . createObjectNode ( ) . set ( "app" , mapper . readTree ( clonedSoftware . toJSON ( ) ) ) ; } catch ( IOException | JSONException e ) { log . error ( String . format ( "Failed to serialize app " + "%s to json for %s event notification" , clonedSoftware . getUniqueName ( ) , SoftwareEventType . CLONED . name ( ) ) , e ) ; } doSystemEvents ( clonedSoftware , SoftwareEventType . CLONED . name ( ) , createdBy , clonedAppJson ) ; } catch ( EntityEventProcessingException e ) { log . error ( e . getMessage ( ) ) ; } return event ; }
Raises events and records history of an app being cloned.
Raises events and records history of an app being cloned .
// notify the old app // notify the newly created public app // notify all old versions of public app // TODO: Throw events on the source and destination folders. Create LogicalFile records if not already present