Changeset 9202


Ignore:
Timestamp:
2005-02-28T10:29:08+13:00 (19 years ago)
Author:
mdewsnip
Message:

More GLI applet improvements, by Matthew Whyte. Now uploads only metadata when only metadata has been changed, and only the source files when only the source files have been changed.

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

Legend:

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

    r9166 r9202  
    259259        error.printStackTrace();
    260260    }
    261     }
    262 
    263 
    264     static public void upload_url_zip(String col_name, String dir, GShell source)
     261    DebugStream.println("Exited download_url_zip"); //debug
     262    }
     263
     264
     265    static public void upload_url_zip(String col_name, String dir, String delete_type, GShell source)
    265266    {
    266267    final String lineEnd = "\r\n";
     
    278279        // Send zip file to server
    279280
    280         File file = new File(zip_fname) ;       
     281        File file = new File(zip_fname) ;
     282       
    281283        FileInputStream fileInputStream = new FileInputStream(file);
    282284       
     
    309311   
    310312        dos.writeBytes(twoHyphens + boundary + lineEnd);
     313        dos.writeBytes("Content-Disposition: form-data; name=\"del\"" + lineEnd + lineEnd);
     314        dos.writeBytes(delete_type + lineEnd); 
     315        System.err.println("**** del="+delete_type);
     316
     317        dos.writeBytes(twoHyphens + boundary + lineEnd);
    311318        dos.writeBytes("Content-Disposition: form-data; name=\"zip\";"
    312319               + " filename=\"" + zip_fname +"\"" + lineEnd);
     
    314321        System.err.println("**** zip (filename)="+zip_fname);
    315322               
     323
     324
    316325        // create a buffer of maximum size                 
    317326        int bytesAvailable = fileInputStream.available();
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r9166 r9202  
    217217        // upload etc/collect.cfg to server to reflect changes
    218218        Utility.zipup(Gatherer.getCollectDirectoryPath(), collection_name, Utility.CONFIG_FILE, null, "", "");
    219         GathererApplet.upload_url_zip(collection_name, "etc", null);
     219        GathererApplet.upload_url_zip(collection_name, "etc", "", null);
    220220        }
    221221    }
  • trunk/gli/src/org/greenstone/gatherer/shell/GShell.java

    r9166 r9202  
    241241        String collect_directory_path = Gatherer.getCollectDirectoryPath();
    242242       
    243         //Only upload the import directory if the files or metadata has changed.
    244         System.err.println("getFilesChanged(): " + Gatherer.c_man.getCollection().getFilesChanged());
    245         System.err.println("getMetadataChanged(): " + Gatherer.c_man.getCollection().getMetadataChanged());
    246         if(Gatherer.c_man.getCollection().getFilesChanged() || Gatherer.c_man.getCollection().getMetadataChanged()) {
    247             // zip up import folder
    248             Utility.zipup(collect_directory_path, col_name, "import", this, "", "");
    249             System.err.println("collect_directory_path: " + collect_directory_path);
    250             System.err.println("col_name: " + col_name);
     243        //Only upload the parts of the import folder (files/metadata) that has been changed.
     244        if(Gatherer.c_man.getCollection().getFilesChanged()) {
     245            // zip up import folder, but exclude metadata
     246            Utility.zipup(collect_directory_path, col_name, "import", this, "", ".*metadata\\.xml");
    251247
    252248            if(hasSignalledStop()) { return; }
    253249            // upload it to gsdl server
    254             GathererApplet.upload_url_zip(col_name, "import", this);
     250            GathererApplet.upload_url_zip(col_name, "import", "files", this);
    255251
    256252            Gatherer.c_man.getCollection().setFilesChanged(false);
     253            System.err.println("Finished uploading files");
     254        }
     255        if(Gatherer.c_man.getCollection().getMetadataChanged()) {
     256            // zip up metadata from import folder
     257            Utility.zipup(collect_directory_path, col_name, "import", this, ".*metadata\\.xml", "");
     258
     259            if(hasSignalledStop()) { return; }
     260            // upload it to gsdl server
     261            GathererApplet.upload_url_zip(col_name, "import", "metadata", this);
    257262            Gatherer.c_man.getCollection().setMetadataChanged(false);
     263            System.err.println("Finished uploading metadata.");
    258264        }
    259265       
     
    263269
    264270        if(hasSignalledStop()) { return; }
    265         GathererApplet.upload_url_zip(col_name, "etc", this);
     271        GathererApplet.upload_url_zip(col_name, "etc", "", this);
    266272
    267273        String collection_directory_path = Gatherer.c_man.getCollectionDirectoryPath(col_name);
     
    273279
    274280            if(hasSignalledStop()) { return; }
    275             GathererApplet.upload_url_zip(col_name, "images", this);           
     281            GathererApplet.upload_url_zip(col_name, "images", "", this);
     282
     283            System.err.println("collect_directory_path: " + collect_directory_path);
     284            System.err.println("col_name: " + col_name);
    276285        }
    277286
  • trunk/gli/src/org/greenstone/gatherer/util/Unzip.java

    r7820 r9202  
    103103    }
    104104    catch (IOException ioe) {
    105         System.err.println("Unhandled exception:");
     105        System.err.println("Unhandled exception on " + args[1]);
    106106        ioe.printStackTrace();
    107107        return;
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r9195 r9202  
    7171    static final public int BUFFER_SIZE = FACTOR * 1024;
    7272    /** Definition of an important directory name, in this case the base dir, or the working directory of the Gatherer. */
    73     /** The regular expression that marks if we only want doc.xml files. Will this work in Windows?? --Matthew */
    74     static final public String METADATA_ONLY_EXPR = "\".*" + File.separator + "doc\\.xml\"";
    7573
    7674    static public String BASE_DIR  = System.getProperty("user.dir") + File.separator;
     
    627625    if((reject_expr != "") && (file_path.matches(reject_expr))) {
    628626        // matches reject expression
    629         DebugStream.println("File \'" + file_path + "\' matches the reject expression \'" + reject_expr + "\'");
     627        //DebugStream.println("File \'" + file_path + "\' matches the reject expression \'" + reject_expr + "\'");
    630628        return encountered_file;
    631629    }
     
    633631    if ((accept_expr != "") && (!file_path.matches(accept_expr))) {
    634632        // does not match accept expression
    635         DebugStream.println("File \'" + file_path + "\' doesn't match accept expression \'" + accept_expr + "\'");
     633        //DebugStream.println("File \'" + file_path + "\' doesn't match accept expression \'" + accept_expr + "\'");
    636634        return encountered_file;
    637635    }
     
    639637    //Special case: we only want the metadata. Parse the xml files.
    640638    if(accept_expr.compareTo(".*doc.xml") == 0) {
    641         System.err.println("Only want to get metadata"); //debug
     639        DebugStream.println("Only want to get metadata");
    642640        Document old_document = XMLTools.parseXMLFile(new File(file_path));
    643641        NodeList content = old_document.getElementsByTagName("Content");
     
    719717    static protected boolean dirFunc (ZipOutputStream zos, String dir_name, int prefix_strip, GShell source, boolean encountered_file, String accept_expr, String reject_expr)
    720718    {
    721     /*
    722     if (reject_expr != "" && (dir_name.matches(reject_expr))) {
    723         // matches reject expression
    724         System.err.println("matches reject expression");
    725         return encountered_file;
    726     }
    727    
    728     if ((accept_expr != "") && (!dir_name.matches(accept_expr))) {
    729         // does not match accept expression
    730         System.err.println("doesn't match accept expression");
    731         return encountered_file;
    732     }
    733     */
    734 
    735719    File dirObj = new File(dir_name);
    736720
     
    859843
    860844        if (zipentry.isDirectory()) {
    861             // Create named directory
    862             boolean success = (new File(zentryname)).mkdir();
    863             if (!success) {
    864             System.err.println("Error: unable to create directory '"+zentryname+"'");
     845            if(!file.exists()) {
     846            // Create named directory, if it doesn't already exist.
     847            boolean success = (file.mkdir());
     848            if (!success) {
     849                System.err.println("Error: unable to create directory '"+zentryname+"'");
     850            }
    865851            }
    866852        }
     
    894880    catch (ZipException error) {
    895881        System.err.println("Error: Unable to open '"+zip_fname+"'");
     882        System.err.println("This maybe caused by the zip file being empty.");
    896883        DebugStream.printStackTrace(error);
    897884    }
Note: See TracChangeset for help on using the changeset viewer.