Ignore:
Timestamp:
2017-05-08T21:18:21+12:00 (7 years ago)
Author:
ak19
Message:

GS3 source code now updated to use SafeProcess instead of Process (calling Runtime.exec() directly). The use of SafeProcess in RunTarget and BrowserLauncher has been tested on Linux. GDBMWrapper, MapRetrieve and admin/guiext's Command.java are not tested. For GDBMWrapper, because it's in a bit of code that works with txtgz databases. MapRetrive.java and Command.java are untested because I don't know how to test them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/MapRetrieve.java

    r28966 r31665  
    2323import org.greenstone.gsdl3.util.GSXML;
    2424import org.greenstone.gsdl3.util.XMLConverter;
     25import org.greenstone.util.SafeProcess;
    2526
    2627import org.w3c.dom.Document;
     
    459460                    // get the map size
    460461                    String get_size[] = { "identify", "-size", "10000", temp_image_file };
     462                    /*
    461463                    Process proc;
    462464                    proc = Runtime.getRuntime().exec(get_size);
     
    464466                    img_size = br.readLine();
    465467                    proc.waitFor();
     468                    */
     469                    SafeProcess proc = new SafeProcess(get_size);
     470                    proc.runProcess();
     471                    img_size = proc.getStdOutput();
     472                    proc = null;
     473
    466474                    img_size = img_size.substring(img_size.indexOf("JPEG") + 5, img_size.indexOf(" ", img_size.indexOf("JPEG") + 5));
    467475                    width = Integer.parseInt(img_size.substring(0, img_size.indexOf("x")));
     
    541549                    BufferedWriter bw = new BufferedWriter(new FileWriter(this.temp_files_dir + "add_x_" + uid));
    542550                    ;
    543                     Process proc;
     551                    SafeProcess proc;
    544552
    545553                    // if a new search
     
    547555                    {
    548556                        // copy requested map to temp.jpg
    549                         proc = Runtime.getRuntime().exec("cp " + this.files_home_dir + "maps" + File.separator + img_num + ".jpg " + temp_image_file);
    550                         proc.waitFor();
     557                        /*proc = Runtime.getRuntime().exec("cp " + this.files_home_dir + "maps" + File.separator + img_num + ".jpg " + temp_image_file);
     558                          proc.waitFor();*/
     559                        proc = new SafeProcess("cp " + this.files_home_dir + "maps" + File.separator + img_num + ".jpg " + temp_image_file);
     560                        proc.runProcess();
     561                        proc = null;                       
    551562                    }
    552563
    553564                    //get the image size
    554565                    String get_size[] = { "identify", "-size", "10000", temp_image_file };
    555                     proc = Runtime.getRuntime().exec(get_size);
     566                    /*proc = Runtime.getRuntime().exec(get_size);               
    556567                    BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    557568                    img_size = br.readLine();
    558569                    proc.waitFor();
     570                    */
     571                    proc = new SafeProcess(get_size);
     572                    proc.runProcess();
     573                    img_size = proc.getStdOutput();
     574                    proc = null;
     575
    559576                    img_size = img_size.substring(img_size.indexOf("JPEG") + 5, img_size.indexOf(" ", img_size.indexOf("JPEG") + 5));
    560577                    if (img_size.indexOf("+") != -1)
     
    754771                            buf.close();
    755772                            // execute the command for the legend image
    756                             proc = Runtime.getRuntime().exec("sh " + this.temp_files_dir + "add_l_" + uid);
    757                             proc.waitFor();
     773                            /*proc = Runtime.getRuntime().exec("sh " + this.temp_files_dir + "add_l_" + uid);
     774                              proc.waitFor();*/
     775                            proc = new SafeProcess("sh " + this.temp_files_dir + "add_l_" + uid);
     776                            proc.runProcess();
     777                            proc = null;
    758778                        }
    759779                        inType.close();
     
    763783
    764784                    // execute the convert commands etc.
    765                     proc = Runtime.getRuntime().exec("sh " + this.temp_files_dir + "add_x_" + uid);
     785                    /*proc = Runtime.getRuntime().exec("sh " + this.temp_files_dir + "add_x_" + uid);
    766786                    proc.waitFor();
     787                    */
     788                    proc = new SafeProcess("sh " + this.temp_files_dir + "add_x_" + uid);
     789                    proc.runProcess();
     790                    proc = null;
    767791
    768792                }
Note: See TracChangeset for help on using the changeset viewer.