Changeset 22410 for main/trunk


Ignore:
Timestamp:
2010-07-15T22:10:59+12:00 (14 years ago)
Author:
ak19
Message:

Getting collectgroup to work for a remote Greenstone server. Need to update gliserver.pl still to work with the collectgroup changes. 1. GLI side changes: no longer does the collectdir parameter to import and build include the colgroup at the end, it is now back to being everything upto the GS collect dir. Instead, the loaded collection is colgroup/subcolname. 2. Changed CollectionManager.getLoadedCollectionName() to return (colgroup/)subcolname instead of the subcolname excluding groupname. 3. This required changes in other classes, including replacing unnecessary explicit calls to getLoadedGroupQualifiedCollectionName(). 4. Added another variant: getLoadedCollectionName(boolean). If the parameter is true, it will put a url style slash between colgroup and subcolname, otherwise use the OS dependent FileSeparator. 5. Changes to RemoteGreenstoneServer to pass the group/subcol as the collectionname to gliserver.pl, with a vertical bar separator. 6. Minor changes like: WorkspaceTreeNode now knows not to load a collection group if it's already in the loaded collection (previously handed only sub collection name), removed old debugging statements and unused import statements.

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

Legend:

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

    r18571 r22410  
    4444import org.greenstone.gatherer.gui.GComboBox;
    4545import org.greenstone.gatherer.gui.GLIButton;
    46 import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
    4746import org.greenstone.gatherer.util.JarTools;
    4847import org.greenstone.gatherer.util.StaticStrings;
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/GeneralManager.java

    r19225 r22410  
    441441        // Set the title
    442442        String collection_title = name_textfield.getText();
    443         String collection_name = CollectionManager.getLoadedGroupQualifiedCollectionName(true);
     443        String collection_name = CollectionManager.getLoadedCollectionName(true);
    444444        Gatherer.g_man.setTitle(collection_title, collection_name);
    445445                collection_name_collectionmeta.setValue(collection_title);
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r18588 r22410  
    4949import org.greenstone.gatherer.gui.ModalDialog;
    5050import org.greenstone.gatherer.gui.WarningDialog;
    51 import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
    5251import org.greenstone.gatherer.util.JarTools;
    5352import org.greenstone.gatherer.util.StaticStrings;
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/SuperCollectionManager.java

    r19224 r22410  
    210210      {
    211211    collection_checklist_model = new ArrayList();
    212     current_coll_name = CollectionManager.getLoadedGroupQualifiedCollectionName(true);
     212    current_coll_name = CollectionManager.getLoadedCollectionName(true);
    213213    File collect_directory = new File(Gatherer.getCollectDirectoryPath());
    214214    add_collections_to_model(collect_directory);
  • main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r22359 r22410  
    212212    if(!Gatherer.isGsdlRemote) {
    213213        command_parts_list.add("-collectdir");
    214         command_parts_list.add(getCollectDirectory());
     214        command_parts_list.add(getCollectDirectory()); // <../collect/>
    215215    }
    216216
     
    220220    }
    221221
    222     command_parts_list.add(collection.getName());
     222    command_parts_list.add(collection.getGroupQualifiedName(false)); // (colgroup/)colname
    223223
    224224    // Run the buildcol.pl and
     
    270270    }
    271271
    272     import_list.add(collection.getName()); 
     272    import_list.add(collection.getGroupQualifiedName(false)); // (colgroup/)colname
    273273
    274274    String[] import_parts = (String[]) import_list.toArray(new String[0]);
     
    311311    }
    312312
    313     build_list.add(collection.getName());
     313    build_list.add(collection.getGroupQualifiedName(false)); // (colgroup/)colname
    314314   
    315315    //build actual string
     
    413413    // Remove the lock file on the server
    414414    if (Gatherer.isGsdlRemote) {
    415         Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getName(), lock_file);
     415        Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getGroupQualifiedName(false), lock_file);
    416416    }
    417417
     
    442442//  command_parts_list.add("-collectdir");
    443443//  command_parts_list.add(getCollectDirectory());
    444 //      command_parts_list.add(collection.getName());
     444//      command_parts_list.add(collection.getGroupQualifiedName(false)); // (colgroup/)colname
    445445//
    446446//  // Run the convert_coll_from_gs2.pl command
     
    936936
    937937
    938     /** Returns the name of the loaded collection.
     938    /** Returns the (group-qualified) name of the loaded collection with
     939     * OS-dependent file separator.
    939940     */
    940941    static public String getLoadedCollectionName()
    941942    {
     943    return CollectionManager.getLoadedCollectionName(false);
     944    }
     945
     946    /** Returns the (group-qualified) name of the loaded collection with
     947     * OS-dependent space separator.
     948     * @url true if url-type forward slashes, false if OS-dependent filesystem slashes.
     949     */
     950    static public String getLoadedCollectionName(boolean url)
     951    {
    942952    if (collection != null) {
    943         return collection.getName();
     953        //return collection.getName();
     954        return collection.getGroupQualifiedName(url);
    944955    }
    945956
     
    10871098    }
    10881099
    1089     command_parts_list.add(collection.getName());
     1100    command_parts_list.add(collection.getGroupQualifiedName(false)); // (colgroup/)colname
    10901101
    10911102    // Run the import.pl command
     
    11201131        // If we're using a remote Greenstone server, upload the metadata file
    11211132        if (Gatherer.isGsdlRemote) {
    1122             Gatherer.remoteGreenstoneServer.uploadCollectionFile(collection.getName(), metadata_set_file);
     1133            Gatherer.remoteGreenstoneServer.uploadCollectionFile(collection.getGroupQualifiedName(false), metadata_set_file);
    11231134        }
    11241135        }
     
    17031714        // If we're using a remote Greenstone server, delete the metadata file on the server
    17041715        if (Gatherer.isGsdlRemote) {
    1705         Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getName(), metadata_set_file);
     1716        Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getGroupQualifiedName(false), metadata_set_file);
    17061717        }
    17071718    }
     
    17891800    // used as arg in the perl scripts
    17901801    private String getCollectDirectory() {
     1802    return Gatherer.getCollectDirectoryPath();
    17911803   
    1792     String collect_dir = collection.getCollectionDirectory().getParentFile().getPath();
    1793     return collect_dir;
     1804    // the following will stick any colgroup at the end of the collect directory, making it no longer
     1805    // possible to get the real collect dir in a general manner if this were located outside greenstone
     1806    //String collect_dir = collection.getCollectionDirectory().getParentFile().getPath();
     1807    //return collect_dir;
    17941808    }
    17951809
     
    18441858        if (Gatherer.isGsdlRemote) {
    18451859            Gatherer.remoteGreenstoneServer.deleteCollectionFile(
    1846                              collection.getName(), new File(getLoadedCollectionIndexDirectoryPath()));
    1847             Gatherer.remoteGreenstoneServer.moveCollectionFile(collection.getName(),
     1860                             collection.getGroupQualifiedName(false), new File(getLoadedCollectionIndexDirectoryPath()));
     1861            Gatherer.remoteGreenstoneServer.moveCollectionFile(collection.getGroupQualifiedName(false),
    18481862                    new File(getLoadedCollectionBuildingDirectoryPath()), new File(getLoadedCollectionIndexDirectoryPath()));
    18491863        }
  • main/trunk/gli/src/org/greenstone/gatherer/file/FileManager.java

    r19239 r22410  
    171171        file_queue.addJob(id, source, source_nodes, target, target_node, type);
    172172        if (Gatherer.isGsdlRemote) {
    173             String collection_name = CollectionManager.getLoadedGroupQualifiedCollectionName(true);
     173            String collection_name = CollectionManager.getLoadedCollectionName();
    174174
    175175            // Perform the appropriate action based on the job type (RemoteGreenstoneServer will queue)
     
    274274        if (file.getAbsolutePath().startsWith(Gatherer.getCollectDirectoryPath()) && file.length() == 0) {
    275275            if (Gatherer.remoteGreenstoneServer.downloadCollectionFile(
    276                                  CollectionManager.getLoadedGroupQualifiedCollectionName(true), file).equals("")) {
     276                                 CollectionManager.getLoadedCollectionName(), file).equals("")) {
    277277            // Something has gone wrong downloading the file
    278278            return;
     
    350350                if (Gatherer.isGsdlRemote) {
    351351                Gatherer.remoteGreenstoneServer.uploadCollectionFile(
    352                                          CollectionManager.getLoadedGroupQualifiedCollectionName(true), folder_file);
     352                                         CollectionManager.getLoadedCollectionName(), folder_file);
    353353                }
    354354            }
     
    357357                if (Gatherer.isGsdlRemote) {
    358358                Gatherer.remoteGreenstoneServer.newCollectionDirectory(
    359                                          CollectionManager.getLoadedGroupQualifiedCollectionName(true), folder_file);
     359                                         CollectionManager.getLoadedCollectionName(), folder_file);
    360360                }
    361361            }
     
    418418        if (Gatherer.isGsdlRemote) {
    419419            Gatherer.remoteGreenstoneServer.moveCollectionFile(
    420                              CollectionManager.getLoadedGroupQualifiedCollectionName(true), collection_file, new_collection_file);
     420                             CollectionManager.getLoadedCollectionName(), collection_file, new_collection_file);
    421421        }
    422422        }
     
    467467        file_queue.addJob(System.currentTimeMillis(), Gatherer.g_man.gather_pane.workspace_tree, new FileNode[] { source_node }, collection_tree, (FileNode)collection_tree_node.getParent(),  FileJob.COPY_FILE_ONLY);
    468468        if (Gatherer.isGsdlRemote) {
    469         String collection_name = CollectionManager.getLoadedGroupQualifiedCollectionName(true);
     469        String collection_name = CollectionManager.getLoadedCollectionName();
    470470        Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection_name, collection_tree_node.getFile());
    471471        Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(collection_name, new File[] { new_file }, target_directory);
  • main/trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTree.java

    r22342 r22410  
    169169        // If the specified folder is open, it must be refreshed
    170170        if (tree_node_path_str.equals(folder_path_str)) {
    171         System.err.println("Must refresh node " + tree_node_path_str + "!");
     171        //System.err.println("Must refresh node " + tree_node_path_str + "!");
    172172        ((WorkspaceTreeModel) getModel()).refresh(expanded_tree_path);
    173173        }
  • main/trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeNode.java

    r19235 r22410  
    168168             
    169169              // One last piece of magic so we can determine the current collection
    170               // I don't think this will work properly with groups,
    171               // as it may give a false positive??
    172               collection_root.is_in_loaded_collection = cols[i].getName().equals(CollectionManager.getLoadedCollectionName());
     170              // Now made to work with collection groups
     171              String groupQualifiedColName = cols[i].getName();
     172              if(is_group_node) { // then title would have stored the colgroup name
     173                  groupQualifiedColName = title + File.separator + cols[i].getName();
     174              }
     175              collection_root.is_in_loaded_collection = groupQualifiedColName.equals(CollectionManager.getLoadedCollectionName());
    173176              child_nodes.add(collection_root);
    174177            }
  • main/trunk/gli/src/org/greenstone/gatherer/gui/PreviewButton.java

    r21587 r22410  
    7777    // we could be working with standalone collections or collection groups
    7878    // so getting a collection-name may have a collection group prefix
    79     // This means CollectionManager.getLoadedCollectionName() is no longer sufficient
    80     String collGroupWithName = CollectionManager.getLoadedGroupQualifiedCollectionName(true);
     79    // This means CollectionManager.getLoadedCollectionName() needs to (and does) return (colgroup/)subcolname
     80    String collGroupWithName = CollectionManager.getLoadedCollectionName(true);
    8181
    8282    // set up the home page for the current collection
  • main/trunk/gli/src/org/greenstone/gatherer/gui/WriteCDImagePrompt.java

    r22361 r22410  
    546546
    547547        // Find the size of the "etc", "images" and "index" directories of the collection
    548         String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection.getShortName());
     548        String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection.getShortName()); // (colgroup/)subcol
    549549        File etc_directory = new File(collection_directory_path + "etc");
    550550        File images_directory = new File(collection_directory_path + "images");
  • main/trunk/gli/src/org/greenstone/gatherer/remote/RemoteGreenstoneServerAction.java

    r19231 r22410  
    118118
    119119        String delete_collection_command = "cmd=delete-collection";
    120         delete_collection_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     120        delete_collection_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    121121        action_output = remote.sendCommandToServer(delete_collection_command, null);
    122122    }
     
    150150
    151151        String delete_collection_file_command = "cmd=delete-collection-file";
    152         delete_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     152        delete_collection_file_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    153153        delete_collection_file_command += "&file=" + Base64.encodeBytes(collection_file_relative_path.getBytes());
    154154        action_output = remote.sendCommandToServer(delete_collection_file_command, null);
     
    178178
    179179        String download_collection_command = "cmd=download-collection";
    180         download_collection_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     180        download_collection_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    181181        download_collection_command += "&lr=" + remote.lang_region;
    182182        String zip_file_path = Gatherer.getCollectDirectoryPath() + collection_name + ".zip";
     
    213213
    214214        String download_collection_archives_command = "cmd=download-collection-archives";
    215         download_collection_archives_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     215        download_collection_archives_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    216216        download_collection_archives_command += "&lr=" + remote.lang_region;
    217217        String zip_file_path = Gatherer.getCollectDirectoryPath() + collection_name + "-archives.zip";
     
    310310
    311311        String file_exists_command = "cmd=file-exists";
    312         file_exists_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     312        file_exists_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    313313        // base64 encode the filename to preserve special characters
    314314        file_exists_command += "&file=" + Base64.encodeBytes(collection_file_relative_path.getBytes());
     
    347347
    348348        String download_collection_file_command = "cmd=download-collection-file";
    349         download_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     349        download_collection_file_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    350350        download_collection_file_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8");
    351351        download_collection_file_command += "&lr=" + remote.lang_region;
     
    470470
    471471        String move_collection_file_command = "cmd=move-collection-file";
    472         move_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     472        move_collection_file_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    473473        move_collection_file_command += "&source=" + Base64.encodeBytes(source_collection_file_relative_path.getBytes());
    474474        move_collection_file_command += "&target=" + Base64.encodeBytes(target_collection_file_relative_path.getBytes());
     
    507507
    508508        String new_collection_directory_command = "cmd=new-collection-directory";
    509         new_collection_directory_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     509        new_collection_directory_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    510510        new_collection_directory_command += "&directory=" + URLEncoder.encode(new_collection_directory_relative_path, "UTF-8");
    511511        action_output = remote.sendCommandToServer(new_collection_directory_command, null);
     
    541541
    542542        String run_script_command = "cmd=run-script";
    543         run_script_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     543        run_script_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    544544        run_script_command += "&script=" + script_name;
    545545        run_script_command += "&language=" + Configuration.getLanguage();
     
    588588        // Upload the zip file
    589589        String upload_collection_file_command = "cmd=upload-collection-file";
    590         upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     590        upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    591591        upload_collection_file_command += "&file=" + URLEncoder.encode(zip_file_name, "UTF-8");
    592592        upload_collection_file_command += "&directory=";
     
    643643
    644644        String upload_collection_file_command = "cmd=upload-collection-file";
    645         upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
     645        upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    646646        upload_collection_file_command += "&file=" + URLEncoder.encode(zip_file_name, "UTF-8");
    647647        upload_collection_file_command += "&directory=" + URLEncoder.encode(target_collection_directory_relative_path, "UTF-8");
Note: See TracChangeset for help on using the changeset viewer.