//example: content type text/html => media type html
MediaTypeRegistry mediaRegistry = (MediaTypeRegistry) Registry.get(Registry.MEDIA_TYPE);
Enumeration en = mediaRegistry.getEntries();
while(en.hasMoreElements())
{
MediaTypeEntry mte = (MediaTypeEntry)en.nextElement();
//TODO: the type can have wildcards, will REGEXP handle this?
/*
RE r = null;
RECompiler rc = null;
try
{
rc = new RECompiler();
r = new RE();
r.setProgram(rc.compile(type));
}
catch (org.apache.regexp.RESyntaxException rex)
{
log.warn("FusionPAM: error processing regular expression [" + type + "]: " +
rex.toString());
}
*/
if(type.indexOf('*') != -1)
{
log.info("Found mime type with wildcard.");
}
else if (type.equals(mte.getMimeType()))// || r.match(mte.getMimeType()))
{
log.info("Found media entry " + mte.getName() + " that matches mimetype " + type);
entry.addMediaType(mte.getName());
break;
}
}
}