} catch (MimeTypeFormatException ex) {
return null;
}
ResourceReference rr = getContentTypes();
try {
TemplateContainer types = (TemplateContainer) rr.lock();
Enumeration e = types.enumerateResourceIdentifiers(true);
String key = "*:*"; // if there is no better match...
int match = -1;
int cmatch;
while (e.hasMoreElements()) {
String ext_entry = (String)e.nextElement();
MimeType entry_type = null;
try {
entry_type = new MimeType(ext_entry.replace(':','/'));
} catch (MimeTypeFormatException mex) {
// ok there is a configuration problem here
continue;
}
cmatch = mtype.match(entry_type);
if (cmatch > match) {
match = cmatch;
key = ext_entry;
if (match == MimeType.MATCH_SPECIFIC_SUBTYPE)
break; // exact match exit loop asap
}
}
return types.lookup(key);
} catch (InvalidResourceException ex) {
String msg = ("[resource indexer]: content-types \""+
type+
"\" couldn't be restored ("+ex.getMessage()+")");
getContext().getServer().errlog(msg);