Changeset 31884

Show
Ignore:
Timestamp:
15.08.2017 19:17:46 (2 months ago)
Author:
ak19
Message:

Much simpler. If proxy env vars were already set upon GLI launch, they still don't turn up in Java System vars. This means that we print out the messages of overriding and restoring variables without having to actually do anything (no restoring of Java System vars with the original env vars when running GLI, as the Java System vars remain empty as at startup.)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r31883 r31884  
    14821482    // https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html 
    14831483    // https://stackoverflow.com/questions/14243590/proxy-settings-in-java   
     1484 
     1485    // Just need to warn the user that we're overriding proxy settings using custom defined proxy settings 
     1486    // and returning to using the original proxy settings when custom defined proxy settings are turned off 
     1487    // We don't actually need to store/restore the original settings, as Java system vars like http.proxyHost 
     1488    // http.proxyPort don't seem to be set even if on GLI startup the env vars like http(s)_proxy were already set. 
     1489 
    14841490     
    14851491    if(use_proxy) { 
    14861492        if(System.getenv(protocol+"_proxy") != null) { 
    14871493        System.err.println("Overriding original "+protocol+" proxy settings"); 
    1488          
    1489         // first store the original settings, but only if we haven't already stored them for this protocol 
    1490         if(startup_proxy_settings.getProperty(protocol+".proxyHost") == null) { 
    1491             ///System.err.println("@@@ Overriding with: " + System.getProperty(protocol+".proxyHost", "")); 
    1492             startup_proxy_settings.setProperty(protocol+".proxyHost", System.getProperty(protocol+".proxyHost", "")); 
    1493             startup_proxy_settings.setProperty(protocol+".proxyPort", System.getProperty(protocol+".proxyPort", "")); 
    1494  
    1495             //if(protocol.equals("http")) { 
    1496             //startup_proxy_settings.setProperty(protocol+".proxyType", System.getProperty(protocol+".proxyType", "")); 
    1497             //startup_proxy_settings.setProperty(protocol+".proxySet", System.getProperty(protocol+".proxySet", "")); 
    1498             //} 
    1499         } 
    15001494        } 
    15011495         
    1502         // finally can now set the custom proxy defined through GLI for this protocol 
     1496        // set the custom proxy defined through GLI for this protocol 
    15031497        System.setProperty(protocol+".proxyHost", Configuration.getString("general."+protocol.toUpperCase()+"_proxy_host", true)); 
    15041498        System.setProperty(protocol+".proxyPort", Configuration.getString("general."+protocol.toUpperCase()+"_proxy_port", true)); 
    15051499 
    15061500        // Not sure what proxyType is. And proxySet ceased to exist since JDK 6 or before. See links above. 
    1507         // But we used to set them both for HTTP before, so still doing so for proxyType which may or may not exist 
    1508         // but proxySet doesn't exist anymore, so not continuing with that. 
     1501        // But we used to set them both for HTTP before, so still doing so for proxyType, since it may or may not exist 
     1502        // But proxySet doesn't exist anymore, so not continuing with that. 
    15091503        if(protocol.equals("http")) { 
    15101504        System.setProperty(protocol+".proxyType", "4"); 
     
    15191513        if(System.getenv(protocol+"_proxy") != null) { 
    15201514        System.err.println("Restoring original "+protocol+" proxy settings"); 
    1521         System.setProperty(protocol+".proxyHost", startup_proxy_settings.getProperty(protocol+".proxyHost")); 
    1522         System.setProperty(protocol+".proxyPort", startup_proxy_settings.getProperty(protocol+".proxyPort")); 
    1523  
    1524         //if(protocol.equals("http")) { 
    1525             //System.setProperty(protocol+".proxyHost", startup_proxy_settings.getProperty(protocol+".proxyType")); 
    1526             //System.setProperty(protocol+".proxyPort", startup_proxy_settings.getProperty(protocol+".proxySet")); 
    1527         //} 
    15281515        } 
    1529         else { 
    1530         System.setProperty(protocol+".proxyHost", ""); 
    1531         System.setProperty(protocol+".proxyPort", ""); 
    1532         //if(protocol.equals("http")) { 
    1533             //System.setProperty(protocol+".proxySet", "false"); 
    1534         //} 
    1535         } 
    1536  
     1516         
     1517        System.setProperty(protocol+".proxyHost", ""); 
     1518        System.setProperty(protocol+".proxyPort", ""); 
     1519        //if(protocol.equals("http")) { 
     1520        //System.setProperty(protocol+".proxySet", "false"); 
     1521        //}       
    15371522    } 
    15381523    }