class UpgradeUtil {

    public static boolean rollbackUpgrade( RollbackSpec rollbackSpec )
    {

        if ( rollbackSpec == null )
        {
            logger.debug( "RollbackSpec is null." );
            return false;
        }

        final String upgradeId = rollbackSpec.getId();
        if ( StringUtils.isBlank( upgradeId ) )
        {
            logger.debug( "RollbackSpec id is either null or blank." );
            return false;
        }

        final String upgradeDir = UpgradeUtil.getUpgradeDir( upgradeId );
        final String rollbackScript = HmsConfigHolder.getHMSConfigProperty( ROLLABACK_SCRIPT );
        final String hmsParentDir = HmsConfigHolder.getHMSConfigProperty( HMS_PARENT_DIR );
        final String hmsDir = HmsConfigHolder.getHMSConfigProperty( HMS_DIR );

        if ( rollbackScript != null && hmsParentDir != null && hmsDir != null )
        {

            final String rollbackScriptAbsPath = FilenameUtils.concat( upgradeDir, rollbackScript );
            List<String> cmdWithArgs = new ArrayList<String>();

            // SCRIPT TO BE EXECUTED
            cmdWithArgs.add( 0, rollbackScriptAbsPath );

            // HMS_TOKEN
            cmdWithArgs.add( 1, upgradeId );

            // HMS_SCRIPT_DIR
            cmdWithArgs.add( 2, upgradeDir );

            // HMS_OOB_BACKUP_DIR_FULLPATH
            String backupDirAbsPath = FilenameUtils.concat( hmsParentDir, "hms_backup_" + upgradeId );
            cmdWithArgs.add( 3, backupDirAbsPath );

            // HMS_DIR_FULLPATH
            cmdWithArgs.add( 4, hmsDir );

            int exitValue = ProcessUtil.getCommandExitValue( cmdWithArgs );
            if ( exitValue == 0 )
            {
                return true;
            }
            else
            {
                logger.debug( "Error while executing rollback script. Script execution returned: {}", exitValue );
                return false;
            }
        }
        else
        {
            logger.info( "Either HMS directory or HMS parent direcotry or rollbackScript not configured."
                + " [ hmsDir: {}; hmsParentDir: {}; rollbackScript: {}.", hmsDir, hmsParentDir, rollbackScript );
            return false;
        }
    }

    private  UpgradeUtil();

}