You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2025/12/02 22:50:41 UTC
(tika) 05/07: TIKA-4545: works through tika-server
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch TIKA-4545-jsonify-all-the-things
in repository https://gitbox.apache.org/repos/asf/tika.git
commit 83eedec37ac5c50f722f93c4915b20389aaab814
Author: tallison <ta...@apache.org>
AuthorDate: Tue Dec 2 17:20:59 2025 -0500
TIKA-4545: works through tika-server
---
tika-langdetect/tika-langdetect-opennlp/pom.xml | 6 ++
.../metadatafilter/OpenNLPMetadataFilter.java | 2 +
tika-langdetect/tika-langdetect-optimaize/pom.xml | 6 ++
.../metadatafilter/OptimaizeMetadataFilter.java | 2 +
.../java/org/apache/tika/plugins/TikaConfigs.java | 3 +-
.../org/apache/tika/config/GlobalSettings.java | 51 ++++++++++++--
.../org/apache/tika/config/loader/TikaLoader.java | 53 ++++++++++++---
.../apache/tika/serialization/JsonMetadata.java | 6 +-
.../apache/tika/server/core/TikaServerConfig.java | 45 ++++---------
.../apache/tika/server/core/TikaServerProcess.java | 36 +++-------
.../server/core/resource/DetectorResource.java | 7 +-
.../server/core/resource/MetadataResource.java | 4 +-
.../tika/server/core/resource/PipesResource.java | 7 +-
.../core/resource/RecursiveMetadataResource.java | 8 +--
.../tika/server/core/resource/TikaDetectors.java | 19 +++---
.../tika/server/core/resource/TikaMimeTypes.java | 24 +++----
.../tika/server/core/resource/TikaParsers.java | 31 ++++-----
.../tika/server/core/resource/TikaResource.java | 68 ++++++++-----------
.../tika/server/core/resource/TikaVersion.java | 2 +-
.../tika/server/core/resource/TikaWelcome.java | 2 +-
.../server/core/resource/TranslateResource.java | 7 +-
.../server/core/resource/UnpackerResource.java | 5 +-
.../org/apache/tika/server/core/CXFTestBase.java | 77 ++++++++++++----------
.../org/apache/tika/server/core/TikaPipesTest.java | 24 ++-----
.../tika/server/core/TikaResourceFetcherTest.java | 2 +-
.../core/TikaResourceMetadataFilterTest.java | 2 +-
.../core/TikaServerAsyncIntegrationTest.java | 19 +-----
.../tika/server/core/TikaServerConfigTest.java | 26 +++-----
.../server/core/TikaServerIntegrationTest.java | 30 ++++-----
.../core/TikaServerPipesIntegrationTest.java | 31 ++-------
.../tika/server/core/TranslateResourceTest.java | 2 +
.../resources/configs/cxf-test-base-template.json | 57 ++++++++++++++++
.../resources/configs/metadata-filter-include.json | 13 ++++
.../resources/configs/metadata-filter-include.xml | 28 --------
.../configs/tika-config-server-badjvmargs.xml | 27 --------
.../configs/tika-config-server-basic.json | 12 ++++
.../resources/configs/tika-config-server-basic.xml | 29 --------
.../configs/tika-config-server-emitter.json | 13 ++++
.../configs/tika-config-server-emitter.xml | 30 ---------
.../tika-config-server-fetcher-template.json | 11 ++++
.../tika-config-server-fetcher-template.xml | 28 --------
.../tika-config-server-fetchers-emitters.json | 28 ++++++++
.../tika-config-server-fetchers-emitters.xml | 28 --------
.../configs/tika-config-server-timeout-10000.xml | 24 -------
.../configs/tika-config-server-timeout-5000.json | 7 ++
.../tika-config-server-tls-one-way-template.json | 19 ++++++
.../tika-config-server-tls-one-way-template.xml | 36 ----------
.../tika-config-server-tls-two-way-template.json | 22 +++++++
.../tika-config-server-tls-two-way-template.xml | 39 -----------
.../resources/configs/tika-config-server-tls.json | 38 +++++++++++
.../resources/configs/tika-config-server-tls.xml | 38 -----------
.../test/resources/configs/tika-config-server.json | 29 ++++++++
.../test/resources/configs/tika-config-server.xml | 29 --------
.../standard/config/TesseractServerConfig.java | 4 ++
.../apache/tika/server/standard/FetcherTest.java | 2 +-
.../server/standard/JsonMaxFieldLengthTest.java | 2 +-
.../tika/server/standard/MetadataResourceTest.java | 2 +
.../server/standard/OpenNLPMetadataFilterTest.java | 2 +-
.../standard/OptimaizeMetadataFilterTest.java | 2 +-
.../standard/RecursiveMetadataFilterTest.java | 2 +-
.../standard/RecursiveMetadataResourceTest.java | 7 +-
.../tika/server/standard/TikaParsersTest.java | 71 +++++++++-----------
.../apache/tika/server/standard/TikaPipesTest.java | 29 ++------
.../tika/server/standard/TikaResourceTest.java | 4 +-
.../standard/UnpackerResourceWithConfigTest.java | 4 +-
.../test/resources/config/TIKA-3137-include.xml | 38 -----------
.../config/tika-config-for-server-tests.xml | 29 --------
.../src/test/resources/config/tika-config-json.xml | 20 ------
.../tika-config-langdetect-opennlp-filter.xml | 32 ---------
.../tika-config-langdetect-optimaize-filter.xml | 32 ---------
.../test/resources/config/tika-config-unpacker.xml | 32 ---------
.../test/resources/configs/TIKA-3137-include.json | 21 ++++++
.../configs/tika-config-for-server-tests.json | 22 +++++++
.../test/resources/configs/tika-config-json.json | 3 +
.../tika-config-langdetect-opennlp-filter.json | 27 ++++++++
.../tika-config-langdetect-optimaize-filter.json | 27 ++++++++
.../resources/configs/tika-config-unpacker.json | 17 +++++
.../tika-config-url-fetcher.xml | 0
78 files changed, 727 insertions(+), 896 deletions(-)
diff --git a/tika-langdetect/tika-langdetect-opennlp/pom.xml b/tika-langdetect/tika-langdetect-opennlp/pom.xml
index 94a64da70..f40614fe5 100644
--- a/tika-langdetect/tika-langdetect-opennlp/pom.xml
+++ b/tika-langdetect/tika-langdetect-opennlp/pom.xml
@@ -41,6 +41,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>tika-annotation-processor</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/tika-langdetect/tika-langdetect-opennlp/src/main/java/org/apache/tika/langdetect/opennlp/metadatafilter/OpenNLPMetadataFilter.java b/tika-langdetect/tika-langdetect-opennlp/src/main/java/org/apache/tika/langdetect/opennlp/metadatafilter/OpenNLPMetadataFilter.java
index b7becc88d..512c2981d 100644
--- a/tika-langdetect/tika-langdetect-opennlp/src/main/java/org/apache/tika/langdetect/opennlp/metadatafilter/OpenNLPMetadataFilter.java
+++ b/tika-langdetect/tika-langdetect-opennlp/src/main/java/org/apache/tika/langdetect/opennlp/metadatafilter/OpenNLPMetadataFilter.java
@@ -17,12 +17,14 @@
package org.apache.tika.langdetect.opennlp.metadatafilter;
import org.apache.tika.config.Field;
+import org.apache.tika.config.TikaComponent;
import org.apache.tika.langdetect.opennlp.OpenNLPDetector;
import org.apache.tika.language.detect.LanguageResult;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.metadata.filter.MetadataFilterBase;
+@TikaComponent
public class OpenNLPMetadataFilter extends MetadataFilterBase {
private int maxCharsForDetection = 10000;
diff --git a/tika-langdetect/tika-langdetect-optimaize/pom.xml b/tika-langdetect/tika-langdetect-optimaize/pom.xml
index 9bb60ed52..cd26c6e96 100644
--- a/tika-langdetect/tika-langdetect-optimaize/pom.xml
+++ b/tika-langdetect/tika-langdetect-optimaize/pom.xml
@@ -52,6 +52,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>tika-annotation-processor</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/tika-langdetect/tika-langdetect-optimaize/src/main/java/org/apache/tika/langdetect/optimaize/metadatafilter/OptimaizeMetadataFilter.java b/tika-langdetect/tika-langdetect-optimaize/src/main/java/org/apache/tika/langdetect/optimaize/metadatafilter/OptimaizeMetadataFilter.java
index cb850d2de..6539046b1 100644
--- a/tika-langdetect/tika-langdetect-optimaize/src/main/java/org/apache/tika/langdetect/optimaize/metadatafilter/OptimaizeMetadataFilter.java
+++ b/tika-langdetect/tika-langdetect-optimaize/src/main/java/org/apache/tika/langdetect/optimaize/metadatafilter/OptimaizeMetadataFilter.java
@@ -17,12 +17,14 @@
package org.apache.tika.langdetect.optimaize.metadatafilter;
import org.apache.tika.config.Field;
+import org.apache.tika.config.TikaComponent;
import org.apache.tika.langdetect.optimaize.OptimaizeLangDetector;
import org.apache.tika.language.detect.LanguageResult;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.metadata.filter.MetadataFilterBase;
+@TikaComponent
public class OptimaizeMetadataFilter extends MetadataFilterBase {
private int maxCharsForDetection = OptimaizeLangDetector.DEFAULT_MAX_CHARS_FOR_DETECTION;
diff --git a/tika-plugins-core/src/main/java/org/apache/tika/plugins/TikaConfigs.java b/tika-plugins-core/src/main/java/org/apache/tika/plugins/TikaConfigs.java
index 0b7f80df6..acefb3640 100644
--- a/tika-plugins-core/src/main/java/org/apache/tika/plugins/TikaConfigs.java
+++ b/tika-plugins-core/src/main/java/org/apache/tika/plugins/TikaConfigs.java
@@ -62,7 +62,8 @@ public class TikaConfigs {
"renderers",
"translators",
"auto-detect-parser-config",
- "autoDetectParserConfig"
+ "autoDetectParserConfig",
+ "server"
);
static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
diff --git a/tika-serialization/src/main/java/org/apache/tika/config/GlobalSettings.java b/tika-serialization/src/main/java/org/apache/tika/config/GlobalSettings.java
index 3f8bb43f6..14cba451b 100644
--- a/tika-serialization/src/main/java/org/apache/tika/config/GlobalSettings.java
+++ b/tika-serialization/src/main/java/org/apache/tika/config/GlobalSettings.java
@@ -44,11 +44,18 @@ import org.apache.tika.exception.TikaConfigException;
public class GlobalSettings {
/**
- * Maximum length for JSON string fields.
+ * Static maximum length for JSON string fields.
* Default: 20,000,000 (Jackson's default)
+ * This is static because it's a global setting that affects all JSON parsing.
+ */
+ private static Integer maxJsonStringFieldLength = 20_000_000;
+
+ /**
+ * Instance field for deserialization from JSON.
+ * The value is copied to the static field when set.
*/
@JsonProperty("maxJsonStringFieldLength")
- private Integer maxJsonStringFieldLength;
+ private Integer instanceMaxJsonStringFieldLength = 20_000_000;
/**
* Service loader configuration for handling initialization problems.
@@ -62,12 +69,46 @@ public class GlobalSettings {
@JsonProperty("xml-reader-utils")
private XmlReaderUtilsConfig xmlReaderUtils;
- public Integer getMaxJsonStringFieldLength() {
+ /**
+ * Gets the static maximum JSON string field length.
+ *
+ * @return the max length, or null if not set
+ */
+ public static Integer getMaxJsonStringFieldLength() {
return maxJsonStringFieldLength;
}
- public void setMaxJsonStringFieldLength(Integer maxJsonStringFieldLength) {
- this.maxJsonStringFieldLength = maxJsonStringFieldLength;
+ /**
+ * Sets the static maximum JSON string field length.
+ * This affects all JSON parsing globally.
+ *
+ * @param length the max length to set
+ */
+ public static void setMaxJsonStringFieldLength(Integer length) {
+ maxJsonStringFieldLength = length;
+ }
+
+ /**
+ * Instance getter for deserialization.
+ * Returns the instance value which may differ from the static value.
+ *
+ * @return the instance max length
+ */
+ public Integer getInstanceMaxJsonStringFieldLength() {
+ return instanceMaxJsonStringFieldLength;
+ }
+
+ /**
+ * Instance setter for deserialization.
+ * Automatically updates the static field when set.
+ *
+ * @param length the max length to set
+ */
+ public void setInstanceMaxJsonStringFieldLength(Integer length) {
+ this.instanceMaxJsonStringFieldLength = length;
+ if (length != null) {
+ setMaxJsonStringFieldLength(length);
+ }
}
public ServiceLoaderConfig getServiceLoader() {
diff --git a/tika-serialization/src/main/java/org/apache/tika/config/loader/TikaLoader.java b/tika-serialization/src/main/java/org/apache/tika/config/loader/TikaLoader.java
index 77c417284..cdd920116 100644
--- a/tika-serialization/src/main/java/org/apache/tika/config/loader/TikaLoader.java
+++ b/tika-serialization/src/main/java/org/apache/tika/config/loader/TikaLoader.java
@@ -83,6 +83,7 @@ public class TikaLoader {
private static MimeTypes mimeTypes;
private static TikaLoader defaultLoader;
private Parser parsers;
+ private Parser autoDetectParser;
private Detector detectors;
private EncodingDetector encodingDetectors;
private MetadataFilter metadataFilter;
@@ -96,8 +97,19 @@ public class TikaLoader {
this.objectMapper = PolymorphicObjectMapperFactory.getMapper();
}
+ /**
+ * Initializes the loader by loading global settings.
+ * Should be called by all factory methods after construction.
+ *
+ * @throws TikaConfigException if loading global settings fails
+ */
+ private void init() throws TikaConfigException {
+ loadGlobalSettings();
+ }
+
/**
* Loads a Tika configuration from a file.
+ * Global settings are automatically loaded and applied during initialization.
*
* @param configPath the path to the JSON configuration file
* @return the Tika loader
@@ -109,6 +121,7 @@ public class TikaLoader {
/**
* Loads a Tika configuration from a file with a specific class loader.
+ * Global settings are automatically loaded and applied during initialization.
*
* @param configPath the path to the JSON configuration file
* @param classLoader the class loader to use for loading components
@@ -118,7 +131,9 @@ public class TikaLoader {
public static TikaLoader load(Path configPath, ClassLoader classLoader)
throws TikaConfigException {
TikaJsonConfig config = TikaJsonConfig.load(configPath);
- return new TikaLoader(config, classLoader);
+ TikaLoader loader = new TikaLoader(config, classLoader);
+ loader.init();
+ return loader;
}
/**
@@ -144,7 +159,14 @@ public class TikaLoader {
*/
public static TikaLoader loadDefault(ClassLoader classLoader) {
TikaJsonConfig config = TikaJsonConfig.loadDefault();
- return new TikaLoader(config, classLoader);
+ TikaLoader loader = new TikaLoader(config, classLoader);
+ try {
+ loader.init();
+ } catch (TikaConfigException e) {
+ // Default config should never throw, but wrap in RuntimeException if it does
+ throw new RuntimeException("Failed to initialize default TikaLoader", e);
+ }
+ return loader;
}
/**
@@ -265,12 +287,23 @@ public class TikaLoader {
return renderers;
}
- public Parser loadAutoDetectParser() throws TikaConfigException, IOException {
- AutoDetectParserConfig adpConfig = configs().load(AutoDetectParserConfig.class);
- if (adpConfig == null) {
- adpConfig = new AutoDetectParserConfig();
+ /**
+ * Loads and returns an AutoDetectParser configured with this loader's parsers and detectors.
+ * Results are cached - subsequent calls return the same instance.
+ *
+ * @return the auto-detect parser
+ * @throws TikaConfigException if loading fails
+ * @throws IOException if loading AutoDetectParserConfig fails
+ */
+ public synchronized Parser loadAutoDetectParser() throws TikaConfigException, IOException {
+ if (autoDetectParser == null) {
+ AutoDetectParserConfig adpConfig = configs().load(AutoDetectParserConfig.class);
+ if (adpConfig == null) {
+ adpConfig = new AutoDetectParserConfig();
+ }
+ autoDetectParser = AutoDetectParser.build((CompositeParser)loadParsers(), loadDetectors(), adpConfig);
}
- return AutoDetectParser.build((CompositeParser)loadParsers(), loadDetectors(), adpConfig);
+ return autoDetectParser;
}
/**
@@ -337,7 +370,7 @@ public class TikaLoader {
*
* <p>Settings include:
* <ul>
- * <li>maxJsonStringFieldLength - Maximum JSON string field length</li>
+ * <li>maxJsonStringFieldLength - Maximum JSON string field length (static, affects all JSON parsing)</li>
* <li>service-loader.initializableProblemHandler - How to handle initialization problems</li>
* <li>xml-reader-utils - XML parser security settings</li>
* </ul>
@@ -364,9 +397,9 @@ public class TikaLoader {
if (globalSettings == null) {
globalSettings = new GlobalSettings();
- // Load maxJsonStringFieldLength from top level
+ // Load maxJsonStringFieldLength from top level and set it statically
if (config.getRootNode().has("maxJsonStringFieldLength")) {
- globalSettings.setMaxJsonStringFieldLength(
+ GlobalSettings.setMaxJsonStringFieldLength(
config.getRootNode().get("maxJsonStringFieldLength").asInt());
}
diff --git a/tika-serialization/src/main/java/org/apache/tika/serialization/JsonMetadata.java b/tika-serialization/src/main/java/org/apache/tika/serialization/JsonMetadata.java
index b47acde2e..4f4374219 100644
--- a/tika-serialization/src/main/java/org/apache/tika/serialization/JsonMetadata.java
+++ b/tika-serialization/src/main/java/org/apache/tika/serialization/JsonMetadata.java
@@ -26,7 +26,9 @@ import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
+import org.apache.tika.config.GlobalSettings;
import org.apache.tika.config.TikaConfig;
+import org.apache.tika.config.loader.TikaLoader;
import org.apache.tika.metadata.Metadata;
public class JsonMetadata {
@@ -79,8 +81,8 @@ public class JsonMetadata {
if (OBJECT_MAPPER
.getFactory()
.streamReadConstraints()
- .getMaxStringLength() != TikaConfig.getMaxJsonStringFieldLength()) {
- OBJECT_MAPPER = buildObjectMapper(TikaConfig.getMaxJsonStringFieldLength());
+ .getMaxStringLength() != GlobalSettings.getMaxJsonStringFieldLength()) {
+ OBJECT_MAPPER = buildObjectMapper(GlobalSettings.getMaxJsonStringFieldLength());
}
return OBJECT_MAPPER.readValue(reader, Metadata.class);
}
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java
index 064188bbb..15ac1cb69 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java
@@ -35,6 +35,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.tika.config.ConfigBase;
+import org.apache.tika.config.loader.TikaLoader;
import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.exception.TikaException;
@@ -106,7 +107,7 @@ private long forkedProcessShutdownMillis = DEFAULT_FORKED_PROCESS_SHUTDOWN_MILLI
//debug or info only
private String logLevel = "";
private Path configPath;
- private List<String> endpoints = new ArrayList<>();
+ private ArrayList<String> endpoints = new ArrayList<>();
private boolean preventStopMethod = false;
@@ -124,11 +125,9 @@ private long forkedProcessShutdownMillis = DEFAULT_FORKED_PROCESS_SHUTDOWN_MILLI
TikaServerConfig config = null;
Set<String> settings = new HashSet<>();
Path pluginsConfig = null;
- if (commandLine.hasOption('a')) {
- pluginsConfig = Paths.get(commandLine.getOptionValue('a'));
- }
+
if (commandLine.hasOption("c")) {
- config = load(Paths.get(commandLine.getOptionValue("c")), pluginsConfig, commandLine, settings);
+ config = load(Paths.get(commandLine.getOptionValue("c")), commandLine, settings);
} else {
config = new TikaServerConfig();
}
@@ -153,24 +152,12 @@ private long forkedProcessShutdownMillis = DEFAULT_FORKED_PROCESS_SHUTDOWN_MILLI
return config;
}
- static TikaServerConfig load(Path p, Path pluginsConfigPath, CommandLine commandLine, Set<String> settings) throws IOException, TikaException {
- try (InputStream is = Files.newInputStream(p)) {
- TikaServerConfig config = TikaServerConfig.load(is, pluginsConfigPath, commandLine, settings);
- if (config.getConfigPath() == null) {
- config.setConfigPath(p
- .toAbsolutePath()
- .toString());
- }
- config.setPipesConfigPath(pluginsConfigPath);
- return config;
+ static TikaServerConfig load(Path tikaConfigPath, CommandLine commandLine, Set<String> settings) throws IOException, TikaException {
+ TikaServerConfig tikaServerConfig = TikaLoader.load(tikaConfigPath).configs().load("server", TikaServerConfig.class);
+ if (tikaServerConfig == null) {
+ throw new TikaConfigException("Couldn't find 'server' element");
}
- }
-
- private static TikaServerConfig load(InputStream is, Path pluginsConfigPath, CommandLine commandLine, Set<String> settings) throws IOException, TikaException {
- TikaServerConfig tikaServerConfig = new TikaServerConfig();
- Set<String> configSettings = tikaServerConfig.configure("server", is);
- settings.addAll(configSettings);
- tikaServerConfig.setPipesConfigPath(pluginsConfigPath);
+ tikaServerConfig.setConfigPath(tikaConfigPath.toAbsolutePath().toString());
return tikaServerConfig;
}
@@ -286,14 +273,6 @@ private long forkedProcessShutdownMillis = DEFAULT_FORKED_PROCESS_SHUTDOWN_MILLI
this.configPath = Paths.get(path);
}
- public void setPipesConfigPath(Path path) {
- this.pluginsConfigPath = path;
- }
-
- public Optional<Path> getPipesConfigPath() {
- return Optional.ofNullable(pluginsConfigPath);
- }
-
public int getDigestMarkLimit() {
return digestMarkLimit;
}
@@ -333,12 +312,12 @@ private long forkedProcessShutdownMillis = DEFAULT_FORKED_PROCESS_SHUTDOWN_MILLI
this.tlsConfig = tlsConfig;
}
- public List<String> getEndpoints() {
+ public ArrayList<String> getEndpoints() {
return endpoints;
}
- public void setEndpoints(List<String> endpoints) {
- this.endpoints = new ArrayList<>(endpoints);
+ public void setEndpoints(ArrayList<String> endpoints) {
+ this.endpoints = endpoints;
}
public String getId() {
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java
index 88da4ad70..0c4eefd64 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java
@@ -57,6 +57,7 @@ import org.xml.sax.SAXException;
import org.apache.tika.Tika;
import org.apache.tika.config.ServiceLoader;
import org.apache.tika.config.TikaConfig;
+import org.apache.tika.config.loader.TikaLoader;
import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.exception.TikaException;
import org.apache.tika.parser.DigestingParser;
@@ -167,36 +168,21 @@ public class TikaServerProcess {
int port = tikaServerConfig.getPort();
// The Tika Configuration to use throughout
- TikaConfig tika;
+ TikaLoader tikaLoader;
if (tikaServerConfig.hasConfigFile()) {
LOG.info("Using custom config: {}", tikaServerConfig.getConfigPath());
- tika = new TikaConfig(tikaServerConfig.getConfigPath());
+ tikaLoader = TikaLoader.load(tikaServerConfig.getConfigPath());
} else {
- tika = TikaConfig.getDefaultConfig();
- }
-
- DigestingParser.Digester digester = null;
- if (!StringUtils.isBlank(tikaServerConfig.getDigest())) {
- try {
- digester = new CommonsDigester(tikaServerConfig.getDigestMarkLimit(), tikaServerConfig.getDigest());
- } catch (IllegalArgumentException commonsException) {
- try {
- digester = new BouncyCastleDigester(tikaServerConfig.getDigestMarkLimit(), tikaServerConfig.getDigest());
- } catch (IllegalArgumentException bcException) {
- throw new IllegalArgumentException(
- "Tried both CommonsDigester (" + commonsException.getMessage() + ") and BouncyCastleDigester (" + bcException.getMessage() + ")", bcException);
- }
- }
+ tikaLoader = TikaLoader.loadDefault();
}
//TODO -- clean this up -- only load as necessary
//REALLY NEED TODO THIS
FetcherManager fetcherManager = null;
InputStreamFactory inputStreamFactory = null;
- if (tikaServerConfig.isEnableUnsecureFeatures() &&
- tikaServerConfig.getPipesConfigPath().isPresent()) {
- TikaConfigs tikaConfigs = TikaConfigs.load(tikaServerConfig.getPipesConfigPath().get());
+ if (tikaServerConfig.isEnableUnsecureFeatures()) {
+ TikaConfigs tikaConfigs = TikaConfigs.load(tikaServerConfig.getConfigPath());
TikaPluginManager pluginManager = TikaPluginManager.load(tikaConfigs);
fetcherManager = FetcherManager.load(pluginManager, tikaConfigs);
inputStreamFactory = new FetcherStreamFactory(fetcherManager);
@@ -210,7 +196,7 @@ public class TikaServerProcess {
ServerStatus serverStatus;
serverStatus = new ServerStatus();
- TikaResource.init(tika, tikaServerConfig, digester, inputStreamFactory, serverStatus);
+ TikaResource.init(tikaLoader, tikaServerConfig, inputStreamFactory, serverStatus);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
List<ResourceProvider> resourceProviders = new ArrayList<>();
@@ -385,9 +371,6 @@ public class TikaServerProcess {
}
if (addAsyncResource) {
- if (tikaServerConfig.getPipesConfigPath().isEmpty()) {
- throw new TikaConfigException("Must specify a pipes config on the commandline with the -a option");
- }
final AsyncResource localAsyncResource = new AsyncResource(tikaServerConfig.getConfigPath());
Runtime
.getRuntime()
@@ -401,10 +384,7 @@ public class TikaServerProcess {
resourceProviders.add(new SingletonResourceProvider(localAsyncResource));
}
if (addPipesResource) {
- if (tikaServerConfig.getPipesConfigPath().isEmpty()) {
- throw new TikaConfigException("Must specify a pipes config on the commandline with the -a option");
- }
- final PipesResource localPipesResource = new PipesResource(tikaServerConfig.getConfigPath(), tikaServerConfig.getPipesConfigPath().get());
+ final PipesResource localPipesResource = new PipesResource(tikaServerConfig.getConfigPath());
Runtime
.getRuntime()
.addShutdownHook(new Thread(() -> {
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/DetectorResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/DetectorResource.java
index bee7fc0bb..fb5a4f022 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/DetectorResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/DetectorResource.java
@@ -30,6 +30,7 @@ import jakarta.ws.rs.core.UriInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.io.TikaInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
@@ -63,11 +64,11 @@ public class DetectorResource {
try (TikaInputStream tis = TikaInputStream.get(TikaResource.getInputStream(is, met, httpHeaders, info))) {
return TikaResource
- .getConfig()
- .getDetector()
+ .getTikaLoader()
+ .loadDetectors()
.detect(tis, met)
.toString();
- } catch (IOException e) {
+ } catch (IOException | TikaConfigException e) {
LOG.warn("Unable to detect MIME type for file. Reason: {} ({})", e.getMessage(), filename, e);
return MediaType.OCTET_STREAM.toString();
} catch (OutOfMemoryError e) {
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/MetadataResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/MetadataResource.java
index 29e452d94..e562da7d8 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/MetadataResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/MetadataResource.java
@@ -38,6 +38,7 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.extractor.DocumentSelector;
import org.apache.tika.language.detect.LanguageHandler;
import org.apache.tika.metadata.Metadata;
@@ -129,7 +130,8 @@ public class MetadataResource {
.build();
}
- protected Metadata parseMetadata(InputStream is, Metadata metadata, MultivaluedMap<String, String> httpHeaders, UriInfo info) throws IOException {
+ protected Metadata parseMetadata(InputStream is, Metadata metadata, MultivaluedMap<String, String> httpHeaders, UriInfo info)
+ throws IOException, TikaConfigException {
final ParseContext context = new ParseContext();
Parser parser = TikaResource.createParser();
fillMetadata(parser, metadata, httpHeaders);
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/PipesResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/PipesResource.java
index 159eb9483..633f16587 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/PipesResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/PipesResource.java
@@ -34,13 +34,16 @@ import jakarta.ws.rs.core.UriInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.tika.config.loader.TikaLoader;
import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.pipes.api.FetchEmitTuple;
import org.apache.tika.pipes.api.PipesResult;
+import org.apache.tika.pipes.core.PipesConfig;
import org.apache.tika.pipes.core.PipesException;
import org.apache.tika.pipes.core.PipesParser;
+import org.apache.tika.pipes.core.async.AsyncConfig;
import org.apache.tika.pipes.core.serialization.JsonFetchEmitTuple;
@Path("/pipes")
@@ -51,8 +54,8 @@ public class PipesResource {
private final PipesParser pipesParser;
- public PipesResource(java.nio.file.Path tikaConfig, java.nio.file.Path asyncConfig) throws TikaConfigException, IOException {
- PipesConfig pipesConfig = PipesConfig.load(tikaConfig, asyncConfig);
+ public PipesResource(java.nio.file.Path tikaConfig) throws TikaConfigException, IOException {
+ PipesConfig pipesConfig = TikaLoader.load(tikaConfig).configs().load("async", AsyncConfig.class);
//this has to be zero. everything must be emitted through the PipesServer
long maxEmit = pipesConfig.getMaxForEmitBatchBytes();
if (maxEmit != 0) {
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/RecursiveMetadataResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/RecursiveMetadataResource.java
index f620f7694..d564f97af 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/RecursiveMetadataResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/RecursiveMetadataResource.java
@@ -19,7 +19,7 @@ package org.apache.tika.server.core.resource;
import static org.apache.tika.server.core.resource.TikaResource.fillMetadata;
import static org.apache.tika.server.core.resource.TikaResource.fillParseContext;
-import static org.apache.tika.server.core.resource.TikaResource.getConfig;
+import static org.apache.tika.server.core.resource.TikaResource.getTikaLoader;
import java.io.InputStream;
import java.util.List;
@@ -74,8 +74,8 @@ public class RecursiveMetadataResource {
RecursiveParserWrapperHandler handler =
new RecursiveParserWrapperHandler(new BasicContentHandlerFactory(type, handlerConfig.getWriteLimit(), handlerConfig.isThrowOnWriteLimitReached(), context),
handlerConfig.getMaxEmbeddedResources(), TikaResource
- .getConfig()
- .getMetadataFilter());
+ .getTikaLoader()
+ .loadMetadataFilters());
try {
TikaResource.parse(wrapper, LOG, "/rmeta", is, handler, metadata, context);
} catch (TikaServerParseException e) {
@@ -87,7 +87,7 @@ public class RecursiveMetadataResource {
//we shouldn't get here?
LOG.error("something went seriously wrong", e);
}
- MetadataFilter metadataFilter = context.get(MetadataFilter.class, getConfig().getMetadataFilter());
+ MetadataFilter metadataFilter = context.get(MetadataFilter.class, getTikaLoader().loadMetadataFilters());
//note that the filter may modify the contents of handler's metadata list.
//do a deep copy if that's problematic.
return metadataFilter.filter(handler.getMetadataList());
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaDetectors.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaDetectors.java
index d9166dca3..07b12285b 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaDetectors.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaDetectors.java
@@ -29,6 +29,7 @@ import jakarta.ws.rs.Produces;
import org.apache.tika.detect.CompositeDetector;
import org.apache.tika.detect.Detector;
+import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.server.core.HTMLHelper;
/**
@@ -46,12 +47,12 @@ public class TikaDetectors {
@GET
@Produces("text/html")
- public String getDectorsHTML() {
+ public String getDectorsHTML() throws TikaConfigException {
StringBuffer h = new StringBuffer();
html.generateHeader(h, "Detectors available to Apache Tika");
detectorAsHTML(TikaResource
- .getConfig()
- .getDetector(), h, 2);
+ .getTikaLoader()
+ .loadDetectors(), h, 2);
html.generateFooter(h);
return h.toString();
}
@@ -80,11 +81,11 @@ public class TikaDetectors {
@GET
@Produces(jakarta.ws.rs.core.MediaType.APPLICATION_JSON)
- public String getDetectorsJSON() throws IOException {
+ public String getDetectorsJSON() throws IOException, TikaConfigException {
Map<String, Object> details = new HashMap<>();
detectorAsMap(TikaResource
- .getConfig()
- .getDetector(), details);
+ .getTikaLoader()
+ .loadDetectors(), details);
return new ObjectMapper().writeValueAsString(details);
}
@@ -108,11 +109,11 @@ public class TikaDetectors {
@GET
@Produces("text/plain")
- public String getDetectorsPlain() {
+ public String getDetectorsPlain() throws TikaConfigException {
StringBuffer text = new StringBuffer();
renderDetector(TikaResource
- .getConfig()
- .getDetector(), text, 0);
+ .getTikaLoader()
+ .loadDetectors(), text, 0);
return text.toString();
}
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaMimeTypes.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaMimeTypes.java
index 36f74418b..d6bb0a879 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaMimeTypes.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaMimeTypes.java
@@ -33,6 +33,8 @@ import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import org.apache.tika.config.TikaConfig;
+import org.apache.tika.config.loader.TikaLoader;
+import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.mime.MediaType;
import org.apache.tika.mime.MediaTypeRegistry;
import org.apache.tika.mime.MimeType;
@@ -66,7 +68,7 @@ public class TikaMimeTypes {
@GET
@Produces("text/html")
- public String getMimeTypesHTML() {
+ public String getMimeTypesHTML() throws TikaConfigException {
StringBuffer h = new StringBuffer();
html.generateHeader(h, "Apache Tika Supported Mime Types");
@@ -160,7 +162,7 @@ public class TikaMimeTypes {
@GET
@Path("/{type}/{subtype}")
@Produces("text/html")
- public String getMimeTypeDetailsHTML(@PathParam("type") String typePart, @PathParam("subtype") String subtype) {
+ public String getMimeTypeDetailsHTML(@PathParam("type") String typePart, @PathParam("subtype") String subtype) throws TikaConfigException {
MediaTypeDetails type = getMediaType(typePart, subtype);
StringBuffer h = new StringBuffer();
@@ -244,7 +246,7 @@ public class TikaMimeTypes {
@GET
@Produces(jakarta.ws.rs.core.MediaType.APPLICATION_JSON)
- public String getMimeTypesJSON() throws IOException {
+ public String getMimeTypesJSON() throws IOException, TikaConfigException {
Map<String, Object> details = new HashMap<>();
for (MediaTypeDetails type : getMediaTypes()) {
@@ -269,7 +271,7 @@ public class TikaMimeTypes {
@GET
@Path("/{type}/{subtype}")
@Produces(jakarta.ws.rs.core.MediaType.APPLICATION_JSON)
- public String getMimeTypeDetailsJSON(@PathParam("type") String typePart, @PathParam("subtype") String subtype) throws IOException {
+ public String getMimeTypeDetailsJSON(@PathParam("type") String typePart, @PathParam("subtype") String subtype) throws IOException, TikaConfigException {
MediaTypeDetails type = getMediaType(typePart, subtype);
Map<String, Object> details = new HashMap<>();
@@ -321,7 +323,7 @@ public class TikaMimeTypes {
@GET
@Produces("text/plain")
- public String getMimeTypesPlain() {
+ public String getMimeTypesPlain() throws TikaConfigException {
StringBuilder text = new StringBuilder();
for (MediaTypeDetails type : getMediaTypes()) {
@@ -352,7 +354,7 @@ public class TikaMimeTypes {
return text.toString();
}
- protected MediaTypeDetails getMediaType(String type, String subtype) throws NotFoundException {
+ protected MediaTypeDetails getMediaType(String type, String subtype) throws NotFoundException, TikaConfigException {
MediaType mt = MediaType.parse(type + "/" + subtype);
for (MediaTypeDetails mtd : getMediaTypes()) {
if (mtd.type.equals(mt)) {
@@ -362,11 +364,11 @@ public class TikaMimeTypes {
throw new NotFoundException("No Media Type registered in Tika for " + mt);
}
- protected List<MediaTypeDetails> getMediaTypes() {
- TikaConfig config = TikaResource.getConfig();
- MimeTypes mimeTypes = config.getMimeRepository();
- MediaTypeRegistry registry = config.getMediaTypeRegistry();
- Map<MediaType, Parser> parsers = ((CompositeParser) config.getParser()).getParsers();
+ protected List<MediaTypeDetails> getMediaTypes() throws TikaConfigException {
+ TikaLoader tikaLoader = TikaResource.getTikaLoader();
+ MimeTypes mimeTypes = TikaLoader.getMimeTypes();
+ MediaTypeRegistry registry = mimeTypes.getMediaTypeRegistry();
+ Map<MediaType, Parser> parsers = ((CompositeParser) tikaLoader.loadParsers()).getParsers();
List<MediaTypeDetails> types = new ArrayList<>(registry
.getTypes()
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaParsers.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaParsers.java
index 64e645c59..318ff5afc 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaParsers.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaParsers.java
@@ -31,6 +31,7 @@ import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
+import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.mime.MediaType;
import org.apache.tika.parser.CompositeParser;
import org.apache.tika.parser.ParseContext;
@@ -55,20 +56,20 @@ public class TikaParsers {
@GET
@Path("/details")
@Produces("text/html")
- public String getParserDetailsHTML() {
+ public String getParserDetailsHTML() throws TikaConfigException {
return getParsersHTML(true);
}
@GET
@Produces("text/html")
- public String getParsersHTML() {
+ public String getParsersHTML() throws TikaConfigException {
return getParsersHTML(false);
}
- protected String getParsersHTML(boolean withMimeTypes) {
+ protected String getParsersHTML(boolean withMimeTypes) throws TikaConfigException {
ParserDetails p = new ParserDetails(TikaResource
- .getConfig()
- .getParser());
+ .getTikaLoader()
+ .loadParsers());
StringBuffer h = new StringBuffer();
html.generateHeader(h, "Parsers available to Apache Tika");
@@ -121,21 +122,21 @@ public class TikaParsers {
@GET
@Path("/details")
@Produces(jakarta.ws.rs.core.MediaType.APPLICATION_JSON)
- public String getParserDetailsJSON() throws IOException {
+ public String getParserDetailsJSON() throws IOException, TikaConfigException {
return getParsersJSON(true);
}
@GET
@Produces(jakarta.ws.rs.core.MediaType.APPLICATION_JSON)
- public String getParsersJSON() throws IOException {
+ public String getParsersJSON() throws IOException, TikaConfigException {
return getParsersJSON(false);
}
- protected String getParsersJSON(boolean withMimeTypes) throws IOException {
+ protected String getParsersJSON(boolean withMimeTypes) throws IOException, TikaConfigException {
Map<String, Object> details = new HashMap<>();
parserAsMap(new ParserDetails(TikaResource
- .getConfig()
- .getParser()), withMimeTypes, details);
+ .getTikaLoader()
+ .loadParsers()), withMimeTypes, details);
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper
.writerWithDefaultPrettyPrinter()
@@ -167,21 +168,21 @@ public class TikaParsers {
@GET
@Path("/details")
@Produces("text/plain")
- public String getParserDetailssPlain() {
+ public String getParserDetailssPlain() throws TikaConfigException {
return getParsersPlain(true);
}
@GET
@Produces("text/plain")
- public String getParsersPlain() {
+ public String getParsersPlain() throws TikaConfigException {
return getParsersPlain(false);
}
- protected String getParsersPlain(boolean withMimeTypes) {
+ protected String getParsersPlain(boolean withMimeTypes) throws TikaConfigException {
StringBuffer text = new StringBuffer();
renderParser(new ParserDetails(TikaResource
- .getConfig()
- .getParser()), withMimeTypes, text, "");
+ .getTikaLoader()
+ .loadParsers()), withMimeTypes, text, "");
return text.toString();
}
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaResource.java
index fcbb24c87..c97c9ccaa 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaResource.java
@@ -64,14 +64,14 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.apache.tika.Tika;
-import org.apache.tika.config.TikaConfig;
import org.apache.tika.config.TikaTaskTimeout;
+import org.apache.tika.config.loader.TikaLoader;
import org.apache.tika.exception.EncryptedDocumentException;
+import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.exception.TikaException;
import org.apache.tika.exception.WriteLimitReachedException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
-import org.apache.tika.parser.AutoDetectParser;
import org.apache.tika.parser.DigestingParser;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.Parser;
@@ -96,46 +96,30 @@ public class TikaResource {
private static final String META_PREFIX = "meta_";
private static final Logger LOG = LoggerFactory.getLogger(TikaResource.class);
private static Pattern ALLOWABLE_HEADER_CHARS = Pattern.compile("(?i)^[-/_+\\.A-Z0-9 ]+$");
- private static TikaConfig TIKA_CONFIG;
+ private static TikaLoader TIKA_LOADER;
private static TikaServerConfig TIKA_SERVER_CONFIG;
- private static DigestingParser.Digester DIGESTER = null;
private static InputStreamFactory INPUTSTREAM_FACTORY = null;
private static ServerStatus SERVER_STATUS = null;
private static ParseContextConfig PARSE_CONTEXT_CONFIG = new CompositeParseContextConfig();
- public static void init(TikaConfig config, TikaServerConfig tikaServerConfg, DigestingParser.Digester digester, InputStreamFactory inputStreamFactory,
+ public static void init(TikaLoader tikaLoader, TikaServerConfig tikaServerConfg, InputStreamFactory inputStreamFactory,
ServerStatus serverStatus) {
- TIKA_CONFIG = config;
+ TIKA_LOADER = tikaLoader;
TIKA_SERVER_CONFIG = tikaServerConfg;
- DIGESTER = digester;
INPUTSTREAM_FACTORY = inputStreamFactory;
SERVER_STATUS = serverStatus;
}
@SuppressWarnings("serial")
- public static Parser createParser() {
- final Parser parser = new AutoDetectParser(TIKA_CONFIG);
-
- if (DIGESTER != null) {
- boolean skipContainer = false;
- if (TIKA_CONFIG
- .getAutoDetectParserConfig()
- .getDigesterFactory() != null && TIKA_CONFIG
- .getAutoDetectParserConfig()
- .getDigesterFactory()
- .isSkipContainerDocument()) {
- skipContainer = true;
- }
- return new DigestingParser(parser, DIGESTER, skipContainer);
- }
- return parser;
+ public static Parser createParser() throws TikaConfigException, IOException {
+ return TIKA_LOADER.loadAutoDetectParser();
}
- public static TikaConfig getConfig() {
- return TIKA_CONFIG;
+ public static TikaLoader getTikaLoader() {
+ return TIKA_LOADER;
}
public static String detectFilename(MultivaluedMap<String, String> httpHeaders) {
@@ -444,7 +428,7 @@ public class TikaResource {
@Consumes("multipart/form-data")
@Produces("text/plain")
@Path("form")
- public StreamingOutput getTextFromMultipart(Attachment att, @Context HttpHeaders httpHeaders, @Context final UriInfo info) {
+ public StreamingOutput getTextFromMultipart(Attachment att, @Context HttpHeaders httpHeaders, @Context final UriInfo info) throws TikaConfigException, IOException {
return produceText(att.getObject(InputStream.class), new Metadata(), preparePostHeaderMap(att, httpHeaders), info);
}
@@ -453,7 +437,7 @@ public class TikaResource {
@Consumes("*/*")
@Produces("text/plain")
@Path("main")
- public StreamingOutput getTextMain(final InputStream is, @Context HttpHeaders httpHeaders, @Context final UriInfo info) {
+ public StreamingOutput getTextMain(final InputStream is, @Context HttpHeaders httpHeaders, @Context final UriInfo info) throws TikaConfigException, IOException {
return produceTextMain(is, httpHeaders.getRequestHeaders(), info);
}
@@ -462,11 +446,11 @@ public class TikaResource {
@Consumes("multipart/form-data")
@Produces("text/plain")
@Path("form/main")
- public StreamingOutput getTextMainFromMultipart(final Attachment att, @Context HttpHeaders httpHeaders, @Context final UriInfo info) {
+ public StreamingOutput getTextMainFromMultipart(final Attachment att, @Context HttpHeaders httpHeaders, @Context final UriInfo info) throws TikaConfigException, IOException {
return produceTextMain(att.getObject(InputStream.class), preparePostHeaderMap(att, httpHeaders), info);
}
- public StreamingOutput produceTextMain(final InputStream is, MultivaluedMap<String, String> httpHeaders, final UriInfo info) {
+ public StreamingOutput produceTextMain(final InputStream is, MultivaluedMap<String, String> httpHeaders, final UriInfo info) throws TikaConfigException, IOException {
final Parser parser = createParser();
final Metadata metadata = new Metadata();
final ParseContext context = new ParseContext();
@@ -488,12 +472,13 @@ public class TikaResource {
@PUT
@Consumes("*/*")
@Produces("text/plain")
- public StreamingOutput getText(final InputStream is, @Context HttpHeaders httpHeaders, @Context final UriInfo info) {
+ public StreamingOutput getText(final InputStream is, @Context HttpHeaders httpHeaders, @Context final UriInfo info) throws TikaConfigException, IOException {
final Metadata metadata = new Metadata();
return produceText(getInputStream(is, metadata, httpHeaders, info), metadata, httpHeaders.getRequestHeaders(), info);
}
- public StreamingOutput produceText(final InputStream is, final Metadata metadata, MultivaluedMap<String, String> httpHeaders, final UriInfo info) {
+ public StreamingOutput produceText(final InputStream is, final Metadata metadata, MultivaluedMap<String, String> httpHeaders, final UriInfo info)
+ throws TikaConfigException, IOException {
final Parser parser = createParser();
final ParseContext context = new ParseContext();
@@ -515,14 +500,14 @@ public class TikaResource {
@Consumes("multipart/form-data")
@Produces("text/html")
@Path("form")
- public StreamingOutput getHTMLFromMultipart(Attachment att, @Context HttpHeaders httpHeaders, @Context final UriInfo info) {
+ public StreamingOutput getHTMLFromMultipart(Attachment att, @Context HttpHeaders httpHeaders, @Context final UriInfo info) throws TikaConfigException, IOException {
return produceOutput(att.getObject(InputStream.class), new Metadata(), preparePostHeaderMap(att, httpHeaders), info, "html");
}
@PUT
@Consumes("*/*")
@Produces("text/html")
- public StreamingOutput getHTML(final InputStream is, @Context HttpHeaders httpHeaders, @Context final UriInfo info) {
+ public StreamingOutput getHTML(final InputStream is, @Context HttpHeaders httpHeaders, @Context final UriInfo info) throws TikaConfigException, IOException {
Metadata metadata = new Metadata();
return produceOutput(getInputStream(is, metadata, httpHeaders, info), metadata, httpHeaders.getRequestHeaders(), info, "html");
}
@@ -531,14 +516,14 @@ public class TikaResource {
@Consumes("multipart/form-data")
@Produces("text/xml")
@Path("form")
- public StreamingOutput getXMLFromMultipart(Attachment att, @Context HttpHeaders httpHeaders, @Context final UriInfo info) {
+ public StreamingOutput getXMLFromMultipart(Attachment att, @Context HttpHeaders httpHeaders, @Context final UriInfo info) throws TikaConfigException, IOException {
return produceOutput(att.getObject(InputStream.class), new Metadata(), preparePostHeaderMap(att, httpHeaders), info, "xml");
}
@PUT
@Consumes("*/*")
@Produces("text/xml")
- public StreamingOutput getXML(final InputStream is, @Context HttpHeaders httpHeaders, @Context final UriInfo info) {
+ public StreamingOutput getXML(final InputStream is, @Context HttpHeaders httpHeaders, @Context final UriInfo info) throws TikaConfigException, IOException {
Metadata metadata = new Metadata();
return produceOutput(getInputStream(is, metadata, httpHeaders, info), metadata, httpHeaders.getRequestHeaders(), info, "xml");
}
@@ -552,8 +537,8 @@ public class TikaResource {
Metadata metadata = new Metadata();
parseToMetadata(getInputStream(att.getObject(InputStream.class), metadata, httpHeaders, info), metadata, preparePostHeaderMap(att, httpHeaders), info, handlerTypeName);
List<Metadata> ret = TikaResource
- .getConfig()
- .getMetadataFilter()
+ .getTikaLoader()
+ .loadMetadataFilters()
.filter(List.of(metadata));
if (ret == null || ret.isEmpty()) {
return new Metadata();
@@ -570,8 +555,7 @@ public class TikaResource {
Metadata metadata = new Metadata();
parseToMetadata(getInputStream(is, metadata, httpHeaders, info), metadata, httpHeaders.getRequestHeaders(), info, handlerTypeName);
List<Metadata> ret = TikaResource
- .getConfig()
- .getMetadataFilter()
+ .getTikaLoader().loadMetadataFilters()
.filter(List.of(metadata));
if (ret == null || ret.isEmpty()) {
return new Metadata();
@@ -579,7 +563,8 @@ public class TikaResource {
return metadata;
}
- private void parseToMetadata(InputStream inputStream, Metadata metadata, MultivaluedMap<String, String> httpHeaders, UriInfo info, String handlerTypeName) throws IOException {
+ private void parseToMetadata(InputStream inputStream, Metadata metadata, MultivaluedMap<String, String> httpHeaders, UriInfo info, String handlerTypeName)
+ throws IOException, TikaConfigException {
final Parser parser = createParser();
final ParseContext context = new ParseContext();
@@ -626,7 +611,8 @@ public class TikaResource {
}
}
- private StreamingOutput produceOutput(final InputStream is, Metadata metadata, final MultivaluedMap<String, String> httpHeaders, final UriInfo info, final String format) {
+ private StreamingOutput produceOutput(final InputStream is, Metadata metadata, final MultivaluedMap<String, String> httpHeaders, final UriInfo info, final String format)
+ throws TikaConfigException, IOException {
final Parser parser = createParser();
final ParseContext context = new ParseContext();
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaVersion.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaVersion.java
index c894c2a88..39b204885 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaVersion.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaVersion.java
@@ -27,7 +27,7 @@ public class TikaVersion {
private Tika tika;
public TikaVersion() {
- this.tika = new Tika(TikaResource.getConfig());
+ this.tika = new Tika();
}
@GET
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaWelcome.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaWelcome.java
index 207629062..274616b61 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaWelcome.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaWelcome.java
@@ -65,7 +65,7 @@ public class TikaWelcome {
private List<Class<?>> endpoints = new LinkedList<>();
public TikaWelcome(List<ResourceProvider> rCoreProviders) {
- this.tika = new Tika(TikaResource.getConfig());
+ this.tika = new Tika();
this.html = new HTMLHelper();
for (ResourceProvider rp : rCoreProviders) {
this.endpoints.add(rp.getResourceClass());
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TranslateResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TranslateResource.java
index 04c8da52b..d581c6934 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TranslateResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TranslateResource.java
@@ -51,9 +51,10 @@ public class TranslateResource {
public TranslateResource(ServerStatus serverStatus, long timeoutMillis) {
this.loader = new ServiceLoader(ServiceLoader.class.getClassLoader(), LoadErrorHandler.WARN);
- this.defaultTranslator = TikaResource
- .getConfig()
- .getTranslator();
+ //TODO -- implement translators
+ //this.defaultTranslator = TikaResource
+ // .getTikaLoader()
+ // .getTranslator();
this.serverStatus = serverStatus;
this.timeoutMillis = timeoutMillis;
}
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/UnpackerResource.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/UnpackerResource.java
index d4ea60cfd..50f2a9d73 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/UnpackerResource.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/UnpackerResource.java
@@ -52,6 +52,7 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
+import org.apache.tika.config.loader.TikaLoader;
import org.apache.tika.exception.TikaMemoryLimitException;
import org.apache.tika.extractor.DefaultEmbeddedStreamTranslator;
import org.apache.tika.extractor.EmbeddedDocumentExtractor;
@@ -212,9 +213,7 @@ public class UnpackerResource {
if (!name.contains(".") && contentType != null) {
try {
- String ext = TikaResource
- .getConfig()
- .getMimeRepository()
+ String ext = TikaLoader.getMimeTypes()
.forName(contentType)
.getExtension();
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/CXFTestBase.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/CXFTestBase.java
index a4c37fcb2..96816fde3 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/CXFTestBase.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/CXFTestBase.java
@@ -57,7 +57,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.tika.config.TikaConfig;
+import org.apache.tika.config.loader.TikaLoader;
import org.apache.tika.parser.digestutils.CommonsDigester;
+import org.apache.tika.pipes.core.async.AsyncConfig;
import org.apache.tika.server.core.resource.TikaResource;
import org.apache.tika.server.core.resource.UnpackerResource;
@@ -69,40 +71,38 @@ public abstract class CXFTestBase {
public final static String EMITTER_JSON_ID = "fse-json";
public final static String EMITTER_BYTES_ID = "fse-bytes";
- public final static String JSON_TEMPLATE = """
+ public final static String BASIC_CONFIG = """
{
- "fetchers": {
- "file-system-fetcher": {
- "fsf": {
- "basePath": "FETCHER_BASE_PATH",
- "extractFileSystemMetadata": false
- }
- }
- },
- "emitters": {
- "file-system-emitter": {
- "fse-json": {
- "basePath": "JSON_EMITTER_BASE_PATH",
- "fileExtension": "json",
- "onExists": "EXCEPTION"
- },
- "fse-bytes": {
- "basePath": "BYTES_EMITTER_BASE_PATH",
- "fileExtension": "",
- "onExists": "EXCEPTION"
- }
- }
- },
- "plugin-roots": "PLUGINS_PATHS"
+ "auto-detect-parser-config": {
+ "spoolToDisk": 1000000,
+ "outputThreshold": 1000000,
+ "digesterFactory": {
+ "@class": "org.apache.tika.parser.digestutils.CommonsDigesterFactory",
+ "markLimit": 100000,
+ "algorithmString": "md5"
+ },
+ "throwOnZeroBytes": false
+ }
}
""";
+ public final static String JSON_TEMPLATE;
+
+ static {
+ try {
+ JSON_TEMPLATE = Files.readString(
+ Paths.get(CXFTestBase.class.getResource("/configs/cxf-test-base-template.json").getPath()), UTF_8);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
protected static final String endPoint = "http://localhost:" + TikaServerConfig.DEFAULT_PORT;
protected final static int DIGESTER_READ_LIMIT = 20 * 1024 * 1024;
protected Server server;
- protected TikaConfig tika;
+ protected TikaLoader tika;
- public static void createPluginsConfig(Path configPath, Path inputDir, Path jsonOutputDir, Path bytesOutputDir) throws IOException {
+ public static void createPluginsConfig(Path configPath, Path inputDir, Path jsonOutputDir, Path bytesOutputDir, Long timeoutMillis) throws IOException {
Path pluginsDir = Paths.get("target/plugins");
if (! Files.isDirectory(pluginsDir)) {
@@ -114,10 +114,17 @@ public abstract class CXFTestBase {
if (bytesOutputDir != null) {
json = json.replace("BYTES_EMITTER_BASE_PATH", bytesOutputDir.toAbsolutePath().toString());
}
+ json = json.replace("TIKA_CONFIG", configPath.toAbsolutePath().toString());
+ if (timeoutMillis != null) {
+ json = json.replace("TIMEOUT_MILLIS", timeoutMillis.toString());
+ } else {
+ json = json.replace("TIMEOUT_MILLIS", "10000");
+ }
json = json.replace("\\", "/");
Files.writeString(configPath, json, StandardCharsets.UTF_8);
}
+
public static void assertContains(String needle, String haystack) {
assertTrue(haystack.contains(needle), needle + " not found in:\n" + haystack);
}
@@ -175,10 +182,15 @@ public abstract class CXFTestBase {
@BeforeEach
public void setUp() throws Exception {
-
- this.tika = new TikaConfig(getTikaConfigInputStream());
+ Path tmp = Files.createTempFile("tika-server-test-", ".json");
+ try {
+ Files.copy(getTikaConfigInputStream(), tmp, StandardCopyOption.REPLACE_EXISTING);
+ this.tika = TikaLoader.load(tmp);
+ } finally {
+ Files.delete(tmp);
+ }
TikaServerConfig tikaServerConfig = getTikaServerConfig();
- TikaResource.init(tika, tikaServerConfig, new CommonsDigester(DIGESTER_READ_LIMIT, "md5," + "sha1:32"),
+ TikaResource.init(tika, tikaServerConfig,
getInputStreamFactory(getPipesConfigInputStream()),
new ServerStatus());
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
@@ -213,9 +225,7 @@ public abstract class CXFTestBase {
}
protected InputStream getTikaConfigInputStream() throws IOException {
- return new ByteArrayInputStream(new String(
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<properties>\n" + " <parsers>\n" + " <parser class=\"org.apache.tika.parser.DefaultParser\"/>\n" +
- " </parsers>\n" + "</properties>").getBytes(UTF_8));
+ return new ByteArrayInputStream(BASIC_CONFIG.getBytes(UTF_8));
}
protected InputStream getPipesConfigInputStream() throws IOException {
@@ -234,7 +244,8 @@ public abstract class CXFTestBase {
.replace("FETCHER_BASE_PATH", getPipesInputPath())
.replace("PLUGINS_PATHS", pluginsDir
.toAbsolutePath()
- .toString());
+ .toString())
+ .replace("TIMEOUT_MILLIS", "10000");
json = json.replace("\\", "/");
return UnsynchronizedByteArrayInputStream
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaPipesTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaPipesTest.java
index 1e84deeda..b488b4f5d 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaPipesTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaPipesTest.java
@@ -79,8 +79,6 @@ public class TikaPipesTest extends CXFTestBase {
private static Path TIKA_PIPES_LOG4j2_PATH;
private static Path TMP_NPE_OUTPUT_FILE;
private static Path TIKA_CONFIG_PATH;
- private static Path TIKA_PIPES_CONFIG_PATH;
- private static String TIKA_CONFIG_XML;
private static FetcherManager FETCHER_MANAGER;
private static String HELLO_WORLD = "hello_world.xml";
private static String HELLO_WORLD_JSON = "hello_world.xml.json";
@@ -105,21 +103,11 @@ public class TikaPipesTest extends CXFTestBase {
TIKA_PIPES_LOG4j2_PATH = Files.createTempFile(TMP_DIR, "log4j2-", ".xml");
Files.copy(TikaPipesTest.class.getResourceAsStream("/log4j2.xml"), TIKA_PIPES_LOG4j2_PATH, StandardCopyOption.REPLACE_EXISTING);
- TIKA_CONFIG_PATH = Files.createTempFile(TMP_DIR, "tika-pipes-", ".xml");
- TIKA_CONFIG_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<properties>" +
- "<pipes><tikaConfig>" + ProcessUtils.escapeCommandLine(TIKA_CONFIG_PATH
- .toAbsolutePath()
- .toString()) + "</tikaConfig><numClients>10</numClients>" + "<forkedJvmArgs>" + "<arg>-Xmx256m</arg>" + "<arg>-Dlog4j.configurationFile=file:" +
- ProcessUtils.escapeCommandLine(TIKA_PIPES_LOG4j2_PATH
- .toAbsolutePath()
- .toString()) + "</arg>" + "</forkedJvmArgs>" + "</pipes>" + "</properties>";
- Files.write(TIKA_CONFIG_PATH, TIKA_CONFIG_XML.getBytes(StandardCharsets.UTF_8));
+ TIKA_CONFIG_PATH = Files.createTempFile(TMP_DIR, "tika-pipes-config-", ".json");
- TIKA_PIPES_CONFIG_PATH = Files.createTempFile(TMP_DIR, "tika-pipes-config-", ".json");
+ CXFTestBase.createPluginsConfig(TIKA_CONFIG_PATH, inputDir, TMP_OUTPUT_DIR, null, 10000L);
- CXFTestBase.createPluginsConfig(TIKA_PIPES_CONFIG_PATH, inputDir, TMP_OUTPUT_DIR, null);
-
- TikaConfigs tikaConfigs = TikaConfigs.load(TIKA_PIPES_CONFIG_PATH);
+ TikaConfigs tikaConfigs = TikaConfigs.load(TIKA_CONFIG_PATH);
TikaPluginManager pluginManager = TikaPluginManager.load(tikaConfigs);
FETCHER_MANAGER = FetcherManager.load(pluginManager, tikaConfigs);
}
@@ -144,7 +132,7 @@ public class TikaPipesTest extends CXFTestBase {
protected void setUpResources(JAXRSServerFactoryBean sf) {
List<ResourceProvider> rCoreProviders = new ArrayList<>();
try {
- rCoreProviders.add(new SingletonResourceProvider(new PipesResource(TIKA_CONFIG_PATH, TIKA_PIPES_CONFIG_PATH)));
+ rCoreProviders.add(new SingletonResourceProvider(new PipesResource(TIKA_CONFIG_PATH)));
} catch (IOException | TikaConfigException e) {
throw new RuntimeException(e);
}
@@ -160,8 +148,8 @@ public class TikaPipesTest extends CXFTestBase {
}
@Override
- protected InputStream getTikaConfigInputStream() {
- return new ByteArrayInputStream(TIKA_CONFIG_XML.getBytes(StandardCharsets.UTF_8));
+ protected InputStream getTikaConfigInputStream() throws IOException {
+ return new ByteArrayInputStream(Files.readAllBytes(TIKA_CONFIG_PATH));
}
@Override
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaResourceFetcherTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaResourceFetcherTest.java
index 54bcbb4c3..8d3373570 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaResourceFetcherTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaResourceFetcherTest.java
@@ -72,7 +72,7 @@ public class TikaResourceFetcherTest extends CXFTestBase {
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
- String configXML = getStringFromInputStream(TikaResourceFetcherTest.class.getResourceAsStream("/configs/tika-config-server-fetcher-template.xml"));
+ String configXML = getStringFromInputStream(TikaResourceFetcherTest.class.getResourceAsStream("/configs/tika-config-server-fetcher-template.json"));
configXML = configXML.replace("{PORT}", "9998");
return new ByteArrayInputStream(configXML.getBytes(StandardCharsets.UTF_8));
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaResourceMetadataFilterTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaResourceMetadataFilterTest.java
index c7f663128..9816bd57f 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaResourceMetadataFilterTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaResourceMetadataFilterTest.java
@@ -46,7 +46,7 @@ public class TikaResourceMetadataFilterTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/configs/metadata-filter-include.xml");
+ return getClass().getResourceAsStream("/configs/metadata-filter-include.json");
}
@Override
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerAsyncIntegrationTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerAsyncIntegrationTest.java
index 096359518..762d6f55d 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerAsyncIntegrationTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerAsyncIntegrationTest.java
@@ -66,9 +66,7 @@ public class TikaServerAsyncIntegrationTest extends IntegrationTestBase {
@TempDir
private static Path TMP_DIR;
private static Path TMP_OUTPUT_DIR;
- private static String TIKA_CONFIG_XML;
private static Path TIKA_CONFIG;
- private static Path PLUGINS_CONFIG;
private static List<String> FILE_LIST = new ArrayList<>();
private static String[] FILES = new String[]{"hello_world.xml", "null_pointer.xml",
// "heavy_hang_30000.xml", "real_oom.xml",
@@ -95,19 +93,9 @@ public class TikaServerAsyncIntegrationTest extends IntegrationTestBase {
}
}
- TIKA_CONFIG = TMP_DIR.resolve("tika-config.xml");
+ TIKA_CONFIG = TMP_DIR.resolve("tika-config.json");
- TIKA_CONFIG_XML =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<properties>" + "<server><endpoints><endpoint>async</endpoint></endpoints>" +
- "<enableUnsecureFeatures>true</enableUnsecureFeatures></server>" + "<async><tikaConfig>" + ProcessUtils.escapeCommandLine(TIKA_CONFIG
- .toAbsolutePath()
- .toString()) + "</tikaConfig><numClients>10</numClients><forkedJvmArgs><arg>-Xmx256m" + "</arg></forkedJvmArgs><timeoutMillis>5000</timeoutMillis>" +
- "</async>" + "</properties>";
-
- FileUtils.write(TIKA_CONFIG.toFile(), TIKA_CONFIG_XML, UTF_8);
-
- PLUGINS_CONFIG = TMP_DIR.resolve("plugins-config.json");
- CXFTestBase.createPluginsConfig(PLUGINS_CONFIG, inputDir, TMP_OUTPUT_DIR, null);
+ CXFTestBase.createPluginsConfig(TIKA_CONFIG, inputDir, TMP_OUTPUT_DIR, null, null);
}
@@ -130,8 +118,7 @@ public class TikaServerAsyncIntegrationTest extends IntegrationTestBase {
Thread serverThread = new Thread(() -> TikaServerCli.main(new String[]{
//for debugging/development, use no fork; otherwise go with the default
//"-noFork",
- "-p", INTEGRATION_TEST_PORT, "-config", TIKA_CONFIG.toAbsolutePath().toString(),
- "-a", PLUGINS_CONFIG.toAbsolutePath().toString() }));
+ "-p", INTEGRATION_TEST_PORT, "-config", TIKA_CONFIG.toAbsolutePath().toString() }));
serverThread.start();
try {
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerConfigTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerConfigTest.java
index 91bfa1778..514e8ca87 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerConfigTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerConfigTest.java
@@ -43,17 +43,12 @@ public class TikaServerConfigTest {
CommandLineParser parser = new DefaultParser();
CommandLine emptyCommandLine = parser.parse(new Options(), new String[]{});
Path path = Paths.get(TikaConfigTest.class
- .getResource("/configs/tika-config-server.xml")
+ .getResource("/configs/tika-config-server.json")
.toURI());
- Path pluginsConfig = Paths.get(TikaConfigTest.class
- .getResource("/configs/tika-pipes-config.json")
- .toURI());
- TikaServerConfig config = TikaServerConfig.load(path, pluginsConfig, emptyCommandLine, settings);
+ TikaServerConfig config = TikaServerConfig.load(path, emptyCommandLine, settings);
assertEquals(54321, config.getTaskTimeoutMillis());
assertEquals(true, config.isEnableUnsecureFeatures());
- assertTrue(settings.contains("taskTimeoutMillis"));
- assertTrue(settings.contains("enableUnsecureFeatures"));
}
@Test
@@ -62,12 +57,9 @@ public class TikaServerConfigTest {
CommandLineParser parser = new DefaultParser();
CommandLine emptyCommandLine = parser.parse(new Options(), new String[]{});
Path path = Paths.get(TikaConfigTest.class
- .getResource("/configs/tika-config-server-fetchers-emitters.xml")
- .toURI());
- Path pluginsConfig = Paths.get(TikaConfigTest.class
- .getResource("/configs/tika-pipes-config.json")
+ .getResource("/configs/tika-config-server-fetchers-emitters.json")
.toURI());
- TikaServerConfig config = TikaServerConfig.load(path, pluginsConfig, emptyCommandLine, settings);
+ TikaServerConfig config = TikaServerConfig.load(path, emptyCommandLine, settings);
assertEquals(54321, config.getTaskTimeoutMillis());
assertEquals(true, config.isEnableUnsecureFeatures());
@@ -77,7 +69,7 @@ public class TikaServerConfigTest {
public void testPorts() throws Exception {
CommandLineParser parser = new DefaultParser();
Path path = Paths.get(TikaConfigTest.class
- .getResource("/configs/tika-config-server.xml")
+ .getResource("/configs/tika-config-server.json")
.toURI());
CommandLine commandLine = parser.parse(new Options()
.addOption(Option
@@ -100,14 +92,12 @@ public class TikaServerConfigTest {
Set<String> settings = new HashSet<>();
CommandLineParser parser = new DefaultParser();
CommandLine emptyCommandLine = parser.parse(new Options(), new String[]{});
+ //.getResource("/configs/tika-config-server-tls.xml")
Path path = Paths.get(TikaConfigTest.class
- .getResource("/configs/tika-config-server-tls.xml")
- .toURI());
- Path pluginsConfig = Paths.get(TikaConfigTest.class
- .getResource("/configs/tika-pipes-config.json")
+ .getResource("/configs/tika-config-server-tls.json")
.toURI());
- TikaServerConfig config = TikaServerConfig.load(path, pluginsConfig, emptyCommandLine, settings);
+ TikaServerConfig config = TikaServerConfig.load(path, emptyCommandLine, settings);
TlsConfig tlsConfig = config.getTlsConfig();
assertTrue(tlsConfig.isActive());
assertFalse(tlsConfig.isClientAuthenticationWanted());
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java
index 0046e388d..a82417df9 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerIntegrationTest.java
@@ -72,35 +72,35 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
.getResource("/ssl-keys")
.toURI());
- String xml = IOUtils.resourceToString("/configs/tika-config-server-tls-two-way-template.xml", UTF_8);
- xml = xml.replace("{SSL_KEYS}", TLS_KEYS
+ String json = IOUtils.resourceToString("/configs/tika-config-server-tls-two-way-template.json", UTF_8);
+ json = json.replace("{SSL_KEYS}", TLS_KEYS
.toAbsolutePath()
.toString());
- TIKA_TLS_TWO_WAY_CONFIG = Files.createTempFile(TLS_CONFIG, "tika-config-tls-", ".xml");
- Files.write(TIKA_TLS_TWO_WAY_CONFIG, xml.getBytes(UTF_8));
+ TIKA_TLS_TWO_WAY_CONFIG = Files.createTempFile(TLS_CONFIG, "tika-config-tls-", ".json");
+ Files.write(TIKA_TLS_TWO_WAY_CONFIG, json.getBytes(UTF_8));
- xml = IOUtils.resourceToString("/configs/tika-config-server-tls-one-way-template.xml", UTF_8);
- xml = xml.replace("{SSL_KEYS}", TLS_KEYS
+ json = IOUtils.resourceToString("/configs/tika-config-server-tls-one-way-template.json", UTF_8);
+ json = json.replace("{SSL_KEYS}", TLS_KEYS
.toAbsolutePath()
.toString());
- TIKA_TLS_ONE_WAY_CONFIG = Files.createTempFile(TLS_CONFIG, "tika-config-tls-", ".xml");
- Files.write(TIKA_TLS_ONE_WAY_CONFIG, xml.getBytes(UTF_8));
+ TIKA_TLS_ONE_WAY_CONFIG = Files.createTempFile(TLS_CONFIG, "tika-config-tls-", ".json");
+ Files.write(TIKA_TLS_ONE_WAY_CONFIG, json.getBytes(UTF_8));
}
@Test
public void testBasic() throws Exception {
- startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
+ startProcess(new String[]{"-config", getConfig("tika-config-server-basic.json")});
testBaseline();
}
@Test
public void testOOM() throws Exception {
- startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
+ startProcess(new String[]{"-config", getConfig("tika-config-server-basic.json")});
awaitServerStartup();
@@ -120,7 +120,7 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
@Test
public void testMinimumTimeoutInHeader() throws Exception {
- startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
+ startProcess(new String[]{"-config", getConfig("tika-config-server-basic.json")});
awaitServerStartup();
Response response = WebClient
@@ -134,7 +134,7 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
@Test
public void testTaskTimeoutHeader() throws Exception {
- startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
+ startProcess(new String[]{"-config", getConfig("tika-config-server-basic.json")});
awaitServerStartup();
Response response = null;
try {
@@ -179,7 +179,7 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
@Test
public void testSystemExit() throws Exception {
- startProcess(new String[]{"-config", getConfig("tika-config-server-basic.xml")});
+ startProcess(new String[]{"-config", getConfig("tika-config-server-basic.json")});
awaitServerStartup();
Response response = null;
@@ -199,7 +199,7 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
@Test
@Timeout(60000)
public void testTimeout() throws Exception {
- startProcess(new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
+ startProcess(new String[]{"-config", getConfig("tika-config-server-timeout-5000.json")});
awaitServerStartup();
Response response = null;
try {
@@ -244,7 +244,7 @@ public class TikaServerIntegrationTest extends IntegrationTestBase {
@Test
public void testStdErrOutBasic() throws Exception {
- startProcess(new String[]{"-config", getConfig("tika-config-server-timeout-10000.xml")});
+ startProcess(new String[]{"-config", getConfig("tika-config-server-timeout-5000.json")});
awaitServerStartup();
Response response = WebClient
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerPipesIntegrationTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerPipesIntegrationTest.java
index 075e85ccd..973fe63cb 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerPipesIntegrationTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TikaServerPipesIntegrationTest.java
@@ -55,7 +55,6 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
private static Path TEMP_OUTPUT_DIR;
private static Path TIKA_CONFIG;
private static Path TIKA_CONFIG_TIMEOUT;
- private static Path TIKA_PIPES_CONFIG;
private static String[] FILES = new String[]{"hello_world.xml", "heavy_hang_30000.xml", "fake_oom.xml", "system_exit.xml", "null_pointer.xml"};
@BeforeAll
@@ -68,26 +67,10 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
for (String mockFile : FILES) {
Files.copy(TikaPipesTest.class.getResourceAsStream("/test-documents/mock/" + mockFile), inputDir.resolve(mockFile));
}
- TIKA_CONFIG = TEMP_WORKING_DIR.resolve("tika-config.xml");
- TIKA_CONFIG_TIMEOUT = TEMP_WORKING_DIR.resolve("tika-config-timeout.xml");
- TIKA_PIPES_CONFIG = TEMP_OUTPUT_DIR.resolve("tika-pipes.json");
- //TODO -- clean this up so that port is sufficient and we don't need portString
- String xml1 =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<properties>" + "<server>" +
- "<enableUnsecureFeatures>true</enableUnsecureFeatures>" +
- "<port>9999</port>" + "<endpoints>" + "<endpoint>pipes</endpoint>" + "<endpoint>status</endpoint>" + "</endpoints>";
- String xml2 = "</server>" + "<pipes><tikaConfig>" + ProcessUtils.escapeCommandLine(TIKA_CONFIG
- .toAbsolutePath()
- .toString()) + "</tikaConfig><numClients>10</numClients><forkedJvmArgs><arg>-Xmx256m" + "</arg>" + //TODO: need to add logging config here
- "</forkedJvmArgs><timeoutMillis>5000</timeoutMillis>" + "</pipes>" + "</properties>";
-
- String tikaConfigXML = xml1 + xml2;
-
- FileUtils.write(TIKA_CONFIG.toFile(), tikaConfigXML, UTF_8);
-
- String tikaConfigTimeoutXML = xml1 + "<taskPulseMillis>100</taskPulseMillis>" + "<taskTimeoutMillis>10000</taskTimeoutMillis>" + xml2;
- FileUtils.write(TIKA_CONFIG_TIMEOUT.toFile(), tikaConfigTimeoutXML, UTF_8);
- CXFTestBase.createPluginsConfig(TIKA_PIPES_CONFIG, inputDir, TEMP_OUTPUT_DIR, null);
+ TIKA_CONFIG = TEMP_WORKING_DIR.resolve("tika-config.json");
+ TIKA_CONFIG_TIMEOUT = TEMP_WORKING_DIR.resolve("tika-config-timeout.json");
+ CXFTestBase.createPluginsConfig(TIKA_CONFIG, inputDir, TEMP_OUTPUT_DIR, null, 5000L);
+ CXFTestBase.createPluginsConfig(TIKA_CONFIG_TIMEOUT, inputDir, TEMP_OUTPUT_DIR, null, 500L);
}
@@ -112,7 +95,6 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
@Test
public void testBasic() throws Exception {
startProcess(new String[]{
- "-a", ProcessUtils.escapeCommandLine(TIKA_PIPES_CONFIG.toAbsolutePath().toString()),
"-config", ProcessUtils.escapeCommandLine(TIKA_CONFIG
.toAbsolutePath()
.toString())});
@@ -127,7 +109,6 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
public void testNPEDefault() throws Exception {
startProcess(new String[]{
- "-a", ProcessUtils.escapeCommandLine(TIKA_PIPES_CONFIG.toAbsolutePath().toString()),
"-config", ProcessUtils.escapeCommandLine(TIKA_CONFIG
.toAbsolutePath()
.toString())});
@@ -144,7 +125,6 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
public void testNPESkip() throws Exception {
startProcess(new String[]{
- "-a", ProcessUtils.escapeCommandLine(TIKA_PIPES_CONFIG.toAbsolutePath().toString()),
"-config", ProcessUtils.escapeCommandLine(TIKA_CONFIG
.toAbsolutePath()
.toString())});
@@ -160,7 +140,6 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
@Test
public void testSystemExit() throws Exception {
startProcess(new String[]{
- "-a", ProcessUtils.escapeCommandLine(TIKA_PIPES_CONFIG.toAbsolutePath().toString()),
"-config", ProcessUtils.escapeCommandLine(TIKA_CONFIG
.toAbsolutePath()
.toString())});
@@ -178,7 +157,6 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
try {
startProcess(new String[]{
- "-a", ProcessUtils.escapeCommandLine(TIKA_PIPES_CONFIG.toAbsolutePath().toString()),
"-config", ProcessUtils.escapeCommandLine(TIKA_CONFIG
.toAbsolutePath()
.toString())});
@@ -199,7 +177,6 @@ public class TikaServerPipesIntegrationTest extends IntegrationTestBase {
@Test
public void testTimeout() throws Exception {
startProcess(new String[]{
- "-a", ProcessUtils.escapeCommandLine(TIKA_PIPES_CONFIG.toAbsolutePath().toString()),
"-config", ProcessUtils.escapeCommandLine(TIKA_CONFIG_TIMEOUT
.toAbsolutePath()
.toString())});
diff --git a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TranslateResourceTest.java b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TranslateResourceTest.java
index 6d9ae1bf8..f1bbd711d 100644
--- a/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TranslateResourceTest.java
+++ b/tika-server/tika-server-core/src/test/java/org/apache/tika/server/core/TranslateResourceTest.java
@@ -28,12 +28,14 @@ import jakarta.ws.rs.core.Response;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.apache.tika.server.core.resource.TranslateResource;
import org.apache.tika.server.core.writer.TarWriter;
import org.apache.tika.server.core.writer.ZipWriter;
+@Disabled("until we get translators working")
public class TranslateResourceTest extends CXFTestBase {
private static final String TRANSLATE_PATH = "/translate";
diff --git a/tika-server/tika-server-core/src/test/resources/configs/cxf-test-base-template.json b/tika-server/tika-server-core/src/test/resources/configs/cxf-test-base-template.json
new file mode 100644
index 000000000..740d5d26b
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/cxf-test-base-template.json
@@ -0,0 +1,57 @@
+{
+ "fetchers": {
+ "file-system-fetcher": {
+ "fsf": {
+ "basePath": "FETCHER_BASE_PATH",
+ "extractFileSystemMetadata": false
+ }
+ }
+ },
+ "emitters": {
+ "file-system-emitter": {
+ "fse-json": {
+ "basePath": "JSON_EMITTER_BASE_PATH",
+ "fileExtension": "json",
+ "onExists": "EXCEPTION"
+ },
+ "fse-bytes": {
+ "basePath": "BYTES_EMITTER_BASE_PATH",
+ "fileExtension": "",
+ "onExists": "EXCEPTION"
+ }
+ }
+ },
+ "server": {
+ "port": 9999,
+ "taskTimeoutMillis": TIMEOUT_MILLIS,
+ "taskPulseMillis": 100,
+ "enableUnsecureFeatures": true,
+ "endpoints": [
+ "rmeta",
+ "status",
+ "async",
+ "pipes"
+ ]
+ },
+ "async": {
+ "tikaConfig": "TIKA_CONFIG",
+ "numClients": 2,
+ "timeoutMillis": TIMEOUT_MILLIS,
+ "emitIntermediateResults": false,
+ "forkedJvmArgs": [
+ "-Xmx512m"
+ ],
+ "maxForEmitBatchBytes": 1000000
+ },
+ "auto-detect-parser-config": {
+ "spoolToDisk": 1000000,
+ "outputThreshold": 1000000,
+ "digesterFactory": {
+ "@class": "org.apache.tika.parser.digestutils.CommonsDigesterFactory",
+ "markLimit": 100000,
+ "algorithmString": "md5,sha1:32"
+ },
+ "throwOnZeroBytes": false
+ },
+ "plugin-roots": "PLUGINS_PATHS"
+}
\ No newline at end of file
diff --git a/tika-server/tika-server-core/src/test/resources/configs/metadata-filter-include.json b/tika-server/tika-server-core/src/test/resources/configs/metadata-filter-include.json
new file mode 100644
index 000000000..25f6b9d41
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/metadata-filter-include.json
@@ -0,0 +1,13 @@
+{
+ "metadata-filters": [
+ {
+ "include-field-metadata-filter": {
+ "include": [
+ "X-TIKA:content",
+ "extended-properties:Application",
+ "Content-Type"
+ ]
+ }
+ }
+ ]
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/metadata-filter-include.xml b/tika-server/tika-server-core/src/test/resources/configs/metadata-filter-include.xml
deleted file mode 100644
index 6dd088e74..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/metadata-filter-include.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <metadataFilters>
- <metadataFilter class="org.apache.tika.metadata.filter.IncludeFieldMetadataFilter">
- <include>
- <field>X-TIKA:content</field>
- <field>extended-properties:Application</field>
- <field>Content-Type</field>
- </include>
- </metadataFilter>
- </metadataFilters>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-badjvmargs.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-badjvmargs.xml
deleted file mode 100644
index 723ac29df..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-badjvmargs.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <port>9999</port>
- <taskTimeoutMillis>54321</taskTimeoutMillis>
- <enableUnsecureFeatures>true</enableUnsecureFeatures>
- <endpoints>
- <endpoint>rmeta</endpoint>
- </endpoints>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-basic.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-basic.json
new file mode 100644
index 000000000..5075150c4
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-basic.json
@@ -0,0 +1,12 @@
+{
+ "server": {
+ "taskTimeoutMillis": 120000,
+ "minimumTimeoutMillis": 10,
+ "taskPulseMillis": 100,
+ "port": 9999,
+ "endpoints": [
+ "rmeta",
+ "status"
+ ]
+ }
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-basic.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-basic.xml
deleted file mode 100644
index 5b07bbb51..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-basic.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <taskTimeoutMillis>120000</taskTimeoutMillis>
- <minimumTimeoutMillis>10</minimumTimeoutMillis>
- <taskPulseMillis>100</taskPulseMillis>
- <port>9999</port>
- <endpoints>
- <endpoint>rmeta</endpoint>
- <endpoint>status</endpoint>
- </endpoints>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-emitter.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-emitter.json
new file mode 100644
index 000000000..dbeadf253
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-emitter.json
@@ -0,0 +1,13 @@
+{
+ "server": {
+ "taskTimeoutMillis": 120000,
+ "taskPulseMillis": 100,
+ "port": 9999,
+ "enableUnsecure": true,
+ "endpoints": [
+ "emit",
+ "async",
+ "status"
+ ]
+ }
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-emitter.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-emitter.xml
deleted file mode 100644
index c8dfcc6c7..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-emitter.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <taskTimeoutMillis>120000</taskTimeoutMillis>
- <taskPulseMillis>100</taskPulseMillis>
- <port>9999</port>
- <enableUnsecure>true</enableUnsecure>
- <endpoints>
- <endpoint>emit</endpoint>
- <endpoint>async</endpoint>
- <endpoint>status</endpoint>
- </endpoints>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetcher-template.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetcher-template.json
new file mode 100644
index 000000000..4dd1b826a
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetcher-template.json
@@ -0,0 +1,11 @@
+{
+ "server": {
+ "port": "{PORT}",
+ "taskTimeoutMillis": 54321,
+ "enableUnsecureFeatures": true,
+ "taskPulseMillis": 100,
+ "endpoints": [
+ "tika"
+ ]
+ }
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetcher-template.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetcher-template.xml
deleted file mode 100644
index 4b0fae94c..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetcher-template.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <port>{PORT}</port>
- <taskTimeoutMillis>54321</taskTimeoutMillis>
- <enableUnsecureFeatures>true</enableUnsecureFeatures>
- <taskPulseMillis>100</taskPulseMillis>
- <endpoints>
- <endpoint>tika</endpoint>
- </endpoints>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetchers-emitters.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetchers-emitters.json
new file mode 100644
index 000000000..0ead781e4
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetchers-emitters.json
@@ -0,0 +1,28 @@
+{
+ "server": {
+ "port": 9999,
+ "taskTimeoutMillis": 54321,
+ "taskPulseMillis": 100,
+ "enableUnsecureFeatures": true,
+ "endpoints": [
+ "rmeta"
+ ]
+ },
+ "fetchers": {
+ "file-system-fetcher": {
+ "fsf": {
+ "basePath": "BASE_PATH",
+ "extractFileSystemMetadata": false
+ }
+ }
+ },
+ "emitters": {
+ "file-system-emitter": {
+ "fse-json": {
+ "basePath": "BASE_PATH",
+ "onExists": "EXCEPTION"
+ }
+ }
+ },
+ "plugin-roots": "target/plugins"
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetchers-emitters.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetchers-emitters.xml
deleted file mode 100644
index 54ac567aa..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-fetchers-emitters.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <port>9999</port>
- <taskTimeoutMillis>54321</taskTimeoutMillis>
- <taskPulseMillis>100</taskPulseMillis>
- <enableUnsecureFeatures>true</enableUnsecureFeatures>
- <endpoints>
- <endpoint>rmeta</endpoint>
- </endpoints>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-timeout-10000.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-timeout-10000.xml
deleted file mode 100644
index 634adec4f..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-timeout-10000.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <port>9999</port>
- <taskTimeoutMillis>10000</taskTimeoutMillis>
- <taskPulseMillis>100</taskPulseMillis>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-timeout-5000.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-timeout-5000.json
new file mode 100644
index 000000000..a6dcefe45
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-timeout-5000.json
@@ -0,0 +1,7 @@
+{
+ "server": {
+ "port": 9999,
+ "taskTimeoutMillis": 5000,
+ "taskPulseMillis": 100
+ }
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-one-way-template.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-one-way-template.json
new file mode 100644
index 000000000..9daf84de3
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-one-way-template.json
@@ -0,0 +1,19 @@
+{
+ "server": {
+ "port": 9999,
+ "taskTimeoutMillis": 1000000,
+ "minimumTimeoutMillis": 10000,
+ "taskPulseMillis": 100,
+ "endpoints": [
+ "rmeta"
+ ],
+ "tlsConfig": {
+ "active": true,
+ "keyStoreType": "PKCS12",
+ "keyStorePassword": "tika-secret",
+ "keyStoreFile": "{SSL_KEYS}/tika-server-keystore.p12",
+ "clientAuthenticationWanted": false,
+ "clientAuthenticationRequired": false
+ }
+ }
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-one-way-template.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-one-way-template.xml
deleted file mode 100644
index 25f226e5c..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-one-way-template.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <port>9999</port>
- <taskTimeoutMillis>1000000</taskTimeoutMillis>
- <minimumTimeoutMillis>10000</minimumTimeoutMillis>
- <taskPulseMillis>100</taskPulseMillis>
- <endpoints>
- <endpoint>rmeta</endpoint>
- </endpoints>
- <tlsConfig>
- <active>true</active>
- <keyStoreType>PKCS12</keyStoreType>
- <keyStorePassword>tika-secret</keyStorePassword>
- <keyStoreFile>{SSL_KEYS}/tika-server-keystore.p12</keyStoreFile>
- <clientAuthenticationWanted>false</clientAuthenticationWanted>
- <clientAuthenticationRequired>false</clientAuthenticationRequired>
- </tlsConfig>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-two-way-template.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-two-way-template.json
new file mode 100644
index 000000000..56da4702d
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-two-way-template.json
@@ -0,0 +1,22 @@
+{
+ "server": {
+ "port": 9999,
+ "taskTimeoutMillis": 1000000,
+ "minimumTimeoutMillis": 10000,
+ "taskPulseMillis": 100,
+ "endpoints": [
+ "rmeta"
+ ],
+ "tlsConfig": {
+ "active": true,
+ "keyStoreType": "PKCS12",
+ "keyStorePassword": "tika-secret",
+ "keyStoreFile": "{SSL_KEYS}/tika-server-keystore.p12",
+ "trustStoreType": "PKCS12",
+ "trustStorePassword": "tika-secret",
+ "trustStoreFile": "{SSL_KEYS}/tika-server-truststore.p12",
+ "clientAuthenticationWanted": true,
+ "clientAuthenticationRequired": true
+ }
+ }
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-two-way-template.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-two-way-template.xml
deleted file mode 100644
index 0c528eff5..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls-two-way-template.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <port>9999</port>
- <taskTimeoutMillis>1000000</taskTimeoutMillis>
- <minimumTimeoutMillis>10000</minimumTimeoutMillis>
- <taskPulseMillis>100</taskPulseMillis>
- <endpoints>
- <endpoint>rmeta</endpoint>
- </endpoints>
- <tlsConfig>
- <active>true</active>
- <keyStoreType>PKCS12</keyStoreType>
- <keyStorePassword>tika-secret</keyStorePassword>
- <keyStoreFile>{SSL_KEYS}/tika-server-keystore.p12</keyStoreFile>
- <trustStoreType>PKCS12</trustStoreType>
- <trustStorePassword>tika-secret</trustStorePassword>
- <trustStoreFile>{SSL_KEYS}/tika-server-truststore.p12</trustStoreFile>
- <clientAuthenticationWanted>true</clientAuthenticationWanted>
- <clientAuthenticationRequired>true</clientAuthenticationRequired>
- </tlsConfig>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls.json
new file mode 100644
index 000000000..029e45e96
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls.json
@@ -0,0 +1,38 @@
+{
+ "server": {
+ "port": 9999,
+ "taskTimeoutMillis": 54321,
+ "taskPulseMillis": 100,
+ "minimumTimeoutMillis": 10,
+ "enableUnsecureFeatures": true,
+ "endpoints": [
+ "rmeta"
+ ],
+ "tlsConfig": {
+ "active": true,
+ "keyStoreType": "myType",
+ "keyStorePassword": "pass",
+ "keyStoreFile": "/something/or/other",
+ "trustStoreType": "myType2",
+ "trustStorePassword": "pass2",
+ "trustStoreFile": "/something/or/other2"
+ }
+ },
+ "fetchers": {
+ "file-system-fetcher": {
+ "fsf": {
+ "basePath": "BASE_PATH",
+ "extractFileSystemMetadata": false
+ }
+ }
+ },
+ "emitters": {
+ "file-system-emitter": {
+ "fse-json": {
+ "basePath": "BASE_PATH",
+ "onExists": "EXCEPTION"
+ }
+ }
+ },
+ "plugin-roots": "target/plugins"
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls.xml
deleted file mode 100644
index 7db1314bd..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server-tls.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <port>9999</port>
- <taskTimeoutMillis>54321</taskTimeoutMillis>
- <taskPulseMillis>100</taskPulseMillis>
- <minimumTimeoutMillis>10</minimumTimeoutMillis>
- <enableUnsecureFeatures>true</enableUnsecureFeatures>
- <endpoints>
- <endpoint>rmeta</endpoint>
- </endpoints>
- <tlsConfig>
- <active>true</active>
- <keyStoreType>myType</keyStoreType>
- <keyStorePassword>pass</keyStorePassword>
- <keyStoreFile>/something/or/other</keyStoreFile>
- <trustStoreType>myType2</trustStoreType>
- <trustStorePassword>pass2</trustStorePassword>
- <trustStoreFile>/something/or/other2</trustStoreFile>
- </tlsConfig>
- </server>
-</properties>
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server.json b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server.json
new file mode 100644
index 000000000..8c327e9fa
--- /dev/null
+++ b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server.json
@@ -0,0 +1,29 @@
+{
+ "server": {
+ "port": 9999,
+ "taskTimeoutMillis": 54321,
+ "taskPulseMillis": 100,
+ "minimumTimeoutMillis": 10,
+ "enableUnsecureFeatures": true,
+ "endpoints": [
+ "rmeta"
+ ]
+ },
+ "fetchers": {
+ "file-system-fetcher": {
+ "fsf": {
+ "basePath": "BASE_PATH",
+ "extractFileSystemMetadata": false
+ }
+ }
+ },
+ "emitters": {
+ "file-system-emitter": {
+ "fse-json": {
+ "basePath": "BASE_PATH",
+ "onExists": "EXCEPTION"
+ }
+ }
+ },
+ "plugin-roots": "target/plugins"
+}
diff --git a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server.xml b/tika-server/tika-server-core/src/test/resources/configs/tika-config-server.xml
deleted file mode 100644
index 8f7d5352d..000000000
--- a/tika-server/tika-server-core/src/test/resources/configs/tika-config-server.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <server>
- <port>9999</port>
- <taskTimeoutMillis>54321</taskTimeoutMillis>
- <taskPulseMillis>100</taskPulseMillis>
- <minimumTimeoutMillis>10</minimumTimeoutMillis>
- <enableUnsecureFeatures>true</enableUnsecureFeatures>
- <endpoints>
- <endpoint>rmeta</endpoint>
- </endpoints>
- </server>
-</properties>
diff --git a/tika-server/tika-server-standard/src/main/java/org/apache/tika/server/standard/config/TesseractServerConfig.java b/tika-server/tika-server-standard/src/main/java/org/apache/tika/server/standard/config/TesseractServerConfig.java
index 90838f3e2..016d3c50d 100644
--- a/tika-server/tika-server-standard/src/main/java/org/apache/tika/server/standard/config/TesseractServerConfig.java
+++ b/tika-server/tika-server-standard/src/main/java/org/apache/tika/server/standard/config/TesseractServerConfig.java
@@ -19,6 +19,7 @@ package org.apache.tika.server.standard.config;
import static org.apache.tika.server.core.resource.TikaResource.processHeaderConfig;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import jakarta.ws.rs.core.MultivaluedMap;
@@ -56,6 +57,9 @@ public class TesseractServerConfig implements ParseContextConfig {
for (Map.Entry<String, List<String>> kvp : httpHeaders.entrySet()) {
if (Strings.CI.startsWith(kvp.getKey(), X_TIKA_OCR_HEADER_PREFIX)) {
ocrConfig = (ocrConfig == null) ? new TesseractOCRConfig() : ocrConfig;
+ if (kvp.getKey().toLowerCase(Locale.ROOT).contains("path")) {
+ throw new IllegalArgumentException("Can't change the paths at runtime.");
+ }
processHeaderConfig(ocrConfig, kvp.getKey(), kvp
.getValue()
.get(0)
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/FetcherTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/FetcherTest.java
index cd5d0c0b4..e0e2ee120 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/FetcherTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/FetcherTest.java
@@ -71,7 +71,7 @@ public class FetcherTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/config/tika-config-url-fetcher.xml");
+ return getClass().getResourceAsStream("/configs/tika-config-url-fetcher.xml");
}
@Override
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/JsonMaxFieldLengthTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/JsonMaxFieldLengthTest.java
index 03982eceb..ed9718eb9 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/JsonMaxFieldLengthTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/JsonMaxFieldLengthTest.java
@@ -63,7 +63,7 @@ public class JsonMaxFieldLengthTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/config/tika-config-json.xml");
+ return getClass().getResourceAsStream("/configs/tika-config-json.json");
}
@Test
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/MetadataResourceTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/MetadataResourceTest.java
index e4bcb1f8a..196068991 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/MetadataResourceTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/MetadataResourceTest.java
@@ -40,6 +40,7 @@ import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.junit.jupiter.api.Test;
+import org.apache.tika.TikaTest;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.serialization.JsonMetadata;
@@ -93,6 +94,7 @@ public class MetadataResourceTest extends CXFTestBase {
assertNotNull(metadata.get(TikaCoreProperties.CREATOR.getName()));
assertEquals("Maxim Valyanskiy", metadata.get(TikaCoreProperties.CREATOR.getName()));
+
assertEquals("f8be45c34e8919eedba48cc8d207fbf0", metadata.get("X-TIKA:digest:MD5"), "X-TIKA:digest:MD5");
}
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/OpenNLPMetadataFilterTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/OpenNLPMetadataFilterTest.java
index 45d27c942..15c706451 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/OpenNLPMetadataFilterTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/OpenNLPMetadataFilterTest.java
@@ -67,7 +67,7 @@ public class OpenNLPMetadataFilterTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/config/tika-config-langdetect-opennlp-filter.xml");
+ return getClass().getResourceAsStream("/configs/tika-config-langdetect-opennlp-filter.json");
}
@Test
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/OptimaizeMetadataFilterTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/OptimaizeMetadataFilterTest.java
index 0ea81742e..f133fb8af 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/OptimaizeMetadataFilterTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/OptimaizeMetadataFilterTest.java
@@ -67,7 +67,7 @@ public class OptimaizeMetadataFilterTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/config/tika-config-langdetect-optimaize-filter.xml");
+ return getClass().getResourceAsStream("/configs/tika-config-langdetect-optimaize-filter.json");
}
@Test
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataFilterTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataFilterTest.java
index 5b11121bc..a87b1064a 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataFilterTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataFilterTest.java
@@ -51,7 +51,7 @@ public class RecursiveMetadataFilterTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/config/TIKA-3137-include.xml");
+ return getClass().getResourceAsStream("/configs/TIKA-3137-include.json");
}
@Override
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataResourceTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataResourceTest.java
index b6dbfc823..e7f916c75 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataResourceTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/RecursiveMetadataResourceTest.java
@@ -77,7 +77,7 @@ public class RecursiveMetadataResourceTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/config/tika-config-for-server-tests.xml");
+ return getClass().getResourceAsStream("/configs/tika-config-for-server-tests.json");
}
@Test
@@ -118,10 +118,9 @@ public class RecursiveMetadataResourceTest extends CXFTestBase {
.get(0)
.getValues(TikaCoreProperties.TIKA_PARSED_BY);
//make sure the CompressorParser doesn't show up here
- assertEquals(3, parsedBy.length);
+ assertEquals(2, parsedBy.length);
assertEquals("org.apache.tika.parser.CompositeParser", parsedBy[0]);
- assertEquals("org.apache.tika.parser.DefaultParser", parsedBy[1]);
- assertEquals("org.apache.tika.parser.microsoft.ooxml.OOXMLParser", parsedBy[2]);
+ assertEquals("org.apache.tika.parser.microsoft.ooxml.OOXMLParser", parsedBy[1]);
//test that the rest is as it should be
assertEquals(12, metadataList.size());
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaParsersTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaParsersTest.java
index 7b464f8da..f844f85a4 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaParsersTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaParsersTest.java
@@ -54,7 +54,7 @@ public class TikaParsersTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/config/tika-config-for-server-tests.xml");
+ return getClass().getResourceAsStream("/configs/tika-config-for-server-tests.json");
}
protected String getPath(boolean withDetails) {
@@ -71,7 +71,6 @@ public class TikaParsersTest extends CXFTestBase {
.get();
String text = getStringFromInputStream((InputStream) response.getEntity());
- assertContains("org.apache.tika.parser.DefaultParser (Composite Parser)", text);
assertContains(OpusParser.class.getName(), text);
assertContains(PackageParser.class.getName(), text);
assertContains(OOXMLParser.class.getName(), text);
@@ -100,12 +99,11 @@ public class TikaParsersTest extends CXFTestBase {
.get();
String text = getStringFromInputStream((InputStream) response.getEntity());
- assertContains("<h3>DefaultParser</h3>", text);
assertContains("Composite", text);
- assertContains("<h4>OpusParser", text);
- assertContains("<h4>PackageParser", text);
- assertContains("<h4>OOXMLParser", text);
+ assertContains("<h3>OpusParser", text);
+ assertContains("<h3>PackageParser", text);
+ assertContains("<h3>OOXMLParser", text);
assertContains(OpusParser.class.getName(), text);
assertContains(PackageParser.class.getName(), text);
@@ -153,47 +151,40 @@ public class TikaParsersTest extends CXFTestBase {
boolean hasOpus = false, hasOOXML = false, hasZip = false;
int nonComposite = 0;
int composite = 0;
+ assertTrue(children.size() > 50);
for (Object o : children) {
Map<String, Object> child = (Map<String, Object>) o;
assertEquals(true, child.containsKey("name"));
assertEquals(true, child.containsKey("composite"));
- List<Object> grandChildrenArr = (List) child.get("children");
- if (grandChildrenArr == null) {
- continue;
+ if (child.get("composite") == Boolean.FALSE) {
+ nonComposite++;
+ } else {
+ composite++;
}
- assertTrue(grandChildrenArr.size() > 50);
- for (Object grandChildO : grandChildrenArr) {
- Map<String, Object> grandChildren = (Map<String, Object>) grandChildO;
-
- if (grandChildren.get("composite") == Boolean.FALSE) {
- nonComposite++;
- } else {
- composite++;
- }
-
- // Will only have mime types if requested
- if (grandChildren.get("composite") == Boolean.FALSE) {
- assertEquals(details, grandChildren.containsKey("supportedTypes"));
- }
-
- String name = (String) grandChildren.get("name");
- if (OpusParser.class
- .getName()
- .equals(name)) {
- hasOpus = true;
- }
- if (OOXMLParser.class
- .getName()
- .equals(name)) {
- hasOOXML = true;
- }
- if (PackageParser.class
- .getName()
- .equals(name)) {
- hasZip = true;
- }
+
+ // Will only have mime types if requested
+ if (child.get("composite") == Boolean.FALSE) {
+ assertEquals(details, child.containsKey("supportedTypes"));
+ }
+
+ String name = (String) child.get("name");
+ if (OpusParser.class
+ .getName()
+ .equals(name)) {
+ hasOpus = true;
}
+ if (OOXMLParser.class
+ .getName()
+ .equals(name)) {
+ hasOOXML = true;
+ }
+ if (PackageParser.class
+ .getName()
+ .equals(name)) {
+ hasZip = true;
+ }
+
}
assertEquals(true, hasOpus);
assertEquals(true, hasOOXML);
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaPipesTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaPipesTest.java
index 80c241b6b..74d37b11a 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaPipesTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaPipesTest.java
@@ -93,8 +93,6 @@ public class TikaPipesTest extends CXFTestBase {
private static Path OUTPUT_BYTES_DIR;
private static Path TIKA_PIPES_LOG4j2_PATH;
private static Path TIKA_CONFIG_PATH;
- private static Path PLUGINS_CONFIG_PATH;
- private static String TIKA_CONFIG_XML;
private static FetcherManager FETCHER_MANAGER;
@BeforeAll
@@ -109,26 +107,13 @@ public class TikaPipesTest extends CXFTestBase {
StandardCopyOption.REPLACE_EXISTING);
Files.copy(TikaPipesTest.class.getResourceAsStream("/test-documents/" + TEST_TWO_BOXES_PDF), inputDir.resolve(TEST_TWO_BOXES_PDF),
StandardCopyOption.REPLACE_EXISTING);
- TIKA_CONFIG_PATH = Files.createTempFile(TMP_WORKING_DIR, "tika-pipes-", ".xml");
TIKA_PIPES_LOG4j2_PATH = Files.createTempFile(TMP_WORKING_DIR, "log4j2-", ".xml");
Files.copy(TikaPipesTest.class.getResourceAsStream("/log4j2.xml"), TIKA_PIPES_LOG4j2_PATH, StandardCopyOption.REPLACE_EXISTING);
- //TODO: templatify this config
- TIKA_CONFIG_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<properties>" +
- "<pipes><params><tikaConfig>" +
- ProcessUtils.escapeCommandLine(TIKA_CONFIG_PATH
- .toAbsolutePath()
- .toString()) + "</tikaConfig><numClients>10</numClients>" + "<forkedJvmArgs>" + "<arg>-Xmx256m</arg>" +
- "<arg>-Dlog4j.configurationFile=file:" +
- ProcessUtils.escapeCommandLine(TIKA_PIPES_LOG4j2_PATH
- .toAbsolutePath()
- .toString()) + "</arg>" + "</forkedJvmArgs>" + "</params></pipes>" + "</properties>";
- Files.write(TIKA_CONFIG_PATH, TIKA_CONFIG_XML.getBytes(StandardCharsets.UTF_8));
-
- PLUGINS_CONFIG_PATH = Files.createTempFile(TMP_WORKING_DIR, "tika-pipes-config-", ".json");
- CXFTestBase.createPluginsConfig(PLUGINS_CONFIG_PATH, inputDir, OUTPUT_JSON_DIR, OUTPUT_BYTES_DIR);
-
- TikaConfigs tikaConfigs = TikaConfigs.load(PLUGINS_CONFIG_PATH);
+ TIKA_CONFIG_PATH = Files.createTempFile(TMP_WORKING_DIR, "tika-pipes-config-", ".json");
+ CXFTestBase.createPluginsConfig(TIKA_CONFIG_PATH, inputDir, OUTPUT_JSON_DIR, OUTPUT_BYTES_DIR, 10000L);
+
+ TikaConfigs tikaConfigs = TikaConfigs.load(TIKA_CONFIG_PATH);
TikaPluginManager pluginManager = TikaPluginManager.load(tikaConfigs);
FETCHER_MANAGER = FetcherManager.load(pluginManager, tikaConfigs);
@@ -145,7 +130,7 @@ public class TikaPipesTest extends CXFTestBase {
protected void setUpResources(JAXRSServerFactoryBean sf) {
List<ResourceProvider> rCoreProviders = new ArrayList<>();
try {
- rCoreProviders.add(new SingletonResourceProvider(new PipesResource(TIKA_CONFIG_PATH, PLUGINS_CONFIG_PATH)));
+ rCoreProviders.add(new SingletonResourceProvider(new PipesResource(TIKA_CONFIG_PATH)));
} catch (IOException | TikaConfigException e) {
throw new RuntimeException(e);
}
@@ -161,8 +146,8 @@ public class TikaPipesTest extends CXFTestBase {
}
@Override
- protected InputStream getTikaConfigInputStream() {
- return new ByteArrayInputStream(TIKA_CONFIG_XML.getBytes(StandardCharsets.UTF_8));
+ protected InputStream getTikaConfigInputStream() throws IOException {
+ return new ByteArrayInputStream(Files.readAllBytes(TIKA_CONFIG_PATH));
}
@Override
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaResourceTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaResourceTest.java
index 0b264dad2..410c0cc3e 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaResourceTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/TikaResourceTest.java
@@ -89,7 +89,7 @@ public class TikaResourceTest extends CXFTestBase {
@Override
protected InputStream getTikaConfigInputStream() {
- return getClass().getResourceAsStream("/config/tika-config-for-server-tests.xml");
+ return getClass().getResourceAsStream("/configs/tika-config-for-server-tests.json");
}
@Test
@@ -494,7 +494,7 @@ public class TikaResourceTest extends CXFTestBase {
.accept("text/plain")
.header(TesseractServerConfig.X_TIKA_OCR_HEADER_PREFIX + "tesseractPath", "bogus path")
.put(ClassLoader.getSystemResourceAsStream("test-documents/testOCR.pdf"));
- assertEquals(400, response.getStatus());
+ assertEquals(500, response.getStatus());
} catch (ProcessingException e) {
//swallow
}
diff --git a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/UnpackerResourceWithConfigTest.java b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/UnpackerResourceWithConfigTest.java
index a8172d5fa..989c017de 100644
--- a/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/UnpackerResourceWithConfigTest.java
+++ b/tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/UnpackerResourceWithConfigTest.java
@@ -67,11 +67,11 @@ public class UnpackerResourceWithConfigTest extends CXFTestBase {
protected InputStream getTikaConfigInputStream() throws IOException {
return this
.getClass()
- .getResourceAsStream("/config/tika-config-unpacker.xml");
+ .getResourceAsStream("/configs/tika-config-unpacker.json");
}
//Test that the PDFParser's renderer can be configured at parse time
- //when specified in tika-config.xml
+ //when specified in tika-config.json
@Test
public void testPDFPerPageRenderColor() throws Exception {
diff --git a/tika-server/tika-server-standard/src/test/resources/config/TIKA-3137-include.xml b/tika-server/tika-server-standard/src/test/resources/config/TIKA-3137-include.xml
deleted file mode 100644
index 056e64c6f..000000000
--- a/tika-server/tika-server-standard/src/test/resources/config/TIKA-3137-include.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <metadataFilters>
- <metadataFilter class="org.apache.tika.metadata.filter.IncludeFieldMetadataFilter">
- <params>
- <include>
- <field>X-TIKA:content</field>
- <field>extended-properties:Application</field>
- <field>Content-Type</field>
- </include>
- </params>
- </metadataFilter>
- <metadataFilter class="org.apache.tika.metadata.filter.ClearByMimeMetadataFilter">
- <params>
- <mimes>
- <mime>image/emf</mime>
- <mime>text/plain</mime>
- </mimes>
- </params>
- </metadataFilter>
- </metadataFilters>
-</properties>
diff --git a/tika-server/tika-server-standard/src/test/resources/config/tika-config-for-server-tests.xml b/tika-server/tika-server-standard/src/test/resources/config/tika-config-for-server-tests.xml
deleted file mode 100644
index 5e86586ae..000000000
--- a/tika-server/tika-server-standard/src/test/resources/config/tika-config-for-server-tests.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <parsers>
- <parser class="org.apache.tika.parser.DefaultParser">
- <parser-exclude class="org.apache.tika.parser.pdf.PDFParser"/>
- </parser>
- <parser class="org.apache.tika.parser.pdf.PDFParser">
- <params>
- <param name="sortByPosition" type="bool">true</param>
- </params>
- </parser>
- </parsers>
-</properties>
\ No newline at end of file
diff --git a/tika-server/tika-server-standard/src/test/resources/config/tika-config-json.xml b/tika-server/tika-server-standard/src/test/resources/config/tika-config-json.xml
deleted file mode 100644
index 8c76bd45a..000000000
--- a/tika-server/tika-server-standard/src/test/resources/config/tika-config-json.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <maxJsonStringFieldLength>50000000</maxJsonStringFieldLength>
-</properties>
diff --git a/tika-server/tika-server-standard/src/test/resources/config/tika-config-langdetect-opennlp-filter.xml b/tika-server/tika-server-standard/src/test/resources/config/tika-config-langdetect-opennlp-filter.xml
deleted file mode 100644
index 7dd1d5fe6..000000000
--- a/tika-server/tika-server-standard/src/test/resources/config/tika-config-langdetect-opennlp-filter.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <parsers>
- <parser class="org.apache.tika.parser.DefaultParser">
- <parser-exclude class="org.apache.tika.parser.pdf.PDFParser"/>
- </parser>
- <parser class="org.apache.tika.parser.pdf.PDFParser">
- <params>
- <param name="sortByPosition" type="bool">true</param>
- </params>
- </parser>
- </parsers>
- <metadataFilters>
- <metadataFilter class="org.apache.tika.langdetect.opennlp.metadatafilter.OpenNLPMetadataFilter"/>
- </metadataFilters>
-</properties>
\ No newline at end of file
diff --git a/tika-server/tika-server-standard/src/test/resources/config/tika-config-langdetect-optimaize-filter.xml b/tika-server/tika-server-standard/src/test/resources/config/tika-config-langdetect-optimaize-filter.xml
deleted file mode 100644
index faaed6fcf..000000000
--- a/tika-server/tika-server-standard/src/test/resources/config/tika-config-langdetect-optimaize-filter.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <parsers>
- <parser class="org.apache.tika.parser.DefaultParser">
- <parser-exclude class="org.apache.tika.parser.pdf.PDFParser"/>
- </parser>
- <parser class="org.apache.tika.parser.pdf.PDFParser">
- <params>
- <param name="sortByPosition" type="bool">true</param>
- </params>
- </parser>
- </parsers>
- <metadataFilters>
- <metadataFilter class="org.apache.tika.langdetect.optimaize.metadatafilter.OptimaizeMetadataFilter"/>
- </metadataFilters>
-</properties>
\ No newline at end of file
diff --git a/tika-server/tika-server-standard/src/test/resources/config/tika-config-unpacker.xml b/tika-server/tika-server-standard/src/test/resources/config/tika-config-unpacker.xml
deleted file mode 100644
index 40150947f..000000000
--- a/tika-server/tika-server-standard/src/test/resources/config/tika-config-unpacker.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<properties>
- <parsers>
- <parser class="org.apache.tika.parser.DefaultParser">
- <parser-exclude class="org.apache.tika.parser.pdf.PDFParser"/>
- </parser>
- <parser class="org.apache.tika.parser.pdf.PDFParser">
- <params>
- <param name="sortByPosition" type="bool">true</param>
- </params>
- </parser>
- </parsers>
- <renderers>
- <renderer class="org.apache.tika.renderer.pdf.pdfbox.PDFBoxRenderer"/>
- </renderers>
-</properties>
\ No newline at end of file
diff --git a/tika-server/tika-server-standard/src/test/resources/configs/TIKA-3137-include.json b/tika-server/tika-server-standard/src/test/resources/configs/TIKA-3137-include.json
new file mode 100644
index 000000000..5b68d569c
--- /dev/null
+++ b/tika-server/tika-server-standard/src/test/resources/configs/TIKA-3137-include.json
@@ -0,0 +1,21 @@
+{
+ "metadata-filters": [
+ {
+ "include-field-metadata-filter": {
+ "include": [
+ "X-TIKA:content",
+ "extended-properties:Application",
+ "Content-Type"
+ ]
+ }
+ },
+ {
+ "clear-by-mime-metadata-filter": {
+ "mimes": [
+ "image/emf",
+ "text/plain"
+ ]
+ }
+ }
+ ]
+}
diff --git a/tika-server/tika-server-standard/src/test/resources/configs/tika-config-for-server-tests.json b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-for-server-tests.json
new file mode 100644
index 000000000..e14b2dab7
--- /dev/null
+++ b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-for-server-tests.json
@@ -0,0 +1,22 @@
+{
+ "parsers": [
+ {
+ "default-parser": {}
+ },
+ {
+ "pdf-parser": {
+ "sortByPosition": true
+ }
+ }
+ ],
+ "auto-detect-parser-config": {
+ "spoolToDisk": 1000000,
+ "outputThreshold": 1000000,
+ "digesterFactory": {
+ "@class": "org.apache.tika.parser.digestutils.CommonsDigesterFactory",
+ "markLimit": 100000,
+ "algorithmString": "md5,sha1:32"
+ },
+ "throwOnZeroBytes": false
+ }
+}
diff --git a/tika-server/tika-server-standard/src/test/resources/configs/tika-config-json.json b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-json.json
new file mode 100644
index 000000000..419a225e6
--- /dev/null
+++ b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-json.json
@@ -0,0 +1,3 @@
+{
+ "maxJsonStringFieldLength": 50000000
+}
diff --git a/tika-server/tika-server-standard/src/test/resources/configs/tika-config-langdetect-opennlp-filter.json b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-langdetect-opennlp-filter.json
new file mode 100644
index 000000000..93c8ae2fa
--- /dev/null
+++ b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-langdetect-opennlp-filter.json
@@ -0,0 +1,27 @@
+{
+ "parsers": [
+ {
+ "default-parser": {}
+ },
+ {
+ "pdf-parser": {
+ "sortByPosition": true
+ }
+ }
+ ],
+ "metadata-filters": [
+ {
+ "open-nlp-metadata-filter": {}
+ }
+ ],
+ "auto-detect-parser-config": {
+ "spoolToDisk": 1000000,
+ "outputThreshold": 1000000,
+ "digesterFactory": {
+ "@class": "org.apache.tika.parser.digestutils.CommonsDigesterFactory",
+ "markLimit": 100000,
+ "algorithmString": "md5,sha1:32"
+ },
+ "throwOnZeroBytes": false
+ }
+}
diff --git a/tika-server/tika-server-standard/src/test/resources/configs/tika-config-langdetect-optimaize-filter.json b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-langdetect-optimaize-filter.json
new file mode 100644
index 000000000..38e69c5c3
--- /dev/null
+++ b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-langdetect-optimaize-filter.json
@@ -0,0 +1,27 @@
+{
+ "parsers": [
+ {
+ "default-parser": {}
+ },
+ {
+ "pdf-parser": {
+ "sortByPosition": true
+ }
+ }
+ ],
+ "metadata-filters": [
+ {
+ "optimaize-metadata-filter": {}
+ }
+ ],
+ "auto-detect-parser-config": {
+ "spoolToDisk": 1000000,
+ "outputThreshold": 1000000,
+ "digesterFactory": {
+ "@class": "org.apache.tika.parser.digestutils.CommonsDigesterFactory",
+ "markLimit": 100000,
+ "algorithmString": "md5,sha1:32"
+ },
+ "throwOnZeroBytes": false
+ }
+}
diff --git a/tika-server/tika-server-standard/src/test/resources/configs/tika-config-unpacker.json b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-unpacker.json
new file mode 100644
index 000000000..331cb60f0
--- /dev/null
+++ b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-unpacker.json
@@ -0,0 +1,17 @@
+{
+ "parsers": [
+ {
+ "default-parser": {}
+ },
+ {
+ "pdf-parser": {
+ "sortByPosition": true
+ }
+ }
+ ],
+ "renderers": [
+ {
+ "pdfbox-renderer": {}
+ }
+ ]
+}
diff --git a/tika-server/tika-server-standard/src/test/resources/config/tika-config-url-fetcher.xml b/tika-server/tika-server-standard/src/test/resources/configs/tika-config-url-fetcher.xml
similarity index 100%
rename from tika-server/tika-server-standard/src/test/resources/config/tika-config-url-fetcher.xml
rename to tika-server/tika-server-standard/src/test/resources/configs/tika-config-url-fetcher.xml