Changeset 22358


Ignore:
Timestamp:
07/06/10 15:36:14 (11 years ago)
Author:
kjdon
Message:

.col file now called gli.col, not collname.col. This means that collections can be renamed and will still open in GLI (although any saved settings in .col file will not be used). If gli.col doesn't exist, look for a collname.col and rename it (for legacy colls). Can now open non-GLI collections. Don't do the scheduling update unless the coll file exists otherwise GLI craps out.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r21880 r22358  
    581581
    582582        // Now create the collection object around the directory.
    583         collection = new Collection(new File(collection_directory_path, name + ".col"));
     583        collection = new Collection(new File(collection_directory_path, "gli.col"));
    584584
    585585        // for remote case, scheduling causes an Exception on creating a new collection that
     
    884884    static public String getLoadedCollectionColFilePath()
    885885    {
    886     return getLoadedCollectionDirectoryPath() + collection.getName() + ".col";
     886    return getLoadedCollectionDirectoryPath() + "gli.col";
    887887    }
    888888
     
    11841184    DebugStream.println("Loading collection " + location + "...");
    11851185
    1186     if (Gatherer.isGsdlRemote) {
    1187         String collection_name = location.substring(location.lastIndexOf(File.separator) + 1, location.length() - ".col".length());
    1188         if (Gatherer.remoteGreenstoneServer.downloadCollection(collection_name).equals("")) {
    1189         return;
    1190         }
    1191     }
    11921186
    11931187    // Check we have actually been given a .col file.
     
    11971191        return;
    11981192    }
    1199 
     1193   
    12001194    // Check that the collection configuration file is available
    12011195    File collection_file = new File(location);
    12021196
    1203     // Ensure that the directory exists
    12041197    File collection_directory = collection_file.getParentFile();
    1205        
     1198    String collection_name = collection_directory.getName();
     1199
     1200    if (Gatherer.isGsdlRemote) {
     1201        if (Gatherer.remoteGreenstoneServer.downloadCollection(collection_name).equals("")) {
     1202        return;
     1203        }
     1204    }
     1205   
     1206    // Ensure that the collection directory exists
    12061207    if (collection_directory == null || !collection_directory.exists()) {
    12071208        // We can't open this
     
    12441245
    12451246    // Now determine if a lock already exists on this collection.
    1246     String collection_name = collection_directory.getName();
    12471247    File lock_file = new File(collection_file.getParentFile(), LOCK_FILE);
    12481248    if (lock_file.exists()) {
     
    12611261
    12621262        lock_file.delete();
     1263    }
     1264
     1265    // now we are using gli.col - old colls may have used the collection name
     1266    if (!collection_file.exists()) {
     1267      File old_coll_file = new File(collection_directory, collection_name+".col");
     1268      if (old_coll_file.exists()) {
     1269        try {
     1270          old_coll_file.renameTo(collection_file);
     1271        } catch (Exception e) {
     1272          DebugStream.println("Couldn't rename "+old_coll_file.getName()+" to gli.col. Will just carry on with default gli.col");
     1273          // but just carry on.
     1274        }
     1275      }
    12631276    }
    12641277
     
    12831296        }
    12841297       
    1285         if (canDoScheduling()) {
    1286         //THIS LOOKS LIKE THE BEST PLACE TO TRY AND UPDATE .col FILES FOR EXISTING COLLECTIONS...Wendy
    1287  
     1298        // need to fix this up as currently it craps out if the .col file is not there, which is may not always be.
     1299        if (canDoScheduling() && collection_file.exists()) {
     1300          //THIS LOOKS LIKE THE BEST PLACE TO TRY AND UPDATE .col FILES FOR EXISTING COLLECTIONS...Wendy
     1301          // Don't need to update anything if collection_file doesn't exist yet.
    12881302        //First, see if "Schedule" exists in the XMl File...
    12891303        BufferedReader bir = new BufferedReader(new FileReader(collection_file));
Note: See TracChangeset for help on using the changeset viewer.