Changeset 32357 for main/trunk

Show
Ignore:
Timestamp:
22.08.2018 22:08:05 (14 months ago)
Author:
ak19
Message:

GS3 Java code has moved away from using tomcat.port to using tomcat.port.<protocol>.

Location:
main/trunk/greenstone3/src/java/org/greenstone
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/FedoraServiceProxy.java

    r28966 r32357  
    3939import org.greenstone.gsdl3.util.OID; 
    4040import org.greenstone.gsdl3.util.XMLConverter; 
     41import org.greenstone.util.ProtocolPortProperties; 
    4142import org.w3c.dom.Document; 
    4243import org.w3c.dom.Element; 
     
    142143        globalProperties.load(Class.forName("org.greenstone.util.GlobalProperties").getClassLoader().getResourceAsStream("global.properties")); 
    143144        String host = globalProperties.getProperty("tomcat.server", "localhost"); 
    144         String port = globalProperties.getProperty("tomcat.port", "8383"); 
    145         String protocol = "http"; 
     145        ProtocolPortProperties protocolPortProps = new ProtocolPortProperties(globalProperties); 
     146        if(protocolPortProps.hadError()) { 
     147        logger.error("Error with port/protocol in global.properties: " + protocolPortProps.getErrorMsg()); 
     148        return false; // configure has failed 
     149        } 
     150        String protocol = protocolPortProps.getProtocol(); 
     151        String port = protocolPortProps.getPort(); 
     152 
    146153        String username = "fedoraIntCallUser"; //"fedoraAdmin" 
    147154        String password = "changeme"; //"<user password>" 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/ServletRealmCheck.java

    r28959 r32357  
    2929import java.net.URLConnection; 
    3030import java.util.Properties; 
     31 
     32import org.greenstone.util.ProtocolPortProperties; 
    3133 
    3234/** 
     
    8688        // get the property value and print it out 
    8789        String servername = buildProps.getProperty("tomcat.server"); 
    88         String port = buildProps.getProperty("tomcat.port"); 
     90        //String protocol = buildProps.getProperty("server.protocol", "http"); 
     91        //String port = buildProps.getProperty("tomcat.port"+protocol, "8383"); 
     92         
     93        ProtocolPortProperties protocolPortProps = new ProtocolPortProperties(buildProps); 
     94        if(protocolPortProps.hadError()) { 
     95            throw new Exception("**** ERROR with port and/or protocol in build.properties:\n" + protocolPortProps.getErrorMsg()); 
     96        } 
     97        String protocol = protocolPortProps.getProtocol(); 
     98        String port = protocolPortProps.getPort(); 
    8999        int portNum = Integer.parseInt(port); 
    90100         
     
    94104            urlSuffix = urlSuffix + "&col="+collection; 
    95105        } 
    96         URL authenticationUrl = new URL("http", servername, portNum, urlSuffix); 
     106        URL authenticationUrl = new URL(protocol, servername, portNum, urlSuffix); 
    97107         
    98108        HttpURLConnection conn = (HttpURLConnection)authenticationUrl.openConnection();      
     
    120130        System.out.print(result); // don't add newline to end 
    121131         
    122     } catch (IOException ex) { 
     132    } catch (Exception ex) { 
    123133        ex.printStackTrace(); 
    124134    } finally { 
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server3.java

    r32329 r32357  
    1111import org.greenstone.server.BaseProperty; 
    1212import org.greenstone.util.GlobalProperties; 
     13import org.greenstone.util.ProtocolPortProperties; 
    1314import org.greenstone.util.RunAnt; 
    1415 
     
    1617{ 
    1718        String opt_ant_properties = null; 
     19        ProtocolPortProperties protocolPortProps = null; 
    1820 
    1921    public Server3(String gsdl3_src_home, String lang) 
     
    2123        super(gsdl3_src_home, lang, gsdl3_src_home + File.separatorChar + "build.properties", "web"+File.separator+"logs"); 
    2224 
    23         Property = new Server3Property(); 
     25        // config properties are loaded into the config_properties object 
     26        // now test the port and protocol values are sane or exit. 
     27        protocolPortProps = new ProtocolPortProperties(config_properties); 
     28        if(protocolPortProps.hadError()) { 
     29            String errorMsg = "Error with port/protocol in " + config_properties_file + ": " + protocolPortProps.getErrorMsg(); 
     30 
     31            // print it everywhere, because port/protocol misconfiguration is a fatal error and we're exiting 
     32            logger_.error(errorMsg); 
     33            System.err.println(errorMsg); 
     34            // If error, then quit this app as soon as possible 
     35            System.exit(-1); 
     36        }    
     37         
     38        Property = protocolPortProps.legacyMode ? new Server3Property() : new Server3Property(protocolPortProps.getProtocol()); 
    2439 
    2540        String frame_title = dictionary.get("ServerControl.Frame_Title"); 
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server3Property.java

    r29845 r32357  
    1414    } 
    1515 
     16    Server3Property(String protocol) 
     17    { 
     18    // Initialising customised final variables  
     19    // Version number, WEB_PORT, autoenter, startbrowser 
     20    // For GS3, the last two are controlled by the same property 
     21    super("3", "tomcat.port."+protocol, "server.auto.start", "server.auto.start",  
     22          "server.keep.port", "server.external.access"); 
     23    } 
    1624} 
  • main/trunk/greenstone3/src/java/org/greenstone/util/GlobalProperties.java

    r32344 r32357  
    181181 
    182182            //port 
    183             portSpecifier = properties.getProperty("tomcat.port"); 
     183            portSpecifier = properties.getProperty("tomcat.port"); // support for legacy tomcat.port? 
     184            if(portSpecifier == null) { 
     185                portSpecifier = protocolSpecifier.startsWith("https") ? properties.getProperty("tomcat.port.https") : properties.getProperty("tomcat.port.http"); 
     186            } 
    184187            if (portSpecifier == null || portSpecifier.equals("")  
    185188                || (protocolSpecifier.equals("http://") && portSpecifier.equals("80"))