Ignore:
Timestamp:
2008-02-12T16:13:13+13:00 (16 years ago)
Author:
davidb
Message:

Changes to GLI to support export into Fedora. New utility called flisvn diff gems/MetadataSetManager.java

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

Legend:

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

    r13819 r14974  
    8686    /** The name of the import element. */
    8787    static final private String IMPORT = "Import";
     88    /** The name of the import element. */
     89    static final private String EXPORT = "Export";
    8890    /** The name of the imported attribute. */
    8991    static final private String IMPORTED = "imported";
     
    111113    }
    112114    // Finally create all of the child managers that are directly dependant on a collection
    113     build_options = new ScriptOptions(getBuildValues(), "buildcol.pl");
    114     import_options = new ScriptOptions(getImportValues(), "import.pl");
     115
     116    if (Configuration.fedora_info.isActive()) {
     117        build_options = new ScriptOptions(getValues(BUILD), "g2f-buildcol.pl");
     118        import_options = new ScriptOptions(getValues(IMPORT), "g2f-import.pl");
     119    }
     120    else {
     121        build_options = new ScriptOptions(getBuildValues(), "buildcol.pl");
     122        import_options = new ScriptOptions(getImportValues(), "import.pl");
     123    }
    115124    }
    116125   
     
    334343   
    335344
     345    /** Method to retrieve the current import/build/export/whatever options associated with this Collection. */
     346    private Element getValues(String val_type) {
     347    Element values_element = null;
     348    try {
     349        Element document_element = document.getDocumentElement();
     350        Element config_element = (Element) XMLTools.getNodeFromNamed(document_element, BUILD_CONFIG);
     351        values_element = (Element) XMLTools.getNodeFromNamed(config_element, val_type);
     352        config_element = null;
     353        document_element = null;
     354    }
     355    catch (Exception error) {
     356        DebugStream.printStackTrace(error);
     357    }
     358    return values_element;
     359    }
     360
    336361   
    337362    /** Method to retrieve the current build options associated with this Collection. */
     
    350375    return build_values_element;
    351376    }
     377
    352378   
    353379    /** Count either documents or folders, depending on the state of the given boolean. */
  • gli/trunk/src/org/greenstone/gatherer/collection/CollectionManager.java

    r14817 r14974  
    159159        command_parts_list.add("-S");
    160160    }
    161     command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl");
     161
     162    if (Configuration.fedora_info.isActive()) {
     163        command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "g2f-buildcol.pl");
     164
     165        command_parts_list.add("-hostname");
     166        command_parts_list.add(Configuration.fedora_info.getHostname());
     167
     168        command_parts_list.add("-port");
     169        command_parts_list.add(Configuration.fedora_info.getPort());
     170
     171        command_parts_list.add("-username");
     172        command_parts_list.add(Configuration.fedora_info.getUsername());
     173
     174        command_parts_list.add("-password");
     175        command_parts_list.add(Configuration.fedora_info.getPassword());
     176
     177        command_parts_list.add("-protocol");
     178        command_parts_list.add(Configuration.fedora_info.getProtocol());
     179
     180    }
     181    else {
     182        command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl");
     183    }
    162184    command_parts_list.add("-gli");
    163185    command_parts_list.add("-language");
     
    193215    public boolean built() {
    194216    if(collection != null) {
    195         // Determine if the collection has been built by looking for the build.cfg or buildConfig.xml file
    196         String file_name = (Gatherer.GS3)? Utility.BUILD_CONFIG_XML : Utility.BUILD_CFG;
    197         File build_cfg_file = new File(getLoadedCollectionIndexDirectoryPath() + file_name);
    198         return build_cfg_file.exists();
     217        // Determine if the collection has been built by looking for the build.cfg (gs20 buildConfig.xml (gs3) or export.inf (fedora) file
     218        String file_name = "";
     219
     220        if (Gatherer.GS3) {
     221        file_name = getLoadedCollectionIndexDirectoryPath() + Utility.BUILD_CONFIG_XML;
     222        }
     223        else {
     224        if (Configuration.fedora_info.isActive()) {
     225            // Fedora build
     226            //file_name = getLoadedCollectionArchivesDirectoryPath() + "import.inf";
     227            file_name = getLoadedCollectionExportDirectoryPath() + "export.inf";
     228        }
     229        else {
     230            file_name = getLoadedCollectionIndexDirectoryPath() + Utility.BUILD_CFG;
     231        }
     232        }
     233
     234        File test_file = new File(file_name);
     235        return test_file.exists();
    199236    }
    200237    return false;
     
    592629    }
    593630
     631    /** Returns the absolute filename of the loaded collection's export directory.
     632     */
     633    static public String getLoadedCollectionExportDirectoryPath()
     634    {
     635    return getLoadedCollectionDirectoryPath() + "export" + File.separator;
     636    }
     637
     638
    594639
    595640    /** Returns the absolute filename of the loaded collection's building directory.
     
    764809        command_parts_list.add("-S");
    765810    }
    766     command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl");
     811
     812    if (Configuration.fedora_info.isActive()) {
     813        command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "g2f-import.pl");
     814
     815        command_parts_list.add("-hostname");
     816        command_parts_list.add(Configuration.fedora_info.getHostname());
     817
     818        command_parts_list.add("-port");
     819        command_parts_list.add(Configuration.fedora_info.getPort());
     820
     821        command_parts_list.add("-username");
     822        command_parts_list.add(Configuration.fedora_info.getUsername());
     823
     824        command_parts_list.add("-password");
     825        command_parts_list.add(Configuration.fedora_info.getPassword());
     826
     827        command_parts_list.add("-protocol");
     828        command_parts_list.add(Configuration.fedora_info.getProtocol());
     829    }
     830    else {
     831        command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl");
     832    }
     833
    767834    command_parts_list.add("-gli");
    768835    command_parts_list.add("-language");
     
    13391406    private boolean installCollection()
    13401407    {
     1408    if (Configuration.fedora_info.isActive()) {
     1409        DebugStream.println("Fedora build complete. No need to move files.");
     1410        return true;
     1411    }
     1412
     1413       
    13411414    DebugStream.println("Build complete. Moving files.");
    13421415
  • gli/trunk/src/org/greenstone/gatherer/collection/ScriptOptions.java

    r13753 r14974  
    247247        }
    248248
     249
    249250        // Create the process.
    250251        Runtime runtime = Runtime.getRuntime();
    251252        Process process = runtime.exec(args);
     253
     254        /*
     255        for (int i=0; i<args.length; i++) {
     256            System.err.print(args[i] + " ");
     257        }
     258        System.err.println("");
     259        */
     260
     261
    252262        document = XMLTools.parseXML(process.getErrorStream());
     263       
     264        if (document == null) {
     265            // command has not generated XML, script has probably failed in some way
     266            for (int i=0; i<args.length; i++) {
     267            DebugStream.print(args[i] + " ");
     268            }
     269            DebugStream.println("");
     270        }
    253271        }
    254272
Note: See TracChangeset for help on using the changeset viewer.