Changeset 6026


Ignore:
Timestamp:
2003-11-28T17:39:07+13:00 (20 years ago)
Author:
jmt12
Message:

Changed build complete dialog to a warning dialog, changed it so a cancelled process no longer displays an error dialog, and rewrote makeCollection method so that the email is optional

File:
1 edited

Legend:

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

    r5996 r6026  
    5555import org.greenstone.gatherer.gui.ExternalCollectionPrompt;
    5656import org.greenstone.gatherer.gui.NewMetaSetPrompt;
     57import org.greenstone.gatherer.gui.WarningDialog;
    5758import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    5859import org.greenstone.gatherer.msm.ElementWrapper;
    5960import org.greenstone.gatherer.msm.GDMManager;
    6061import org.greenstone.gatherer.msm.GreenstoneArchiveParser;
     62import org.greenstone.gatherer.msm.LegacyCollectionImporter;
    6163import org.greenstone.gatherer.msm.MetadataSet;
    6264import org.greenstone.gatherer.msm.MetadataSetManager;
     
    799801        collection.cdm = new CollectionDesignManager(new File(collection_file.getParent(), Utility.CONFIG_DIR));
    800802        if (non_gatherer_collection) {
    801         // do a dummy load of GDMManager - so we don't load in the old
    802         // metadata.xml files, we just create new empty ones.
    803         collection.gdm = new GDMManager(true);
    804         if (findAndLoadExistingMetadata(collection_directory)==false) {
    805             lock_file = null;
    806             collection_directory = null;
    807             closeCollection();
    808             return false;
    809         }
    810         } else {
    811         collection.gdm = new GDMManager();
    812         }
     803        // We first recurse the Import folder tree, reading in any metadata.xml files, and then altering the non-namespaced element names to be valid GLI names
     804        LegacyCollectionImporter lci = new LegacyCollectionImporter(collection_directory, collection.cdm);
     805        lci.importMetadata();
     806        lci = null;
     807        }
     808       
     809        // Whether the collection is legacy or not, we should now be able to prepared the GDMManager
     810        collection.gdm = new GDMManager();
    813811       
    814812        // Tell everyone that it worked.
     
    885883
    886884    return true;
    887     }
    888    
    889 
    890     // now try to load in existing metadata, delete the existing metadata.xml files, then save the new ones.
    891     private boolean findAndLoadExistingMetadata(File collection_dir) {
    892 
    893     TreeModel collection_tree = getRecordSet();
    894     FileNode root_node = (FileNode)collection_tree.getRoot();
    895     if (searchForMetadata(collection_tree, root_node)==false) {
    896         return false;
    897     }
    898     removeOldMetadataFiles(collection_dir);
    899     collection.gdm.save(root_node);
    900     return true;
    901     }
    902 
    903     // this moves all the existing metadata files into a back up directory
    904     public void removeOldMetadataFiles(File collection_dir) {
    905     File import_dir = new File(collection_dir, Utility.IMPORT_DIR);
    906     File import_bak_dir = new File(collection_dir, Utility.IMPORT_BAK_DIR);
    907     import_bak_dir.mkdir();
    908 
    909     moveMetadataFiles(import_dir, import_bak_dir);
    910 
    911     }
    912 
    913     private boolean moveMetadataFiles(File source_dir, File dest_dir) {
    914 
    915     // find the metadata file in this dir
    916     File meta_file = new File(source_dir, "metadata.xml");
    917     if (meta_file.exists()) {
    918         File new_meta_file = new File(dest_dir, "metadata.xml");
    919         try {
    920         dest_dir.mkdirs();
    921         if (meta_file.renameTo(new_meta_file)== false) {
    922             throw new Exception("");
    923         }
    924         } catch (Exception e) {
    925         Gatherer.println("Exception: couldn't move the file "+meta_file.getPath() + e.getMessage());
    926         }
    927     }
    928    
    929     // now go through child directories
    930     File [] children = source_dir.listFiles();
    931     for (int i=0; i<children.length; i++) {
    932         File child = children[i];
    933         if (child.isDirectory()) {
    934         moveMetadataFiles(child, new File(dest_dir, child.getName()));
    935         }
    936     }
    937     return true;
    938     }
    939        
     885    }   
    940886
    941887    private boolean searchForMetadata(TreeModel collection_tree, FileNode current_node) {
     
    969915    String command[];
    970916    if(Utility.isWindows()) {
    971         if(description == null || email == null || title == null) {
     917        if(description == null || title == null) {
    972918        command = new String[4];
     919        command[0] = Gatherer.config.perl_path;
     920        command[1] = "-S";
     921        command[2] = Gatherer.config.getScriptPath() + "mkcol.pl";
     922        command[3] = name;
     923        }
     924        // Users are no longer required to supply an email
     925        else if(email == null) {
     926        command = new String[8];
     927        command[0] = Gatherer.config.perl_path;
     928        command[1] = "-S";
     929        command[2] = Gatherer.config.getScriptPath() + "mkcol.pl";
     930        command[3] = "-title";
     931        command[4] = title;
     932        command[5] = "-about";
     933        command[6] = description;
     934        command[7] = name;
    973935        }
    974936        else {
    975937        command = new String[10];
    976         }
    977         command[0] = Gatherer.config.perl_path;
    978         command[1] = "-S";
    979         command[2] = Gatherer.config.getScriptPath() + "mkcol.pl";
    980         if(description == null || email == null || title == null) {
    981         command[3] = name;
    982         }
    983         else {
     938        command[0] = Gatherer.config.perl_path;
     939        command[1] = "-S";
     940        command[2] = Gatherer.config.getScriptPath() + "mkcol.pl";
    984941        command[3] = "-title";
    985942        command[4] = title;
     
    992949    }
    993950    else {
    994         if(description == null || email == null || title == null) {
     951        if(description == null || title == null) {
    995952        command = new String[2];
    996953        command[0] = "mkcol.pl";
    997954        command[1] = name;
     955        }
     956        else if(email == null) {
     957        command = new String[6];
     958        command[0] = "mkcol.pl";
     959        command[1] = "-title";
     960        command[2] = title;
     961        command[3] = "-about";
     962        command[4] = description;
     963        command[5] = name;
    998964        }
    999965        else {
     
    10511017    ///ystem.err.println("Recieved process complete event - " + event);
    10521018    // If we were running an import, now run a build.
    1053     if(event.getType() == GShell.IMPORT && event.getStatus() != GShell.ERROR) {
     1019    if(event.getType() == GShell.IMPORT && event.getStatus() == GShell.OK) {
    10541020        // Finish import.
    10551021        collection.setImported(true);
     
    10571023    }
    10581024    // If we were running a build, now is when we move files across.
    1059     else if(event.getType() == GShell.BUILD && event.getStatus() != GShell.ERROR) {
    1060         ///ystem.err.println("Installing collection.");
     1025    else if(event.getType() == GShell.BUILD && event.getStatus() == GShell.OK) {
    10611026        if(installCollection()) {
    10621027        // 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.");
    10641028        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());
    10671029            Gatherer.self.configServer(GSDLSiteConfig.ADD_COMMAND + collection.getName());
    10681030        }
    1069         //else {
    1070         ///ystem.err.println("GLI can't recognize a local library.");
    1071         //}
    1072         // Signal collection changed.
    1073         // workspace_model = null;
     1031        WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", false);
     1032        collection_built_warning_dialog.display();
     1033        collection_built_warning_dialog.dispose();
     1034        collection_built_warning_dialog = null;
    10741035        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);
    10761036        }
    10771037        else {
Note: See TracChangeset for help on using the changeset viewer.