You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "timgrein (via GitHub)" <gi...@apache.org> on 2026/09/15 07:51:11 UTC

[PR] TIKA-4892: Fix --list-met-models [tika]

timgrein opened a new pull request, #3173:
URL: https://github.com/apache/tika/pull/3173

   Currently `--list-met-models` only prints `Serializible` as `Metadata` doesn't implement the different metadata interfaces (`AccessPermissions` ... `Zip`) anymore.
   I've added them now explicitly to `TikaCLI`. An alternative approach would be to use reflection to scan over the directory containing the metadata interfaces, but this sounds a bit hacky. A marker interface would also rely on a new interface needing to implement it explicitly, so I thought simply hardcoding it is the most straightforward solution.
   
   New output:
   ```
   java -jar tika-app/target/tika-app-*.jar --list-met-models                                                                                                                                                                         
   AccessPermissions
    ASSEMBLE_DOCUMENT
    CAN_MODIFY
    CAN_MODIFY_ANNOTATIONS
   ...
   Zip
    CENTRAL_DIRECTORY_ONLY_ENTRIES
    COMMENT
    COMPRESSED_SIZE
    COMPRESSION_METHOD
   ...
   ```


-- 
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: dev-unsubscribe@tika.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] TIKA-4892: Fix --list-met-models [tika]

Posted by "tballison (via GitHub)" <gi...@apache.org>.
tballison commented on PR #3173:
URL: https://github.com/apache/tika/pull/3173#issuecomment-5696358324

   Thank you for this @timgrein ! What would you think of reusing the `metadata-key-fields.json`  we have in tika-metadata-schema? Perhaps add that as a dependency in tika-app and then filter for those that are live in tika-app -- filter out those in tika-parsers-scientific(??? or whatever modules we don't auto-include in tika-app)... or, better perhaps a Class.forName() check?
   
   I might also include the TikaCoreProperties. wdyt?


-- 
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: dev-unsubscribe@tika.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] TIKA-4892: Fix --list-met-models [tika]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3173:
URL: https://github.com/apache/tika/pull/3173#discussion_r4016079137


##########
tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java:
##########
@@ -1051,21 +1147,15 @@ private void configure() throws TikaException, IOException, SAXException {
     }
 
     private void displayMetModels() {
-        Class<?>[] modelClasses = Metadata.class.getInterfaces();
-        Arrays.sort(modelClasses, Comparator.comparing(Class::getName));
-
-        for (Class<?> modelClass : modelClasses) {
-            // we don't care about internal Tika met classes
-            // if we do, then we can take this conditional out
-            if (!modelClass
-                    .getSimpleName()
-                    .contains("Tika")) {
-                System.out.println(modelClass.getSimpleName());
-                Field[] keyFields = modelClass.getFields();
-                Arrays.sort(keyFields, Comparator.comparing(Field::getName));
-                for (Field keyField : keyFields) {
-                    System.out.println(" " + keyField.getName());
-                }
+        Class<?>[] sorted = Arrays.copyOf(METADATA_CLASSES, METADATA_CLASSES.length);
+        Arrays.sort(sorted, Comparator.comparing(Class::getSimpleName));
+
+        for (Class<?> modelClass : sorted) {

Review Comment:
   This changes the source of the model list, but `TikaCLITest.testListMetModels` still only asserts `text/plain`, which comes from the `-x` parse and does not verify this output. Add assertions for representative models and keys (for example, `AccessPermissions`/`CAN_MODIFY` and `Zip`/`COMMENT`) so omissions from this hard-coded array fail CI.



-- 
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: dev-unsubscribe@tika.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] TIKA-4892: Fix --list-met-models [tika]

Posted by "timgrein (via GitHub)" <gi...@apache.org>.
timgrein commented on code in PR #3173:
URL: https://github.com/apache/tika/pull/3173#discussion_r4024301145


##########
tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java:
##########
@@ -1051,21 +1147,15 @@ private void configure() throws TikaException, IOException, SAXException {
     }
 
     private void displayMetModels() {
-        Class<?>[] modelClasses = Metadata.class.getInterfaces();
-        Arrays.sort(modelClasses, Comparator.comparing(Class::getName));
-
-        for (Class<?> modelClass : modelClasses) {
-            // we don't care about internal Tika met classes
-            // if we do, then we can take this conditional out
-            if (!modelClass
-                    .getSimpleName()
-                    .contains("Tika")) {
-                System.out.println(modelClass.getSimpleName());
-                Field[] keyFields = modelClass.getFields();
-                Arrays.sort(keyFields, Comparator.comparing(Field::getName));
-                for (Field keyField : keyFields) {
-                    System.out.println(" " + keyField.getName());
-                }
+        Class<?>[] sorted = Arrays.copyOf(METADATA_CLASSES, METADATA_CLASSES.length);
+        Arrays.sort(sorted, Comparator.comparing(Class::getSimpleName));
+
+        for (Class<?> modelClass : sorted) {

Review Comment:
   Addressed with [Assert a few models](https://github.com/apache/tika/pull/3173/commits/ed3125a96b13289e86a5f3fe1a1b13b03e5d4d1d)



-- 
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: dev-unsubscribe@tika.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org