Changeset 7168 for trunk/gli/src/org/greenstone/gatherer/msm
- Timestamp:
- 2004-03-31T13:58:29+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/msm/LegacyCollectionImporter.java
r7119 r7168 105 105 106 106 107 // This copies all the existing metadata.xml files into a backup directory 108 public void backupMetadataXMLFiles(File collection_dir) 109 { 110 File import_dir = new File(collection_dir, Utility.IMPORT_DIR); 111 File import_bak_dir = new File(collection_dir, Utility.IMPORT_BAK_DIR); 112 import_bak_dir.mkdir(); 113 copyMetadataXMLFiles(import_dir, import_bak_dir); 114 } 115 116 117 private void copyMetadataXMLFiles(File source_dir, File target_dir) 118 { 119 // Find the metadata.xml file in this dir 120 File metadata_file = new File(source_dir, StaticStrings.METADATA_XML); 121 if (metadata_file.exists()) { 122 File backup_metadata_file = new File(target_dir, StaticStrings.METADATA_XML); 123 try { 124 target_dir.mkdirs(); 125 Gatherer.f_man.getQueue().copyFile(metadata_file, backup_metadata_file, null); 126 if (!backup_metadata_file.exists()) { 127 throw new Exception(""); 128 } 129 } 130 catch (Exception e) { 131 Gatherer.println("Exception: couldn't copy file " + metadata_file.getPath() + e.getMessage()); 132 } 133 } 134 135 // Now go through child directories 136 File [] children = source_dir.listFiles(); 137 for (int i = 0; i < children.length; i++) { 138 File child = children[i]; 139 if (child.isDirectory()) { 140 copyMetadataXMLFiles(child, new File(target_dir, child.getName())); 141 } 142 } 143 } 144 145 107 146 public void importMetadata() 108 147 { … … 137 176 } 138 177 139 // First, copy the original file to make a backup140 File backup_file = new File(file.getParentFile(), StaticStrings.METADATA_BAK);141 try {142 Gatherer.f_man.getQueue().copyFile(file, backup_file, null);143 if (!backup_file.exists()) {144 throw new Error();145 }146 }147 catch (Exception ex) {148 System.err.println("Exception occurred while importing legacy collection.");149 System.err.println("Error: Could not backup metadata.xml file to " + backup_file);150 ex.printStackTrace();151 System.err.println("Aborting legacy collection import.");152 cancelled = true;153 return;154 }178 // // First, copy the original file to make a backup 179 // File backup_file = new File(file.getParentFile(), StaticStrings.METADATA_BAK); 180 // try { 181 // Gatherer.f_man.getQueue().copyFile(file, backup_file, null); 182 // if (!backup_file.exists()) { 183 // throw new Error(); 184 // } 185 // } 186 // catch (Exception ex) { 187 // System.err.println("Exception occurred while importing legacy collection."); 188 // System.err.println("Error: Could not backup metadata.xml file to " + backup_file); 189 // ex.printStackTrace(); 190 // System.err.println("Aborting legacy collection import."); 191 // cancelled = true; 192 // return; 193 // } 155 194 156 195 // Parse the metadata.xml file
Note:
See TracChangeset
for help on using the changeset viewer.