Changeset 32418 for main


Ignore:
Timestamp:
2018-09-03T15:21:46+12:00 (6 years ago)
Author:
ak19
Message:

Fix. If tomcat.port exists in a properties file, it does not automatically mean legacy mode, since global.properties still has a tomcat.port property.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/util/ProtocolPortProperties.java

    r32358 r32418  
    7777
    7878    // We could either be dealing with properties files from before https support was introduced, in which case we want to be backwards compatible
    79     // Or we're dealing with properties files after https support was introduced.
     79    // Or we're dealing with properties files after https support was introduced.  
    8080    // To determine which, can ignore server.protocol: server.protocol was introduced at a time when tomcat.port was still in effect,
    81     // server.protocol's presence does not indicate whether our GS3 installation supports https or not. Only the tomcat.port property
    82     // indicates that: if tomcat.port exists it's an older GS3 that has no https support, so default to http. If there is no tomcat.port,
    83     // but there is a server.protocol check for the newer tomcat.port.<protocol> properties.
    84 
    85     if(port != null) { // tomcat.port exists, so this is a GS3 before https support.
     81    // server.protocol's presence does not indicate whether our GS3 installation supports https or not. Only the tomcat.port properties
     82    // indicates that: if tomcat.port exists BUT tomcat.port.http(s) don't, then it's an older GS3 that has no https support, so default to http.
     83    // If there is no tomcat.port at all, but there is a server.protocol check for the newer tomcat.port.<protocol> properties.
     84    // NOTE: global.properties still has a property called tomcat.port. We're only dealing with the old tomcat.port-only way if tomcat.port.http(s) don't exist
     85   
     86    if(props.getProperty("tomcat.port.http") == null && props.getProperty("tomcat.port.https") == null && port != null) {
     87                // tomcat.port exists but tomcat.port.http(s) don't, so this is a GS3 before https support.
    8688        legacyMode = true;
    8789
    88         // Back when tomcat.port was used, server.protocol if specified
     90        // Back when tomcat.port was used AND tomcat.port.http(s) didn't exist, server.protocol if specified
    8991        // would always be treated as http regardless of what it was set to
    90         protocol = defProtocol;
    91 
     92       
     93        protocol = defProtocol; // tomcat.port.http(s) doesn't exist, just use http
     94       
     95       
    9296        if(port.equals("")) {
    9397        errorCode =  OLD_TOMCATPORT_BUT_NO_VALUE;
     
    96100            port = httpPort = defHttpPort;
    97101        }
    98         } else { // No issus: using tomcat.port is the pre-https way.       
     102        } else { // No issues: using tomcat.port is the pre-https way.     
    99103        errorCode = ALL_CORRECT;
    100104        httpPort = port;
     
    106110        protocol = props.getProperty("server.protocol");
    107111        if(protocol == null || (!protocol.equals("http") && !protocol.equals("https"))) {
    108         // tomcat.port was null AND now server.protocol is null or wrong. Something very wrong with the properties file
    109         if(protocol == null) {         
     112        if(port == null) { // if tomcat.port is null AND server.protocol is null or wrong. Something very wrong with the properties file
     113            errorCode = NO_PROTOCOL_OR_PORT;
     114            msg.append("server.protocol not set. And can't determine port.");
     115        } else if(protocol == null) {           
    110116            errorCode = NO_PROTOCOL_OR_PORT;
    111             msg.append("server.protocol not set. And can't determine port.");
     117            msg.append("server.protocol not set.");
    112118        } else {
    113119            errorCode = INVALID_PROTOCOL;
Note: See TracChangeset for help on using the changeset viewer.