From 25c697f7c34a814d89b16f843421f07a5e59189a Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 29 Aug 2023 10:00:59 +0200 Subject: [PATCH 1/3] Allow suppression of scanning error reports --- .../hl7/fhir/igtools/publisher/Publisher.java | 14 ++++- .../fhir/igtools/publisher/SimpleFetcher.java | 54 ++++++++++++++----- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java index 704903d35..c755a7c6c 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java @@ -648,7 +648,7 @@ public enum GenerationTool { private String igName; private IGBuildMode mode; // for the IG publication infrastructure - private IFetchFile fetcher = new SimpleFetcher(this); + private SimpleFetcher fetcher = new SimpleFetcher(this); private SimpleWorkerContext context; // private DataRenderer dr; private InstanceValidator validator; @@ -2755,6 +2755,16 @@ else if (p.getValue().equals("show-reference-messages")) hasTranslations = true; translationSupplements.add(p.getValue()); break; + case "logged-when-scanning": + if ("false".equals(p.getValue())) { + fetcher.setReport(false); + } else if ("stack".equals(p.getValue())) { + fetcher.setReport(true); + fetcher.setDebug(true); + } else { + fetcher.setReport(true); + } + break; default: if (!template.isParameter(pc)) { unknownParams.add(pc+"="+p.getValue()); @@ -12009,7 +12019,7 @@ private static String nowAsDate(Calendar cal) { } - public void setFetcher(IFetchFile theFetcher) { + public void setFetcher(SimpleFetcher theFetcher) { fetcher = theFetcher; } diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/SimpleFetcher.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/SimpleFetcher.java index 20ada948a..32ab5ef39 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/SimpleFetcher.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/SimpleFetcher.java @@ -54,7 +54,8 @@ public class SimpleFetcher implements IFetchFile { private ILoggingService log; private String rootDir; private FmlParser fp; - private boolean debug; + private boolean debug = false; + private boolean report = true; public SimpleFetcher(ILoggingService log) { @@ -333,9 +334,11 @@ public List scan(String sourceDir, IWorkerContext context, boolean ok = true; } catch (Exception e) { if (!f.getName().startsWith("Binary-") && !f.getName().startsWith("binary-") ) { // we don't notify here because Binary is special. - log.logMessage(e.getMessage() +" loading "+f); - if (debug) { - e.printStackTrace(); + if (report) { + log.logMessage(e.getMessage() +" loading "+f); + if (debug) { + e.printStackTrace(); + } } } } @@ -349,9 +352,11 @@ public List scan(String sourceDir, IWorkerContext context, boolean } } catch (Exception e) { if (!f.getName().startsWith("Binary-")) { // we don't notify here because Binary is special. - log.logMessage(e.getMessage() +" loading "+f); - if (debug) { - e.printStackTrace(); + if (report) { + log.logMessage(e.getMessage() +" loading "+f); + if (debug) { + e.printStackTrace(); + } } } } @@ -364,10 +369,13 @@ public List scan(String sourceDir, IWorkerContext context, boolean ok = true; } catch (Exception e) { if (!f.getName().startsWith("Binary-")) { // we don't notify here because Binary is special. - log.logMessage(e.getMessage() +" loading "+f); - if (debug) { - e.printStackTrace(); + if (report) { + log.logMessage(e.getMessage() +" loading "+f); + if (debug) { + e.printStackTrace(); + } } + } } } @@ -382,9 +390,11 @@ public List scan(String sourceDir, IWorkerContext context, boolean ok = true; } catch (Exception e) { if (!f.getName().startsWith("Binary-")) { // we don't notify here because Binary is special. - log.logMessage(e.getMessage() +" loading "+f); - if (debug) { - e.printStackTrace(); + if (report) { + log.logMessage(e.getMessage() +" loading "+f); + if (debug) { + e.printStackTrace(); + } } } } @@ -475,5 +485,21 @@ public void scanFolders(File dir, List dirs) { } } - + public boolean isDebug() { + return debug; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public boolean isReport() { + return report; + } + + public void setReport(boolean report) { + this.report = report; + } + + } From 02b002b53dab9a6349587f71707dac177c1212ef Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 29 Aug 2023 10:01:08 +0200 Subject: [PATCH 2/3] fix bug with path going missing --- .../java/org/hl7/fhir/igtools/web/PackageRegistryBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/web/PackageRegistryBuilder.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/web/PackageRegistryBuilder.java index cd416d092..8aecb8b4a 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/web/PackageRegistryBuilder.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/web/PackageRegistryBuilder.java @@ -43,10 +43,10 @@ private void update(JsonObject json, String path, PackageList pl) { if (e == null) { e = new JsonObject(); json.forceArray("packages").add(e); - e.add("path", path); } else { e.clear(); } + e.add("path", path); e.add("package-id", pl.pid()); e.add("title", pl.title()); e.add("canonical", pl.canonical()); From 7ba8fc4f762050cc9e85cad80768b67695f8b68b Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 29 Aug 2023 10:01:18 +0200 Subject: [PATCH 3/3] remove comment --- .../src/test/java/tests/AllGuidesTests.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/org.hl7.fhir.publisher.core/src/test/java/tests/AllGuidesTests.java b/org.hl7.fhir.publisher.core/src/test/java/tests/AllGuidesTests.java index 653dbca99..eaa1e4af3 100644 --- a/org.hl7.fhir.publisher.core/src/test/java/tests/AllGuidesTests.java +++ b/org.hl7.fhir.publisher.core/src/test/java/tests/AllGuidesTests.java @@ -22,17 +22,6 @@ public class AllGuidesTests { private static final String VER = "1.0.53"; -// private void test(String path) throws Exception { -// System.out.println("======================================================================================="); -// System.out.println("Publish IG "+path); -// Publisher pub = new Publisher(); -// pub.setConfigFile(path); -// pub.setCacheOption(CacheOption.LEAVE); -// pub.execute(); -// System.out.println("======================================================================================="); -// System.out.println(""); -// } - private void testIg(String id, String path) throws Exception { if (!igsPathExists()) { Assertions.assertTrue(true); @@ -44,7 +33,7 @@ private void testIg(String id, String path) throws Exception { Publisher pub = new Publisher(); pub.setConfigFile(p); pub.setTxServer(FhirSettings.getTxFhirDevelopment()); - pub.setCacheOption(CacheOption.LEAVE); + pub.setCacheOption(CacheOption.CLEAR_ALL); pub.execute(); System.out.println("===== Analysis ======================================================================");