Changeset 7292 for trunk


Ignore:
Timestamp:
2004-05-07T13:02:33+12:00 (20 years ago)
Author:
kjdon
Message:

made the directory parser recursive, and now it doesn't look at any namespaced metadata - only tries to extract non-namespaced, ie greenstone extracted, metadata

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/msm/GreenstoneArchiveParser.java

    r7204 r7292  
    7676        // Determine the collection archive directory.
    7777        File archive_directory = new File(Gatherer.c_man.getCollectionArchive());
    78         // For each of the hash coded directories within.
    79         File document_directories[] = archive_directory.listFiles();
    80         for(int i = 0; i < document_directories.length; i++) {
    81         // Find the doc.xml file within
    82         if(document_directories[i].isDirectory()) {
    83             File document_file = new File(document_directories[i], "doc.xml");
    84             // Then extract the metadata from it.
    85             if(document_file.exists()) {
    86             int count = extractMetadata(document_file);
    87             // Display a pretty progress message.
    88             String[] args = new String[2];
    89             args[0] = document_directories[i].getName();
    90             args[1] = String.valueOf(count);
    91             shell.fireMessage(GShell.IMPORT, shell.typeAsString(GShell.IMPORT) + "> " + Dictionary.get("GShell.Extracted", args), GShell.OK, null);
    92             args = null;
    93             progress.increment();
    94             }
    95         }
    96         }
     78        // Start the extraction process
     79        processDirectory(archive_directory, progress);
    9780    }
    9881    // All done. Outta here like a bald man.
     82    }
     83   
     84    private void processDirectory(File directory, GShellProgressMonitor progress) {
     85    // look for a doc.xml file here
     86    File document_file = new File(directory, "doc.xml");
     87    // Then extract the metadata from it.
     88    if(document_file.exists()) {
     89        int count = extractMetadata(document_file);
     90        // Display a pretty progress message.
     91        String[] args = new String[2];
     92        args[0] = directory.getName();
     93        args[1] = String.valueOf(count);
     94        this.shell.fireMessage(GShell.IMPORT, shell.typeAsString(GShell.IMPORT) + "> " + Dictionary.get("GShell.Extracted", args), GShell.OK, null);
     95        args = null;
     96        progress.increment();
     97    }
     98   
     99    // for each directory here, process it
     100    File sub_directories[] = directory.listFiles();
     101    for(int i = 0; i < sub_directories.length; i++) {
     102        // Find the doc.xml file within
     103        if(sub_directories[i].isDirectory()) {
     104        processDirectory(sub_directories[i], progress);
     105        }
     106    }
    99107    }
    100108
     
    149157    {
    150158    String name = metadata_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
    151 
    152159    // There is also a special case when the metadata name is gsdlsourcefilename, as we use this to find the FileRecord we want to add metadata to.
    153160    if (name.equals("gsdlsourcefilename")) {
     
    161168        return false;
    162169        }
     170    }
     171
     172    // namespaced metadata, we don't extract at the moment
     173    if (name.indexOf(MSMUtils.NS_SEP)!=-1) {
     174        return false;
    163175    }
    164176
     
    197209        return false;
    198210    }
    199 
    200211    // Create a new metadata object.
    201212    GValueModel value_tree = Gatherer.c_man.msm.getValueTree(element);
Note: See TracChangeset for help on using the changeset viewer.