Changeset 18358 for gli/branches/rtl-gli/src/org/greenstone/gatherer/collection/CollectionManager.java
- Timestamp:
- 2009-01-12T11:18:22+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/branches/rtl-gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r14358 r18358 76 76 import org.w3c.dom.*; 77 77 78 /** This class manages many aspects of the collection, from its creation via scripts, data access via methods and its importing and building into the final collection. It is also respo sible for firing appropriate event when significant changes have occured within the collection, and for creating a new metadata set manager as necessary.78 /** This class manages many aspects of the collection, from its creation via scripts, data access via methods and its importing and building into the final collection. It is also responsible for firing appropriate event when significant changes have occured within the collection, and for creating a new metadata set manager as necessary. 79 79 * @author John Thompson 80 80 * @version 2.3 … … 87 87 /** Are we currently in the process of importing? */ 88 88 static private boolean importing = false; 89 /** Are we currently in the process of scheduling? */ 90 static private boolean scheduling = false; 89 91 /** The objects listening for CollectionContentsChanged events. */ 90 92 static private ArrayList collection_contents_changed_listeners = new ArrayList(); … … 97 99 /** An inner class listener responsible for noting tree changes and resetting saved when they occur. */ 98 100 static private FMTreeModelListener fm_tree_model_listener = null; 99 /** The monitor respo sible for parsing the build process. */101 /** The monitor responsible for parsing the build process. */ 100 102 static private GShellProgressMonitor build_monitor = null; 101 /** The monitor respo sible for parsing the import process. */103 /** The monitor responsible for parsing the import process. */ 102 104 static private GShellProgressMonitor import_monitor = null; 105 /** The monitor responsible for parsing the scheduler process. */ 106 static private GShellProgressMonitor schedule_monitor = null; 103 107 104 108 /** The name of the standard lock file. */ … … 109 113 /** Used to indicate the source of the message is the building methods. */ 110 114 static final public int BUILDING = 5; 115 /** Used to indicate the source of the message is in the scheduling methods...? */ 116 static final public int SCHEDULING = 7; 111 117 112 118 … … 116 122 this.building = false; 117 123 this.importing = false; 124 this.scheduling = false; 118 125 this.collection = null; 119 126 … … 159 166 command_parts_list.add("-S"); 160 167 } 161 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl"); 168 169 if (Configuration.fedora_info.isActive()) { 170 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "g2f-buildcol.pl"); 171 172 command_parts_list.add("-hostname"); 173 command_parts_list.add(Configuration.fedora_info.getHostname()); 174 175 command_parts_list.add("-port"); 176 command_parts_list.add(Configuration.fedora_info.getPort()); 177 178 command_parts_list.add("-username"); 179 command_parts_list.add(Configuration.fedora_info.getUsername()); 180 181 command_parts_list.add("-password"); 182 command_parts_list.add(Configuration.fedora_info.getPassword()); 183 184 command_parts_list.add("-protocol"); 185 command_parts_list.add(Configuration.fedora_info.getProtocol()); 186 187 } 188 else { 189 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl"); 190 } 162 191 command_parts_list.add("-gli"); 163 192 command_parts_list.add("-language"); … … 187 216 } 188 217 218 /*probably repeating alot of work, but I want to keep this separate... wendy*/ 219 public void scheduleBuild(boolean incremental_build) 220 { 221 222 DebugStream.println("In CollectionManager.scheduleBuild(), incremental_build: " + incremental_build); 223 DebugStream.println("Is event dispatch threa: " + SwingUtilities.isEventDispatchThread()); 224 225 ArrayList sched_list = new ArrayList(); 226 if ((Utility.isWindows()) && (!Gatherer.isGsdlRemote)) { 227 sched_list.add(Configuration.perl_path); 228 sched_list.add("-S"); 229 } 230 sched_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "schedule.pl"); 231 sched_list.add("-colname"); 232 sched_list.add(collection.getName()); 233 sched_list.add("-gli"); 234 235 // First, generate the import.pl command, also converting to a string 236 // Generate the import.pl command 237 ArrayList import_list = new ArrayList(); 238 if ((Utility.isWindows()) && (!Gatherer.isGsdlRemote)) { 239 import_list.add(Configuration.perl_path); 240 import_list.add("-S"); 241 } 242 import_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl"); 243 import_list.add("-language"); 244 import_list.add(Configuration.getLanguage()); 245 import_list.add("-collectdir"); 246 import_list.add(getCollectDirectory()); 247 248 String[] import_options = collection.import_options.getValues(); 249 int i = 0; 250 for (i = 0; i < import_options.length; i++) { 251 import_list.add(import_options[i]); 252 } 253 254 import_list.add(collection.getName()); 255 256 String[] import_parts = (String[]) import_list.toArray(new String[0]); 257 String command = ""; 258 i = 0; 259 for (i = 0; i < import_parts.length-1; i++) { 260 command = command + import_parts[i] + " "; 261 } 262 command = command + import_parts[i]; 263 264 sched_list.add("-import"); 265 sched_list.add("\"" + command + "\""); 266 267 // Generate the buildcol.pl command, also converting to a string 268 ArrayList build_list = new ArrayList(); 269 270 // i'm not doing this in schedule.pl right now - should i be? 271 if ((Utility.isWindows()) && (!Gatherer.isGsdlRemote)) { 272 build_list.add(Configuration.perl_path); 273 build_list.add("-S"); 274 } 275 build_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl"); 276 build_list.add("-language"); 277 build_list.add(Configuration.getLanguage()); 278 build_list.add("-collectdir"); 279 build_list.add(getCollectDirectory()); 280 281 // If the user hasn't manually specified "-keepold" or "-removeold" then pick one based on incremental_build 282 if (!collection.build_options.getValueEnabled("keepold") && !collection.build_options.getValueEnabled("removeold")) { 283 build_list.add(incremental_build ? "-keepold" : "-removeold"); 284 } 285 286 String[] build_options = collection.build_options.getValues(); 287 for (i = 0; i < build_options.length; i++) { 288 build_list.add(build_options[i]); 289 } 290 291 build_list.add(collection.getName()); 292 293 //build actual string 294 String[] build_parts = (String[]) build_list.toArray(new String[0]); 295 String command2 = ""; 296 for(i = 0; i < build_parts.length-1; i++) { 297 command2 = command2 + build_parts[i] + " "; 298 } 299 command2 = command2 + build_parts[i]; 300 301 sched_list.add("-build"); 302 sched_list.add("\"" + command2 + "\""); 303 304 //next, the scheduling frequency goes here 305 String[] schedule_options = collection.schedule_options.getValues(); 306 for(i = 0; i < schedule_options.length; i++) { 307 sched_list.add(schedule_options[i]); 308 } 309 310 //now, hope it will run. ;) 311 String[] sched_parts = (String[]) sched_list.toArray(new String[0]); 312 313 GShell shell = new GShell(sched_parts, GShell.SCHEDULE, SCHEDULING, this, schedule_monitor, GShell.GSHELL_SCHEDULE); 314 shell.addGShellListener(Gatherer.g_man.create_pane); 315 shell.addGShellListener(Gatherer.g_man.format_pane); 316 shell.start(); 317 } 189 318 190 319 /** Used to determine whether the currently active collection has been built. … … 193 322 public boolean built() { 194 323 if(collection != null) { 195 // Determine if the collection has been built by looking for the build.cfg or buildConfig.xml file 196 String file_name = (Gatherer.GS3)? Utility.BUILD_CONFIG_XML : Utility.BUILD_CFG; 197 File build_cfg_file = new File(getLoadedCollectionIndexDirectoryPath() + file_name); 198 return build_cfg_file.exists(); 324 // Determine if the collection has been built by looking for the build.cfg (gs2) 325 // buildConfig.xml (gs3) or export.inf (fedora) file 326 String file_name = ""; 327 328 if (Configuration.fedora_info.isActive()) { // FLI case 329 // Fedora build 330 //file_name = getLoadedCollectionArchivesDirectoryPath() + "import.inf"; 331 file_name = getLoadedCollectionExportDirectoryPath() + "export.inf"; 332 } else { 333 // GLI is running, check if it's greenstone 3 or greenstone 2 334 if (Gatherer.GS3) { // GS3 GLI 335 file_name = getLoadedCollectionIndexDirectoryPath() + Utility.BUILD_CONFIG_XML; 336 } 337 else { // greenstone 2 GLI 338 file_name = getLoadedCollectionIndexDirectoryPath() + Utility.BUILD_CFG; 339 } 340 } 341 File test_file = new File(file_name); 342 return test_file.exists(); 199 343 } 200 344 return false; … … 235 379 // Remove the lock file on the server 236 380 if (Gatherer.isGsdlRemote) { 237 RemoteGreenstoneServer.deleteCollectionFile(collection.getName(), lock_file);381 Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getName(), lock_file); 238 382 } 239 383 … … 380 524 if (!new File(collection_directory_path).exists()) { 381 525 // If there is no collection directory then the creation was unsuccessful, or cancelled 382 526 383 527 return; 384 528 } … … 403 547 collection_import_directory.mkdirs(); 404 548 if (Gatherer.isGsdlRemote) { 405 RemoteGreenstoneServer.newCollectionDirectory(name, collection_import_directory);549 Gatherer.remoteGreenstoneServer.newCollectionDirectory(name, collection_import_directory); 406 550 } 407 551 } … … 413 557 collection.import_options.setValue("removeold", true, null); 414 558 559 // for remote case, scheduling causes an Exception on creating a new collection that 560 // can't be recovered from. For GS3, it doesn't work since it it trying to access etc/main.cfg 561 if (canDoScheduling()) { 562 scheduling(); 563 } 564 415 565 MetadataSetManager.clearMetadataSets(); 416 566 MetadataXMLFileManager.clearMetadataXMLFiles(); … … 431 581 if (Gatherer.isGsdlRemote) { 432 582 String base_collection_name = base_collection_directory.getName(); 433 RemoteGreenstoneServer.downloadCollection(base_collection_name);583 Gatherer.remoteGreenstoneServer.downloadCollection(base_collection_name); 434 584 } 435 585 … … 513 663 DebugStream.printStackTrace(error); 514 664 } 665 } 666 667 private void scheduling() 668 throws Exception 669 { 670 //try to obtain email address of collection owner if it exists... 671 String stmp = Configuration.getEmail(); 672 if(stmp != null) { 673 collection.schedule_options.setValue("toaddr", false, Configuration.getEmail()); 674 } 675 676 //The next few items deal with updating the SMTP server, and the to: and from: addresses 677 //from main.cfg and the collection configuration. if no changes are made, or the 678 //values are result to NULL, any existing values are kept. 679 680 //try to obtain email address of Greenstone installation webmaster for - used to indicate "sender". 681 File mcfg = new File(LocalGreenstone.getDirectoryPath() + File.separator + "etc" + File.separator + "main.cfg"); 682 BufferedReader maincfg = new BufferedReader(new FileReader(mcfg)); 683 stmp = ""; 684 String fromaddr = ""; 685 while((stmp = maincfg.readLine()) != null) { 686 if(stmp.startsWith("maintainer")) { 687 fromaddr = stmp.substring(10); //length of MailServer 688 fromaddr = fromaddr.trim(); 689 break; 690 } 691 } 692 maincfg.close(); 693 if(!fromaddr.equals("NULL") && !fromaddr.equals("null")) { 694 collection.schedule_options.setValue("fromaddr", false, fromaddr); 695 } 696 697 //try to obtain an smtp server address from main.cfg. If that fails, 698 //try mail.server if an email address exists. If that fails, 699 //maybe a message to set attribute in main.cfg? 700 //i'm pretty sure there exists functionality to do this, but 701 //i'll finish this faster if I just wrote it 702 703 704 maincfg = new BufferedReader(new FileReader(mcfg)); 705 String smtptmp = "NULL"; 706 while((stmp = maincfg.readLine()) != null) { 707 if(stmp.startsWith("MailServer")) { 708 smtptmp = stmp.substring(10); //length of MailServer 709 smtptmp = smtptmp.trim(); 710 break; 711 } 712 } 713 maincfg.close(); 714 715 //try if lookup fails 716 if(smtptmp.equals("NULL") || smtptmp.equals("null")) { 717 String email2=fromaddr; 718 if(!email2.equals("NULL") && !email2.equals("null")) { 719 int loc = email2.indexOf('@'); 720 email2 = email2.substring(loc+1); 721 smtptmp = "mail."+email2; 722 } 723 } 724 if(!smtptmp.equals("NULL") && !smtptmp.equals("null")) { 725 collection.schedule_options.setValue("smtp", false, smtptmp); 726 } 727 515 728 } 516 729 … … 552 765 // Delete the collection on the server if we're using a remote Greenstone 553 766 if (Gatherer.isGsdlRemote) { 554 RemoteGreenstoneServer.deleteCollection(collection_name); 555 } 556 767 Gatherer.remoteGreenstoneServer.deleteCollection(collection_name); 768 } 769 770 // if Greenstone3, need to deactivate the collection on the server 771 if (Gatherer.GS3) { 772 Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.DEACTIVATE_COMMAND + collection_name); 773 } 774 557 775 // Now delete the collection directory 558 776 return Utility.delete(new File(getCollectionDirectoryPath(collection_name))); … … 591 809 return getLoadedCollectionDirectoryPath() + "archives" + File.separator; 592 810 } 811 812 /** Returns the absolute filename of the loaded collection's export directory. 813 */ 814 static public String getLoadedCollectionExportDirectoryPath() 815 { 816 return getLoadedCollectionDirectoryPath() + "export" + File.separator; 817 } 818 593 819 594 820 … … 764 990 command_parts_list.add("-S"); 765 991 } 766 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl"); 992 993 if (Configuration.fedora_info.isActive()) { 994 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "g2f-import.pl"); 995 996 command_parts_list.add("-hostname"); 997 command_parts_list.add(Configuration.fedora_info.getHostname()); 998 999 command_parts_list.add("-port"); 1000 command_parts_list.add(Configuration.fedora_info.getPort()); 1001 1002 command_parts_list.add("-username"); 1003 command_parts_list.add(Configuration.fedora_info.getUsername()); 1004 1005 command_parts_list.add("-password"); 1006 command_parts_list.add(Configuration.fedora_info.getPassword()); 1007 1008 command_parts_list.add("-protocol"); 1009 command_parts_list.add(Configuration.fedora_info.getProtocol()); 1010 } 1011 else { 1012 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl"); 1013 } 1014 767 1015 command_parts_list.add("-gli"); 768 1016 command_parts_list.add("-language"); … … 808 1056 // If we're using a remote Greenstone server, upload the metadata file 809 1057 if (Gatherer.isGsdlRemote) { 810 RemoteGreenstoneServer.uploadCollectionFile(collection.getName(), metadata_set_file);1058 Gatherer.remoteGreenstoneServer.uploadCollectionFile(collection.getName(), metadata_set_file); 811 1059 } 812 1060 } … … 874 1122 if (Gatherer.isGsdlRemote) { 875 1123 String collection_name = location.substring(location.lastIndexOf(File.separator) + 1, location.length() - ".col".length()); 876 if ( RemoteGreenstoneServer.downloadCollection(collection_name).equals("")) {1124 if (Gatherer.remoteGreenstoneServer.downloadCollection(collection_name).equals("")) { 877 1125 return; 878 1126 } … … 959 1207 System.err.println("Cannot write lock file!"); 960 1208 String args[] = new String[2]; 961 args[0] = location; 962 args[1] = Dictionary.get("FileActions.Write_Not_Permitted_Title"); 1209 args[0] = location; 1210 args[1] = Dictionary.get("FileActions.Write_Not_Permitted_Message", new String[]{lock_file.getAbsolutePath()}); 1211 if(Gatherer.client_operating_system.toUpperCase().indexOf("WINDOWS")!=-1){ 1212 //if(Gatherer.client_operating_system.toUpperCase().indexOf("VISTA")!=-1){ 1213 args[1] += Dictionary.get("FileActions.File_Permission_Detail", new String[]{Configuration.gsdl_path, System.getProperty("user.name")}); 1214 //} 1215 } 963 1216 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Open_With_Reason", args), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 964 1217 args = null; 965 1218 return; 966 1219 } 967 1220 1221 if (canDoScheduling()) { 1222 //THIS LOOKS LIKE THE BEST PLACE TO TRY AND UPDATE .col FILES FOR EXISTING COLLECTIONS...Wendy 1223 1224 //First, see if "Schedule" exists in the XMl File... 1225 BufferedReader bir = new BufferedReader(new FileReader(collection_file)); 1226 boolean flag = false; 1227 try { 1228 String stmp = new String(); 1229 1230 while((stmp = bir.readLine()) != null) { 1231 stmp = stmp.trim(); 1232 if(stmp.equals("<Schedule>") || stmp.equals("<Schedule/>")) { 1233 flag = true; 1234 break; 1235 } 1236 } 1237 bir.close(); 1238 1239 } catch (IOException ioe) { 1240 DebugStream.printStackTrace(ioe); 1241 } 1242 1243 //modify if old .col (i.e. no Schedule exists in XML file) 1244 if(!flag) { 1245 File new_collection_file = new File(collection_directory.getAbsolutePath() + "/tmp.col"); 1246 1247 1248 BufferedWriter bor = new BufferedWriter(new FileWriter(new_collection_file)); 1249 bir = new BufferedReader(new FileReader(collection_file)); 1250 1251 try { 1252 String stmp = new String(); 1253 while((stmp = bir.readLine()) != null) { 1254 String stmp2 = stmp.trim(); 1255 if(stmp2.startsWith("<!ELEMENT Argument")) { 1256 bor.write(" <!ELEMENT Schedule (Arguments*)>\n"); 1257 } 1258 else if(stmp2.equals("</BuildConfig>")) { 1259 bor.write(" <Schedule/>\n"); 1260 } 1261 1262 bor.write(stmp + "\n"); 1263 1264 } 1265 bir.close(); 1266 bor.close(); 1267 } catch (IOException ioe) { 1268 DebugStream.printStackTrace(ioe); 1269 } 1270 1271 //copy over tmp.col to replace 1272 try { 1273 collection_file.delete(); 1274 new_collection_file.renameTo(collection_file); 1275 } catch (Exception e) { 1276 DebugStream.printStackTrace(e); 1277 } 1278 } 1279 } 1280 968 1281 // Open the collection file 969 1282 this.collection = new Collection(collection_file); … … 976 1289 throw(new Exception(Dictionary.get("CollectionManager.Missing_Config"))); // this error message does not agree with the error 977 1290 } 978 1291 1292 if (canDoScheduling()) { 1293 scheduling(); 1294 } 1295 979 1296 MetadataSetManager.clearMetadataSets(); 980 1297 MetadataSetManager.loadMetadataSets(collection_metadata_directory); … … 997 1314 MetadataXMLFileManager.loadMetadataXMLFiles(collection_import_directory,collection.toSkimFile()); 998 1315 999 // Read through the doc.xml files in the archives directory1000 File collection_archives_directory = new File(getLoadedCollectionArchivesDirectoryPath());1316 1317 // get rid of the previous scan through docxml files 1001 1318 DocXMLFileManager.clearDocXMLFiles(); 1002 DocXMLFileManager.loadDocXMLFiles(collection_archives_directory); 1319 1320 if (Configuration.fedora_info.isActive()) { // FLI case 1321 // Read through the docmets.xml files in the export directory 1322 File collection_export_directory = new File(getLoadedCollectionExportDirectoryPath()); 1323 DocXMLFileManager.loadDocXMLFiles(collection_export_directory,"docmets.xml"); 1324 } 1325 else { 1326 // Read through the doc.xml files in the archives directory 1327 File collection_archives_directory = new File(getLoadedCollectionArchivesDirectoryPath()); 1328 DocXMLFileManager.loadDocXMLFiles(collection_archives_directory,"doc.xml"); 1329 } 1330 1003 1331 1004 1332 // Get a list of the collection specific classifiers and plugins … … 1019 1347 // There is obviously no existing collection present. 1020 1348 DebugStream.printStackTrace(error); 1349 error.printStackTrace(); 1021 1350 if(error.getMessage() != null) { 1022 1351 String[] args = new String[2]; 1023 args[0] = location; 1024 args[1] = error.getMessage(); 1352 args[0] = location; 1353 //args[1] = error.getMessage(); 1354 args[1] = "The Librarian Interface does not have permission to write to... Please check file permissions."; 1025 1355 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Open_With_Reason", args), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1026 1356 } … … 1035 1365 } 1036 1366 1367 /** At present, scheduling only works for GS2, only when GS2 is local and only when GLI runs from 1368 * within a GS2 installation. This method can be adjusted as scheduling becomes available for more 1369 * more situations. */ 1370 public static boolean canDoScheduling() { 1371 // Would be nice to support more of these, rather than returning false 1372 if(Gatherer.isGsdlRemote) { 1373 return false; 1374 } 1375 if(Gatherer.GS3) { 1376 return false; 1377 } 1378 if (Configuration.fedora_info.isActive()) { 1379 return false; 1380 } 1381 1382 // GS2's etc/main.cfg is necessary for scheduling, but scheduling looks for it locally: 1383 // it assumes GLI is inside a GS2 installation 1384 File mcfg = new File(LocalGreenstone.getDirectoryPath() + File.separator + "etc" + File.separator + "main.cfg"); 1385 if(!mcfg.exists()) { 1386 System.out.println("Cannot do scheduling, since there is no file: " + mcfg.getAbsolutePath() 1387 + ".\nScheduling presently depends on GLI running from inside a GS2."); 1388 return false; 1389 } 1390 1391 return true; 1392 } 1037 1393 1038 1394 private void makeCollection(String name, String email) … … 1045 1401 } 1046 1402 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "mkcol.pl"); 1047 command_parts_list.add((Gatherer.GS3) ? Utility.GS3MODE_ARGUMENT : "");// add '-gs3mode' 1403 if(Gatherer.GS3) { 1404 command_parts_list.add(Utility.GS3MODE_ARGUMENT); // add '-gs3mode' 1405 } 1048 1406 1049 1407 command_parts_list.add("-collectdir"); … … 1062 1420 // Run the mkcol.pl command 1063 1421 String[] command_parts = (String[]) command_parts_list.toArray(new String[0]); 1422 //for(int i = 0; i < command_parts.length; i++) { 1423 ///ystem.err.println("\""+command_parts[i]+"\""); 1424 //} 1064 1425 1065 1426 GShell process = new GShell(command_parts, GShell.NEW, COLLECT, this, null, GShell.GSHELL_NEW); … … 1072 1433 */ 1073 1434 public synchronized void message(GShellEvent event) { 1435 1074 1436 } 1075 1437 … … 1123 1485 buildCollection(false); 1124 1486 } 1487 else if(event.getType() == GShell.SCHEDULE && event.getStatus() == GShell.OK ) { 1488 1489 WarningDialog collection_built_warning_dialog = new WarningDialog("warning.ScheduleBuilt", Dictionary.get("ScheduleBuilt.Title"), Dictionary.get("ScheduleBuilt.Message"), null, false); 1490 collection_built_warning_dialog.setMessageOnly(true); // Not a warning 1491 collection_built_warning_dialog.display(); 1492 collection_built_warning_dialog.dispose(); 1493 collection_built_warning_dialog = null; 1494 } 1125 1495 // If we were running a build, now is when we move files across. 1126 1496 else if(event.getType() == GShell.BUILD && event.getStatus() == GShell.OK) { … … 1159 1529 Gatherer.g_man.repaint(); 1160 1530 } 1161 else if (event.getStatus() == GShell.ERROR) { 1162 DebugStream.println("There was an error in the gshell:"+ event.getMessage()); 1163 if (event.getType() == GShell.NEW) { 1164 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Create_Collection"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1165 } else { 1531 else if (event.getStatus() == GShell.ERROR) { 1532 if (event.getType() == GShell.NEW) { 1533 String name = event.getMessage(); 1534 String collectDir = getCollectionDirectoryPath(name); 1535 String errMsg = ""; 1536 if (!new File(getCollectionDirectoryPath(name)).exists() || !new File(getCollectionDirectoryPath(name)).canWrite()) { 1537 String reason = Dictionary.get("FileActions.Write_Not_Permitted_Message", new String[]{collectDir}); 1538 errMsg = Dictionary.get("CollectionManager.Cannot_Create_Collection_With_Reason", new String[]{reason}); 1539 if(Gatherer.client_operating_system.toUpperCase().indexOf("WINDOWS") != -1){ 1540 //if(Gatherer.client_operating_system.toUpperCase().indexOf("VISTA")!=-1){ 1541 errMsg += Dictionary.get("FileActions.File_Permission_Detail", new String[]{Configuration.gsdl_path, System.getProperty("user.name")}); 1542 //} 1543 } 1544 } else { 1545 errMsg = Dictionary.get("CollectionManager.Cannot_Create_Collection"); 1546 } 1547 JOptionPane.showMessageDialog(Gatherer.g_man, errMsg, Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1548 } 1549 else if(event.getType() == GShell.SCHEDULE) { 1550 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Schedule_Failed"), Dictionary.get("CollectionManager.Schedule_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1551 } 1552 else { 1166 1553 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1167 1554 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); … … 1199 1586 } 1200 1587 1588 public void registerScheduleMonitor(GShellProgressMonitor monitor) { 1589 schedule_monitor = monitor; 1590 } 1591 1201 1592 1202 1593 static public void removeCollectionContentsChangedListener(CollectionContentsChangedListener listener) … … 1227 1618 // If we're using a remote Greenstone server, delete the metadata file on the server 1228 1619 if (Gatherer.isGsdlRemote) { 1229 RemoteGreenstoneServer.deleteCollectionFile(collection.getName(), metadata_set_file);1620 Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getName(), metadata_set_file); 1230 1621 } 1231 1622 } … … 1317 1708 private boolean installCollection() 1318 1709 { 1710 if (Configuration.fedora_info.isActive()) { 1711 DebugStream.println("Fedora build complete. No need to move files."); 1712 return true; 1713 } 1714 1715 1319 1716 DebugStream.println("Build complete. Moving files."); 1320 1717 … … 1353 1750 1354 1751 if (Gatherer.isGsdlRemote) { 1355 RemoteGreenstoneServer.deleteCollectionFile(collection.getName(), new File(getLoadedCollectionIndexDirectoryPath())); 1356 RemoteGreenstoneServer.moveCollectionFile(collection.getName(), new File(getLoadedCollectionBuildingDirectoryPath()), new File(getLoadedCollectionIndexDirectoryPath())); 1752 Gatherer.remoteGreenstoneServer.deleteCollectionFile( 1753 collection.getName(), new File(getLoadedCollectionIndexDirectoryPath())); 1754 Gatherer.remoteGreenstoneServer.moveCollectionFile(collection.getName(), 1755 new File(getLoadedCollectionBuildingDirectoryPath()), new File(getLoadedCollectionIndexDirectoryPath())); 1357 1756 } 1358 1757
Note:
See TracChangeset
for help on using the changeset viewer.