Changeset 5996


Ignore:
Timestamp:
2003-11-25T16:23:23+13:00 (20 years ago)
Author:
jmt12
Message:

Made several changes to the way collections are opened - thus to create a more consistant state when things go wrong. For instance opening a collection with a corrupt or missing collect.cfg no longer provides the user with a seemingly working gli bar a title of #ERROR... oh and a nasty trick of crashing when you try to save your past hours worth of work ;P

File:
1 edited

Legend:

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

    r5893 r5996  
    544544    return Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator + collection.getName() + ".col";
    545545    }
     546    /** Constructs the absolute filename of the collection images directory, which should resemble "$GSDLHOME/collect/<col_name>/images/"
     547     * @return A <strong>String</strong> containing the filename.
     548     * @see org.greenstone.gatherer.Configuration
     549     * @see org.greenstone.gatherer.Gatherer
     550     * @see org.greenstone.gatherer.collection.Collection
     551     * @see org.greenstone.gatherer.util.Utility
     552     */
     553    public String getCollectionImages() {
     554    return Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator + StaticStrings.IMAGES_FOLDER;
     555    }
    546556    /** Constructs the absolute filename of the collection import directory, which should resemble "$GSDLHOME/collect/&lt;col_name&gt;/import/"
    547557     * @return A <strong>String</strong> containing the filename.
     
    717727        return false;
    718728    }
     729    // Check that there is the collection configuration file available
     730
    719731    File collection_file = new File(location);
    720732    // Ensure that the directory exists.
     
    761773        // Open the collection file
    762774        collection = new Collection(collection_file);
     775        if(collection.getTitle().equals(StaticStrings.ERROR_STR)) {
     776        collection = null;
     777        // Remove lock file
     778        if(lock_file.exists()) {
     779            lock_file.delete();
     780        }
     781        throw(new Exception(Dictionary.get("CollectionManager.Missing_Config")));
     782        }
     783
    763784        collection.msm = new MetadataSetManager();
    764785        msm = collection.msm; // Legacy
     
    807828        // There is obviously no existing collection present.
    808829        Gatherer.printStackTrace(error);
    809         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Open", args2), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     830        if(error.getMessage() != null) {
     831        String[] args = new String[2];
     832        args[0] = args2[0];
     833        args[1] = error.getMessage();
     834        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Open_With_Reason", args), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     835        }
     836        else {
     837        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Open", args2), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     838        }
    810839    }
    811840   
     
    10231052    // If we were running an import, now run a build.
    10241053    if(event.getType() == GShell.IMPORT && event.getStatus() != GShell.ERROR) {
    1025                 // Finish import.
     1054        // Finish import.
    10261055        collection.setImported(true);
    10271056        buildCollection();
     
    10291058    // If we were running a build, now is when we move files across.
    10301059    else if(event.getType() == GShell.BUILD && event.getStatus() != GShell.ERROR) {
    1031                 ///ystem.err.println("Installing collection.");
    1032         installCollection();
    1033         // If we have a local library running (that we know about) then we ask it to add our newly create collection
    1034         ///ystem.err.println("Check if we should reset local server.");
    1035         if(Gatherer.config.exec_file != null) {
    1036         ///ystem.err.println("Local Library Found!");
    1037         //Gatherer.g_man.preview_pane.configServer(GSDLSiteConfig.ADD_COMMAND + collection.getName());
    1038         Gatherer.self.configServer(GSDLSiteConfig.ADD_COMMAND + collection.getName());
    1039         }
    1040         //else {
    1041         ///ystem.err.println("GLI can't recognize a local library.");
    1042         //}
    1043         // Signal collection changed.
    1044         // workspace_model = null;
    1045         Gatherer.g_man.collectionChanged(ready());
    1046         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE);
     1060        ///ystem.err.println("Installing collection.");
     1061        if(installCollection()) {
     1062        // If we have a local library running (that we know about) then we ask it to add our newly create collection
     1063        ///ystem.err.println("Check if we should reset local server.");
     1064        if(Gatherer.config.exec_file != null) {
     1065            ///ystem.err.println("Local Library Found!");
     1066            //Gatherer.g_man.preview_pane.configServer(GSDLSiteConfig.ADD_COMMAND + collection.getName());
     1067            Gatherer.self.configServer(GSDLSiteConfig.ADD_COMMAND + collection.getName());
     1068        }
     1069        //else {
     1070        ///ystem.err.println("GLI can't recognize a local library.");
     1071        //}
     1072        // Signal collection changed.
     1073        // workspace_model = null;
     1074        Gatherer.g_man.collectionChanged(ready());
     1075        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE);
     1076        }
     1077        else {
     1078        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
     1079        Gatherer.g_man.collectionChanged(ready());
     1080        }
    10471081    }
    10481082    else if(event.getStatus() == GShell.ERROR) {
     
    11971231     * @see org.greenstone.gatherer.util.Utility
    11981232     */
    1199     private void installCollection() {
     1233    private boolean installCollection() {
    12001234    Gatherer.println("Build complete. Moving files.");
    12011235
     
    12681302    catch (Exception exception) {
    12691303        JOptionPane.showMessageDialog(Gatherer.g_man, "Exception detected during collection install.\nMost likely caused by Windows or Local Library holding locks on files:\n" + exception.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    1270     }
     1304        return false;
     1305    }
     1306    return true;
    12711307    }
    12721308
Note: See TracChangeset for help on using the changeset viewer.