- Timestamp:
- 2002-10-04T11:30:37+12:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSFile.java
r3386 r3440 29 29 30 30 /** 31 * GSFile s- utility class for Greenstone.32 * 33 * contains File creation methods.31 * GSFile - utility class for Greenstone. 32 * 33 * all file paths are created here 34 34 * 35 35 * @author <a href="mailto:[email protected]">Katherine Don</a> … … 37 37 * @see File 38 38 */ 39 39 40 public class GSFile { 40 41 41 /** creates a File for the site config file*/42 static public FilesiteConfigFile(String site_home) {43 return new File(site_home + File.separatorChar+"sitecfg.xml");44 45 } 46 47 /** c reates a File for the collection directory*/48 static public File collectDirFile(String site_home) {49 return new File(site_home+File.separatorChar+"collect");42 /** site config file path */ 43 static public String siteConfigFile(String site_home) { 44 return site_home + File.separatorChar+"sitecfg.xml"; 45 46 } 47 48 /** collection directory path */ 49 static public String collectDir(String site_home) { 50 return site_home+File.separatorChar+"collect"; 50 51 } 51 52 52 53 53 /** c reates a File for the collection config file*/54 static public FilecollectionConfigFile(String site_home,55 String collection_name) {56 return new File(site_home+File.separatorChar+"collect"+54 /** collection config file path*/ 55 static public String collectionConfigFile(String site_home, 56 String collection_name) { 57 return site_home+File.separatorChar+"collect"+ 57 58 File.separatorChar+collection_name+ 58 59 File.separatorChar+"etc"+ 59 File.separatorChar+"collectcfg.xml" );60 61 } 62 63 /** c reates a File for the collection build config file*/64 static public FilecollectionBuildConfigFile(String site_home,65 String collection_name ) {66 return new File(site_home+File.separatorChar+"collect"+60 File.separatorChar+"collectcfg.xml"; 61 62 } 63 64 /** collection build config file path*/ 65 static public String collectionBuildConfigFile(String site_home, 66 String collection_name ) { 67 return site_home+File.separatorChar+"collect"+ 67 68 File.separatorChar+collection_name+ 68 69 File.separatorChar+"index"+ 69 File.separatorChar+"buildcfg.xml" );70 } 71 72 /** returns the directory for XML Transforms*/73 static public String xmlTransformDir(String gsdl_home) {74 return gsdl_home+File.separatorChar+"transform";75 } 76 77 /** returns the base directory name for a collection*/70 File.separatorChar+"buildcfg.xml"; 71 } 72 73 /** XML Transform directory path */ 74 static public String xmlTransformDir(String interface_home) { 75 return interface_home+File.separatorChar+"transform"; 76 } 77 78 /** collection base directory path */ 78 79 static public String collectionBaseDir(String site_home, 79 80 String collection_name) { … … 82 83 } 83 84 84 /** returns thetext path (for doc retrieval) relative to collectionBaseDir */85 /** text path (for doc retrieval) relative to collectionBaseDir */ 85 86 static public String collectionTextPath(String collection_name) { 86 87 return "index"+File.separatorChar+"text"+File.separatorChar+ … … 88 89 } 89 90 90 /** returns theindex path (for querying) relative to collectionBaseDir */91 /** index path (for querying) relative to collectionBaseDir */ 91 92 static public String collectionIndexPath(String collection_name, 92 93 String index_name) { … … 95 96 } 96 97 97 /** returns anabsolute path for an associated file */98 /** absolute path for an associated file */ 98 99 static public String assocFileAbsolutePath(String site_home, 99 100 String collection_name, … … 108 109 /** returns the absolute path to a stylesheet 109 110 * stylesheets are looked for in the following order 110 * site-specific, ui specific, default 111 * returns null if the file cannot be found*/ 112 /* static public String stylesheetPath(String gsdl_home, String display_home, 113 String site_home, String filename) { 114 115 // try site one first 116 File stylesheet = new File(site_home+File.separatorChar+"transform"+ 117 File.separatorChar+filename); 118 if (stylesheet.exists()) { 119 return stylesheet.getPath(); 120 } 121 // try custom display 122 stylesheet = new File(display_home+File.separatorChar+"transform"+ 123 File.separatorChar+filename); 124 if (stylesheet.exists()) { 125 return stylesheet.getPath(); 126 } 127 // return the default one - should we check that it exists here? 128 stylesheet = new File(gsdl_home+File.separatorChar+"transform"+ 129 File.separatorChar+filename); 130 if (stylesheet.exists()) { 131 return stylesheet.getPath(); 132 } 133 134 // cant find it 135 return null; 136 } 137 */ 138 139 140 static public String stylesheetPath(ConfigVars config, String filename) { 111 * site-specific, interface-specific, default 112 * returns null if the file cannot be found */ 113 static public String stylesheetFile(ConfigVars config, String filename) { 141 114 // try site one first 142 115 File stylesheet = new File(config.sites_home_+File.separatorChar+ … … 146 119 return stylesheet.getPath(); 147 120 } 148 // try cu stom display121 // try current interface 149 122 stylesheet = new File(config.interfaces_home_+File.separatorChar+ 150 123 config.interface_name_+File.separatorChar+ … … 153 126 return stylesheet.getPath(); 154 127 } 155 // return the default one - should we check that it exists here?128 // try default interface 156 129 stylesheet = new File(config.interfaces_home_+File.separatorChar+ 157 130 "default"+File.separatorChar+ … … 164 137 return null; 165 138 } 139 140 141 /** language specific files directory */ 142 public static String translateFile(ConfigVars config, String lang) { 143 144 return config.interfaces_home_+File.separatorChar+ 145 "translate"+File.separatorChar+lang+".xml"; 146 } 147 /** base directory for phind data */ 148 public static String phindBaseDir(String site_home, String coll_name, 149 String phind_index) { 150 return site_home + File.separatorChar + 151 "collect" + File.separatorChar + 152 coll_name + File.separatorChar + 153 "index" + File.separatorChar + 154 "phind"+phind_index; 155 } 156 157 /** the gdbm database file - 158 * note, need to change extension depending on OS */ 159 static public String GDBMDatabaseFile(String site_home, 160 String collection_name) { 161 162 return site_home + File.separatorChar + 163 "collect" + File.separatorChar + 164 collection_name + File.separatorChar + 165 "index" + File.separatorChar + "text" + File.separatorChar + 166 collection_name + ".ldb"; 167 168 } 169 170 // some file utility methods 171 172 /** read in a file and encode it using base64 173 * encoded data returned as a String */ 166 174 static public String base64EncodeFromFile(String in_filename) { 167 175 byte [] data=null; … … 175 183 176 184 } 185 186 /** decode some base64 data, and write it to the specified file */ 177 187 static public boolean base64DecodeToFile(String data, String out_filename) { 178 188 try { … … 188 198 } 189 199 200 /** read in a file to a byte array */ 190 201 public static byte[] readFile(String filename) throws IOException { 191 202 File file = new File(filename); … … 198 209 return buffer; 199 210 } 211 212 /** write a byte array to a file */ 200 213 public static void writeFile(byte [] buffer, String filename) throws IOException { 201 214 File file = new File(filename); … … 206 219 } 207 220 208 // this assumes that lang stuff is in its own directory -209 //interfaces_home/translate210 public static String getLangPath(ConfigVars config, String lang) {211 212 return config.interfaces_home_+File.separatorChar+213 "translate"+File.separatorChar+lang+".xml";214 }215 216 public static File getLangFile(ConfigVars config, String lang) {217 218 return new File(config.interfaces_home_+File.separatorChar+219 "translate"+File.separatorChar+lang+".xml");220 }221 222 public static String phindBasePath(String site_home, String coll_name,223 String phind_index) {224 return site_home + File.separatorChar +225 "collect" + File.separatorChar +226 coll_name + File.separatorChar +227 "index" + File.separatorChar +228 "phind"+phind_index;229 }230 231 221 }
Note:
See TracChangeset
for help on using the changeset viewer.