in app/models/PostrunAction.scala [131:174]
def isPojo:Boolean = runnable.startsWith("java:")
/**
* asynchronously executes this postrun action on a newly created project
* @param projectFileName - filename of the newly created project
* @param projectEntry - models.projectEntry object representing the newly created project
* @param projectType - models.projectType that the project was created from
* @param config - implicitly provided play.api.Configuration object, representing the app configuration
* @return a Future containing a Try containing either the script output or an error
*/
def run(projectFileName:String,projectEntry:ProjectEntry,projectType:ProjectType,dataCache:PostrunDataCache,
workingGroupMaybe: Option[PlutoWorkingGroup], commissionMaybe: Option[PlutoCommission])
(implicit config:Configuration):Future[Try[JythonOutput]] = {
backupProjectFile(projectFileName) flatMap {
case Failure(error) =>
val logger = Logger(this.getClass)
logger.error(s"Unable to back up project file $projectFileName:", error)
Future(Failure(error))
case Success(backupPath) =>
val logger = Logger(this.getClass)
logger.info(s"Backed up project file from $projectFileName to ${backupPath.toString}")
logger.debug(s"Going to try to run script at path $getScriptPath...")
val resultFuture = if(isPojo){
runPojo(projectFileName, projectEntry, projectType, dataCache, workingGroupMaybe, commissionMaybe)
} else {
Future(Failure(new RuntimeException("Unsupported postrun type")))
}
resultFuture.map({
case Failure(error) =>
logger.error(s"Unable to start postrun script: ${error.getMessage}", error)
restoreBackupFile(backupPath, projectFileName) match {
case Failure(restoreError)=>
logger.error(s"Cannot restore backup, project file $projectFileName may be corrupted")
Failure(error)
case Success(unitval)=>
Failure(error)
}
case Success(result)=>Success(result)
})
}
}