private static OptimizationContext createContext(CommandLine cmdLine) throws KeywordOptimizerException {
  String adsPropertiesPath=ADS_PROPERTIES_DEFAULT_PATH;
  if (cmdLine.hasOption("ap")) {
    adsPropertiesPath=cmdLine.getOptionValue("ap");
  }
  log("Using ads properties file: " + adsPropertiesPath);
  try {
    AdWordsApiUtil util=new AdWordsApiUtil(adsPropertiesPath);
    Configuration configuration=loadConfiguration(cmdLine);
    return new OptimizationContext(configuration,util);
  }
 catch (  ConfigurationLoadException e) {
    throw new KeywordOptimizerException("Error loading the ads properties file",e);
  }
catch (  ValidationException e) {
    throw new KeywordOptimizerException("Missing refresh token",e);
  }
catch (  OAuthException e) {
    throw new KeywordOptimizerException("Authentication error",e);
  }
}

private static OptimizationContext createContext ( CommandLine cmdLine ) throws KeywordOptimizerException { String adsPropertiesPath = ADS_PROPERTIES_DEFAULT_PATH ; if ( cmdLine . hasOption ( "ap" ) ) { adsPropertiesPath = cmdLine . getOptionValue ( "ap" ) ; } log ( "Using ads properties file: " + adsPropertiesPath ) ; try { AdWordsApiUtil util = new AdWordsApiUtil ( adsPropertiesPath ) ; Configuration configuration = loadConfiguration ( cmdLine ) ; return new OptimizationContext ( configuration , util ) ; } catch ( ConfigurationLoadException e ) { throw new KeywordOptimizerException ( "Error loading the ads properties file" , e ) ; } catch ( ValidationException e ) { throw new KeywordOptimizerException ( "Missing refresh token" , e ) ; } catch ( OAuthException e ) { throw new KeywordOptimizerException ( "Authentication error" , e ) ; } }
creates and initializes optimization context , holding the adwords api util .
