From a1b2c9a67d6ffaeb08f42b5bada6c6088bba4956 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Thu, 16 Aug 2012 17:49:35 +0200 Subject: [PATCH] doctype2mime fix, influences metadata conversion between old metadata and solr --- defaults/httpd.mime | 1 + source/de/anomic/crawler/retrieval/Response.java | 16 +++++++++++----- .../net/yacy/cora/document/Classification.java | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/defaults/httpd.mime b/defaults/httpd.mime index 2fc577369..9b763ccb5 100644 --- a/defaults/httpd.mime +++ b/defaults/httpd.mime @@ -47,6 +47,7 @@ kml = application/vnd.google-earth.kml+xml lha = application/x-lzh lzh = application/x-lzh m4v = video/x-m4v +md5 = text/plain mf = application/octet-stream mov = video/quicktime mm = application/freemind diff --git a/source/de/anomic/crawler/retrieval/Response.java b/source/de/anomic/crawler/retrieval/Response.java index b9c75c845..46e674bee 100644 --- a/source/de/anomic/crawler/retrieval/Response.java +++ b/source/de/anomic/crawler/retrieval/Response.java @@ -118,16 +118,22 @@ public class Response { } public static String doctype2mime(String ext, char doctype) { - String mime = Classification.ext2mime(ext); - int p = mime.indexOf('/'); - if (p < 0) return mime; - if (doctype == DT_TEXT) return "text" + mime.substring(p); + if (doctype == DT_PDFPS) return "application/pdf"; + if (doctype == DT_HTML) return "text/html"; + if (doctype == DT_DOC) return "application/msword"; + if (doctype == DT_FLASH) return "application/x-shockwave-flash"; + if (doctype == DT_SHARE) return "text/plain"; + if (doctype == DT_BINARY) return "application/octet-stream"; + String mime = Classification.ext2mime(ext); + int p = mime.indexOf('/'); + if (p < 0) return mime; + if (doctype == DT_TEXT) return "text" + mime.substring(p); if (doctype == DT_IMAGE) return "image" + mime.substring(p); if (doctype == DT_AUDIO) return "audio" + mime.substring(p); if (doctype == DT_MOVIE) return "video" + mime.substring(p); return mime; } - + public static final int QUEUE_STATE_FRESH = 0; public static final int QUEUE_STATE_PARSING = 1; public static final int QUEUE_STATE_CONDENSING = 2; diff --git a/source/net/yacy/cora/document/Classification.java b/source/net/yacy/cora/document/Classification.java index 13afe7018..7afbf7272 100644 --- a/source/net/yacy/cora/document/Classification.java +++ b/source/net/yacy/cora/document/Classification.java @@ -184,7 +184,7 @@ public class Classification { } public static String ext2mime(final String ext) { - return mimeTable.getProperty(ext, "application/" + ext); + return mimeTable.getProperty(ext, "application/" + (ext == null || ext.length() == 0 ? "octet-stream" : ext)); } public static String ext2mime(final String ext, final String dfltMime) {