Ignore:
Timestamp:
2010-08-11T21:28:34+12:00 (14 years ago)
Author:
ak19
Message:

Ticket #152: Allowing different paths to collect dir so that GLI can work with collect dirs on pen drives. NONE OF THESE CHANGES ARE FOR Client-GLI AS YET. 1. Preferences (Connection tab), Open and New Collection dialogs allow one to change the current collect directory containing the collections to select from. 2. New Collection dialog allows one to base a new collection on an existing collection in a collect dir other than the current collect dir. 3. Collections in the Documents in Greenstone Collections Workspace Tree Node now have two additional rightclick options: to move and copy these collections to another location.

File:
1 edited

Legend:

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

    r21965 r22605  
    497497        if (no_load || open_collection_file_path.equals("")) {
    498498        open_collection_file_path = null;
    499         }
     499        //      collectDirectoryHasChanged(); // make sure gsdlsite.cfg's collecthome defaults to GS' collect
     500        }
     501
     502        // If opening a collection outside the standard GS collect folder, need
     503        // to open the non-standard collect folder that the collection resides in
     504        if (open_collection_file_path != null &&
     505        !open_collection_file_path.startsWith(getCollectDirectoryPath())) {
     506        File collectFolder = null;
     507        if(!open_collection_file_path.endsWith("gli.col")) { // then it's a collect folder
     508            collectFolder = new File(open_collection_file_path);
     509        } else {
     510            // the filepath is a gli.col file. To get the collect folder: the 1st level
     511            // up is collection folder, 2 two levels up is the containing collect folder
     512            collectFolder = new File(open_collection_file_path).getParentFile().getParentFile();
     513        }
     514
     515        // Need to deal with colgroups as well: while there's an etc/collect.cfg in the current
     516        // collectFolder, move one level up
     517        String cfg_file = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE;
     518        if(new File(collectFolder.getAbsolutePath()+File.separator+cfg_file).exists()) { // colgroup
     519            collectFolder = collectFolder.getParentFile();
     520           
     521        }
     522        setCollectDirectoryPath(collectFolder.getAbsolutePath()); // now set this as the current collect folder
     523        }
     524       
    500525    }
    501526    catch (Exception exception) {
     
    761786        System.err.println("Error: Unable to make directory: " + gli_user_directory);
    762787    }
     788    }
     789
     790
     791    public static void collectDirectoryHasChanged(String oldCollectPath, String newCollectPath) {
     792    if(oldCollectPath.equals(newCollectPath)) {
     793        return; // nothing to be done
     794    }
     795
     796    // first save any open collection in the *old* location
     797    if(Gatherer.c_man.getCollection() != null) {
     798        Gatherer.setCollectDirectoryPath(oldCollectPath); // go back to current collection's location
     799        Gatherer.g_man.saveThenCloseCurrentCollection(); // close the current collection first
     800    }
     801   
     802    // change to new collect path
     803    Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(),
     804                true, newCollectPath);
     805    Gatherer.setCollectDirectoryPath(newCollectPath);
     806   
     807
     808    // refresh the Documents in Greenstone Collections
     809    //WorkspaceTreeModel.refreshGreenstoneCollectionsNode();
     810    Gatherer.g_man.refreshWorkspaceTreeGreenstoneCollections();
     811   
     812    // The web server needs to be told where a new (non-standard) collecthome home is.
     813    // The web server reads collecthome from cgi-bin/gsdlsite.cfg, where the property
     814    // collecthome can be specified if a non-standard collecthome is to be used. If no
     815    // such property is specified in the file, then it assumes the standard GS collecthome.
     816    // This method does nothing for a remote Greenstone.   
     817    if(Gatherer.isGsdlRemote) {
     818        return;
     819    }   
     820
     821    String gsdlsitecfg = "";
     822    if(Gatherer.GS3) { // web/WEB-INF/cgi/gsdl3site.cfg
     823        gsdlsitecfg = Configuration.gsdl3_path + File.separator + "WEB-INF"
     824        + File.separator + "cgi" + File.separator + "gsdl3site.cfg";
     825    } else { // cgi-bin/gsdlsite.cfg
     826        gsdlsitecfg = Configuration.gsdl_path + File.separator
     827        + "cgi-bin" + File.separator + "gsdlsite.cfg";
     828    }
     829
     830    // non-destructive update of gsdl(3)site.cfg (comments preserved)
     831    Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", Gatherer.getCollectDirectoryPath());
    763832    }
    764833
Note: See TracChangeset for help on using the changeset viewer.