Ignore:
Timestamp:
2005-04-27T11:17:29+12:00 (19 years ago)
Author:
mdewsnip
Message:

Replaced all the nonsense where string arrays were created for running perl scripts with array lists. This removes a lot of duplicated code where the same things were added in different cases, and the silly (and error-prone) "new String[11]"s.

File:
1 edited

Legend:

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

    r9677 r9755  
    5353import org.greenstone.gatherer.shell.GShellEvent;
    5454import org.greenstone.gatherer.shell.GShellListener;
    55 import org.greenstone.gatherer.util.ArrayTools;
    5655import org.greenstone.gatherer.util.Utility;
    5756import org.greenstone.gatherer.util.XMLTools;
     
    226225    }
    227226
    228     private int explodeMetadata() {
    229 
    230     String [] args;
     227    private int explodeMetadata()
     228    {
    231229    if (Gatherer.isGsdlRemote) {
    232230        // what here??
    233231        return -1;
    234232    }
    235     if(Utility.isWindows()){
    236         args = new String[5];
    237         args[0] = Configuration.perl_path;
    238         args[1] = "-S";
    239         args[2] = Configuration.getScriptPath() + "explode_metadata_database.pl";
    240         args[3] = "-plugin";
    241         args[4] = plugin_name;
    242     } else {
    243         args = new String[3];
    244         args[0] = Configuration.getScriptPath() + "explode_metadata_database.pl";
    245         args[1] = "-plugin";
    246         args[2] = plugin_name;
    247 
    248     }
    249     // add in all the options from the user
    250     args = ArrayTools.add(args, options.getValues());
    251     // add in the filename
    252     args = ArrayTools.add(args, metadata_file.getPath());
    253 
     233
     234    // Generate the explode_metadata_database.pl command
     235    ArrayList command_parts_list = new ArrayList();
     236    if (Utility.isWindows() && (!Gatherer.isGsdlRemote)) {
     237        command_parts_list.add(Configuration.perl_path);
     238        command_parts_list.add("-S");
     239    }
     240    command_parts_list.add(Configuration.getScriptPath() + "explode_metadata_database.pl");
     241    command_parts_list.add("-plugin");
     242    command_parts_list.add(plugin_name);
     243
     244    // Add in all the options from the user
     245    String[] explode_options = options.getValues();
     246    for (int i = 0; i < explode_options.length; i++) {
     247        command_parts_list.add(explode_options[i]);
     248    }
     249
     250    // Add in the filename
     251    command_parts_list.add(metadata_file.getPath());
     252
     253    // Run the explode_metadata_database.pl command
     254    String[] command_parts = (String[]) command_parts_list.toArray(new String[0]);
    254255    this.error_message = new StringBuffer();
    255     GShell process = new GShell(args, GShell.EXPLODE, 3, this, null, GShell.GSHELL_EXPLODE);
     256    GShell process = new GShell(command_parts, GShell.EXPLODE, 3, this, null, GShell.GSHELL_EXPLODE);
    256257    //process.start();
    257258    process.run();
Note: See TracChangeset for help on using the changeset viewer.