Project

General

Profile

Revision 1556

Added by Jing Tao over 18 years ago

Add contenttypeprovider when read a data file.

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
340 340
        if ( (username != null) &&  !username.equals("public") ) {
341 341
          handleInsertOrUpdateAction(out,params,username,groupnames);
342 342
        } else {
343
          out.println("Permission denied for user"+username +" " + action);
344
        }
343
          out.println("Permission denied for user "+username +" " + action);
344
       }
345 345
        out.close();
346 346
      } else if (action.equals("delete")) {
347 347
        PrintWriter out = response.getWriter();
......
1256 1256

  
1257 1257
        //MIME type
1258 1258
        String contentType = getServletContext().getMimeType(filename);
1259
        if (contentType == null) {
1260
          if (filename.endsWith(".xml")) {
1261
            contentType="text/xml";
1262
          } else if (filename.endsWith(".css")) {
1263
            contentType="text/css";
1264
          } else if (filename.endsWith(".dtd")) {
1265
            contentType="text/plain";
1266
          } else if (filename.endsWith(".xsd")) {
1267
            contentType="text/xml";
1268
          } else if (filename.endsWith("/")) {
1269
            contentType="text/html";
1270
          } else {
1271
            File f = new File(filename);
1272
            if ( f.isDirectory() ) {
1273
              contentType="text/html";
1274
            } else {
1275
              // Use the content type set in the metacat.properties file
1276
              contentType= util.getOption("defaultcontenttype");
1277
              System.out.println(" default content type: "+ contentType);
1278
              if ( contentType == null ) {
1279
              contentType="application/octet-stream";
1280
              }
1281
            }
1282
          }
1259
        if (contentType == null) 
1260
        {
1261
          ContentTypeProvider provider = new ContentTypeProvider(docid);
1262
          contentType = provider.getContentType();
1263
          MetaCatUtil.debugMessage("Final contenttype is: "+ contentType, 30);
1283 1264
        }
1284
        System.out.println("final content type: "+contentType);
1265
       
1285 1266
        response.setContentType(contentType);
1286 1267
        // if we decide to use "application/octet-stream" for all data returns
1287 1268
        // response.setContentType("application/octet-stream");

Also available in: Unified diff