Changeset 32153

Show
Ignore:
Timestamp:
26.02.2018 19:57:21 (7 months ago)
Author:
ak19
Message:

2 Bugfixes and tidying up errorhandling in JarTools?. 1. Dr Bainbridge fixed issue surrounding env.Path rather than env.PATH being used on Windows, while the empty env.PATH was being concatenated as a variable name by build.xml. This resulted in a cyclical reference, noticed when running the GLI Web Start Application (converted from GLI Applet). Fix is in build.xml. 2. My bugfix to WebGatherer?.java, the new GLI Web Start Application. The collectionDir wasn't set correctly until the Gatherer object was instantiated, but the collect dir needed to be known by other code beforehand. So shifted the Gatherer object instantiation up a bit. 3. Can't yet reproduce the Exception seen twice before when running GLI Web Start application. The exception was thrown in ZipTools?.java. Tested by rerunning the applet repeatedly, but it hasn't struck again yet. Perhaps it's been fixed now because of the other changes?

Location:
main/trunk
Files:
4 modified

Legend:

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

    r17629 r32153  
    152152    } 
    153153     
     154    // For WebGatherer.java, which uses Java Web Start over JNLP to run the repurposed "applet" as application, 
     155    // it turned out that for GS3, we need the collectionDirectoryPath set for the subsequent code to work. 
     156    // In WebGatherer.java, moved the instantiation of the Gatherer object here, but to avoid major changes to 
     157    // this GathererApplet.java class, just calling the relevant line in Gatherer() constructor at this stage: 
     158    Gatherer.setCollectDirectoryPath(Gatherer.getGLIUserDirectoryPath() + "collect" + File.separator); 
     159     
    154160    File collect_directory = new File(Gatherer.getCollectDirectoryPath()); 
    155161    if (!collect_directory.exists()) { 
  • main/trunk/gli/src/org/greenstone/gatherer/WebGatherer.java

    r32150 r32153  
    194194    } 
    195195     
     196    // Create an instance of the Gatherer class, which will parse the args and prepare the rest of the GLI 
     197    gatherer = new Gatherer(args); // Do this early as it will also call Gatherer.setCollectDirectoryPath(), because we need that to have been set hereafter. 
     198                 
    196199    File collect_directory = new File(Gatherer.getCollectDirectoryPath()); 
    197200    if (!collect_directory.exists()) { 
     
    217220        unzipFromJar("metadata.zip", Gatherer.getGLIDirectoryPath()); 
    218221    } 
    219  
    220     // Create an instance of the Gatherer class, which will parse the args and prepare the rest of the GLI 
    221     gatherer = new Gatherer(args); 
    222222 
    223223    gatherer.openGUI(); 
  • main/trunk/gli/src/org/greenstone/gatherer/util/JarTools.java

    r32139 r32153  
    133133    static public boolean isInJar(String filename)  
    134134    { 
     135    InputStream fis = null; 
    135136    try { 
    136         InputStream fis = root_class.getResourceAsStream("/" + filename);            
    137         fis.close(); 
     137        fis = root_class.getResourceAsStream("/" + filename); 
     138        if(fis == null) { 
     139            System.err.println("@@@ JarTools.isInJar(): file inputstream for file /"+filename+" is still null. Not in jar file."); 
     140            return false; 
     141        } 
    138142    } 
    139143    catch (Exception exception) { 
     
    141145        return false; 
    142146    } 
     147    finally { 
     148        if(!SafeProcess.closeResource(fis)) { 
     149            System.err.println("@@@ JarTools.isInJar(): Couldn't close file inputstream"); 
     150            return false; 
     151        } 
     152    } 
    143153 
    144154    return true; 
  • main/trunk/greenstone3/build.xml

    r32152 r32153  
    649649  </path> 
    650650 
    651  
    652   <path id="local.tomcat.path"> 
    653     <pathelement location="${basedir}/bin/script"/> 
    654     <pathelement location="${basedir}/bin"/> 
    655     <pathelement location="${lib.jni}"/> 
    656     <pathelement path="${env.PATH}"/> 
    657     <pathelement path="${env.Path}"/> 
    658     <pathelement path="${wn.home}/bin"/> 
    659   </path> 
     651   
     652    <if><bool><isset property="env.PATH"/></bool> 
     653      <path id="local.tomcat.path"> 
     654        <pathelement location="${basedir}/bin/script"/> 
     655        <pathelement location="${basedir}/bin"/> 
     656        <pathelement location="${lib.jni}"/>     
     657        <pathelement path="${env.PATH}"/> 
     658        <pathelement path="${wn.home}/bin"/> 
     659      </path> 
     660      <!-- Windows can be case sensitive about env.PATH, preferring env.Path. See https://ant.apache.org/manual/Tasks/property.html  --> 
     661      <else><if><bool><isset property="env.Path"/></bool> 
     662        <path id="local.tomcat.path"> 
     663          <pathelement location="${basedir}/bin/script"/> 
     664          <pathelement location="${basedir}/bin"/> 
     665          <pathelement location="${lib.jni}"/> 
     666          <pathelement path="${env.Path}"/> 
     667          <pathelement path="${wn.home}/bin"/> 
     668        </path> 
     669      <!-- else print error about no path set --> 
     670      <else> 
     671        <echo>No env.PATH (or env.Path) set. Unable to set local.tomcat.path property</echo> 
     672      </else></if></else>    
     673    </if>    
    660674 
    661675  <target name="test-setup"> 
     
    666680    <echo>is windows : ${current.os.iswindows}</echo> 
    667681    <echo>os.unix: ${os.unix}</echo> 
     682    <echo>env.PATH: ${env.PATH}</echo> 
     683    <echo>env.Path: ${env.Path}</echo>   
    668684  </target> 
    669685