Changeset 22771 for main


Ignore:
Timestamp:
2010-08-24T19:49:00+12:00 (14 years ago)
Author:
ak19
Message:

More changes for ticket 152: making the collectdir moveable. When using server.exe, if GLI was last shutdown when another collectdir was active, this needs to be read in from the user config.xml by GLI, and server.exe needs to use it.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
4 edited

Legend:

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

    r22691 r22771  
    708708    }
    709709
    710     /** Returns the path of the Greenstone "collect" directory. */
     710    /** Returns the path of the current collect directory. */
    711711    static public String getCollectDirectoryPath()
    712712    {
     
    714714        return non_standard_collect_directory_path;
    715715    }
    716 
    717     if (!GS3) {
    718         return Configuration.gsdl_path + "collect" + File.separator;
    719     }
    720     else {
    721         return getSitesDirectoryPath() + Configuration.site_name + File.separator + "collect" + File.separator;
    722     }
    723     }
    724 
     716   
     717    return getDefaultGSCollectDirectoryPath();
     718   
     719    }
     720
     721    /** Returns the path of the Greenstone "collect" directory. */
     722    static public String getDefaultGSCollectDirectoryPath() {
     723        if (!GS3) {
     724            return Configuration.gsdl_path + "collect" + File.separator;
     725        }
     726        else {
     727            return getSitesDirectoryPath() + Configuration.site_name + File.separator + "collect" + File.separator;
     728        }
     729    }   
    725730
    726731    /** Returns the path of the GLI directory. */
     
    833838    // non-destructive update of gsdl(3)site.cfg (comments preserved)
    834839    String collectDir = Gatherer.getCollectDirectoryPath();
     840    //collectDir = "\"" + collectDir.substring(0, collectDir.length()-1) + "\""; // remove file separator at end   
    835841    collectDir = collectDir.substring(0, collectDir.length()-1); // remove file separator at end   
    836842    Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", collectDir);
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java

    r20447 r22771  
    410410       
    411411    // If we're using the Local Library we must release the collection before writing to the collect.cfg file
    412     String collection_name = CollectionManager.getLoadedCollectionName ();
     412    String collection_name = CollectionManager.getLoadedCollectionName (false); // url style slash
    413413    boolean collection_released = false;
    414414    if (Gatherer.c_man.built () && LocalLibraryServer.isRunning () == true) {
  • main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r22678 r22771  
    425425
    426426    // If we're using the Local Library we must release the collection before writing to the collect.cfg file
    427     if(Gatherer.isLocalLibrary) {
    428         LocalLibraryServer.releaseCollection(collection.getName());
     427    if(Gatherer.isLocalLibrary) {       
     428        LocalLibraryServer.releaseCollection(getLoadedCollectionName()); // URL style slash //collection.getName());
    429429    }
    430430   
     
    18501850        // Ensure that the local library has released this collection so we can delete the index directory
    18511851        if (LocalLibraryServer.isRunning() == true) {
    1852         LocalLibraryServer.releaseCollection(collection.getName());
     1852        LocalLibraryServer.releaseCollection(getLoadedCollectionName()); // URL style slash //collection.getName());
    18531853        }
    18541854        // deactivate it in tomcat so that windows will release the index files
  • main/trunk/gli/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java

    r22678 r22771  
    162162    }
    163163
    164 
     164    /** collection name can be a group-qualified collect name */
    165165    static public void releaseCollection(String collection_name)
    166166    {
     
    693693        useGLISiteCfg(server_exe);
    694694        }
     695       
     696        // We're in the constructor, so we'll be running the LLS the first time,  if we're
     697        // running *server.exe* and if the current collect dir at Local Lib's startup is
     698        // anything other than the default GS collect dir, then use that:
     699        if (isPersistentServer) { // server.exe, so we're dealing with a local GS2
     700            String collectDir = Configuration.getString("general.open_collection_gs2", true);
     701
     702            // If opening a collection outside the standard GS collect folder, need
     703            // to open the non-standard collect folder that the collection resides in
     704            if (!collectDir.startsWith(Gatherer.getDefaultGSCollectDirectoryPath())) {
     705                File collectFolder = null;
     706                if(!collectDir.endsWith("gli.col")) { // then it's a collect folder
     707                    collectFolder = new File(collectDir);
     708                } else {
     709                    // the filepath is a gli.col file. To get the collect folder: the 1st level
     710                    // up is collection folder, 2 two levels up is the containing collect folder
     711                    collectFolder = new File(collectDir).getParentFile().getParentFile();
     712                }
     713
     714                // Need to deal with colgroups as well: while there's an etc/collect.cfg in the current
     715                // collectFolder, move one level up
     716                if(new File(collectFolder.getAbsolutePath()+File.separator+Utility.CONFIG_FILE).exists()) {
     717                    collectFolder = collectFolder.getParentFile();             
     718                }   
     719                collectDir = collectFolder.getAbsolutePath();               
     720               
     721                // write out the non-standard collectDir (minus file separator at end) to the lls site conf
     722                // file being used
     723                if(collectDir.endsWith(File.separator)) {
     724                    collectDir = collectDir.substring(0, collectDir.length());
     725                }
     726                put(COLLECTHOME, collectDir);
     727                save();
     728                lastModified = configFile.lastModified();
     729            }
     730        } // now the correct current collect dir will get loaded when the server is started up hereafter       
    695731    }
    696732
     
    9761012       
    9771013            // write out the line
    978             out.write(line + "\n");
     1014            out.write(line);
     1015            out.newLine();
    9791016        }
    9801017       
Note: See TracChangeset for help on using the changeset viewer.