diff --git a/CHANGELOG.md b/CHANGELOG.md index a8d7e2f5a..51bd20cfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fix problem with catalog file for compressed ontologies [#1281] + ## [1.9.10] - 2026-02-18 ### Fixed diff --git a/robot-core/src/main/java/org/obolibrary/robot/IOHelper.java b/robot-core/src/main/java/org/obolibrary/robot/IOHelper.java index 4187b5833..4f041e258 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/IOHelper.java +++ b/robot-core/src/main/java/org/obolibrary/robot/IOHelper.java @@ -288,7 +288,7 @@ protected static boolean cleanTDB(String tdbDir) { * file for a catalog file. * * @param ontologyFile the - * @return the guessed catalog File; may not exist! + * @return the guessed catalog File or null if it does not exist */ public File guessCatalogFile(File ontologyFile) { String path = ontologyFile.getParent(); @@ -296,7 +296,12 @@ public File guessCatalogFile(File ontologyFile) { if (path != null) { catalogPath = path + "/catalog-v001.xml"; } - return new File(catalogPath); + File catalogFile = new File(catalogPath); + if (catalogFile.isFile()) { + return catalogFile; + } else { + return null; + } } /** @@ -309,10 +314,6 @@ public File guessCatalogFile(File ontologyFile) { public OWLOntology loadOntology(String ontologyPath) throws IOException { File ontologyFile = new File(ontologyPath); File catalogFile = guessCatalogFile(ontologyFile); - if (!catalogFile.isFile()) { - // If the catalog file does not exist, do not use catalog - catalogFile = null; - } return loadOntology(ontologyFile, catalogFile); } @@ -387,10 +388,6 @@ public OWLOntology loadOntology(String ontologyPath, String catalogPath, String */ public OWLOntology loadOntology(File ontologyFile) throws IOException { File catalogFile = guessCatalogFile(ontologyFile); - if (!catalogFile.isFile()) { - // If the catalog file does not exist, do not use catalog - catalogFile = null; - } return loadOntology(ontologyFile, catalogFile); } @@ -484,10 +481,10 @@ public OWLOntology loadOntology(File ontologyFile, File catalogFile, String inpu } // Maybe unzip if (ontologyFile.getPath().endsWith(".gz")) { - if (catalogFile == null) { - return loadCompressedOntology(ontologyFile, null, inputFormat); - } else { + if (catalogFile != null && catalogFile.isFile()) { return loadCompressedOntology(ontologyFile, catalogFile.getAbsolutePath(), inputFormat); + } else { + return loadCompressedOntology(ontologyFile, null, inputFormat); } }