From 62bbadd52e80b43b8519aae1a6cd10ef153ab535 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 24 Jun 2020 14:41:53 -0400 Subject: [PATCH 1/4] removing old pipeline files (#256) --- azure-pipelines.yml | 105 --------------------------------- module-snapshot-publishing.yml | 86 --------------------------- 2 files changed, 191 deletions(-) delete mode 100644 azure-pipelines.yml delete mode 100644 module-snapshot-publishing.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index b181f23f1..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,105 +0,0 @@ -trigger: none - -pr: none - -# Different users have different machine setups, we run the build three times, on ubuntu, osx, and windows -strategy: - matrix: - linux: - imageName: 'ubuntu-latest' - mac: - imageName: "macos-10.15" - windows: - imageName: "windows-2019" - maxParallel: 3 - -pool: - vmImage: $(imageName) - -variables: - currentImage: $(imageName) - codecov: $(CODECOV_TOKEN) - VERSION: - -steps: - # This task pulls the value from the org.hl7.fhir.r5 project pom.xml file. All modules are released as - # the same version, at the same time, as defined in the root level pom.xml. - - task: PowerShell@2 - condition: and(eq(variables.currentImage, 'ubuntu-latest'), eq(variables['Build.SourceBranch'], 'refs/heads/release')) - inputs: - targetType: 'inline' - script: | - [xml]$pomXml = Get-Content -Path .\pom.xml - # version - Write-Host $pomXml.project.version - $version=$pomXml.project.version - Write-Host "##vso[task.setvariable variable=version]$version" - - # Prints out the build version, for debugging purposes - - bash: echo Pulled version from pom.xml => $(version) - condition: and(eq(variables.currentImage, 'ubuntu-latest'), eq(variables['Build.SourceBranch'], 'refs/heads/release')) - - # Azure pipelines cannot pass variables between pipelines, but it can pass files, so we - # pass the build id (ex: 1.1.13-SNAPSHOT) as a string in a file. - # This is used in the release pipeline, so we create it here. - # This is only done for the release branch. - - bash: | - echo $(version) - VERSION=$(version) - echo "$VERSION" > $(System.DefaultWorkingDirectory)/VERSION - condition: and(eq(variables.currentImage, 'ubuntu-latest'), eq(variables['Build.SourceBranch'], 'refs/heads/release')) - - # Copies the VERSION file containing the build id (ex: 1.1.13-SNAPSHOT) to the staging directory - # This is done for release versions only. - - task: CopyFiles@2 - condition: and(eq(variables.currentImage, 'ubuntu-latest'), eq(variables['Build.SourceBranch'], 'refs/heads/release')) - displayName: 'Copy Files to: $(build.artifactstagingdirectory)' - inputs: - SourceFolder: '$(System.Defaultworkingdirectory)' - Contents: "$(System.DefaultWorkingDirectory)/VERSION" - TargetFolder: '$(build.artifactstagingdirectory)' - - # Runs 'mvn clean package' - - task: Maven@3 - inputs: - mavenPomFile: 'pom.xml' - mavenOptions: '-Xmx3072m' - javaHomeOption: 'JDKVersion' - jdkVersionOption: '1.8' - jdkArchitectureOption: 'x64' - publishJUnitResults: true - testResultsFiles: '**/surefire-reports/TEST-*.xml' - goals: 'package' - - # Upload test results to codecov - - script: bash <(curl https://codecov.io/bash) -t $(codecov) - displayName: 'codecov Bash Uploader' - condition: and(eq(variables.currentImage, 'ubuntu-latest'), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - - # Publishes the test results to build artifacts. - - task: PublishCodeCoverageResults@1 - displayName: 'Publish JaCoCo test results ' - inputs: - codeCoverageTool: 'JaCoCo' - summaryFileLocation: '$(System.DefaultWorkingDirectory)/org.hl7.fhir.report/target/site/jacoco-aggregate/jacoco.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/org.hl7.fhir.report/target/site/jacoco-aggregate/' - condition: and(eq(variables.currentImage, 'ubuntu-latest'), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - - # Publishes the built Validator jar to build artifacts. Primarily for testing and debugging builds. - - task: PublishPipelineArtifact@1 - displayName: 'Publish Validator jar' - condition: and(eq(variables.currentImage, 'ubuntu-latest'), eq(variables['Build.SourceBranch'], 'refs/heads/release')) - inputs: - targetPath: "$(System.DefaultWorkingDirectory)/org.hl7.fhir.validation/target/org.hl7.fhir.validation-$(version).jar" - artifactName: Validator - - # Publishes the files we've moved into the staging directory, so they can be accessed by the - # release pipeline. You will notice that we only do this for the ubuntu build, as doing it - # for each of the three release pipelines will cause conflicts. - # This is done for release versions only. - - task: PublishBuildArtifacts@1 - condition: and(eq(variables.currentImage, 'ubuntu-latest'), eq(variables['Build.SourceBranch'], 'refs/heads/release')) - displayName: 'Publish Build Artifacts' - inputs: - PathtoPublish: '$(build.artifactstagingdirectory)' - diff --git a/module-snapshot-publishing.yml b/module-snapshot-publishing.yml deleted file mode 100644 index ebac6c0ac..000000000 --- a/module-snapshot-publishing.yml +++ /dev/null @@ -1,86 +0,0 @@ -# This pipeline produces a SNAPSHOT build for each of the sub modules in -# the core library, and publishes them to ossrh. -trigger: none -pr: none - -pool: - vmImage: "ubuntu-16.04" - -variables: - currentModule: $(module) - -steps: - # Signing, for now, occurs for all builds, SNAPSHOT or release. So we need a valid - # signing key. The next two steps download the public and private keys from the - # secure library files. - - task: DownloadSecureFile@1 - displayName: 'Download public key.' - inputs: - secureFile: public.key - - - task: DownloadSecureFile@1 - displayName: 'Download private key.' - inputs: - secureFile: private.key - - # Import both the private and public keys into gpg for signing. - - bash: | - gpg --import --no-tty --batch --yes $(Agent.TempDirectory)/public.key - gpg --import --no-tty --batch --yes $(Agent.TempDirectory)/private.key - gpg --list-keys --keyid-format LONG - gpg --list-secret-keys --keyid-format LONG - displayName: 'Import signing keys.' - - # For creating the snapshot release with maven, we need to build a fake settings.xml - # for it to read from. This is done for the master branch merges only. - - bash: | - cat >$(System.DefaultWorkingDirectory)/settings.xml < - - - ossrh - $(SONATYPE_USER) - $(SONATYPE_PASS) - - - sonatype-nexus-snapshots - $(SONATYPE_USER) - $(SONATYPE_PASS) - - - sonatype-nexus-staging - $(SONATYPE_USER) - $(SONATYPE_PASS) - - - $(PGP_KEYNAME) - $(PGP_PASSPHRASE) - - - - - release - - true - - - $(PGP_KEYNAME) - - - - - EOL - displayName: 'Create .mvn/settings.xml' - - # Deploy the SNAPSHOT artifact to sonatype nexus. - # This is done for the master branch merges only. - - task: Maven@3 - displayName: 'Deploy $(module) to Sonatype staging' - inputs: - mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml' - goals: deploy - options: '--settings $(System.DefaultWorkingDirectory)/settings.xml' - publishJUnitResults: false From b8405c23b8ba15beed0ccd55516ae5948ab9dfe3 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 24 Jun 2020 16:43:30 -0400 Subject: [PATCH 2/4] Update master-branch-pipeline.yml for Azure Pipelines Adding -Pdeploy profile to maven command for SNAPSHOT upload. --- master-branch-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master-branch-pipeline.yml b/master-branch-pipeline.yml index 8f249acec..5a873f62e 100644 --- a/master-branch-pipeline.yml +++ b/master-branch-pipeline.yml @@ -81,5 +81,5 @@ steps: inputs: mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml' goals: deploy - options: '--settings $(System.DefaultWorkingDirectory)/settings.xml' + options: '--settings $(System.DefaultWorkingDirectory)/settings.xml -Pdeploy' publishJUnitResults: false From 7bbbd7af0aaecc1c140e601c4a9228b41ea1aa73 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Wed, 24 Jun 2020 17:27:14 -0400 Subject: [PATCH 3/4] Gpg profile (#258) * removing old pipeline files * adding gpg profile --- .../org/hl7/fhir/utilities/Utilities.java | 937 +++++++++--------- pom.xml | 46 +- 2 files changed, 485 insertions(+), 498 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java index 48dac02a5..13feb4f24 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java @@ -1,39 +1,39 @@ package org.hl7.fhir.utilities; -/* - Copyright (c) 2011+, HL7, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - */ +/* + Copyright (c) 2011+, HL7, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + */ +import org.apache.commons.io.FileUtils; +import org.hl7.fhir.exceptions.FHIRException; import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -42,7 +42,6 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.channels.FileChannel; import java.nio.file.Paths; @@ -50,316 +49,302 @@ import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import org.apache.commons.io.FileUtils; -import org.hl7.fhir.exceptions.FHIRException; - -import net.sf.saxon.TransformerFactoryImpl; import static org.apache.commons.lang3.StringUtils.isBlank; public class Utilities { -// private static final String TOKEN_REGEX = "^a-z[A-Za-z0-9]*$"; - private static final String OID_REGEX = "[0-2](\\.(0|[1-9][0-9]*))+"; /** - * Returns the plural form of the word in the string. - * - * Examples: - * - *
-     *   inflector.pluralize("post")               #=> "posts"
-     *   inflector.pluralize("octopus")            #=> "octopi"
-     *   inflector.pluralize("sheep")              #=> "sheep"
-     *   inflector.pluralize("words")              #=> "words"
-     *   inflector.pluralize("the blue mailman")   #=> "the blue mailmen"
-     *   inflector.pluralize("CamelOctopus")       #=> "CamelOctopi"
-     * 
- * - * - * - * Note that if the {@link Object#toString()} is called on the supplied object, so this method works for non-strings, too. - * - * - * @param word the word that is to be pluralized. - * @return the pluralized form of the word, or the word itself if it could not be pluralized - * @see #singularize(Object) - */ - public static String pluralizeMe( String word ) { + * Returns the plural form of the word in the string. + *

+ * Examples: + * + *

+   *   inflector.pluralize("post")               #=> "posts"
+   *   inflector.pluralize("octopus")            #=> "octopi"
+   *   inflector.pluralize("sheep")              #=> "sheep"
+   *   inflector.pluralize("words")              #=> "words"
+   *   inflector.pluralize("the blue mailman")   #=> "the blue mailmen"
+   *   inflector.pluralize("CamelOctopus")       #=> "CamelOctopi"
+   * 
+ *

+ *

+ *

+ * Note that if the {@link Object#toString()} is called on the supplied object, so this method works for non-strings, too. + * + * @param word the word that is to be pluralized. + * @return the pluralized form of the word, or the word itself if it could not be pluralized + * @see #singularize(Object) + */ + public static String pluralizeMe(String word) { Inflector inf = new Inflector(); return inf.pluralize(word); } - + public static String pluralize(String word, int count) { if (count == 1) return word; Inflector inf = new Inflector(); return inf.pluralize(word); } - - - public static boolean isInteger(String string) { - if (isBlank(string)) { - return false; - } - String value = string.startsWith("-") ? string.substring(1) : string; - for (char next : value.toCharArray()) { - if (!Character.isDigit(next)) { - return false; - } - } - // check bounds -2,147,483,648..2,147,483,647 - if (value.length() > 10) - return false; - if (string.startsWith("-")) { - if (value.length() == 10 && string.compareTo("2147483648") > 0) - return false; - } else { - if (value.length() == 10 && string.compareTo("2147483647") > 0) - return false; - } - return true; - } - - public static boolean isLong(String string) { - if (isBlank(string)) { - return false; - } - String value = string.startsWith("-") ? string.substring(1) : string; - for (char next : value.toCharArray()) { - if (!Character.isDigit(next)) { - return false; - } - } - // check bounds -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 - if (value.length() > 20) - return false; - if (string.startsWith("-")) { - if (value.length() == 20 && string.compareTo("9223372036854775808") > 0) - return false; - } else { - if (value.length() == 20 && string.compareTo("9223372036854775807") > 0) - return false; - } - return true; - } - - public static boolean isHex(String string) { - try { - int i = Integer.parseInt(string, 16); - return i != i+1; - } catch (Exception e) { - return false; - } - } - - public enum DecimalStatus { - BLANK, SYNTAX, RANGE, OK - } - - public static boolean isDecimal(String value, boolean allowExponent, boolean allowLeadingZero) { - DecimalStatus ds = checkDecimal(value, allowExponent, true); - return ds == DecimalStatus.OK || ds == DecimalStatus.RANGE; - } - - public static boolean isDecimal(String value, boolean allowExponent) { - DecimalStatus ds = checkDecimal(value, allowExponent, false); - return ds == DecimalStatus.OK || ds == DecimalStatus.RANGE; - } - - public static DecimalStatus checkDecimal(String value, boolean allowExponent, boolean allowLeadingZero) { - if (isBlank(value)) { - return DecimalStatus.BLANK; - } - - // check for leading zeros - if (!allowLeadingZero) { - if (value.startsWith("0") && !"0".equals(value) && !value.startsWith("0.")) - return DecimalStatus.SYNTAX; - if (value.startsWith("-0") && !"-0".equals(value) && !value.startsWith("-0.")) - return DecimalStatus.SYNTAX; - if (value.startsWith("+0") && !"+0".equals(value) && !value.startsWith("+0.")) - return DecimalStatus.SYNTAX; - } - // check for trailing dot - if (value.endsWith(".")) { - return DecimalStatus.SYNTAX; - } - - boolean havePeriod = false; - boolean haveExponent = false; - boolean haveSign = false; - boolean haveDigits = false; - int preDecLength = 0; - int postDecLength = 0; - int exponentLength = 0; - int length = 0; - for (char next : value.toCharArray()) { - if (next == '.') { - if (!haveDigits || havePeriod || haveExponent) - return DecimalStatus.SYNTAX; - havePeriod = true; - preDecLength = length; - length = 0; - } else if (next == '-' || next == '+' ) { - if (haveDigits || haveSign) - return DecimalStatus.SYNTAX; - haveSign = true; - } else if (next == 'e' || next == 'E' ) { - if (!haveDigits || haveExponent || !allowExponent) - return DecimalStatus.SYNTAX; - haveExponent = true; - haveSign = false; - haveDigits = false; - if (havePeriod) - postDecLength = length; - else - preDecLength = length; - length = 0; - } else if (!Character.isDigit(next)) { - return DecimalStatus.SYNTAX; - } else { - haveDigits = true; - length++; - } - } - if (haveExponent && !haveDigits) - return DecimalStatus.SYNTAX; - if (haveExponent) - exponentLength = length; - else if (havePeriod) - postDecLength = length; - else - preDecLength = length; - - // now, bounds checking - these are arbitrary - if (exponentLength > 4) - return DecimalStatus.RANGE; - if (preDecLength + postDecLength > 18) - return DecimalStatus.RANGE; - - return DecimalStatus.OK; + + public static boolean isInteger(String string) { + if (isBlank(string)) { + return false; } - - public static String camelCase(String value) { - return new Inflector().camelCase(value.trim().replace(" ", "_"), false); - } - - public static String escapeXml(String doco) { - if (doco == null) - return ""; - - StringBuilder b = new StringBuilder(); - for (char c : doco.toCharArray()) { - if (c == '<') - b.append("<"); - else if (c == '>') - b.append(">"); - else if (c == '&') - b.append("&"); + String value = string.startsWith("-") ? string.substring(1) : string; + for (char next : value.toCharArray()) { + if (!Character.isDigit(next)) { + return false; + } + } + // check bounds -2,147,483,648..2,147,483,647 + if (value.length() > 10) + return false; + if (string.startsWith("-")) { + if (value.length() == 10 && string.compareTo("2147483648") > 0) + return false; + } else { + if (value.length() == 10 && string.compareTo("2147483647") > 0) + return false; + } + return true; + } + + public static boolean isLong(String string) { + if (isBlank(string)) { + return false; + } + String value = string.startsWith("-") ? string.substring(1) : string; + for (char next : value.toCharArray()) { + if (!Character.isDigit(next)) { + return false; + } + } + // check bounds -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 + if (value.length() > 20) + return false; + if (string.startsWith("-")) { + if (value.length() == 20 && string.compareTo("9223372036854775808") > 0) + return false; + } else { + if (value.length() == 20 && string.compareTo("9223372036854775807") > 0) + return false; + } + return true; + } + + public static boolean isHex(String string) { + try { + int i = Integer.parseInt(string, 16); + return i != i + 1; + } catch (Exception e) { + return false; + } + } + + public enum DecimalStatus { + BLANK, SYNTAX, RANGE, OK + } + + public static boolean isDecimal(String value, boolean allowExponent, boolean allowLeadingZero) { + DecimalStatus ds = checkDecimal(value, allowExponent, true); + return ds == DecimalStatus.OK || ds == DecimalStatus.RANGE; + } + + public static boolean isDecimal(String value, boolean allowExponent) { + DecimalStatus ds = checkDecimal(value, allowExponent, false); + return ds == DecimalStatus.OK || ds == DecimalStatus.RANGE; + } + + public static DecimalStatus checkDecimal(String value, boolean allowExponent, boolean allowLeadingZero) { + if (isBlank(value)) { + return DecimalStatus.BLANK; + } + + // check for leading zeros + if (!allowLeadingZero) { + if (value.startsWith("0") && !"0".equals(value) && !value.startsWith("0.")) + return DecimalStatus.SYNTAX; + if (value.startsWith("-0") && !"-0".equals(value) && !value.startsWith("-0.")) + return DecimalStatus.SYNTAX; + if (value.startsWith("+0") && !"+0".equals(value) && !value.startsWith("+0.")) + return DecimalStatus.SYNTAX; + } + + // check for trailing dot + if (value.endsWith(".")) { + return DecimalStatus.SYNTAX; + } + + boolean havePeriod = false; + boolean haveExponent = false; + boolean haveSign = false; + boolean haveDigits = false; + int preDecLength = 0; + int postDecLength = 0; + int exponentLength = 0; + int length = 0; + for (char next : value.toCharArray()) { + if (next == '.') { + if (!haveDigits || havePeriod || haveExponent) + return DecimalStatus.SYNTAX; + havePeriod = true; + preDecLength = length; + length = 0; + } else if (next == '-' || next == '+') { + if (haveDigits || haveSign) + return DecimalStatus.SYNTAX; + haveSign = true; + } else if (next == 'e' || next == 'E') { + if (!haveDigits || haveExponent || !allowExponent) + return DecimalStatus.SYNTAX; + haveExponent = true; + haveSign = false; + haveDigits = false; + if (havePeriod) + postDecLength = length; + else + preDecLength = length; + length = 0; + } else if (!Character.isDigit(next)) { + return DecimalStatus.SYNTAX; + } else { + haveDigits = true; + length++; + } + } + if (haveExponent && !haveDigits) + return DecimalStatus.SYNTAX; + if (haveExponent) + exponentLength = length; + else if (havePeriod) + postDecLength = length; + else + preDecLength = length; + + // now, bounds checking - these are arbitrary + if (exponentLength > 4) + return DecimalStatus.RANGE; + if (preDecLength + postDecLength > 18) + return DecimalStatus.RANGE; + + return DecimalStatus.OK; + } + + public static String camelCase(String value) { + return new Inflector().camelCase(value.trim().replace(" ", "_"), false); + } + + public static String escapeXml(String doco) { + if (doco == null) + return ""; + + StringBuilder b = new StringBuilder(); + for (char c : doco.toCharArray()) { + if (c == '<') + b.append("<"); + else if (c == '>') + b.append(">"); + else if (c == '&') + b.append("&"); else if (c == '"') b.append("""); - else - b.append(c); - } - return b.toString(); - } + else + b.append(c); + } + return b.toString(); + } - public static String titleize(String s) { - StringBuilder b = new StringBuilder(); - boolean up = true; - for (char c : s.toCharArray()) { - if (up) - b.append(Character.toUpperCase(c)); - else - b.append(c); - up = c == ' '; - } - return b.toString(); - } - - public static String capitalize(String s) - { - if( s == null ) return null; - if( s.length() == 0 ) return s; - if( s.length() == 1 ) return s.toUpperCase(); - - return s.substring(0, 1).toUpperCase() + s.substring(1); - } - - public static void copyDirectory(String sourceFolder, String destFolder, FileNotifier notifier) throws IOException, FHIRException { + public static String titleize(String s) { + StringBuilder b = new StringBuilder(); + boolean up = true; + for (char c : s.toCharArray()) { + if (up) + b.append(Character.toUpperCase(c)); + else + b.append(c); + up = c == ' '; + } + return b.toString(); + } + + public static String capitalize(String s) { + if (s == null) return null; + if (s.length() == 0) return s; + if (s.length() == 1) return s.toUpperCase(); + + return s.substring(0, 1).toUpperCase() + s.substring(1); + } + + public static void copyDirectory(String sourceFolder, String destFolder, FileNotifier notifier) throws IOException, FHIRException { CSFile src = new CSFile(sourceFolder); if (!src.exists()) - throw new FHIRException("Folder " +sourceFolder+" not found"); + throw new FHIRException("Folder " + sourceFolder + " not found"); createDirectory(destFolder); - - String[] files = src.list(); - for (String f : files) { - if (new CSFile(sourceFolder+File.separator+f).isDirectory()) { - if (!f.startsWith(".")) // ignore .git files... - copyDirectory(sourceFolder+File.separator+f, destFolder+File.separator+f, notifier); - } else { - if (notifier != null) - notifier.copyFile(sourceFolder+File.separator+f, destFolder+File.separator+f); - copyFile(new CSFile(sourceFolder+File.separator+f), new CSFile(destFolder+File.separator+f)); - } - } + + String[] files = src.list(); + for (String f : files) { + if (new CSFile(sourceFolder + File.separator + f).isDirectory()) { + if (!f.startsWith(".")) // ignore .git files... + copyDirectory(sourceFolder + File.separator + f, destFolder + File.separator + f, notifier); + } else { + if (notifier != null) + notifier.copyFile(sourceFolder + File.separator + f, destFolder + File.separator + f); + copyFile(new CSFile(sourceFolder + File.separator + f), new CSFile(destFolder + File.separator + f)); + } + } } - + public static void copyFile(String source, String dest) throws IOException { copyFile(new File(source), new File(dest)); } - public static void copyFile(File sourceFile, File destFile) throws IOException { - if(!destFile.exists()) { - if (!new CSFile(destFile.getParent()).exists()) { - createDirectory(destFile.getParent()); - } - destFile.createNewFile(); - } + public static void copyFile(File sourceFile, File destFile) throws IOException { + if (!destFile.exists()) { + if (!new CSFile(destFile.getParent()).exists()) { + createDirectory(destFile.getParent()); + } + destFile.createNewFile(); + } - FileChannel source = null; - FileChannel destination = null; + FileChannel source = null; + FileChannel destination = null; - try { - source = new FileInputStream(sourceFile).getChannel(); - destination = new FileOutputStream(destFile).getChannel(); - destination.transferFrom(source, 0, source.size()); - } - finally { - if(source != null) { - source.close(); - } - if(destination != null) { - destination.close(); - } - } - } + try { + source = new FileInputStream(sourceFile).getChannel(); + destination = new FileOutputStream(destFile).getChannel(); + destination.transferFrom(source, 0, source.size()); + } finally { + if (source != null) { + source.close(); + } + if (destination != null) { + destination.close(); + } + } + } public static boolean checkFolder(String dir, List errors) - throws IOException - { - if (!new CSFile(dir).exists()) { - errors.add("Unable to find directory "+dir); + throws IOException { + if (!new CSFile(dir).exists()) { + errors.add("Unable to find directory " + dir); return false; } else { return true; } } - public static boolean checkFile(String purpose, String dir, String file, List errors) - throws IOException - { - if (!new CSFile(dir+file).exists()) { + public static boolean checkFile(String purpose, String dir, String file, List errors) + throws IOException { + if (!new CSFile(dir + file).exists()) { if (errors != null) - errors.add("Unable to find "+purpose+" file "+file+" in "+dir); + errors.add("Unable to find " + purpose + " file " + file + " in " + dir); return false; } else { return true; @@ -401,8 +386,8 @@ public class Utilities { if (files != null) { for (String f : files) { if (!existsInList(f, exemptions)) { - File fh = new CSFile(folder+File.separatorChar+f); - if (fh.isDirectory()) + File fh = new CSFile(folder + File.separatorChar + f); + if (fh.isDirectory()) clearDirectory(fh.getAbsolutePath()); fh.delete(); } @@ -412,7 +397,7 @@ public class Utilities { } } - public static File createDirectory(String path) throws IOException{ + public static File createDirectory(String path) throws IOException { new CSFile(path).mkdirs(); return new File(path); } @@ -421,15 +406,14 @@ public class Utilities { if (name.lastIndexOf('.') > -1) return name.substring(0, name.lastIndexOf('.')) + ext; else - return name+ext; + return name + ext; } - - public static String cleanupTextString( String contents ) - { - if( contents == null || contents.trim().equals("") ) - return null; - else - return contents.trim(); + + public static String cleanupTextString(String contents) { + if (contents == null || contents.trim().equals("")) + return null; + else + return contents.trim(); } @@ -438,37 +422,33 @@ public class Utilities { } - - - public static void bytesToFile(byte[] content, String filename) throws IOException { + public static void bytesToFile(byte[] content, String filename) throws IOException { FileOutputStream out = new FileOutputStream(filename); out.write(content); out.close(); - + } - public static String appendSlash(String definitions) { - return definitions.endsWith(File.separator) ? definitions : definitions+File.separator; - } + return definitions.endsWith(File.separator) ? definitions : definitions + File.separator; + } public static String appendForwardSlash(String definitions) { - return definitions.endsWith("/") ? definitions : definitions+"/"; - } + return definitions.endsWith("/") ? definitions : definitions + "/"; + } public static String fileTitle(String file) { if (file == null) return null; String s = new File(file).getName(); - return s.indexOf(".") == -1? s : s.substring(0, s.indexOf(".")); + return s.indexOf(".") == -1 ? s : s.substring(0, s.indexOf(".")); } - public static String systemEol() - { - return System.getProperty("line.separator"); + public static String systemEol() { + return System.getProperty("line.separator"); } public static String normaliseEolns(String value) { @@ -476,10 +456,10 @@ public class Utilities { } - public static String unescapeXml(String xml) throws FHIRException { + public static String unescapeXml(String xml) throws FHIRException { if (xml == null) return null; - + StringBuilder b = new StringBuilder(); int i = 0; while (i < xml.length()) { @@ -490,29 +470,29 @@ public class Utilities { e.append(xml.charAt(i)); i++; } - if (e.toString().equals("lt")) + if (e.toString().equals("lt")) b.append("<"); - else if (e.toString().equals("gt")) + else if (e.toString().equals("gt")) b.append(">"); - else if (e.toString().equals("amp")) + else if (e.toString().equals("amp")) b.append("&"); - else if (e.toString().equals("quot")) + else if (e.toString().equals("quot")) b.append("\""); else if (e.toString().equals("mu")) - b.append((char)956); + b.append((char) 956); else - throw new FHIRException("unknown XML entity \""+e.toString()+"\""); - } else + throw new FHIRException("unknown XML entity \"" + e.toString() + "\""); + } else b.append(xml.charAt(i)); i++; - } + } return b.toString(); } - public static String unescapeJson(String json) throws FHIRException { + public static String unescapeJson(String json) throws FHIRException { if (json == null) return null; - + StringBuilder b = new StringBuilder(); int i = 0; while (i < json.length()) { @@ -520,49 +500,49 @@ public class Utilities { i++; char ch = json.charAt(i); switch (ch) { - case '"': - b.append('b'); - break; - case '\\': - b.append('\\'); - break; - case '/': - b.append('/'); - break; - case 'b': - b.append('\b'); - break; - case 'f': - b.append('\f'); - break; - case 'n': - b.append('\n'); - break; - case 'r': - b.append('\r'); - break; - case 't': - b.append('\t'); - break; - case 'u': - String hex = json.substring(i+1, i+5); - b.append((char) Integer.parseInt(hex, 16)); - break; - default: - throw new FHIRException("Unknown JSON escape \\"+ch); + case '"': + b.append('b'); + break; + case '\\': + b.append('\\'); + break; + case '/': + b.append('/'); + break; + case 'b': + b.append('\b'); + break; + case 'f': + b.append('\f'); + break; + case 'n': + b.append('\n'); + break; + case 'r': + b.append('\r'); + break; + case 't': + b.append('\t'); + break; + case 'u': + String hex = json.substring(i + 1, i + 5); + b.append((char) Integer.parseInt(hex, 16)); + break; + default: + throw new FHIRException("Unknown JSON escape \\" + ch); } - } else + } else b.append(json.charAt(i)); i++; - } + } return b.toString(); } public static boolean isPlural(String word) { word = word.toLowerCase(); - if ("restricts".equals(word) || "contains".equals(word) || "data".equals(word) || "specimen".equals(word) || "replaces".equals(word) || "addresses".equals(word) - || "supplementalData".equals(word) || "instantiates".equals(word) || "imports".equals(word)) + if ("restricts".equals(word) || "contains".equals(word) || "data".equals(word) || "specimen".equals(word) || "replaces".equals(word) || "addresses".equals(word) + || "supplementalData".equals(word) || "instantiates".equals(word) || "imports".equals(word)) return false; Inflector inf = new Inflector(); return !inf.singularize(word).equals(word); @@ -591,7 +571,7 @@ public class Utilities { StringBuilder s = new StringBuilder(); boolean d = false; boolean first = true; - for(String arg: args) { + for (String arg : args) { if (first && arg == null) continue; first = false; @@ -609,7 +589,7 @@ public class Utilities { } } else if ("[user]".equals(a)) { a = System.getProperty("user.home"); - } else if (a.startsWith("[") && a.endsWith("]")){ + } else if (a.startsWith("[") && a.endsWith("]")) { String ev = System.getenv(a.replace("[", "").replace("]", "")); if (ev != null) { a = ev; @@ -622,23 +602,23 @@ public class Utilities { a = a.replace("/", File.separator); if (s.length() > 0 && a.startsWith(File.separator)) a = a.substring(File.separator.length()); - - while (a.startsWith(".."+File.separator)) { + + while (a.startsWith(".." + File.separator)) { if (s.length() == 0) { s = new StringBuilder(Paths.get(".").toAbsolutePath().normalize().toString()); } else { - String p = s.toString().substring(0, s.length()-1); + String p = s.toString().substring(0, s.length() - 1); if (!p.contains(File.separator)) { s = new StringBuilder(); } else { - s = new StringBuilder(p.substring(0, p.lastIndexOf(File.separator))+File.separator); + s = new StringBuilder(p.substring(0, p.lastIndexOf(File.separator)) + File.separator); } } a = a.substring(3); } if ("..".equals(a)) { - int i = s.substring(0, s.length()-1).lastIndexOf(File.separator); - s = new StringBuilder(s.substring(0, i+1)); + int i = s.substring(0, s.length() - 1).lastIndexOf(File.separator); + s = new StringBuilder(s.substring(0, i + 1)); } else s.append(a); } @@ -656,7 +636,7 @@ public class Utilities { public static String pathURL(String... args) { StringBuilder s = new StringBuilder(); boolean d = false; - for(String arg: args) { + for (String arg : args) { if (!d) d = !noString(arg); else if (!s.toString().endsWith("/") && !arg.startsWith("/")) @@ -667,7 +647,6 @@ public class Utilities { } - // public static void checkCase(String filename) { // File f = new CSFile(filename); // if (!f.getName().equals(filename)) @@ -684,7 +663,7 @@ public class Utilities { if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_') s.append(c); else if (c != ' ') - s.append("."+Integer.toString(c)); + s.append("." + Integer.toString(c)); } return s.toString(); } @@ -695,7 +674,7 @@ public class Utilities { return false; boolean result = isAlphabetic(tail.charAt(0)); for (int i = 1; i < tail.length(); i++) { - result = result && (isAlphabetic(tail.charAt(i)) || isDigit(tail.charAt(i)) || (tail.charAt(i) == '_') || (tail.charAt(i) == '[') || (tail.charAt(i) == ']')); + result = result && (isAlphabetic(tail.charAt(i)) || isDigit(tail.charAt(i)) || (tail.charAt(i) == '_') || (tail.charAt(i) == '[') || (tail.charAt(i) == ']')); } return result; } @@ -722,7 +701,7 @@ public class Utilities { s = s.trim(); if (s.endsWith(".") || s.endsWith("?")) return s; - return s+"."; + return s + "."; } @@ -730,20 +709,20 @@ public class Utilities { if (Utilities.noString(s)) return s; if (s.endsWith(".")) - return s.substring(0, s.length()-1); + return s.substring(0, s.length() - 1); return s; } - public static String stripBOM(String string) { - return string.replace("\uFEFF", ""); + public static String stripBOM(String string) { + return string.replace("\uFEFF", ""); } public static String oidTail(String id) { if (id == null || !id.contains(".")) return id; - return id.substring(id.lastIndexOf(".")+1); + return id.substring(id.lastIndexOf(".") + 1); } @@ -756,7 +735,7 @@ public class Utilities { public static String escapeJava(String doco) { if (doco == null) return ""; - + StringBuilder b = new StringBuilder(); for (char c : doco.toCharArray()) { if (c == '\r') @@ -767,9 +746,9 @@ public class Utilities { b.append("\\\""); else if (c == '\\') b.append("\\\\"); - else + else b.append(c); - } + } return b.toString(); } @@ -785,32 +764,31 @@ public class Utilities { b.append(Character.toLowerCase(name.charAt(i))); } parts.add(b.toString()); - return parts.toArray(new String[] {} ); + return parts.toArray(new String[]{}); } public static String encodeUri(String v) { return v.replace(" ", "%20").replace("?", "%3F").replace("=", "%3D"); } - - public static String normalize(String s) { - if (noString(s)) - return null; - StringBuilder b = new StringBuilder(); - boolean isWhitespace = false; - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - if (!Character.isWhitespace(c)) { - b.append(Character.toLowerCase(c)); - isWhitespace = false; - } else if (!isWhitespace) { - b.append(' '); - isWhitespace = true; - } - } - return b.toString().trim(); + public static String normalize(String s) { + if (noString(s)) + return null; + StringBuilder b = new StringBuilder(); + boolean isWhitespace = false; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (!Character.isWhitespace(c)) { + b.append(Character.toLowerCase(c)); + isWhitespace = false; + } else if (!isWhitespace) { + b.append(' '); + isWhitespace = true; + } + } + return b.toString().trim(); } public static String normalizeSameCase(String s) { @@ -820,29 +798,29 @@ public class Utilities { boolean isWhitespace = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (!Character.isWhitespace(c)) { + if (!Character.isWhitespace(c)) { b.append(c); isWhitespace = false; } else if (!isWhitespace) { b.append(' '); - isWhitespace = true; - } + isWhitespace = true; + } } return b.toString().trim(); } public static void copyFileToDirectory(File source, File destDir) throws IOException { - copyFile(source, new File(path(destDir.getAbsolutePath(), source.getName()))); + copyFile(source, new File(path(destDir.getAbsolutePath(), source.getName()))); } - public static boolean isWhitespace(String s) { - boolean ok = true; - for (int i = 0; i < s.length(); i++) - ok = ok && Character.isWhitespace(s.charAt(i)); - return ok; - + public static boolean isWhitespace(String s) { + boolean ok = true; + for (int i = 0; i < s.length(); i++) + ok = ok && Character.isWhitespace(s.charAt(i)); + return ok; + } @@ -858,7 +836,7 @@ public class Utilities { public static boolean charInSet(char value, char... array) { for (int i : array) if (value == i) - return true; + return true; return false; } @@ -872,30 +850,30 @@ public class Utilities { return false; for (String s : array) if (value.equals(s)) - return true; + return true; return false; } - + public static boolean existsInList(String value, String... array) { if (value == null) return false; for (String s : array) if (value.equals(s)) - return true; + return true; return false; } public static boolean existsInList(int value, int... array) { for (int i : array) if (value == i) - return true; + return true; return false; } public static boolean existsInListNC(String value, String... array) { for (String s : array) if (value.equalsIgnoreCase(s)) - return true; + return true; return false; } @@ -920,15 +898,15 @@ public class Utilities { } public static File createTempFile(String prefix, String suffix) throws IOException { - // this allows use to eaily identify all our dtemp files and delete them, since delete on Exit doesn't really work. - File file = File.createTempFile("ohfu-"+prefix, suffix); + // this allows use to eaily identify all our dtemp files and delete them, since delete on Exit doesn't really work. + File file = File.createTempFile("ohfu-" + prefix, suffix); file.deleteOnExit(); return file; } - public static boolean isAsciiChar(char ch) { - return ch >= ' ' && ch <= '~'; + public static boolean isAsciiChar(char ch) { + return ch >= ' ' && ch <= '~'; } @@ -937,19 +915,19 @@ public class Utilities { } public static String makeUuidUrn() { - return "urn:uuid:"+UUID.randomUUID().toString().toLowerCase(); + return "urn:uuid:" + UUID.randomUUID().toString().toLowerCase(); } public static boolean isURL(String s) { boolean ok = s.matches("^http(s{0,1})://[a-zA-Z0-9_/\\-\\.]+\\.([A-Za-z/]{2,5})[a-zA-Z0-9_/\\&\\?\\=\\-\\.\\~\\%]*"); return ok; - } + } public static String escapeJson(String value) { if (value == null) return ""; - + StringBuilder b = new StringBuilder(); for (char c : value.toCharArray()) { if (c == '\r') @@ -963,10 +941,10 @@ public class Utilities { else if (c == '\\') b.append("\\\\"); else if (((int) c) < 32) - b.append("\\u"+Utilities.padLeft(String.valueOf((int) c), '0', 4)); + b.append("\\u" + Utilities.padLeft(String.valueOf((int) c), '0', 4)); else b.append(c); - } + } return b.toString(); } @@ -977,9 +955,9 @@ public class Utilities { if (Character.isLetter(c)) { if (lastBreak) b.append(Character.toUpperCase(c)); - else { + else { if (Character.isUpperCase(c)) - b.append(" "); + b.append(" "); b.append(c); } lastBreak = false; @@ -990,31 +968,29 @@ public class Utilities { } if (b.length() == 0) return code; - else + else return b.toString(); } public static String uncapitalize(String s) { - if( s == null ) return null; - if( s.length() == 0 ) return s; - if( s.length() == 1 ) return s.toLowerCase(); - + if (s == null) return null; + if (s.length() == 0) return s; + if (s.length() == 1) return s.toLowerCase(); + return s.substring(0, 1).toLowerCase() + s.substring(1); } public static int charCount(String s, char c) { - int res = 0; - for (char ch : s.toCharArray()) - if (ch == c) - res++; - return res; + int res = 0; + for (char ch : s.toCharArray()) + if (ch == c) + res++; + return res; } - - public static boolean isOid(String cc) { return cc.matches(OID_REGEX) && cc.lastIndexOf('.') >= 5; } @@ -1033,13 +1009,13 @@ public class Utilities { File src = new File(folder); String[] files = src.list(); for (String f : files) { - if (new File(folder+File.separator+f).isDirectory()) { - deleteAllFiles(folder+File.separator+f, type); + if (new File(folder + File.separator + f).isDirectory()) { + deleteAllFiles(folder + File.separator + f, type); } else if (f.endsWith(type)) { - new File(folder+File.separator+f).delete(); + new File(folder + File.separator + f).delete(); } } - + } public static boolean compareIgnoreWhitespace(File f1, File f2) throws IOException { @@ -1062,7 +1038,7 @@ public class Utilities { while (isWhitespace(foundByte)) foundByte = in2.read(); } - if (expectedByte != foundByte) + if (expectedByte != foundByte) return false; expectedByte = in1.read(); } @@ -1074,16 +1050,18 @@ public class Utilities { if (in1 != null) { try { in1.close(); - } catch (IOException e) {} + } catch (IOException e) { + } } if (in2 != null) { try { in2.close(); - } catch (IOException e) {} + } catch (IOException e) { + } } } } - + private static boolean isWhitespace(int b) { return b == 9 || b == 10 || b == 13 || b == 32; } @@ -1095,7 +1073,7 @@ public class Utilities { public static boolean isAbsoluteUrl(String ref) { - return ref != null && (ref.startsWith("http:") || ref.startsWith("https:") || ref.startsWith("urn:uuid:") || ref.startsWith("urn:oid:")) ; + return ref != null && (ref.startsWith("http:") || ref.startsWith("https:") || ref.startsWith("urn:uuid:") || ref.startsWith("urn:oid:")); } @@ -1120,7 +1098,7 @@ public class Utilities { public static String getFileExtension(String fn) { - return fn.contains(".") ? fn.substring(fn.lastIndexOf(".")+1) : ""; + return fn.contains(".") ? fn.substring(fn.lastIndexOf(".") + 1) : ""; } @@ -1132,9 +1110,9 @@ public class Utilities { if (!first) b.append(" "); b.append(Character.toLowerCase(c)); - } else + } else b.append(c); - first = false; + first = false; } return b.toString(); } @@ -1162,7 +1140,7 @@ public class Utilities { if (i == 0) break; list.add(line.substring(0, i)); - line = line.substring(i+1); + line = line.substring(i + 1); } list.add(line); StringBuilder b = new StringBuilder(); @@ -1171,7 +1149,7 @@ public class Utilities { if (first) first = false; else - b.append("\r\n"+padLeft("", ' ', indent)); + b.append("\r\n" + padLeft("", ' ', indent)); b.append(s); } return b.toString(); @@ -1180,9 +1158,9 @@ public class Utilities { public static int countFilesInDirectory(String dirName) { File dir = new File(dirName); - if (dir.exists() == false) { + if (dir.exists() == false) { return 0; - } + } int i = 0; for (File f : dir.listFiles()) if (!f.isDirectory()) @@ -1212,24 +1190,24 @@ public class Utilities { public static void visitFiles(String folder, String extension, FileVisitor visitor) throws FileNotFoundException, IOException { visitFiles(new File(folder), extension, visitor); } - + public static void visitFiles(File folder, String extension, FileVisitor visitor) throws FileNotFoundException, IOException { for (File file : folder.listFiles()) { - if (file.isDirectory()) + if (file.isDirectory()) visitFiles(file, extension, visitor); - else if (extension == null || file.getName().endsWith(extension)) + else if (extension == null || file.getName().endsWith(extension)) visitor.visitFile(file); - } + } } public static String extractBaseUrl(String url) { - if (url == null) - return null; - else if (url.contains("/")) - return url.substring(0, url.lastIndexOf("/")); + if (url == null) + return null; + else if (url.contains("/")) + return url.substring(0, url.lastIndexOf("/")); else return url; - } + } public static String listCanonicalUrls(Set keys) { return keys.toString(); @@ -1253,12 +1231,12 @@ public class Utilities { for (String s : target) if (!source.contains(s)) extra.add(s); - + } /** * Only handles simple FHIRPath expressions of the type produced by the validator - * + * * @param path * @return */ @@ -1269,16 +1247,16 @@ public class Utilities { while (i < p.length) { String s = p[i]; if (s.contains("[")) { - String si = s.substring(s.indexOf("[")+1, s.length()-1); + String si = s.substring(s.indexOf("[") + 1, s.length() - 1); if (!Utilities.isInteger(si)) - throw new FHIRException("The FHIRPath expression '"+path+"' is not valid"); - s = s.substring(0, s.indexOf("["))+"["+Integer.toString(Integer.parseInt(si)+1)+"]"; + throw new FHIRException("The FHIRPath expression '" + path + "' is not valid"); + s = s.substring(0, s.indexOf("[")) + "[" + Integer.toString(Integer.parseInt(si) + 1) + "]"; } - if (i < p.length - 1 && p[i+1].startsWith(".ofType(")) { + if (i < p.length - 1 && p[i + 1].startsWith(".ofType(")) { i++; - s = s + capitalize(p[i].substring(8, p.length-1)); + s = s + capitalize(p[i].substring(8, p.length - 1)); } - b.append(s); + b.append(s); i++; } return b.toString(); @@ -1291,7 +1269,7 @@ public class Utilities { return String.format("%s hours", d.toHours()); } else if (d.toMinutes() > 2) { return String.format("%s mins", d.toMinutes()); - } else { + } else { return String.format("%s ms", d.toMillis()); } } @@ -1309,5 +1287,4 @@ public class Utilities { } - } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 618183f6a..f483679d6 100644 --- a/pom.xml +++ b/pom.xml @@ -311,24 +311,6 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - ${gpg.keyname} - ${gpg.keyname} - - - - org.sonatype.plugins nexus-staging-maven-plugin @@ -346,4 +328,32 @@ + + + + deploy + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + ${gpg.keyname} + ${gpg.keyname} + + + + + + + + From 9c65e3b50d01450149ce850b8a5cf8165212dab2 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Thu, 25 Jun 2020 16:03:52 -0400 Subject: [PATCH 4/4] Update README.md --- README.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5df86c226..ce80b4bc1 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,23 @@ # HAPI FHIR - HL7 FHIR Core Artifacts -### CI/CD -| master Branch CI | SNAPSHOT Publisher | -| :---: | :---: | -| [![Build Status][Badge-BuildPipeline]][Link-BuildPipeline] | [![Build Status][Badge-SnapshotPipeline]][Link-SnapshotPipeline] | +| CI Status (master) | +| :---: | +| [![Build Status][Badge-BuildPipeline]][Link-BuildPipeline] | -All intergration and delivery done on Azure pipelines. Every successful merge to master branch will result in a new SNAPSHOT build being published to Sonatype. Azure project can be viewed [here][Link-AzureProject]. +### CI/CD + +All intergration and delivery done on Azure pipelines. Azure project can be viewed [here][Link-AzureProject]. ### Current Versions -| Project | Latest SNAPSHOT | Current Release | +| Project | Current Release | Latest SNAPSHOT | | :---: | :---: | :---: | -| org.hl7.fhir.validation.cli | [![Snapshot Artifact][Badge-cliSonatypeSnapshot]][Link-cliSonatypeSnapshot] | [![Release Artifacts][Badge-cliSonatypeRelease]][Link-cliSonatypeRelease] | -| org.hl7.fhir.r4 | [![Snapshot Artifact][Badge-r4SonatypeSnapshot]][Link-r4SonatypeSnapshot] | [![Release Artifacts][Badge-r4SonatypeRelease]][Link-r4SonatypeRelease] | -| org.hl7.fhir.r5 | [![Snapshot Artifact][Badge-r5SonatypeSnapshot]][Link-r5SonatypeSnapshot] | [![Release Artifacts][Badge-r5SonatypeRelease]][Link-r5SonatypeRelease] | +| org.hl7.fhir.validation.cli | [![Release Artifacts][Badge-r4SonatypeRelease]][Link-cliSonatypeRelease] | [![Snapshot Artifact][Badge-cliSonatypeSnapshot]][Link-cliSonatypeSnapshot] | +| org.hl7.fhir.validation | [![Release Artifacts][Badge-validationSonatypeRelease]][Link-validationSonatypeRelease] | [![Snapshot Artifact][Badge-validationSonatypeSnapshot]][Link-validationSonatypeSnapshot] | +| org.hl7.fhir.dstu2 | [![Release Artifacts][Badge-dstu2SonatypeRelease]][Link-dstu2SonatypeRelease] | [![Snapshot Artifact][Badge-dstu2SonatypeSnapshot]][Link-dstu2SonatypeSnapshot] | +| org.hl7.fhir.dstu2016may | [![Release Artifacts][Badge-dstu2016maySonatypeRelease]][Link-dstu2016maySonatypeRelease] | [![Snapshot Artifact][Badge-dstu2016maySonatypeSnapshot]][Link-dstu2016maySonatypeSnapshot] | +| org.hl7.fhir.dstu3 | [![Release Artifacts][Badge-dstu3SonatypeRelease]][Link-dstu3SonatypeRelease] | [![Snapshot Artifact][Badge-dstu3SonatypeSnapshot]][Link-dstu3SonatypeSnapshot] | +| org.hl7.fhir.r4 | [![Release Artifacts][Badge-r4SonatypeRelease]][Link-r4SonatypeRelease] | [![Snapshot Artifact][Badge-r4SonatypeSnapshot]][Link-r4SonatypeSnapshot] | +| org.hl7.fhir.r5 | [![Release Artifacts][Badge-r5SonatypeRelease]][Link-r5SonatypeRelease] | [![Snapshot Artifact][Badge-r5SonatypeSnapshot]][Link-r5SonatypeSnapshot] | ### Building this Project This project uses [Apache Maven](http://maven.apache.org) to build. To build: @@ -25,6 +30,11 @@ To skip unit tests: ``` mvn -Dmaven.test.skip install ``` +### Publishing Binaries + +An brief overview of our publishing process is [here][Link-Publishing]. + +For more detailed instructions on cutting a release, please read [the wiki][Link-PublishingRelease] ### Download ##### org.hl7.fhir.validation.cli @@ -42,6 +52,36 @@ mvn -Dmaven.test.skip install compile group: 'ca.uhn.hapi.fhir', name: 'org.hl7.fhir.validation.cli', version: '(latest version)' ``` +##### org.hl7.fhir.dstu2 +###### Maven +```xml + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu2 + (latest version) + +``` + +###### Gradle +```groovy +compile group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-dstu2', version: '(latest version)' +``` + +##### org.hl7.fhir.dstu3 +###### Maven +```xml + + ca.uhn.hapi.fhir + hapi-fhir-structures-dstu3 + (latest version) + +``` + +###### Gradle +```groovy +compile group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-dstu3', version: '(latest version)' +``` + ##### org.hl7.fhir.r4 ###### Maven ```xml @@ -76,24 +116,41 @@ compile group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-r5', version: '(l This project is maintained by [Grahame Grieve][Link-grahameGithub] and [James Agnew][Link-jamesGithub] on behalf of the FHIR community. [Link-AzureProject]: https://dev.azure.com/fhir-pipelines/fhir-core-library -[Link-BuildPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_build/latest?definitionId=16&branchName=master +[Link-BuildPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_build/latest?definitionId=29&branchName=master [Link-SnapshotPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_build/latest?definitionId=17&branchName=master +[Link-dstu2SonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.dstu2&v=LATEST "Sonatype Snapshot" +[Link-dstu2SonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.dstu2&v=LATEST "Sonatype Release" +[Link-dstu2016maySonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.dstu2016may&v=LATEST "Sonatype Snapshot" +[Link-dstu2016maySonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.dstu2016may&v=LATEST "Sonatype Release" +[Link-dstu3SonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.dstu3&v=LATEST "Sonatype Snapshot" +[Link-dstu3SonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.dstu3&v=LATEST "Sonatype Release" [Link-r4SonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.r4&v=LATEST "Sonatype Snapshot" [Link-r4SonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.r4&v=LATEST "Sonatype Release" [Link-r5SonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.r5&v=LATEST "Sonatype Snapshot" [Link-r5SonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.r5&v=LATEST "Sonatype Release" [Link-cliSonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.validation.cli&v=LATEST "Sonatype Snapshot" -[Link-cliSonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.validation.cli&v=LATEST "Sonatype Release" +[Link-cliSonatypeRelease]: https://github.com/hapifhir/org.hl7.fhir.core/releases/latest/download/validator_cli.jar +[Link-validationSonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.validation&v=LATEST "Sonatype Snapshot" +[Link-validationSonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.validation&v=LATEST "Sonatype Release" [Link-grahameGithub]: https://github.com/grahamegrieve [Link-jamesGithub]: https://github.com/jamesagnew +[Link-Publishing]: https://github.com/FHIR/fhir-test-cases/wiki/Publishing-Binaries +[Link-PublishingRelease]: https://github.com/FHIR/fhir-test-cases/wiki/Detailed-Release-Instructions -[Badge-BuildPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_apis/build/status/Build%20%26%20Test?branchName=master + +[Badge-BuildPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_apis/build/status/Master%20Branch%20Pipeline?branchName=master [Badge-SnapshotPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_apis/build/status/Module%20SNAPSHOT%20Publisher?branchName=master +[Badge-dstu2SonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.dstu2.svg "Sonatype Releases" +[Badge-dstu2SonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.dstu2.svg "Sonatype Snapshots" +[Badge-dstu2016maySonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.dstu2016may.svg "Sonatype Releases" +[Badge-dstu2016maySonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.dstu2016may.svg "Sonatype Snapshots" +[Badge-dstu3SonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.dstu3.svg "Sonatype Releases" +[Badge-dstu3SonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.dstu3.svg "Sonatype Snapshots" [Badge-r4SonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.r4.svg "Sonatype Releases" [Badge-r4SonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.r4.svg "Sonatype Snapshots" [Badge-r5SonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.r5.svg "Sonatype Releases" [Badge-r5SonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.r5.svg "Sonatype Snapshots" [Badge-cliSonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.cli.svg "Sonatype Releases" [Badge-cliSonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.cli.svg "Sonatype Snapshots" - - +[Badge-validationSonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.svg "Sonatype Releases" +[Badge-validationSonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.svg "Sonatype Snapshots"