Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
import org.apache.tika.pipes.core.EmitStrategyConfig;
import org.apache.tika.pipes.core.PipesClient;
import org.apache.tika.pipes.core.PipesConfig;
import org.apache.tika.pipes.core.config.ConfigStore;
import org.apache.tika.pipes.core.config.ConfigStoreFactory;
import org.apache.tika.pipes.core.emitter.EmitterManager;
import org.apache.tika.pipes.core.fetcher.FetcherManager;
import org.apache.tika.plugins.TikaPluginManager;
Expand Down Expand Up @@ -454,10 +456,14 @@ protected void initializeResources() throws TikaException, IOException, SAXExcep
TikaJsonConfig tikaJsonConfig = tikaLoader.getConfig();
TikaPluginManager tikaPluginManager = TikaPluginManager.load(tikaJsonConfig);

//TODO allowed named configurations in tika config
this.fetcherManager = FetcherManager.load(tikaPluginManager, tikaJsonConfig);
// Always initialize emitters to support runtime overrides via ParseContext
this.emitterManager = EmitterManager.load(tikaPluginManager, tikaJsonConfig);
// Create ConfigStore using the same configuration as TikaGrpcServerImpl
// This allows fetchers saved via gRPC to be available to PipesServer
ConfigStore configStore = createConfigStore(pipesConfig, tikaPluginManager);

// Load FetcherManager with ConfigStore to enable runtime modifications
this.fetcherManager = FetcherManager.load(tikaPluginManager, tikaJsonConfig, true, configStore);
// Always initialize emitters to support runtime overrides via ParseContext
this.emitterManager = EmitterManager.load(tikaPluginManager, tikaJsonConfig, true, configStore);
this.autoDetectParser = (AutoDetectParser) tikaLoader.loadAutoDetectParser();
// Get the digester for pre-parse digesting of container documents.
// If user configured skipContainerDocumentDigest=false (the default), PipesServer
Expand All @@ -484,6 +490,18 @@ protected void initializeResources() throws TikaException, IOException, SAXExcep
this.rMetaParser = new RecursiveParserWrapper(autoDetectParser);
}

private ConfigStore createConfigStore(PipesConfig pipesConfig, TikaPluginManager tikaPluginManager) throws TikaException {
if (pipesConfig.getConfigStore() != null) {
ConfigStoreFactory factory = tikaPluginManager.getPluginManager()
.getExtensions(ConfigStoreFactory.class).stream()
.filter(f -> f.getClass().getName().equals(pipesConfig.getConfigStore().getFactoryClass()))
.findFirst()
.orElseThrow(() -> new TikaException("Could not find ConfigStoreFactory: " +
pipesConfig.getConfigStore().getFactoryClass()));
return factory.build(pipesConfig.getConfigStore().getParams());
}
return null;
}

private void write(PROCESSING_STATUS processingStatus, PipesResult pipesResult) {
try {
Expand Down
Loading