Changeset 8214


Ignore:
Timestamp:
2004-10-04T15:38:50+13:00 (20 years ago)
Author:
kjdon
Message:

a few changes to do with creating collections. different error if it fails (not the coll can't be previewed error), creates the collect directory if it diesn't exist, and if makeCollection fails, don't continue with the rest of creating a collection, cos then you get the collection opened, but it has no config file

File:
1 edited

Legend:

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

    r8044 r8214  
    327327
    328328    try {
     329        // first make sure that the collect directory exists
     330        File collect_dir = new File(getCollectDirectory());
     331        if (!collect_dir.exists()) {
     332        collect_dir.mkdirs();
     333        }
    329334        // Create a progress monitor.
    330335        ProgressMonitor progress = new ProgressMonitor(Gatherer.g_man, Dictionary.get("CollectionManager.Creating_New"), "mkcol.pl", 0, 7);
    331336        // Create the new collection.
    332337        makeCollection(description, email, name, title);
    333         progress.setProgress(1);
     338       
    334339        // *******************
     340        //check that this creation has worked - simply by checking for the existence of the collect.cfg file
    335341        String a_dir;
    336342        if (Gatherer.GS3) {
     
    339345        a_dir = Utility.getCollectionDir(Gatherer.config.gsdl_path, name);
    340346        }
     347        File config_file = new File(Utility.getConfigFile(a_dir));
     348        if (!config_file.exists()) {
     349        // no point continuing
     350        Gatherer.println("The collection could not be created");
     351        progress.close();
     352        return;
     353        }
     354        progress.setProgress(1);
     355       
    341356        // ACTIVE_DIR/log/
    342357        File log_dir_temp = new File(Utility.getLogDir(a_dir)+"temp.dat");
     
    11231138    }
    11241139    GShell process = new GShell(command, GShell.NEW, COLLECT, this, null, GShell.GSHELL_NEW);
    1125     process.addGShellListener(this);
    11261140    process.run(); // Don't bother threading this... yet
    1127        
    11281141    }
    11291142
     
    12001213    else if(event.getStatus() == GShell.ERROR || event.getStatus() == GShell.CANCELLED) {
    12011214        Gatherer.println("There was an error in the gshell:"+ event.getMessage());
    1202         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
    1203         Gatherer.g_man.collectionChanged(ready());
     1215        if (event.getType() == GShell.NEW) {
     1216        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Create_Collection"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     1217        } else {
     1218        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
     1219        Gatherer.g_man.collectionChanged(ready());
     1220        }
     1221       
    12041222        Gatherer.g_man.repaint(); // It appears Java's own dialogs have the same not always painting correct area bug that I suffer from. Well I don't suffer from it personally, but my ModalDialog components do.
    12051223    }
Note: See TracChangeset for help on using the changeset viewer.