Changeset 4805


Ignore:
Timestamp:
2003-06-25T14:41:54+12:00 (21 years ago)
Author:
jmt12
Message:

bug#2030158: GLI now recognizes old greenstone collections and then, rather than try and load them which it wasn't so good at, shows a dialog explaining what the user should do instead.

File:
1 edited

Legend:

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

    r4799 r4805  
    753753        File collection_directory = collection_file.getParentFile();
    754754        if(collection_directory.exists()) {
    755         String name = collection_directory.getName();
    756         File lock_file = new File(collection_file.getParentFile(), LOCK_FILE);
    757         // Now determine if a lock already exists on this collection.
    758         int choice = LockFileDialog.YES_OPTION;
    759         if(lock_file.exists()) {
    760             LockFileDialog dialog = new LockFileDialog(Gatherer.g_man, name, lock_file);
    761             choice = dialog.getChoice();
    762             dialog.dispose();
    763             dialog = null;
    764         }
    765         if(choice == LockFileDialog.YES_OPTION) {
    766             try {
    767             if(lock_file.exists()) {
    768                 lock_file.delete();
     755        // Special case of a user trying to open an old greenstone collection. One day this will be supported, but for now complain, and explain how to actually re-build this collection
     756        File metadata_directory = new File(collection_directory, Utility.META_DIR);
     757        if(!metadata_directory.exists()) {
     758            JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Old_Collection", args2), get("General.Warning"), JOptionPane.INFORMATION_MESSAGE);
     759        }
     760        // Normal GLI collection
     761        else {
     762            String name = collection_directory.getName();
     763            File lock_file = new File(collection_file.getParentFile(), LOCK_FILE);
     764            // Now determine if a lock already exists on this collection.
     765            int choice = LockFileDialog.YES_OPTION;
     766            if(lock_file.exists()) {
     767            LockFileDialog dialog = new LockFileDialog(Gatherer.g_man, name, lock_file);
     768            choice = dialog.getChoice();
     769            dialog.dispose();
     770            dialog = null;
     771            }
     772            if(choice == LockFileDialog.YES_OPTION) {
     773            try {
     774                if(lock_file.exists()) {
     775                lock_file.delete();
     776                }
     777                // Create a lock file.
     778                createLockFile(lock_file);
     779                // Open the collection file
     780                collection = new Collection(collection_file);
     781                ///ystem.err.println("In CollectionManager::loadCollection(), collection: " + collection);
     782                collection.msm = new MetadataSetManager();
     783                msm = collection.msm; // Legacy
     784                collection.msm.load();
     785                collection.cdm = new CollectionDesignManager();
     786                collection.gdm = new GDMManager();
     787                // Tell everyone that it worked.
     788                Gatherer.println(get("Loading_Successful", name));
     789                // Now we need to hook up classes that depend on messages from the metadata set manager to keep their content fresh.
     790                collection.msm.addMSMListener(this);
     791                // We're done. Let everyone know.
     792                if(Gatherer.g_man != null) {
     793                workspace_model = null;
     794                Gatherer.g_man.collectionChanged(ready());
     795                }
     796                result = true;
     797                ///ystem.err.println("Done loadCollection().");
     798            } catch (Exception error) {
     799                // There is obviously no existing collection present.
     800                Gatherer.printStackTrace(error);
     801                JOptionPane.showMessageDialog(Gatherer.g_man, get("Cannot_Open", args2), get("General.Error"), JOptionPane.ERROR_MESSAGE);
    769802            }
    770             // Create a lock file.
    771             createLockFile(lock_file);
    772             // Open the collection file
    773             collection = new Collection(collection_file);
    774             ///ystem.err.println("In CollectionManager::loadCollection(), collection: " + collection);
    775             collection.msm = new MetadataSetManager();
    776             msm = collection.msm; // Legacy
    777             collection.msm.load();
    778             collection.cdm = new CollectionDesignManager();
    779             collection.gdm = new GDMManager();
    780             // Tell everyone that it worked.
    781             Gatherer.println(get("Loading_Successful", name));
    782             // Now we need to hook up classes that depend on messages from the metadata set manager to keep their content fresh.
    783             collection.msm.addMSMListener(this);
    784             // We're done. Let everyone know.
    785             if(Gatherer.g_man != null) {
    786                 workspace_model = null;
    787                 Gatherer.g_man.collectionChanged(ready());
    788             }
    789             result = true;
    790             ///ystem.err.println("Done loadCollection().");
    791             } catch (Exception error) {
    792             // There is obviously no existing collection present.
    793             Gatherer.printStackTrace(error);
    794             JOptionPane.showMessageDialog(Gatherer.g_man, get("Cannot_Open", args2), get("General.Error"), JOptionPane.ERROR_MESSAGE);
    795             }
    796         }
    797         lock_file = null;
     803            }
     804            lock_file = null;
     805        }
    798806        }
    799807        else {
Note: See TracChangeset for help on using the changeset viewer.