Changeset 10342
- Timestamp:
- 2005-07-28T15:50:17+12:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Configuration.java
r10330 r10342 155 155 156 156 // If the existing user config.xml file isn't recent enough, backup the old version and update it 157 File config_xml_file = new File( Utility.getGLIUserFolder(),config_xml_file_name);157 File config_xml_file = new File(Gatherer.getGLIUserDirectoryPath() + config_xml_file_name); 158 158 if (config_xml_file != null && config_xml_file.exists()) { 159 159 just_updated_config_xml_file = updateUserConfigXMLFileIfNecessary(config_xml_file); … … 732 732 } 733 733 try { 734 user_config_xml = new File( Utility.getGLIUserFolder(),config_xml_name);734 user_config_xml = new File(Gatherer.getGLIUserDirectoryPath() + config_xml_name); 735 735 ///ystem.err.println("Trying to save to: " + user_config_xml.getAbsolutePath()); 736 736 ///ystem.err.println("Writing."); … … 740 740 catch(Exception exception) { 741 741 user_config_xml = null; 742 }743 // Always do this if the above fails.744 if(user_config_xml == null || !user_config_xml.exists()) {745 // But failing that we produce a general copy746 XMLTools.writeXMLFile(new File(Utility.BASE_DIR + config_xml_name), general_config);747 742 } 748 743 } -
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r10330 r10342 69 69 static public boolean exit = false; 70 70 71 static private String gli_directory_path = null; 72 static private String gli_user_directory_path = null; 73 71 74 /** All of the external applications that must exit before we close the Gatherer. */ 72 75 public Vector apps = new Vector(); … … 131 134 // Set the Greenstone path and collect directory specially when running with a remote Greenstone 132 135 if (isGsdlRemote) { 133 go.gsdl_path = Utility.getGLIUserFolder() + File.separator; 134 Gatherer.setCollectDirectoryPath(go.gsdl_path + "collect" + File.separator); 136 go.gsdl_path = getGLIUserDirectoryPath(); 137 setCollectDirectoryPath(go.gsdl_path + "collect" + File.separator); 138 } 139 else { 140 setGLIDirectoryPath(go.gsdl_path + "gli"); 135 141 } 136 142 137 143 // Users may specify a non-standard collect directory (eg. when running one GLI in a network environment) 138 144 if (go.collect_directory_path != null) { 139 Gatherer.setCollectDirectoryPath(go.collect_directory_path);145 setCollectDirectoryPath(go.collect_directory_path); 140 146 } 141 147 142 148 // Special code for running with a remote Greenstone 143 149 if (isGsdlRemote) { 144 File gli_user_directory = Utility.getGLIUserFolder();145 146 Utility.BASE_DIR = go.gsdl_path;147 Utility.METADATA_DIR = Utility.BASE_DIR + "metadata" + File.separator;148 Utility.TMP_DIR = Utility.BASE_DIR + "tmp" + File.separator;149 150 150 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml"; 151 151 Configuration.CONFIG_XML = "configRemote.xml"; … … 160 160 // for documented example collections so "base this on 161 161 // existing collection" works 162 ZipTools.unzipFromJar(Utility.COLLECT_ZIP, g li_user_directory.toString());162 ZipTools.unzipFromJar(Utility.COLLECT_ZIP, getGLIUserDirectoryPath()); 163 163 } 164 164 else { … … 170 170 } 171 171 172 File tmp_dir = new File(Utility.TMP_DIR); 173 if (!tmp_dir.exists()) { 174 if (!tmp_dir.mkdir()) { 175 System.err.println("Warning: Unable to make directory: " + tmp_dir.toString()); 176 } 177 178 String username = System.getProperty("user.name"); 179 if ((username != null) && (username != "")) { 180 File user_tmp_dir = new File(Utility.TMP_DIR + File.separator + username); 181 if (!user_tmp_dir.exists()) { 182 if (!user_tmp_dir.mkdir()) { 183 System.err.println("Warning: Unable to make directory: " + user_tmp_dir.toString()); 184 } 185 } 186 } 187 } 188 189 File metadata_directory = new File(Utility.METADATA_DIR); 172 File metadata_directory = new File(Gatherer.getGLIMetadataDirectoryPath()); 190 173 if (!metadata_directory.exists()) { 191 174 // dig out metadata.zip from JAR file and unzip it 192 ZipTools.unzipFromJar(Utility.METADATA_ZIP, g li_user_directory.toString());193 } 194 195 File plug_dat = new File( Utility.BASE_DIR+ "plugins.dat");175 ZipTools.unzipFromJar(Utility.METADATA_ZIP, getGLIUserDirectoryPath()); 176 } 177 178 File plug_dat = new File(getGLIUserDirectoryPath() + "plugins.dat"); 196 179 if (!plug_dat.exists()) { 197 JarTools.extractFromJar("plugins.dat", Utility.BASE_DIR, false);198 } 199 200 File class_dat = new File( Utility.BASE_DIR+ "classifiers.dat");180 JarTools.extractFromJar("plugins.dat", getGLIUserDirectoryPath(), false); 181 } 182 183 File class_dat = new File(getGLIUserDirectoryPath() + "classifiers.dat"); 201 184 if (!class_dat.exists()) { 202 JarTools.extractFromJar("classifiers.dat", Utility.BASE_DIR, false);185 JarTools.extractFromJar("classifiers.dat", getGLIUserDirectoryPath(), false); 203 186 } 204 187 } … … 229 212 230 213 // Debug file is created in the user's GLI directory 231 debug_file_path = Utility.getGLIUserFolder().toString() + File.separator+ debug_file_path;214 debug_file_path = getGLIUserDirectoryPath() + debug_file_path; 232 215 DebugStream.println("Debug file path: " + debug_file_path); 233 216 DebugStream.setDebugFile(debug_file_path); … … 541 524 542 525 526 /** Returns the path of the Greenstone "collect" directory. */ 543 527 static public String getCollectDirectoryPath() 544 528 { … … 553 537 return getSitesDirectoryPath() + Configuration.site_name + File.separator + "collect" + File.separator; 554 538 } 539 } 540 541 542 /** Returns the path of the GLI directory. */ 543 static public String getGLIDirectoryPath() 544 { 545 return gli_directory_path; 546 } 547 548 549 /** Returns the path of the GLI "metadata" directory. */ 550 static public String getGLIMetadataDirectoryPath() 551 { 552 return getGLIDirectoryPath() + "metadata" + File.separator; 553 } 554 555 556 /** Returns the path of the GLI user directory. */ 557 static public String getGLIUserDirectoryPath() 558 { 559 return gli_user_directory_path; 560 } 561 562 563 /** Returns the path of the GLI user "cache" directory. */ 564 static public String getGLIUserCacheDirectoryPath() 565 { 566 return getGLIUserDirectoryPath() + "cache" + File.separator; 567 } 568 569 570 /** Returns the path of the GLI user "log" directory. */ 571 static public String getGLIUserLogDirectoryPath() 572 { 573 return getGLIUserDirectoryPath() + "log" + File.separator; 555 574 } 556 575 … … 568 587 non_standard_collect_directory_path = non_standard_collect_directory_path + File.separator; 569 588 } 589 } 590 591 592 static public void setGLIDirectoryPath(String gli_directory_path_arg) 593 { 594 gli_directory_path = gli_directory_path_arg; 595 } 596 597 598 static public void setGLIUserDirectoryPath(String gli_user_directory_path_arg) 599 { 600 gli_user_directory_path = gli_user_directory_path_arg; 570 601 } 571 602 -
trunk/gli/src/org/greenstone/gatherer/GathererApplet.java
r10242 r10342 89 89 } 90 90 91 // Determine the GLI user directory path 92 String gli_user_directory_path = System.getProperty("user.home") + File.separator; 93 if (Utility.isWindows()) { 94 String windows_home_parameter = getParameter("windowsHome"); 95 if (windows_home_parameter != null && !windows_home_parameter.equals("")) { 96 gli_user_directory_path = windows_home_parameter + File.separator + "GLI" + File.separator; 97 } 98 else { 99 gli_user_directory_path += "Application Data" + File.separator + "Greenstone" + File.separator + "GLI" + File.separator; 100 } 101 } 102 else { 103 gli_user_directory_path += ".gli" + File.separator; 104 } 105 Gatherer.setGLIUserDirectoryPath(gli_user_directory_path); 106 Gatherer.setGLIDirectoryPath(gli_user_directory_path); 107 91 108 // Ensure the GLI user directory exists 92 File gli_user_directory = Utility.setGLIUserFolder(getParameter("windowsHome"));109 File gli_user_directory = new File(gli_user_directory_path); 93 110 if (!gli_user_directory.exists() && !gli_user_directory.mkdirs()) { 94 111 System.err.println("Error: Unable to make directory: " + gli_user_directory.toString()); -
trunk/gli/src/org/greenstone/gatherer/GathererProg.java
r10242 r10342 61 61 } 62 62 63 // Determine the GLI user directory path 64 String gli_user_directory_path = System.getProperty("user.home") + File.separator; 65 if (Utility.isWindows()) { 66 gli_user_directory_path += "Application Data" + File.separator + "Greenstone" + File.separator + "GLI" + File.separator; 67 } 68 else { 69 gli_user_directory_path += ".gli" + File.separator; 70 } 71 Gatherer.setGLIUserDirectoryPath(gli_user_directory_path); 72 63 73 // Ensure the GLI user directory exists 64 File gli_user_directory = Utility.setGLIUserFolder(null); // Defaults to user's home area74 File gli_user_directory = new File(gli_user_directory_path); 65 75 if (!gli_user_directory.exists() && !gli_user_directory.mkdirs()) { 66 76 System.err.println("Error: Unable to make directory: " + gli_user_directory.toString()); -
trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java
r10341 r10342 103 103 104 104 DebugStream.println("deleting classifiers.dat"); 105 File class_file = new File( Utility.getGLIUserFolder(),"classifiers.dat");105 File class_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat"); 106 106 if (class_file.exists()) { 107 107 return Utility.delete(class_file); … … 261 261 private void saveClassifiers() { 262 262 try { 263 File classifiers_dat_file = new File( Utility.getGLIUserFolder(),"classifiers.dat");263 File classifiers_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat"); 264 264 FileOutputStream file = new FileOutputStream(classifiers_dat_file); 265 265 ObjectOutputStream out = new ObjectOutputStream(file); … … 369 369 private void loadClassifiers() { 370 370 // Attempt to restore the cached file. 371 File classifiers_dat_file = new File( Utility.getGLIUserFolder(),"classifiers.dat");371 File classifiers_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat"); 372 372 try { 373 373 FileInputStream file = new FileInputStream(classifiers_dat_file); -
trunk/gli/src/org/greenstone/gatherer/cdm/MetadataSetView.java
r9172 r10342 289 289 public void actionPerformed(ActionEvent event) 290 290 { 291 JFileChooser chooser = new JFileChooser(new File( Utility.METADATA_DIR));291 JFileChooser chooser = new JFileChooser(new File(Gatherer.getGLIMetadataDirectoryPath())); 292 292 chooser.setFileFilter(new MetadataSet.MetadataSetFileFilter()); 293 293 int return_val = chooser.showDialog(Gatherer.g_man, Dictionary.get("CDM.MetadataSetManager.Add")); -
trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java
r10237 r10342 107 107 108 108 DebugStream.println("deleting plugins.dat"); 109 File plugin_file = new File( Utility.getGLIUserFolder(),"plugins.dat");109 File plugin_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat"); 110 110 if (plugin_file.exists()) { 111 111 return Utility.delete(plugin_file); … … 359 359 private void savePlugins() { 360 360 try { 361 File plugins_dat_file = new File( Utility.getGLIUserFolder(),"plugins.dat");361 File plugins_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat"); 362 362 FileOutputStream file = new FileOutputStream(plugins_dat_file); 363 363 ObjectOutputStream out = new ObjectOutputStream(file); … … 499 499 private void loadPlugins() { 500 500 // Attempt to restore the cached file. 501 File plugins_dat_file = new File( Utility.getGLIUserFolder(),"plugins.dat");501 File plugins_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat"); 502 502 try { 503 503 FileInputStream file = new FileInputStream(plugins_dat_file); -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r10263 r10342 317 317 //check that this creation has worked - simply by checking for the existence of the collect.cfg file 318 318 String collection_directory_path = getCollectionDirectoryPath(name); 319 File co nfig_file = new File(Utility.getConfigFile(collection_directory_path));320 if (!co nfig_file.exists()) {319 File collect_cfg_file = new File(collection_directory_path + "collect.cfg"); 320 if (!collect_cfg_file.exists()) { 321 321 // no point continuing 322 322 System.err.println("Error: no collect.cfg file has been created!"); … … 327 327 328 328 // ACTIVE_DIR/log/ 329 File log_dir_temp = new File(Utility.getLogDir(collection_directory_path)+"temp.dat"); 330 File log_dir = log_dir_temp.getParentFile(); 329 File log_dir = new File(collection_directory_path + "log"); 331 330 log_dir.mkdirs(); 332 331 progress.setNote(Dictionary.get("CollectionManager.Log_Created")); 333 332 334 333 // Make sure an import folder exists 335 File import_directory = new File( Utility.getImportDir(collection_directory_path));334 File import_directory = new File(collection_directory_path + "import"); 336 335 if (!import_directory.exists()) { 337 336 import_directory.mkdirs(); … … 396 395 // Always import the extracted metadata set if we didn't already 397 396 if (MetadataSetManager.getMetadataSet(MetadataSetManager.EXTRACTED_METADATA_NAMESPACE) == null) { 398 File extracted_metadata_set_file = new File( Utility.METADATA_DIR+ Utility.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION);397 File extracted_metadata_set_file = new File(Gatherer.getGLIMetadataDirectoryPath() + Utility.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION); 399 398 importMetadataSet(new MetadataSet(extracted_metadata_set_file)); 400 399 } … … 1147 1146 1148 1147 // Always import the extracted metadata set 1149 File extracted_metadata_set_file = new File( Utility.METADATA_DIR+ Utility.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION);1148 File extracted_metadata_set_file = new File(Gatherer.getGLIMetadataDirectoryPath() + Utility.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION); 1150 1149 importMetadataSet(new MetadataSet(extracted_metadata_set_file)); 1151 1150 -
trunk/gli/src/org/greenstone/gatherer/collection/DownloadJob.java
r8811 r10342 101 101 // this.model = model; 102 102 103 String log_filename = Utility.getLogDir(null) + "wget" + initial.hashCode() + ".log";103 String log_filename = Gatherer.getGLIUserLogDirectoryPath() + "wget" + initial.hashCode() + ".log"; 104 104 File log_file = new File(log_filename); 105 105 if(log_file.exists()) { … … 413 413 414 414 // Parse arguments into array. 415 args.add( Utility.BASE_DIR + "wget");415 args.add(Configuration.getWGetPath()); 416 416 args.add("-d"); 417 417 args.add("-o"); -
trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r10325 r10342 111 111 112 112 // ...except for files from the "Downloaded Files" folder 113 String downloaded_files_folder_path = Utility.getCacheDir().getAbsolutePath();113 String downloaded_files_folder_path = Gatherer.getGLIUserCacheDirectoryPath(); 114 114 for (int i = 0; i < source_nodes.length; i++) { 115 115 // Is this the "Downloaded Files" folder? -
trunk/gli/src/org/greenstone/gatherer/file/FileSystem.java
r9755 r10342 4 4 import org.greenstone.gatherer.DebugStream; 5 5 import org.greenstone.gatherer.Dictionary; 6 import org.greenstone.gatherer.Gatherer; 6 7 import org.greenstone.gatherer.util.Utility; 7 8 … … 59 60 { 60 61 // Return a mapping to the downloaded files folder 61 return new WorkspaceTreeNode( Utility.getCacheDir(), Dictionary.get("Tree.DownloadedFiles"));62 return new WorkspaceTreeNode(new File(Gatherer.getGLIUserCacheDirectoryPath()), Dictionary.get("Tree.DownloadedFiles")); 62 63 } 63 64 } -
trunk/gli/src/org/greenstone/gatherer/file/RecycleBin.java
r10011 r10342 81 81 setOpaque(true); 82 82 83 this.model = new FileSystemModel(new RecycleBinNode(new File( Utility.getGLIUserFolder(),"recycle")));83 this.model = new FileSystemModel(new RecycleBinNode(new File(Gatherer.getGLIUserDirectoryPath() + "recycle"))); 84 84 } 85 85 -
trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeNode.java
r9458 r10342 112 112 ArrayTools.sort(sites); 113 113 for (int i = 0; sites != null && i < sites.length; i++) { 114 File collect_dir = new File(sites[i], Utility.COL_DIR);114 File collect_dir = new File(sites[i], "collect"); 115 115 if (!collect_dir.exists()) { 116 116 continue; -
trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
r10330 r10342 197 197 // Load all the core metadata sets (in the GLI "metadata" directory) 198 198 model = new GEMSModel(); 199 File metadata_directory = new File( Utility.METADATA_DIR);199 File metadata_directory = new File(getGLIMetadataDirectoryPath()); 200 200 if (metadata_directory.exists()) { 201 201 // Load just those .mds files in this directory, and return them … … 385 385 386 386 387 static public String getGLIDirectoryPath() 388 { 389 return System.getProperty("user.dir") + File.separator; 390 } 391 392 393 static public String getGLIMetadataDirectoryPath() 394 { 395 return getGLIDirectoryPath() + "metadata" + File.separator; 396 } 397 387 398 388 399 private class GEMSMenuBar … … 514 525 //we first launch the dialog to determine where the jfilechooser should be opened 515 526 //ie: for collection specific sets - attila dec10-04 516 String set_directory = Utility.METADATA_DIR;527 String set_directory = getGLIMetadataDirectoryPath(); 517 528 518 529 SetSelectionDialog m = new SetSelectionDialog(); … … 1559 1570 //setup to write to filename from existing file 1560 1571 try { 1561 out = new FileOutputStream( Utility.METADATA_DIR + File.separator+ namespace_str + ".mds");1572 out = new FileOutputStream(getGLIMetadataDirectoryPath() + namespace_str + ".mds"); 1562 1573 OutputStreamWriter pout = new OutputStreamWriter(out, "UTF8"); 1563 1574 p = new PrintWriter(pout); … … 1576 1587 p.close(); 1577 1588 1578 MetadataSet loadedset = msm.loadMetadataSet(new File( Utility.METADATA_DIR + File.separator+ namespace_str + ".mds"));1589 MetadataSet loadedset = msm.loadMetadataSet(new File(getGLIMetadataDirectoryPath() + namespace_str + ".mds")); 1579 1590 model.add(null, loadedset, GEMSNode.SET); 1580 1591 } … … 2244 2255 if(current_set != null) { 2245 2256 2246 //If the current_set_filename is dls or dublin or ex and in the METADATA_DIR, then do2257 //If the current_set_filename is dls or dublin or ex and in the GLI metadata directory, then do 2247 2258 //not let anyone remove them --Attila 2248 2259 File current_set_filename = current_set.getFile(); 2249 if(current_set_filename.toString().compareTo(new String( Utility.METADATA_DIR+"dls.mds")) == 0 ||2250 current_set_filename.toString().compareTo(new String( Utility.METADATA_DIR+"dublin.mds")) == 0 ||2251 current_set_filename.toString().compareTo(new String( Utility.METADATA_DIR+"ex.mds")) == 0){2260 if(current_set_filename.toString().compareTo(new String(getGLIMetadataDirectoryPath() + "dls.mds")) == 0 || 2261 current_set_filename.toString().compareTo(new String(getGLIMetadataDirectoryPath() + "dublin.mds")) == 0 || 2262 current_set_filename.toString().compareTo(new String(getGLIMetadataDirectoryPath() + "ex.mds")) == 0){ 2252 2263 2253 2264 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Cannot_Delete_Core_Sets_Error"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); -
trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java
r9170 r10342 85 85 mds.setName(name); 86 86 // this is the location for a global metadata set 87 File mds_file = new File( Utility.METADATA_DIR,namespace + ".mds");87 File mds_file = new File(GEMS.getGLIMetadataDirectoryPath() + namespace + ".mds"); 88 88 mds.setFile(mds_file); 89 89 mds_hashtable.put(namespace, mds); … … 399 399 400 400 public void save() { 401 File file = new File( Utility.METADATA_DIR);401 File file = new File(GEMS.getGLIMetadataDirectoryPath()); 402 402 403 403 if (!file.exists()) { -
trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java
r8992 r10342 307 307 public void actionPerformed(ActionEvent event) { 308 308 // Retrieve the cache folder and delete it. 309 Utility.delete( Utility.getCacheDir());309 Utility.delete(Gatherer.getGLIUserCacheDirectoryPath()); 310 310 // ...and refresh the node in the workspace tree to show it's all gone 311 311 Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.DOWNLOADED_FILES_CHANGED); … … 369 369 depth_object = null; 370 370 371 File destination_file = Utility.getCacheDir(); 372 destination_file.mkdirs(); // If they aren't already 373 String destination_filename = destination_file.getAbsolutePath(); 374 if(!destination_filename.endsWith(File.separator)) { 375 destination_filename = destination_filename + File.separator; 376 } 371 String destination_file_path = Gatherer.getGLIUserCacheDirectoryPath(); 372 (new File(destination_file_path)).mkdirs(); // If they aren't already 377 373 378 374 if(url != null) { 379 getter.newDownloadJob(higher_checkbox.isSelected(), (higher_checkbox.isSelected()? false : !same_host_checkbox.isSelected()), !requisite_checkbox.isSelected(), url, depth_value, destination_file name);375 getter.newDownloadJob(higher_checkbox.isSelected(), (higher_checkbox.isSelected()? false : !same_host_checkbox.isSelected()), !requisite_checkbox.isSelected(), url, depth_value, destination_file_path); 380 376 } 381 377 } -
trunk/gli/src/org/greenstone/gatherer/gui/FileAssociationDialog.java
r9354 r10342 290 290 */ 291 291 public void actionPerformed(ActionEvent event) { 292 JFileChooser chooser = new JFileChooser(new File( Utility.BASE_DIR));292 JFileChooser chooser = new JFileChooser(new File(Gatherer.getGLIUserDirectoryPath())); 293 293 OpenCollectionDialog.disableRename(chooser); 294 294 chooser.setDialogTitle(Dictionary.get("FileAssociationDialog.Browse_Title")); -
trunk/gli/src/org/greenstone/gatherer/gui/HelpFrame.java
r10013 r10342 47 47 import org.greenstone.gatherer.DebugStream; 48 48 import org.greenstone.gatherer.Dictionary; 49 import org.greenstone.gatherer.Gatherer; 49 50 import org.greenstone.gatherer.util.JarTools; 50 51 import org.greenstone.gatherer.util.StaticStrings; … … 322 323 url = JarTools.getResource("/" + help_file); 323 324 if (url == null) { 324 File file = new File( Utility.BASE_DIR+ help_file);325 File file = new File(Gatherer.getGLIUserDirectoryPath() + help_file); 325 326 try { 326 327 url = file.toURL(); -
trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionMetadataPrompt.java
r9864 r10342 70 70 71 71 // Show the metadata sets (except extracted!) available in the GLI "metadata" folder 72 ArrayList metadata_sets = MetadataSetManager.listMetadataSets(new File( Utility.METADATA_DIR));72 ArrayList metadata_sets = MetadataSetManager.listMetadataSets(new File(Gatherer.getGLIMetadataDirectoryPath())); 73 73 ArrayList metadata_set_list_entries = new ArrayList(); 74 74 for (int i = 0; i < metadata_sets.size(); i++) { -
trunk/gli/src/org/greenstone/gatherer/gui/PreviewCommandDialog.java
r8243 r10342 176 176 */ 177 177 public void actionPerformed(ActionEvent event) { 178 JFileChooser chooser = new JFileChooser(new File( Utility.BASE_DIR));178 JFileChooser chooser = new JFileChooser(new File(Gatherer.getGLIUserDirectoryPath())); 179 179 OpenCollectionDialog.disableRename(chooser); 180 180 chooser.setDialogTitle(Dictionary.get("FileAssociationDialog.Browse_Title")); -
trunk/gli/src/org/greenstone/gatherer/shell/GShell.java
r10259 r10342 627 627 progress.messageOnProgressBar("Downloading CD-ROM data from server"); 628 628 } 629 630 // !! TO DO 629 631 630 //Export directory derrived from -cdname argument 631 //This needs to be exactly the same as derrived by exportcol.pl - perhaps it should be passed in as an argument? 632 String cd_dir = "exported_collections"; 633 for(int i=0; i<args.length-1; i++) { 634 if(args[i] == "-cdname") { 635 //Remove all spaces 636 String cdName = args[i+1]; 637 Pattern pattern = Pattern.compile("\\s"); 638 Matcher matcher = pattern.matcher(cdName); 639 cd_dir = "exported_" + matcher.replaceAll(""); 640 } 641 } 642 //DebugStream.println("cd_dir is: " + cd_dir); 643 644 String tmp_dir = Utility.TMP_DIR; 645 String user_tmp_dir = "/tmp"; 646 647 //String username = System.getProperty("user.name"); 648 //if ((username != null) && (username != "")) { 649 // user_cd_dir = username + File.separator + cd_dir; 650 //user_tmp_dir = user_tmp_dir + File.separator + username; 651 //} 652 653 String full_local_cd_dir = tmp_dir + cd_dir; //Need to tell user this! 654 655 Utility.delete(full_local_cd_dir); // remove current cd-rom dir, if it exists 656 RemoteGreenstoneServer.download_url_zip(user_tmp_dir,cd_dir,this,"",""); 657 658 ZipTools.unzip(Configuration.gsdl_path, user_tmp_dir.substring(1)); 659 660 if (progress!=null) { 661 System.err.println("Asking progress bar to be empty string"); 662 progress.messageOnProgressBar(""); 663 } 664 665 //The string needs to start with exportcol.pl> otherwise it won't be displayed in the final dialog 666 String message = "exportcol.pl>\nThese files have been copied from the server to " + full_local_cd_dir + " and are ready to written to CD-ROM"; 667 fireMessage(type, message, status, bos); //Hopefully this works 668 System.err.println("Finished download of /tmp ..."); 669 } 670 632 if (progress!=null) { 633 progress.messageOnProgressBar(""); 634 } 635 } 671 636 } 672 637 } -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r10330 r10342 65 65 /** The size of the io buffer, in bytes. */ 66 66 static final public int BUFFER_SIZE = 1024; 67 /** Definition of an important directory name, in this case the base dir, or the working directory of the Gatherer. */68 69 static public String BASE_DIR = System.getProperty("user.dir") + File.separator;70 67 static final public String BUILD_CFG_FILENAME = "build.cfg"; 71 68 static final public String CFG_COLLECTIONMETA_COLLECTIONNAME = "collectionmeta\tcollectionname"; … … 80 77 static final public String CFG_FORMAT = "format"; 81 78 static final public String CFG_MAINTAINER = "maintainer"; 82 /** Definition of an important directory name, in this case the parent directory of all the collections in the gsdl. */83 static final public String COL_DIR = "collect" + File.separator;84 79 static final public String COLLECTION_TREE = "Collection"; 85 80 /** Definition of an important directory name, in this case the file the collection configuration is expect to be in. */ … … 91 86 static final public String GLI_EXTENSION = ".col"; 92 87 93 static public String TMP_DIR = BASE_DIR + "tmp" + File.separator;94 95 88 /** Definition of an important directory name, in this case the images directory for the collection. */ 96 89 static final public String IMAGES_DIR = "images" + File.separator; … … 99 92 /** Definition of an important directory name, in this case the backup import directory for the collection. */ 100 93 static final public String IMPORT_BAK_DIR = "import.bak" + File.separator; 101 /** Definition of an important directory name, in this case the log directory for the collection. */102 static final public String LOG_DIR = "log" + File.separator;103 94 /** Definition of an important directory name, in this case the macros directory for the collection. */ 104 95 static final public String MACROS_DIR = "macros" + File.separator; 105 96 /** Definition of an important directory name, in this case the location of the expected collection metadata sets.. */ 106 97 static final public String META_DIR = "metadata" + File.separator; // Col. Copy 107 /** Definition of an important directory name, in this case the location of the default metadata sets. */108 static public String METADATA_DIR = BASE_DIR + "metadata" + File.separator;109 98 /** Definition of an important zip file, in this case zipped up version of metadata file stored in JAR file */ 110 99 static final public String METADATA_ZIP = "metadata.zip"; … … 119 108 static final public String PROGRAM_VERSION = "v2.60"; 120 109 static final public String WORKSPACE_TREE = "Workspace"; 121 static final public String XML_DIRECTORY = "xml" + File.separator;122 123 static protected File gli_user_folder = null;124 110 125 111 … … 326 312 327 313 328 /** Builds the cache dir by appending the user path and 'cache'.329 * @return a File representing the path to the private file cache within the current collection.330 */331 public static File getCacheDir() {332 return new File(getGLIUserFolder(), StaticStrings.CACHE_FOLDER);333 }334 335 336 /** Method which constructs the configuration file given a certain collection.337 * @param col_dir The location of the collection directory as a <strong>String</strong>.338 * @return The location of the given collections configuration file, also as a <strong>String</strong>.339 */340 static public String getConfigFile(String col_dir) {341 return col_dir + CONFIG_FILE;342 }343 344 314 static public String getDateString() { 345 315 Calendar current = Calendar.getInstance(); … … 381 351 382 352 383 static final private String APPLICATION_DATA_FOLDER = "Application Data";384 static final private String UNIX_GLI_CONFIG_FOLDER = ".gli";385 static final private String USER_HOME_PROPERTY = "user.home";386 static final private String WIN_GLI_CONFIG_FOLDER = "Greenstone" + File.separator + "GLI";387 388 static public File setGLIUserFolder(String windows_home) {389 gli_user_folder = null;390 if(Utility.isWindows()) {391 if ((windows_home != null) && (windows_home != "")) {392 gli_user_folder = new File(windows_home + File.separator + "GLI" + File.separator);393 }394 else {395 gli_user_folder = new File(System.getProperty(USER_HOME_PROPERTY) + File.separator + APPLICATION_DATA_FOLDER + File.separator + WIN_GLI_CONFIG_FOLDER + File.separator);396 }397 }398 else {399 gli_user_folder = new File(System.getProperty(USER_HOME_PROPERTY) +400 File.separator + UNIX_GLI_CONFIG_FOLDER + File.separator);401 }402 return gli_user_folder;403 }404 405 static public File getGLIUserFolder()406 {407 return gli_user_folder;408 }409 410 411 /** Method which constructs the import directory given a certain collection.412 * @param col_dir The location of the collection directory as a <strong>String</strong>.413 * @return The location of the given collections import directory, also as a <strong>String</strong>.414 */415 public static String getImportDir(String col_dir) {416 return col_dir + IMPORT_DIR;417 }418 419 /** Method which constructs the log directory given a certain collection.420 * @param col_dir The location of the collection directory as a <strong>String</strong>.421 * @return The location of the given collections log directory, also as a <strong>String</strong>.422 */423 public static String getLogDir(String col_dir) {424 if(col_dir != null) {425 return col_dir + LOG_DIR;426 }427 else {428 return getGLIUserFolder().getAbsolutePath() + File.separator + LOG_DIR;429 }430 }431 353 /** Determine this machines name. 432 354 * @return The name as a <strong>String</strong>.
Note:
See TracChangeset
for help on using the changeset viewer.