Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
56f99e4872
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
|
<nature>org.eclipse.pde.PluginNature</nature>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -108,10 +108,18 @@ public class FmlParser extends ParserBase {
|
||||||
parseGroup(result, lexer);
|
parseGroup(result, lexer);
|
||||||
}
|
}
|
||||||
} catch (FHIRLexerException e) {
|
} catch (FHIRLexerException e) {
|
||||||
|
if (policy == ValidationPolicy.NONE) {
|
||||||
|
throw e;
|
||||||
|
} else {
|
||||||
logError("2023-02-24", e.getLocation().getLine(), e.getLocation().getColumn(), "??", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL);
|
logError("2023-02-24", e.getLocation().getLine(), e.getLocation().getColumn(), "??", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
if (policy == ValidationPolicy.NONE) {
|
||||||
|
throw e;
|
||||||
|
} else {
|
||||||
logError("2023-02-24", -1, -1, "?", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL);
|
logError("2023-02-24", -1, -1, "?", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
result.setIgnorePropertyOrder(true);
|
result.setIgnorePropertyOrder(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,5 +698,15 @@ public class CodeSystemUtilities {
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkDisplay(CodeSystem cs, ConceptDefinitionComponent cd, String display) {
|
||||||
|
List<String> displays = getDisplays(cs, cd);
|
||||||
|
for (String s : displays) {
|
||||||
|
if (s.equalsIgnoreCase(display)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class TestingUtilities extends BaseTestingUtilities {
|
||||||
fcontext.loadFromPackage(utg, new TestPackageLoader(Utilities.strings("CodeSystem", "ValueSet")));
|
fcontext.loadFromPackage(utg, new TestPackageLoader(Utilities.strings("CodeSystem", "ValueSet")));
|
||||||
}
|
}
|
||||||
if (!fcontext.hasPackage("hl7.fhir.uv.extensions", null)) {
|
if (!fcontext.hasPackage("hl7.fhir.uv.extensions", null)) {
|
||||||
NpmPackage ext = pcm.loadPackage("hl7.fhir.uv.extensions", "current");
|
NpmPackage ext = pcm.loadPackage("hl7.fhir.uv.extensions", "1.0.0");
|
||||||
System.out.println("Loading Extensions: "+ext.name()+"#"+ext.version());
|
System.out.println("Loading Extensions: "+ext.name()+"#"+ext.version());
|
||||||
fcontext.loadFromPackage(ext, new TestPackageLoader(Utilities.strings("CodeSystem", "ValueSet", "StructureDefinition")));
|
fcontext.loadFromPackage(ext, new TestPackageLoader(Utilities.strings("CodeSystem", "ValueSet", "StructureDefinition")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,202 @@
|
||||||
|
package org.hl7.fhir.utilities;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.With;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class PathBuilder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, the normalized built path must be a child of the first entry of the buildPath arguments. If a
|
||||||
|
* different parent is desired, this can be set via <code>withRequiredTarget</code>
|
||||||
|
*/
|
||||||
|
@With
|
||||||
|
private final String requiredTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, the first entry of the buildPath argument cannot be null or an empty string. Setting this to false will
|
||||||
|
* disable this check.
|
||||||
|
*/
|
||||||
|
@With
|
||||||
|
private final boolean requireNonNullNonEmptyFirstEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, the first entry of the buildPath argument cannot be a root directory (<code>"/", "C:\", etc. </code>. Setting this to false will disable this check.
|
||||||
|
*/
|
||||||
|
@With
|
||||||
|
private final boolean requireNonRootFirstEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, the normalized built path must be a child of the first entry of the buildPath arguments. Setting this
|
||||||
|
* to false will disable this check.
|
||||||
|
*/
|
||||||
|
@With
|
||||||
|
private final boolean requirePathIsChildOfTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an instance of PathBuilder with all checks enabled (recommended).
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static PathBuilder getPathBuilder() {
|
||||||
|
return new PathBuilder(null, true, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Builds a path from the passed argument strings. This path will be compatible with the local filesystem.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* If the args contain variables enclosed in square brackets (<code>[ ]</code>), they will be replaced with values in
|
||||||
|
* the built path. There are several built-in variables available, listed below. Any text between square brackets that
|
||||||
|
* does not match these will be replaced by a matching System environment variable if one is available.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Built-in variables include:
|
||||||
|
* <ul>
|
||||||
|
* <li><i>[tmp]</i> An available temp directory (Java Temp directory, <code>c:\\temp, $TMPDIR, %TEMP%</code>, etc.) </li>
|
||||||
|
* <li><i>[user]</i> The OS user directory (~, user.home, etc) </li>
|
||||||
|
* </ul>
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* This method will run several checks by default to ensure that the built path does not point to unintended areas of
|
||||||
|
* the filesystem. If these checks are violated, a RuntimeException will be thrown. If needed in special cases, the
|
||||||
|
* behavior of these checks can be modified via the linked fluent constructor methods below.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param args entries with which to construct the filesystem path
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @return a local filesystem path
|
||||||
|
*
|
||||||
|
* @see this#withRequiredTarget(String)
|
||||||
|
* @see this#withRequireNonNullNonEmptyFirstEntry(boolean)
|
||||||
|
* @see this#withRequireNonRootFirstEntry(boolean)
|
||||||
|
* @see this#withRequirePathIsChildOfTarget(boolean)
|
||||||
|
*/
|
||||||
|
public String buildPath(String... args) {
|
||||||
|
|
||||||
|
checkNonNullNonEmptyFirstEntry(args);
|
||||||
|
checkNonRootFirstEntry(args);
|
||||||
|
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
boolean argIsNotEmptyOrNull = false;
|
||||||
|
|
||||||
|
boolean first = true;
|
||||||
|
for (String arg : args) {
|
||||||
|
if (first && arg == null)
|
||||||
|
continue;
|
||||||
|
first = false;
|
||||||
|
if (!argIsNotEmptyOrNull)
|
||||||
|
argIsNotEmptyOrNull = !Utilities.noString(arg);
|
||||||
|
else if (!stringBuilder.toString().endsWith(File.separator))
|
||||||
|
stringBuilder.append(File.separator);
|
||||||
|
String a = arg;
|
||||||
|
if (stringBuilder.length() == 0) {
|
||||||
|
a = replaceVariables(a);
|
||||||
|
}
|
||||||
|
a = a.replace("\\", File.separator);
|
||||||
|
a = a.replace("/", File.separator);
|
||||||
|
if (stringBuilder.length() > 0 && a.startsWith(File.separator))
|
||||||
|
a = a.substring(File.separator.length());
|
||||||
|
|
||||||
|
while (a.startsWith(".." + File.separator)) {
|
||||||
|
if (stringBuilder.length() == 0) {
|
||||||
|
stringBuilder = new StringBuilder(Paths.get(".").toAbsolutePath().normalize().toString());
|
||||||
|
} else {
|
||||||
|
String p = stringBuilder.toString().substring(0, stringBuilder.length() - 1);
|
||||||
|
if (!p.contains(File.separator)) {
|
||||||
|
stringBuilder = new StringBuilder();
|
||||||
|
} else {
|
||||||
|
stringBuilder = new StringBuilder(p.substring(0, p.lastIndexOf(File.separator)) + File.separator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a = a.substring(3);
|
||||||
|
}
|
||||||
|
if ("..".equals(a)) {
|
||||||
|
int i = stringBuilder.substring(0, stringBuilder.length() - 1).lastIndexOf(File.separator);
|
||||||
|
stringBuilder = new StringBuilder(stringBuilder.substring(0, i + 1));
|
||||||
|
} else
|
||||||
|
stringBuilder.append(a);
|
||||||
|
}
|
||||||
|
checkPathIsChildOfTarget(stringBuilder.toString(), args);
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkPathIsChildOfTarget(String path, String[] args) {
|
||||||
|
if (!requirePathIsChildOfTarget) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String target = requiredTarget != null
|
||||||
|
? requiredTarget
|
||||||
|
: args[0];
|
||||||
|
|
||||||
|
if (!Path.of(path).normalize().startsWith(Path.of(replaceVariables(target)).normalize())) {
|
||||||
|
throw new RuntimeException("Computed path does not start with first element: " + String.join(", ", args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNonRootFirstEntry(String[] args) {
|
||||||
|
if (!requireNonRootFirstEntry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isPathRoot(args[0])) {
|
||||||
|
throw new RuntimeException("First entry cannot be root: " + args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNonNullNonEmptyFirstEntry(String[] args) {
|
||||||
|
if (!requireNonNullNonEmptyFirstEntry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args[0] == null || Utilities.noString(args[0].trim())) {
|
||||||
|
throw new RuntimeException("First entry cannot be null or empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String replaceVariables(String a) {
|
||||||
|
if ("[tmp]".equals(a)) {
|
||||||
|
if (hasCTempDir()) {
|
||||||
|
return Utilities.C_TEMP_DIR;
|
||||||
|
} else if (ToolGlobalSettings.hasTempPath()) {
|
||||||
|
return ToolGlobalSettings.getTempPath();
|
||||||
|
} else {
|
||||||
|
return System.getProperty("java.io.tmpdir");
|
||||||
|
}
|
||||||
|
} else if ("[user]".equals(a)) {
|
||||||
|
return System.getProperty("user.home");
|
||||||
|
} else if (a.startsWith("[") && a.endsWith("]")) {
|
||||||
|
String ev = System.getenv(a.replace("[", "").replace("]", ""));
|
||||||
|
if (ev != null) {
|
||||||
|
return ev;
|
||||||
|
} else {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean hasCTempDir() {
|
||||||
|
if (!System.getProperty("os.name").toLowerCase().contains("win")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
File tmp = new File(Utilities.C_TEMP_DIR);
|
||||||
|
return tmp.exists() && tmp.isDirectory() && tmp.canWrite();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean isPathRoot(String pathString) {
|
||||||
|
boolean actual;
|
||||||
|
Path path = Path.of(pathString);
|
||||||
|
Path normalizedPath = path.normalize();
|
||||||
|
actual = normalizedPath.equals(path.getRoot());
|
||||||
|
return actual;
|
||||||
|
}
|
||||||
|
}
|
|
@ -613,47 +613,22 @@ public class Utilities {
|
||||||
return s.toString();
|
return s.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPathRoot(String pathString) {
|
|
||||||
boolean actual;
|
|
||||||
Path path = Path.of(pathString);
|
|
||||||
Path normalizedPath = path.normalize();
|
|
||||||
actual = normalizedPath.equals(path.getRoot());
|
|
||||||
return actual;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composes a path string using by concatenating the passed arguments.
|
* Composes a path string using by concatenating the passed arguments.
|
||||||
* Variables such as [tmp] and [user] are replaced.
|
|
||||||
*
|
*
|
||||||
* In order to prevent unintentional access to areas of the file system
|
* This method enables all checks for unintended path locations.
|
||||||
* outside of the first entry, this method will throw exceptions in situations
|
|
||||||
* where the constructed path is at a higher level than the first entry, or
|
|
||||||
* where the first entry is null or empty.
|
|
||||||
*
|
*
|
||||||
* @param args
|
* @param args
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* @see PathBuilder#buildPath(String...)
|
||||||
*/
|
*/
|
||||||
public static String path(String... args) throws IOException {
|
public static String path(String... args) throws IOException {
|
||||||
if (args[0] == null || noString(args[0].trim())) {
|
return PathBuilder.getPathBuilder().buildPath(args);
|
||||||
throw new RuntimeException("First entry cannot be null or empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPathRoot(args[0])) {
|
|
||||||
throw new RuntimeException("First entry cannot be root: " + args[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
String output = uncheckedPath(args);
|
|
||||||
|
|
||||||
if (!Path.of(output.toString()).normalize().startsWith(Path.of(replaceVariables(args[0])).normalize())) {
|
|
||||||
throw new RuntimeException("Computed path does not start with first element: " + String.join(", ", args));
|
|
||||||
}
|
|
||||||
return output.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composes a path string using by concatenating the passed arguments.
|
* Composes a path string using by concatenating the passed arguments.
|
||||||
* Variables such as [tmp] and [user] are replaced.
|
|
||||||
*
|
*
|
||||||
* This method does not check for unintentional access to areas of the file
|
* This method does not check for unintentional access to areas of the file
|
||||||
* system outside of the first entry. ONLY USE THIS METHOD IN CASES WHERE YOU
|
* system outside of the first entry. ONLY USE THIS METHOD IN CASES WHERE YOU
|
||||||
|
@ -662,83 +637,18 @@ public class Utilities {
|
||||||
* @param args
|
* @param args
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
*
|
||||||
|
* @see PathBuilder#buildPath(String...)
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static String uncheckedPath(String... args) {
|
public static String uncheckedPath(String... args) {
|
||||||
StringBuilder s = new StringBuilder();
|
return PathBuilder.getPathBuilder()
|
||||||
boolean argIsNotEmptyOrNull = false;
|
.withRequireNonRootFirstEntry(false)
|
||||||
|
.withRequireNonNullNonEmptyFirstEntry(false)
|
||||||
boolean first = true;
|
.withRequirePathIsChildOfTarget(false)
|
||||||
for (String arg : args) {
|
.buildPath(args);
|
||||||
if (first && arg == null)
|
|
||||||
continue;
|
|
||||||
first = false;
|
|
||||||
if (!argIsNotEmptyOrNull)
|
|
||||||
argIsNotEmptyOrNull = !noString(arg);
|
|
||||||
else if (!s.toString().endsWith(File.separator))
|
|
||||||
s.append(File.separator);
|
|
||||||
String a = arg;
|
|
||||||
if (s.length() == 0) {
|
|
||||||
a = replaceVariables(a);
|
|
||||||
}
|
|
||||||
a = a.replace("\\", File.separator);
|
|
||||||
a = a.replace("/", File.separator);
|
|
||||||
if (s.length() > 0 && a.startsWith(File.separator))
|
|
||||||
a = a.substring(File.separator.length());
|
|
||||||
|
|
||||||
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);
|
|
||||||
if (!p.contains(File.separator)) {
|
|
||||||
s = new StringBuilder();
|
|
||||||
} else {
|
|
||||||
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));
|
|
||||||
} else
|
|
||||||
s.append(a);
|
|
||||||
}
|
|
||||||
// if (!Path.of(s.toString()).normalize().startsWith(Path.of(replaceVariables(args[0])).normalize())) {
|
|
||||||
// throw new RuntimeException("Computed path '"+s.toString()+"' normalised to '"+Path.of(s.toString()).normalize()+"' does not start with first element: " + String.join(", ", args));
|
|
||||||
// }
|
|
||||||
return s.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String replaceVariables(String a) {
|
|
||||||
if ("[tmp]".equals(a)) {
|
|
||||||
if (hasCTempDir()) {
|
|
||||||
return C_TEMP_DIR;
|
|
||||||
} else if (ToolGlobalSettings.hasTempPath()) {
|
|
||||||
return ToolGlobalSettings.getTempPath();
|
|
||||||
} else {
|
|
||||||
return System.getProperty("java.io.tmpdir");
|
|
||||||
}
|
|
||||||
} else if ("[user]".equals(a)) {
|
|
||||||
return System.getProperty("user.home");
|
|
||||||
} else if (a.startsWith("[") && a.endsWith("]")) {
|
|
||||||
String ev = System.getenv(a.replace("[", "").replace("]", ""));
|
|
||||||
if (ev != null) {
|
|
||||||
return ev;
|
|
||||||
} else {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasCTempDir() {
|
|
||||||
if (!System.getProperty("os.name").toLowerCase().contains("win")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
File tmp = new File(C_TEMP_DIR);
|
|
||||||
return tmp.exists() && tmp.isDirectory() && tmp.canWrite();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String pathURL(String... args) {
|
public static String pathURL(String... args) {
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -157,8 +157,7 @@ public class ConceptMapValidator extends BaseValidator {
|
||||||
if (warningOrError(srcCS.getContent() == CodeSystemContentMode.COMPLETE, errors, "2023-03-05", IssueType.REQUIRED, code.line(), code.col(), stack.push(code, -1, null, null).getLiteralPath(), cd != null, I18nConstants.CONCEPTMAP_GROUP_SOURCE_CODE_INVALID, c, srcCS.getVersionedUrl())) {
|
if (warningOrError(srcCS.getContent() == CodeSystemContentMode.COMPLETE, errors, "2023-03-05", IssueType.REQUIRED, code.line(), code.col(), stack.push(code, -1, null, null).getLiteralPath(), cd != null, I18nConstants.CONCEPTMAP_GROUP_SOURCE_CODE_INVALID, c, srcCS.getVersionedUrl())) {
|
||||||
Element display = src.getNamedChild("display");
|
Element display = src.getNamedChild("display");
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
List<String> displays = CodeSystemUtilities.getDisplays(srcCS, cd);
|
warning(errors, "2023-03-05", IssueType.REQUIRED, code.line(), code.col(), stack.push(code, -1, null, null).getLiteralPath(), CodeSystemUtilities.checkDisplay(srcCS, cd, display.getValue()), I18nConstants.CONCEPTMAP_GROUP_SOURCE_DISPLAY_INVALID, display.getValue(), CodeSystemUtilities.getDisplays(srcCS, cd));
|
||||||
ok = rule(errors, "2023-03-05", IssueType.REQUIRED, code.line(), code.col(), stack.push(code, -1, null, null).getLiteralPath(), displays.contains(display.getValue()), I18nConstants.CONCEPTMAP_GROUP_SOURCE_DISPLAY_INVALID, display.getValue(), displays) && ok;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ok = false;
|
ok = false;
|
||||||
|
@ -184,8 +183,7 @@ public class ConceptMapValidator extends BaseValidator {
|
||||||
if (warningOrError(tgtCS.getContent() == CodeSystemContentMode.COMPLETE, errors, "2023-03-05", IssueType.REQUIRED, code.line(), code.col(), stack.push(code, -1, null, null).getLiteralPath(), cd != null, I18nConstants.CONCEPTMAP_GROUP_TARGET_CODE_INVALID, c, tgtCS.getVersionedUrl())) {
|
if (warningOrError(tgtCS.getContent() == CodeSystemContentMode.COMPLETE, errors, "2023-03-05", IssueType.REQUIRED, code.line(), code.col(), stack.push(code, -1, null, null).getLiteralPath(), cd != null, I18nConstants.CONCEPTMAP_GROUP_TARGET_CODE_INVALID, c, tgtCS.getVersionedUrl())) {
|
||||||
Element display = tgt.getNamedChild("display");
|
Element display = tgt.getNamedChild("display");
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
List<String> displays = CodeSystemUtilities.getDisplays(tgtCS, cd);
|
warning(errors, "2023-03-05", IssueType.REQUIRED, code.line(), code.col(), stack.push(code, -1, null, null).getLiteralPath(), CodeSystemUtilities.checkDisplay(tgtCS, cd, display.getValue()), I18nConstants.CONCEPTMAP_GROUP_TARGET_DISPLAY_INVALID, display.getValue(), CodeSystemUtilities.getDisplays(tgtCS, cd));
|
||||||
ok = rule(errors, "2023-03-05", IssueType.REQUIRED, code.line(), code.col(), stack.push(code, -1, null, null).getLiteralPath(), displays.contains(display.getValue()), I18nConstants.CONCEPTMAP_GROUP_TARGET_DISPLAY_INVALID, display.getValue(), displays) && ok;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ok = false;
|
ok = false;
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
||||||
HAPI FHIR
|
HAPI FHIR
|
||||||
-->
|
-->
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.6.116-SNAPSHOT</version>
|
<version>5.6.117-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
Loading…
Reference in New Issue