This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new 80b7f1c9c TIKA-4341 -- fix MetadataListFilter's deserialization (#2030)
80b7f1c9c is described below
commit 80b7f1c9cba38927db67eb0d3a3178c3ed10c868
Author: Tim Allison <[email protected]>
AuthorDate: Wed Oct 30 09:28:29 2024 -0400
TIKA-4341 -- fix MetadataListFilter's deserialization (#2030)
---
.../metadata/listfilter/MetadataListFilter.java | 3 +-
.../listfilter/MetadataListFilterTest.java | 41 ++++++++++++++++++++++
.../listfilter/metadatalistfilter-config.xml | 22 ++++++++++++
3 files changed, 64 insertions(+), 2 deletions(-)
diff --git
a/tika-core/src/main/java/org/apache/tika/metadata/listfilter/MetadataListFilter.java
b/tika-core/src/main/java/org/apache/tika/metadata/listfilter/MetadataListFilter.java
index 93021da7c..0735a98a1 100644
---
a/tika-core/src/main/java/org/apache/tika/metadata/listfilter/MetadataListFilter.java
+++
b/tika-core/src/main/java/org/apache/tika/metadata/listfilter/MetadataListFilter.java
@@ -26,7 +26,6 @@ import org.apache.tika.config.ConfigBase;
import org.apache.tika.exception.TikaConfigException;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
-import org.apache.tika.metadata.filter.MetadataFilter;
public abstract class MetadataListFilter extends ConfigBase implements
Serializable {
/**
@@ -40,7 +39,7 @@ public abstract class MetadataListFilter extends ConfigBase
implements Serializa
IOException {
try {
return buildComposite("metadataListFilters",
CompositeMetadataListFilter.class,
- "metadataListFilter", MetadataFilter.class, root);
+ "metadataListFilter", MetadataListFilter.class, root);
} catch (TikaConfigException e) {
if (allowMissing && e.getMessage().contains("could not find
metadataListFilters")) {
return new NoOpListFilter();
diff --git
a/tika-core/src/test/java/org/apache/tika/metadata/listfilter/MetadataListFilterTest.java
b/tika-core/src/test/java/org/apache/tika/metadata/listfilter/MetadataListFilterTest.java
new file mode 100644
index 000000000..ad5aa1a19
--- /dev/null
+++
b/tika-core/src/test/java/org/apache/tika/metadata/listfilter/MetadataListFilterTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.metadata.listfilter;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.InputStream;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.tika.config.TikaConfig;
+
+public class MetadataListFilterTest {
+
+ @Test
+ public void testBasic() throws Exception {
+ TikaConfig tikaConfig;
+ try (InputStream is = MetadataListFilterTest.class.getResourceAsStream(
+ "metadatalistfilter-config.xml")) {
+ tikaConfig = new TikaConfig(is);
+ }
+ CompositeMetadataListFilter compositeMetadataListFilter =
(CompositeMetadataListFilter) tikaConfig.getMetadataListFilter();
+ assertEquals(1, compositeMetadataListFilter.getFilters().size());
+ assertTrue(compositeMetadataListFilter.getFilters().get(0) instanceof
AttachmentCountingListFilter);
+ }
+}
diff --git
a/tika-core/src/test/resources/org/apache/tika/metadata/listfilter/metadatalistfilter-config.xml
b/tika-core/src/test/resources/org/apache/tika/metadata/listfilter/metadatalistfilter-config.xml
new file mode 100644
index 000000000..55d25e58b
--- /dev/null
+++
b/tika-core/src/test/resources/org/apache/tika/metadata/listfilter/metadatalistfilter-config.xml
@@ -0,0 +1,22 @@
+<?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>
+ <metadataListFilters>
+ <metadataListFilter
class="org.apache.tika.metadata.listfilter.AttachmentCountingListFilter"/>
+ </metadataListFilters>
+</properties>
\ No newline at end of file