Author: mattmann
Date: Sat Jun  6 23:18:34 2015
New Revision: 1683966

URL: http://svn.apache.org/r1683966
Log:
Fix for TIKA-1652, TIKA-1426: Tika Server should allow config file override 
from the command line like Tika App

Modified:
    tika/trunk/CHANGES.txt
    
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java

Modified: tika/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/tika/trunk/CHANGES.txt?rev=1683966&r1=1683965&r2=1683966&view=diff
==============================================================================
--- tika/trunk/CHANGES.txt (original)
+++ tika/trunk/CHANGES.txt Sat Jun  6 23:18:34 2015
@@ -1,4 +1,7 @@
-Release 1.9 - Current Development
+Release 1.9 - 6/6/2015
+
+  * Tika-server allows a user to specify the Tika config
+    from the command line (TIKA-1652, TIKA-1426).
 
   * Matlab file detection has been improved (TIKA-1634).
 

Modified: 
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java
URL: 
http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java?rev=1683966&r1=1683965&r2=1683966&view=diff
==============================================================================
--- 
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java 
(original)
+++ 
tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaServerCli.java 
Sat Jun  6 23:18:34 2015
@@ -70,6 +70,7 @@ public class TikaServerCli {
         options.addOption("C", "cors", true, "origin allowed to make CORS 
requests (default=NONE)\nall allowed if \"all\"");
         options.addOption("h", "host", true, "host name (default = " + 
DEFAULT_HOST + ')');
         options.addOption("p", "port", true, "listen port (default = " + 
DEFAULT_PORT + ')');
+        options.addOption("c", "config", true, "Tika Configuration file to 
override default config with.");
         options.addOption("l", "log", true, "request URI log level ('debug' or 
'info')");
         options.addOption("s", "includeStack", false, "whether or not to 
return a stack trace\nif there is an exception during 'parse'");
         options.addOption("?", "help", false, "this help message");
@@ -129,9 +130,18 @@ public class TikaServerCli {
                 if (!url.equals("*")) origins.add(url);         // Empty list 
allows all origins.
                 corsFilter.setAllowOrigins(origins);
             }
-
-            // The Tika Configuration to use throughout
-            TikaConfig tika = TikaConfig.getDefaultConfig();
+            
+            // The Tika Configuration to use throughout            
+            TikaConfig tika;
+            
+            if (line.hasOption("config")){
+              String configFilePath = line.getOptionValue("config");
+             logger.info("Using custom config: "+configFilePath);
+              tika = new TikaConfig(configFilePath);
+            }
+            else{
+              tika = TikaConfig.getDefaultConfig();
+            }
 
             JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
 


Reply via email to