def __init__(self, module):
        '''
        Constructor
        '''
        ActionBundle.__init__(self, module)
        euclidModule = module.subModule
        
        # Generate a unique ActionBundle execution id
        guid = generateGUID()
        log.info("Unique ActionBundle execution ID generated: " + guid)
        
        # Check if JBOSS is running
        if getProcessPIDByPath(module.targetDeploymentPath): die("The JBOSS server at '" + module.targetDeploymentPath + "' is up. Installation will not continue")        
        
        # Prepare directory to unpack package
        unzippedPackagePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "unzippedPackage")
        
        # Prepare backup directory
        backupPath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "backup")
        
        # Prepare explode wars directory
        explodePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "explode")        
        
        # Prepare configuration directory
        configDirectoryPath = createDirectoriesRecursively(euclidModule.euclidConfigDir)
        
        # Since Euclid is deployed on JBOSS some paths have an %s to allow a configurable 
        # config dir, so do a little sprintf to fix them
        sprintfOnDictionaryValues(module.relativeConfigurationFiles, module.targetDeploymentProfile) 
        sprintfOnDictionaryValues(euclidModule.relativeMergableConfigurationFiles, euclidModule.euclidConfigDir)
        # Since Euclid is deployed on JBOSS some paths have an %s to allow a configurable 
        # server profile, so do a little sprintf to fix them   
        sprintfOnDictionaryValues(module.relativeCopyableFilesOrFolders, module.targetDeploymentProfile) 
        sprintfOnDictionaryValues(euclidModule.relativeWarsToBeExploded, module.targetDeploymentProfile)

        # Extract package into tmp dir
        ExtractZipToDir(module.moduleFilename, unzippedPackagePath)
        
        # Configure relativeConfigurationFiles
        for k, v in module.relativeConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
            replaceInsensitiveStringInFile("${CREATE_SCHEMA}", "true", exactExtractedLocation)
            CheckFileConfigurationIsComplete(exactExtractedLocation)
        
        # Configure relativeMergableConfigurationFiles
        for k, v in euclidModule.relativeMergableConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
            replaceInsensitiveStringInFile("${CREATE_SCHEMA}", "true", exactExtractedLocation)
            CheckFileConfigurationIsComplete(exactExtractedLocation)
        
        # Explode wars
#        for k, v in euclidModule.relativeWarsToBeExploded.items():
#            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
#            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v
#            backupFileOrDirIfExists(exactTargetLocation,backupPath)
#            ExtractZipToDir(exactExtractedLocation, exactTargetLocation)
        for k, v in euclidModule.relativeWarsToBeExploded.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            i = rfind(k, scriptGlobals.osDirSeparator)
            if i > -1: 
                tmpExplodeWarLocation = explodePath + scriptGlobals.osDirSeparator + k[i+1:]
            else:
                tmpExplodeWarLocation = explodePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            createDirectoriesRecursively(tmpExplodeWarLocation)
            ExtractZipToDir(exactExtractedLocation, tmpExplodeWarLocation)
            AltMoveDirOrFile(tmpExplodeWarLocation,exactTargetLocation)
            
        # Copy config files
        for k, v in module.relativeConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation) 
        # Copy mergable config files (no need to merge on clean install)
        for k, v in euclidModule.relativeMergableConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation)       
        # Copy other files
        for k, v in module.relativeCopyableFilesOrFolders.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation)
    def __init__(self, module):
        '''
        Constructor
        '''
        ActionBundle.__init__(self, module)
        euclidModule = module.subModule
        
        # Generate a unique ActionBundle execution id
        guid = generateGUID()
        log.info("Unique ActionBundle execution ID generated: " + guid)
        
        # Check if JBOSS is running
        if getProcessPIDByPath(module.targetDeploymentPath): die("The JBOSS server at '" + module.targetDeploymentPath + "' is up. Installation will not continue")        
        
        # Prepare directory to unpack package
        unzippedPackagePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "unzippedPackage")
        
        # Prepare backup directory
        backupPath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "backup")
        
        # Prepare explode wars directory
        explodePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "explode")
        
        # Prepare configuration directory
        configDirectoryPath = createDirectoriesRecursively(euclidModule.euclidConfigDir)
        
        # Since Euclid is deployed on JBOSS some paths have an %s to allow a configurable 
        # config dir, so do a little sprintf to fix them
        sprintfOnDictionaryValues(module.relativeConfigurationFiles, module.targetDeploymentProfile) 
        sprintfOnDictionaryValues(euclidModule.relativeMergableConfigurationFiles, euclidModule.euclidConfigDir)
        # Since Euclid is deployed on JBOSS some paths have an %s to allow a configurable 
        # server profile, so do a little sprintf to fix them   
        sprintfOnDictionaryValues(module.relativeCopyableFilesOrFolders, module.targetDeploymentProfile) 
        sprintfOnDictionaryValues(euclidModule.relativeWarsToBeExploded, module.targetDeploymentProfile)

        # Extract package into tmp dir
        ExtractZipToDir(module.moduleFilename, unzippedPackagePath)
        
        versionTmpPath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "tmp")
        installedWarPath = module.targetDeploymentPath + scriptGlobals.osDirSeparator + "server" + scriptGlobals.osDirSeparator + module.targetDeploymentProfile + scriptGlobals.osDirSeparator + "deploy" + scriptGlobals.osDirSeparator + module.name + ".war"
        installedVersionInfo = getVersionInfoFromWar(installedWarPath, module.relativeVersionInformationPath, module.versionInformationRegex, module.revisionInformationRegex, versionTmpPath)
        newWarPath = unzippedPackagePath + scriptGlobals.osDirSeparator + "bin" + scriptGlobals.osDirSeparator + module.name + ".war"
        newVersionInfo = getVersionInfoFromWar(newWarPath, module.relativeVersionInformationPath, module.versionInformationRegex, module.revisionInformationRegex, versionTmpPath)
        log.info("\n------ UPDATE VERSION INFO ------------------------" + 
                 "\nCurrently installed: " + installedVersionInfo[0] + " (" + installedVersionInfo[1] + ")" + 
                 "\n    To be installed: " + newVersionInfo[0] + " (" + newVersionInfo[1] + ")" +
                 "\n---------------------------------------------------")
        versionSameOrNewer=False
        if compareVersions(newVersionInfo[0], installedVersionInfo[0]) < 0 :
            versionSameOrNewer=True
            continueOrCancel("\nWARNING: Installed version is newer! If you continue the installation DB migration will not be executed.")
        elif compareVersions(newVersionInfo[0], installedVersionInfo[0]) == 0 :
            versionSameOrNewer=True
            continueOrCancel("\nWARNING: Same version already installed! If you continue the installation DB migration will not be executed.")
        
        # Configure relativeConfigurationFiles
        for k, v in module.relativeConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
            replaceInsensitiveStringInFile("${CREATE_SCHEMA}", "false", exactExtractedLocation)
            CheckFileConfigurationIsComplete(exactExtractedLocation)
        
        # Configure relativeMergableConfigurationFiles
        for k, v in euclidModule.relativeMergableConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
            replaceInsensitiveStringInFile("${CREATE_SCHEMA}", "false", exactExtractedLocation)
            CheckFileConfigurationIsComplete(exactExtractedLocation)
        
        # Explode wars
#        for k, v in euclidModule.relativeWarsToBeExploded.items():
#            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
#            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v
#            backupFileOrDirIfExists(exactTargetLocation,backupPath)
#            ExtractZipToDir(exactExtractedLocation, exactTargetLocation)
        for k, v in euclidModule.relativeWarsToBeExploded.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            i = rfind(k, scriptGlobals.osDirSeparator)
            if i > -1: 
                tmpExplodeWarLocation = explodePath + scriptGlobals.osDirSeparator + k[i+1:]
            else:
                tmpExplodeWarLocation = explodePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            createDirectoriesRecursively(tmpExplodeWarLocation)
            ExtractZipToDir(exactExtractedLocation, tmpExplodeWarLocation)
            AltMoveDirOrFile(tmpExplodeWarLocation,exactTargetLocation)
        
        # Copy config files
        for k, v in module.relativeConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation) 
            
        # Copy merge config files and copy (just copy for now)
        for k, v in euclidModule.relativeMergableConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation)
#            secondaryFileName = unzippedPackagePath + scriptGlobals.osDirSeparator + k
#            mergedFileName = secondaryFileName+".merged"
#            primaryFileName = v 
#            MergeSectionlessConfigFiles(primaryFileName, secondaryFileName, mergedFileName)
#            CopyDirOrFile(mergedFileName, primaryFileName)      

        # Copy other files
        for k, v in module.relativeCopyableFilesOrFolders.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation)
        
        #Construct DB connection string
        if versionSameOrNewer:
            log.info("Skipping DB migration scripts execution!")
            return
        dbUsername = readPropertyFromPropertiesFile("DB_CONNECTION_USERNAME", module.name, lib.OptParser.options.envprops)
        dbPassword = readPropertyFromPropertiesFile("DB_CONNECTION_PASSWORD", module.name, lib.OptParser.options.envprops)
        connUrl = readPropertyFromPropertiesFile("DB_CONNECTION_URL", module.name, lib.OptParser.options.envprops)
        finalConnectionString = string.replace(connUrl, '@', dbUsername + '/' + dbPassword + '@', 1)
        
        # Execute DB migration scripts
        confParser = ConfigParser.ConfigParser()
        confParser.read(unzippedPackagePath + scriptGlobals.osDirSeparator + euclidModule.relativeDatabaseUpgrateDescriptionFilePath)
        ok, scripts, default = getDbUpdateScriptsToRun(installedVersionInfo[0], confParser)
        if ok == False:
            continueOrCancel("\nERROR: This installer does not support updating from " + installedVersionInfo[0] + " version!")
        elif len(default)>0:
            log.info('DB update scripts to be executed:\n' + string.join(scripts, ", "))
            continueOrCancel("\nWARNING: Default DB update scripts are used for branch(es) " + string.join(default,", ") + ". This is probably probably OK, but you should make sure that the currently installed version is supported by the update procedure (please read the deployment instructions or consult with the development team).")
        else:
            log.info('DB update scripts to be executed:\n' + string.join(scripts, ", "))
        baseDbScriptPath = unzippedPackagePath + scriptGlobals.osDirSeparator + module.relativeDatabaseUpgradeFilePath + scriptGlobals.osDirSeparator
        for script in scripts:
            #print "Execute: " + baseDbScriptPath + script
            RunOracleScriptFromFile(baseDbScriptPath + script, finalConnectionString)