Changeset 29869 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
- Timestamp:
- 2015-05-12T21:47:35+12:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
r29576 r29869 33 33 public static final int BUILD = 2; 34 34 public static final int ACTIVATE = 3; 35 public static final int SET_METADATA_SERVER = 4; 35 36 36 37 /** … … 118 119 case ACTIVATE: 119 120 activateCollection(); 121 break; 122 case SET_METADATA_SERVER: 123 setMetadataForCollection(); 120 124 break; 121 125 default: … … 202 206 command.add("-collectdir"); 203 207 command.add(GSFile.collectDir(this.site_home)); 208 command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly 204 209 command.addAll(extractParameters(this.process_params)); 205 210 command.add(this.collection_name); … … 272 277 command.add("-collectdir"); 273 278 command.add(GSFile.collectDir(this.site_home)); 279 command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly 274 280 command.addAll(extractParameters(this.process_params)); 275 281 command.add(this.collection_name); … … 279 285 280 286 if (runPerlCommand(command_str)) 287 { 288 // success!! - need to send the final completed message 289 sendProcessComplete(new ConstructionEvent(this, GSStatus.COMPLETED, "")); 290 }// else an error message has already been sent, do nothing 291 292 } 293 294 295 protected void setMetadataForCollection() 296 { 297 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "Collection metadata: setMetadata for collection.")); 298 299 Vector<String> command = new Vector<String>(); 300 301 String perlPath = GlobalProperties.getProperty("perl.path", "perl"); 302 if (perlPath.charAt(perlPath.length() - 1) != File.separatorChar) 303 { 304 perlPath = perlPath + File.separator; 305 } 306 307 String cgi_directory = GlobalProperties.getGSDL3Home() + File.separator + "WEB-INF" + File.separator + "cgi"; 308 command.add(perlPath + "perl"); 309 command.add("-S"); 310 //command.add(GlobalProperties.getGSDL3Home() + File.separator + "WEB-INF" + File.separator + "cgi" + File.separator + "metadata-server.pl"); 311 command.add(cgi_directory + File.separator + "metadata-server.pl"); 312 313 // Need to set QUERY_STRING and REQUEST_METHOD=GET in environment 314 // http://www.cgi101.com/class/ch3/text.html 315 String[] envvars = { 316 "QUERY_STRING=" + this.query_string, 317 "REQUEST_METHOD=GET" 318 }; 319 320 String[] command_str = {}; 321 command_str = command.toArray(command_str); 322 323 // http://www.cgi101.com/class/ch3/text.html 324 // setenv QUERY_STRING and REQUEST_METHOD = GET. 325 if (runPerlCommand(command_str, envvars, new File(cgi_directory))) 326 //new File(GlobalProperties.getGSDL3Home() + File.separator + "WEB-INF" + File.separator + "cgi"))) 281 327 { 282 328 // success!! - need to send the final completed message … … 316 362 317 363 /** returns true if completed correctly, false otherwise */ 318 protected boolean runPerlCommand(String[] command) 364 protected boolean runPerlCommand(String[] command) { 365 return runPerlCommand(command, null, null); 366 } 367 368 protected boolean runPerlCommand(String[] command, String[] envvars, File dir) 319 369 { 320 370 int sepIndex = this.gsdl3home.lastIndexOf(File.separator); … … 329 379 args.add("PERL_PERTURB_KEYS=0"); 330 380 381 if(envvars != null) { 382 for(int i = 0; i < envvars.length; i++) { 383 args.add(envvars[i]); 384 } 385 } 386 331 387 for (String a : System.getenv().keySet()) 332 388 { … … 345 401 Runtime rt = Runtime.getRuntime(); 346 402 sendProcessBegun(new ConstructionEvent(this, GSStatus.ACCEPTED, "starting")); 347 Process prcs = rt.exec(command, args.toArray(new String[args.size()])); 403 Process prcs = (dir == null) 404 ? rt.exec(command, args.toArray(new String[args.size()])) 405 : rt.exec(command, args.toArray(new String[args.size()]), dir); 348 406 349 407 InputStreamReader eisr = new InputStreamReader(prcs.getErrorStream());
Note:
See TracChangeset
for help on using the changeset viewer.