Changeset 2407 for trunk/gsdl/src


Ignore:
Timestamp:
2001-05-14T12:34:09+12:00 (23 years ago)
Author:
sjboddie
Message:

further changes to collector interface

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/collectoraction.cpp

    r2401 r2407  
    198198  argsinfo.addarginfo (NULL, arg_ainfo);
    199199
    200   arg_ainfo.shortname = "bc1filenum";
     200  arg_ainfo.shortname = "bc1inputnum";
    201201  arg_ainfo.longname = "collector specific";
    202202  arg_ainfo.multiplechar = true;
    203203  arg_ainfo.defaultstatus = cgiarginfo::weak;
    204   arg_ainfo.argdefault = "1";
     204  arg_ainfo.argdefault = "3";
    205205  arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
    206206  argsinfo.addarginfo (NULL, arg_ainfo);
    207207
    208   arg_ainfo.shortname = "bc1httpnum";
    209   arg_ainfo.longname = "collector specific";
    210   arg_ainfo.multiplechar = true;
    211   arg_ainfo.defaultstatus = cgiarginfo::weak;
    212   arg_ainfo.argdefault = "1";
    213   arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
    214   argsinfo.addarginfo (NULL, arg_ainfo);
    215 
    216   arg_ainfo.shortname = "bc1ftpnum";
    217   arg_ainfo.longname = "collector specific";
    218   arg_ainfo.multiplechar = true;
    219   arg_ainfo.defaultstatus = cgiarginfo::weak;
    220   arg_ainfo.argdefault = "1";
    221   arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
    222   argsinfo.addarginfo (NULL, arg_ainfo);
    223 
    224   arg_ainfo.shortname = "bc1fileinput";
     208  arg_ainfo.shortname = "bc1input";
    225209  arg_ainfo.longname = "collector specific";
    226210  arg_ainfo.multiplechar = true;
     
    231215  argsinfo.addarginfo (NULL, arg_ainfo);
    232216
    233   arg_ainfo.shortname = "bc1httpinput";
    234   arg_ainfo.longname = "collector specific";
    235   arg_ainfo.multiplechar = true;
    236   arg_ainfo.multiplevalue = true;
    237   arg_ainfo.defaultstatus = cgiarginfo::weak;
    238   arg_ainfo.argdefault = "";
    239   arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
    240   argsinfo.addarginfo (NULL, arg_ainfo);
    241 
    242   arg_ainfo.shortname = "bc1ftpinput";
     217  arg_ainfo.shortname = "bc1inputtype";
    243218  arg_ainfo.longname = "collector specific";
    244219  arg_ainfo.multiplechar = true;
     
    358333    saved_args["bc1clone"] = "";
    359334    saved_args["bc1clonecol"] = "";
    360     saved_args["bc1filenum"] = "";
    361     saved_args["bc1httpnum"] = "";
    362     saved_args["bc1ftpnum"] = "";
    363     saved_args["bc1fileinput"] = "";
    364     saved_args["bc1httpinput"] = "";
    365     saved_args["bc1ftpinput"] = "";
     335    saved_args["bc1inputnum"] = "";
     336    saved_args["bc1input"] = "";
     337    saved_args["bc1inputtype"] = "";
    366338
    367339    // update the argdb database with any arguments that were set
     
    864836}
    865837
    866 // set _filelist_, _httplist_, _ftplist_ and _badsources_ macros
     838// set _sourcelist_ and _badsources_ macros
    867839void collectoraction::set_inputsourceboxes (displayclass &disp, cgiargsclass &args,
    868840                        ostream &logout) {
     
    870842  if (badsources) disp.setmacro ("badsources", "collector", "1");
    871843
    872   int numfileboxes = args["bc1filenum"].getint();
    873   int numhttpboxes = args["bc1httpnum"].getint();
    874   int numftpboxes = args["bc1ftpnum"].getint();
    875 
    876   text_t filelist = get_source_box(args["bc1fileinput"], numfileboxes, "file");
    877   text_t httplist = get_source_box(args["bc1httpinput"], numhttpboxes, "http");
    878   text_t ftplist = get_source_box(args["bc1ftpinput"], numftpboxes, "ftp");
    879 
    880   disp.setmacro("filelist", "collector", dm_safe(filelist));
    881   disp.setmacro("httplist", "collector", dm_safe(httplist));
    882   disp.setmacro("ftplist", "collector", dm_safe(ftplist));
     844  text_t sourcelist = get_source_box(args["bc1input"], args["bc1inputnum"].getint(),
     845                     args["bc1inputtype"]);
     846
     847  disp.setmacro("sourcelist", "collector", sourcelist);
    883848
    884849  // reset badsources and failedsources variables
     
    887852}
    888853
    889 text_t collectoraction::get_source_box (text_t inputarg, int numboxes, text_t boxtype) {
    890 
    891   text_tarray files;
    892   // this relies on filenames/URLs/ftp addresses not being able to contain
     854text_t collectoraction::get_source_box (text_t inputarglist, int numboxes,
     855                    text_t inputtypelist) {
     856
     857  text_tarray inputvalues;
     858  // this relies on filenames/URLs not being able to contain
    893859  // commas
    894   splitchar (inputarg.begin(), inputarg.end(), ',', files);
    895 
    896   text_t rv = "<table border=0>\n";
     860  splitchar (inputarglist.begin(), inputarglist.end(), ',', inputvalues);
     861  // remove any empty values from the end of the array
     862  if (inputvalues.size()) {
     863    text_tarray::iterator l = inputvalues.end() - 1;
     864    text_tarray::iterator b = inputvalues.begin();
     865    while ((*l).empty() && l >= b) {
     866      l--;
     867    }
     868    inputvalues.erase(l+1, inputvalues.end());
     869  }
     870
     871  text_tarray inputtypes;
     872  splitchar (inputtypelist.begin(), inputtypelist.end(), ',', inputtypes);
     873
     874  int numvalues = inputvalues.size();
     875  int numtypes = inputtypes.size();
     876
     877  text_t last = "file://";
     878  text_t rv;
    897879  for (int i = 0; i < numboxes; i++) {
    898     rv += "<tr><td><input type=text name=\"bc1" + boxtype + "input\" value=\"";
    899     if (i < files.size()) {
    900       rv += files[i];
    901     }
    902     rv += "\" size=50></td>";
     880    rv += "<nobr><select name=\"bc1inputtype\">\n";
     881    rv += "<option value=\"file://\"";
     882    if ((i < numtypes && inputtypes[i] == "file://") ||
     883    (numboxes == 3 && i == 0 && numvalues == 0) ||
     884    (i >= 3 && i >= numvalues && last == "file://")) {
     885      rv += " selected";
     886      last = "file://";
     887    }
     888    rv += ">file://\n";
     889    rv += "<option value=\"http://\"";
     890    if ((i < numtypes && inputtypes[i] == "http://") ||
     891    (numboxes == 3 && i == 1 && numvalues == 0) ||
     892    (i >= 3 && i >= numvalues && last == "http://")) {
     893      rv += " selected";
     894      last = "http://";
     895    }
     896    rv += ">http://\n";
     897    rv += "<option value=\"ftp://\"";
     898    if ((i < numtypes && inputtypes[i] == "ftp://") ||
     899    (numboxes == 3 && i == 2 && numvalues == 0) ||
     900    (i >= 3 && i >= numvalues && last == "ftp://")) {
     901      rv += " selected";
     902      last = "ftp://";
     903    }
     904    rv += ">ftp://\n";
     905    rv += "</select>\n";
     906    rv += "<input type=text name=\"bc1input\" value=\"";
     907    if (i < numvalues) {
     908      rv += dm_safe(inputvalues[i]);
     909    }
     910    rv += "\" size=50>";
    903911    if (badsources) {
    904       if ((i < files.size()) && (!files[i].empty())) {
    905     if (failedsources[files[i]] == "1") {
    906       rv += "<td width=40>no</td>";
     912      if ((i < numvalues) && (!inputvalues[i].empty())) {
     913    if (failedsources[inputvalues[i]] == "1") {
     914      rv += "_iconcross_";
    907915    } else {
    908       rv += "<td width=40>yes</td>";
     916      rv += "_icontick_";
    909917    }
    910918      } else {
    911     rv += "<td width=40></td>";
     919    rv += "_iconblank_";
    912920      }
    913921    }
    914922    if (i+1 == numboxes) {
    915       rv += "<td><a href=\"javascript:more('" + boxtype + "')\">more</a></td></tr>\n";
     923      rv += "_imagemore_</nobr>";
    916924    } else {
    917       rv += "<td></td></tr>\n";
    918     }
    919   }
    920   rv += "</table>\n";
     925      rv += "</nobr>\n";
     926    }
     927  }
    921928 
    922929  return rv;
     
    10051012  // _gsdlhome_ - the gsdlhome path (dm_safe)
    10061013
    1007   // _filelist_ -- these three display "input source" text boxes
    1008   // _httplist_ -- for the "source data" page
    1009   // _ftplist_  --
    1010 
     1014  // _sourcelist_ -- "input source" text boxes
    10111015  // _badsources_ -- will be set to "1" if we've come from the
    10121016  //                 "source data" page and there's a problem
     
    16361640  }
    16371641
    1638   text_tarray files;
    1639   text_t filevals = args["bc1fileinput"];
    1640   // this relies on filenames not being able to contain commas
    1641   splitchar (filevals.begin(), filevals.end(), ',', files);
    1642   text_tarray::const_iterator here = files.begin();
    1643   text_tarray::const_iterator end = files.end();
    1644   while (here != end) {
    1645     options += " -download \"" + *here + "\"";
    1646     here ++;
    1647   }
    1648   text_tarray https;
    1649   text_t httpvals = args["bc1httpinput"];
    1650   // this relies on URLs not being able to contain commas
    1651   splitchar (httpvals.begin(), httpvals.end(), ',', https);
    1652   here = https.begin();
    1653   end = https.end();
    1654   while (here != end) {
    1655     options += " -download \"" + *here + "\"";
    1656     here ++;
    1657   }
    1658   text_tarray ftps;
    1659   text_t ftpvals = args["bc1ftpinput"];
    1660   // this relies on ftp addresses not being able to contain commas
    1661   splitchar (ftpvals.begin(), ftpvals.end(), ',', ftps);
    1662   here = ftps.begin();
    1663   end = ftps.end();
    1664   while (here != end) {
    1665     options += " -download \"" + *here + "\"";
    1666     here ++;
     1642  text_tarray inputvalues, inputtypes;
     1643  // this relies on filenames/URLs not being able to contain commas
     1644  splitchar (args["bc1input"].begin(), args["bc1input"].end(), ',', inputvalues);
     1645  splitchar (args["bc1inputtype"].begin(), args["bc1inputtype"].end(), ',', inputtypes);
     1646  int numvalues = inputvalues.size();
     1647  int numtypes = inputtypes.size();
     1648  for (int i = 0; i < numvalues; i++) {
     1649    if (!inputvalues[i].empty()) {
     1650      text_t type = "file://"; // default
     1651      if (i < numtypes) type = inputtypes[i];
     1652      options += " -download \"" + type + format_url(inputvalues[i]) + "\"";
     1653    }
    16671654  }
    16681655
     
    18631850  bool found = false;
    18641851
    1865   // check local filesystem for file:// sources
    1866   text_tarray files;
    1867   text_t filevals = args["bc1fileinput"];
    1868   // this relies on filenames not being able to contain commas
    1869   splitchar (filevals.begin(), filevals.end(), ',', files);
    1870   text_tarray::const_iterator here = files.begin();
    1871   text_tarray::const_iterator end = files.end();
    1872   while (here != end) {
    1873     text_t file = format_url(*here);
    1874     if (!file_exists(file) && !directory_exists(file)) {
    1875       failedsources[*here] = "1";
    1876       badsources = true;
    1877     }
    1878     found = true;
    1879     here ++;
    1880   }
    1881 
    1882   // ping http:// sources
    1883   files.erase(files.begin(), files.end());
    1884   text_t httpvals = args["bc1httpinput"];
    1885   // this relies on URLs not being able to contain commas
    1886   splitchar (httpvals.begin(), httpvals.end(), ',', files);
    1887   here = files.begin();
    1888   end = files.end();
    1889   while (here != end) {
    1890     if (gsdl_system ("perl -S ping.pl -quiet http://" + format_url(*here), true, logout)) {
    1891       failedsources[*here] = "1";
    1892       badsources = true;
    1893     }
    1894     found = true;
    1895     here++;
    1896   }
    1897 
    1898   // ping ftp:// sources
    1899   files.erase(files.begin(), files.end());
    1900   text_t ftpvals = args["bc1ftpinput"];
    1901   // this relies on FTP addresses not being able to contain commas
    1902   splitchar (ftpvals.begin(), ftpvals.end(), ',', files);
    1903   here = files.begin();
    1904   end = files.end();
    1905   while (here != end) {
    1906     if (gsdl_system ("perl -S ping.pl -quiet ftp://" + format_url(*here), true, logout)) {
    1907       failedsources[*here] = "1";
    1908       badsources = true;
    1909     }
    1910     found = true;
    1911     here++;
     1852  text_tarray inputvalues;
     1853  // this relies on filenames/URLs not being able to contain
     1854  // commas
     1855  splitchar (args["bc1input"].begin(), args["bc1input"].end(), ',', inputvalues);
     1856
     1857  text_tarray inputtypes;
     1858  splitchar (args["bc1inputtype"].begin(), args["bc1inputtype"].end(), ',', inputtypes);
     1859
     1860  int numvalues = inputvalues.size();
     1861  int numtypes = inputtypes.size();
     1862
     1863  for (int i = 0; i < numvalues; i++) {
     1864    text_t value = format_url(inputvalues[i]);
     1865    text_t type = "file://"; // default
     1866    if (!value.empty()) {
     1867      found = true;
     1868      if (i >= numtypes || inputtypes[i].empty()) {
     1869    logout << "collectoraction::check_sources: WARNING type not set\n";
     1870      } else {
     1871    type = inputtypes[i];
     1872      }
     1873      if (type == "file://") {
     1874    if (!file_exists(value) && !directory_exists(value)) {
     1875      failedsources[inputvalues[i]] = "1";
     1876      badsources = true;
     1877    }
     1878      } else if (type == "http://") {
     1879    if (gsdl_system ("perl -S ping.pl -quiet http://" + value, true, logout)) {
     1880      failedsources[inputvalues[i]] = "1";
     1881      badsources = true;
     1882    }
     1883      } else if (type == "ftp://") {
     1884    if (gsdl_system ("perl -S ping.pl -quiet ftp://" + value, true, logout)) {
     1885      failedsources[inputvalues[i]] = "1";
     1886      badsources = true;
     1887    }
     1888      }
     1889    }
    19121890  }
    19131891
  • trunk/gsdl/src/recpt/collectoraction.h

    r2401 r2407  
    5757                 ostream &logout);
    5858
    59   text_t get_source_box (text_t inputarg, int numboxes, text_t boxtype);
     59  text_t get_source_box (text_t inputarglist, int numboxes,
     60             text_t inputtypelist);
    6061
    6162  void set_cfgfile (displayclass &disp, cgiargsclass &args, ostream &logout);
Note: See TracChangeset for help on using the changeset viewer.