Changeset 27868

Show
Ignore:
Timestamp:
15.07.2013 23:25:48 (6 years ago)
Author:
davidb
Message:

Additional fallback code added that tries to use System property gsdl3.writablehome to locate global.properties

Files:
1 modified

Legend:

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

    r27825 r27868  
    2121import java.io.File; 
    2222import java.io.InputStream; 
     23import java.io.FileInputStream; 
    2324import java.util.Properties; 
    2425 
     
    7172    public static String getGSDL3WebAddress() 
    7273    { 
     74                logger.info("**** Asked for Web Address"); 
    7375        return gsdl3_web_address; 
    7476    } 
     
    7678    public static String getFullGSDL3WebAddress() 
    7779    { 
     80                logger.info("**** Asked for FULL Web Address"); 
    7881        return full_gsdl3_web_address; 
    7982    } 
     
    8487        { 
    8588            InputStream in = Class.forName("org.greenstone.util.GlobalProperties").getClassLoader().getResourceAsStream(properties_filename); 
     89 
     90            if (in==null) 
     91            { 
     92                    // Try to find it through gsdl3.writablehome 
     93                    logger.info("Couldn't find '" + properties_filename + "' through ClassLoader"); 
     94                    logger.info("Trying alternative path through System property gsdl3.writablehome"); 
     95                gsdl3_writablehome = System.getProperty("gsdl3.writablehome"); 
     96                if (gsdl3_writablehome!=null) { 
     97 
     98                    String gp_full_filename = gsdl3_writablehome + File.separator + "WEB-INF" 
     99                    + File.separator + "classes"  
     100                    + File.separator + properties_filename;  
     101 
     102                    try { 
     103                    in = new FileInputStream(gp_full_filename); 
     104                    logger.info("Found '" + properties_filename + "'"); 
     105                    } 
     106                    catch (Exception e) { 
     107                    logger.info("Unable to locate '" + gp_full_filename + "'"); 
     108                    } 
     109                } 
     110                else { 
     111                    logger.info("Java property gsdl3.writablehome was not set"); 
     112                } 
     113            } 
     114 
    86115            if (in != null) 
    87116            { 
     
    90119                in.close(); 
    91120            } 
    92             else 
    93             { 
    94                 logger.error("Couldn't load global properties: " + properties_filename); 
    95             } 
     121            else { 
     122                    logger.error("Failed to find '" + properties_filename + "'"); 
     123            }     
    96124 
    97125            gsdl3_home = properties.getProperty("gsdl3.home");