Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZipIRIMapper is case sensitive for file extensions #1140

Closed
srfteixeira opened this issue May 23, 2024 · 0 comments · May be fixed by #1142
Closed

ZipIRIMapper is case sensitive for file extensions #1140

srfteixeira opened this issue May 23, 2024 · 0 comments · May be fixed by #1142

Comments

@srfteixeira
Copy link
Contributor

Hi,

The ZipIRIMapper is case sensitive for the file extensions, while the AutoIRIMapper is not case sensitive. This is causing problems opening .OWL files inside a zip file using the AutoIRIMapper

ZipIRIMapper implementation:

protected void parseIfExtensionSupported(ZipFile file, ZipEntry e, String baseIRI) throws IOException {
        String name = e.getName();
        int lastIndexOf = name.lastIndexOf(46);
        if (lastIndexOf >= 0) {
            IRI physicalIRI = IRI.create(baseIRI + name);
            String extension = name.substring(lastIndexOf);
            if (".obo".equals(extension)) {
                this.oboFileMap.put(name, physicalIRI);
            } else {
                InputStream in = file.getInputStream(e);
                Throwable var9 = null;

                try {
                    IRI logical;
                    if (".ofn".equals(extension)) {
                        logical = parseFSSFile(in);
                        if (logical != null) {
                            this.ontologyIRI2PhysicalURIMap.put(logical, physicalIRI);
                        }
                    } else if (".omn".equals(extension)) {
                        logical = parseManchesterSyntaxFile(in);
                        if (logical != null) {
                            this.ontologyIRI2PhysicalURIMap.put(logical, physicalIRI);
                        }
                    } else if (this.fileExtensions.contains(extension)) {
                        logical = this.parseFile(in);
                        if (logical != null) {
                            this.ontologyIRI2PhysicalURIMap.put(logical, physicalIRI);
                        }
                    }
                } catch (Throwable var18) {
                    var9 = var18;
                    throw var18;
                } finally {
                    if (in != null) {
                        if (var9 != null) {
                            try {
                                in.close();
                            } catch (Throwable var17) {
                                var9.addSuppressed(var17);
                            }
                        } else {
                            in.close();
                        }
                    }

                }
            }

        }
    }

AutoIRIMapper Implementation:

protected void parseIfExtensionSupported(File file) {
        String name = file.getName();
        int lastIndexOf = name.lastIndexOf(46);
        if (lastIndexOf >= 0) {
            String extension = name.substring(lastIndexOf);
            if (!".zip".equalsIgnoreCase(extension) && !".jar".equalsIgnoreCase(extension)) {
                if (".obo".equalsIgnoreCase(extension)) {
                    this.oboFileMap.put(name, IRI.create(file));
                } else if (".ofn".equalsIgnoreCase(extension)) {
                    this.parseFSSFile(file);
                } else if (".omn".equalsIgnoreCase(extension)) {
                    this.parseManchesterSyntaxFile(file);
                } else if (this.fileExtensions.contains(extension.toLowerCase())) {
                    this.parseFile(file);
                }
(...)
srfteixeira added a commit to srfteixeira/owlapi that referenced this issue May 23, 2024
Fix case sensitive extensions in ZipIRIMapper

Fixes owlcs#1140
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant