Changeset 32419 for main/trunk

Show
Ignore:
Timestamp:
03.09.2018 16:08:35 (13 months ago)
Author:
ak19
Message:

ProtocolPortProperties?.java constructors can throw an Exception now.

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

Legend:

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

    r32357 r32419  
    142142        Properties globalProperties = new Properties(); 
    143143        globalProperties.load(Class.forName("org.greenstone.util.GlobalProperties").getClassLoader().getResourceAsStream("global.properties")); 
     144         
     145        ProtocolPortProperties protocolPortProps = new ProtocolPortProperties(globalProperties); // can throw Exception 
    144146        String host = globalProperties.getProperty("tomcat.server", "localhost"); 
    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         } 
    150147        String protocol = protocolPortProps.getProtocol(); 
    151148        String port = protocolPortProps.getPort(); 
     
    185182    } catch(Exception e) { 
    186183        logger.error("Error instantiating the interface to the Fedora Repository:\n", e); // second parameter prints e's stacktrace 
    187         return false; 
     184        return false; // configure has failed 
    188185    }  
    189186 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/ServletRealmCheck.java

    r32357 r32419  
    8888        // get the property value and print it out 
    8989        String servername = buildProps.getProperty("tomcat.server"); 
    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         } 
     90        ProtocolPortProperties protocolPortProps = new ProtocolPortProperties(buildProps); // can throw Exception 
    9791        String protocol = protocolPortProps.getProtocol(); 
    9892        String port = protocolPortProps.getPort(); 
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server3.java

    r32357 r32419  
    2525        // config properties are loaded into the config_properties object 
    2626        // now test the port and protocol values are sane or exit. 
    27         protocolPortProps = new ProtocolPortProperties(config_properties); 
    28         if(protocolPortProps.hadError()) { 
     27        try { 
     28            protocolPortProps = new ProtocolPortProperties(config_properties); 
     29        } catch(Exception e) { 
    2930            String errorMsg = "Error with port/protocol in " + config_properties_file + ": " + protocolPortProps.getErrorMsg(); 
    3031 
     
    3435            // If error, then quit this app as soon as possible 
    3536            System.exit(-1); 
    36         }    
     37        } 
    3738         
    3839        Property = protocolPortProps.legacyMode ? new Server3Property() : new Server3Property(protocolPortProps.getProtocol()); 
  • main/trunk/greenstone3/src/java/org/greenstone/util/ProtocolPortProperties.java

    r32418 r32419  
    6666    // Won't attempt to recover on error. 
    6767    // This means on error, port etc values will be invalid 
    68     public ProtocolPortProperties(Properties props) { 
     68    public ProtocolPortProperties(Properties props) throws Exception { 
    6969    this(props, false); 
    7070    } 
    7171 
    72     public ProtocolPortProperties(Properties props, boolean recover) 
     72    public ProtocolPortProperties(Properties props, boolean recover) throws Exception 
    7373    { 
    7474    StringBuffer msg = new StringBuffer(); 
     
    215215     
    216216    errorMsg = msg.toString(); 
     217 
     218    if(!recover && errorCode != ALL_CORRECT) { 
     219        throw new Exception(errorMsg); 
     220    } 
    217221    } 
    218222