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>(); cmdWithArgs.add( 0, rollbackScriptAbsPath ); cmdWithArgs.add( 1, upgradeId ); cmdWithArgs.add( 2, upgradeDir ); String backupDirAbsPath = FilenameUtils.concat( hmsParentDir, "hms_backup_" + upgradeId ); cmdWithArgs.add( 3, backupDirAbsPath ); 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(); static boolean initiateUpgrade( final String upgradeId, final String upgradeBinaryFileName ); static boolean rollbackUpgrade( RollbackSpec rollbackSpec ); static Response validateUpgradeRequest( OobUpgradeSpec upgradeSpec ); static Response validateUpgradeBinaryChecksum( final OobUpgradeSpec upgradeSpec ); static Response validateUpgradeScripts( final String upgradeId ); static void validateRollbackRequest( RollbackSpec rollbackSpec ); static String getFileName( final Map<String, List<InputPart>> formDataMap ); static String getUpgradeId( final Map<String, List<InputPart>> formDataMap ); static byte[] getFileContent( final Map<String, List<InputPart>> formDataMap ); static void deleteUpgradeFiles( final String upgradeId ); static String getHmsUpgradeDir(); static String getUpgradeDir( final String upgradeId );  }
@Test public void testRollbackUpgradeWithNullSpec() { assertFalse( UpgradeUtil.rollbackUpgrade( null ) ); }