Changeset 19041


Ignore:
Timestamp:
2009-04-17T19:44:48+12:00 (15 years ago)
Author:
ak19
Message:

The PreviewButton's response had not been updated to load the page of a collection if this was nested in a collectiongroup. Adjusted relevant classes to make the PreviewButton work in the collection group case as well.

Location:
gli/trunk/src/org/greenstone/gatherer
Files:
3 edited

Legend:

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

    r18945 r19041  
    182182    public String getName() {
    183183    return file.getParentFile().getName();
     184    }
     185
     186    /** @return just the name of the collection group if any, else returns "" */
     187    public String getCollectionGroupName() {
     188    String groupAndColName = getGroupWithName(true);
     189
     190    int slash = groupAndColName.indexOf('/');
     191    if(slash == -1) {
     192        return "";
     193    } else { // remove the colName from the end, to get the groupName
     194        return groupAndColName.substring(0, slash);
     195    }
     196    }
     197
     198    /**
     199     * If the collection is part of a collection group, returns the
     200     * colgroupname/colname, else returns the colname.
     201     * If url = true, then returns the sub-path as a URL (containing / only),
     202     * and if url = false, then the sub-path is returned in filepath form
     203     * (\ or /, depending on the OS).
     204     * @return collection-group-name/collection-name
     205     */
     206    public String getGroupWithName(boolean url) {
     207    // Subtracting collect dir's path from the current collection's path
     208
     209    String groupAndCol;
     210    String collectDir = Gatherer.getCollectDirectoryPath();
     211    String currentCollDir = file.getParentFile().getAbsolutePath();
     212   
     213    if(currentCollDir.startsWith(collectDir)) {
     214        groupAndCol = currentCollDir.substring(collectDir.length());       
     215    } else {
     216        // shouldn't happen, but in case it does, just return the collection name.
     217        System.err.println("Current collection " + currentCollDir + " is not located inside collectdir " + "collectDir");
     218        groupAndCol = getName();
     219    }
     220
     221    if(url) {
     222        groupAndCol = groupAndCol.replace('\\', '/');
     223    }
     224
     225    return groupAndCol;
    184226    }
    185227   
  • gli/trunk/src/org/greenstone/gatherer/collection/CollectionManager.java

    r18948 r19041  
    916916    }
    917917
     918    /** Returns the "collectionGroupName/collectionName" or just the collectionName
     919     *  depending on whether the collection is part of a collection group or not.
     920     * If url = true, then returns the sub-path as a URL (containing / only),
     921     * and if url = false, then the sub-path is returned in filepath form
     922     * (\ or /, depending on the OS).
     923     */
     924    static public String getLoadedColNameWithGroup(boolean url)
     925    {
     926    if (collection != null) {
     927        return collection.getGroupWithName(url);
     928    }
     929
     930    return null;
     931    }
    918932
    919933    public CollectionTree getCollectionTree()
  • gli/trunk/src/org/greenstone/gatherer/gui/PreviewButton.java

    r18987 r19041  
    7474    }
    7575    protected void configureHomeURL() {
     76    // we could be working with standalone collections or collection groups
     77    // so getting a collection-name may have a collection group prefix
     78    // This means CollectionManager.getLoadedCollectionName() is no longer sufficient
     79    String collGroupWithName = CollectionManager.getLoadedColNameWithGroup(true);
     80
    7681    // set up the home page for the current collection
    7782    if (Gatherer.GS3 && !Configuration.fedora_info.isActive()) { // GLI for GS3 case
    7883        // don't do anything fancy here
    79         preview_address = Configuration.library_url.toString() + Configuration.getServletPath() + "?a=p&sa=about&c=" + CollectionManager.getLoadedCollectionName() + "&l=" + Configuration.getLanguage();
     84        preview_address = Configuration.library_url.toString() + Configuration.getServletPath()
     85        + "?a=p&sa=about&c=" + collGroupWithName + "&l=" + Configuration.getLanguage();
    8086        return;
    8187    }
     
    8692   
    8793    // FLI or GLI for GS2 case (no library_url)
    88     preview_address = Configuration.library_url.toString() + "?c=" + CollectionManager.getLoadedCollectionName() + "&l=" + Configuration.getLanguage();
     94    preview_address = Configuration.library_url.toString() + "?c=" + collGroupWithName + "&l=" + Configuration.getLanguage();
    8995
    9096    String main_args = "&a=p&p=about";
Note: See TracChangeset for help on using the changeset viewer.