/**
  * Get MIMEType which corresponds to file content. If file content does not allow to determine
  * MIMEtype, the default MIMEType will be returned.
  *
  * @param filename the filename
  * @param is the is
  * @return String MIMEType
  */
 public String getMimeType(String filename, InputStream is) {
   String mimeType = getMimeType(filename);
   if (resolver.getDefaultMimeType().equals(mimeType)) {
     mimeType = resolver.getMimeType(filename, is);
   }
   return mimeType;
 }
  /**
   * Get file extension corresponds to MIMEType. If MIMEType is empty or equals default MIMEType
   * empty string will be returned. If there is no file extension for specific MIMEType the empty
   * string will be returned also. In case when there are more than one extension for specific
   * MIMEType the first occurred extension in the list will be returned if MIMEType ends with this
   * extension otherwise just first occurred.
   *
   * @param mimeType MIMEType
   * @return file extension
   */
  public String getExtension(String mimeType) {
    String extension = resolver.getExtension(mimeType);
    if (extension.length() == 0) {
      // use this resolver map (the same logic as in MimeTypeResolver)
      mimeType = mimeType.toLowerCase();

      if (mimeType.isEmpty() || mimeType.equals(resolver.getDefaultMimeType())) {
        return "";
      }

      List<String> values = extentions.get(mimeType);
      if (values == null) {
        return "";
      }

      String resultExt = "";
      for (String ext : values) {
        if (mimeType.endsWith(ext)) {
          return ext;
        }

        if (resultExt.isEmpty()) {
          resultExt = ext;
        }
      }
      extension = resultExt;
    }
    return extension;
  }
 /**
  * Get MIMEType which corresponds to file extension. If file extension is unknown the default
  * MIMEType will be returned. If there are more than one MIMETypes for specific extension the
  * first occurred in the list will be returned.
  *
  * @param filename the filename
  * @return String MIMEType
  */
 public String getMimeType(String filename) {
   String mimeType = resolver.getMimeType(filename);
   if (resolver.getDefaultMimeType().equals(mimeType)) {
     // default resolver didn't recognize the type
     // try guess from this resolver map
     String ext = filename.substring(filename.lastIndexOf(".") + 1);
     if (ext.isEmpty()) {
       ext = filename;
     }
     List<String> values = mimeTypes.get(ext.toLowerCase());
     mimeType = values == null ? mimeType : values.get(0);
   }
   return mimeType;
 }
 /**
  * Returns default MIMEType.
  *
  * @return String
  */
 public String getDefaultMimeType() {
   return resolver.getDefaultMimeType();
 }