From ae49f580d0a0af0ccf87dbc19ce81ae9096aeeb3 Mon Sep 17 00:00:00 2001 From: Johannes Heinecke Date: Sun, 4 Jun 2023 14:43:14 +0200 Subject: [PATCH] absent option --rootdir corrected --- CHANGES.md | 3 +++ Dockerfile | 8 ++++---- README.md | 2 +- pom.xml | 4 ++-- .../orange/labs/httpserver/ServeurHTTP.java | 20 +++++++++++++------ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e8f4931..052dcd4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ # Changes +## Version 2.22.3 +* bug concerning --rootdir corrected + ## Version 2.22.2 * MISC shortcut correction, `mod addmisc` added * new test diff --git a/Dockerfile b/Dockerfile index 61e3628..d81a553 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ FROM openjdk:17-alpine -ARG VERSION=2.22.0 -# docker build --build-arg 2.22.0 -t jheinecke/conllueditor:2.22.0 . -# docker build --build-arg 2.22.0 -t jheinecke/conllueditor:latest . +ARG VERSION=2.22.3 +# docker build --build-arg 2.22.3 -t jheinecke/conllueditor:2.22.3 . +# docker build --build-arg 2.22.3 -t jheinecke/conllueditor:latest . # docker run -t --rm --name conllueditor -p 5555:5555 --user 1000:1000 -v :/data --env filename=tt.conllu jheinecke/conllueditor:latest -# docker push jheinecke/conllueditor:2.22.0 +# docker push jheinecke/conllueditor:2.22.3 # docker push jheinecke/conllueditor:latest # docker exec -it conllueditor /bin/sh diff --git a/README.md b/README.md index 7ae2b51..972bf5f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ The editor provides the following functionalities: * adding Translit= values to the MISC column (transliterating the FORM column) see section [Transliteration](#transliteration) * finding similar or identical sentence in a list of CoNLL-U files, see section [Find Similar Sentences](#find-similar-sentences) -Current version: 2.22.2 (see [change history](CHANGES.md)) +Current version: 2.22.3 (see [change history](CHANGES.md)) ConlluEditor can also be used as front-end to display the results of dependency parsing in the same way as the editor. * dependency tree/dependency hedge diff --git a/pom.xml b/pom.xml index b32e029..3464233 100644 --- a/pom.xml +++ b/pom.xml @@ -32,13 +32,13 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. author Johannes Heinecke - version 2.22.2 as of 22nd May 2023 + version 2.22.3 as of 4th June 2023 --> 4.0.0 com.orange.labs ConlluEditor - 2.22.2 + 2.22.3 jar diff --git a/src/main/java/com/orange/labs/httpserver/ServeurHTTP.java b/src/main/java/com/orange/labs/httpserver/ServeurHTTP.java index 8a27bb1..f8dca1c 100644 --- a/src/main/java/com/orange/labs/httpserver/ServeurHTTP.java +++ b/src/main/java/com/orange/labs/httpserver/ServeurHTTP.java @@ -1,6 +1,6 @@ /** This library is under the 3-Clause BSD License -Copyright (c) 2018-2021, Orange S.A. +Copyright (c) 2018-2023, Orange S.A. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @author Johannes Heinecke - @version 2.10.0 as of 10th January 2021 + @version 2.22.3 as of 4th June 2023 */ package com.orange.labs.httpserver; @@ -105,14 +105,17 @@ public ServeurHTTP(int port, /*ConlluEditor */ Object e, String rootdir, int deb HttpServer server = HttpServer.create(new InetSocketAddress(this.port), 0); String indexhtml = null; + String indexjs = null; if (e instanceof ConlluEditor) { ce = (ConlluEditor) e; server.createContext("/edit/", new EditHandler(ce)); indexhtml = "index.html"; + indexjs = "edit.js"; } else if (e instanceof ParserClient) { pc = (ParserClient) e; server.createContext("/parse/", new ParseHandler(pc)); indexhtml = "parse.html"; + indexjs = "parse.js"; } else { System.err.println("Bad Context: " + e); System.exit(11); @@ -128,9 +131,7 @@ public ServeurHTTP(int port, /*ConlluEditor */ Object e, String rootdir, int deb s = URLDecoder.decode(s, "UTF-8"); rootdir = s; System.err.println("calculated rootdir from .jar: " + s); - } - - if (rootdir != null) { + } else { Path rdir = new File(rootdir).toPath(); if (!Files.exists(rdir)) { throw new IOException(rootdir + " does not exist"); @@ -138,8 +139,15 @@ public ServeurHTTP(int port, /*ConlluEditor */ Object e, String rootdir, int deb if (!Files.isDirectory(rdir)) { throw new IOException(rootdir + " is not a directory"); } - server.createContext("/", new FileHandler(rootdir, indexhtml)); + if (!Files.exists(new File(rootdir, indexhtml).toPath())) { + throw new IOException(rootdir + " does contain '" + indexhtml + "'"); + } + if (!Files.exists(new File(rootdir, indexjs).toPath())) { + throw new IOException(rootdir + " does contain '" + indexjs + "'"); + } } + + server.createContext("/", new FileHandler(rootdir, indexhtml)); server.setExecutor(null); String hostname = "localhost";