Extract helper methods canonicalize() and allowedInMap().

These avoid some duplication. This CL also adds:
 - a sanity check that none of the types or extensions
   read from the mime.types data file is invalid (throws
   IAE otherwise),
 - unit test coverage for some invalid/unknown types.

Test: MimeUtilsTest

Change-Id: I7a3b449f2c5a0ab8b25da63676f6cab008d0f119
2 files changed