Changeset 10214 for trunk/gli/src


Ignore:
Timestamp:
2005-07-06T15:18:57+12:00 (19 years ago)
Author:
mdewsnip
Message:

Some comments by Matthew Whyte.

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

Legend:

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

    r10207 r10214  
    125125   
    126126
    127     /** It turns out that in Java you have to make sure a directory is empty before you delete it (much like unix I suppose), and so just like unix I'll have to set up a recursive delete function.
     127    /**
     128     * Delete a file or directory
     129     * It turns out that in Java you have to make sure a directory is empty before you delete it (much like unix I suppose),
     130     * and so just like unix I'll have to set up a recursive delete function.
     131     *
    128132     * @param file The <strong>File</strong> you want to delete.
    129133     * @return A <i>boolean</i> which is <i>true</i> if the file specified was successfully deleted, <i>false</i> otherwise.
     
    439443
    440444
    441     /** Method which unzips a given metadata resoure
    442      * @param zip_fname The name of the zip file as a <strong>String</strong>.
     445    /**
     446     * Method which unzips a given metadata resoure.
     447     * @param jar_zip_fname The name of the jar file as a <strong>String</strong>.
    443448     * @param dst_dir The destination directory for unzipping, also as a <strong>String</strong>.
    444      * @param use_classloader Used to determine whether or not to look in resource bundle.
     449     * @see JarTools.extractFromJar(String, String, boolean)
    445450     */
    446451    static public void unzipFromJar(String jar_zip_fname, String dst_dir) {
     
    512517    }
    513518
    514     /*
    515       Method to handle zipping up of a file. Called by zipup and dirFunc.
    516 
    517       @param zos the zip output stream, as a <strong>ZipOutputStream</strong>
    518       @param file_path the <strong>String</strong> containing the path to the file/directory tozip up
    519       @param prefix_strip the <strong>int</strong> used to substring the file_path
    520       @param source the <strong>GShell</strong> that is calling this method, so that we can check to see if the process has been cancelled. null if GShell is not the calling object.
    521       @param accept_expr a <strong>String</strong> containing a regular expression of files to include in the archive. All other files will be excluded.
    522       @param reject_expr a <strong>String</strong> containing a regular expression of files not to include in the archive.
    523 
    524       @return boolean
    525 
    526       @see dirFunc
    527       @see zipup
    528      */
    529     static protected boolean zipFunc (ZipOutputStream zos, String file_path, int prefix_strip, GShell source, boolean encountered_file, String accept_expr, String reject_expr)
     519    /**
     520     * Method to handle zipping up of a file (not a directory).
     521     * Called by {@link zipup(String, String, String, GShell, String, String)} and {@link dirFunc(ZipOutputStream, String, int, GShell, boolean, String, String)}
     522     *
     523     * @param zos the zip output stream, as a <strong>ZipOutputStream</strong>
     524     * @param file_path the <strong>String</strong> containing the path to the file/directory tozip up
     525     * @param prefix_strip the <strong>int</strong> used to substring the file_path
     526     * @param source the <strong>GShell</strong> object that is calling this method, so that we can check to see if the process has been cancelled.
     527     *               This is null if GShell is not the calling object.
     528     * @param accept_expr a <strong>String</strong> containing a regular expression of files to include in the archive. All other files will be excluded.
     529     *                    There is a special case of ".*doc.xml", where the doc.xml files will be parsed to only include their metadata.
     530     * @param reject_expr a <strong>String</strong> containing a regular expression of files not to include in the archive.
     531     * @return boolean - true if the zip was created successfully(?).
     532     * @see dirFunc(ZipOutputStream, String, int, GShell, boolean, String, String)
     533     * @see zipup(String, String, String, GShell, String, String)
     534     */
     535    static protected boolean zipFunc(ZipOutputStream zos, String file_path, int prefix_strip, GShell source, boolean encountered_file, String accept_expr, String reject_expr)
    530536    {
    531537    String new_file_path = file_path;
     
    609615    }
    610616
    611     /*
    612       Method to handle ziping up of a directory.
    613 
    614       @param zos
    615       @param dir_name
    616       @param prefix_strip
    617       @param source
    618       @param encountered_file ??What's this??
    619       @param accept_expr
    620       @param reject_expr
    621 
    622       @see zipup
    623       @see zipFunc
     617    /**
     618     * Method to handle ziping up of a directory. This is called by {@link zipup(String, String, String, GShell, String, String)}
     619     *
     620     * @param zos the <strong>ZipOutputStream</strong> to output to.
     621     * @param dir_name the directory name to zip, as a <strong>String</strong>
     622     * @param prefix_strip the <strong>int</strong> used to substring the file_path
     623     * @param source the <strong>GShell</strong> object that is calling this method, so that we can check to see if the process has been cancelled.
     624     *               This is null if GShell is not the calling object.
     625     * @param encountered_file ??What's this??
     626     * @param accept_expr a <strong>String</strong> containing a regular expression of files to include in the archive. All other files will be excluded.
     627     * @param reject_expr a <strong>String</strong> containing a regular expression of files not to include in the archive.
     628     *
     629     * @see zipup(String, String, String, GShell, String, String)
     630     * @see zipFunc(ZipOutputStream, String, int, GShell, boolean, String, String)
    624631     */
    625632    static protected boolean dirFunc (ZipOutputStream zos, String dir_name, int prefix_strip, GShell source, boolean encountered_file, String accept_expr, String reject_expr)
     
    670677   
    671678    /**
    672       Method to zip up a given file or directory
    673 
    674       @param col_dir
    675       @param col_name
    676       @param dir_or_file
    677       @param source
    678       @param filter
    679 
    680       @see zipFunc
    681       @see dirFunc
     679     * Method to zip up a given file or directory associated with a particular collection.
     680     * This method mainly called from {@link GShell}, with a few exceptions. The zip files produced are used
     681     * to pass files (new files to add, metadata, etc) between the GLI applet and the Greenstone server.
     682     * The actual zipping of files and directories is handled by {@link zipFunc(ZipOutputStream, String, int, GShell, boolean, String, String) and
     683     * {@link dirFunc(ZipOutputStream, String, int, GShell, boolean, String, String)} respectfully.
     684     *
     685     * @param col_dir the path to the collect directory, as a <strong>String</strong>
     686     * @param col_name the collection name, as as <strong>String</strong>
     687     * @param dir_or_file the directory or file within the collection to zip up, as a <strong>String</strong>
     688     * @param source the <strong>GShell</strong> object that is calling this method, so that we can check to see if the process has been cancelled.
     689     *               This is null if GShell is not the calling object.
     690     * @param accept_expr a <strong>String</strong> containing a regular expression of files to include in the archive. All other files will be excluded.
     691     * @param reject_expr a <strong>String</strong> containing a regular expression of files not to include in the archive.
     692     *
     693     * @see zipFunc(ZipOutputStream, String, int, GShell, boolean, String, String)
     694     * @see dirFunc(ZipOutputStream, String, int, GShell, boolean, String, String)
    682695     */
    683696    static public boolean zipup(String col_dir, String col_name, String dir_or_file, GShell source, String accept_expr, String reject_expr)
     
    689702    int prefix_strip = col_dir.length();
    690703    boolean encountered_file = false;
    691    
     704
    692705    String zip_fname = col_dir + col_name + ".zip";
    693706    String zip_dir_or_file = col_dir + col_name + File.separator + dir_or_file;
     
    738751    }
    739752   
    740 
     753    /**
     754     * Method to unzip a zip file associated with a particular collection.
     755     * The location and name of the zip file should be derrived from the collection. Please see below for details.
     756     *
     757     * @param col_dir the path to the collection directory, as a <strong>String</strong>. This is where the zip file should be located.
     758     * @param col_name the name of the collection, as a <strong>String</strong>. This should be the name of the zip file (with a  .zip extension).
     759     */
    741760    static public void unzip(String col_dir, String col_name)
    742761    {
     
    751770    try {
    752771        File cfile = new File(zip_fname);
    753         System.err.println("**** zip fname = " + cfile.toString());
    754 
    755772        ZipFile zipfile = new ZipFile(cfile, zip_mode);
    756773       
  • trunk/gli/src/org/greenstone/gatherer/util/Zipup.java

    r9894 r10214  
    4040import java.io.File;
    4141
    42 /*
    43   Class to zip up a given directory of a given Greenstone collection.
    44 
    45   Arguments:
    46   gsdlhome, the home of greensone, eg "/research/mgw5/gsdl/"
    47   collecion, thename of the collection, eg "mgw5-test"
    48   dir, the name of the directory to zip up, eg "archives"
    49   [accept_expression], a regular expression of files to exclusively include in the archive
    50   [reject_expression], a regular expression of files to exclude from the archive
    51 
    52   @see org.greenstone.gatherer.util.Utility#zipup
     42/**
     43 * Zip up a given directory of a given Greenstone collection.
     44 * The actual zipping code is contained in {@link Utility.zipup(String, String, String, GShell, String, String)}.
     45 * This class basically contains a main method that requires adequate arguments to call the zipup method.
     46 *
     47 * Arguments:
     48 * <br>gsdlhome, the home of greensone, eg "/research/mgw5/gsdl/"
     49 * <br>collecion, the name of the collection, eg "mgw5-test"
     50 * <br>directory, the name of the directory to zip up, eg "archives"
     51 * <br>[accept_expression], a regular expression of files to exclusively include in the archive. Optional.
     52 * <br>[reject_expression], a regular expression of files to exclude from the archive. Optional.
     53 *
     54 * @see Utility.zipup(String, String, String, GShell, String, String)
    5355 */
    5456public class Zipup {
Note: See TracChangeset for help on using the changeset viewer.