/* $Id$ */

/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.manifoldcf.core.extmimemap;

import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
import java.util.*;

/** Map file extension to a mime type.
*/
public class ExtensionMimeMap
{
  protected final static Map<String,String> mimeMap;
  static {
    mimeMap = new HashMap<String,String>();
    mimeMap.put("xml", "text/xml");
    mimeMap.put("csv", "text/csv");
    mimeMap.put("json", "application/json");
    mimeMap.put("pdf", "application/pdf");
    mimeMap.put("rtf", "text/rtf");
    mimeMap.put("html", "text/html");
    mimeMap.put("htm", "text/html");
    mimeMap.put("doc", "application/msword");
    mimeMap.put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
    mimeMap.put("ppt", "application/vnd.ms-powerpoint");
    mimeMap.put("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
    mimeMap.put("xls", "application/vnd.ms-excel");
    mimeMap.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    mimeMap.put("odt", "application/vnd.oasis.opendocument.text");
    mimeMap.put("ott", "application/vnd.oasis.opendocument.text");
    mimeMap.put("odp", "application/vnd.oasis.opendocument.presentation");
    mimeMap.put("otp", "application/vnd.oasis.opendocument.presentation");
    mimeMap.put("ods", "application/vnd.oasis.opendocument.spreadsheet");
    mimeMap.put("ots", "application/vnd.oasis.opendocument.spreadsheet");
    mimeMap.put("txt", "text/plain");
    mimeMap.put("log", "text/plain");
    mimeMap.put("aspx", "text/html");
  }

  /** Map extension to mime type */
  public static String mapToMimeType(String extension)
  {
    return mimeMap.get(extension.toLowerCase(java.util.Locale.ROOT));
  }
  
}

@@ -913,19 +913,28 @@
 ort 
-java.util.*
+org.apache.tika.Tika
 ;%0A%0A/
@@ -1010,1389 +1010,8 @@
 p%0A%7B%0A
-  protected final static Map%3CString,String%3E mimeMap;%0A  static %7B%0A    mimeMap = new HashMap%3CString,String%3E();%0A    mimeMap.put(%22xml%22, %22text/xml%22);%0A    mimeMap.put(%22csv%22, %22text/csv%22);%0A    mimeMap.put(%22json%22, %22application/json%22);%0A    mimeMap.put(%22pdf%22, %22application/pdf%22);%0A    mimeMap.put(%22rtf%22, %22text/rtf%22);%0A    mimeMap.put(%22html%22, %22text/html%22);%0A    mimeMap.put(%22htm%22, %22text/html%22);%0A    mimeMap.put(%22doc%22, %22application/msword%22);%0A    mimeMap.put(%22docx%22, %22application/vnd.openxmlformats-officedocument.wordprocessingml.document%22);%0A    mimeMap.put(%22ppt%22, %22application/vnd.ms-powerpoint%22);%0A    mimeMap.put(%22pptx%22, %22application/vnd.openxmlformats-officedocument.presentationml.presentation%22);%0A    mimeMap.put(%22xls%22, %22application/vnd.ms-excel%22);%0A    mimeMap.put(%22xlsx%22, %22application/vnd.openxmlformats-officedocument.spreadsheetml.sheet%22);%0A    mimeMap.put(%22odt%22, %22application/vnd.oasis.opendocument.text%22);%0A    mimeMap.put(%22ott%22, %22application/vnd.oasis.opendocument.text%22);%0A    mimeMap.put(%22odp%22, %22application/vnd.oasis.opendocument.presentation%22);%0A    mimeMap.put(%22otp%22, %22application/vnd.oasis.opendocument.presentation%22);%0A    mimeMap.put(%22ods%22, %22application/vnd.oasis.opendocument.spreadsheet%22);%0A    mimeMap.put(%22ots%22, %22application/vnd.oasis.opendocument.spreadsheet%22);%0A    mimeMap.put(%22txt%22, %22text/plain%22);%0A    mimeMap.put(%22log%22, %22text/plain%22);%0A    mimeMap.put(%22aspx%22, %22text/html%22);%0A  %7D%0A%0A
   /*
@@ -1116,64 +1116,40 @@
 urn 
-mimeMap.get(extension.toLowerCase(java.util.Locale.ROOT)
+new Tika().detect(%22x.%22+extension
 );%0A 

Use tika to implement extension mapping