Changeset 24883
- Timestamp:
- 2011-12-13T09:53:03+13:00 (11 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/CollectionConstructor.java
r5148 r24883 1 1 package org.greenstone.gsdl3.build; 2 3 import java.io.File; 2 4 3 5 import org.greenstone.gsdl3.util.*; … … 12 14 /** the site in which building is to take place */ 13 15 protected String site_home = null; 16 /** the name of the site*/ 17 protected String site_name = null; 14 18 /** the name of the collection */ 15 19 protected String collection_name = null; … … 42 46 public void setSiteHome(String site_home) { 43 47 this.site_home = site_home; 48 49 File siteHomeFile = new File(site_home); 50 this.site_name = siteHomeFile.getName(); 44 51 } 45 52 public void setCollectionName(String coll_name) { -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
r24816 r24883 3 3 // greenstome classes 4 4 import org.greenstone.gsdl3.util.*; 5 import org.greenstone.util.GlobalProperties; 5 6 6 7 // xml classes … … 10 11 //general java classes 11 12 import java.io.BufferedReader; 13 import java.io.BufferedWriter; 14 import java.io.FileWriter; 12 15 import java.io.InputStreamReader; 13 16 import java.io.File; 17 import java.util.ArrayList; 14 18 import java.util.Vector; 15 19 … … 47 51 { 48 52 // try to get the environment variables 49 this.gsdl2home = System.getProperty("GSDLHOME"); 50 this.gsdl3home = System.getProperty("GSDL3HOME"); 51 this.gsdlos = System.getProperty("GSDLOS"); 52 this.path = System.getProperty("PATH"); 53 this.gsdl3home = GlobalProperties.getGSDL3Home(); 54 this.gsdl2home = this.gsdl3home + File.separator + ".." + File.separator + "gs2build"; 55 this.gsdlos = System.getProperty("os.name").startsWith("Windows") ? "Windows" : "Linux"; 56 this.path = System.getenv("PATH"); 57 53 58 if (this.gsdl2home == null) 54 59 { 55 System.err.println("You must have g reenstone2installed, and GSDLHOME set for GS2Perl building to work!!");60 System.err.println("You must have gs2build installed, and GSDLHOME set for GS2Perl building to work!!"); 56 61 return false; 57 62 } … … 162 167 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "Collection construction: build collection.")); 163 168 Vector command = new Vector(); 164 command.add("buildcol.pl"); 169 command.add(GlobalProperties.getProperty("perl.path", "perl")); 170 command.add("-S"); 171 command.add(GlobalProperties.getGS2Build() + File.separator + "bin" + File.separator + "script" + File.separator + "buildcol.pl"); 172 command.add("-site"); 173 command.add(this.site_name); 165 174 command.add("-collectdir"); 166 175 command.add(GSFile.collectDir(this.site_home)); 167 176 command.addAll(extractParameters(this.process_params)); 168 177 command.add(this.collection_name); 178 169 179 String[] command_str = {}; 170 180 command_str = (String[]) command.toArray(command_str); … … 175 185 sendProcessComplete(new ConstructionEvent(this, GSStatus.COMPLETED, "")); 176 186 }// else an error message has already been sent, do nothing 177 //178 179 187 } 180 188 … … 196 204 { 197 205 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "deleting index directory")); 198 index_dir.delete();206 GSFile.deleteFile(index_dir); 199 207 if (index_dir.exists()) 200 208 { 201 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "index directory still exists!")); 209 sendMessage(new ConstructionEvent(this, GSStatus.ERROR, "index directory still exists!")); 210 return; 202 211 } 203 212 } … … 207 216 { 208 217 sendMessage(new ConstructionEvent(this, GSStatus.ERROR, "index dir wasn't created!")); 209 }210 211 // run the convert coll script to convert the gs2 coll to gs3212 Vector command = new Vector();213 command.add("convert_coll_from_gs2.pl");214 command.add("-collectdir");215 command.add(GSFile.collectDir(this.site_home));216 command.addAll(extractParameters(this.process_params));217 command.add(this.collection_name);218 String[] command_str = {};219 command_str = (String[]) command.toArray(command_str);220 221 if (!runPerlCommand(command_str))222 {223 // an error has occurred, dont carry on224 return;225 218 } 226 219 … … 264 257 ConstructionEvent evt; 265 258 266 String args[] = { "GSDLHOME=" + this.gsdl2home, "GSDL3HOME=" + this.gsdl3home, "GSDLOS=" + this.gsdlos, "PATH=" + this.path }; 259 ArrayList<String> args = new ArrayList<String>(); 260 args.add("GSDLHOME=" + this.gsdl2home); 261 args.add("GSDL3HOME=" + this.gsdl3home); 262 args.add("GSDLOS=" + this.gsdlos); 263 args.add("GSDL-RUN-SETUP=true"); 264 265 for (String a : System.getenv().keySet()) 266 { 267 args.add(a + "=" + System.getenv(a)); 268 } 269 267 270 String command_str = ""; 268 271 for (int i = 0; i < command.length; i++) … … 270 273 command_str = command_str + command[i] + " "; 271 274 } 275 272 276 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "command = " + command_str)); 273 277 try … … 275 279 Runtime rt = Runtime.getRuntime(); 276 280 sendProcessBegun(new ConstructionEvent(this, GSStatus.ACCEPTED, "starting")); 277 Process prcs = rt.exec(command, args );281 Process prcs = rt.exec(command, args.toArray(new String[args.size()])); 278 282 279 283 InputStreamReader eisr = new InputStreamReader(prcs.getErrorStream()); … … 283 287 // Captures the std err of a program and pipes it into 284 288 // std in of java 289 290 BufferedWriter bw = new BufferedWriter(new FileWriter(GSFile.collectDir(this.site_home) + File.separator + this.collection_name + File.separator + "log" + File.separator + "build_log." + (System.currentTimeMillis()) + ".txt")); 291 bw.write("Document Editor Build\n"); 292 285 293 String eline = null; 286 294 String stdinline = null; … … 289 297 if (eline != null) 290 298 { 299 //System.err.println("ERROR: " + eline); 300 bw.write(eline + "\n"); 291 301 sendProcessStatus(new ConstructionEvent(this, GSStatus.CONTINUING, eline)); 292 302 } 293 303 if (stdinline != null) 294 304 { 305 //System.err.println("OUT: " + stdinline); 306 bw.write(stdinline + "\n"); 295 307 sendProcessStatus(new ConstructionEvent(this, GSStatus.CONTINUING, stdinline)); 296 308 } 297 309 } 310 bw.close(); 311 298 312 if (!this.cancel) 299 313 {
Note:
See TracChangeset
for help on using the changeset viewer.