- Timestamp:
- 2011-08-26T15:32:35+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/server/Server2.java
r24479 r24491 14 14 import java.net.URL; 15 15 //import java.net.URLConnection; 16 import java.util.ArrayList; 16 17 import java.util.Properties; 17 import java.util. ArrayList;18 import java.util.StringTokenizer; 18 19 19 20 import org.apache.log4j.*; … … 449 450 } 450 451 451 int index = 1; // move onto any subsequent arguments 452 453 // defaults for optional arguments 454 // if no config file is given, then it defaults to llssite.cfg (embedded in quotes to preserve spaces in the filepath) 452 //for(int i = 0; i < args.length; i++) { System.err.println("Arg[" + i + "]: |" + args[i] + "|"); } 453 454 // for every subsequent argument, check whether we're dealing with amalgamated 455 // parameters in that argument. If so, split on whitespace and reconstruct arguments 456 for(int i = 1; i < args.length; i++) { 457 458 // if the *last* occurrence of a flag parameter is not at the start of 459 // this argument then we're dealing with amalgamated parameters in this 460 // argument. Need to split on whitespace and reconstitute the args list 461 int lastIndex = args[i].lastIndexOf("--"); 462 if(lastIndex > 0) { 463 464 StringTokenizer tokenizer = new StringTokenizer(args[i]); // splits on whitespace 465 String[] tokens = new String[tokenizer.countTokens()+i]; 466 int j = 0; 467 for(; j < i; j++) { // copy over previous arguments 468 tokens[j] = args[j]; 469 } 470 471 // the remainder comes from the tokens 472 for(; tokenizer.hasMoreTokens(); j++) { 473 tokens[j] = tokenizer.nextToken(); 474 } 475 args = null; 476 args = tokens; 477 } 478 479 } 480 481 // Defaults for optional arguments 482 483 // if no config file is given, then it defaults to llssite.cfg 484 // (embedded in quotes to preserve spaces in the filepath) 455 485 File defaultConfigFile = new File(gsdl2_dir, "llssite.cfg"); 456 486 String configfile = defaultConfigFile.getAbsolutePath(); 457 487 int port = -1; 458 488 String mode = ""; 459 String lang = "en"; 460 461 // cycle through arguments, parsing and storing them 489 String lang = "en"; 490 491 int index = 1; // move onto any subsequent arguments (past 1st GSDLHOME arg) 492 if (args.length > index && !args[index].startsWith("--")) { 493 lang = args[index]; // 2nd arg is not a flag option, so must be language 494 index++; 495 } 496 497 // Cycle through arguments, parsing and storing them 498 // note that the batch file could have split arguments in the config- 499 // filepath over several parameters. Here we join them back up again. 462 500 while(args.length > index) { 463 501 … … 483 521 } 484 522 485 else if(args[index].length() == 2) { 486 // there is an optional argument, but without a --FLAGNAME= prefix, so it's a language code 487 lang = args[index]; 523 else if(!args[index].startsWith("--")) { // assume it's part of the config file name (that this path had spaces in it) 524 configfile = configfile + " " + args[index]; // reinstate space in path 488 525 } 489 526 490 527 index++; 491 528 } 492 529 530 //System.err.println("\n\n*******\n\ngsdlhome: " + gsdl2_home + " | lang: " + lang + " |configfile:" 531 // + configfile + "| mode: " + mode + " | quitport: " + port + "\n\n*************\n"); 493 532 new Server2(gsdl2_home, lang, configfile, port, mode); 494 533 }
Note:
See TracChangeset
for help on using the changeset viewer.