Ignore:
Timestamp:
2009-01-15T18:51:49+13:00 (15 years ago)
Author:
ak19
Message:

Changed to work with the tail filename (of the replacement file) returned by script replace_srcdoc_with_html.pl. The file by this new name is now downloaded.

File:
1 edited

Legend:

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

    r18376 r18397  
    8181    /** whether we were successful or not */
    8282    private boolean successful;
    83 
     83    /** The command output of a successful execution of the replace script
     84     * containing the generated tailname of the replacement file */
     85    private String successfulOutput;
    8486
    8587    public ReplaceSrcDocWithHtmlPrompt(File[] source_files) {
     
    180182    if(event.getStatus() == GShell.OK) {
    181183        successful = true;
     184        GShell process = (GShell)event.getSource();
     185        successfulOutput = process.getCommandOutput();
     186        process.resetCommandOutput();
    182187    }
    183188    }
     
    292297        return 0;
    293298    }
    294     return -1;
     299    return 1;
    295300    }   
    296301
     
    354359        // first run the replace process for all src files, and accumulate error exit values (0 means it's fine)
    355360        for(int i = 0; i < srcdoc_files.length; i++) {
    356         int exit_value_this_time =  replaceSrcDoc(i);
     361        int exit_value_this_time = replaceSrcDoc(i);
    357362        exit_value += exit_value_this_time; // if all files successfully replaced, exit_value will stay at 0
    358363
     
    366371        } else {
    367372            if (Gatherer.isGsdlRemote) {
     373            //System.err.println("*****ReplaceSrcDocWithHtmlPrompt.java - run() - gsdl remote case");
     374
     375            // Conversion may have renamed the file by URL- or base64-encoding it.
     376            // The new replacement file's tailname is the last line of the script output.
     377            String[] lines = successfulOutput.split("\n");
     378            String suffixlessFilename = lines[lines.length-1];
     379            String htmlFile = suffixlessFilename+".html";
     380
    368381            // Delete the local copy of the old source document file on the client side
    369382            // (it's already been replaced on the server side), and download the updated
    370383            // (html) file and any directory containing associated files
    371             System.err.println("*****ReplaceSrcDocWithHtmlPrompt.java - run() - gsdl remote case");
    372             // not sure what the new file is renamed to, so at present still delete entire
    373             // containing directory and get the updated copy of this directory from remote server
    374384            Utility.delete(srcdoc_files[i]); // remove the local copy of src doc
    375 
    376             // let's get just the filename without the suffix
    377             String htmlFile = srcdoc_files[i].getName();
    378             int lastperiod = htmlFile.lastIndexOf('.');
    379             String suffixlessFilename = htmlFile.substring(0, lastperiod); // cut off suffix
    380             htmlFile = suffixlessFilename+".html"; // html filename
    381385
    382386            // download the generated html file from the server side to put it
     
    390394            // If an associated_folder by such a name exists, download it
    391395            if(Gatherer.remoteGreenstoneServer.exists(CollectionManager.getLoadedCollectionName(), assoc_folder)) {
    392               Gatherer.remoteGreenstoneServer.downloadCollectionFile(
     396                Gatherer.remoteGreenstoneServer.downloadCollectionFile(
    393397                                    CollectionManager.getLoadedCollectionName(), assoc_folder);
    394398            }
Note: See TracChangeset for help on using the changeset viewer.