Project

General

Profile

« Previous | Next » 

Revision 733

Added by bojilova almost 23 years ago

Tomcat has got configurated mime type mappings, but some are
missing. Thus added support for them in MetaCatServlet as:
File type > MIME type
-------------
----------------
.xml -> "text/xml"
.xsd -> "text/xml"
.dtd -> "text/plain"
.css -> "text/css"
directory -> "text/html"
other file types -> "application/octet-stream"

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
27 27

  
28 28
package edu.ucsb.nceas.metacat;
29 29

  
30
import java.io.File;
30 31
import java.io.PrintWriter;
31 32
import java.io.IOException;
32 33
import java.io.StringReader;
......
788 789
      
789 790
      if ( doc.getRootNodeID() == 0 ) {
790 791
        // this is data file
791
        // ??? look at handleGetData
792 792
        ServletOutputStream out = response.getOutputStream(); 
793 793
        String filepath = util.getOption("datafilepath");
794 794
        if(!filepath.endsWith("/")) {
......
804 804
          } else if (filename.endsWith(".dtd")) {
805 805
            contentType="text/plain";
806 806
          } else if (filename.endsWith(".xsd")) {
807
            contentType="text/plain";
807
            contentType="text/xml";
808 808
          } else if (filename.endsWith("/")) {
809
            contentType="text/directory";
809
            contentType="text/html";
810 810
          } else {
811
            contentType="text/plain";
811
            File f = new File(filename);
812
            if ( f.isDirectory() ) {
813
              contentType="text/html";
814
            } else {
815
              contentType="application/octet-stream";
816
            }
812 817
          }
813 818
        }
814 819
        response.setContentType(contentType);
820
        // if we decide to use "application/octet-stream" for all data returns
821
        // response.setContentType("application/octet-stream");
815 822
        FileInputStream fin = null;
816 823
        try {
817 824
          fin = new FileInputStream(filename);
......
865 872
      } else if (docid.endsWith(".dtd")) {
866 873
        contentType="text/plain";
867 874
      } else if (docid.endsWith(".xsd")) {
868
        contentType="text/plain";
875
        contentType="text/xml";
869 876
      } else if (docid.endsWith("/")) {
870
        contentType="text/directory";
877
        contentType="text/html";
871 878
      } else {
872
        contentType="text/plain";
879
        File f = new File(docid);
880
        if ( f.isDirectory() ) {
881
          contentType="text/html";
882
        } else {
883
          contentType="application/octet-stream";
884
        }
873 885
      }
874 886
    }
875 887
    response.setContentType(contentType);
888
    // if we decide to use "application/octet-stream" for all data returns
889
    // response.setContentType("application/octet-stream");
876 890

  
877 891
    // this is http url
878 892
    URL url = new URL(docid);

Also available in: Unified diff