janhoy commented on code in PR #3670:
URL: https://github.com/apache/solr/pull/3670#discussion_r2428716937


##########
solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractingRequestHandler.java:
##########
@@ -81,25 +64,116 @@ public void inform(SolrCore core) {
         parseContextConfig =
             new ParseContextConfig(core.getResourceLoader(), 
parseContextConfigLoc);
       }
+
+      // Always create local backend
+      this.localBackend = new LocalTikaExtractionBackend(core, tikaConfigLoc, 
parseContextConfig);
+
+      // Optionally create Tika Server backend if URL configured
+      String tikaServerUrl = (String) 
initArgs.get(ExtractingParams.TIKASERVER_URL);
+      if (tikaServerUrl != null) {
+        int timeoutSecs = 0;
+        Object initTimeout = 
initArgs.get(ExtractingParams.TIKASERVER_TIMEOUT_SECS);
+        if (initTimeout != null) {
+          try {
+            timeoutSecs = Integer.parseInt(String.valueOf(initTimeout));
+          } catch (NumberFormatException nfe) {
+            throw new SolrException(
+                ErrorCode.SERVER_ERROR,
+                "Invalid value for '"
+                    + ExtractingParams.TIKASERVER_TIMEOUT_SECS
+                    + "': "
+                    + initTimeout,
+                nfe);
+          }
+        }
+        Object maxCharsObj = 
initArgs.get(ExtractingParams.TIKASERVER_MAX_CHARS);
+        long maxCharsLimit = 
TikaServerExtractionBackend.DEFAULT_MAXCHARS_LIMIT;
+        if (maxCharsObj != null) {
+          try {
+            maxCharsLimit = Long.parseLong(String.valueOf(maxCharsObj));
+          } catch (NumberFormatException nfe) {
+            throw new SolrException(
+                ErrorCode.SERVER_ERROR,
+                "Invalid value for '"
+                    + ExtractingParams.TIKASERVER_MAX_CHARS
+                    + "': "
+                    + maxCharsLimit);
+          }
+        }
+        this.tikaServerBackend =
+            new TikaServerExtractionBackend(tikaServerUrl, timeoutSecs, 
initArgs, maxCharsLimit);
+      }
+
+      // Choose default backend name
+      String backendName = (String) 
initArgs.get(ExtractingParams.EXTRACTION_BACKEND);
+      this.defaultBackendName =

Review Comment:
   Validate that backendName is either null or one of the two allowed values



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to