import java.awt.Color
import java.util.concurrent.Callable
import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicBoolean

import static Services.*
import static ServiceControl.*
import java.awt.AWTException
import java.awt.Font
import java.awt.Image
import java.awt.Menu
import java.awt.MenuItem
import java.awt.PopupMenu
import java.awt.SystemTray
import java.awt.TrayIcon
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import javax.swing.JOptionPane
import javax.imageio.ImageIO


group 'com.att.ecomp'
version '1.01-SNAPSHOT'

apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: "org.hidetake.ssh"
apply plugin: 'java-gradle-plugin'
apply plugin: 'idea'

sourceCompatibility = 1.8

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'org.codehaus.groovy:groovy-all:2.4.12'
        classpath "org.hidetake:gradle-ssh-plugin:2.9.0"
    }
}

enum Services {
    BACKEND ,   //be
    FRONTEND ,  //fe
    DB ,        //cassandra
    CACHING ,   //elawsrticsearch
    SECURITY ,   //webseal
    ALL //all services
}
enum ServiceControl {
    HEALTH ,
    START ,
    RESTART ,
    STOP ,
    KILL
}
//env variables
//fill YOUR_WINDOWS_USER_HOME
project.ext.set("NEW_VAG",Boolean.FALSE) //flags to use new vagrant configuration
project.ext.set("IS_HOTSWAP",Boolean.FALSE) //flags to use new vagrant configuration
project.ext.set("PROJECT_PATH", System.getenv("SDC")) //ex. 'C:\\GIT_WORK\\asdc\\sdc')
project.ext.set("VAGRANT_HOME", NEW_VAG ? System.getenv("NEW_VAG") : System.getenv("VAG")) //ex. 'C:\\GIT_WORK\\vagrant-asdc-all-in-one')
project.ext.set("USER_HOME", "${System.getenv("USERPROFILE")}\\.ssh")
project.ext.set("BE_REMOTE", NEW_VAG ? '/opt/app/jetty/base/be' : '/home/vagrant/catalog-be' )
project.ext.set("FE_REMOTE", NEW_VAG ? '/opt/app/jetty/base/fe' : '/home/vagrant/catalog-fe' )
project.ext.set("VAGRANT_USER",     NEW_VAG ? 'm11981' : 'vagrant' )
project.ext.set("RSA_PRIVATE_KEY_PATH", NEW_VAG ? "$VAGRANT_HOME/id_rsa" : '' )
project.ext.set("VAGRANT_PASSWORD", NEW_VAG ? 'Aa123456' : 'vagrant' )
project.ext.set("X_FOLDER",'/xFolder' )
project.ext.set("BE_DEPENDENCIES", 'common-be,common-app-api,catalog-dao,catalog-model,security-utils' )
project.ext.set("command", [ (ALL) :  [  (HEALTH) : { NEW_VAG ? 'sudo curl -i http://localhost:8181/sdc1/rest/healthCheck' : 'curl -i localhost:8080/sdc2/rest/healthCheck' } ,
                                         (KILL) : { NEW_VAG ? 'sudo pkill java' : 'pkill java'} ]  ,   //  TODO: refine kill only for services
                             (BACKEND) : [  (START) : { NEW_VAG ? 'sudo service jettyBE start' : 'service catalog-be start'} ,
                                            (STOP) : { NEW_VAG ? 'sudo service jettyBE stop' : 'service catalog-be stop'} ,
                                            (RESTART) : { NEW_VAG ? 'sudo service jettyBE restart' : 'service catalog-be restart'}]  ,
                             (DB) : [  (START) : { NEW_VAG ? 'sudo service cassandra start' : 'start-asdc-storage.sh' } ,
                                       (STOP) : { NEW_VAG ? 'sudo service cassandra stop' : 'service cassandra stop'} ,
                                       (RESTART) : { NEW_VAG ? 'sudo service cassandra restart' : 'service cassandra restart'} ]  ,
                             (FRONTEND): [  (START) : {  NEW_VAG ? 'sudo service jettyFE start' : 'service catalog-fe start'   } ,
                                            (STOP) : { NEW_VAG ? 'sudo service jettyFE stop' : 'service catalog-fe stop'} ,
                                            (RESTART) : {  NEW_VAG ? 'sudo service jettyFE restart' : 'service catalog-fe restart'   } ]  ,
                             (CACHING): [  (START) : { NEW_VAG ? 'sudo service elasticsearch start' : 'echo "starting es is not yet supported"'   } ],
                             (SECURITY): [  (START) : {  NEW_VAG ? 'sudo docker start sdc-WebSeal-Simulator' : 'service webseal-simulator start'   } ,
                                            (STOP) : { NEW_VAG ? 'sudo docker stop sdc-WebSeal-Simulator' : 'service webseal-simulator stop'} ,
                                            (RESTART) : { NEW_VAG ? 'sudo docker restart sdc-WebSeal-Simulator' : 'service webseal-simulator restart'}]
                             ] )      //abstraction level to shell scripts , support old and new vagrant bash commands

//icons
project.ext.set("warnImg",'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAADvSURBVDhPY2RgYPgPxGQDiAGLXkB4UMD56DuD9YFUhj179oD5Li4uDEcdZjN8l+ME8+EgTgLTAJDm7zWKYPb/enUwzdh4E0xzttxHNQRoABOUCQYYmj+9QrCBACQHUoMM4AYga74ZDiRAmvnEwHwQGywGBOiGgA1A16wmJYjQDAJANkgMmyEosYBVMzIAuuTWs/cM6iuhfCCAGwDWrAHxKyFw68ZNuCE40wGygcga0AEkEEHRiIxxASzqUKKRHIAwAJgo4BgXwKIGxQUgf8MwOsAlh+EFUMDBMAxgE0MGoLwAignSMFQPzmgkDjAwAACSmn13nChk1QAAAABJRU5ErkJggg==')
project.ext.set("okImg1",'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAD4SURBVDhPY2RgYPgPxGQDiAGLXkB4UMD56DuD9YFUhj179oD5Li4uDEcdZjN8l+ME8+EgTgLTAJDm7zWKYLbSRh8wfc9/C5jmbLmPagjQACYoEwwwNLMxgzHMIJAcSA0ygBuArFm81gyi+ddfCAaywWJAgG4I2AB0zdxWkhCNMABkg8SwGYISC1g1IwOgS74ee87wsvkUVADJAJjpyIDbRAxMfz3zCkwjA5ghONMB2DVIBiDbigwggQiKRmSMC2BRhxKN5ACEAcBEAce4ABY1LFAaDLAFJAwgyyGHB4YXQAEHwzCATQwZgPICKCZIw1A9OKOROMDAAAA4gXvZorg7ZgAAAABJRU5ErkJggg==')
project.ext.set("okImg2" , 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAADjSURBVDhPY2RgYPgPxGQDiAGLXkB4UMD56DuD9YFUhj179oD5Li4uDEcdZjN8l+ME8+EgTgLTAJDm7zWKYPbWZ7Jg2lvqMZjmbLmPagjQACYoEwywaQYBGBskB1KDDOAGIGuetFsUTCMDmBi6IWAD0DUra3OA2cgAJIbNEJRYwKUZGdy9+oMhz/U1lIdkADZnwwwDaUIHMENwpgNk16DbigwggQiKRmSMC2BRhxKN5ACEAcBEAce4ABY1LFAaDLAFJAwgyyGHB4YXQAEHwzCATQwZgPICKCZIw1A9OKOROMDAAAAZD3X55epfOAAAAABJRU5ErkJggg==')
project.ext.set("errorImg" , 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAADlSURBVDhPY2RgYPgPxGQDiAGLXkB4UMD56DuD9YFUhj179oD5Li4uDEcdZjN8l+ME8+EgTgLTAJDm7zWKYPZbGRUwLfzkDpjmbLmPagjQACYoEwywaQYBGBskB1KDDOAGIGtexisCppEBTAzdELAB6Jrd+QXAbGQAEsNmCEos4NKMDHZ+/MAQ9fkNlIdkADZnwwwDaUIHyIaADMDAQAP/AwMPjEFsbGpAGGs6AEUPsnfgzsaiDiUayQUgF2A4jaAXoHpQXAByNgyjA1xyGF4A+RuGYQCbGDLA6gWCGKoHJSGRDhgYAL/hkunRq+joAAAAAElFTkSuQmCC')
project.ext.set("unavailableImg" , 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAABJ0AAASdAHeZh94AAAAB3RJTUUH4QwNDgEDrNoaqgAAAOhJREFUOMulkz8OgjAUhz8MQ7mBkwnnkBAH4mbCCdxcXLwAoxdwYXHjBCRupoMheg4TJ29QNhwshMofSfpLOry2v6/vta8OUGEhF4DsbUx6L8XytkNKCUAURTxWZ9TCM93buQb8mFXiI4E43gCQ5xeQPt7x2YG4fWa0OQwDhBANRCVdyGyKOQyDJhuV+HgvZQLGzABCiEGI036FPnNbZVlSFPfvnWg1gJpea72OjPh6lUZcQ5yhPkjTkxHv94fpfcB23t81PftmWMr9e+pQZjobd6zuobX2fViXAFCRvSv9GtOH9ji23/kDswRrCVqtQOAAAAAASUVORK5CYII=')


//health params
project.ext.set("trayIcon", null)
project.ext.set("lastStatus", null)
project.ext.set("isStopHealthCheck", false)
project.ext.set("isHaltHealth", new AtomicBoolean(false) )
project.ext.set("startedAwait", Long.MAX_VALUE)
project.ext.set("logFile", 'C:/ProgramData/all.log')
project.ext.set("pomList" , ["${System?.getenv('SDC')}/catalog-fe/pom.xml" ,"${System?.getenv('SDC')}/catalog-be/pom.xml" ] )   //empty list will scan all openecomp poms
project.ext.set("pomChangesMap" , [:] )
project.ext.set("beConfigFilesToCopyMapping" , [ 'src/main/resources/config/*.yaml' : 'config/catalog-be/' ,
                                               'src/main/resources/config/*.properties' : 'config/catalog-be/'] )

//menu item strings
project.ext.set("toggleHealthString" , "Halt Health" )
//menu item
project.ext.set("toggleHealthItemView" , null )

//other
project.ext.set("IS_MVN_INSTALL",false)
project.ext.set("executor" , null )
project.ext.set("lockObj" , new Object() )
/*compile?.doLast {
    println "2. hello compile2"
}*/

/*def post(String host , String serviceName,String msg){
    // POST
    def post = new URL("$host/$serviceName").openConnection();
    def message = '{"message":"this is a message"}'
    post.setRequestMethod("POST")
    post.setDoOutput(true)
    post.setRequestProperty("Content-Type", "application/json")
    post.getOutputStream().write(message.getBytes("UTF-8"));
    def postRC = post.getResponseCode();
    println(postRC);
    if( postRC.equals(200)) {
        println(post.getInputStream().getText());
    }
}

def postStat( long operationTime, String user , String meta  ){
    def host = 'http://135.76.123.70:8888'
    def params = "user=$user&meta=$meta"
    post host , "UserStats" , params
}*/


def hash( List list ){
    def map = list?.collectEntries { File file -> [(file?.absolutePath) : file?.text?.hashCode() ]}

    map
}

def pomChanges(){
    long started = System.currentTimeMillis()
    if ( !pomList )
        listPom()
    //find hash changes
    def changes = pomList?.findAll {
        def File file = new File(it);
        pomChangesMap[it] != file?.text?.hashCode()
    }
    println "\n\n[MasterD][POM]--> detected changes for -> $changes"
    //update changes in map
    changes?.each { pomChangesMap[it] = new File(it)?.text?.hashCode() }
    println "\n\n[MasterD][POM]--> pom map -> $pomChangesMap"

    println """ 
            ****** POM changes detection finished after -> ${System.currentTimeMillis()- started}ms  ******
            """

    changes
}
//list pom with updated file hashes
def listPom(){
    long started = System.currentTimeMillis()
    if (!pomList) {
        def tree = fileTree( PROJECT_PATH ).include '**/pom.xml'//.filter { it.isFile() && it?.toString()?.toLowerCase()?.endsWith('pom.xml') }
        //println "$PROJECT_PATH list is ->${ list?.collect { it?.absolutePath } }"
        //flatten and filter openecomp poms
        pomList = tree?.flatten()?.findAll { File file -> file?.text?.contains('org.openecomp.sdc') }?.collect {File file -> file?.absolutePath }
    }
    pomChangesMap = pomList.collectEntries { absolutePath ->[ ( absolutePath ) : new File(absolutePath)?.text?.hashCode() ] }

    println """ [MasterD][Init] intializing POM detector

            *********       POM listing finished after -> ${System.currentTimeMillis()- started}ms    *********
            """
    return pomList
}


task initialization(){
    listPom()
    executor = Executors.newCachedThreadPool();
}

def parallel( closure ){
    executor?.submit(new Callable<Object>(){
        @Override
        public Object call() {
            closure();
            return null;
        }
    })
}
/*class Preferences {
    def String Username
    def String IsNewVagrant
    def String IsRapidMode
}

def initXFolder(){
    def folder = new File(X_FOLDER);
    folder?.exists() ?: folder?.mkdirs()

    new File("${folder?.absolutePath}/$PREFERENCES_FILENAME")
}*/

task tester{
    /*doLast{
        //postStat(10000, "shay" , "report/index")
        listPom()
        new File('catalog-be\\pom.xml') << "#hello"
        pomChanges()
    }*/
}


def fetchFilesByExtention(remote, local , ext ){
    ssh.run {
        def started = System.currentTimeMillis()
        println "folder diff"
        session(remotes.vagrant) {
            //execute "cd /home/vagrant/catalog-be/tmp ; ls -lt | grep catalog-be" //todo- use my dates to filter
            get from: remote  , into: local , filter: {  it?.absolutePath =~ /jetty.*catalog-be.*\.dir.*\.$ext/  } // {  it?.absolutePath =~ /.*catalog-be.*dir.*classes.*/  }
        }
        println "fetched files in ${System.currentTimeMillis() - started} ms"
    }
}

def updateRemoteFile(String remote , String local){
    ssh.run {
        def to = "$BE_REMOTE${remote[remote?.indexOf("tmp\\")..remote.size()-1].replaceAll("\\\\","/")}"
        println "copying $local \nto\n $to"
        session(remotes.vagrant) {
            put from: local  , into: to }
    }
}

def compareAndSwap(){
    def final LIMIT = 10
    def newClasses = new File("$PROJECT_PATH\\catalog-be\\target\\classes")
    def File jettyClasses ;
    //locate classes
    println "traversing.."
    new File("build/hotswap").traverse { if (it?.directory && it?.name?.equals("classes")){
        jettyClasses = it
        return;
    }  }
    def jettyClassesList = []
    jettyClasses?.traverse { jettyClassesList << it }

    println "$jettyClasses"
    //Sort compiled classes
    def files = []
    newClasses?.traverse {  files << it }
    def result = files.sort{ a,b -> b.lastModified() <=> a.lastModified() }
    println "show only last $LIMIT changes"
    result[0..LIMIT]?.each{ println it?.lastModified() +" | "+ it?.name + (it?.directory ? "[Directory]" : "") } //show only last 10 changes

    //update
    def changesMap = [ : ] //<old,new>
    println "updating changes"
    result[0..LIMIT]?.each { File f -> def File other = jettyClassesList.find{ File other-> other?.absolutePath?.endsWith(f?.name) };
        if ( !(f.directory) && f?.text?.hashCode() != other?.text?.hashCode() )
            updateRemoteFile( other?.getAbsolutePath() , f?.getAbsolutePath() )
    } //use hashing
}

task hotswap(){
    doLast {
        new File("build/hotswap")?.deleteDir()
        new File("build/hotswap")?.mkdirs()
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        fetchFilesByExtention( "$BE_REMOTE/tmp/" , 'build/hotswap' , "class")
        compareAndSwap()
    }
}

remotes {
    vagrant {
        host = '127.0.0.1'
        port = 2222
        user = VAGRANT_USER
        password = VAGRANT_PASSWORD
        identity = NEW_VAG ? new File(RSA_PRIVATE_KEY_PATH) : null
    }

}

def gitLatest(){

}

def newEcoSystem(){
    //cleanTitan()
    backupDB() //and clean all
    //restoreDB() //restore latest
    createSchema()
    fillSchema()
    postCreate()
    startAll()
    //todo- conside updating from git
    updaterBEFull()
    updaterFE()
}
def importHeatTypes(){
   //todo- impl
}
def postCreate(){
    importNormative()
    importHeatTypes()
}
def fillSchema(){
    // add conformence level
}
def createSchemaPreStep(){
    //todo- DB up
}
def createSchemaPostStep(){
    ////todo- impl create amdocs dox
}
def createSchema(){
    createSchemaPreStep()
    //todo- create schema
    //todo- create titan
    createSchemaPostStep()
}

def cleanTitan(){
    execSafe{
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                execute "cqlsh -e 'DROP KEYSPACE titan;'"
                println "[MasterD][DB_DROP]-> Dropped 'titan' KEYSPACE."
            }
        }
    }
}
task cleanTitan {
    doLast{
        cleanTitan()
    }
}

task fetchE2EDB(){
    doLast{
        fetchE2EDB()
    }
}
def fetchE2EDB(){
    execSafe{
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                def tmp = '$CASSANDRA_HOME/backup/e2e'
                //execute 'mkdir $CASSANDRA_HOME/backup/e2e/'
                //execute 'wget http://135.76.210.202:8080/ETE_backup_files/latest_ETE_backup_file.zip -P /vagrant/db'
                println "[MasterD] download finished, unzipping.."
                execute "unzip -u $tmp/latest_ETE_backup_file.zip" //execute 'unzip -u /vagrant/db/latest_ETE_backup_file.zip'//'
                def folder = execute "cd $tmp; ls -d -- */"
                println "[MasterD] unzipping finished into -> $folder , untaring.."
                execute "tar zxf $tmp/$folder/* --strip 3 -C" +'$CASSANDRA_HOME/data | pv -l >/dev/null'
                println "[MasterD][E2E_DB]-> Downloaded & unzipped e2e data successfully."
            }
        }
    }
}
def copyExplodedBE() {
    execSafe{
        println "[MasterD][BackEnd] copying exploded war."
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        long started = System.currentTimeMillis()
        def dirPath = "${PROJECT_PATH}/catalog-be/target/catalog-be-1.1.0-SNAPSHOT"
        def dir = new File(dirPath);
        println "[MasterD][BackEnd] copying ${dir?.directorySize()/(1024*1024)} MB, from ${dir?.name} to $BE_REMOTE/webapps"
                ssh.run {
                    session(remotes.vagrant) {
                        execute "rm -R $BE_REMOTE/webapps/catalog-be-1.1.0-SNAPSHOT"
                        put from: dir?.absolutePath , into: "$BE_REMOTE/webapps"
                    }
                }
        println "[MasterD][BackEnd] Successfully copied exploded war in ${System.currentTimeMillis()-started}ms."
    }
}
task copyExplodedBE(){
    doLast{
        copyExplodedBE()
    }
}
def backupDB() {
    execSafe{
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                execute 'mkdir -p $CASSANDRA_HOME/backup'
                def res = execute 'mv $CASSANDRA_HOME/data $CASSANDRA_HOME/backup/data_$(date +\'%Y_%m_%d__%H:%M:%S\')'
                println "[MasterD][DB_BACKUP]-> snapshot DB finished. $res"
            }
        }
    }
}
task backupDB{
    doLast{
        backupDB()
    }
}

def restoreDB(){
    execSafe{
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                println "[MasterD]-> restoring DB"
                execute 'mkdir -p $CASSANDRA_HOME/data'
                def res = execute 'mv $CASSANDRA_HOME/backup/data_*/* $CASSANDRA_HOME/data'
                println "[MasterD]-> DB restore FINISHED!! $res"
            }
        }
    }
}
task restoreDB() {
    doLast {
        restoreDB()
    }
}

def vm( ){
    exec{
        if (VAGRANT_HOME){
            workingDir VAGRANT_HOME	//vagrant path
            println "*****************\nworking dir -> $VAGRANT_HOME"
            commandLine "cmd","/c", "vagrant up"
            //args = [ ]
        } else {
            println "[MasterD]--> please define windows enviroment variable VAG pointing to vagrant project"
        }
    }
}

task vm{
    doLast{
        vm()
    }
}

def copyFE() {
    println "[MasterD][FrontEnd] starting war copy."
    ssh.settings {
        knownHosts = allowAnyHosts
    }
    long started = System.currentTimeMillis()
    def target = "${PROJECT_PATH}/catalog-fe/target/"
    def files = GFileUtils.listFiles( new File(target) , ["war"] as String[] , false);
    files?.each{ File file ->
        if (!file?.name?.contains('classes')){
            println "[MasterD][FrontEnd] copying ${file.length()/(1024*1024)} MB, from ${file?.name} to $FE_REMOTE/webapps"
            ssh.run {
                session(remotes.vagrant) {
                    put from: file?.absolutePath , into: "$FE_REMOTE/webapps"
                }
            }
        }

    }
    println "[MasterD][FrontEnd] Successfully copied war in ${System.currentTimeMillis()-started}ms."
}

task deployFE{
    doLast {
        copyFE()
    }
}


def copyBE(){
    println "[MasterD][BackEnd] starting war copy."
    ssh.settings {
        knownHosts = allowAnyHosts
    }
    def target = "${PROJECT_PATH}/catalog-be/target/"
    def files = GFileUtils.listFiles( new File(target) , ["war"] as String[] , false);
    long started = System.currentTimeMillis()
    files?.each{ File file ->
        if (!file?.name?.contains('classes')){
            println "[MasterD][BackEnd] copying ${file.length()/(1024*1024)} MB, from ${file?.name} to $BE_REMOTE/webapps"
            ssh.run {
                session(remotes.vagrant) {
                    put from: file?.absolutePath , into: "$BE_REMOTE/webapps"
                }
            }
        }
    }
    println "[MasterD][BackEnd] SUCCESSFULY copied be war in ${System.currentTimeMillis()-started}ms."
}

task deployBE {
    doLast {
        copyBE()
    }
}
def compileFE(){
    exec{
        println "[MasterD][FE]--> compiling project at -> ${PROJECT_PATH}\\catalog-fe"
        workingDir "${PROJECT_PATH}"	//vagrant path
        commandLine 'cmd','/c','mvn -T 2 compile -pl catalog-fe,catalog-ui -am -Pcatalog -Dmaven.test.skip'
    }
}
task compileFE(){
    doLast{
        compileFE()
    }
}
def compileBE(){
    exec{
        println "[MasterD][BE]--> compiling project at -> ${PROJECT_PATH}\\catalog-be"
        workingDir "${PROJECT_PATH}"	//vagrant path
        commandLine 'cmd','/c','mvn -T 2 compile -pl catalog-be -Pcatalog -Dmaven.test.skip'
    }
}
task compileBE{
    doLast{
        compileBE()
    }
}

def compile(){
    exec{
        println "[MasterD]--> compiling project at -> ${PROJECT_PATH}"
        workingDir "${PROJECT_PATH}"	//vagrant path
        commandLine 'cmd','/c','mvn -T 2 compile -am -Pcatalog -Dmaven.test.skip'
    }
}

task compile{
    doLast{
        compile()
    }
}
def compileDependencies(){
    def cmd = IS_MVN_INSTALL ? 'install' : 'compile'
    exec{
        println "[MasterD]--> compiling BE dependencies  -> $BE_DEPENDENCIES [ SKIPPING TESTS!! ]"
        workingDir "${PROJECT_PATH}"	//vagrant path
        commandLine 'cmd','/c',"mvn $cmd -pl $BE_DEPENDENCIES -Pcatalog -Dmaven.test.skip" //commandLine 'cmd', '/c','mvn -T 1C package -pl catalog-model,catalog-dao,catalog-be -P catalog -Dmaven.test.skip'
    }
}
task compileDependencies {
    doLast{
        compileDependencies()
    }
}
def compileWar(){
    def cmd = IS_MVN_INSTALL ? 'install' : 'compile'
    exec{
        println "--> compiling project at -> ${PROJECT_PATH}\\catalog-be"
        workingDir "${PROJECT_PATH}"	//vagrant path
        commandLine 'cmd','/c',"mvn -T 1 $cmd war:war -pl catalog-be -Pcatalog -Dmaven.test.skip" //commandLine 'cmd', '/c','mvn -T 1C package -pl catalog-model,catalog-dao,catalog-be -P catalog -Dmaven.test.skip'
    }
}
task compileWar(){
    doLast{
        compileWar()
    }
}

//deprecated - use deployBE()
task be() {
    doLast{
        def started = System.currentTimeMillis();
        exec{
            println "[MasterD]--> copying be... [from $VAGRANT_HOME]"
            workingDir VAGRANT_HOME	//vagrant path
            commandLine 'cmd','/c', 'copy_war_be.bat','localhost' , "$PROJECT_PATH\\catalog-be\\target\\catalog-be*.war" , "$BE_REMOTE/webapps"
            //args = [ ]
        }
        println """
                ****    copying finished in -> ${System.currentTimeMillis() - started}ms         ****
                """
    }
}

task beConfig( ) {
    doLast{
        exec{
            workingDir "${System.env.VAG}"	//vagrant path
            commandLine 'cmd','/c','copy_war_be_with_configuration','localhost' , "$PROJECT_PATH\\catalog-be\\target\\catalog-be*.war" , "$BE_REMOTE/webapps"
            //args = [ ]
        }
    }

}
task feConfig( ) {
    doLast{
        exec{
            workingDir "${System.env.VAG}"	//vagrant path
            commandLine 'cmd','/c','copy_war_fe_with_configuration','localhost' , "$PROJECT_PATH\\catalog-fe\\target\\catalog-fe*.war" , "$FE_REMOTE/webapps"
            //args = [ ]
        }
    }

}

task fe() {
    doLast{
        exec {
            workingDir "${System.env.VAG}"    //vagrant path
            commandLine 'cmd','/c', 'copy_war_fe.bat', 'localhost', "$PROJECT_PATH\\catalog-fe\\target\\catalog-fe*.war", "$FE_REMOTE/webapps"
            //args = [ ]
        }
    }
}

def installAllProject(){
    exec{
        println "[MasterD]--> Compiling&Installing project at -> ${PROJECT_PATH}"
        workingDir "${PROJECT_PATH}"	//vagrant path
        commandLine 'cmd','/c','mvn -T 2 clean install -U -Pcatalog -Dmaven.test.skip'
    }
}
task installAllProject {
    doLast {
        installAllProject()
    }
}

task installAll {
    doLast{
        println '[MasterD]--> Finished!!'
    }
}
installAll.dependsOn { tasks.findAll { task -> task.name.startsWith('install_') } }

def install_BE(){
    exec {
            println '[MasterD][Install]--> Installing BE!!'
            workingDir "${PROJECT_PATH}"
            commandLine 'cmd','/c', 'mvn clean install -pl catalog-be -am -Pcatalog -Dmaven.test.skip'
            //args = [ ]
    }
}

task install_BE() {
    doLast{
        install_BE()
    }
}

def install_FE() {
    exec {
        workingDir "${PROJECT_PATH}"
        commandLine 'cmd','/c', 'mvn clean install -pl catalog-ui,catalog-fe -am -Pcatalog -Dmaven.test.skip'
    }
}
task install_FE() {
    doLast {
        install_FE()
    }
}

def updaterBERapid(){
    /* if ( ticket() > PREVIOUS_BUILD_VAR ){
     PREVIOUS_BUILD_VAR = ticket()*/
    def started = System.currentTimeMillis();
    println "[MasterD][Rapid]--> compiling changes using maven"
    compileWar()
    println "[MasterD][Rapid]--> copying war"
    copyBE() //use this if you want to deploy entire war //hotswap.execute()
    restartBackend()
    println msg(" redeploy finished in -> ${System.currentTimeMillis() - started}ms ")
}
task updaterBERapid(){
    doLast {
        updaterBERapid()
    }
}
def updaterBE(){
    def started = System.currentTimeMillis();
    IS_MVN_INSTALL = pomChanges() ? true :  false
    println "[MasterD]--> compiling changes using maven"
    compileDependencies()
    compileWar()
    println "[MasterD]--> copying war"
    IS_HOTSWAP ? copyExplodedBE() : copyBE() //execute() //use this if you want to deploy entire war //hotswap.execute()
    restartBackend()
    println msg("redeploy finished in -> ${System.currentTimeMillis() - started}ms ")
}
task updaterBE(){
    doLast {
        updaterBE()
    }
}
def copyBEConfiguration(){
/*    execSafe {
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                println msg("Stopping BackEnd Server")
                execute command[BACKEND][STOP]()
            }
        }
    }*/
}
def updaterBEFull(){
    def started = System.currentTimeMillis();
    compile()
    println "[MasterD]--> copying war"
    copyBE() //use this if you want to deploy entire war //hotswap.execute()
    copyBEConfiguration()
    println msg("redeploy finished in -> ${System.currentTimeMillis() - started}ms ")
}
task updaterBEFull(){
    doLast {
        updaterBEFull()
    }
}
def copyFEConfiguration(){
    //todo- implement
}
def updaterFE(){
    def started = System.currentTimeMillis();
    println "[MasterD]--> compiling changes using maven"
    compileFE()
    println "[MasterD]--> copying war"
    copyFE() //.execute() //use this if you want to deploy entire war //hotswap.execute()
    copyFEConfiguration()
    println msg("redeploy finished in -> ${System.currentTimeMillis() - started}ms ")
}
task updaterFE(){
    doLast {
      updaterFE()
    }
}
def stopBackend(){
    execSafe {
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                println msg("Stopping BackEnd Server")
                execute command[BACKEND][STOP]()
            }
        }
    }
}
task stopBackend(){
    doLast {
        stopBackend()
    }
}

def startBackend(){
    execSafe {
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                println msg("[MasterD] starting backend sever")

                execute command[BACKEND][START]()
            }
        }
    }
    println """[MasterD]->  finished !!
					    """
}
task startBackend(){
    doLast{
        startBackend()
    }
}

def restartBackend(){
    execSafe {
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                println msg("[MasterD] restarting backend sever")

                execute command[BACKEND][RESTART]()
            }
        }
    }
    println """[MasterD]->  finished !!
					    """
}
//todo- remove this if you want to auto-deploy on every file save
/*
compileJava.doFirst{
    updater?.execute()
}*/

enum STATUS { UP, DOWN , UNKNOWN , UNAVAILABLE }

task health(){
    doLast {
        prepareTray()
    }
}

def execSafe( closure){
   if (!lockObj) {
        [0..4].forEach( {println "Critical ERROR : lock object is not initialized\n\nCritical ERROR : cannot run tasks\n"}() )
        return;
   }
   synchronized (lockObj){
           boolean prev = isHaltHealth.get()
           try {
               isHaltHealth.set(true)
               closure()
           } catch (Exception e) {
               println e
           } finally {
               isHaltHealth.set(prev)
           }
   }
}

def fetchFiles( remote, local ){
    ssh.run {
        session(remotes.vagrant) {
            //execute "cd /home/vagrant/catalog-be/tmp ; ls -lt | grep catalog-be" //todo- use my dates to filter
            def f = get from: remote  , into: local
            println f?.name
            //return f
        }
        //println "fetched files in ${System.currentTimeMillis() - started} ms"
    }

    //return null
}


def killJava(){
    execSafe {
        def res
        ssh.run {
            session( remotes.vagrant ) {
                println """					 *-*-****************************-*-*
								killing all java proccesses
						*-*-****************************-*-*
					"""
                res = execute command[ALL][KILL]()
            }
        }
        println res?.toString()
    }
}

def importNormative(){
    execSafe {
        ssh.run {
            session(remotes.vagrant) {
                println """					 *-*-************************************-*-*
											importNormative
								*-*-************************************-*-*
							"""
                execute "python -v $BE_REMOTE/scripts/import/tosca/importNormativeAll.py"
            }
        }
    }
}

def startAll(){
    def startCassandra = """
                        #!/bin/bash
                        
                        cassandra&
                        elasticsearch -d
                        
                        #Wait until ES is up
                        until curl localhost:9200/_cluster/health;
                        do
                            printf "."
                            sleep 3
                        done
                        
                        # Create Elastic Mapping if not exist in ES
                        createESMapping.sh
                        """
    execSafe {
        ssh.run {
            session(remotes.vagrant) {
                println """					 *-*-************************************-*-*
								starting all SDC services(DB,BE,FE,Webseal)
							*-*-************************************-*-*
				"""
                if ( NEW_VAG ){
                    execute command[DB][START]()
                    Thread.sleep(5000)
                    execute command[CACHING][START]()
                }
                else
                    execute startCassandra
                //[0..4]?.forEach( Thread?.sleep(2000) )
                Thread?.sleep(10000)
                Thread?.sleep(10000)
                execute command[BACKEND][START]()
                execute command[FRONTEND][START]()
                execute command[SECURITY][START]()
            }
        }
    }
}


/*def clearLog(type: Delete){
    delete{
        delete 'C:/ProgramData/all.log'
        followSymlinks = true
    }
}*/
task clearLog(type: Delete){
    doLast{
        delete 'C:/ProgramData/all.log'
        followSymlinks = true
    }
}
def logBE(){
    try{
        println "\n*** logging BE all.log ***\n"

            ssh.run {
                session( remotes.vagrant ) {
                    //String now = execute 'echo \"\$(date +\'%Y_%m_%d\')\"'
                    //println "\n\n*******************************************************\n\n"+now?.toString()
                    clearLog?.execute() //todo- remove this .execute()
                    fetchFiles( '/home/vagrant/catalog-be/logs/SDC/SDC-BE/all.log' , 'C:/ProgramData') //"%USERPROFILE%\AppData\Local\")
                    //project.ext.set( "logFile" , 'C:/ProgramData/all.log' )

                    //				-f /home/vagrant/catalog-fe/logs/*$now.stderrout.log -f /home/vagrant/catalog-be/logs/*$now.stderrout.log -f /home/vagrant/catalog-be/logs/ASDC/ASDC-BE/debug.log*'
                }
            }

        parallel {
            exec {
                //if ( logFile ){
                String notepad = 'C:\\Program Files (x86)\\Notepad++\\notepad++.exe'
                println "logging $logFile to notepad++ [$notepad]"
                commandLine 'cmd','/c' , notepad ,logFile
            }
        }
    }catch(Exception e){
        println "cannot open logs!!!"
        e.printStackTrace()
    }
}
task logBE(){
    doLast{
        logBE()
    }
}

def toggleHealthPolling(){
    isHaltHealth.set(!isHaltHealth.get())
}
//converts predefined icon to Image
def Image convert( imageName ){
    String encodedimage = project.ext.get(imageName);
    byte[] byteImage = encodedimage?.split(',')[1]?.decodeBase64()
    Image image = ImageIO.read(new ByteArrayInputStream(byteImage));
}

def refreshMenu(String imageName){
    switch( imageName ) {
        case 'unavailableImg' : toggleHealthString = "Resume Health";  break;
        default : toggleHealthString = "Halt Health";
    }
    if (((MenuItem)toggleHealthItemView).getLabel() != toggleHealthString)
        ((MenuItem)toggleHealthItemView).setLabel(toggleHealthString);
}
def startDB(){
        println "[MasterD] Starting database.."
        execSafe {
            ssh.settings {
                knownHosts = allowAnyHosts
            }
            ssh.run {
                session(remotes.vagrant) {
                    execute command[DB][START]()
                }
            }
        }
}
task startDB(){
    doLast {
        startDB()
    }
}
def stopDB(){
    execSafe {
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                execute command[DB][STOP]()
            }
        }
    }
}
task stopDB(){
    doLast {
        stopDB()
    }
}
def startFE(){
    execSafe {
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                execute command[FRONTEND][START]()
            }
        }
    }
}
task startFE(){
    doLast {
        startFE()
    }
}
def stopFE(){
    execSafe {
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vagrant) {
                execute command[FRONTEND][STOP]()
            }
        }
    }
}
task stopFE(){
    doLast {
        stopFE()
    }
}

def ActionListener newListener( closure  ){
    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                    closure()
            } catch (AWTException e1) {
                System.err.println(e1);
            }
        }
    }

    listener
}

ext.updateTray = { STATUS status ->
    lastStatus = status
    if (SystemTray.isSupported()) {
        // get the SystemTray instance
        SystemTray tray = SystemTray.getSystemTray();
        // load an image
        String imageName = status==STATUS.UP ? (Math.random()>0.5 ?'okImg1':'okImg2') : status==STATUS.UNAVAILABLE ? 'unavailableImg' : status==STATUS.DOWN ? 'errorImg' : 'warnImg'
        Image image = convert imageName
        if (trayIcon != null) {
            trayIcon.setImage(image)
            refreshMenu(imageName);
            return ;
        }
        //region  -> Menu UI
        // create a popup menu
        PopupMenu popup = new PopupMenu();
        // create menu item for the default action

        MenuItem hotswapItem = new MenuItem("===> WAR <===");
        hotswapItem.setFont(new Font("MONOSPACED" , Font.BOLD ,15f ))

        //region Multilevel Menus
        Menu deployMasterMenu = new Menu("DeployMaster");
        Menu backendMenu = new Menu("Backend");
        Menu frontendMenu = new Menu("Frontend");
        Menu dbMenu = new Menu("Database");
        try{
            deployMasterMenu.setFont(new Font("Cooper Black" ,Font.BOLD ,14f ))
            backendMenu.setFont(new Font("Cooper Black" ,Font.PLAIN ,13f ))
            frontendMenu.setFont(new Font("Cooper Black" ,Font.PLAIN ,13f ))
            dbMenu.setFont(new Font("Cooper Black" ,Font.PLAIN ,13f ))
        }catch(Exception e){
            println e
        }

        //DeployMaster Menu
        MenuItem updaterBeWithDependenciesItem = new MenuItem("[BE] Quick Compile -> Deploy");
        MenuItem updaterFullBeItem = new MenuItem("[BE] Full Install  -> Deploy");
        MenuItem updaterFeItem = new MenuItem("[FE] Quick Compile -> Deploy");
        MenuItem updaterFullFeItem = new MenuItem("[FE] Full Install -> Deploy");

        //Menu UI build

        deployMasterMenu.add(updaterFullBeItem);
        deployMasterMenu.add(updaterBeWithDependenciesItem);

        deployMasterMenu.addSeparator();
        deployMasterMenu.add(updaterFullFeItem);
        deployMasterMenu.add(updaterFeItem);


        //BE menu
        MenuItem startItem = new MenuItem("[BE] Start");
        MenuItem stopItem = new MenuItem("[BE] Stop BackEnd");
        MenuItem copyBeWarItem = new MenuItem("[BE] Copy War");
        backendMenu.add(startItem);
        backendMenu.add(stopItem);
        backendMenu.add(copyBeWarItem);

        //FE menu
        MenuItem startFEItem = new MenuItem("[FE] Start");
        MenuItem stopFEItem = new MenuItem("[FE] Stop");
        MenuItem copyFeWarItem = new MenuItem("[FE] Copy War");
        frontendMenu.add(startFEItem);
        frontendMenu.add(stopFEItem);
        frontendMenu.add(copyFeWarItem);

        //DB menu
        MenuItem startDBItem = new MenuItem("[DB] Start");
        MenuItem stopDBItem = new MenuItem("[DB] Stop");
        MenuItem backupDBItem = new MenuItem("[DB] Backup");
        MenuItem restoreDBItem = new MenuItem("[DB] Restore");
        dbMenu.add(startDBItem);
        dbMenu.add(stopDBItem);
        dbMenu.add(backupDBItem);
        dbMenu.add(restoreDBItem);
        //endregion


        MenuItem killItem = new MenuItem("Kill All");
        MenuItem startAllItem = new MenuItem("Start All");
        MenuItem importItem = new MenuItem("Import Normative");
        MenuItem healthInfoItem = new MenuItem("[Info] Health");
        MenuItem toggleHealthItem = new MenuItem(toggleHealthString);
        MenuItem logsItem = new MenuItem("Logs [Beta]");
        MenuItem exitItem = new MenuItem("Exit");

        toggleHealthItemView = toggleHealthItem;

        popup.add(hotswapItem);
        popup?.addSeparator();
        popup.add(deployMasterMenu);
        popup?.addSeparator();
        popup.add(backendMenu)
        popup.add(frontendMenu)
        popup.add(dbMenu)
        popup?.addSeparator();
        popup.add(startAllItem);
        popup.add(killItem);
        popup?.addSeparator();
        popup.add(toggleHealthItem);
        popup.add(healthInfoItem);
        popup?.addSeparator();
        popup.add(importItem);
        popup.add(logsItem);
        popup?.addSeparator();
        popup.add(exitItem);
        //endregion UI
        // construct a TrayIcon
        trayIcon = new TrayIcon(image, "HealthTray", popup);

        //region -> Button actions
        def listenerHotswap = newListener { project.ext.set("IS_HOTSWAP", !IS_HOTSWAP); hotswapItem?.setLabel( IS_HOTSWAP ? "==> HotSwap <==" : "===> WAR <===")   }
        // create a action listener to listen for default action executed on the tray icon
        def listenerFullBE = newListener { parallel { install_BE(); IS_HOTSWAP ? copyExplodedBE() : copyBE(); restartBackend() } }
        def listenerFullFE = newListener { parallel { install_FE(); copyFE() } }
        ActionListener listenerFE = newListener { parallel { updaterFE() } }
        ActionListener listenerBE = newListener { parallel { updaterBE() } }
        ActionListener exitListener = newListener {
                    executor?.isShutdown() ?: executor?.shutdown()
                    tray.remove(trayIcon);
                    project.ext.set("isStopHealthCheck", true)
                    println "Shutting down.. bye bye.."
                }
        ActionListener stopBackendListener = newListener { stopBackend() }
        ActionListener startBEListener = newListener { parallel { startBackend() } }
        ActionListener killJavaListener = newListener { killJava() }

        ActionListener startAllListener = newListener { parallel { startAll() } }

        ActionListener listener5 = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    parallel { importNormative() }
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        };

        ActionListener listener6 = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    parallel { healthPopup() }
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        };

        ActionListener listener7 = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    logBE()//tasks.logger.execute()
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        };
        ActionListener listener8 = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    toggleHealthPolling()//tasks.logger.execute()
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        };
        ActionListener copyBeWarListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    parallel { copyBE() }//.execute()//tasks.logger.execute()
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        };

        ActionListener startDBListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    parallel {
                        startDB()
                    }//tasks.logger.execute()
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        }

        ActionListener stopDBListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    stopDB()//tasks.logger.execute()
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        }

        ActionListener dbBackupListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    parallel {
                        backupDB()//tasks.logger.execute()
                    }
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        }

        ActionListener feStartListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    parallel {
                        startFE()
                    }//tasks.logger.execute()
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        }

        ActionListener feStopListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    stopFE()//tasks.logger.execute()
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        }

        ActionListener feCopyListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    parallel {
                        copyFE() //.execute()//tasks.logger.execute()
                    }
                } catch (AWTException e1) {
                    System.err.println(e1);
                }
            }
        }


        //def listenerFullModules = newListener { parallel { installAllProject() } }
        //region -> Button<=Listener
        hotswapItem.addActionListener(listenerHotswap)
        updaterFeItem.addActionListener(listenerFE)
        updaterFullBeItem.addActionListener( listenerFullBE )
        updaterBeWithDependenciesItem.addActionListener( listenerBE )
        updaterFullFeItem.addActionListener( listenerFullFE )
        stopItem.addActionListener(stopBackendListener)
        startItem.addActionListener(startBEListener)
        copyBeWarItem.addActionListener(copyBeWarListener);
        killItem.addActionListener(killJavaListener)
        startAllItem.addActionListener(startAllListener)
        importItem.addActionListener(listener5)
        healthInfoItem.addActionListener(listener6)
        toggleHealthItem.addActionListener(listener8)
        logsItem.addActionListener(listener7)
        exitItem.addActionListener(exitListener)

        startDBItem.addActionListener( startDBListener )
        stopDBItem.addActionListener( stopDBListener )
        backupDBItem.addActionListener( dbBackupListener )
        copyFeWarItem.addActionListener( feCopyListener )
        startFEItem.addActionListener( feStartListener )
        stopFEItem.addActionListener( feStopListener )
        //endregion
        //endregion
        // set the TrayIcon properties

        // ...
        // add the tray image
        try {
            tray.add(trayIcon);

        } catch (AWTException e) {
            System.err.println(e);
        }
        // ...
    } else {
        println "Java TrayIcon Option is not supported in your System, try enabling it. Bye Bye"
    }

}

def prepareTray(){
    long UPDATE_THRESHOLD = 3500
    float SCALAR = 1
    ssh.settings {
        knownHosts = allowAnyHosts
    }
    while(!isStopHealthCheck) {
        if (!isHaltHealth.get()) {    //if await or await is more then 60 second return health check
            ssh.run {
                session(remotes.vagrant) {
                    try {
                        def healthOutput = execute command[ALL][HEALTH]()
                        if (healthOutput?.contains("Failed command .* with status 7") || healthOutput?.contains("Problem accessing /sdc2/rest/healthCheck"))
                            updateTray(STATUS.DOWN)
                        def statusCollecion = healthOutput?.findAll "\"healthCheckStatus\": \".*\""
                        def upCount = statusCollecion?.count { it?.contains("UP") }
                        def downCount = statusCollecion?.count { it?.contains("DOWN") }
                        def uknownCount = (statusCollecion?.size() - upCount) - downCount
                        println " UP -> $upCount | downCount=$downCount | uknownCount=$uknownCount "
                        (uknownCount > 0 || (downCount > 0 && upCount > 0)) ? updateTray(STATUS.UNKNOWN) : ((upCount > 0) ? updateTray(STATUS.UP) : updateTray(STATUS.DOWN))
                        SCALAR = 1
                    } catch (Exception e) {
                        updateTray(STATUS.DOWN)
                        println e
                        SCALAR = Math.min(SCALAR * 1.1, 5) //slow down on errors
                    }
                    //green color effects
                    if (lastStatus && lastStatus == STATUS.UP) {
                        trayIcon.setImage(convert(Math.random() > 0.5 ? 'okImg1' : 'okImg2'))
                        //randomly green change color
                    }
                    Thread.yield()
                    Thread?.sleep((long) (UPDATE_THRESHOLD * SCALAR))
                }
            }
        }else{
            updateTray(STATUS.UNAVAILABLE)
            Thread.yield()
        }
    }
}

def healthPopup(){
    ssh.run {
        session(remotes.vagrant) {
            def healthOutput = execute command[ALL][HEALTH]()
            JOptionPane.showMessageDialog(null,
                    healthOutput,
                    "HEALTH",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }
}

project.ext.set("msg", { content -> """
                        ************************************************************************************************
                        ************************************************************************************************
                        *******                                                                                *********
                        **************                                                                  ****************
                                                $content      

                        ************************************************************************************************
                        ************************************************************************************************
                        """} )
