Changeset 9883


Ignore:
Timestamp:
2005-05-16T15:17:54+12:00 (19 years ago)
Author:
davidb
Message:

Support for collect.zip being in Jar file put back in. This lets the applet
version of GLI be seeded with interesting example collections to be based
on (e.g. the documented demo collections).

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
2 edited

Legend:

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

    r9876 r9883  
    152152    File col_dir = new File(Gatherer.getCollectDirectoryPath());
    153153    if (!col_dir.exists()) {
    154         col_dir.mkdir();
    155     }
     154
     155        if (Utility.isInJar(Utility.COLLECT_ZIP)) {
     156        // Dig out collect.zip from JAR file and unzip it (thereby
     157        // creating collect directory and descendants.
     158        //   This is done to seed gsdl home folder with config files
     159        //   for documented example collections so "base this on
     160        //   existing collection" works
     161        Utility.unzipFromJar(Utility.COLLECT_ZIP,gli_user_directory.toString());
     162        }
     163        else {
     164        // Prepare an empty collect dir for general use
     165        col_dir.mkdir();
     166        }
     167        }
     168
     169    /*
     170        File tmp_dir = new File(Utility.TMP_DIR);
     171        if (!tmp_dir.exists()) {
     172            tmp_dir.mkdir();
     173        }
     174    */
    156175
    157176    File metadata_directory = new File(Utility.METADATA_DIR);
    158177    if (!metadata_directory.exists()) {
    159         // digout metadata.zip from JAR file and unzip it
     178        // dig out metadata.zip from JAR file and unzip it
    160179        Utility.unzipFromJar(Utility.METADATA_ZIP, gli_user_directory.toString());
    161180    }
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r9876 r9883  
    111111    /** Definition of an important zip file, in this case zipped up version of metadata file stored in JAR file */
    112112    static final public String METADATA_ZIP = "metadata.zip";
     113    static final public String COLLECT_ZIP = "collect.zip";
    113114    /** The default name of the perl executable under unix. */
    114115    static final public String PERL_EXECUTABLE_UNIX = "perl";
     
    518519
    519520
     521    static public boolean isInJar(String filename)
     522    {
     523    try {
     524        InputStream fis = base.getResourceAsStream("/"+filename);
     525           
     526        fis.close();
     527
     528    }
     529    catch (Exception error) {
     530        System.err.println("**** collect.zip not there!");
     531        error.printStackTrace();
     532
     533
     534        return false;
     535    }
     536    return true;
     537    }
     538
     539
     540
    520541    static public void extractFromJar(String filename, String dst_dir, boolean must_be_present)
    521542    {
Note: See TracChangeset for help on using the changeset viewer.