Changeset 3763


Ignore:
Timestamp:
Aug 10, 2010, 11:04:53 AM (13 years ago)
Author:
Fredrik Levander
Message:

Refs #688. Removed results script name from mascot parameters, since it is not stable. Updated parsing of results date and filename. Removed unused code.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/conf/mascot.properties.in

    r3698 r3763  
    5959mascot.input.script.path = /cgi/search_form.pl
    6060mascot.search.script.path = /cgi/nph-mascot.exe
    61 # For mascot server 2.3:
    62 # mascot.result.script.path = /cgi/master_results_2.pl
    63 # For Mascot Server 2.2:
    64 mascot.result.script.path = /cgi/master_results.pl
    6561mascot.export.script.path = /cgi/export_dat_2.pl
    6662mascot.archive.path = /data
  • trunk/client/servlet/src/locale/en/dictionary

    r3756 r3763  
    871871Wizard=Wizard
    872872Write=Write
     873X!TandemParameterSet=X!Tandem parameter set
    873874XTandemListPathDefaultParameters=Default parameters
    874875XTandemListPathTaxonomyInformation=Taxonomy information
  • trunk/client/servlet/src/org/proteios/action/mascot/SearchMascot.java

    r3719 r3763  
    125125    //String mascotWebSearchScriptPath = "/cgi/nph-mascot.exe";
    126126    String mascotWebSearchScriptPath = pf.getProperty("mascot.search.script.path");
    127     // Mascot web Mascot result script path
    128     //String mascotWebResultScriptPath = "/cgi/master_results.pl";
    129     String mascotWebResultScriptPath = pf.getProperty("mascot.result.script.path");
    130127    // Mascot web Mascot export script path
    131128    //String mascotExportWebScriptPath = "/cgi/export_dat_2.pl";
     
    165162    log.debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\"");
    166163    log.debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\"");
    167     log.debug("mascotWebResultScriptPath = \"" + mascotWebResultScriptPath + "\"");
    168164    log.debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\"");
    169165    log.debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\"");
     
    282278      StringParameterType mascotWebSearchScriptPathParam = new StringParameterType();
    283279      job.setParameterValue("mascotWebSearchScriptPath", mascotWebSearchScriptPathParam, mascotWebSearchScriptPath);
    284       //
    285       StringParameterType mascotWebResultScriptPathParam = new StringParameterType();
    286       job.setParameterValue("mascotWebResultScriptPath", mascotWebResultScriptPathParam, mascotWebResultScriptPath);
    287280      //
    288281      StringParameterType mascotWebExportScriptPathParam = new StringParameterType();
  • trunk/plugin/src/org/proteios/plugins/SearchMascotPlugin.java

    r3722 r3763  
    3030import org.apache.commons.httpclient.HttpClient;
    3131import org.apache.commons.httpclient.HttpStatus;
    32 import org.apache.commons.httpclient.methods.GetMethod;
    3332import org.apache.commons.httpclient.methods.PostMethod;
    3433import org.apache.commons.httpclient.methods.multipart.FilePart;
     
    5554
    5655import java.io.BufferedReader;
    57 import java.io.FileInputStream;
    58 import java.io.FileOutputStream;
    5956import java.io.IOException;
    6057import java.io.InputStream;
     
    6360import java.io.PrintWriter;
    6461import java.util.ArrayList;
    65 import java.util.Calendar;
    66 import java.util.GregorianCalendar;
    6762import java.util.Hashtable;
    6863import java.util.List;
     
    7772{
    7873  private class StreamGobbler
    79     extends Thread
     74      extends Thread
    8075  {
    8176    InputStream is;
     
    107102    public void run()
    108103    {
    109    PrintWriter pw;
    110    InputStreamReader isr;
    111    BufferedReader br;
    112    String line;
     104      PrintWriter pw;
     105      InputStreamReader isr;
     106      BufferedReader br;
     107      String line;
    113108
    114109      try
     
    153148
    154149  private class FileItemPartSource
    155     implements PartSource
     150      implements PartSource
    156151  {
    157152    File file;
     
    274269      ProgressReporter progress)
    275270  {
    276   String mascotWebServerURLStr;
    277   String mascotWebSearchScriptPath;
    278   String mascotWebResultScriptPath;
    279   String mascotWebExportScriptPath;
    280   String mascotWebArchivePath;
    281   String mascotWebResultFilenamePrefix;
    282   String mascotWebServerTimediffHoursStr;
    283   String mascotWebServerTimediffCorrectionMinutesStr;
    284   String tmpDir;
    285   String mascotInstallPath;
    286   String mascotProgramName;
    287   String mascotDatabaseDirectoryPath;
    288   String mascotInputFilename;
    289   String mascotOutputPath;
    290   String mascotSearchUserName;
    291   String mascotSearchUserEmail;
    292   String mascotProgramPath;
    293   String mascotInputPath;
    294   Integer mascotpssId;
    295   Integer spectrumFileId;
    296   Integer dirId;
    297   Boolean uploadOutputFileFlag;
    298   Boolean useWebInterfaceFlag;
    299   double mascotWebServerTimediffHours;
    300   double mascotWebServerTimediffCorrectionMinutes;
    301   double mascotWebServerTimediffMinutes;
    302  
     271    String mascotWebServerURLStr;
     272    String mascotWebSearchScriptPath;
     273    String mascotWebExportScriptPath;
     274    String mascotWebArchivePath;
     275    String mascotWebResultFilenamePrefix;
     276    String mascotWebServerTimediffHoursStr;
     277    String mascotWebServerTimediffCorrectionMinutesStr;
     278    String tmpDir;
     279    String mascotInstallPath;
     280    String mascotProgramName;
     281    String mascotDatabaseDirectoryPath;
     282    String mascotInputFilename;
     283    String mascotOutputPath;
     284    String mascotSearchUserName;
     285    String mascotSearchUserEmail;
     286    String mascotProgramPath;
     287    String mascotInputPath;
     288    Integer mascotpssId;
     289    Integer spectrumFileId;
     290    Integer dirId;
     291    Boolean uploadOutputFileFlag;
     292    Boolean useWebInterfaceFlag;
     293    double mascotWebServerTimediffHours;
     294    double mascotWebServerTimediffCorrectionMinutes;
     295    double mascotWebServerTimediffMinutes;
     296
    303297    mascotWebServerURLStr = (String) job.getValue("mascotWebServerURLStr");
    304     mascotWebSearchScriptPath = (String) job.getValue("mascotWebSearchScriptPath");
    305     mascotWebResultScriptPath = (String) job.getValue("mascotWebResultScriptPath");
    306     mascotWebExportScriptPath = (String) job.getValue("mascotWebExportScriptPath");
     298    mascotWebSearchScriptPath = (String) job
     299      .getValue("mascotWebSearchScriptPath");
     300    mascotWebExportScriptPath = (String) job
     301      .getValue("mascotWebExportScriptPath");
    307302    mascotWebArchivePath = (String) job.getValue("mascotWebArchivePath");
    308     mascotWebResultFilenamePrefix = (String) job.getValue("mascotWebResultFilenamePrefix");
    309     mascotWebServerTimediffHoursStr = (String) job.getValue("mascotWebServerTimediffHours");
    310     mascotWebServerTimediffCorrectionMinutesStr = (String) job.getValue("mascotWebServerTimediffCorrectionMinutes");
     303    mascotWebResultFilenamePrefix = (String) job
     304      .getValue("mascotWebResultFilenamePrefix");
     305    mascotWebServerTimediffHoursStr = (String) job
     306      .getValue("mascotWebServerTimediffHours");
     307    mascotWebServerTimediffCorrectionMinutesStr = (String) job
     308      .getValue("mascotWebServerTimediffCorrectionMinutes");
    311309    tmpDir = (String) job.getValue("tmpDir");
    312310    mascotInstallPath = (String) job.getValue("mascotInstallPath");
    313311    mascotProgramName = (String) job.getValue("mascotProgramName");
    314     mascotDatabaseDirectoryPath = (String) job.getValue("mascotDatabaseDirectoryPath");
     312    mascotDatabaseDirectoryPath = (String) job
     313      .getValue("mascotDatabaseDirectoryPath");
    315314    mascotInputFilename = (String) job.getValue("mascotInputFilename");
    316315    mascotOutputPath = (String) job.getValue("mascotOutputPath");
     
    329328      .equals(""))
    330329    {
    331       mascotWebServerTimediffHours = Double.parseDouble(mascotWebServerTimediffHoursStr);
     330      mascotWebServerTimediffHours = Double
     331        .parseDouble(mascotWebServerTimediffHoursStr);
    332332    }
    333333
    334334    mascotWebServerTimediffCorrectionMinutes = 0;
    335     if (mascotWebServerTimediffCorrectionMinutesStr != null &&
    336       !mascotWebServerTimediffCorrectionMinutesStr.equals(""))
     335    if (mascotWebServerTimediffCorrectionMinutesStr != null && !mascotWebServerTimediffCorrectionMinutesStr
     336      .equals(""))
    337337    {
    338338      mascotWebServerTimediffCorrectionMinutes = Double
     
    343343    //
    344344    log.debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\"");
    345     log.debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\"");
    346     log.debug("mascotWebResultScriptPath = \"" + mascotWebResultScriptPath + "\"");
    347     log.debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\"");
     345    log
     346      .debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\"");
     347    log
     348      .debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\"");
    348349    log.debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\"");
    349     log.debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\"");
    350     log.debug("mascotWebServerTimediffHoursStr = \"" + mascotWebServerTimediffHoursStr + "\"");
    351     log.debug("mascotWebServerTimediffHours = " + mascotWebServerTimediffHours);
    352     log.debug("mascotWebServerTimediffCorrectionMinutesStr = \"" + mascotWebServerTimediffCorrectionMinutesStr + "\"");
    353     log.debug("mascotWebServerTimediffCorrectionMinutes = " + mascotWebServerTimediffCorrectionMinutes);
    354     log.debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes);
     350    log
     351      .debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\"");
     352    log
     353      .debug("mascotWebServerTimediffHoursStr = \"" + mascotWebServerTimediffHoursStr + "\"");
     354    log
     355      .debug("mascotWebServerTimediffHours = " + mascotWebServerTimediffHours);
     356    log
     357      .debug("mascotWebServerTimediffCorrectionMinutesStr = \"" + mascotWebServerTimediffCorrectionMinutesStr + "\"");
     358    log
     359      .debug("mascotWebServerTimediffCorrectionMinutes = " + mascotWebServerTimediffCorrectionMinutes);
     360    log
     361      .debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes);
    355362    log.debug("tmpDir = \"" + tmpDir + "\"");
    356363    log.debug("mascotInstallPath = \"" + mascotInstallPath + "\"");
    357364    log.debug("mascotProgramName = \"" + mascotProgramName + "\"");
    358365    log.debug("mascotProgramPath = \"" + mascotProgramPath + "\"");
    359     log.debug("mascotDatabaseDirectoryPath = \"" + mascotDatabaseDirectoryPath + "\"");
     366    log
     367      .debug("mascotDatabaseDirectoryPath = \"" + mascotDatabaseDirectoryPath + "\"");
    360368    log.debug("mascotInputFilename = \"" + mascotInputFilename + "\"");
    361369    log.debug("mascotInputPath = \"" + mascotInputPath + "\"");
     
    374382      // Perform Mascot search using web interface
    375383      mascotSearchViaWebInterface(request, response, progress,
    376       mascotWebServerURLStr, mascotWebSearchScriptPath,
    377       mascotWebResultScriptPath, mascotWebExportScriptPath,
    378       mascotInputFilename,
    379       mascotWebArchivePath, mascotWebResultFilenamePrefix,
    380       mascotWebServerTimediffMinutes,
    381       mascotSearchUserName, mascotSearchUserEmail,
    382       mascotpssId, spectrumFileId, dirId,
    383       uploadOutputFileFlag);
     384        mascotWebServerURLStr, mascotWebSearchScriptPath,
     385        mascotWebExportScriptPath, mascotInputFilename,
     386        mascotWebArchivePath, mascotWebResultFilenamePrefix,
     387        mascotWebServerTimediffMinutes, mascotSearchUserName,
     388        mascotSearchUserEmail, mascotpssId, spectrumFileId, dirId,
     389        uploadOutputFileFlag);
    384390    }
    385391    else
    386     {
    387       // Perform Mascot search using local search engine
    388       mascotSearchLocal(request, response, progress, tmpDir,
    389       mascotInstallPath, mascotProgramName, mascotDatabaseDirectoryPath,
    390       mascotInputFilename, mascotOutputPath, mascotpssId,
    391       spectrumFileId, dirId, uploadOutputFileFlag);
    392     }
     392    {}
    393393    done();
    394394  }
     
    410410
    411411
    412  private void addStringPart(String name, String value, List<Part> list)
    413  {
     412  private void addStringPart(String name, String value, List<Part> list)
     413  {
    414414    log.debug("name = \"" + name + "\", value = \"" + value + "\"");
    415415    list.add(new StringPart(name, value));
    416  }
     416  }
     417
    417418
    418419  /**
     
    423424   * @param response Response
    424425   * @param progress ProgressReporter
    425    * @param mascotWebServerURLStr String URL to the Mascot web
    426    *        server
    427    * @param mascotWebSearchScriptPath String Mascot web search
    428    *        script path
    429    * @param mascotWebResultScriptPath String Mascot web result
    430    *        script path
    431    * @param mascotWebExportScriptPath String Mascot web export
    432    *        script path
     426   * @param mascotWebServerURLStr String URL to the Mascot web server
     427   * @param mascotWebSearchScriptPath String Mascot web search script path
     428   * @param mascotWebResultScriptPath String Mascot web result script path
     429   * @param mascotWebExportScriptPath String Mascot web export script path
    433430   * @param mascotInputFilename String The Mascot input filename
    434    * @param mascotWebArchivePath String Mascot web result archive directory path
    435    * @param mascotWebResultFilenamePrefix String Mascot web
    436    *        result filename prefix
    437    * @param mascotWebServerTimediffMinutes double Mascot web
    438    *        server time difference in minutes
     431   * @param mascotWebArchivePath String Mascot web result archive directory
     432   *        path
     433   * @param mascotWebResultFilenamePrefix String Mascot web result filename
     434   *        prefix
     435   * @param mascotWebServerTimediffMinutes double Mascot web server time
     436   *        difference in minutes
    439437   * @param mascotSearchUserName String User name to use for Mascot search.
    440    * @param mascotSearchUserEmail String User e-mail address to use for Mascot search.
     438   * @param mascotSearchUserEmail String User e-mail address to use for Mascot
     439   *        search.
    441440   * @param mascotpssId Integer The Mascot parameter set storage id
    442441   * @param spectrumFileId Integer The Mascot spectrum file id
     
    447446      Response response, ProgressReporter progress,
    448447      String mascotWebServerURLStr, String mascotWebSearchScriptPath,
    449       String mascotWebResultScriptPath, String mascotWebExportScriptPath,
    450       String mascotInputFilename, String mascotWebArchivePath,
    451       String mascotWebResultFilenamePrefix, double mascotWebServerTimediffMinutes,
    452       String mascotSearchUserName, String mascotSearchUserEmail,
    453       Integer mascotpssId, Integer spectrumFileId, Integer dirId,
    454       Boolean uploadOutputFileFlag)
    455   {
    456 
    457   Boolean mascotShowUnassignedInput;
    458   Boolean mascotQueryPeaksInput;
    459   DbControl dc;
    460   ItemFactory factory;
    461   MascotParameterSetStorage mascotpss;
    462   File spectrumFile;
    463   MascotParameterSet mascotParameterSet;
    464   PostMethod postMethod;
    465   HttpClient httpClient;
    466   List<Part> partsList;
    467   Part[] parts;
    468   PartSource partSource;
    469   boolean imported;
    470   Pattern p;
    471   Matcher m;
    472   int statusCode, resultPatternPrefixLen, mascotSearchNumber;
    473 
    474   String mascotWebSearchScriptURLStr;
    475   String mascotWebArchiveURLStr;
    476   String name;
    477   String value;
    478   String content;
    479   String resultFilename;
    480   String resultDate;
    481   String usedResultFilename;
    482   String resultUrl;
    483   String filenameOfUploadedFile;
    484   String inputDataFilename;
    485   String ioErrorString;
    486   String resultPatternPrefix;
    487   String resultPatternStr;
    488   String foundString;
    489   String mess;
    490   String doneMessage;
    491   String spectrumFileInfo;
    492   String mascotResultDate;
    493   String mascotSearchNumberStr;
    494   String mascotShowUnassignedStr;
    495   String mascotQueryPeaksStr;
    496   String mascotQueryMasterStr;
    497   String errorMessage;
    498 
    499   // Define
     448      String mascotWebExportScriptPath, String mascotInputFilename,
     449      String mascotWebArchivePath, String mascotWebResultFilenamePrefix,
     450      double mascotWebServerTimediffMinutes, String mascotSearchUserName,
     451      String mascotSearchUserEmail, Integer mascotpssId,
     452      Integer spectrumFileId, Integer dirId, Boolean uploadOutputFileFlag)
     453  {
     454
     455    Boolean mascotShowUnassignedInput;
     456    Boolean mascotQueryPeaksInput;
     457    DbControl dc;
     458    ItemFactory factory;
     459    MascotParameterSetStorage mascotpss;
     460    File spectrumFile;
     461    MascotParameterSet mascotParameterSet;
     462    PostMethod postMethod;
     463    HttpClient httpClient;
     464    List<Part> partsList;
     465    Part[] parts;
     466    PartSource partSource;
     467    boolean imported;
     468    Pattern p;
     469    Matcher m;
     470    int statusCode, mascotSearchNumber;
     471
     472    String mascotWebSearchScriptURLStr;
     473    String mascotWebArchiveURLStr;
     474    String name;
     475    String value;
     476    String content;
     477    String resultFilename;
     478    String resultDate;
     479    String usedResultFilename;
     480    String resultUrl;
     481    String filenameOfUploadedFile;
     482    String inputDataFilename;
     483    String ioErrorString;
     484    String foundString;
     485    String mess;
     486    String doneMessage;
     487    String spectrumFileInfo;
     488    String mascotResultDate;
     489    String mascotSearchNumberStr;
     490    String mascotShowUnassignedStr;
     491    String mascotQueryPeaksStr;
     492    String mascotQueryMasterStr;
     493    String errorMessage;
     494
     495    // Define
    500496    log.debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\"");
    501     log.debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\"");
    502     log.debug("mascotWebResultScriptPath = \"" + mascotWebResultScriptPath + "\"");
    503     log.debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\"");
     497    log
     498      .debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\"");
     499    log
     500      .debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\"");
    504501    log.debug("mascotInputFilename = \"" + mascotInputFilename + "\"");
    505502    log.debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\"");
    506     log.debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\"");
    507     log.debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes);
     503    log
     504      .debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\"");
     505    log
     506      .debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes);
    508507    log.debug("mascotSearchUserName = \"" + mascotSearchUserName + "\"");
    509508    log.debug("mascotSearchUserEmail = \"" + mascotSearchUserEmail + "\"");
     
    527526    }
    528527
    529     log.debug("mascotWebSearchScriptURLStr = \"" + mascotWebSearchScriptURLStr + "\"");
    530     log.debug("mascotWebArchiveURLStr = \"" + mascotWebArchiveURLStr + "\"");
     528    log
     529      .debug("mascotWebSearchScriptURLStr = \"" + mascotWebSearchScriptURLStr + "\"");
     530    log
     531      .debug("mascotWebArchiveURLStr = \"" + mascotWebArchiveURLStr + "\"");
    531532
    532533    dc = sc.newDbControl();
    533534    factory = new ItemFactory(dc);
    534     mascotpss = factory.getById(MascotParameterSetStorage.class, mascotpssId);
     535    mascotpss = factory.getById(MascotParameterSetStorage.class,
     536      mascotpssId);
    535537    log.debug("mascotParameterSetStorage = " + mascotpss);
    536538    // Get spectrum file
     
    554556      // Hidden input fields with fixed data
    555557      addStringPart("INTERMEDIATE", "", partsList);
    556       addStringPart("FORMVER","1.01",partsList);
    557       addStringPart("PEAK","AUTO",partsList);
    558       addStringPart("ErrTolRepeat","0",partsList);
    559       addStringPart("SHOWALLMODS","",partsList);
     558      addStringPart("FORMVER", "1.01", partsList);
     559      addStringPart("PEAK", "AUTO", partsList);
     560      addStringPart("ErrTolRepeat", "0", partsList);
     561      addStringPart("SHOWALLMODS", "", partsList);
    560562
    561563      // Hidden input fields with variable data
     
    580582        value = new String("");
    581583      }
    582    addStringPart("TAXONOMY", value, partsList);
     584      addStringPart("TAXONOMY", value, partsList);
    583585
    584586      log.debug("Enzyme");
     
    596598      log.debug("Variable mods");
    597599      value = mascotParameterSet.getVariable();
    598    addStringPart("IT_MODS", value, partsList);
    599 
    600       if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet.getSearchType().equals("SQ"))
     600      addStringPart("IT_MODS", value, partsList);
     601
     602      if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet
     603        .getSearchType().equals("SQ"))
    601604      {
    602605        log.debug("Quantitation");
    603606        value = mascotParameterSet.getQuantitation();
    604      addStringPart("QUANTITATION", value, partsList);
     607        addStringPart("QUANTITATION", value, partsList);
    605608      }
    606609
     
    609612        log.debug("Protein mass (kDa)");
    610613        value = mascotParameterSet.getProteinMass();
    611      addStringPart("SEG", value, partsList);
     614        addStringPart("SEG", value, partsList);
    612615      }
    613616
    614617      log.debug("Peptide mass tolerance");
    615618      value = mascotParameterSet.getPepTol();
    616    addStringPart("TOL", value, partsList);
     619      addStringPart("TOL", value, partsList);
    617620
    618621      log.debug("Peptide mass tolerance unit");
    619622      value = mascotParameterSet.getPepTolUnit();
    620    addStringPart("TOLU", value, partsList);
     623      addStringPart("TOLU", value, partsList);
    621624
    622625      if (mascotParameterSet.getSearchType().equals("MIS"))
    623626      {
    624627        value = mascotParameterSet.getPeptideIsotopeError();
    625      addStringPart("PEP_ISOTOPE_ERROR", value, partsList);
    626       }
    627 
    628       if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet.getSearchType().equals("SQ"))
     628        addStringPart("PEP_ISOTOPE_ERROR", value, partsList);
     629      }
     630
     631      if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet
     632        .getSearchType().equals("SQ"))
    629633      {
    630634        log.debug("MS/MS mass tolerance");
    631635        value = mascotParameterSet.getMsMsTol();
    632      addStringPart("ITOL", value, partsList);
     636        addStringPart("ITOL", value, partsList);
    633637
    634638        log.debug("MS/MS mass tolerance unit");
    635639        value = mascotParameterSet.getMsMsTolUnit();
    636      addStringPart("ITOLU", value, partsList);
     640        addStringPart("ITOLU", value, partsList);
    637641
    638642        log.debug("Peptide charge");
    639643        value = mascotParameterSet.getPeptideCharge();
    640      addStringPart("CHARGE", value, partsList);
     644        addStringPart("CHARGE", value, partsList);
    641645      }
    642646
     
    646650        log.debug("Mass ion type");
    647651        value = mascotParameterSet.getMassIonType();
    648      addStringPart("CHARGE", value, partsList);
     652        addStringPart("CHARGE", value, partsList);
    649653      }
    650654
    651655      log.debug("Mass type");
    652656      value = mascotParameterSet.getMassType();
    653    addStringPart("MASS", value, partsList);
     657      addStringPart("MASS", value, partsList);
    654658
    655659      if (mascotParameterSet.getSearchType().equals("MIS"))
    656660      {
    657661        value = mascotParameterSet.getDataFormat();
    658      addStringPart("FORMAT", value, partsList);
     662        addStringPart("FORMAT", value, partsList);
    659663
    660664        value = mascotParameterSet.getPrecursor();
    661      addStringPart("PRECURSOR", value, partsList);
    662       }
    663 
    664       if (mascotParameterSet.getSearchType().equals("SQ") || mascotParameterSet.getSearchType().equals("PMF"))
     665        addStringPart("PRECURSOR", value, partsList);
     666      }
     667
     668      if (mascotParameterSet.getSearchType().equals("SQ") || mascotParameterSet
     669        .getSearchType().equals("PMF"))
    665670      {
    666671        log.debug("Mascot query");
    667672        value = mascotParameterSet.getMascotQuery();
    668      addStringPart("QUE", value, partsList);
    669       }
    670 
    671       if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet.getSearchType().equals("SQ"))
     673        addStringPart("QUE", value, partsList);
     674      }
     675
     676      if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet
     677        .getSearchType().equals("SQ"))
    672678      {
    673679        value = mascotParameterSet.getInstrument();
    674      addStringPart("INSTRUMENT", value, partsList);
     680        addStringPart("INSTRUMENT", value, partsList);
    675681      }
    676682
     
    678684      {
    679685        value = mascotParameterSet.getErrorTolerant();
    680      addStringPart("ERRORTOLERANT", value, partsList);
     686        addStringPart("ERRORTOLERANT", value, partsList);
    681687      }
    682688
    683689      value = mascotParameterSet.getDecoy();
    684    addStringPart("DECOY", value, partsList);
     690      addStringPart("DECOY", value, partsList);
    685691
    686692      value = mascotParameterSet.getReportTop();
    687    addStringPart("REPORT", value, partsList);
     693      addStringPart("REPORT", value, partsList);
    688694
    689695      if (spectrumFile != null)
     
    693699        log.debug("name = \"" + name + "\", value = \"" + value + "\"");
    694700        // Send spectrum file data as post data
    695         partSource = new FileItemPartSource(spectrumFile
    696           .getName(), spectrumFile);
     701        partSource = new FileItemPartSource(spectrumFile.getName(),
     702          spectrumFile);
    697703        partsList.add(new FilePart(name, partSource));
    698704      }
     
    750756      content = postMethod.getResponseBodyAsString();
    751757      log.debug("Response body: " + content);
    752       //
    753758      // Construct Mascot result filename pattern string
    754759      // ../cgi/master_results.pl?file=../data/20090603/F018001.dat
    755       // resultPatternStr = "/cgi/master_results\\.pl\\?file=\\.\\./data/\\d\\d\\d\\d\\d\\d\\d\\d/F\\d+\\.dat"
    756       resultPatternPrefix = mascotWebResultScriptPath;
    757       log.debug("resultPatternPrefix = \"" + resultPatternPrefix + "\"");
    758       resultPatternPrefix = resultPatternPrefix.substring("/cgi".length());
    759       log.debug("resultPatternPrefix = \"" + resultPatternPrefix + "\"");
    760       resultPatternStr = resultPatternPrefix.replaceAll("\\.", "\\\\.");
    761       log.debug("resultPatternStr = \"" + resultPatternStr + "\"");
    762       resultPatternPrefix += "?file=..";
    763       resultPatternStr += "\\?file=\\.\\.";
    764       log.debug("resultPatternStr = \"" + resultPatternStr + "\"");
    765       resultPatternPrefix += mascotWebArchivePath;
    766       resultPatternStr += mascotWebArchivePath;
    767       log.debug("resultPatternStr = \"" + resultPatternStr + "\"");
    768       if (!resultPatternStr.endsWith("/"))
    769       {
    770         resultPatternPrefix += "/";
    771         resultPatternStr += "/";
    772         log.debug("resultPatternStr = \"" + resultPatternStr + "\"");
    773       }
    774       resultPatternStr += "\\d\\d\\d\\d\\d\\d\\d\\d/";
    775       log.debug("resultPatternStr = \"" + resultPatternStr + "\"");
    776       resultPatternStr += mascotWebResultFilenamePrefix;
    777       log.debug("resultPatternStr = \"" + resultPatternStr + "\"");
    778       resultPatternStr += "\\d+\\.dat";
    779       log.debug("resultPatternStr = \"" + resultPatternStr + "\"");
    780760      // Parse Mascot search output for result filename
    781       p = Pattern.compile("/master_results_?2?\\.pl\\?file=\\.\\./data/\\d{8}/F\\d+\\.dat");
     761      p = Pattern
     762        .compile("/master_results_?2?\\.pl\\?file=\\.\\./data/(\\d{8})/(F\\d+\\.dat)");
    782763      m = p.matcher(content);
    783764      if (m.find())
     
    785766        // Get found string
    786767        foundString = m.group(0);
     768        resultDate = m.group(1);
     769        resultFilename = m.group(2);
    787770        log.debug("foundString = \"" + foundString + "\"");
    788771        // Get result URL for future reference
     
    790773        log.debug("resultUrl = \"" + resultUrl + "\"");
    791774        // Extract date in YYYYMMDD format from directory name
    792         resultPatternPrefixLen = resultPatternPrefix.length();
    793         log.debug("resultPatternPrefix = \"" + resultPatternPrefix + "\"");
    794         log.debug("resultPatternPrefixLen = " + resultPatternPrefixLen);
    795         foundString = foundString.substring(resultPatternPrefixLen);
    796         log.debug("foundString = \"" + foundString + "\"");
    797         resultDate = foundString.substring(0,8);
    798775        log.debug("resultDate = \"" + resultDate + "\"");
    799         foundString = foundString.substring(9);
    800         log.debug("foundString = \"" + foundString + "\"");
    801         resultFilename = foundString;
    802776        log.debug("resultFilename = \"" + resultFilename + "\"");
    803777        if (resultFilename != null)
    804778        {
    805779          usedResultFilename = resultFilename;
    806           log.debug("usedResultFilename = \"" + usedResultFilename + "\"");
     780          log
     781            .debug("usedResultFilename = \"" + usedResultFilename + "\"");
    807782          filenameOfUploadedFile = resultFilename;
    808           log.debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");
     783          log
     784            .debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");
    809785          imported = true;
    810786        }
     
    819795          if (content.contains("Sorry"))
    820796          {
    821             mess = content.substring(content
    822               .indexOf("Sorry"));
     797            mess = content.substring(content.indexOf("Sorry"));
    823798            if (mess.contains("Please press the back button"))
    824799            {
    825               // Remove Mascot instruction to press the back button
    826               mess = mess.substring(0, mess.indexOf("Please press the back button"));
     800              // Remove Mascot instruction to press the back
     801              // button
     802              mess = mess.substring(0, mess
     803                .indexOf("Please press the back button"));
    827804            }
    828805            ioErrorString = "Server message: " + mess;
     
    835812          }
    836813        }
    837         p = Pattern.compile("&quot;(GPM\\d+)&quot;");
    838         m = p.matcher(content);
    839         if (m.find())
    840         {
    841           inputDataFilename = "input" + m.group(1) + ".xml";
    842         }
    843         else
    844         {
    845           inputDataFilename = "could not parse";
    846         }
     814        inputDataFilename = "could not parse";
    847815      }
    848816      log.debug("resultFilename = " + resultFilename);
     
    881849      if (spectrumFile != null)
    882850      {
    883         spectrumFileInfo = new String(spectrumFile.getName() + "[" + spectrumFile.getId() + "]");
     851        spectrumFileInfo = new String(
     852          spectrumFile.getName() + "[" + spectrumFile.getId() + "]");
    884853      }
    885854      else
     
    900869        // Get Mascot search number
    901870        // Remove Mascot result filename prefix
    902         mascotSearchNumberStr = resultFilename.substring(mascotWebResultFilenamePrefix.length());
    903         log.debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\"");
     871        mascotSearchNumberStr = resultFilename
     872          .substring(mascotWebResultFilenamePrefix.length());
     873        log
     874          .debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\"");
    904875        // Remove file extension ".dat"
    905         mascotSearchNumberStr = mascotSearchNumberStr.substring(0, mascotSearchNumberStr.length() - 4);
    906         log.debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\"");
     876        mascotSearchNumberStr = mascotSearchNumberStr.substring(0,
     877          mascotSearchNumberStr.length() - 4);
     878        log
     879          .debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\"");
    907880        mascotSearchNumber = Integer.parseInt(mascotSearchNumberStr);
    908881        log.debug("mascotSearchNumber = " + mascotSearchNumber);
     
    919892          mascotQueryPeaksStr = new String("1");
    920893        }
    921         // Mascot "query_master" flag must be set to "1" for any other "query" setting to work
     894        // Mascot "query_master" flag must be set to "1" for any other
     895        // "query" setting to work
    922896        mascotQueryMasterStr = new String("0");
    923897        if (mascotQueryPeaksInput != null && mascotQueryPeaksInput)
     
    926900        }
    927901        //
    928         log.debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\"");
    929         log.debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\"");
    930         log.debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\"");
     902        log
     903          .debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\"");
     904        log
     905          .debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\"");
     906        log
     907          .debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\"");
    931908        log.debug("mascotResultDate = \"" + mascotResultDate + "\"");
    932         log.debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\"");
     909        log
     910          .debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\"");
    933911        log.debug("mascotSearchNumber = " + mascotSearchNumber);
    934         log.debug("mascotShowUnassignedInput = " + mascotShowUnassignedInput);
    935         log.debug("mascotShowUnassignedStr = \"" + mascotShowUnassignedStr + "\"");
     912        log
     913          .debug("mascotShowUnassignedInput = " + mascotShowUnassignedInput);
     914        log
     915          .debug("mascotShowUnassignedStr = \"" + mascotShowUnassignedStr + "\"");
    936916        log.debug("mascotQueryPeaksInput = " + mascotQueryPeaksInput);
    937         log.debug("mascotQueryPeaksStr = \"" + mascotQueryPeaksStr + "\"");
    938         log.debug("mascotQueryMasterStr = \"" + mascotQueryMasterStr + "\"");
     917        log
     918          .debug("mascotQueryPeaksStr = \"" + mascotQueryPeaksStr + "\"");
     919        log
     920          .debug("mascotQueryMasterStr = \"" + mascotQueryMasterStr + "\"");
    939921        log.debug("dirId = " + dirId);
    940922        // Hash table with extra arguments
    941         Hashtable<String, String> extraArgHashtable = new Hashtable<String, String>(0);
    942         extraArgHashtable.put("show_unassigned", mascotShowUnassignedStr);
     923        Hashtable<String, String> extraArgHashtable = new Hashtable<String, String>(
     924          0);
     925        extraArgHashtable.put("show_unassigned",
     926          mascotShowUnassignedStr);
    943927        extraArgHashtable.put("query_master", mascotQueryMasterStr);
    944928        extraArgHashtable.put("query_peaks", mascotQueryPeaksStr);
     
    974958
    975959  /**
    976    * Start a job that performs an X!Tandem search using a web interface to an
    977    * X!Tandem search engine.
     960   * Mascot results XML export
    978961   *
    979962   * @param request Request
     
    986969   * @param mascotResultFilenamePrefix String Mascot result filename prefix
    987970   * @param mascotSearchNumber int Mascot search number
    988    * @param extraArgHashtable Hashtable<String, String> Key-value pairs for extra arguments.
     971   * @param extraArgHashtable Hashtable<String, String> Key-value pairs for
     972   *        extra arguments.
    989973   * @param dirId Integer Id for the directory to upload the file to
    990974   */
     
    997981  {
    998982    log.debug("mascotServerURLStr = \"" + mascotServerURLStr + "\"");
    999     log.debug("mascotExportScriptPath = \"" + mascotExportScriptPath + "\"");
     983    log
     984      .debug("mascotExportScriptPath = \"" + mascotExportScriptPath + "\"");
    1000985    log.debug("mascotArchivePath = \"" + mascotArchivePath + "\"");
    1001986    log.debug("mascotResultDate = \"" + mascotResultDate + "\"");
    1002     log.debug("mascotResultFilenamePrefix = \"" + mascotResultFilenamePrefix + "\"");
     987    log
     988      .debug("mascotResultFilenamePrefix = \"" + mascotResultFilenamePrefix + "\"");
    1003989    log.debug("mascotSearchNumber = " + mascotSearchNumber);
    1004990    // Extra arguments
    1005     for (String argName: extraArgHashtable.keySet())
     991    for (String argName : extraArgHashtable.keySet())
    1006992    {
    1007993      String argVal = extraArgHashtable.get(argName);
     
    10211007    log
    10221008      .debug("mascotExportScriptURLStr = \"" + mascotExportScriptURLStr + "\"");
    1023     log
    1024       .debug("mascotArchiveURLStr = \"" + mascotArchiveURLStr + "\"");
     1009    log.debug("mascotArchiveURLStr = \"" + mascotArchiveURLStr + "\"");
    10251010    //
    10261011    // "../data/20080924/F009765.dat");
    1027     String mascotSearchNumberStr = leftPaddedString(Integer.toString(mascotSearchNumber), 6, '0');
     1012    String mascotSearchNumberStr = leftPaddedString(Integer
     1013      .toString(mascotSearchNumber), 6, '0');
    10281014    log.debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\"");
    10291015    String resultFilePath = ".." + mascotArchivePath + "/" + mascotResultDate + "/" + mascotResultFilenamePrefix + mascotSearchNumberStr + ".dat";
     
    10361022    // Apache HttpClient stuff
    10371023    PostMethod postMethod = null;
    1038     HttpClient httpClient = null;
     1024    // HttpClient httpClient = null;
    10391025    List<Part> partsList = new ArrayList<Part>(0);
    10401026    String name = null;
     
    10451031      // Mascot result file to download
    10461032      name = new String("file");
    1047       //value = new String("../data/20080924/F009765.dat");
     1033      // value = new String("../data/20080924/F009765.dat");
    10481034      value = resultFilePath;
    10491035      log.debug("name = \"" + name + "\", value = \"" + value + "\"");
     
    10531039          .get(partsList.size() - 1));
    10541040      // Default settings
    1055       for (String argName: mascotResultExportArgHashtable.keySet())
     1041      for (String argName : mascotResultExportArgHashtable.keySet())
    10561042      {
    10571043        name = argName;
    10581044        value = mascotResultExportArgHashtable.get(argName);
    1059         log.debug("name = \"" + argName + "\", value = \"" + value + "\"");
     1045        log
     1046          .debug("name = \"" + argName + "\", value = \"" + value + "\"");
    10601047        partsList.add(new StringPart(name, value));
    10611048        log
     
    10641051      }
    10651052      // Extra arguments
    1066       for (String argName: extraArgHashtable.keySet())
     1053      for (String argName : extraArgHashtable.keySet())
    10671054      {
    10681055        name = argName;
    10691056        value = extraArgHashtable.get(argName);
    1070         log.debug("name = \"" + argName + "\", value = \"" + value + "\"");
     1057        log
     1058          .debug("name = \"" + argName + "\", value = \"" + value + "\"");
    10711059        partsList.add(new StringPart(name, value));
    10721060        log
     
    10941082    }
    10951083    // Execute request
    1096     String content = null;
     1084    // String content = null;
    10971085    String resultFilename = null;
    10981086    String usedResultFilename = null;
    1099     String inputDataFilename = new String("unknown");
     1087    // String inputDataFilename = new String("unknown");
    11001088    boolean imported = false;
    11011089    String ioErrorString = null;
     
    11121100    resultFilename = mascotResultFilenamePrefix + mascotSearchNumberStr + ".dat";
    11131101    usedResultFilename = mascotResultDate + "_" + mascotResultFilenamePrefix + mascotSearchNumberStr + ".dat";
    1114     String filenameOfUploadedFile = constructFilenameOfUploadedFile(inputFilename, usedResultFilename);
    1115     FileType fileType = factory.getBySystemId(FileType.class, FileType.MASCOT_XML);
    1116     String description = new String("Mascot result - date: " + mascotResultDate + " file: " + resultFilename);
     1102    String filenameOfUploadedFile = constructFilenameOfUploadedFile(
     1103      inputFilename, usedResultFilename);
     1104    FileType fileType = factory.getBySystemId(FileType.class,
     1105      FileType.MASCOT_XML);
     1106    String description = new String(
     1107      "Mascot result - date: " + mascotResultDate + " file: " + resultFilename);
    11171108    log.debug("resultFilename = \"" + resultFilename + "\"");
    11181109    log.debug("usedResultFilename = \"" + usedResultFilename + "\"");
    1119     log.debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");
     1110    log
     1111      .debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");
    11201112    log.debug("fileType = \"" + fileType + "\"");
    11211113    log.debug("description = \"" + description + "\"");
     
    11271119      try
    11281120      {
    1129         uploadFileViaWebInterface(postMethod,
    1130           filenameOfUploadedFile, dirId,
    1131           description, fileType);
     1121        uploadFileViaWebInterface(postMethod, filenameOfUploadedFile,
     1122          dirId, description, fileType);
    11321123        doneMessagePart2 = doneMessagePart2 + "\n" + "Result file uploaded: " + filenameOfUploadedFile;
    11331124        imported = true;
     
    11641155      errorMessage = errorMessage + "\n" + doneMessagePart2;
    11651156      //
    1166       err.add(new BaseException("No Mascot result retrieval could be performed"));
     1157      err.add(new BaseException(
     1158        "No Mascot result retrieval could be performed"));
    11671159      response.setError(errorMessage, err);
    11681160    }
     
    11721164
    11731165  /**
    1174    * Fetches Mascot result export default settings
    1175    * in the form of a hash table with name-value pairs.
     1166   * Fetches Mascot result export default settings in the form of a hash table
     1167   * with name-value pairs.
    11761168   *
    1177    * @return Hashtable<String, String> Name-value pair hash table of Mascot result export default settings.
     1169   * @return Hashtable<String, String> Name-value pair hash table of Mascot
     1170   *         result export default settings.
    11781171   */
    11791172  private Hashtable<String, String> fetchMascotResultExportDefaultSettings()
    11801173  {
    11811174    // Hash table with default settings
    1182     Hashtable<String, String> mascotResultExportArgHashtable = new Hashtable<String, String>(0);
     1175    Hashtable<String, String> mascotResultExportArgHashtable = new Hashtable<String, String>(
     1176      0);
    11831177    mascotResultExportArgHashtable.put("export_format", "XML");
    11841178    mascotResultExportArgHashtable.put("do_export", "1");
     
    11951189    // show_unassigned : Include peptides not assigned to proteins
    11961190    // show_inassigned settings excluded here as it is user-selected
    1197     //mascotResultExportArgHashtable.put("show_unassigned", "0");
     1191    // mascotResultExportArgHashtable.put("show_unassigned", "0");
    11981192    mascotResultExportArgHashtable.put("show_same_sets", "1");
    11991193    mascotResultExportArgHashtable.put("_showsubsets", "1");
     
    12361230
    12371231  /**
    1238    * Construct filename for uploaded search result file.
    1239    * The constructed filename consists of the (possibly modified)
    1240    * base name of the input file, an underscore, plus the modified
    1241    * result filename consisting of the date, an underscore, and the
    1242    * result filename with file extension ".dat" exchanged for ".xml".
     1232   * Construct filename for uploaded search result file. The constructed
     1233   * filename consists of the (possibly modified) base name of the input file,
     1234   * an underscore, plus the modified result filename consisting of the date,
     1235   * an underscore, and the result filename with file extension ".dat"
     1236   * exchanged for ".xml".
    12431237   *
    12441238   * @param inputFilename String Filename of input file for search.
     
    12621256        tmpStr = tmpStr.substring(strIndex + 1);
    12631257      }
    1264       log.debug("tmpStr after removing prefix ending with '\\' = \"" + tmpStr + "\"");
     1258      log
     1259        .debug("tmpStr after removing prefix ending with '\\' = \"" + tmpStr + "\"");
    12651260      // Remove optional prefix ending with '/'
    12661261      strIndex = tmpStr.lastIndexOf("/");
     
    12691264        tmpStr = tmpStr.substring(strIndex + 1);
    12701265      }
    1271       log.debug("tmpStr after removing prefix ending with '/' = \"" + tmpStr + "\"");
     1266      log
     1267        .debug("tmpStr after removing prefix ending with '/' = \"" + tmpStr + "\"");
    12721268      // Remove optional prefix ending with ':'
    12731269      strIndex = tmpStr.lastIndexOf(":");
     
    12761272        tmpStr = tmpStr.substring(strIndex + 1);
    12771273      }
    1278       log.debug("tmpStr after removing prefix ending with ':' = \"" + tmpStr + "\"");
     1274      log
     1275        .debug("tmpStr after removing prefix ending with ':' = \"" + tmpStr + "\"");
    12791276      // Remove any initial blanks
    12801277      tmpStr = tmpStr.replaceAll("^\\ *", "");
    1281       log.debug("tmpStr after removing initial blanks = \"" + tmpStr + "\"");
     1278      log
     1279        .debug("tmpStr after removing initial blanks = \"" + tmpStr + "\"");
    12821280      // Remove optional file extension from input filename
    12831281      strIndex = tmpStr.lastIndexOf(".");
     
    12861284        tmpStr = tmpStr.substring(0, strIndex);
    12871285      }
    1288       log.debug("tmpStr after removing file extension = \"" + tmpStr + "\"");
    1289       // Replace any remaining blanks ' ' in input filename with underscores '_'
     1286      log
     1287        .debug("tmpStr after removing file extension = \"" + tmpStr + "\"");
     1288      // Replace any remaining blanks ' ' in input filename with
     1289      // underscores '_'
    12901290      tmpStr = tmpStr.replaceAll(" ", "_");
    1291       log.debug("tmpStr after replacing blanks ' ' with underscores '_' = \"" + tmpStr + "\"");
    1292       // Replace any remaining dots '.' in input filename with underscores '_'
     1291      log
     1292        .debug("tmpStr after replacing blanks ' ' with underscores '_' = \"" + tmpStr + "\"");
     1293      // Replace any remaining dots '.' in input filename with underscores
     1294      // '_'
    12931295      tmpStr = tmpStr.replaceAll("\\.", "_");
    1294       log.debug("tmpStr after replacing dots '.' with underscores '_' = \"" + tmpStr + "\"");
     1296      log
     1297        .debug("tmpStr after replacing dots '.' with underscores '_' = \"" + tmpStr + "\"");
    12951298      // Add underscore and modified result filename
    12961299      tmpStr = tmpStr + "_" + filename;
    1297       log.debug("tmpStr after adding underscore '_' and modified result filename = \"" + tmpStr + "\"");
     1300      log
     1301        .debug("tmpStr after adding underscore '_' and modified result filename = \"" + tmpStr + "\"");
    12981302    }
    12991303    else
     
    13581362
    13591363  /**
    1360    * Fetches Mascot input filename from parsed result file
    1361    * via web interface from HTTPClient PostMethod.
     1364   * Fetches Mascot input filename from parsed result file via web interface
     1365   * from HTTPClient PostMethod.
    13621366   *
    1363    * @param postMethod PostMethod HTTPClient PostMethod for getting input stream of Mascot result file.
    1364    * @return String Mascot input filename for result file, or null if not found.
     1367   * @param postMethod PostMethod HTTPClient PostMethod for getting input
     1368   *        stream of Mascot result file.
     1369   * @return String Mascot input filename for result file, or null if not
     1370   *         found.
    13651371   */
    13661372  private String fetchMascotInputFilename(PostMethod postMethod)
     
    13761382      if (statusCode != HttpStatus.SC_OK)
    13771383      {
    1378         log.warn("Error when trying to execute PostMethod: " + postMethod
    1379           .getStatusLine());
     1384        log
     1385          .warn("Error when trying to execute PostMethod: " + postMethod
     1386            .getStatusLine());
    13801387      }
    13811388      // Get response
    1382       //InputStream inStream = postMethod.getResponseBodyAsStream();
     1389      // InputStream inStream = postMethod.getResponseBodyAsStream();
    13831390      String content = postMethod.getResponseBodyAsString();
    13841391      String regexStr = new String("<FILENAME>.+</FILENAME>");
     
    14021409      else
    14031410      {
    1404         log.debug("regex string \"" + regexStr + "\" not found in file contents.");
     1411        log
     1412          .debug("regex string \"" + regexStr + "\" not found in file contents.");
    14051413      }
    14061414    }
     
    14291437
    14301438  /**
    1431    * Checks Mascot output via web interface from
    1432    * HTTPClient PostMethod for indications of problems.
     1439   * Checks Mascot output via web interface from HTTPClient PostMethod for
     1440   * indications of problems.
    14331441   *
    1434    * @param postMethod PostMethod HTTPClient PostMethod for getting input stream of Mascot result file.
     1442   * @param postMethod PostMethod HTTPClient PostMethod for getting input
     1443   *        stream of Mascot result file.
    14351444   * @return String Error text to display, or null if no error found.
    14361445   */
     
    14471456      if (statusCode != HttpStatus.SC_OK)
    14481457      {
    1449         log.warn("Error when trying to execute PostMethod: " + postMethod
    1450           .getStatusLine());
     1458        log
     1459          .warn("Error when trying to execute PostMethod: " + postMethod
     1460            .getStatusLine());
    14511461      }
    14521462      // Get response
    1453       //InputStream inStream = postMethod.getResponseBodyAsStream();
     1463      // InputStream inStream = postMethod.getResponseBodyAsStream();
    14541464      boolean errorIndicated = false;
    14551465      String content = postMethod.getResponseBodyAsString();
     
    14641474      else
    14651475      {
    1466         log.debug("regex string \"" + regexStr + "\" not found in file contents.");
     1476        log
     1477          .debug("regex string \"" + regexStr + "\" not found in file contents.");
    14671478      }
    14681479      if (errorIndicated)
     
    14881499        else
    14891500        {
    1490           log.debug("regex string \"" + regexStr + "\" not found in file contents.");
     1501          log
     1502            .debug("regex string \"" + regexStr + "\" not found in file contents.");
    14911503        }
    14921504        if (errorText == null || errorText.equals(""))
    14931505        {
    1494           errorText = new String("Software error reported by Mascot server, but error text could not be retrieved.");
     1506          errorText = new String(
     1507            "Software error reported by Mascot server, but error text could not be retrieved.");
    14951508        }
    14961509      }
     
    15201533
    15211534  /**
    1522    * Uploads file via web interface into Proteios
    1523    * from HTTPClient PostMethod.
     1535   * Uploads file via web interface into Proteios from HTTPClient PostMethod.
    15241536   *
    1525    * @param postMethod PostMethod HTTPClient PostMethod for getting input stream of file to upload
     1537   * @param postMethod PostMethod HTTPClient PostMethod for getting input
     1538   *        stream of file to upload
    15261539   * @param filenameOfUploadedFile String Filename to use for uploaded file
    15271540   * @param dirId Integer Database id of directory to put file item in
     
    15311544   */
    15321545  private void uploadFileViaWebInterface(PostMethod postMethod,
    1533       String filenameOfUploadedFile, Integer dirId,
    1534       String descr, FileType fileType)
     1546      String filenameOfUploadedFile, Integer dirId, String descr,
     1547      FileType fileType)
    15351548      throws BaseException
    15361549  {
     
    15821595      if (statusCode != HttpStatus.SC_OK)
    15831596      {
    1584         log.warn("Error when trying to execute PostMethod: " + postMethod
    1585           .getStatusLine());
     1597        log
     1598          .warn("Error when trying to execute PostMethod: " + postMethod
     1599            .getStatusLine());
    15861600      }
    15871601      // Get response
     
    16131627    }
    16141628  }
    1615 
    1616  
    1617   /**
    1618    * Gets the actual result filename when searching Mascot via a web interface,
    1619    * given the reported result filename. First is checked if a file with the
    1620    * latter name exists. If the file is not found, the check is repeated with
    1621    * an added time stamp and extra suffix added to the filename, starting with
    1622    * the current time and repeated a number of seconds back in time if not
    1623    * file is found. If a file is found, the successful filename is returned,
    1624    * otherwise null.
    1625    *
    1626    * @param directoryURLStr String URL of web directory with file to upload
    1627    * @param originalFilename String The original reported Mascot result filename.
    1628    * @param mascotWebServerTimediffMinutes double The time difference to the Mascot
    1629    *        web server in minutes
    1630    * @return String The actual result filename if found, else null.
    1631    */
    1632   private String fetchUsedResultFilename(String directoryURLStr,
    1633       String originalFilename, double mascotWebServerTimediffMinutes)
    1634   {
    1635     log.debug("directoryURLStr = \"" + directoryURLStr + "\"");
    1636     log.debug("originalFilename = \"" + originalFilename + "\"");
    1637     log.debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes);
    1638     String actualFilename = null;
    1639     boolean outputFileFound = false;
    1640     // First try to find file using original filename
    1641     String testFilename = originalFilename;
    1642     if (fileCanBeReadViaWebInterface(directoryURLStr, testFilename))
    1643     {
    1644       actualFilename = testFilename;
    1645       outputFileFound = true;
    1646     }
    1647     log
    1648       .debug("testFilename = \"" + testFilename + "\" outputFileFound = " + outputFileFound);
    1649     // If file not found, try adding time stamp etc. to filename
    1650     if (!outputFileFound)
    1651     {
    1652       // Get output file name including time stamp, check a number of
    1653       // seconds back in time
    1654       // Calendar cal = Calendar.getInstance();
    1655       Calendar cal = GregorianCalendar.getInstance();
    1656       // Correct time to Mascot web server time zone
    1657       int mascotWebServerTimeDiffInMillis = (int) (mascotWebServerTimediffMinutes * 60 * 1000);
    1658       long timeInMilliSec = cal.getTimeInMillis();
    1659       timeInMilliSec += mascotWebServerTimeDiffInMillis;
    1660       cal.setTimeInMillis(timeInMilliSec);
    1661       int maxSeconds = 90;
    1662       // Check maxSeconds back in time
    1663       for (int secToSubtract = 0; !outputFileFound && secToSubtract < maxSeconds; secToSubtract++)
    1664       {
    1665         testFilename = fetchMascotOutputPathWithTimeStamp(
    1666           originalFilename, null, cal, -secToSubtract);
    1667         if (fileCanBeReadViaWebInterface(directoryURLStr, testFilename))
    1668         {
    1669           actualFilename = testFilename;
    1670           outputFileFound = true;
    1671           log
    1672             .debug("testFilename = \"" + testFilename + "\" outputFileFound = " + outputFileFound + " Time difference in seconds = " + -secToSubtract);
    1673         }
    1674         // log.debug("testFilename = \"" + testFilename + "\"
    1675         // outputFileFound = " + outputFileFound + " secToSubtract = " +
    1676         // secToSubtract);
    1677       }
    1678       // Check maxSeconds forward in time
    1679       for (int secToAdd = 1; !outputFileFound && secToAdd < maxSeconds; secToAdd++)
    1680       {
    1681         testFilename = fetchMascotOutputPathWithTimeStamp(
    1682           originalFilename, null, cal, secToAdd);
    1683         if (fileCanBeReadViaWebInterface(directoryURLStr, testFilename))
    1684         {
    1685           actualFilename = testFilename;
    1686           outputFileFound = true;
    1687           log
    1688             .debug("testFilename = \"" + testFilename + "\" outputFileFound = " + outputFileFound + " Time difference in seconds = " + secToAdd);
    1689         }
    1690         // log.debug("testFilename = \"" + testFilename + "\"
    1691         // outputFileFound = " + outputFileFound + " secToAdd = " +
    1692         // secToAdd);
    1693       }
    1694     }
    1695     return actualFilename;
    1696   }
    1697 
    1698 
    1699   /**
    1700    * Start a job that performs an Mascot search using a locally installed
    1701    * Mascot search engine.
    1702    *
    1703    * @param request Request
    1704    * @param response Response
    1705    * @param progress ProgressReporter
    1706    * @param tmpDir String Directory for temporary files
    1707    * @param mascotInstallPath String The Mascot install path
    1708    * @param mascotProgramName String The Mascot program name
    1709    * @param mascotDatabaseDirectoryPath String Path to directory with Mascot databases
    1710    * @param mascotInputFilename String The Mascot input filename
    1711    * @param mascotOutputPath String The Mascot output path
    1712    * @param mascotpssId Integer The Mascot parameter set storage id
    1713    * @param spectrumFileId Integer The Mascot spectrum file id
    1714    * @param dirId Integer The directory id
    1715    * @param uploadOutputFileFlag Boolean The upload output file flag
    1716    */
    1717   private void mascotSearchLocal(Request request, Response response,
    1718       ProgressReporter progress, String tmpDir,
    1719       String mascotInstallPath, String mascotProgramName, String mascotDatabaseDirectoryPath,
    1720       String mascotInputFilename, String mascotOutputPath,
    1721       Integer mascotpssId, Integer spectrumFileId, Integer dirId,
    1722       Boolean uploadOutputFileFlag)
    1723   {
    1724     String mascotProgramPath = mascotInstallPath + "/" + mascotProgramName;
    1725     String mascotInputPath = mascotInstallPath + "/" + mascotInputFilename;
    1726     //
    1727     log.debug("tmpDir = \"" + tmpDir + "\"");
    1728     log.debug("mascotInstallPath = \"" + mascotInstallPath + "\"");
    1729     log.debug("mascotProgramName = \"" + mascotProgramName + "\"");
    1730     log.debug("mascotProgramPath = \"" + mascotProgramPath + "\"");
    1731     log.debug("mascotDatabaseDirectoryPath = \"" + mascotDatabaseDirectoryPath + "\"");
    1732     log.debug("mascotInputFilename = \"" + mascotInputFilename + "\"");
    1733     log.debug("mascotInputPath = \"" + mascotInputPath + "\"");
    1734     log.debug("mascotOutputPath = \"" + mascotOutputPath + "\"");
    1735     log.debug("uploadOutputFileFlag = " + uploadOutputFileFlag);
    1736     // Create output file in directory for temporary files
    1737     mascotOutputPath = new String("mascot_output_" + job.getId() + ".xml");
    1738     // Calendar cal = Calendar.getInstance();
    1739     Calendar cal = GregorianCalendar.getInstance();
    1740     String mascotOutputPathWithTimeStamp = fetchMascotOutputPathWithTimeStamp(
    1741       mascotOutputPath, null, cal, 0);
    1742     log.debug("mascotOutputPathWithTimeStamp = \"" + mascotOutputPathWithTimeStamp + "\"");
    1743     mascotOutputPath = tmpDir + "/" + mascotOutputPathWithTimeStamp;
    1744     log.debug("mascotOutputPath (modified) = \"" + mascotOutputPath + "\"");
    1745     //
    1746     DbControl dc = sc.newDbControl();
    1747     ItemFactory factory = new ItemFactory(dc);
    1748     MascotParameterSetStorage mascotpss = factory.getById(
    1749       MascotParameterSetStorage.class, mascotpssId);
    1750     log.debug("mascotParameterSetStorage = " + mascotpss);
    1751     // Get spectrum file
    1752     File spectrumFile = factory.getById(File.class, spectrumFileId);
    1753     log.debug("spectrumFile = " + spectrumFile);
    1754     // Get Mascot input data from Mascot parameters XML file
    1755     MascotParameterSet mascotParameterSet = mascotpss
    1756       .fetchMascotParameterSet();
    1757     //
    1758     // To be completed if needed...
    1759   }
    1760 
    1761 
    1762   /**
    1763    * Update command line with new option and value,
    1764    * provided that the value differs from null and
    1765    * an empty string.
    1766    *
    1767    * @param cmd String Current command line to append new options to.
    1768    * @param option String New option string.
    1769    * @param value String Value of new option.
    1770    * @return String Updated command line with new option appended.
    1771    */
    1772   private String updateCommand(String cmd, String option, String value)
    1773   {
    1774     String valueString = new String("\"" + value + "\"");
    1775     if (value == null)
    1776     {
    1777       valueString = value;
    1778     }
    1779     log.debug("option = \"" + option + "\", value = " + valueString);
    1780     if (value != null && !value.equals(""))
    1781     {
    1782       cmd = cmd + " " + option + " " + value;
    1783     }
    1784     else
    1785     {
    1786       log.debug("option = \"" + option + "\" skipped, since value = " + valueString);
    1787     }
    1788     // Return command line
    1789     return cmd;
    1790   }
    1791 
    1792 
    1793   /**
    1794    * Appends time stamp to file base filename (filename excluding optional
    1795    * file extension) for XML file path. Adds ".xml" file extension. Example:
    1796    * Basic xml file path: proteios_mascot_output Discr id: 3 Time stamp:
    1797    * 2008-02-29 12:47:00 Returned xml file path:
    1798    * proteios_mascot_output_3.2008_02_29_12_47_00.xml
    1799    *
    1800    * @param xmlFilePath String Input file path
    1801    * @param discrId Integer Index to discriminate between files created same
    1802    *        second
    1803    * @param inputCal Calendar Timestamp to use
    1804    * @param secondsToAd int Number of seconds to add (subtract if negative) to
    1805    *        timestamp
    1806    * @return String File path with time stamp appended to file name
    1807    */
    1808   private String fetchMascotOutputPathWithTimeStamp(String xmlFilePath,
    1809       Integer discrId, Calendar inputCal, int secondsToAdd)
    1810   {
    1811     /*
    1812      * Appends time stamp to file base filename (filename excluding optional
    1813      * file extension) for XML file path. Adds ".xml" file extension.
    1814      * Example: Basic xml file path: proteios_mascot_output Discr id: 3
    1815      * Time stamp: 2008-02-29 12:47:00 Returned xml file path:
    1816      * proteios_mascot_output_3.2008_02_29_12_47_00.xml
    1817      */
    1818     StringBuilder sb = new StringBuilder();
    1819     sb.append(xmlFilePath);
    1820     // Remove ".xml" file extension
    1821     if (sb.toString().endsWith(".xml"))
    1822     {
    1823       sb.setLength(sb.length() - 4);
    1824     }
    1825     //
    1826     if (discrId != null && discrId >= 0)
    1827     {
    1828       sb.append("_");
    1829       sb.append(discrId);
    1830     }
    1831     //
    1832     sb.append(".");
    1833     // Make a copy of the input Calendar object, as we don't want to change
    1834     // the value of the latter
    1835     Calendar cal = (Calendar) inputCal.clone();
    1836     long timeInMilliSec = cal.getTimeInMillis();
    1837     timeInMilliSec += secondsToAdd * 1000;
    1838     cal.setTimeInMillis(timeInMilliSec);
    1839     int year = cal.get(Calendar.YEAR);
    1840     int month = cal.get(Calendar.MONTH) + 1;
    1841     int day = cal.get(Calendar.DAY_OF_MONTH);
    1842     int hour = cal.get(Calendar.HOUR_OF_DAY);
    1843     int min = cal.get(Calendar.MINUTE);
    1844     int sec = cal.get(Calendar.SECOND);
    1845     String monthStr = leftPaddedString(Integer.toString(month), 2, '0');
    1846     String dayStr = leftPaddedString(Integer.toString(day), 2, '0');
    1847     String hourStr = leftPaddedString(Integer.toString(hour), 2, '0');
    1848     String minStr = leftPaddedString(Integer.toString(min), 2, '0');
    1849     String secStr = leftPaddedString(Integer.toString(sec), 2, '0');
    1850     sb.append(year);
    1851     sb.append("_");
    1852     sb.append(monthStr);
    1853     sb.append("_");
    1854     sb.append(dayStr);
    1855     sb.append("_");
    1856     sb.append(hourStr);
    1857     sb.append("_");
    1858     sb.append(minStr);
    1859     sb.append("_");
    1860     sb.append(secStr);
    1861     //
    1862     sb.append(".xml");
    1863     String xmlFilePathWithSuffix = sb.toString();
    1864     // log.debug("xmlFilePath = \"" + xmlFilePath + "\"");
    1865     // log.debug("xmlFilePathWithSuffix = \"" + xmlFilePathWithSuffix +
    1866     // "\"");
    1867     //
    1868     return xmlFilePathWithSuffix;
    1869   }
    1870 
    1871 
    1872   /**
    1873    * Checks if a file can be read via web interface.
    1874    *
    1875    * @param directoryURLStr String URL of web directory with file to upload
    1876    * @param fileName String Filename of file to upload
    1877    * @return boolean Returns true if file can be read, else false.
    1878    */
    1879   private boolean fileCanBeReadViaWebInterface(String directoryURLStr,
    1880       String fileName)
    1881   {
    1882     // log.debug("directoryURLStr = \"" + directoryURLStr + "\"");
    1883     // log.debug("fileName = \"" + fileName + "\"");
    1884     //
    1885     String fileURLStr = directoryURLStr + "/" + fileName;
    1886     // log.debug("fileURLStr = \"" + fileURLStr + "\"");
    1887     //
    1888     boolean result = false;
    1889     GetMethod getMethod = null;
    1890     try
    1891     {
    1892       // Get Get method
    1893       getMethod = new GetMethod(fileURLStr);
    1894       // Get HTTP client
    1895       HttpClient httpClient = new HttpClient();
    1896       int statusCode = httpClient.executeMethod(getMethod);
    1897       // Check status code
    1898       // log.debug("Response status code: " + statusCode);
    1899       if (statusCode == HttpStatus.SC_OK)
    1900       {
    1901         result = true;
    1902       }
    1903       else
    1904       {
    1905         result = false;
    1906       }
    1907     }
    1908     catch (Exception e)
    1909     {
    1910       log
    1911         .debug("Exception when trying to contact url \"" + fileURLStr + "\": " + e);
    1912       result = false;
    1913     }
    1914     finally
    1915     {
    1916       // Release current connection to the connection pool once you are
    1917       // done
    1918       if (getMethod != null)
    1919       {
    1920         // log.debug("Trying to release connection to GetMethod");
    1921         getMethod.releaseConnection();
    1922         // log.debug("After trying to release connection to GetMethod");
    1923       }
    1924       else
    1925       {
    1926         log.debug("Connection to GetMethod already closed.");
    1927       }
    1928     }
    1929     return result;
    1930   }
    1931 
    1932 
    1933   /**
    1934    * Checks if an input stream can be opened from a local file path.
    1935    *
    1936    * @param basePath String Path from with localPath is referenced
    1937    * @param localPath String Path to local file
    1938    * @return boolean True if input stream can be opened from file, else false.
    1939    */
    1940   private boolean localFileCanBeRead(String basePath, String localPath)
    1941   {
    1942     log.debug("basePath = \"" + basePath + "\"");
    1943     log.debug("localPath = \"" + localPath + "\"");
    1944     String fullPath = null;
    1945     if (basePath != null && !basePath.equals(""))
    1946     {
    1947       fullPath = basePath + "/" + localPath;
    1948     }
    1949     else
    1950     {
    1951       fullPath = localPath;
    1952     }
    1953     log.debug("fullPath = \"" + fullPath + "\"");
    1954     boolean fileCheckResult = false;
    1955     InputStream inStream = null;
    1956     try
    1957     {
    1958       inStream = new FileInputStream(fullPath);
    1959       inStream.close();
    1960       fileCheckResult = true;
    1961     }
    1962     catch (Exception e)
    1963     {
    1964       log.debug(e.getMessage(), e);
    1965     }
    1966     return fileCheckResult;
    1967   }
    1968 
    1969 
    1970   /**
    1971    * Saves a file item as a temporary file.
    1972    *
    1973    * @param inFile File File item to copy to temporary file.
    1974    * @param tmpFile java.io.File Temporary file to create.
    1975    * @throws IOException If there is an error
    1976    */
    1977   private void saveTemporaryFile(File inFile, java.io.File tmpFile)
    1978       throws IOException
    1979   {
    1980     //
    1981     InputStream iStream = null;
    1982     OutputStream oStream = null;
    1983     //
    1984     try
    1985     {
    1986       iStream = inFile.getDownloadStream(0);
    1987     }
    1988     catch (Exception e)
    1989     {
    1990       throw new IOException(
    1991         "Exception when trying to get download stream for file \"" + inFile
    1992           .getPath() + "\" : " + e);
    1993     }
    1994     // Save input file data in external temporary file
    1995     try
    1996     {
    1997       oStream = new FileOutputStream(tmpFile);
    1998       org.apache.commons.io.IOUtils.copy(iStream, oStream);
    1999       oStream.flush();
    2000     }
    2001     catch (Exception e)
    2002     {
    2003       throw new IOException(
    2004         "Exception when trying to get upload stream for file \"" + tmpFile
    2005           .getAbsolutePath() + "\" : " + e);
    2006     }
    2007     // Make sure that download stream is closed
    2008     try
    2009     {
    2010       if (iStream != null)
    2011       {
    2012         // Close download stream.
    2013         iStream.close();
    2014       }
    2015     }
    2016     catch (Exception e)
    2017     {
    2018       throw new IOException(
    2019         "Exception when trying to close download stream for file \"" + inFile
    2020           .getPath() + "\" : " + e);
    2021     }
    2022     // Make sure that upload stream is closed
    2023     try
    2024     {
    2025       if (oStream != null)
    2026       {
    2027         oStream.flush();
    2028         // Close upload stream.
    2029         oStream.close();
    2030       }
    2031     }
    2032     catch (Exception e)
    2033     {
    2034       throw new IOException(
    2035         "Exception when trying to close upload stream for file \"" + tmpFile
    2036           .getAbsolutePath() + "\" : " + e);
    2037     }
    2038   }
    2039 
    2040 
    2041   /**
    2042    * Uploads file via web interface into Proteios.
    2043    *
    2044    * @param directoryURLStr String URL of web directory with file to upload
    2045    * @param filename String Filename of file to upload
    2046    * @param filenameOfUploadedFile String Filename to use for uploaded file
    2047    * @param dirId Integer Database id of directory to put file item in
    2048    * @param descr String Description for uploaded file item
    2049    * @param fileType FileType FileType for uploaded file item
    2050    * @throws BaseException
    2051    */
    2052   private void uploadFileViaWebInterface(String directoryURLStr,
    2053       String filename, String filenameOfUploadedFile, Integer dirId,
    2054       String descr, FileType fileType)
    2055       throws BaseException
    2056   {
    2057     log.debug("directoryURLStr = \"" + directoryURLStr + "\"");
    2058     log.debug("filename = \"" + filename + "\"");
    2059     log
    2060       .debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");
    2061     log.debug("dirId = " + dirId);
    2062     log.debug("descr = \"" + descr + "\"");
    2063     log.debug("fileType = \"" + fileType + "\"");
    2064     //
    2065     String fileURLStr = directoryURLStr + "/" + filename;
    2066     log.debug("fileURLStr = \"" + fileURLStr + "\"");
    2067     /*
    2068      * If there is an active project the file is saved in the project
    2069      * directory, otherwise we use the users home directory.
    2070      */
    2071     DbControl dc = sc.newDbControl();
    2072     ItemFactory factory = new ItemFactory(dc);
    2073     //
    2074     Directory dir = null;
    2075     if (dirId != null && dirId > 0)
    2076     {
    2077       try
    2078       {
    2079         dir = factory.getById(Directory.class, dirId);
    2080       }
    2081       catch (Exception e1)
    2082       {
    2083         throw new BaseException(
    2084           "No such directory. Please contact administrator.");
    2085       }
    2086     }
    2087     log.debug("dir = " + dir);
    2088     //
    2089     File file = factory.create(File.class);
    2090     file.setDirectory(dir);
    2091     file.setName(filenameOfUploadedFile);
    2092     if (descr != null)
    2093     {
    2094       file.setDescription(descr);
    2095     }
    2096     file.setMimeType("text/xml");
    2097     file.setFileType(fileType);
    2098     dc.saveItem(file);
    2099     //
    2100     GetMethod getMethod = null;
    2101     try
    2102     {
    2103       // Get Get method
    2104       getMethod = new GetMethod(fileURLStr);
    2105       // Get HTTP client
    2106       HttpClient httpClient = new HttpClient();
    2107       int statusCode = httpClient.executeMethod(getMethod);
    2108       // Check status code
    2109       log.debug("Response status code: " + statusCode);
    2110       if (statusCode != HttpStatus.SC_OK)
    2111       {
    2112         log.warn("Error when trying to execute GetMethod: " + getMethod
    2113           .getStatusLine());
    2114       }
    2115       // Get response
    2116       InputStream inStream = getMethod.getResponseBodyAsStream();
    2117       //
    2118       //
    2119       // inStream = new FileInputStream(mascotOutputFilePath);
    2120       file.upload(inStream, false);
    2121       dc.commit();
    2122       inStream.close();
    2123     }
    2124     catch (Exception e)
    2125     {
    2126       dc.close();
    2127       log.error(e.getMessage(), e);
    2128       throw new BaseException(e);
    2129     }
    2130     finally
    2131     {
    2132       // Release current connection to the connection pool once you are
    2133       // done
    2134       if (getMethod != null)
    2135       {
    2136         log.debug("Trying to release connection to GetMethod");
    2137         getMethod.releaseConnection();
    2138         log.debug("After trying to release connection to GetMethod");
    2139       }
    2140       else
    2141       {
    2142         log.debug("Connection to GetMethod already closed.");
    2143       }
    2144     }
    2145   }
    2146 
    2147 
    2148   /**
    2149    * Uploads output file from locally installed Mascot search engine into
    2150    * Proteios.
    2151    *
    2152    * @param directoryPath String Path to directory where output file is created
    2153    * @param outputFileName String Filename of Mascot result file
    2154    * @param filenameOfUploadedFile String Filename to use for uploaded file
    2155    * @param dirId Integer Database id of directory to put output file in
    2156    * @param descr String Output file description
    2157    * @throws BaseException
    2158    */
    2159   private void uploadMascotOutputFile(String directoryPath,
    2160       String outputFileName, String filenameOfUploadedFile,
    2161       Integer dirId, String descr)
    2162       throws BaseException
    2163   {
    2164     log.debug("directoryPath = \"" + directoryPath + "\"");
    2165     log.debug("outputFileName = \"" + outputFileName + "\"");
    2166     log.debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");
    2167     log.debug("dirId = " + dirId);
    2168     log.debug("descr = \"" + descr + "\"");
    2169     String mascotOutputFilePath = directoryPath + "/" + outputFileName;
    2170     log.debug("mascotOutputFilePath = \"" + mascotOutputFilePath + "\"");
    2171     /*
    2172      * If there is an active project the file is saved in the project
    2173      * directory, otherwise we use the users home directory.
    2174      */
    2175     DbControl dc = sc.newDbControl();
    2176     ItemFactory factory = new ItemFactory(dc);
    2177     //
    2178     Directory dir = null;
    2179     if (dirId != null && dirId > 0)
    2180     {
    2181       try
    2182       {
    2183         dir = factory.getById(Directory.class, dirId);
    2184       }
    2185       catch (Exception e1)
    2186       {
    2187         throw new BaseException(
    2188           "No such directory. Please contact administrator.");
    2189       }
    2190     }
    2191     log.debug("dir = " + dir);
    2192     //
    2193     FileType fileType = factory.getBySystemId(FileType.class,
    2194       FileType.MASCOT_XML);
    2195     //
    2196     File file = factory.create(File.class);
    2197     file.setDirectory(dir);
    2198     file.setName(filenameOfUploadedFile);
    2199     if (descr != null)
    2200     {
    2201       file.setDescription(descr);
    2202     }
    2203     file.setMimeType("text/xml");
    2204     file.setFileType(fileType);
    2205     dc.saveItem(file);
    2206     InputStream inStream = null;
    2207     try
    2208     {
    2209       inStream = new FileInputStream(mascotOutputFilePath);
    2210       file.upload(inStream, false);
    2211       dc.commit();
    2212       inStream.close();
    2213     }
    2214     catch (Exception e)
    2215     {
    2216       dc.close();
    2217       log.error(e.getMessage(), e);
    2218       throw new BaseException(e);
    2219     }
    2220   }
    22211629}
Note: See TracChangeset for help on using the changeset viewer.