MCPcopy Create free account
hub / github.com/apache/nutch / MimeUtil

Method MimeUtil

src/java/org/apache/nutch/util/MimeUtil.java:73–102  ·  view source on GitHub ↗
(Configuration conf)

Source from the content-addressed store, hash-verified

71 .getLogger(MethodHandles.lookup().lookupClass());
72
73 public MimeUtil(Configuration conf) {
74 tika = new Tika();
75 ObjectCache objectCache = ObjectCache.get(conf);
76 MimeTypes mimeTypez = (MimeTypes) objectCache.getObject(MimeTypes.class
77 .getName());
78 if (mimeTypez == null) {
79 try {
80 String customMimeTypeFile = conf.get("mime.types.file");
81 if (customMimeTypeFile != null
82 && customMimeTypeFile.equals("") == false) {
83 try {
84 mimeTypez = MimeTypesFactory.create(conf
85 .getConfResourceAsInputStream(customMimeTypeFile));
86 } catch (Exception e) {
87 LOG.error("Can't load mime.types.file : " + customMimeTypeFile
88 + " using Tika's default");
89 }
90 }
91 if (mimeTypez == null)
92 mimeTypez = MimeTypes.getDefaultMimeTypes();
93 } catch (Exception e) {
94 LOG.error("Exception in MimeUtil " + e.getMessage());
95 throw new RuntimeException(e);
96 }
97 objectCache.setObject(MimeTypes.class.getName(), mimeTypez);
98 }
99
100 this.mimeTypes = mimeTypez;
101 this.mimeMagic = conf.getBoolean("mime.type.magic", true);
102 }
103
104 /**
105 * Cleans a {@link MimeType} name by removing out the actual {@link MimeType},

Callers

nothing calls this directly

Calls 9

getMethod · 0.95
getObjectMethod · 0.95
setObjectMethod · 0.95
errorMethod · 0.80
getMethod · 0.65
createMethod · 0.65
getNameMethod · 0.45
equalsMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected