Ignore:
Timestamp:
2003-11-24T14:26:35+13:00 (20 years ago)
Author:
cs025
Message:

Index document type, metadata extensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/HTMLRecogniser.java

    r5800 r5944  
    99public class HTMLRecogniser implements RecogniserInterface
    1010{
    11     DocumentList listRepository;
     11  DocumentList listRepository;
    1212
    13     public HTMLRecogniser(DocumentList listRepository)
    14     {   this.listRepository = listRepository;
    15     }
     13  public HTMLRecogniser(DocumentList listRepository)
     14  { this.listRepository = listRepository;
     15  }
     16 
     17  public boolean parseDocument(METSFile file)
     18  {
     19    String MIMEType = file.getMIMEType();
     20    if (MIMEType == null ||
     21    MIMEType.equals("text/html")) {
     22      URL location = file.getLocation();
     23      return this.parseDocument(location);
     24    }
     25    return false;
     26  }
    1627
    17     public boolean parseDocument(METSFile file)
    18     {
    19         String MIMEType = file.getMIMEType();
    20         if (MIMEType == null ||
    21               MIMEType.equals("text/html")) {
    22             URL location = file.getLocation();
    23             return this.parseDocument(location);
    24         }
    25         return false;
    26     }
     28  public boolean parseDocument(URL url)
     29  { String fileName = null;
    2730
    28     public boolean parseDocument(URL url)
    29     {   if (url.toString().startsWith("file://")) {
    30             String fileName = url.toString().substring(7);
    31             if (fileName.endsWith(".htm") ||
    32                   fileName.endsWith(".html"))
    33           { System.out.println("Posting HTML Document " + fileName);
     31    if (url.toString().startsWith("file://")) {
     32      fileName = url.toString().substring(7);
     33    }
     34    else if (url.toString().startsWith("file:/")) {
     35      fileName = url.toString().substring(5);
     36    }
    3437
    35             HTMLDocument doc = new HTMLDocument(url);
    36             this.listRepository.addDocument(doc);
    37               return true;
    38             }
    39         }
    40         else {
    41             // Get Mime type remotely, and then proceed if required
    42             String mimeType = HTTPTools.getMIMEType(url);
     38    if (fileName != null) {
     39      if (fileName.endsWith(".htm") ||
     40      fileName.endsWith(".html"))
     41      { System.out.println("Posting HTML Document " + fileName);
    4342
    44             if (mimeType == "text/html")
    45             {   System.out.println("Posting HTML Document " + url.toString());
     43        HTMLDocument doc = new HTMLDocument(url);
     44    this.listRepository.addDocument(doc);
     45    return true;
     46      }
     47    }
     48    else {
     49      // Get Mime type remotely, and then proceed if required
     50      String mimeType = HTTPTools.getMIMEType(url);
     51
     52      if (mimeType == "text/html")
     53      { System.out.println("Posting HTML Document " + url.toString());
    4654           
    47                 HTMLDocument doc = new HTMLDocument(url);
    48                 this.listRepository.addDocument(doc);
    49                 return true;
    50             }
    51         }
    52         return false;
    53     }
     55        HTMLDocument doc = new HTMLDocument(url);
     56    this.listRepository.addDocument(doc);
     57    return true;
     58      }
     59    }
     60    return false;
     61  }
    5462}
Note: See TracChangeset for help on using the changeset viewer.