Add error codes to all exceptions (#3278)
* Initial design of adding exception codes to exceptions * Initial design of adding exception codes to exceptions * change int module name to string * add comment * shorten message * shorten message * added checkstyle * developing checker * completed checkstyle plugin and unit test for it * fix NPE * fix checker so it ignores throws on exceptions that aren't new * change parameter order in InvalidResponseException * accept Msg.code() in any parameter since some exceptions like MessageException have the message string as the second parameter * exclude generated files * BIG COMMIT added error codes to all exception throws * example test fix * Modified tests such that the assert statements would better match the message responses. * Modified additional tests such that the assert statements would better match the message responses. * fix test * merge master * merge master * Fourth commit of modified tests such that the assert statements would better match the message response * Changes made to modify assert statements such that they match the new errors which now use error codes. Also changed ResourceNotFoundException to include error codes in its messages. * Modified assert messages to better match new error codes * Time Zone changes DRAFT. Certain tests pass in intellij and fail during mvn install * Modified assert messages to better match new error codes * Added comments for time zone fixes. Previous commit comment on time zone fixes was incorrect. By invaliding caches, all tests on both intellij and mvn install passed. * Reverted changes on azure-pipelines.yml * updated hapi-fhir version for checkstyle module * changes to azure-pipelines.yml * changes to azure-pipelines.yml * change to pom.xml to include hapi-fhir-checkstyle in ALLMODULES * changes to azure-piplines (these changes are to be reverted after testing) * reverted changes to azure-piplines * reverted change where hapi-fhir-checkstyle was added to pom.xml (hapi-fhir) * Attempted fix on checkstyle build error * modified azure-piplines.yml to change maven repository for checkstyle build * Attempted fix on checkstyle build error * checkstyle config location change for hapi-depoloyable-pom. (will be reverted if it does not work) * attempted dependency add for hapi-depoloyable-pom. (will be reverted if it does not work) * reverted changes for hapi-deployable-pom * add javadoc * update last code * Attempted fix on checkstyle build error * Finished adding in missing error codes to pass Checkstyle checks * Test pipelining * Fixing errors and bumping version (as suggested by Gary) * Merge * Fixing Checkstyle error * Attempted fix for date error * Add error code onto assert statement * Add in a couple more error codes * Fixing assert statements * Bump to static version for dependency * Adding error code to message * Adding error codes to exceptions * Adding error codes to exceptions * Change to work with cdr branch * Update to faulty error message * Merge changes * allow checkstyle pom to deploy Co-authored-by: Ken Stevens <khstevens@gmail.com> Co-authored-by: Simon Zuccherato <simon.zuccherato@smilecdr.com> Co-authored-by: Predap <simon.zuccherato@gmail.com> Co-authored-by: Predap <46201929+Predap@users.noreply.github.com> Co-authored-by: Tadgh <garygrantgraham@gmail.com>
This commit is contained in:
parent
65398ca14f
commit
c42ecc5c08
|
@ -17,6 +17,15 @@ jobs:
|
||||||
timeoutInMinutes: 360
|
timeoutInMinutes: 360
|
||||||
container: maven:3.8-openjdk-17
|
container: maven:3.8-openjdk-17
|
||||||
steps:
|
steps:
|
||||||
|
- task: Maven@3
|
||||||
|
env:
|
||||||
|
JAVA_HOME_11_X64: /usr/java/openjdk-17
|
||||||
|
displayName: Checkstyle Build
|
||||||
|
inputs:
|
||||||
|
mavenPomFile: 'hapi-fhir-checkstyle/pom.xml'
|
||||||
|
goals: 'clean install'
|
||||||
|
options: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
|
||||||
|
jdkVersionOption: 1.11
|
||||||
- task: DockerInstaller@0
|
- task: DockerInstaller@0
|
||||||
displayName: Docker Installer
|
displayName: Docker Installer
|
||||||
inputs:
|
inputs:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir</artifactId>
|
<artifactId>hapi-fhir</artifactId>
|
||||||
<version>5.7.0-PRE9-SNAPSHOT</version>
|
<version>5.7.0-PRE10-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>hapi-deployable-pom</artifactId>
|
<artifactId>hapi-deployable-pom</artifactId>
|
||||||
<version>5.7.0-PRE9-SNAPSHOT</version>
|
<version>5.7.0-PRE10-SNAPSHOT</version>
|
||||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.*;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
@ -41,7 +42,7 @@ public class BuiltJarDstu2IT {
|
||||||
ctx.newXmlParser().encodeResourceToString(p);
|
ctx.newXmlParser().encodeResourceToString(p);
|
||||||
fail();
|
fail();
|
||||||
} catch (ca.uhn.fhir.context.ConfigurationException e) {
|
} catch (ca.uhn.fhir.context.ConfigurationException e) {
|
||||||
assertEquals("Unable to initialize StAX - XML processing is disabled",e.getMessage());
|
assertEquals(Msg.code(1754) + "Unable to initialize StAX - XML processing is disabled",e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-deployable-pom</artifactId>
|
<artifactId>hapi-deployable-pom</artifactId>
|
||||||
<version>5.7.0-PRE9-SNAPSHOT</version>
|
<version>5.7.0-PRE10-SNAPSHOT</version>
|
||||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,16 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public abstract class BaseRuntimeChildDefinition {
|
public abstract class BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
private BaseRuntimeChildDefinition myReplacedParentDefinition;
|
private BaseRuntimeChildDefinition myReplacedParentDefinition;
|
||||||
|
@ -98,7 +99,7 @@ public abstract class BaseRuntimeChildDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shouldn't happen
|
// Shouldn't happen
|
||||||
throw new IllegalStateException("Unable to find reference type");
|
throw new IllegalStateException(Msg.code(1692) + "Unable to find reference type");
|
||||||
}
|
}
|
||||||
|
|
||||||
// public String getExtensionUrl() {
|
// public String getExtensionUrl() {
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
import ca.uhn.fhir.util.ParametersUtil;
|
import ca.uhn.fhir.util.ParametersUtil;
|
||||||
|
@ -210,7 +211,7 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
||||||
try {
|
try {
|
||||||
theField.set(theTarget, theValue);
|
theField.set(theTarget, theValue);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new ConfigurationException("Failed to set value", e);
|
throw new ConfigurationException(Msg.code(1736) + "Failed to set value", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +219,7 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
||||||
try {
|
try {
|
||||||
return theField.get(theTarget);
|
return theField.get(theTarget);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new ConfigurationException("Failed to get value", e);
|
throw new ConfigurationException(Msg.code(1737) + "Failed to get value", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IBoundCodeableConcept;
|
import ca.uhn.fhir.model.api.IBoundCodeableConcept;
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
|
@ -131,10 +132,10 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
|
|
||||||
void addChild(BaseRuntimeChildDefinition theNext) {
|
void addChild(BaseRuntimeChildDefinition theNext) {
|
||||||
if (theNext == null) {
|
if (theNext == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException(Msg.code(1698));
|
||||||
}
|
}
|
||||||
if (theNext.getExtensionUrl() != null) {
|
if (theNext.getExtensionUrl() != null) {
|
||||||
throw new IllegalArgumentException("Shouldn't haven an extension URL, use addExtension instead");
|
throw new IllegalArgumentException(Msg.code(1699) + "Shouldn't haven an extension URL, use addExtension instead");
|
||||||
}
|
}
|
||||||
myChildren.add(theNext);
|
myChildren.add(theNext);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +150,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
validateSealed();
|
validateSealed();
|
||||||
BaseRuntimeChildDefinition retVal = myNameToChild.get(theName);
|
BaseRuntimeChildDefinition retVal = myNameToChild.get(theName);
|
||||||
if (retVal == null) {
|
if (retVal == null) {
|
||||||
throw new DataFormatException("Unknown child name '" + theName + "' in element " + getName() + " - Valid names are: " + new TreeSet<String>(myNameToChild.keySet()));
|
throw new DataFormatException(Msg.code(1700) + "Unknown child name '" + theName + "' in element " + getName() + " - Valid names are: " + new TreeSet<String>(myNameToChild.keySet()));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +282,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (order == Child.REPLACE_PARENT) {
|
if (order == Child.REPLACE_PARENT) {
|
||||||
throw new ConfigurationException("Field " + nextField.getName() + "' on target type " + declaringClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT
|
throw new ConfigurationException(Msg.code(1701) + "Field " + nextField.getName() + "' on target type " + declaringClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT
|
||||||
+ ") but no parent element with extension URL " + extensionAttr.url() + " could be found on type " + nextField.getDeclaringClass().getSimpleName());
|
+ ") but no parent element with extension URL " + extensionAttr.url() + " could be found on type " + nextField.getDeclaringClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +309,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (order == Child.REPLACE_PARENT) {
|
if (order == Child.REPLACE_PARENT) {
|
||||||
throw new ConfigurationException("Field " + nextField.getName() + "' on target type " + declaringClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT
|
throw new ConfigurationException(Msg.code(1702) + "Field " + nextField.getName() + "' on target type " + declaringClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT
|
||||||
+ ") but no parent element with name " + elementName + " could be found on type " + nextField.getDeclaringClass().getSimpleName());
|
+ ") but no parent element with name " + elementName + " could be found on type " + nextField.getDeclaringClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +318,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order < 0 && order != Child.ORDER_UNKNOWN) {
|
if (order < 0 && order != Child.ORDER_UNKNOWN) {
|
||||||
throw new ConfigurationException("Invalid order '" + order + "' on @Child for field '" + nextField.getName() + "' on target type: " + declaringClass);
|
throw new ConfigurationException(Msg.code(1703) + "Invalid order '" + order + "' on @Child for field '" + nextField.getName() + "' on target type: " + declaringClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order != Child.ORDER_UNKNOWN && !orderIsReplaceParent) {
|
if (order != Child.ORDER_UNKNOWN && !orderIsReplaceParent) {
|
||||||
|
@ -339,11 +340,11 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
List<Class<? extends IBase>> choiceTypes = next.getChoiceTypes();
|
List<Class<? extends IBase>> choiceTypes = next.getChoiceTypes();
|
||||||
|
|
||||||
if (orderMap.containsKey(order)) {
|
if (orderMap.containsKey(order)) {
|
||||||
throw new ConfigurationException("Detected duplicate field order '" + childAnnotation.order() + "' for element named '" + elementName + "' in type '" + declaringClass.getCanonicalName() + "' - Already had: " + orderMap.get(order).getElementName());
|
throw new ConfigurationException(Msg.code(1704) + "Detected duplicate field order '" + childAnnotation.order() + "' for element named '" + elementName + "' in type '" + declaringClass.getCanonicalName() + "' - Already had: " + orderMap.get(order).getElementName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elementNames.contains(elementName)) {
|
if (elementNames.contains(elementName)) {
|
||||||
throw new ConfigurationException("Detected duplicate field name '" + elementName + "' in type '" + declaringClass.getCanonicalName() + "'");
|
throw new ConfigurationException(Msg.code(1705) + "Detected duplicate field name '" + elementName + "' in type '" + declaringClass.getCanonicalName() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> nextElementType = next.getElementType();
|
Class<?> nextElementType = next.getElementType();
|
||||||
|
@ -393,7 +394,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
refTypesList.add(myContext.getVersion().getVersion().isRi() ? IAnyResource.class : IResource.class);
|
refTypesList.add(myContext.getVersion().getVersion().isRi() ? IAnyResource.class : IResource.class);
|
||||||
continue;
|
continue;
|
||||||
} else if (IBaseResource.class.isAssignableFrom(nextType) == false) {
|
} else if (IBaseResource.class.isAssignableFrom(nextType) == false) {
|
||||||
throw new ConfigurationException("Field '" + nextField.getName() + "' in class '" + nextField.getDeclaringClass().getCanonicalName() + "' is of type " + BaseResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
|
throw new ConfigurationException(Msg.code(1706) + "Field '" + nextField.getName() + "' in class '" + nextField.getDeclaringClass().getCanonicalName() + "' is of type " + BaseResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
|
||||||
}
|
}
|
||||||
refTypesList.add((Class<? extends IBaseResource>) nextType);
|
refTypesList.add((Class<? extends IBaseResource>) nextType);
|
||||||
}
|
}
|
||||||
|
@ -439,7 +440,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationException("Field '" + elementName + "' in type '" + declaringClass.getCanonicalName() + "' is not a valid child type: " + nextElementType);
|
throw new ConfigurationException(Msg.code(1707) + "Field '" + elementName + "' in type '" + declaringClass.getCanonicalName() + "' is not a valid child type: " + nextElementType);
|
||||||
}
|
}
|
||||||
|
|
||||||
Binding bindingAnnotation = ModelScanner.pullAnnotation(nextField, Binding.class);
|
Binding bindingAnnotation = ModelScanner.pullAnnotation(nextField, Binding.class);
|
||||||
|
@ -485,7 +486,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
||||||
}
|
}
|
||||||
for (String nextName : next.getValidChildNames()) {
|
for (String nextName : next.getValidChildNames()) {
|
||||||
if (myNameToChild.containsKey(nextName)) {
|
if (myNameToChild.containsKey(nextName)) {
|
||||||
throw new ConfigurationException("Duplicate child name[" + nextName + "] in Element[" + getName() + "]");
|
throw new ConfigurationException(Msg.code(1708) + "Duplicate child name[" + nextName + "] in Element[" + getName() + "]");
|
||||||
}
|
}
|
||||||
myNameToChild.put(nextName, next);
|
myNameToChild.put(nextName, next);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.util.UrlUtil;
|
import ca.uhn.fhir.util.UrlUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
@ -28,7 +29,11 @@ import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
||||||
|
|
||||||
|
@ -96,7 +101,7 @@ public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (retVal == null) {
|
if (retVal == null) {
|
||||||
throw new ConfigurationException("Class " + getImplementingClass() + " has no constructor with a single argument of type " + argumentType);
|
throw new ConfigurationException(Msg.code(1695) + "Class " + getImplementingClass() + " has no constructor with a single argument of type " + argumentType);
|
||||||
}
|
}
|
||||||
myConstructors.put(argumentType, retVal);
|
myConstructors.put(argumentType, retVal);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +174,7 @@ public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
||||||
return getConstructor(theArgument).newInstance(theArgument);
|
return getConstructor(theArgument).newInstance(theArgument);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException("Failed to instantiate type:" + getImplementingClass().getName(), e);
|
throw new ConfigurationException(Msg.code(1696) + "Failed to instantiate type:" + getImplementingClass().getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +196,7 @@ public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
||||||
for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
|
for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
|
||||||
String extUrl = next.getExtensionUrl();
|
String extUrl = next.getExtensionUrl();
|
||||||
if (myUrlToExtension.containsKey(extUrl)) {
|
if (myUrlToExtension.containsKey(extUrl)) {
|
||||||
throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]");
|
throw new ConfigurationException(Msg.code(1697) + "Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]");
|
||||||
}
|
}
|
||||||
myUrlToExtension.put(extUrl, next);
|
myUrlToExtension.put(extUrl, next);
|
||||||
if (next.isModifier()) {
|
if (next.isModifier()) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import ca.uhn.fhir.context.support.DefaultProfileValidationSupport;
|
||||||
import ca.uhn.fhir.context.support.IValidationSupport;
|
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||||
import ca.uhn.fhir.fhirpath.IFhirPath;
|
import ca.uhn.fhir.fhirpath.IFhirPath;
|
||||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
import ca.uhn.fhir.model.api.IFhirVersion;
|
import ca.uhn.fhir.model.api.IFhirVersion;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
@ -179,7 +180,7 @@ public class FhirContext {
|
||||||
|
|
||||||
if (theVersion != null) {
|
if (theVersion != null) {
|
||||||
if (!theVersion.isPresentOnClasspath()) {
|
if (!theVersion.isPresentOnClasspath()) {
|
||||||
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructuresForSpecifiedVersion", theVersion.name()));
|
throw new IllegalStateException(Msg.code(1680) + getLocalizer().getMessage(FhirContext.class, "noStructuresForSpecifiedVersion", theVersion.name()));
|
||||||
}
|
}
|
||||||
myVersion = theVersion.getVersionImplementation();
|
myVersion = theVersion.getVersionImplementation();
|
||||||
} else if (FhirVersionEnum.DSTU2.isPresentOnClasspath()) {
|
} else if (FhirVersionEnum.DSTU2.isPresentOnClasspath()) {
|
||||||
|
@ -193,7 +194,7 @@ public class FhirContext {
|
||||||
} else if (FhirVersionEnum.R4.isPresentOnClasspath()) {
|
} else if (FhirVersionEnum.R4.isPresentOnClasspath()) {
|
||||||
myVersion = FhirVersionEnum.R4.getVersionImplementation();
|
myVersion = FhirVersionEnum.R4.getVersionImplementation();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructures"));
|
throw new IllegalStateException(Msg.code(1681) + getLocalizer().getMessage(FhirContext.class, "noStructures"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theVersion == null) {
|
if (theVersion == null) {
|
||||||
|
@ -456,7 +457,7 @@ public class FhirContext {
|
||||||
Validate.notNull(theResourceType, "theResourceType can not be null");
|
Validate.notNull(theResourceType, "theResourceType can not be null");
|
||||||
|
|
||||||
if (Modifier.isAbstract(theResourceType.getModifiers())) {
|
if (Modifier.isAbstract(theResourceType.getModifiers())) {
|
||||||
throw new IllegalArgumentException("Can not scan abstract or interface class (resource definitions must be concrete classes): " + theResourceType.getName());
|
throw new IllegalArgumentException(Msg.code(1682) + "Can not scan abstract or interface class (resource definitions must be concrete classes): " + theResourceType.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeResourceDefinition retVal = (RuntimeResourceDefinition) myClassToElementDefinition.get(theResourceType);
|
RuntimeResourceDefinition retVal = (RuntimeResourceDefinition) myClassToElementDefinition.get(theResourceType);
|
||||||
|
@ -489,7 +490,7 @@ public class FhirContext {
|
||||||
|
|
||||||
Class<? extends IBaseResource> resourceType = nameToType.get(theResourceName.toLowerCase());
|
Class<? extends IBaseResource> resourceType = nameToType.get(theResourceName.toLowerCase());
|
||||||
if (resourceType == null) {
|
if (resourceType == null) {
|
||||||
throw new DataFormatException(createUnknownResourceNameError(theResourceName, theVersion));
|
throw new DataFormatException(Msg.code(1683) + createUnknownResourceNameError(theResourceName, theVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
return getResourceDefinition(resourceType);
|
return getResourceDefinition(resourceType);
|
||||||
|
@ -556,7 +557,7 @@ public class FhirContext {
|
||||||
// Multiple spots in HAPI FHIR and Smile CDR depend on DataFormatException
|
// Multiple spots in HAPI FHIR and Smile CDR depend on DataFormatException
|
||||||
// being thrown by this method, don't change that.
|
// being thrown by this method, don't change that.
|
||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
throw new DataFormatException(createUnknownResourceNameError(theResourceName, myVersion.getVersion()));
|
throw new DataFormatException(Msg.code(1684) + createUnknownResourceNameError(theResourceName, myVersion.getVersion()));
|
||||||
}
|
}
|
||||||
if (IBaseResource.class.isAssignableFrom(clazz)) {
|
if (IBaseResource.class.isAssignableFrom(clazz)) {
|
||||||
retVal = scanResourceType(clazz);
|
retVal = scanResourceType(clazz);
|
||||||
|
@ -605,7 +606,7 @@ public class FhirContext {
|
||||||
try (InputStream propFile = myVersion.getFhirVersionPropertiesFile()) {
|
try (InputStream propFile = myVersion.getFhirVersionPropertiesFile()) {
|
||||||
props.load(propFile);
|
props.load(propFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ConfigurationException("Failed to load version properties file", e);
|
throw new ConfigurationException(Msg.code(1685) + "Failed to load version properties file", e);
|
||||||
}
|
}
|
||||||
Enumeration<?> propNames = props.propertyNames();
|
Enumeration<?> propNames = props.propertyNames();
|
||||||
while (propNames.hasMoreElements()) {
|
while (propNames.hasMoreElements()) {
|
||||||
|
@ -628,7 +629,7 @@ public class FhirContext {
|
||||||
try {
|
try {
|
||||||
myRestfulClientFactory = (IRestfulClientFactory) ReflectionUtil.newInstance(Class.forName("ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory"), FhirContext.class, this);
|
myRestfulClientFactory = (IRestfulClientFactory) ReflectionUtil.newInstance(Class.forName("ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory"), FhirContext.class, this);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ConfigurationException("hapi-fhir-client does not appear to be on the classpath");
|
throw new ConfigurationException(Msg.code(1686) + "hapi-fhir-client does not appear to be on the classpath");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return myRestfulClientFactory;
|
return myRestfulClientFactory;
|
||||||
|
@ -1024,7 +1025,7 @@ public class FhirContext {
|
||||||
if (next instanceof RuntimeResourceDefinition) {
|
if (next instanceof RuntimeResourceDefinition) {
|
||||||
if ("Bundle".equals(next.getName())) {
|
if ("Bundle".equals(next.getName())) {
|
||||||
if (!IBaseBundle.class.isAssignableFrom(next.getImplementingClass())) {
|
if (!IBaseBundle.class.isAssignableFrom(next.getImplementingClass())) {
|
||||||
throw new ConfigurationException("Resource type declares resource name Bundle but does not implement IBaseBundle");
|
throw new ConfigurationException(Msg.code(1687) + "Resource type declares resource name Bundle but does not implement IBaseBundle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1209,7 +1210,7 @@ public class FhirContext {
|
||||||
ArrayList<Class<? extends IBaseResource>> retVal = new ArrayList<Class<? extends IBaseResource>>(1);
|
ArrayList<Class<? extends IBaseResource>> retVal = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||||
for (Class<?> clazz : theResourceTypes) {
|
for (Class<?> clazz : theResourceTypes) {
|
||||||
if (!IResource.class.isAssignableFrom(clazz)) {
|
if (!IResource.class.isAssignableFrom(clazz)) {
|
||||||
throw new IllegalArgumentException(clazz.getCanonicalName() + " is not an instance of " + IResource.class.getSimpleName());
|
throw new IllegalArgumentException(Msg.code(1688) + clazz.getCanonicalName() + " is not an instance of " + IResource.class.getSimpleName());
|
||||||
}
|
}
|
||||||
retVal.add((Class<? extends IResource>) clazz);
|
retVal.add((Class<? extends IResource>) clazz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IFhirVersion;
|
import ca.uhn.fhir.model.api.IFhirVersion;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
|
|
||||||
|
@ -66,13 +67,13 @@ public enum FhirVersionEnum {
|
||||||
|
|
||||||
public IFhirVersion getVersionImplementation() {
|
public IFhirVersion getVersionImplementation() {
|
||||||
if (!isPresentOnClasspath()) {
|
if (!isPresentOnClasspath()) {
|
||||||
throw new IllegalStateException("Version " + name() + " is not present on classpath");
|
throw new IllegalStateException(Msg.code(1709) + "Version " + name() + " is not present on classpath");
|
||||||
}
|
}
|
||||||
if (myVersionImplementation == null) {
|
if (myVersionImplementation == null) {
|
||||||
try {
|
try {
|
||||||
myVersionImplementation = (IFhirVersion) Class.forName(myVersionClass).newInstance();
|
myVersionImplementation = (IFhirVersion) Class.forName(myVersionClass).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new InternalErrorException("Failed to instantiate FHIR version " + name(), e);
|
throw new InternalErrorException(Msg.code(1710) + "Failed to instantiate FHIR version " + name(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return myVersionImplementation;
|
return myVersionImplementation;
|
||||||
|
@ -139,7 +140,7 @@ public enum FhirVersionEnum {
|
||||||
case R5:
|
case R5:
|
||||||
return FhirContext.forR5();
|
return FhirContext.forR5();
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Unknown version: " + this); // should not happen
|
throw new IllegalStateException(Msg.code(1711) + "Unknown version: " + this); // should not happen
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface IVersionProvider {
|
private interface IVersionProvider {
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.context;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.RuntimeSearchParam.RuntimeSearchParamStatusEnum;
|
import ca.uhn.fhir.context.RuntimeSearchParam.RuntimeSearchParamStatusEnum;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
|
@ -178,8 +179,7 @@ class ModelScanner {
|
||||||
ResourceDef resourceDefinition = pullAnnotation(theClass, ResourceDef.class);
|
ResourceDef resourceDefinition = pullAnnotation(theClass, ResourceDef.class);
|
||||||
if (resourceDefinition != null) {
|
if (resourceDefinition != null) {
|
||||||
if (!IBaseResource.class.isAssignableFrom(theClass)) {
|
if (!IBaseResource.class.isAssignableFrom(theClass)) {
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(Msg.code(1714) + "Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||||
"Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends IBaseResource> resClass = (Class<? extends IBaseResource>) theClass;
|
Class<? extends IBaseResource> resClass = (Class<? extends IBaseResource>) theClass;
|
||||||
|
@ -208,8 +208,7 @@ class ModelScanner {
|
||||||
if (IResourceBlock.class.isAssignableFrom(theClass) || IBaseBackboneElement.class.isAssignableFrom(theClass) || IBaseDatatypeElement.class.isAssignableFrom(theClass)) {
|
if (IResourceBlock.class.isAssignableFrom(theClass) || IBaseBackboneElement.class.isAssignableFrom(theClass) || IBaseDatatypeElement.class.isAssignableFrom(theClass)) {
|
||||||
scanBlock(theClass);
|
scanBlock(theClass);
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(Msg.code(1715) + "Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||||
"Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +217,7 @@ class ModelScanner {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ConfigurationException("Resource class[" + theClass.getName() + "] does not contain any valid HAPI-FHIR annotations");
|
throw new ConfigurationException(Msg.code(1716) + "Resource class[" + theClass.getName() + "] does not contain any valid HAPI-FHIR annotations");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +229,7 @@ class ModelScanner {
|
||||||
// Just in case someone messes up when upgrading from DSTU2
|
// Just in case someone messes up when upgrading from DSTU2
|
||||||
if (myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
|
if (myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
|
||||||
if (BaseIdentifiableElement.class.isAssignableFrom(theClass)) {
|
if (BaseIdentifiableElement.class.isAssignableFrom(theClass)) {
|
||||||
throw new ConfigurationException("@Block class for version " + myContext.getVersion().getVersion().name() + " should not extend " + BaseIdentifiableElement.class.getSimpleName() + ": " + theClass.getName());
|
throw new ConfigurationException(Msg.code(1717) + "@Block class for version " + myContext.getVersion().getVersion().name() + " should not extend " + BaseIdentifiableElement.class.getSimpleName() + ": " + theClass.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +266,7 @@ class ModelScanner {
|
||||||
|
|
||||||
String resourceName = theDatatypeDefinition.name();
|
String resourceName = theDatatypeDefinition.name();
|
||||||
if (isBlank(resourceName)) {
|
if (isBlank(resourceName)) {
|
||||||
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
throw new ConfigurationException(Msg.code(1718) + "Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseRuntimeElementDefinition<?> elementDef;
|
BaseRuntimeElementDefinition<?> elementDef;
|
||||||
|
@ -314,7 +313,7 @@ class ModelScanner {
|
||||||
parent = parent.getSuperclass();
|
parent = parent.getSuperclass();
|
||||||
}
|
}
|
||||||
if (isBlank(resourceName)) {
|
if (isBlank(resourceName)) {
|
||||||
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name(): " + theClass.getCanonicalName()
|
throw new ConfigurationException(Msg.code(1719) + "Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name(): " + theClass.getCanonicalName()
|
||||||
+ " - This is only allowed for types that extend other resource types ");
|
+ " - This is only allowed for types that extend other resource types ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +330,7 @@ class ModelScanner {
|
||||||
String resourceId = resourceDefinition.id();
|
String resourceId = resourceDefinition.id();
|
||||||
if (!isBlank(resourceId)) {
|
if (!isBlank(resourceId)) {
|
||||||
if (myIdToResourceDefinition.containsKey(resourceId)) {
|
if (myIdToResourceDefinition.containsKey(resourceId)) {
|
||||||
throw new ConfigurationException("The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and "
|
throw new ConfigurationException(Msg.code(1720) + "The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and "
|
||||||
+ myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName());
|
+ myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,7 +383,7 @@ class ModelScanner {
|
||||||
if (searchParam != null) {
|
if (searchParam != null) {
|
||||||
RestSearchParameterTypeEnum paramType = RestSearchParameterTypeEnum.forCode(searchParam.type().toLowerCase());
|
RestSearchParameterTypeEnum paramType = RestSearchParameterTypeEnum.forCode(searchParam.type().toLowerCase());
|
||||||
if (paramType == null) {
|
if (paramType == null) {
|
||||||
throw new ConfigurationException("Search param " + searchParam.name() + " has an invalid type: " + searchParam.type());
|
throw new ConfigurationException(Msg.code(1721) + "Search param " + searchParam.name() + " has an invalid type: " + searchParam.type());
|
||||||
}
|
}
|
||||||
Set<String> providesMembershipInCompartments;
|
Set<String> providesMembershipInCompartments;
|
||||||
providesMembershipInCompartments = new HashSet<>();
|
providesMembershipInCompartments = new HashSet<>();
|
||||||
|
@ -453,7 +452,7 @@ class ModelScanner {
|
||||||
if (List.class.equals(nextElementType)) {
|
if (List.class.equals(nextElementType)) {
|
||||||
nextElementType = ReflectionUtil.getGenericCollectionTypeOfField(next);
|
nextElementType = ReflectionUtil.getGenericCollectionTypeOfField(next);
|
||||||
} else if (Collection.class.isAssignableFrom(nextElementType)) {
|
} else if (Collection.class.isAssignableFrom(nextElementType)) {
|
||||||
throw new ConfigurationException("Field '" + next.getName() + "' in type '" + next.getClass().getCanonicalName() + "' is a Collection - Only java.util.List curently supported");
|
throw new ConfigurationException(Msg.code(1722) + "Field '" + next.getName() + "' in type '" + next.getClass().getCanonicalName() + "' is a Collection - Only java.util.List curently supported");
|
||||||
}
|
}
|
||||||
return nextElementType;
|
return nextElementType;
|
||||||
}
|
}
|
||||||
|
@ -462,7 +461,7 @@ class ModelScanner {
|
||||||
static IValueSetEnumBinder<Enum<?>> getBoundCodeBinder(Field theNext) {
|
static IValueSetEnumBinder<Enum<?>> getBoundCodeBinder(Field theNext) {
|
||||||
Class<?> bound = getGenericCollectionTypeOfCodedField(theNext);
|
Class<?> bound = getGenericCollectionTypeOfCodedField(theNext);
|
||||||
if (bound == null) {
|
if (bound == null) {
|
||||||
throw new ConfigurationException("Field '" + theNext + "' has no parameter for " + BoundCodeDt.class.getSimpleName() + " to determine enum type");
|
throw new ConfigurationException(Msg.code(1723) + "Field '" + theNext + "' has no parameter for " + BoundCodeDt.class.getSimpleName() + " to determine enum type");
|
||||||
}
|
}
|
||||||
|
|
||||||
String fieldName = "VALUESET_BINDER";
|
String fieldName = "VALUESET_BINDER";
|
||||||
|
@ -470,7 +469,7 @@ class ModelScanner {
|
||||||
Field bindingField = bound.getField(fieldName);
|
Field bindingField = bound.getField(fieldName);
|
||||||
return (IValueSetEnumBinder<Enum<?>>) bindingField.get(null);
|
return (IValueSetEnumBinder<Enum<?>>) bindingField.get(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException("Field '" + theNext + "' has type parameter " + bound.getCanonicalName() + " but this class has no valueset binding field (must have a field called " + fieldName + ")", e);
|
throw new ConfigurationException(Msg.code(1724) + "Field '" + theNext + "' has type parameter " + bound.getCanonicalName() + " but this class has no valueset binding field (must have a field called " + fieldName + ")", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +539,7 @@ class ModelScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ConfigurationException("Unknown class[" + nextValue + "] for data type definition: " + nextKey.substring("datatype.".length()), e);
|
throw new ConfigurationException(Msg.code(1725) + "Unknown class[" + nextValue + "] for data type definition: " + nextKey.substring("datatype.".length()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (nextKey.startsWith("resource.")) {
|
} else if (nextKey.startsWith("resource.")) {
|
||||||
|
@ -553,19 +552,19 @@ class ModelScanner {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!IBaseResource.class.isAssignableFrom(nextClass)) {
|
if (!IBaseResource.class.isAssignableFrom(nextClass)) {
|
||||||
throw new ConfigurationException("Class is not assignable from " + IBaseResource.class.getSimpleName() + ": " + nextValue);
|
throw new ConfigurationException(Msg.code(1726) + "Class is not assignable from " + IBaseResource.class.getSimpleName() + ": " + nextValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
theResourceTypes.put(resName, nextClass);
|
theResourceTypes.put(resName, nextClass);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ConfigurationException("Unknown class[" + nextValue + "] for resource definition: " + nextKey.substring("resource.".length()), e);
|
throw new ConfigurationException(Msg.code(1727) + "Unknown class[" + nextValue + "] for resource definition: " + nextKey.substring("resource.".length()), e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationException("Unexpected property in version property file: " + nextKey + "=" + nextValue);
|
throw new ConfigurationException(Msg.code(1728) + "Unexpected property in version property file: " + nextKey + "=" + nextValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ConfigurationException("Failed to load model property file from classpath: " + "/ca/uhn/fhir/model/dstu/model.properties");
|
throw new ConfigurationException(Msg.code(1729) + "Failed to load model property file from classpath: " + "/ca/uhn/fhir/model/dstu/model.properties");
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
|
@ -20,14 +20,23 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.hl7.fhir.instance.model.api.*;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||||
|
|
||||||
|
@ -150,7 +159,7 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
||||||
if (myDatatypeToElementName.containsKey(next)) {
|
if (myDatatypeToElementName.containsKey(next)) {
|
||||||
String existing = myDatatypeToElementName.get(next);
|
String existing = myDatatypeToElementName.get(next);
|
||||||
if (!existing.equals(elementName)) {
|
if (!existing.equals(elementName)) {
|
||||||
throw new ConfigurationException("Already have element name " + existing + " for datatype " + next.getSimpleName() + " in " + getElementName() + ", cannot add " + elementName);
|
throw new ConfigurationException(Msg.code(1693) + "Already have element name " + existing + " for datatype " + next.getSimpleName() + " in " + getElementName() + ", cannot add " + elementName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
myDatatypeToElementName.put(next, elementName);
|
myDatatypeToElementName.put(next, elementName);
|
||||||
|
|
|
@ -20,19 +20,19 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
import ca.uhn.fhir.model.base.composite.BaseContainedDt;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
|
||||||
import ca.uhn.fhir.model.base.composite.BaseContainedDt;
|
|
||||||
|
|
||||||
public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefinition {
|
public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefinition {
|
||||||
|
|
||||||
private BaseRuntimeElementDefinition<?> myElem;
|
private BaseRuntimeElementDefinition<?> myElem;
|
||||||
|
@ -82,7 +82,7 @@ public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefi
|
||||||
} else if (List.class.isAssignableFrom(actualType)) {
|
} else if (List.class.isAssignableFrom(actualType)) {
|
||||||
myElem = new RuntimeElemContainedResourceList(IBaseResource.class, false);
|
myElem = new RuntimeElemContainedResourceList(IBaseResource.class, false);
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationException("Fhir Version definition returned invalid contained type: " + actualType);
|
throw new ConfigurationException(Msg.code(1735) + "Fhir Version definition returned invalid contained type: " + actualType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,12 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class RuntimeChildPrimitiveEnumerationDatatypeDefinition extends RuntimeChildPrimitiveDatatypeDefinition {
|
public class RuntimeChildPrimitiveEnumerationDatatypeDefinition extends RuntimeChildPrimitiveDatatypeDefinition {
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class RuntimeChildPrimitiveEnumerationDatatypeDefinition extends RuntimeC
|
||||||
clazz = Class.forName(className);
|
clazz = Class.forName(className);
|
||||||
retVal = clazz.newInstance();
|
retVal = clazz.newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException("Failed to instantiate " + className, e);
|
throw new ConfigurationException(Msg.code(1694) + "Failed to instantiate " + className, e);
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,12 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -28,13 +34,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
|
||||||
|
|
||||||
public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||||
|
|
||||||
private BaseRuntimeElementDefinition<?> myRuntimeDef;
|
private BaseRuntimeElementDefinition<?> myRuntimeDef;
|
||||||
|
@ -111,7 +110,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
||||||
// else {
|
// else {
|
||||||
// RuntimeResourceDefinition nextDef = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
// RuntimeResourceDefinition nextDef = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
||||||
// if (nextDef == null) {
|
// if (nextDef == null) {
|
||||||
// throw new ConfigurationException("Can't find child of type: " + next.getCanonicalName() + " in " + getField().getDeclaringClass());
|
// throw new ConfigurationException(Msg.code(1691) + "Can't find child of type: " + next.getCanonicalName() + " in " + getField().getDeclaringClass());
|
||||||
// }
|
// }
|
||||||
// myValidChildNames.add(getElementName() + nextDef.getName());
|
// myValidChildNames.add(getElementName() + nextDef.getName());
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||||
|
@ -180,7 +181,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
||||||
// CodeType should win. If we aren't in a situation like that, there is a problem with the
|
// CodeType should win. If we aren't in a situation like that, there is a problem with the
|
||||||
// model so we should bail.
|
// model so we should bail.
|
||||||
if (!existing.isStandardType()) {
|
if (!existing.isStandardType()) {
|
||||||
throw new ConfigurationException("More than one child of " + getElementName() + " matches attribute name " + attrName + ". Found [" + existing.getImplementingClass().getName() + "] and [" + next.getImplementingClass().getName() + "]");
|
throw new ConfigurationException(Msg.code(1734) + "More than one child of " + getElementName() + " matches attribute name " + attrName + ". Found [" + existing.getImplementingClass().getName() + "] and [" + next.getImplementingClass().getName() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,17 @@ package ca.uhn.fhir.context;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||||
import org.hl7.fhir.instance.model.api.ICompositeType;
|
import org.hl7.fhir.instance.model.api.ICompositeType;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import java.util.Map;
|
||||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompositeDefinition<ICompositeType> implements IRuntimeDatatypeDefinition {
|
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompositeDefinition<ICompositeType> implements IRuntimeDatatypeDefinition {
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompos
|
||||||
|
|
||||||
String resourceName = theDef.name();
|
String resourceName = theDef.name();
|
||||||
if (isBlank(resourceName)) {
|
if (isBlank(resourceName)) {
|
||||||
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theImplementingClass.getCanonicalName());
|
throw new ConfigurationException(Msg.code(1712) + "Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theImplementingClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
mySpecialization = theDef.isSpecialization();
|
mySpecialization = theDef.isSpecialization();
|
||||||
|
@ -59,7 +60,7 @@ public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompos
|
||||||
if (myProfileOfType != null) {
|
if (myProfileOfType != null) {
|
||||||
myProfileOf = theClassToElementDefinitions.get(myProfileOfType);
|
myProfileOf = theClassToElementDefinitions.get(myProfileOfType);
|
||||||
if (myProfileOf == null) {
|
if (myProfileOf == null) {
|
||||||
throw new ConfigurationException("Unknown profileOf value: " + myProfileOfType);
|
throw new ConfigurationException(Msg.code(1713) + "Unknown profileOf value: " + myProfileOfType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,13 @@ package ca.uhn.fhir.context;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
@ -28,13 +34,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
|
||||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
|
||||||
|
|
||||||
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveType<?>> implements IRuntimeDatatypeDefinition {
|
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveType<?>> implements IRuntimeDatatypeDefinition {
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefini
|
||||||
|
|
||||||
String resourceName = theDef.name();
|
String resourceName = theDef.name();
|
||||||
if (isBlank(resourceName)) {
|
if (isBlank(resourceName)) {
|
||||||
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theImplementingClass.getCanonicalName());
|
throw new ConfigurationException(Msg.code(1689) + "Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theImplementingClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
mySpecialization = theDef.isSpecialization();
|
mySpecialization = theDef.isSpecialization();
|
||||||
|
@ -142,7 +142,7 @@ public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefini
|
||||||
b.append(getImplementingClass().getName());
|
b.append(getImplementingClass().getName());
|
||||||
b.append(" - Valid types: ");
|
b.append(" - Valid types: ");
|
||||||
b.append(theClassToElementDefinitions.keySet());
|
b.append(theClassToElementDefinitions.keySet());
|
||||||
throw new ConfigurationException(b.toString());
|
throw new ConfigurationException(Msg.code(1690) + b.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
import ca.uhn.fhir.util.UrlUtil;
|
import ca.uhn.fhir.util.UrlUtil;
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
|
@ -60,11 +61,11 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
||||||
try {
|
try {
|
||||||
instance = theClass.getConstructor().newInstance();
|
instance = theClass.getConstructor().newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "nonInstantiableType", theClass.getName(), e.toString()), e);
|
throw new ConfigurationException(Msg.code(1730) + myContext.getLocalizer().getMessage(getClass(), "nonInstantiableType", theClass.getName(), e.toString()), e);
|
||||||
}
|
}
|
||||||
myStructureVersion = instance.getStructureFhirVersionEnum();
|
myStructureVersion = instance.getStructureFhirVersionEnum();
|
||||||
if (myStructureVersion != theContext.getVersion().getVersion()) {
|
if (myStructureVersion != theContext.getVersion().getVersion()) {
|
||||||
throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "typeWrongVersion", theContext.getVersion().getVersion(), theClass.getName(), myStructureVersion));
|
throw new ConfigurationException(Msg.code(1731) + myContext.getLocalizer().getMessage(getClass(), "typeWrongVersion", theContext.getVersion().getVersion(), theClass.getName(), myStructureVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -106,7 +107,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> Class<T> getImplementingClass(Class<T> theClass) {
|
public <T> Class<T> getImplementingClass(Class<T> theClass) {
|
||||||
if (!theClass.isAssignableFrom(getImplementingClass())) {
|
if (!theClass.isAssignableFrom(getImplementingClass())) {
|
||||||
throw new ConfigurationException("Unable to convert " + getImplementingClass() + " to " + theClass);
|
throw new ConfigurationException(Msg.code(1732) + "Unable to convert " + getImplementingClass() + " to " + theClass);
|
||||||
}
|
}
|
||||||
return (Class<T>) getImplementingClass();
|
return (Class<T>) getImplementingClass();
|
||||||
}
|
}
|
||||||
|
@ -234,7 +235,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
||||||
if (hasExtensions()) {
|
if (hasExtensions()) {
|
||||||
if (IAnyResource.class.isAssignableFrom(getImplementingClass())) {
|
if (IAnyResource.class.isAssignableFrom(getImplementingClass())) {
|
||||||
if (!IDomainResource.class.isAssignableFrom(getImplementingClass())) {
|
if (!IDomainResource.class.isAssignableFrom(getImplementingClass())) {
|
||||||
throw new ConfigurationException("Class \"" + getImplementingClass() + "\" is invalid. This resource type is not a DomainResource, it must not have extensions");
|
throw new ConfigurationException(Msg.code(1733) + "Class \"" + getImplementingClass() + "\" is invalid. This resource type is not a DomainResource, it must not have extensions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ package ca.uhn.fhir.context.support;
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.api.Constants;
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
import ca.uhn.fhir.util.BundleUtil;
|
import ca.uhn.fhir.util.BundleUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -99,7 +100,7 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
|
||||||
structureDefinitionResources.add("/org/hl7/fhir/instance/model/profile/" + nextKey);
|
structureDefinitionResources.add("/org/hl7/fhir/instance/model/profile/" + nextKey);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ConfigurationException(e);
|
throw new ConfigurationException(Msg.code(1740) + e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DSTU2_1:
|
case DSTU2_1:
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.context.support;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.fhir.util.ParametersUtil;
|
import ca.uhn.fhir.util.ParametersUtil;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
@ -711,7 +712,7 @@ public interface IValidationSupport {
|
||||||
|
|
||||||
public void throwNotFoundIfAppropriate() {
|
public void throwNotFoundIfAppropriate() {
|
||||||
if (isFound() == false) {
|
if (isFound() == false) {
|
||||||
throw new ResourceNotFoundException("Unable to find code[" + getSearchedForCode() + "] in system[" + getSearchedForSystem() + "]");
|
throw new ResourceNotFoundException(Msg.code(1738) + "Unable to find code[" + getSearchedForCode() + "] in system[" + getSearchedForSystem() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,7 +756,7 @@ public interface IValidationSupport {
|
||||||
IValidationSupport.CodingConceptProperty prop = (IValidationSupport.CodingConceptProperty) next;
|
IValidationSupport.CodingConceptProperty prop = (IValidationSupport.CodingConceptProperty) next;
|
||||||
ParametersUtil.addPartCoding(theContext, property, "value", prop.getCodeSystem(), prop.getCode(), prop.getDisplay());
|
ParametersUtil.addPartCoding(theContext, property, "value", prop.getCodeSystem(), prop.getCode(), prop.getDisplay());
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Don't know how to handle " + next.getClass());
|
throw new IllegalStateException(Msg.code(1739) + "Don't know how to handle " + next.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ca.uhn.fhir.i18n;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR - Core Library
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||||
|
* %%
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
|
public final class HapiErrorCode {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -5,10 +5,20 @@ import ca.uhn.fhir.util.UrlUtil;
|
||||||
import ca.uhn.fhir.util.VersionUtil;
|
import ca.uhn.fhir.util.VersionUtil;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.trim;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +105,7 @@ public class HapiLocalizer {
|
||||||
if (formatString == null) {
|
if (formatString == null) {
|
||||||
ourLog.warn("Unknown localization key: {}", theQualifiedKey);
|
ourLog.warn("Unknown localization key: {}", theQualifiedKey);
|
||||||
if (ourFailOnMissingMessage) {
|
if (ourFailOnMissingMessage) {
|
||||||
throw new ConfigurationException("Unknown localization key: " + theQualifiedKey);
|
throw new ConfigurationException(Msg.code(1908) + "Unknown localization key: " + theQualifiedKey);
|
||||||
}
|
}
|
||||||
formatString = UNKNOWN_I18N_KEY_MESSAGE;
|
formatString = UNKNOWN_I18N_KEY_MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package ca.uhn.fhir.i18n;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR - Core Library
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||||
|
* %%
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
|
public final class Msg {
|
||||||
|
private static final String ERROR_CODE_PREFIX = "HAPI";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IMPORTANT: Please update the following comment after you add a new code
|
||||||
|
* Last code value: 2018
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Msg() {}
|
||||||
|
|
||||||
|
public static String code(int theCode) {
|
||||||
|
return String.format("%s-%04d: ", ERROR_CODE_PREFIX, theCode);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.interceptor.executor;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.interceptor.api.HookParams;
|
import ca.uhn.fhir.interceptor.api.HookParams;
|
||||||
import ca.uhn.fhir.interceptor.api.IBaseInterceptorBroadcaster;
|
import ca.uhn.fhir.interceptor.api.IBaseInterceptorBroadcaster;
|
||||||
import ca.uhn.fhir.interceptor.api.IBaseInterceptorService;
|
import ca.uhn.fhir.interceptor.api.IBaseInterceptorService;
|
||||||
|
@ -404,7 +405,7 @@ public abstract class BaseInterceptorService<POINTCUT extends IPointcut> impleme
|
||||||
*/
|
*/
|
||||||
boolean haveAppropriateParams(POINTCUT thePointcut, HookParams theParams) {
|
boolean haveAppropriateParams(POINTCUT thePointcut, HookParams theParams) {
|
||||||
if (theParams.getParamsForType().values().size() != thePointcut.getParameterTypes().size()) {
|
if (theParams.getParamsForType().values().size() != thePointcut.getParameterTypes().size()) {
|
||||||
throw new IllegalArgumentException(String.format("Wrong number of params for pointcut %s - Wanted %s but found %s", thePointcut.name(), toErrorString(thePointcut.getParameterTypes()), theParams.getParamsForType().values().stream().map(t -> t != null ? t.getClass().getSimpleName() : "null").sorted().collect(Collectors.toList())));
|
throw new IllegalArgumentException(Msg.code(1909) + String.format("Wrong number of params for pointcut %s - Wanted %s but found %s", thePointcut.name(), toErrorString(thePointcut.getParameterTypes()), theParams.getParamsForType().values().stream().map(t -> t != null ? t.getClass().getSimpleName() : "null").sorted().collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> wantedTypes = new ArrayList<>(thePointcut.getParameterTypes());
|
List<String> wantedTypes = new ArrayList<>(thePointcut.getParameterTypes());
|
||||||
|
@ -574,10 +575,10 @@ public abstract class BaseInterceptorService<POINTCUT extends IPointcut> impleme
|
||||||
if (targetException instanceof RuntimeException) {
|
if (targetException instanceof RuntimeException) {
|
||||||
throw ((RuntimeException) targetException);
|
throw ((RuntimeException) targetException);
|
||||||
} else {
|
} else {
|
||||||
throw new InternalErrorException("Failure invoking interceptor for pointcut(s) " + getPointcut(), targetException);
|
throw new InternalErrorException(Msg.code(1910) + "Failure invoking interceptor for pointcut(s) " + getPointcut(), targetException);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1911) + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.model.api;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import ca.uhn.fhir.util.CoverageIgnore;
|
import ca.uhn.fhir.util.CoverageIgnore;
|
||||||
|
@ -94,13 +95,13 @@ public abstract class BaseIdentifiableElement extends BaseElement implements IId
|
||||||
@Override
|
@Override
|
||||||
@CoverageIgnore
|
@CoverageIgnore
|
||||||
public IdDt setValue(String theValue) throws DataFormatException {
|
public IdDt setValue(String theValue) throws DataFormatException {
|
||||||
throw new UnsupportedOperationException("Use IElement#setElementSpecificId(String) to set the element ID for an element");
|
throw new UnsupportedOperationException(Msg.code(1899) + "Use IElement#setElementSpecificId(String) to set the element ID for an element");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CoverageIgnore
|
@CoverageIgnore
|
||||||
public void setValueAsString(String theValue) throws DataFormatException {
|
public void setValueAsString(String theValue) throws DataFormatException {
|
||||||
throw new UnsupportedOperationException("Use IElement#setElementSpecificId(String) to set the element ID for an element");
|
throw new UnsupportedOperationException(Msg.code(1900) + "Use IElement#setElementSpecificId(String) to set the element ID for an element");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,18 +20,18 @@ package ca.uhn.fhir.model.api;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import java.util.List;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import java.util.ArrayList;
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import java.util.List;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
|
||||||
|
|
||||||
@DatatypeDef(name = "Extension")
|
@DatatypeDef(name = "Extension")
|
||||||
public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDatatype, IBaseExtension<ExtensionDt, IDatatype> {
|
public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDatatype, IBaseExtension<ExtensionDt, IDatatype> {
|
||||||
|
@ -116,7 +116,7 @@ public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDa
|
||||||
*/
|
*/
|
||||||
public IPrimitiveDatatype<?> getValueAsPrimitive() {
|
public IPrimitiveDatatype<?> getValueAsPrimitive() {
|
||||||
if (!(getValue() instanceof IPrimitiveDatatype)) {
|
if (!(getValue() instanceof IPrimitiveDatatype)) {
|
||||||
throw new ClassCastException("Extension with URL["+myUrl+"] can not be cast to primitive type, type is: "+ getClass().getCanonicalName());
|
throw new ClassCastException(Msg.code(1887) + "Extension with URL["+myUrl+"] can not be cast to primitive type, type is: "+ getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
return (IPrimitiveDatatype<?>) getValue();
|
return (IPrimitiveDatatype<?>) getValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package ca.uhn.fhir.model.api;
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* HAPI FHIR - Core Library
|
* HAPI FHIR - Core Library
|
||||||
|
@ -189,7 +190,7 @@ public class Include implements Serializable {
|
||||||
|
|
||||||
public void setValue(String theValue) {
|
public void setValue(String theValue) {
|
||||||
if (myImmutable) {
|
if (myImmutable) {
|
||||||
throw new IllegalStateException("Can not change the value of this include");
|
throw new IllegalStateException(Msg.code(1888) + "Can not change the value of this include");
|
||||||
}
|
}
|
||||||
|
|
||||||
String value = defaultString(theValue);
|
String value = defaultString(theValue);
|
||||||
|
@ -274,7 +275,7 @@ public class Include implements Serializable {
|
||||||
String paramType = getParamType();
|
String paramType = getParamType();
|
||||||
String paramName = getParamName();
|
String paramName = getParamName();
|
||||||
if (isBlank(paramType) || isBlank(paramName)) {
|
if (isBlank(paramType) || isBlank(paramName)) {
|
||||||
throw new IllegalStateException("This include does not contain a value in the format [ResourceType]:[paramName]");
|
throw new IllegalStateException(Msg.code(1889) + "This include does not contain a value in the format [ResourceType]:[paramName]");
|
||||||
}
|
}
|
||||||
b.append(paramType);
|
b.append(paramType);
|
||||||
b.append(":");
|
b.append(":");
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.model.api;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||||
|
@ -31,7 +32,11 @@ import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
|
@ -386,7 +391,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
||||||
} else if (retValObj instanceof ExtensionDt) {
|
} else if (retValObj instanceof ExtensionDt) {
|
||||||
return (ExtensionDt) retValObj;
|
return (ExtensionDt) retValObj;
|
||||||
}
|
}
|
||||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName()
|
throw new InternalErrorException(Msg.code(1890) + "Found an object of type '" + retValObj.getClass().getCanonicalName()
|
||||||
+ "' in resource metadata for key " + this.name() + " - Expected "
|
+ "' in resource metadata for key " + this.name() + " - Expected "
|
||||||
+ ExtensionDt.class.getCanonicalName());
|
+ ExtensionDt.class.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
@ -409,7 +414,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
||||||
} else if (retValObj instanceof String) {
|
} else if (retValObj instanceof String) {
|
||||||
return theBinder.fromCodeString((String) retValObj);
|
return theBinder.fromCodeString((String) retValObj);
|
||||||
}
|
}
|
||||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
throw new InternalErrorException(Msg.code(1891) + "Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
||||||
+ InstantDt.class.getCanonicalName());
|
+ InstantDt.class.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +457,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
||||||
}
|
}
|
||||||
return (InstantDt) retValObj;
|
return (InstantDt) retValObj;
|
||||||
}
|
}
|
||||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
throw new InternalErrorException(Msg.code(1892) + "Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
||||||
+ InstantDt.class.getCanonicalName());
|
+ InstantDt.class.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,7 +471,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
||||||
}
|
}
|
||||||
return (String) retValObj;
|
return (String) retValObj;
|
||||||
}
|
}
|
||||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
throw new InternalErrorException(Msg.code(1893) + "Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
||||||
+ String.class.getCanonicalName());
|
+ String.class.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,7 +491,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
||||||
} else if (retValObj instanceof Number) {
|
} else if (retValObj instanceof Number) {
|
||||||
return new IdDt(retValObj.toString());
|
return new IdDt(retValObj.toString());
|
||||||
}
|
}
|
||||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
throw new InternalErrorException(Msg.code(1894) + "Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
||||||
+ IdDt.class.getCanonicalName());
|
+ IdDt.class.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,10 @@ package ca.uhn.fhir.model.api;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.util.CoverageIgnore;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -28,10 +32,6 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.util.CoverageIgnore;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of tags present on a single resource. TagList is backed by a {@link LinkedHashSet}, so the order of
|
* A collection of tags present on a single resource. TagList is backed by a {@link LinkedHashSet}, so the order of
|
||||||
* added tags will be consistent, but duplicates will not be preserved.
|
* added tags will be consistent, but duplicates will not be preserved.
|
||||||
|
@ -270,7 +270,7 @@ public class TagList implements Set<Tag>, Serializable, IBase {
|
||||||
@Override
|
@Override
|
||||||
@CoverageIgnore
|
@CoverageIgnore
|
||||||
public List<String> getFormatCommentsPre() {
|
public List<String> getFormatCommentsPre() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1895));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -279,17 +279,17 @@ public class TagList implements Set<Tag>, Serializable, IBase {
|
||||||
@Override
|
@Override
|
||||||
@CoverageIgnore
|
@CoverageIgnore
|
||||||
public List<String> getFormatCommentsPost() {
|
public List<String> getFormatCommentsPost() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1896));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getUserData(String theName) {
|
public Object getUserData(String theName) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1897));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUserData(String theName, Object theValue) {
|
public void setUserData(String theName, Object theValue) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1898));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,8 @@ package ca.uhn.fhir.model.base.composite;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
@ -31,6 +30,7 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.model.primitive.UriDt;
|
import ca.uhn.fhir.model.primitive.UriDt;
|
||||||
import ca.uhn.fhir.rest.param.ParameterUtil;
|
import ca.uhn.fhir.rest.param.ParameterUtil;
|
||||||
import ca.uhn.fhir.rest.param.TokenParam;
|
import ca.uhn.fhir.rest.param.TokenParam;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
public abstract class BaseCodingDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
public abstract class BaseCodingDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ public abstract class BaseCodingDt extends BaseIdentifiableElement implements IC
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public IQueryParameterType setMissing(Boolean theMissing) {
|
public IQueryParameterType setMissing(Boolean theMissing) {
|
||||||
throw new UnsupportedOperationException("get/setMissing is not supported in StringDt. Use {@link StringParam} instead if you need this functionality");
|
throw new UnsupportedOperationException(Msg.code(1903) + "get/setMissing is not supported in StringDt. Use {@link StringParam} instead if you need this functionality");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package ca.uhn.fhir.model.base.composite;
|
package ca.uhn.fhir.model.base.composite;
|
||||||
|
|
||||||
import java.util.List;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.util.CoverageIgnore;
|
import ca.uhn.fhir.util.CoverageIgnore;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* HAPI FHIR - Core Library
|
* HAPI FHIR - Core Library
|
||||||
|
@ -38,7 +39,7 @@ public abstract class BaseContainedDt implements IDatatype {
|
||||||
@Override
|
@Override
|
||||||
@CoverageIgnore
|
@CoverageIgnore
|
||||||
public List<String> getFormatCommentsPost() {
|
public List<String> getFormatCommentsPost() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1901));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +48,7 @@ public abstract class BaseContainedDt implements IDatatype {
|
||||||
@Override
|
@Override
|
||||||
@CoverageIgnore
|
@CoverageIgnore
|
||||||
public List<String> getFormatCommentsPre() {
|
public List<String> getFormatCommentsPre() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1902));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,9 +20,8 @@ package ca.uhn.fhir.model.base.composite;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
@ -30,6 +29,7 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.model.primitive.UriDt;
|
import ca.uhn.fhir.model.primitive.UriDt;
|
||||||
import ca.uhn.fhir.rest.param.ParameterUtil;
|
import ca.uhn.fhir.rest.param.ParameterUtil;
|
||||||
import ca.uhn.fhir.rest.param.StringParam;
|
import ca.uhn.fhir.rest.param.StringParam;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
public abstract class BaseIdentifierDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
public abstract class BaseIdentifierDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public abstract class BaseIdentifierDt extends BaseIdentifiableElement implement
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public IQueryParameterType setMissing(Boolean theMissing) {
|
public IQueryParameterType setMissing(Boolean theMissing) {
|
||||||
throw new UnsupportedOperationException("get/setMissing is not supported in StringDt. Use {@link StringParam} instead if you need this functionality");
|
throw new UnsupportedOperationException(Msg.code(1907) + "get/setMissing is not supported in StringDt. Use {@link StringParam} instead if you need this functionality");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,21 @@ package ca.uhn.fhir.model.base.composite;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.*;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.primitive.*;
|
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||||
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||||
|
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||||
|
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||||
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
|
import ca.uhn.fhir.model.primitive.UriDt;
|
||||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||||
import ca.uhn.fhir.rest.param.QuantityParam;
|
import ca.uhn.fhir.rest.param.QuantityParam;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public abstract class BaseQuantityDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
public abstract class BaseQuantityDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
||||||
|
|
||||||
|
@ -231,7 +237,7 @@ public abstract class BaseQuantityDt extends BaseIdentifiableElement implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public IQueryParameterType setMissing(Boolean theMissing) {
|
public IQueryParameterType setMissing(Boolean theMissing) {
|
||||||
throw new UnsupportedOperationException("get/setMissing is not supported in StringDt. Use {@link StringParam} instead if you need this functionality");
|
throw new UnsupportedOperationException(Msg.code(1904) + "get/setMissing is not supported in StringDt. Use {@link StringParam} instead if you need this functionality");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,19 +20,19 @@ package ca.uhn.fhir.model.base.composite;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
public abstract class BaseResourceReferenceDt extends BaseIdentifiableElement implements IBaseDatatype, IBaseReference {
|
public abstract class BaseResourceReferenceDt extends BaseIdentifiableElement implements IBaseDatatype, IBaseReference {
|
||||||
|
|
||||||
|
@ -97,10 +97,10 @@ public abstract class BaseResourceReferenceDt extends BaseIdentifiableElement im
|
||||||
|
|
||||||
IdDt resourceId = getReference();
|
IdDt resourceId = getReference();
|
||||||
if (resourceId == null || isBlank(resourceId.getValue())) {
|
if (resourceId == null || isBlank(resourceId.getValue())) {
|
||||||
throw new IllegalStateException("Reference has no resource ID defined");
|
throw new IllegalStateException(Msg.code(1905) + "Reference has no resource ID defined");
|
||||||
}
|
}
|
||||||
if (isBlank(resourceId.getBaseUrl()) || isBlank(resourceId.getResourceType())) {
|
if (isBlank(resourceId.getBaseUrl()) || isBlank(resourceId.getResourceType())) {
|
||||||
throw new IllegalStateException("Reference is not complete (must be in the form [baseUrl]/[resource type]/[resource ID]) - Reference is: " + resourceId.getValue());
|
throw new IllegalStateException(Msg.code(1906) + "Reference is not complete (must be in the form [baseUrl]/[resource type]/[resource ID]) - Reference is: " + resourceId.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
String resourceUrl = resourceId.getValue();
|
String resourceUrl = resourceId.getValue();
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.model.primitive;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
@ -31,8 +32,8 @@ import org.apache.commons.lang3.time.FastDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.TimeZone;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
@ -69,7 +70,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
||||||
public BaseDateTimeDt(Date theDate, TemporalPrecisionEnum thePrecision) {
|
public BaseDateTimeDt(Date theDate, TemporalPrecisionEnum thePrecision) {
|
||||||
setValue(theDate, thePrecision);
|
setValue(theDate, thePrecision);
|
||||||
if (isPrecisionAllowed(thePrecision) == false) {
|
if (isPrecisionAllowed(thePrecision) == false) {
|
||||||
throw new DataFormatException("Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + thePrecision + " precision): " + theDate);
|
throw new DataFormatException(Msg.code(1880) + "Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + thePrecision + " precision): " + theDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +550,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
||||||
*/
|
*/
|
||||||
public BaseDateTimeDt setPrecision(TemporalPrecisionEnum thePrecision) throws DataFormatException {
|
public BaseDateTimeDt setPrecision(TemporalPrecisionEnum thePrecision) throws DataFormatException {
|
||||||
if (thePrecision == null) {
|
if (thePrecision == null) {
|
||||||
throw new NullPointerException("Precision may not be null");
|
throw new NullPointerException(Msg.code(1881) + "Precision may not be null");
|
||||||
}
|
}
|
||||||
myPrecision = thePrecision;
|
myPrecision = thePrecision;
|
||||||
updateStringValue();
|
updateStringValue();
|
||||||
|
@ -664,11 +665,11 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void throwBadDateFormat(String theValue) {
|
private void throwBadDateFormat(String theValue) {
|
||||||
throw new DataFormatException("Invalid date/time format: \"" + theValue + "\"");
|
throw new DataFormatException(Msg.code(1882) + "Invalid date/time format: \"" + theValue + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void throwBadDateFormat(String theValue, String theMesssage) {
|
private void throwBadDateFormat(String theValue, String theMesssage) {
|
||||||
throw new DataFormatException("Invalid date/time format: \"" + theValue + "\": " + theMesssage);
|
throw new DataFormatException(Msg.code(1883) + "Invalid date/time format: \"" + theValue + "\": " + theMesssage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -731,13 +732,13 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
||||||
|
|
||||||
private void validateValueInRange(long theValue, long theMinimum, long theMaximum) {
|
private void validateValueInRange(long theValue, long theMinimum, long theMaximum) {
|
||||||
if (theValue < theMinimum || theValue > theMaximum) {
|
if (theValue < theMinimum || theValue > theMaximum) {
|
||||||
throw new IllegalArgumentException("Value " + theValue + " is not between allowable range: " + theMinimum + " - " + theMaximum);
|
throw new IllegalArgumentException(Msg.code(1884) + "Value " + theValue + " is not between allowable range: " + theMinimum + " - " + theMaximum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validatePrecisionAndThrowDataFormatException(String theValue, TemporalPrecisionEnum thePrecision) {
|
private void validatePrecisionAndThrowDataFormatException(String theValue, TemporalPrecisionEnum thePrecision) {
|
||||||
if (isPrecisionAllowed(thePrecision) == false) {
|
if (isPrecisionAllowed(thePrecision) == false) {
|
||||||
throw new DataFormatException("Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + thePrecision + " precision): " + theValue);
|
throw new DataFormatException(Msg.code(1885) + "Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + thePrecision + " precision): " + theValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,12 @@ package ca.uhn.fhir.model.primitive;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseBooleanDatatype;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseBooleanDatatype;
|
||||||
|
|
||||||
@DatatypeDef(name = "boolean")
|
@DatatypeDef(name = "boolean")
|
||||||
public class BooleanDt extends BasePrimitive<Boolean> implements IBaseBooleanDatatype {
|
public class BooleanDt extends BasePrimitive<Boolean> implements IBaseBooleanDatatype {
|
||||||
|
@ -52,7 +52,7 @@ public class BooleanDt extends BasePrimitive<Boolean> implements IBaseBooleanDat
|
||||||
} else if ("false".equals(theValue)) {
|
} else if ("false".equals(theValue)) {
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
} else {
|
} else {
|
||||||
throw new DataFormatException("Invalid boolean string: '" + theValue + "'");
|
throw new DataFormatException(Msg.code(1872) + "Invalid boolean string: '" + theValue + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ca.uhn.fhir.model.primitive;
|
package ca.uhn.fhir.model.primitive;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||||
|
@ -192,13 +193,13 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
|
||||||
@Override
|
@Override
|
||||||
public void applyTo(IBaseResource theResouce) {
|
public void applyTo(IBaseResource theResouce) {
|
||||||
if (theResouce == null) {
|
if (theResouce == null) {
|
||||||
throw new NullPointerException("theResource can not be null");
|
throw new NullPointerException(Msg.code(1875) + "theResource can not be null");
|
||||||
} else if (theResouce instanceof IResource) {
|
} else if (theResouce instanceof IResource) {
|
||||||
((IResource) theResouce).setId(new IdDt(getValue()));
|
((IResource) theResouce).setId(new IdDt(getValue()));
|
||||||
} else if (theResouce instanceof IAnyResource) {
|
} else if (theResouce instanceof IAnyResource) {
|
||||||
((IAnyResource) theResouce).setId(getValue());
|
((IAnyResource) theResouce).setId(getValue());
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown resource class type, does not implement IResource or extend Resource");
|
throw new IllegalArgumentException(Msg.code(1876) + "Unknown resource class type, does not implement IResource or extend Resource");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,7 +687,7 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
|
||||||
*/
|
*/
|
||||||
public static IdDt of(IBaseResource theResouce) {
|
public static IdDt of(IBaseResource theResouce) {
|
||||||
if (theResouce == null) {
|
if (theResouce == null) {
|
||||||
throw new NullPointerException("theResource can not be null");
|
throw new NullPointerException(Msg.code(1877) + "theResource can not be null");
|
||||||
}
|
}
|
||||||
IIdType retVal = theResouce.getIdElement();
|
IIdType retVal = theResouce.getIdElement();
|
||||||
if (retVal == null) {
|
if (retVal == null) {
|
||||||
|
@ -700,14 +701,14 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
|
||||||
|
|
||||||
private static String toPlainStringWithNpeThrowIfNeeded(BigDecimal theIdPart) {
|
private static String toPlainStringWithNpeThrowIfNeeded(BigDecimal theIdPart) {
|
||||||
if (theIdPart == null) {
|
if (theIdPart == null) {
|
||||||
throw new NullPointerException("BigDecimal ID can not be null");
|
throw new NullPointerException(Msg.code(1878) + "BigDecimal ID can not be null");
|
||||||
}
|
}
|
||||||
return theIdPart.toPlainString();
|
return theIdPart.toPlainString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String toPlainStringWithNpeThrowIfNeeded(Long theIdPart) {
|
private static String toPlainStringWithNpeThrowIfNeeded(Long theIdPart) {
|
||||||
if (theIdPart == null) {
|
if (theIdPart == null) {
|
||||||
throw new NullPointerException("Long ID can not be null");
|
throw new NullPointerException(Msg.code(1879) + "Long ID can not be null");
|
||||||
}
|
}
|
||||||
return theIdPart.toString();
|
return theIdPart.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ package ca.uhn.fhir.model.primitive;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseIntegerDatatype;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseIntegerDatatype;
|
||||||
|
|
||||||
@DatatypeDef(name = "integer")
|
@DatatypeDef(name = "integer")
|
||||||
public class IntegerDt extends BasePrimitive<Integer> implements IBaseIntegerDatatype {
|
public class IntegerDt extends BasePrimitive<Integer> implements IBaseIntegerDatatype {
|
||||||
|
@ -62,7 +62,7 @@ public class IntegerDt extends BasePrimitive<Integer> implements IBaseIntegerDat
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(theValue);
|
return Integer.parseInt(theValue);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new DataFormatException(e);
|
throw new DataFormatException(Msg.code(1873) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,14 @@ package ca.uhn.fhir.model.primitive;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||||
import ca.uhn.fhir.rest.param.StringParam;
|
import ca.uhn.fhir.rest.param.StringParam;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@DatatypeDef(name = "string")
|
@DatatypeDef(name = "string")
|
||||||
public class StringDt extends BasePrimitive<String> implements IQueryParameterType {
|
public class StringDt extends BasePrimitive<String> implements IQueryParameterType {
|
||||||
|
@ -145,7 +145,7 @@ public class StringDt extends BasePrimitive<String> implements IQueryParameterTy
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public IQueryParameterType setMissing(Boolean theMissing) {
|
public IQueryParameterType setMissing(Boolean theMissing) {
|
||||||
throw new UnsupportedOperationException("get/setMissing is not supported in StringDt. Use {@link StringParam} instead if you need this functionality");
|
throw new UnsupportedOperationException(Msg.code(1874) + "get/setMissing is not supported in StringDt. Use {@link StringParam} instead if you need this functionality");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,18 @@ package ca.uhn.fhir.model.view;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.*;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
import org.hl7.fhir.instance.model.api.*;
|
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildDeclaredExtensionDefinition;
|
||||||
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -48,7 +58,7 @@ public class ViewGenerator {
|
||||||
try {
|
try {
|
||||||
retVal = theTargetType.newInstance();
|
retVal = theTargetType.newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException("Failed to instantiate " + theTargetType, e);
|
throw new ConfigurationException(Msg.code(1886) + "Failed to instantiate " + theTargetType, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyChildren(sourceDef, (IBase) theResource, targetDef, (IBase) retVal);
|
copyChildren(sourceDef, (IBase) theResource, targetDef, (IBase) retVal);
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.narrative;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.narrative2.NarrativeTemplateManifest;
|
import ca.uhn.fhir.narrative2.NarrativeTemplateManifest;
|
||||||
import ca.uhn.fhir.narrative2.ThymeleafNarrativeGenerator;
|
import ca.uhn.fhir.narrative2.ThymeleafNarrativeGenerator;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
|
@ -61,7 +62,7 @@ public abstract class BaseThymeleafNarrativeGenerator extends ThymeleafNarrative
|
||||||
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(propFileName);
|
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(propFileName);
|
||||||
setManifest(manifest);
|
setManifest(manifest);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1808) + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
myInitialized = true;
|
myInitialized = true;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||||
import ca.uhn.fhir.fhirpath.IFhirPath;
|
import ca.uhn.fhir.fhirpath.IFhirPath;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.narrative.INarrativeGenerator;
|
import ca.uhn.fhir.narrative.INarrativeGenerator;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
@ -94,7 +95,7 @@ public abstract class BaseNarrativeGenerator implements INarrativeGenerator {
|
||||||
nextTargetNarrative.setStatusAsString("generated");
|
nextTargetNarrative.setStatusAsString("generated");
|
||||||
retVal = true;
|
retVal = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1865) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.narrative2;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ public class NarrativeTemplate implements INarrativeTemplate {
|
||||||
try {
|
try {
|
||||||
return NarrativeTemplateManifest.loadResource(getTemplateFileName());
|
return NarrativeTemplateManifest.loadResource(getTemplateFileName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1866) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ package ca.uhn.fhir.narrative2;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
@ -163,7 +164,7 @@ public class NarrativeTemplateManifest implements INarrativeTemplateManifest {
|
||||||
try {
|
try {
|
||||||
nextTemplate.addAppliesToClass((Class<? extends IBase>) Class.forName(className));
|
nextTemplate.addAppliesToClass((Class<? extends IBase>) Class.forName(className));
|
||||||
} catch (ClassNotFoundException theE) {
|
} catch (ClassNotFoundException theE) {
|
||||||
throw new InternalErrorException("Could not find class " + className + " declared in narative manifest");
|
throw new InternalErrorException(Msg.code(1867) + "Could not find class " + className + " declared in narative manifest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (nextKey.endsWith(".profile")) {
|
} else if (nextKey.endsWith(".profile")) {
|
||||||
|
@ -201,7 +202,7 @@ public class NarrativeTemplateManifest implements INarrativeTemplateManifest {
|
||||||
} else if (nextKey.endsWith(".title")) {
|
} else if (nextKey.endsWith(".title")) {
|
||||||
ourLog.debug("Ignoring title property as narrative generator no longer generates titles: {}", nextKey);
|
ourLog.debug("Ignoring title property as narrative generator no longer generates titles: {}", nextKey);
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationException("Invalid property name: " + nextKey
|
throw new ConfigurationException(Msg.code(1868) + "Invalid property name: " + nextKey
|
||||||
+ " - the key must end in one of the expected extensions "
|
+ " - the key must end in one of the expected extensions "
|
||||||
+ "'.profile', '.resourceType', '.dataType', '.style', '.contextPath', '.narrative', '.title'");
|
+ "'.profile', '.resourceType', '.dataType', '.style', '.contextPath', '.narrative', '.title'");
|
||||||
}
|
}
|
||||||
|
@ -218,7 +219,7 @@ public class NarrativeTemplateManifest implements INarrativeTemplateManifest {
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
try (InputStream resource2 = DefaultThymeleafNarrativeGenerator.class.getResourceAsStream("/" + cpName)) {
|
try (InputStream resource2 = DefaultThymeleafNarrativeGenerator.class.getResourceAsStream("/" + cpName)) {
|
||||||
if (resource2 == null) {
|
if (resource2 == null) {
|
||||||
throw new IOException("Can not find '" + cpName + "' on classpath");
|
throw new IOException(Msg.code(1869) + "Can not find '" + cpName + "' on classpath");
|
||||||
}
|
}
|
||||||
return IOUtils.toString(resource2, Charsets.UTF_8);
|
return IOUtils.toString(resource2, Charsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
@ -228,13 +229,13 @@ public class NarrativeTemplateManifest implements INarrativeTemplateManifest {
|
||||||
} else if (name.startsWith("file:")) {
|
} else if (name.startsWith("file:")) {
|
||||||
File file = new File(name.substring("file:".length()));
|
File file = new File(name.substring("file:".length()));
|
||||||
if (file.exists() == false) {
|
if (file.exists() == false) {
|
||||||
throw new IOException("File not found: " + file.getAbsolutePath());
|
throw new IOException(Msg.code(1870) + "File not found: " + file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
try (FileInputStream inputStream = new FileInputStream(file)) {
|
try (FileInputStream inputStream = new FileInputStream(file)) {
|
||||||
return IOUtils.toString(inputStream, Charsets.UTF_8);
|
return IOUtils.toString(inputStream, Charsets.UTF_8);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Invalid resource name: '" + name + "' (must start with classpath: or file: )");
|
throw new IOException(Msg.code(1871) + "Invalid resource name: '" + name + "' (must start with classpath: or file: )");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.narrative2;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.thymeleaf.IEngineConfiguration;
|
import org.thymeleaf.IEngineConfiguration;
|
||||||
|
@ -45,7 +46,10 @@ import org.thymeleaf.templateresolver.DefaultTemplateResolver;
|
||||||
import org.thymeleaf.templateresource.ITemplateResource;
|
import org.thymeleaf.templateresource.ITemplateResource;
|
||||||
import org.thymeleaf.templateresource.StringTemplateResource;
|
import org.thymeleaf.templateresource.StringTemplateResource;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
|
@ -113,12 +117,12 @@ public class ThymeleafNarrativeGenerator extends BaseNarrativeGenerator {
|
||||||
if (isNotBlank(theName)) {
|
if (isNotBlank(theName)) {
|
||||||
templateOpt = getManifest().getTemplateByName(theFhirContext, getStyle(), theName);
|
templateOpt = getManifest().getTemplateByName(theFhirContext, getStyle(), theName);
|
||||||
if (templateOpt.isEmpty()) {
|
if (templateOpt.isEmpty()) {
|
||||||
throw new InternalErrorException("Unknown template name: " + theName);
|
throw new InternalErrorException(Msg.code(1863) + "Unknown template name: " + theName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
templateOpt = getManifest().getTemplateByElement(theFhirContext, getStyle(), elementValue);
|
templateOpt = getManifest().getTemplateByElement(theFhirContext, getStyle(), elementValue);
|
||||||
if (templateOpt.isEmpty()) {
|
if (templateOpt.isEmpty()) {
|
||||||
throw new InternalErrorException("No template for type: " + elementValue.getClass());
|
throw new InternalErrorException(Msg.code(1864) + "No template for type: " + elementValue.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import ca.uhn.fhir.context.RuntimeChildChoiceDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeChildContainedResources;
|
import ca.uhn.fhir.context.RuntimeChildContainedResources;
|
||||||
import ca.uhn.fhir.context.RuntimeChildNarrativeDefinition;
|
import ca.uhn.fhir.context.RuntimeChildNarrativeDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
|
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
|
||||||
|
@ -66,7 +67,6 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -273,7 +273,7 @@ public abstract class BaseParser implements IParser {
|
||||||
try {
|
try {
|
||||||
encodeResourceToWriter(theResource, stringWriter);
|
encodeResourceToWriter(theResource, stringWriter);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new Error("Encountered IOException during write to string - This should not happen!");
|
throw new Error(Msg.code(1828) + "Encountered IOException during write to string - This should not happen!");
|
||||||
}
|
}
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
}
|
}
|
||||||
|
@ -291,8 +291,7 @@ public abstract class BaseParser implements IParser {
|
||||||
Validate.notNull(theEncodeContext, "theEncodeContext can not be null");
|
Validate.notNull(theEncodeContext, "theEncodeContext can not be null");
|
||||||
|
|
||||||
if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) {
|
if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(Msg.code(1829) + "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum());
|
||||||
"This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String resourceName = myContext.getResourceType(theResource);
|
String resourceName = myContext.getResourceType(theResource);
|
||||||
|
@ -685,7 +684,7 @@ public abstract class BaseParser implements IParser {
|
||||||
try {
|
try {
|
||||||
metaValue = (IBaseMetaType) metaValue.getClass().getMethod("copy").invoke(metaValue);
|
metaValue = (IBaseMetaType) metaValue.getClass().getMethod("copy").invoke(metaValue);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new InternalErrorException("Failed to duplicate meta", e);
|
throw new InternalErrorException(Msg.code(1830) + "Failed to duplicate meta", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBlank(metaValue.getVersionId())) {
|
if (isBlank(metaValue.getVersionId())) {
|
||||||
|
@ -897,9 +896,9 @@ public abstract class BaseParser implements IParser {
|
||||||
RuntimeChildChoiceDefinition choice = (RuntimeChildChoiceDefinition) nextChild;
|
RuntimeChildChoiceDefinition choice = (RuntimeChildChoiceDefinition) nextChild;
|
||||||
b.append(" - Expected one of: " + choice.getValidChildTypes());
|
b.append(" - Expected one of: " + choice.getValidChildTypes());
|
||||||
}
|
}
|
||||||
throw new DataFormatException(b.toString());
|
throw new DataFormatException(Msg.code(1831) + b.toString());
|
||||||
}
|
}
|
||||||
throw new DataFormatException(nextChild + " has no child of type " + theType);
|
throw new DataFormatException(Msg.code(1832) + nextChild + " has no child of type " + theType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldEncodeResource(String theName) {
|
protected boolean shouldEncodeResource(String theName) {
|
||||||
|
|
|
@ -20,8 +20,18 @@ package ca.uhn.fhir.parser;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.*;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum;
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum;
|
||||||
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildContainedResources;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildDeclaredExtensionDefinition;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildNarrativeDefinition;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildUndeclaredExtensionDefinition;
|
||||||
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
@ -45,11 +55,21 @@ import ca.uhn.fhir.parser.json.JsonLikeWriter;
|
||||||
import ca.uhn.fhir.parser.json.jackson.JacksonStructure;
|
import ca.uhn.fhir.parser.json.jackson.JacksonStructure;
|
||||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||||
import ca.uhn.fhir.util.ElementUtil;
|
import ca.uhn.fhir.util.ElementUtil;
|
||||||
import ca.uhn.fhir.util.FhirTerser;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.apache.commons.text.WordUtils;
|
import org.apache.commons.text.WordUtils;
|
||||||
import org.hl7.fhir.instance.model.api.*;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseBooleanDatatype;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseDecimalDatatype;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseIntegerDatatype;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
import org.hl7.fhir.instance.model.api.INarrative;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
@ -60,7 +80,6 @@ import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.ID_DATATYPE;
|
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.ID_DATATYPE;
|
||||||
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.PRIMITIVE_DATATYPE;
|
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.PRIMITIVE_DATATYPE;
|
||||||
|
@ -150,11 +169,11 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||||
|
|
||||||
// private void assertObjectOfType(JsonLikeValue theResourceTypeObj, Object theValueType, String thePosition) {
|
// private void assertObjectOfType(JsonLikeValue theResourceTypeObj, Object theValueType, String thePosition) {
|
||||||
// if (theResourceTypeObj == null) {
|
// if (theResourceTypeObj == null) {
|
||||||
// throw new DataFormatException("Invalid JSON content detected, missing required element: '" + thePosition + "'");
|
// throw new DataFormatException(Msg.code(1836) + "Invalid JSON content detected, missing required element: '" + thePosition + "'");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (theResourceTypeObj.getValueType() != theValueType) {
|
// if (theResourceTypeObj.getValueType() != theValueType) {
|
||||||
// throw new DataFormatException("Invalid content of element " + thePosition + ", expected " + theValueType);
|
// throw new DataFormatException(Msg.code(1837) + "Invalid content of element " + thePosition + ", expected " + theValueType);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -204,7 +223,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||||
|
|
||||||
JsonLikeValue resourceTypeObj = object.get("resourceType");
|
JsonLikeValue resourceTypeObj = object.get("resourceType");
|
||||||
if (resourceTypeObj == null || !resourceTypeObj.isString() || isBlank(resourceTypeObj.getAsString())) {
|
if (resourceTypeObj == null || !resourceTypeObj.isString() || isBlank(resourceTypeObj.getAsString())) {
|
||||||
throw new DataFormatException("Invalid JSON content detected, missing required element: 'resourceType'");
|
throw new DataFormatException(Msg.code(1838) + "Invalid JSON content detected, missing required element: 'resourceType'");
|
||||||
}
|
}
|
||||||
|
|
||||||
String resourceType = resourceTypeObj.getAsString();
|
String resourceType = resourceTypeObj.getAsString();
|
||||||
|
@ -364,7 +383,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||||
break;
|
break;
|
||||||
case UNDECL_EXT:
|
case UNDECL_EXT:
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Should not have this state here: " + theChildDef.getChildType().name());
|
throw new IllegalStateException(Msg.code(1839) + "Should not have this state here: " + theChildDef.getChildType().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -621,8 +640,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||||
Validate.notNull(theJsonLikeWriter, "theJsonLikeWriter can not be null");
|
Validate.notNull(theJsonLikeWriter, "theJsonLikeWriter can not be null");
|
||||||
|
|
||||||
if (theResource.getStructureFhirVersionEnum() != getContext().getVersion().getVersion()) {
|
if (theResource.getStructureFhirVersionEnum() != getContext().getVersion().getVersion()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(Msg.code(1840) + "This parser is for FHIR version " + getContext().getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum());
|
||||||
"This parser is for FHIR version " + getContext().getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EncodeContext encodeContext = new EncodeContext();
|
EncodeContext encodeContext = new EncodeContext();
|
||||||
|
@ -911,7 +929,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!object.isArray()) {
|
if (!object.isArray()) {
|
||||||
throw new DataFormatException("Syntax error parsing JSON FHIR structure: Expected ARRAY at element '" + thePosition + "', found '" + object.getJsonType() + "'");
|
throw new DataFormatException(Msg.code(1841) + "Syntax error parsing JSON FHIR structure: Expected ARRAY at element '" + thePosition + "', found '" + object.getJsonType() + "'");
|
||||||
}
|
}
|
||||||
return object.getAsArray();
|
return object.getAsArray();
|
||||||
}
|
}
|
||||||
|
@ -924,7 +942,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||||
if (theAlternateVal.isArray()) {
|
if (theAlternateVal.isArray()) {
|
||||||
JsonLikeArray array = theAlternateVal.getAsArray();
|
JsonLikeArray array = theAlternateVal.getAsArray();
|
||||||
if (array.size() > 1) {
|
if (array.size() > 1) {
|
||||||
throw new DataFormatException("Unexpected array of length " + array.size() + " (expected 0 or 1) for element: " + theElementName);
|
throw new DataFormatException(Msg.code(1842) + "Unexpected array of length " + array.size() + " (expected 0 or 1) for element: " + theElementName);
|
||||||
}
|
}
|
||||||
if (array.size() == 0) {
|
if (array.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -1074,7 +1092,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||||
if (theState.isPreResource()) {
|
if (theState.isPreResource()) {
|
||||||
JsonLikeValue resType = nextObject.get("resourceType");
|
JsonLikeValue resType = nextObject.get("resourceType");
|
||||||
if (resType == null || !resType.isString()) {
|
if (resType == null || !resType.isString()) {
|
||||||
throw new DataFormatException("Missing required element 'resourceType' from JSON resource object, unable to parse");
|
throw new DataFormatException(Msg.code(1843) + "Missing required element 'resourceType' from JSON resource object, unable to parse");
|
||||||
}
|
}
|
||||||
theState.enteringNewElement(null, resType.getAsString());
|
theState.enteringNewElement(null, resType.getAsString());
|
||||||
preResource = true;
|
preResource = true;
|
||||||
|
@ -1532,7 +1550,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
||||||
}
|
}
|
||||||
BaseRuntimeElementDefinition<?> childDef = extDef.getChildElementDefinitionByDatatype(value.getClass());
|
BaseRuntimeElementDefinition<?> childDef = extDef.getChildElementDefinitionByDatatype(value.getClass());
|
||||||
if (childDef == null) {
|
if (childDef == null) {
|
||||||
throw new ConfigurationException("Unable to encode extension, unrecognized child element type: " + value.getClass().getCanonicalName());
|
throw new ConfigurationException(Msg.code(1844) + "Unable to encode extension, unrecognized child element type: " + value.getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, value, childDef, childName, false, myParent, false, theEncodeContext);
|
encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, value, childDef, childName, false, myParent, false, theEncodeContext);
|
||||||
managePrimitiveExtension(value, theResDef, theResource, theEventWriter, childDef, childName, theEncodeContext, theContainedResource);
|
managePrimitiveExtension(value, theResDef, theResource, theEventWriter, childDef, childName, theEncodeContext, theContainedResource);
|
||||||
|
|
|
@ -20,14 +20,16 @@ package ca.uhn.fhir.parser;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.*;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||||
import ca.uhn.fhir.util.BundleBuilder;
|
import ca.uhn.fhir.util.BundleBuilder;
|
||||||
import ca.uhn.fhir.util.BundleUtil;
|
import ca.uhn.fhir.util.BundleUtil;
|
||||||
import org.hl7.fhir.instance.model.api.*;
|
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -72,7 +74,7 @@ public class NDJsonParser extends BaseParser {
|
||||||
protected void doEncodeResourceToWriter(IBaseResource theResource, Writer theWriter, EncodeContext theEncodeContext) throws IOException {
|
protected void doEncodeResourceToWriter(IBaseResource theResource, Writer theWriter, EncodeContext theEncodeContext) throws IOException {
|
||||||
// We only encode bundles to NDJSON.
|
// We only encode bundles to NDJSON.
|
||||||
if (!(IBaseBundle.class.isAssignableFrom(theResource.getClass()))) {
|
if (!(IBaseBundle.class.isAssignableFrom(theResource.getClass()))) {
|
||||||
throw new IllegalArgumentException("NDJsonParser can only encode Bundle types. Received " + theResource.getClass().getName());
|
throw new IllegalArgumentException(Msg.code(1833) + "NDJsonParser can only encode Bundle types. Received " + theResource.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, convert the bundle to a list of resources.
|
// Ok, convert the bundle to a list of resources.
|
||||||
|
@ -95,7 +97,7 @@ public class NDJsonParser extends BaseParser {
|
||||||
public <T extends IBaseResource> T doParseResource(Class<T> theResourceType, Reader theReader) throws DataFormatException {
|
public <T extends IBaseResource> T doParseResource(Class<T> theResourceType, Reader theReader) throws DataFormatException {
|
||||||
// We can only parse to bundles.
|
// We can only parse to bundles.
|
||||||
if ((theResourceType != null) && (!(IBaseBundle.class.isAssignableFrom(theResourceType)))) {
|
if ((theResourceType != null) && (!(IBaseBundle.class.isAssignableFrom(theResourceType)))) {
|
||||||
throw new DataFormatException("NDJsonParser can only parse to Bundle types. Received " + theResourceType.getName());
|
throw new DataFormatException(Msg.code(1834) + "NDJsonParser can only parse to Bundle types. Received " + theResourceType.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -114,7 +116,7 @@ public class NDJsonParser extends BaseParser {
|
||||||
|
|
||||||
return (T) myBuilder.getBundle();
|
return (T) myBuilder.getBundle();
|
||||||
} catch (IOException err) {
|
} catch (IOException err) {
|
||||||
throw new DataFormatException(err.getMessage());
|
throw new DataFormatException(Msg.code(1835) + err.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import ca.uhn.fhir.context.RuntimePrimitiveDatatypeNarrativeDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimePrimitiveDatatypeXhtmlHl7OrgDefinition;
|
import ca.uhn.fhir.context.RuntimePrimitiveDatatypeXhtmlHl7OrgDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceBlockDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceBlockDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
||||||
|
@ -593,7 +594,7 @@ class ParserState<T> {
|
||||||
BaseRuntimeElementDefinition<?> target = child.getChildByName(theChildName);
|
BaseRuntimeElementDefinition<?> target = child.getChildByName(theChildName);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
// This is a bug with the structures and shouldn't happen..
|
// This is a bug with the structures and shouldn't happen..
|
||||||
throw new DataFormatException("Found unexpected element '" + theChildName + "' in parent element '" + myDefinition.getName() + "'. Valid names are: " + child.getValidChildNames());
|
throw new DataFormatException(Msg.code(1809) + "Found unexpected element '" + theChildName + "' in parent element '" + myDefinition.getName() + "'. Valid names are: " + child.getValidChildNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (target.getChildType()) {
|
switch (target.getChildType()) {
|
||||||
|
@ -671,7 +672,7 @@ class ParserState<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new DataFormatException("Illegal resource position: " + target.getChildType());
|
throw new DataFormatException(Msg.code(1810) + "Illegal resource position: " + target.getChildType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -744,7 +745,7 @@ class ParserState<T> {
|
||||||
@Override
|
@Override
|
||||||
public void endingElement() throws DataFormatException {
|
public void endingElement() throws DataFormatException {
|
||||||
if (myExtension.getValue() != null && myExtension.getExtension().size() > 0) {
|
if (myExtension.getValue() != null && myExtension.getExtension().size() > 0) {
|
||||||
throw new DataFormatException("Extension (URL='" + myExtension.getUrl() + "') must not have both a value and other contained extensions");
|
throw new DataFormatException(Msg.code(1811) + "Extension (URL='" + myExtension.getUrl() + "') must not have both a value and other contained extensions");
|
||||||
}
|
}
|
||||||
pop();
|
pop();
|
||||||
}
|
}
|
||||||
|
@ -904,7 +905,7 @@ class ParserState<T> {
|
||||||
} else if (metadataValue instanceof ExtensionDt) {
|
} else if (metadataValue instanceof ExtensionDt) {
|
||||||
newExtension = (ExtensionDt) metadataValue;
|
newExtension = (ExtensionDt) metadataValue;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Expected ExtensionDt as custom resource metadata type, got: " + metadataValue.getClass().getSimpleName());
|
throw new IllegalStateException(Msg.code(1812) + "Expected ExtensionDt as custom resource metadata type, got: " + metadataValue.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
newExtension.setUrl(theUrlAttr);
|
newExtension.setUrl(theUrlAttr);
|
||||||
myMap.put(resourceMetadataKeyEnum, newExtension);
|
myMap.put(resourceMetadataKeyEnum, newExtension);
|
||||||
|
@ -994,18 +995,18 @@ class ParserState<T> {
|
||||||
definition = myContext.getResourceDefinition(myParentVersion, theLocalPart);
|
definition = myContext.getResourceDefinition(myParentVersion, theLocalPart);
|
||||||
}
|
}
|
||||||
if ((definition == null)) {
|
if ((definition == null)) {
|
||||||
throw new DataFormatException("Element '" + theLocalPart + "' is not a known resource type, expected a resource at this position");
|
throw new DataFormatException(Msg.code(1813) + "Element '" + theLocalPart + "' is not a known resource type, expected a resource at this position");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
definition = myContext.getResourceDefinition(myResourceType);
|
definition = myContext.getResourceDefinition(myResourceType);
|
||||||
if (!StringUtils.equals(theLocalPart, definition.getName())) {
|
if (!StringUtils.equals(theLocalPart, definition.getName())) {
|
||||||
throw new DataFormatException(myContext.getLocalizer().getMessage(ParserState.class, "wrongResourceTypeFound", definition.getName(), theLocalPart));
|
throw new DataFormatException(Msg.code(1814) + myContext.getLocalizer().getMessage(ParserState.class, "wrongResourceTypeFound", definition.getName(), theLocalPart));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeResourceDefinition def = definition;
|
RuntimeResourceDefinition def = definition;
|
||||||
if (!definition.getName().equals(theLocalPart) && definition.getName().equalsIgnoreCase(theLocalPart)) {
|
if (!definition.getName().equals(theLocalPart) && definition.getName().equalsIgnoreCase(theLocalPart)) {
|
||||||
throw new DataFormatException("Unknown resource type '" + theLocalPart + "': Resource names are case sensitive, found similar name: '" + definition.getName() + "'");
|
throw new DataFormatException(Msg.code(1815) + "Unknown resource type '" + theLocalPart + "': Resource names are case sensitive, found similar name: '" + definition.getName() + "'");
|
||||||
}
|
}
|
||||||
myInstance = newInstance(def);
|
myInstance = newInstance(def);
|
||||||
|
|
||||||
|
@ -1283,7 +1284,7 @@ class ParserState<T> {
|
||||||
@Override
|
@Override
|
||||||
public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
|
public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
|
||||||
if (!TagList.ELEMENT_NAME_LC.equals(theLocalPart.toLowerCase())) {
|
if (!TagList.ELEMENT_NAME_LC.equals(theLocalPart.toLowerCase())) {
|
||||||
throw new DataFormatException("resourceType does not appear to be 'TagList', found: " + theLocalPart);
|
throw new DataFormatException(Msg.code(1816) + "resourceType does not appear to be 'TagList', found: " + theLocalPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
push(new TagListState(myTagList));
|
push(new TagListState(myTagList));
|
||||||
|
@ -1474,7 +1475,7 @@ class ParserState<T> {
|
||||||
if (TagList.ATTR_CATEGORY.equals(theLocalPart)) {
|
if (TagList.ATTR_CATEGORY.equals(theLocalPart)) {
|
||||||
push(new TagState(myTagList));
|
push(new TagState(myTagList));
|
||||||
} else {
|
} else {
|
||||||
throw new DataFormatException("Unexpected element: " + theLocalPart);
|
throw new DataFormatException(Msg.code(1817) + "Unexpected element: " + theLocalPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1550,7 +1551,7 @@ class ParserState<T> {
|
||||||
} else if (Tag.ATTR_LABEL.equals(theLocalPart) || "display".equals(theLocalPart)) {
|
} else if (Tag.ATTR_LABEL.equals(theLocalPart) || "display".equals(theLocalPart)) {
|
||||||
mySubState = LABEL;
|
mySubState = LABEL;
|
||||||
} else {
|
} else {
|
||||||
throw new DataFormatException("Unexpected element: " + theLocalPart);
|
throw new DataFormatException(Msg.code(1818) + "Unexpected element: " + theLocalPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,17 @@ package ca.uhn.fhir.parser;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.*;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition;
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildContainedResources;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildDirectResource;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildExtension;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildNarrativeDefinition;
|
||||||
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.narrative.INarrativeGenerator;
|
import ca.uhn.fhir.narrative.INarrativeGenerator;
|
||||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||||
|
@ -28,17 +38,40 @@ import ca.uhn.fhir.util.rdf.RDFUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.jena.datatypes.xsd.XSDDatatype;
|
import org.apache.jena.datatypes.xsd.XSDDatatype;
|
||||||
import org.apache.jena.irix.IRIs;
|
import org.apache.jena.irix.IRIs;
|
||||||
import org.apache.jena.irix.SetupJenaIRI;
|
import org.apache.jena.rdf.model.Literal;
|
||||||
import org.apache.jena.rdf.model.*;
|
import org.apache.jena.rdf.model.Model;
|
||||||
|
import org.apache.jena.rdf.model.RDFNode;
|
||||||
|
import org.apache.jena.rdf.model.Resource;
|
||||||
|
import org.apache.jena.rdf.model.Statement;
|
||||||
|
import org.apache.jena.rdf.model.StmtIterator;
|
||||||
import org.apache.jena.riot.Lang;
|
import org.apache.jena.riot.Lang;
|
||||||
import org.apache.jena.riot.system.IRIResolver;
|
|
||||||
import org.apache.jena.vocabulary.RDF;
|
import org.apache.jena.vocabulary.RDF;
|
||||||
import org.hl7.fhir.instance.model.api.*;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseElement;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseXhtml;
|
||||||
|
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
import org.hl7.fhir.instance.model.api.INarrative;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.Reader;
|
||||||
import java.util.*;
|
import java.io.Writer;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.*;
|
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.ID_DATATYPE;
|
||||||
|
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.PRIMITIVE_DATATYPE;
|
||||||
|
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.PRIMITIVE_XHTML;
|
||||||
|
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.PRIMITIVE_XHTML_HL7ORG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the FHIR RDF parser/encoder. Users should not interact with this class directly, but should use
|
* This class is the FHIR RDF parser/encoder. Users should not interact with this class directly, but should use
|
||||||
|
@ -150,7 +183,7 @@ public class RDFParser extends BaseParser {
|
||||||
|
|
||||||
RuntimeResourceDefinition resDef = getContext().getResourceDefinition(resource);
|
RuntimeResourceDefinition resDef = getContext().getResourceDefinition(resource);
|
||||||
if (resDef == null) {
|
if (resDef == null) {
|
||||||
throw new ConfigurationException("Unknown resource type: " + resource.getClass());
|
throw new ConfigurationException(Msg.code(1845) + "Unknown resource type: " + resource.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!containedResource) {
|
if (!containedResource) {
|
||||||
|
@ -158,7 +191,7 @@ public class RDFParser extends BaseParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(resource instanceof IAnyResource)) {
|
if (!(resource instanceof IAnyResource)) {
|
||||||
throw new IllegalStateException("Unsupported resource found: " + resource.getClass().getName());
|
throw new IllegalStateException(Msg.code(1846) + "Unsupported resource found: " + resource.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create absolute IRI for the resource
|
// Create absolute IRI for the resource
|
||||||
|
@ -399,7 +432,7 @@ public class RDFParser extends BaseParser {
|
||||||
case EXTENSION_DECLARED:
|
case EXTENSION_DECLARED:
|
||||||
case UNDECL_EXT:
|
case UNDECL_EXT:
|
||||||
default: {
|
default: {
|
||||||
throw new IllegalStateException("Unexpected node - should not happen: " + childDef.getName());
|
throw new IllegalStateException(Msg.code(1847) + "Unexpected node - should not happen: " + childDef.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ca.uhn.fhir.parser;
|
package ca.uhn.fhir.parser;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.parser.json.JsonLikeValue.ScalarType;
|
import ca.uhn.fhir.parser.json.JsonLikeValue.ScalarType;
|
||||||
import ca.uhn.fhir.parser.json.JsonLikeValue.ValueType;
|
import ca.uhn.fhir.parser.json.JsonLikeValue.ValueType;
|
||||||
import ca.uhn.fhir.util.UrlUtil;
|
import ca.uhn.fhir.util.UrlUtil;
|
||||||
|
@ -36,18 +37,18 @@ public class StrictErrorHandler extends BaseErrorHandler implements IParserError
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void containedResourceWithNoId(IParseLocation theLocation) {
|
public void containedResourceWithNoId(IParseLocation theLocation) {
|
||||||
throw new DataFormatException("Resource has contained child resource with no ID");
|
throw new DataFormatException(Msg.code(1819) + "Resource has contained child resource with no ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incorrectJsonType(IParseLocation theLocation, String theElementName, ValueType theExpected, ScalarType theExpectedScalarType, ValueType theFound, ScalarType theFoundScalarType) {
|
public void incorrectJsonType(IParseLocation theLocation, String theElementName, ValueType theExpected, ScalarType theExpectedScalarType, ValueType theFound, ScalarType theFoundScalarType) {
|
||||||
String message = LenientErrorHandler.createIncorrectJsonTypeMessage(theElementName, theExpected, theExpectedScalarType, theFound, theFoundScalarType);
|
String message = LenientErrorHandler.createIncorrectJsonTypeMessage(theElementName, theExpected, theExpectedScalarType, theFound, theFoundScalarType);
|
||||||
throw new DataFormatException(message);
|
throw new DataFormatException(Msg.code(1820) + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidValue(IParseLocation theLocation, String theValue, String theError) {
|
public void invalidValue(IParseLocation theLocation, String theValue, String theError) {
|
||||||
throw new DataFormatException(describeLocation(theLocation) + "Invalid attribute value \"" + UrlUtil.sanitizeUrlPart(theValue) + "\": " + theError);
|
throw new DataFormatException(Msg.code(1821) + describeLocation(theLocation) + "Invalid attribute value \"" + UrlUtil.sanitizeUrlPart(theValue) + "\": " + theError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,32 +62,32 @@ public class StrictErrorHandler extends BaseErrorHandler implements IParserError
|
||||||
b.append(theLocation.getParentElementName());
|
b.append(theLocation.getParentElementName());
|
||||||
b.append("'");
|
b.append("'");
|
||||||
}
|
}
|
||||||
throw new DataFormatException(b.toString());
|
throw new DataFormatException(Msg.code(1822) + b.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unexpectedRepeatingElement(IParseLocation theLocation, String theElementName) {
|
public void unexpectedRepeatingElement(IParseLocation theLocation, String theElementName) {
|
||||||
throw new DataFormatException(describeLocation(theLocation) + "Multiple repetitions of non-repeatable element '" + theElementName + "' found during parse");
|
throw new DataFormatException(Msg.code(1823) + describeLocation(theLocation) + "Multiple repetitions of non-repeatable element '" + theElementName + "' found during parse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unknownAttribute(IParseLocation theLocation, String theAttributeName) {
|
public void unknownAttribute(IParseLocation theLocation, String theAttributeName) {
|
||||||
throw new DataFormatException(describeLocation(theLocation) + "Unknown attribute '" + theAttributeName + "' found during parse");
|
throw new DataFormatException(Msg.code(1824) + describeLocation(theLocation) + "Unknown attribute '" + theAttributeName + "' found during parse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unknownElement(IParseLocation theLocation, String theElementName) {
|
public void unknownElement(IParseLocation theLocation, String theElementName) {
|
||||||
throw new DataFormatException(describeLocation(theLocation) + "Unknown element '" + theElementName + "' found during parse");
|
throw new DataFormatException(Msg.code(1825) + describeLocation(theLocation) + "Unknown element '" + theElementName + "' found during parse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unknownReference(IParseLocation theLocation, String theReference) {
|
public void unknownReference(IParseLocation theLocation, String theReference) {
|
||||||
throw new DataFormatException(describeLocation(theLocation) + "Resource has invalid reference: " + theReference);
|
throw new DataFormatException(Msg.code(1826) + describeLocation(theLocation) + "Resource has invalid reference: " + theReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extensionContainsValueAndNestedExtensions(IParseLocation theLocation) {
|
public void extensionContainsValueAndNestedExtensions(IParseLocation theLocation) {
|
||||||
throw new DataFormatException(describeLocation(theLocation) + "Extension contains both a value and nested extensions");
|
throw new DataFormatException(Msg.code(1827) + describeLocation(theLocation) + "Extension contains both a value and nested extensions");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,22 @@ package ca.uhn.fhir.parser;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.*;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
import ca.uhn.fhir.model.api.*;
|
import ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition;
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildContainedResources;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildExtension;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildNarrativeDefinition;
|
||||||
|
import ca.uhn.fhir.context.RuntimeChildUndeclaredExtensionDefinition;
|
||||||
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
|
||||||
|
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||||
|
import ca.uhn.fhir.model.api.Tag;
|
||||||
|
import ca.uhn.fhir.model.api.TagList;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||||
|
@ -33,11 +47,31 @@ import ca.uhn.fhir.util.NonPrettyPrintWriterWrapper;
|
||||||
import ca.uhn.fhir.util.PrettyPrintWriterWrapper;
|
import ca.uhn.fhir.util.PrettyPrintWriterWrapper;
|
||||||
import ca.uhn.fhir.util.XmlUtil;
|
import ca.uhn.fhir.util.XmlUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hl7.fhir.instance.model.api.*;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseXhtml;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
import javax.xml.stream.*;
|
import javax.xml.stream.FactoryConfigurationError;
|
||||||
import javax.xml.stream.events.*;
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
import javax.xml.stream.XMLStreamConstants;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
|
import javax.xml.stream.events.Attribute;
|
||||||
|
import javax.xml.stream.events.Characters;
|
||||||
|
import javax.xml.stream.events.Comment;
|
||||||
|
import javax.xml.stream.events.EntityReference;
|
||||||
|
import javax.xml.stream.events.Namespace;
|
||||||
|
import javax.xml.stream.events.StartElement;
|
||||||
|
import javax.xml.stream.events.XMLEvent;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -72,9 +106,9 @@ public class XmlParser extends BaseParser {
|
||||||
try {
|
try {
|
||||||
return XmlUtil.createXmlReader(theReader);
|
return XmlUtil.createXmlReader(theReader);
|
||||||
} catch (FactoryConfigurationError e1) {
|
} catch (FactoryConfigurationError e1) {
|
||||||
throw new ConfigurationException("Failed to initialize STaX event factory", e1);
|
throw new ConfigurationException(Msg.code(1848) + "Failed to initialize STaX event factory", e1);
|
||||||
} catch (XMLStreamException e1) {
|
} catch (XMLStreamException e1) {
|
||||||
throw new DataFormatException(e1);
|
throw new DataFormatException(Msg.code(1849) + e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +137,7 @@ public class XmlParser extends BaseParser {
|
||||||
encodeResourceToXmlStreamWriter(theResource, eventWriter, false, theEncodeContext);
|
encodeResourceToXmlStreamWriter(theResource, eventWriter, false, theEncodeContext);
|
||||||
eventWriter.flush();
|
eventWriter.flush();
|
||||||
} catch (XMLStreamException e) {
|
} catch (XMLStreamException e) {
|
||||||
throw new ConfigurationException("Failed to initialize STaX event factory", e);
|
throw new ConfigurationException(Msg.code(1850) + "Failed to initialize STaX event factory", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,12 +228,12 @@ public class XmlParser extends BaseParser {
|
||||||
parserState.xmlEvent(nextEvent);
|
parserState.xmlEvent(nextEvent);
|
||||||
|
|
||||||
} catch (DataFormatException e) {
|
} catch (DataFormatException e) {
|
||||||
throw new DataFormatException("DataFormatException at [" + nextEvent.getLocation().toString() + "]: " + e.getMessage(), e);
|
throw new DataFormatException(Msg.code(1851) + "DataFormatException at [" + nextEvent.getLocation().toString() + "]: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parserState.getObject();
|
return parserState.getObject();
|
||||||
} catch (XMLStreamException e) {
|
} catch (XMLStreamException e) {
|
||||||
throw new DataFormatException(e);
|
throw new DataFormatException(Msg.code(1852) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +355,7 @@ public class XmlParser extends BaseParser {
|
||||||
}
|
}
|
||||||
case EXTENSION_DECLARED:
|
case EXTENSION_DECLARED:
|
||||||
case UNDECL_EXT: {
|
case UNDECL_EXT: {
|
||||||
throw new IllegalStateException("state should not happen: " + childDef.getName());
|
throw new IllegalStateException(Msg.code(1853) + "state should not happen: " + childDef.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +522,7 @@ public class XmlParser extends BaseParser {
|
||||||
private void encodeResourceToXmlStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, boolean theContainedResource, IIdType theResourceId, EncodeContext theEncodeContext) throws XMLStreamException {
|
private void encodeResourceToXmlStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, boolean theContainedResource, IIdType theResourceId, EncodeContext theEncodeContext) throws XMLStreamException {
|
||||||
RuntimeResourceDefinition resDef = getContext().getResourceDefinition(theResource);
|
RuntimeResourceDefinition resDef = getContext().getResourceDefinition(theResource);
|
||||||
if (resDef == null) {
|
if (resDef == null) {
|
||||||
throw new ConfigurationException("Unknown resource type: " + theResource.getClass());
|
throw new ConfigurationException(Msg.code(1854) + "Unknown resource type: " + theResource.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!theContainedResource) {
|
if (!theContainedResource) {
|
||||||
|
@ -617,13 +651,13 @@ public class XmlParser extends BaseParser {
|
||||||
if (childName == null) {
|
if (childName == null) {
|
||||||
childDef = getContext().getElementDefinition(value.getClass());
|
childDef = getContext().getElementDefinition(value.getClass());
|
||||||
if (childDef == null) {
|
if (childDef == null) {
|
||||||
throw new ConfigurationException("Unable to encode extension, unrecognized child element type: " + value.getClass().getCanonicalName());
|
throw new ConfigurationException(Msg.code(1855) + "Unable to encode extension, unrecognized child element type: " + value.getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
childName = RuntimeChildUndeclaredExtensionDefinition.createExtensionChildName(childDef);
|
childName = RuntimeChildUndeclaredExtensionDefinition.createExtensionChildName(childDef);
|
||||||
} else {
|
} else {
|
||||||
childDef = extDef.getChildElementDefinitionByDatatype(value.getClass());
|
childDef = extDef.getChildElementDefinitionByDatatype(value.getClass());
|
||||||
if (childDef == null) {
|
if (childDef == null) {
|
||||||
throw new ConfigurationException("Unable to encode extension, unrecognized child element type: " + value.getClass().getCanonicalName());
|
throw new ConfigurationException(Msg.code(1856) + "Unable to encode extension, unrecognized child element type: " + value.getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
encodeChildElementToStreamWriter(theResource, theEventWriter, extDef, value, childName, childDef, null, theIncludedResource, null, theEncodeContext);
|
encodeChildElementToStreamWriter(theResource, theEventWriter, extDef, value, childName, childDef, null, theIncludedResource, null, theEncodeContext);
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.parser.json.jackson;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import ca.uhn.fhir.parser.json.JsonLikeArray;
|
import ca.uhn.fhir.parser.json.JsonLikeArray;
|
||||||
import ca.uhn.fhir.parser.json.JsonLikeObject;
|
import ca.uhn.fhir.parser.json.JsonLikeObject;
|
||||||
|
@ -84,7 +85,7 @@ public class JacksonStructure implements JsonLikeStructure {
|
||||||
while (true) {
|
while (true) {
|
||||||
nextInt = pbr.read();
|
nextInt = pbr.read();
|
||||||
if (nextInt == -1) {
|
if (nextInt == -1) {
|
||||||
throw new DataFormatException("Did not find any content to parse");
|
throw new DataFormatException(Msg.code(1857) + "Did not find any content to parse");
|
||||||
}
|
}
|
||||||
if (nextInt == '{') {
|
if (nextInt == '{') {
|
||||||
pbr.unread(nextInt);
|
pbr.unread(nextInt);
|
||||||
|
@ -98,9 +99,9 @@ public class JacksonStructure implements JsonLikeStructure {
|
||||||
pbr.unread(nextInt);
|
pbr.unread(nextInt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
throw new DataFormatException("Content does not appear to be FHIR JSON, first non-whitespace character was: '" + (char) nextInt + "' (must be '{' or '[')");
|
throw new DataFormatException(Msg.code(1858) + "Content does not appear to be FHIR JSON, first non-whitespace character was: '" + (char) nextInt + "' (must be '{' or '[')");
|
||||||
}
|
}
|
||||||
throw new DataFormatException("Content does not appear to be FHIR JSON, first non-whitespace character was: '" + (char) nextInt + "' (must be '{')");
|
throw new DataFormatException(Msg.code(1859) + "Content does not appear to be FHIR JSON, first non-whitespace character was: '" + (char) nextInt + "' (must be '{')");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextInt == '{') {
|
if (nextInt == '{') {
|
||||||
|
@ -110,10 +111,10 @@ public class JacksonStructure implements JsonLikeStructure {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e.getMessage().startsWith("Unexpected char 39")) {
|
if (e.getMessage().startsWith("Unexpected char 39")) {
|
||||||
throw new DataFormatException("Failed to parse JSON encoded FHIR content: " + e.getMessage() + " - " +
|
throw new DataFormatException(Msg.code(1860) + "Failed to parse JSON encoded FHIR content: " + e.getMessage() + " - " +
|
||||||
"This may indicate that single quotes are being used as JSON escapes where double quotes are required", e);
|
"This may indicate that single quotes are being used as JSON escapes where double quotes are required", e);
|
||||||
}
|
}
|
||||||
throw new DataFormatException("Failed to parse JSON encoded FHIR content: " + e.getMessage(), e);
|
throw new DataFormatException(Msg.code(1861) + "Failed to parse JSON encoded FHIR content: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ public class JacksonStructure implements JsonLikeStructure {
|
||||||
return new JacksonJsonObject((ObjectNode) jsonLikeRoot);
|
return new JacksonJsonObject((ObjectNode) jsonLikeRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new DataFormatException("Content must be a valid JSON Object. It must start with '{'.");
|
throw new DataFormatException(Msg.code(1862) + "Content must be a valid JSON Object. It must start with '{'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ROOT_TYPE {OBJECT, ARRAY}
|
private enum ROOT_TYPE {OBJECT, ARRAY}
|
||||||
|
|
|
@ -21,9 +21,9 @@ package ca.uhn.fhir.rest.api;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.annotation.Patch;
|
import ca.uhn.fhir.rest.annotation.Patch;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.util.UrlUtil;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -76,11 +76,11 @@ public enum PatchTypeEnum {
|
||||||
if (retVal == null) {
|
if (retVal == null) {
|
||||||
if (isBlank(contentType)) {
|
if (isBlank(contentType)) {
|
||||||
String msg = theContext.getLocalizer().getMessage(PatchTypeEnum.class, "missingPatchContentType");
|
String msg = theContext.getLocalizer().getMessage(PatchTypeEnum.class, "missingPatchContentType");
|
||||||
throw new InvalidRequestException(msg);
|
throw new InvalidRequestException(Msg.code(1964) + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
String msg = theContext.getLocalizer().getMessageSanitized(PatchTypeEnum.class, "invalidPatchContentType", contentType);
|
String msg = theContext.getLocalizer().getMessageSanitized(PatchTypeEnum.class, "invalidPatchContentType", contentType);
|
||||||
throw new InvalidRequestException(msg);
|
throw new InvalidRequestException(Msg.code(1965) + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.api;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.util.UrlUtil;
|
import ca.uhn.fhir.util.UrlUtil;
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ public enum SearchContainedModeEnum {
|
||||||
|
|
||||||
SearchContainedModeEnum retVal = codeToEnum.get(theCode);
|
SearchContainedModeEnum retVal = codeToEnum.get(theCode);
|
||||||
if (retVal == null) {
|
if (retVal == null) {
|
||||||
throw new InvalidRequestException("Invalid contained mode: " + UrlUtil.sanitizeUrlPart(theCode));
|
throw new InvalidRequestException(Msg.code(1963) + "Invalid contained mode: " + UrlUtil.sanitizeUrlPart(theCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package ca.uhn.fhir.rest.api;
|
package ca.uhn.fhir.rest.api;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -114,7 +116,7 @@ public class SortSpec implements Serializable {
|
||||||
*/
|
*/
|
||||||
public SortSpec setChain(SortSpec theChain) {
|
public SortSpec setChain(SortSpec theChain) {
|
||||||
if (theChain == this) {
|
if (theChain == this) {
|
||||||
throw new IllegalArgumentException("Can not chain this to itself");
|
throw new IllegalArgumentException(Msg.code(1966) + "Can not chain this to itself");
|
||||||
}
|
}
|
||||||
myChain = theChain;
|
myChain = theChain;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -34,18 +34,17 @@ public class InvalidResponseException extends BaseServerResponseException {
|
||||||
* @param theMessage
|
* @param theMessage
|
||||||
* The message
|
* The message
|
||||||
*/
|
*/
|
||||||
public InvalidResponseException(int theStatusCode, String theMessage) {
|
public InvalidResponseException(String theMessage, int theStatusCode) {
|
||||||
super(theStatusCode, theMessage);
|
super(theStatusCode, theMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
|
||||||
* @param theMessage
|
* @param theMessage
|
||||||
* The message
|
* The message
|
||||||
* @param theCause The cause
|
* @param theCause The cause
|
||||||
*/
|
*/
|
||||||
public InvalidResponseException(int theStatusCode, String theMessage, Throwable theCause) {
|
public InvalidResponseException(String theMessage, int theStatusCode, Throwable theCause) {
|
||||||
super(theStatusCode, theMessage, theCause);
|
super(theStatusCode, theMessage, theCause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ public class InvalidResponseException extends BaseServerResponseException {
|
||||||
* @param theCause
|
* @param theCause
|
||||||
* The underlying cause exception
|
* The underlying cause exception
|
||||||
*/
|
*/
|
||||||
public InvalidResponseException(int theStatusCode, Throwable theCause) {
|
public InvalidResponseException(Throwable theCause, int theStatusCode) {
|
||||||
super(theStatusCode, theCause.toString(), theCause);
|
super(theStatusCode, theCause.toString(), theCause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
package ca.uhn.fhir.rest.param;
|
package ca.uhn.fhir.rest.param;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
/*-
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
* #%L
|
||||||
* HAPI FHIR - Core Library
|
* HAPI FHIR - Core Library
|
||||||
* %%
|
* %%
|
||||||
|
@ -24,10 +20,14 @@ import ca.uhn.fhir.context.FhirContext;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.rest.api.Constants;
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for RESTful operation parameter types
|
* Base class for RESTful operation parameter types
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +94,7 @@ public abstract class BaseParam implements IQueryParameterType {
|
||||||
if (isNotBlank(theQualifier) && theQualifier.charAt(0) == '.') {
|
if (isNotBlank(theQualifier) && theQualifier.charAt(0) == '.') {
|
||||||
if (!isSupportsChain()) {
|
if (!isSupportsChain()) {
|
||||||
String msg = theContext.getLocalizer().getMessage(BaseParam.class, "chainNotSupported", theParamName + theQualifier, theQualifier);
|
String msg = theContext.getLocalizer().getMessage(BaseParam.class, "chainNotSupported", theParamName + theQualifier, theQualifier);
|
||||||
throw new InvalidRequestException(msg);
|
throw new InvalidRequestException(Msg.code(1935) + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.param;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
@ -57,7 +58,7 @@ public abstract class BaseParamWithPrefix<T extends BaseParam> extends BaseParam
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > 0 && theString.length() == offset) {
|
if (offset > 0 && theString.length() == offset) {
|
||||||
throw new DataFormatException("Invalid date/time format: \"" + theString + "\"");
|
throw new DataFormatException(Msg.code(1940) + "Invalid date/time format: \"" + theString + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
String prefix = theString.substring(0, offset);
|
String prefix = theString.substring(0, offset);
|
||||||
|
@ -87,7 +88,7 @@ public abstract class BaseParamWithPrefix<T extends BaseParam> extends BaseParam
|
||||||
myPrefix = ParamPrefixEnum.EQUAL;
|
myPrefix = ParamPrefixEnum.EQUAL;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
throw new DataFormatException("Invalid prefix: \"" + prefix + "\"");
|
throw new DataFormatException(Msg.code(1941) + "Invalid prefix: \"" + prefix + "\"");
|
||||||
}
|
}
|
||||||
ourLog.warn("Date parameter has legacy prefix '{}' which has been removed from FHIR. This should be replaced with '{}'", prefix, myPrefix.getValue());
|
ourLog.warn("Date parameter has legacy prefix '{}' which has been removed from FHIR. This should be replaced with '{}'", prefix, myPrefix.getValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,18 +19,19 @@ package ca.uhn.fhir.rest.param;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import java.util.List;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|
||||||
|
|
||||||
public class CompositeParam<A extends IQueryParameterType, B extends IQueryParameterType> extends BaseParam implements IQueryParameterType {
|
public class CompositeParam<A extends IQueryParameterType, B extends IQueryParameterType> extends BaseParam implements IQueryParameterType {
|
||||||
|
|
||||||
|
@ -48,16 +49,16 @@ public class CompositeParam<A extends IQueryParameterType, B extends IQueryParam
|
||||||
try {
|
try {
|
||||||
myLeftType = theLeftType.newInstance();
|
myLeftType = theLeftType.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
throw new ConfigurationException("Failed to instantiate type: " + myLeftType, e);
|
throw new ConfigurationException(Msg.code(1943) + "Failed to instantiate type: " + myLeftType, e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new ConfigurationException("Failed to instantiate type: " + myLeftType, e);
|
throw new ConfigurationException(Msg.code(1944) + "Failed to instantiate type: " + myLeftType, e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
myRightType = theRightType.newInstance();
|
myRightType = theRightType.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
throw new ConfigurationException("Failed to instantiate type: " + myRightType, e);
|
throw new ConfigurationException(Msg.code(1945) + "Failed to instantiate type: " + myRightType, e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new ConfigurationException("Failed to instantiate type: " + myRightType, e);
|
throw new ConfigurationException(Msg.code(1946) + "Failed to instantiate type: " + myRightType, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ public class CompositeParam<A extends IQueryParameterType, B extends IQueryParam
|
||||||
} else {
|
} else {
|
||||||
List<String> parts = ParameterUtil.splitParameterString(theValue, '$', false);
|
List<String> parts = ParameterUtil.splitParameterString(theValue, '$', false);
|
||||||
if (parts.size() > 2) {
|
if (parts.size() > 2) {
|
||||||
throw new InvalidRequestException("Invalid value for composite parameter (only one '$' is valid for this parameter, others must be escaped). Value was: " + theValue);
|
throw new InvalidRequestException(Msg.code(1947) + "Invalid value for composite parameter (only one '$' is valid for this parameter, others must be escaped). Value was: " + theValue);
|
||||||
}
|
}
|
||||||
myLeftType.setValueAsQueryToken(theContext, theParamName, theQualifier, parts.get(0));
|
myLeftType.setValueAsQueryToken(theContext, theParamName, theQualifier, parts.get(0));
|
||||||
if (parts.size() > 1) {
|
if (parts.size() > 1) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.rest.param;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||||
import ca.uhn.fhir.model.primitive.BaseDateTimeDt;
|
import ca.uhn.fhir.model.primitive.BaseDateTimeDt;
|
||||||
|
@ -197,7 +198,7 @@ public class DateParam extends BaseParamWithPrefix<DateParam> implements /*IQuer
|
||||||
if (theParameters.size() == 1) {
|
if (theParameters.size() == 1) {
|
||||||
setValueAsString(theParameters.get(0));
|
setValueAsString(theParameters.get(0));
|
||||||
} else if (theParameters.size() > 1) {
|
} else if (theParameters.size() > 1) {
|
||||||
throw new InvalidRequestException("This server does not support multi-valued dates for this parameter: " + theParameters);
|
throw new InvalidRequestException(Msg.code(1939) + "This server does not support multi-valued dates for this parameter: " + theParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ca.uhn.fhir.rest.param;
|
package ca.uhn.fhir.rest.param;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
||||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
@ -79,10 +80,10 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
public DateRangeParam(DateParam theDateParam) {
|
public DateRangeParam(DateParam theDateParam) {
|
||||||
this();
|
this();
|
||||||
if (theDateParam == null) {
|
if (theDateParam == null) {
|
||||||
throw new NullPointerException("theDateParam can not be null");
|
throw new NullPointerException(Msg.code(1919) + "theDateParam can not be null");
|
||||||
}
|
}
|
||||||
if (theDateParam.isEmpty()) {
|
if (theDateParam.isEmpty()) {
|
||||||
throw new IllegalArgumentException("theDateParam can not be empty");
|
throw new IllegalArgumentException(Msg.code(1920) + "theDateParam can not be empty");
|
||||||
}
|
}
|
||||||
if (theDateParam.getPrefix() == null) {
|
if (theDateParam.getPrefix() == null) {
|
||||||
setRangeFromDatesInclusive(theDateParam.getValueAsString(), theDateParam.getValueAsString());
|
setRangeFromDatesInclusive(theDateParam.getValueAsString(), theDateParam.getValueAsString());
|
||||||
|
@ -109,7 +110,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Should not happen
|
// Should not happen
|
||||||
throw new InvalidRequestException("Invalid comparator for date range parameter:" + theDateParam.getPrefix() + ". This is a bug.");
|
throw new InvalidRequestException(Msg.code(1921) + "Invalid comparator for date range parameter:" + theDateParam.getPrefix() + ". This is a bug.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
private void addParam(DateParam theParsed) throws InvalidRequestException {
|
private void addParam(DateParam theParsed) throws InvalidRequestException {
|
||||||
if (theParsed.getPrefix() == null || theParsed.getPrefix() == EQUAL) {
|
if (theParsed.getPrefix() == null || theParsed.getPrefix() == EQUAL) {
|
||||||
if (myLowerBound != null || myUpperBound != null) {
|
if (myLowerBound != null || myUpperBound != null) {
|
||||||
throw new InvalidRequestException("Can not have multiple date range parameters for the same param without a qualifier");
|
throw new InvalidRequestException(Msg.code(1922) + "Can not have multiple date range parameters for the same param without a qualifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theParsed.getMissing() != null) {
|
if (theParsed.getMissing() != null) {
|
||||||
|
@ -179,19 +180,19 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
case GREATERTHAN:
|
case GREATERTHAN:
|
||||||
case GREATERTHAN_OR_EQUALS:
|
case GREATERTHAN_OR_EQUALS:
|
||||||
if (myLowerBound != null) {
|
if (myLowerBound != null) {
|
||||||
throw new InvalidRequestException("Can not have multiple date range parameters for the same param that specify a lower bound");
|
throw new InvalidRequestException(Msg.code(1923) + "Can not have multiple date range parameters for the same param that specify a lower bound");
|
||||||
}
|
}
|
||||||
myLowerBound = theParsed;
|
myLowerBound = theParsed;
|
||||||
break;
|
break;
|
||||||
case LESSTHAN:
|
case LESSTHAN:
|
||||||
case LESSTHAN_OR_EQUALS:
|
case LESSTHAN_OR_EQUALS:
|
||||||
if (myUpperBound != null) {
|
if (myUpperBound != null) {
|
||||||
throw new InvalidRequestException("Can not have multiple date range parameters for the same param that specify an upper bound");
|
throw new InvalidRequestException(Msg.code(1924) + "Can not have multiple date range parameters for the same param that specify an upper bound");
|
||||||
}
|
}
|
||||||
myUpperBound = theParsed;
|
myUpperBound = theParsed;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new InvalidRequestException("Unknown comparator: " + theParsed.getPrefix());
|
throw new InvalidRequestException(Msg.code(1925) + "Unknown comparator: " + theParsed.getPrefix());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -299,7 +300,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
case LESSTHAN_OR_EQUALS:
|
case LESSTHAN_OR_EQUALS:
|
||||||
case ENDS_BEFORE:
|
case ENDS_BEFORE:
|
||||||
case NOT_EQUAL:
|
case NOT_EQUAL:
|
||||||
throw new IllegalStateException("Invalid lower bound comparator: " + myLowerBound.getPrefix());
|
throw new IllegalStateException(Msg.code(1926) + "Invalid lower bound comparator: " + myLowerBound.getPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -329,7 +330,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
case APPROXIMATE:
|
case APPROXIMATE:
|
||||||
case NOT_EQUAL:
|
case NOT_EQUAL:
|
||||||
case STARTS_AFTER:
|
case STARTS_AFTER:
|
||||||
throw new IllegalStateException("Invalid upper bound comparator: " + myUpperBound.getPrefix());
|
throw new IllegalStateException(Msg.code(1927) + "Invalid upper bound comparator: " + myUpperBound.getPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -359,7 +360,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
case LESSTHAN_OR_EQUALS:
|
case LESSTHAN_OR_EQUALS:
|
||||||
case ENDS_BEFORE:
|
case ENDS_BEFORE:
|
||||||
case NOT_EQUAL:
|
case NOT_EQUAL:
|
||||||
throw new IllegalStateException("Invalid lower bound comparator: " + myLowerBound.getPrefix());
|
throw new IllegalStateException(Msg.code(1928) + "Invalid lower bound comparator: " + myLowerBound.getPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -423,7 +424,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
case APPROXIMATE:
|
case APPROXIMATE:
|
||||||
case NOT_EQUAL:
|
case NOT_EQUAL:
|
||||||
case STARTS_AFTER:
|
case STARTS_AFTER:
|
||||||
throw new IllegalStateException("Invalid upper bound comparator: " + myUpperBound.getPrefix());
|
throw new IllegalStateException(Msg.code(1929) + "Invalid upper bound comparator: " + myUpperBound.getPrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -551,7 +552,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (paramList.size() > 1) {
|
if (paramList.size() > 1) {
|
||||||
throw new InvalidRequestException("DateRange parameter does not support OR queries");
|
throw new InvalidRequestException(Msg.code(1930) + "DateRange parameter does not support OR queries");
|
||||||
}
|
}
|
||||||
String param = paramList.get(0);
|
String param = paramList.get(0);
|
||||||
|
|
||||||
|
@ -567,7 +568,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
|
|
||||||
if (parsed.getPrefix() == null) {
|
if (parsed.getPrefix() == null) {
|
||||||
if (haveHadUnqualifiedParameter) {
|
if (haveHadUnqualifiedParameter) {
|
||||||
throw new InvalidRequestException("Multiple date parameters with the same name and no qualifier (>, <, etc.) is not supported");
|
throw new InvalidRequestException(Msg.code(1931) + "Multiple date parameters with the same name and no qualifier (>, <, etc.) is not supported");
|
||||||
}
|
}
|
||||||
haveHadUnqualifiedParameter = true;
|
haveHadUnqualifiedParameter = true;
|
||||||
}
|
}
|
||||||
|
@ -616,7 +617,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
private void validateAndSet(DateParam lowerBound, DateParam upperBound) {
|
private void validateAndSet(DateParam lowerBound, DateParam upperBound) {
|
||||||
if (hasBound(lowerBound) && hasBound(upperBound)) {
|
if (hasBound(lowerBound) && hasBound(upperBound)) {
|
||||||
if (lowerBound.getValue().getTime() > upperBound.getValue().getTime()) {
|
if (lowerBound.getValue().getTime() > upperBound.getValue().getTime()) {
|
||||||
throw new DataFormatException(format(
|
throw new DataFormatException(Msg.code(1932) + format(
|
||||||
"Lower bound of %s is after upper bound of %s",
|
"Lower bound of %s is after upper bound of %s",
|
||||||
lowerBound.getValueAsString(), upperBound.getValueAsString()));
|
lowerBound.getValueAsString(), upperBound.getValueAsString()));
|
||||||
}
|
}
|
||||||
|
@ -633,7 +634,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
break;
|
break;
|
||||||
case LESSTHAN:
|
case LESSTHAN:
|
||||||
case LESSTHAN_OR_EQUALS:
|
case LESSTHAN_OR_EQUALS:
|
||||||
throw new DataFormatException("Lower bound comparator must be > or >=, can not be " + lowerBound.getPrefix().getValue());
|
throw new DataFormatException(Msg.code(1933) + "Lower bound comparator must be > or >=, can not be " + lowerBound.getPrefix().getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,7 +649,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
||||||
break;
|
break;
|
||||||
case GREATERTHAN:
|
case GREATERTHAN:
|
||||||
case GREATERTHAN_OR_EQUALS:
|
case GREATERTHAN_OR_EQUALS:
|
||||||
throw new DataFormatException("Upper bound comparator must be < or <=, can not be " + upperBound.getPrefix().getValue());
|
throw new DataFormatException(Msg.code(1934) + "Upper bound comparator must be < or <=, can not be " + upperBound.getPrefix().getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ca.uhn.fhir.rest.param;
|
package ca.uhn.fhir.rest.param;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.rest.api.Constants;
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
@ -104,7 +105,7 @@ public class HasParam extends BaseParam implements IQueryParameterType {
|
||||||
|
|
||||||
|
|
||||||
private static void throwInvalidSyntaxException(String theParameterName) {
|
private static void throwInvalidSyntaxException(String theParameterName) {
|
||||||
throw new InvalidRequestException("Invalid _has parameter syntax: " + theParameterName);
|
throw new InvalidRequestException(Msg.code(1942) + "Invalid _has parameter syntax: " + theParameterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,7 @@ package ca.uhn.fhir.rest.param;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
@ -35,6 +34,8 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.model.primitive.UriDt;
|
import ca.uhn.fhir.model.primitive.UriDt;
|
||||||
import ca.uhn.fhir.util.CoverageIgnore;
|
import ca.uhn.fhir.util.CoverageIgnore;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CoverageIgnore
|
@CoverageIgnore
|
||||||
public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype {
|
public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype {
|
||||||
|
|
||||||
|
@ -292,7 +293,7 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public BaseResourceReferenceDt getValueSet() {
|
public BaseResourceReferenceDt getValueSet() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1949));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -303,13 +304,13 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
||||||
@Deprecated //override deprecated method
|
@Deprecated //override deprecated method
|
||||||
@Override
|
@Override
|
||||||
public Boolean getMissing() {
|
public Boolean getMissing() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1950));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated //override deprecated method
|
@Deprecated //override deprecated method
|
||||||
@Override
|
@Override
|
||||||
public IQueryParameterType setMissing(Boolean theMissing) {
|
public IQueryParameterType setMissing(Boolean theMissing) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException(Msg.code(1951));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.rest.param;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
|
@ -123,7 +124,7 @@ public class ParameterUtil {
|
||||||
boolean isRi = theContext.getVersion().getVersion().isRi();
|
boolean isRi = theContext.getVersion().getVersion().isRi();
|
||||||
boolean usesHapiId = IdDt.class.equals(paramType);
|
boolean usesHapiId = IdDt.class.equals(paramType);
|
||||||
if (isRi == usesHapiId) {
|
if (isRi == usesHapiId) {
|
||||||
throw new ConfigurationException("Method uses the wrong Id datatype (IdDt / IdType) for the given context FHIR version: " + theMethod.toString());
|
throw new ConfigurationException(Msg.code(1936) + "Method uses the wrong Id datatype (IdDt / IdType) for the given context FHIR version: " + theMethod.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
|
@ -221,8 +222,7 @@ public class ParameterUtil {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (theParameters.size() > 1) {
|
if (theParameters.size() > 1) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(Msg.code(1937) + "Type " + theParam.getClass().getCanonicalName() + " does not support multiple values");
|
||||||
"Type " + theParam.getClass().getCanonicalName() + " does not support multiple values");
|
|
||||||
}
|
}
|
||||||
theParam.setValueAsQueryToken(theContext, theParamName, theParameters.getQualifier(),
|
theParam.setValueAsQueryToken(theContext, theParamName, theParameters.getQualifier(),
|
||||||
theParameters.get(0));
|
theParameters.get(0));
|
||||||
|
|
|
@ -20,20 +20,20 @@ package ca.uhn.fhir.rest.param;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import java.util.List;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseQuantityDt;
|
import ca.uhn.fhir.model.base.composite.BaseQuantityDt;
|
||||||
|
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||||
|
import ca.uhn.fhir.model.primitive.UriDt;
|
||||||
|
import ca.uhn.fhir.util.CoverageIgnore;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import java.math.BigDecimal;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import java.util.List;
|
||||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
|
||||||
import ca.uhn.fhir.model.primitive.UriDt;
|
|
||||||
import ca.uhn.fhir.util.CoverageIgnore;
|
|
||||||
|
|
||||||
public class QuantityParam extends BaseParamWithPrefix<QuantityParam> implements IQueryParameterType {
|
public class QuantityParam extends BaseParamWithPrefix<QuantityParam> implements IQueryParameterType {
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ public class QuantityParam extends BaseParamWithPrefix<QuantityParam> implements
|
||||||
} else if (theParam instanceof QuantityParam) {
|
} else if (theParam instanceof QuantityParam) {
|
||||||
return (QuantityParam) theParam;
|
return (QuantityParam) theParam;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid quantity type: " + theParam.getClass());
|
throw new IllegalArgumentException(Msg.code(1948) + "Invalid quantity type: " + theParam.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.rest.param;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
||||||
import ca.uhn.fhir.model.primitive.UriDt;
|
import ca.uhn.fhir.model.primitive.UriDt;
|
||||||
|
@ -87,7 +88,7 @@ public class TokenParam extends BaseParam /*implements IQueryParameterType*/ {
|
||||||
|
|
||||||
public TokenParam(String theSystem, String theValue, boolean theText) {
|
public TokenParam(String theSystem, String theValue, boolean theText) {
|
||||||
if (theText && isNotBlank(theSystem)) {
|
if (theText && isNotBlank(theSystem)) {
|
||||||
throw new IllegalArgumentException("theSystem can not be non-blank if theText is true (:text searches do not include a system). In other words, set the first parameter to null for a text search");
|
throw new IllegalArgumentException(Msg.code(1938) + "theSystem can not be non-blank if theText is true (:text searches do not include a system). In other words, set the first parameter to null for a text search");
|
||||||
}
|
}
|
||||||
setSystem(theSystem);
|
setSystem(theSystem);
|
||||||
setValue(theValue);
|
setValue(theValue);
|
||||||
|
|
|
@ -20,14 +20,15 @@ package ca.uhn.fhir.rest.param.binder;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.rest.param.CompositeParam;
|
import ca.uhn.fhir.rest.param.CompositeParam;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
class BaseBinder<T> {
|
class BaseBinder<T> {
|
||||||
private List<Class<? extends IQueryParameterType>> myCompositeTypes;
|
private List<Class<? extends IQueryParameterType>> myCompositeTypes;
|
||||||
private Constructor<? extends T> myConstructor;
|
private Constructor<? extends T> myConstructor;
|
||||||
|
@ -40,7 +41,7 @@ class BaseBinder<T> {
|
||||||
|
|
||||||
if (myType.equals(CompositeParam.class)) {
|
if (myType.equals(CompositeParam.class)) {
|
||||||
if (myCompositeTypes.size() != 2) {
|
if (myCompositeTypes.size() != 2) {
|
||||||
throw new ConfigurationException("Search parameter of type " + myType.getName() + " must have 2 composite types declared in parameter annotation, found " + theCompositeTypes.size());
|
throw new ConfigurationException(Msg.code(1959) + "Search parameter of type " + myType.getName() + " must have 2 composite types declared in parameter annotation, found " + theCompositeTypes.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ class BaseBinder<T> {
|
||||||
}
|
}
|
||||||
myConstructor = myType.getConstructor(types);
|
myConstructor = myType.getConstructor(types);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
throw new ConfigurationException("Query parameter type " + theType.getName() + " has no constructor with types " + theCompositeTypes);
|
throw new ConfigurationException(Msg.code(1960) + "Query parameter type " + theType.getName() + " has no constructor with types " + theCompositeTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ class BaseBinder<T> {
|
||||||
T dt = myConstructor.newInstance(args);
|
T dt = myConstructor.newInstance(args);
|
||||||
return dt;
|
return dt;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1961) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,17 +20,19 @@ package ca.uhn.fhir.rest.param.binder;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
|
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||||
|
import ca.uhn.fhir.rest.param.ParameterUtil;
|
||||||
|
import ca.uhn.fhir.rest.param.StringParam;
|
||||||
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
|
||||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
|
||||||
import ca.uhn.fhir.rest.param.*;
|
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|
||||||
|
|
||||||
abstract class BaseJavaPrimitiveBinder<T>implements IParamBinder<T> {
|
abstract class BaseJavaPrimitiveBinder<T>implements IParamBinder<T> {
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ abstract class BaseJavaPrimitiveBinder<T>implements IParamBinder<T> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (theParams.size() > 1 || theParams.get(0).size() > 1) {
|
if (theParams.size() > 1 || theParams.get(0).size() > 1) {
|
||||||
throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theName + "'. This server is not configured to allow multiple (AND) values for this param.");
|
throw new InvalidRequestException(Msg.code(1955) + "Multiple values detected for non-repeatable parameter '" + theName + "'. This server is not configured to allow multiple (AND) values for this param.");
|
||||||
}
|
}
|
||||||
|
|
||||||
T value = doParse(theParams.get(0).get(0));
|
T value = doParse(theParams.get(0).get(0));
|
||||||
|
|
|
@ -20,14 +20,15 @@ package ca.uhn.fhir.rest.param.binder;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
|
||||||
|
|
||||||
public class CollectionBinder
|
public class CollectionBinder
|
||||||
// implements IParamBinder
|
// implements IParamBinder
|
||||||
{
|
{
|
||||||
|
@ -44,7 +45,7 @@ public class CollectionBinder
|
||||||
} else if (theCollectionType.equals(Collection.class)) {
|
} else if (theCollectionType.equals(Collection.class)) {
|
||||||
return (Class<? extends Collection>) ArrayList.class;
|
return (Class<? extends Collection>) ArrayList.class;
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationException("Unsupported binding collection type '" + theCollectionType.getCanonicalName() + "' for " + thePositionDescription);
|
throw new ConfigurationException(Msg.code(1956) + "Unsupported binding collection type '" + theCollectionType.getCanonicalName() + "' for " + thePositionDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ public class CollectionBinder
|
||||||
// } else if (theCollectionType == Collection.class) {
|
// } else if (theCollectionType == Collection.class) {
|
||||||
// myCollectionType = ArrayList.class;
|
// myCollectionType = ArrayList.class;
|
||||||
// } else {
|
// } else {
|
||||||
// throw new ConfigurationException("Unsupported binding collection type: " + theCollectionType.getCanonicalName());
|
// throw new ConfigurationException(Msg.code(1957) + "Unsupported binding collection type: " + theCollectionType.getCanonicalName());
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ public class CollectionBinder
|
||||||
// try {
|
// try {
|
||||||
// retVal = (Collection<Object>) myCollectionType.newInstance();
|
// retVal = (Collection<Object>) myCollectionType.newInstance();
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// throw new InternalErrorException("Failed to instantiate " + myCollectionType, e);
|
// throw new InternalErrorException(Msg.code(1958) + "Failed to instantiate " + myCollectionType, e);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// List<String> params = QueryUtil.splitQueryStringByCommasIgnoreEscape(theString);
|
// List<String> params = QueryUtil.splitQueryStringByCommasIgnoreEscape(theString);
|
||||||
|
|
|
@ -20,14 +20,17 @@ package ca.uhn.fhir.rest.param.binder;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.*;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
||||||
|
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class QueryParameterAndBinder extends BaseBinder<IQueryParameterAnd<?>> implements IParamBinder<IQueryParameterAnd<?>> {
|
public final class QueryParameterAndBinder extends BaseBinder<IQueryParameterAnd<?>> implements IParamBinder<IQueryParameterAnd<?>> {
|
||||||
|
|
||||||
public QueryParameterAndBinder(Class<? extends IQueryParameterAnd<?>> theType, List<Class<? extends IQueryParameterType>> theCompositeTypes) {
|
public QueryParameterAndBinder(Class<? extends IQueryParameterAnd<?>> theType, List<Class<? extends IQueryParameterType>> theCompositeTypes) {
|
||||||
|
@ -48,7 +51,7 @@ public final class QueryParameterAndBinder extends BaseBinder<IQueryParameterAnd
|
||||||
dt = newInstance();
|
dt = newInstance();
|
||||||
dt.setValuesAsQueryTokens(theContext, theParamName, theString);
|
dt.setValuesAsQueryTokens(theContext, theParamName, theString);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1952) + e);
|
||||||
}
|
}
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,16 +20,17 @@ package ca.uhn.fhir.rest.param.binder;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class QueryParameterOrBinder extends BaseBinder<IQueryParameterOr<?>> implements IParamBinder<IQueryParameterOr<?>> {
|
public final class QueryParameterOrBinder extends BaseBinder<IQueryParameterOr<?>> implements IParamBinder<IQueryParameterOr<?>> {
|
||||||
|
|
||||||
public QueryParameterOrBinder(Class<? extends IQueryParameterOr<?>> theType, List<Class<? extends IQueryParameterType>> theCompositeTypes) {
|
public QueryParameterOrBinder(Class<? extends IQueryParameterOr<?>> theType, List<Class<? extends IQueryParameterType>> theCompositeTypes) {
|
||||||
|
@ -53,12 +54,12 @@ public final class QueryParameterOrBinder extends BaseBinder<IQueryParameterOr<?
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
if (theString.size() > 1) {
|
if (theString.size() > 1) {
|
||||||
throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theParamName + "'. This server is not configured to allow multiple (AND/OR) values for this param.");
|
throw new InvalidRequestException(Msg.code(1953) + "Multiple values detected for non-repeatable parameter '" + theParamName + "'. This server is not configured to allow multiple (AND/OR) values for this param.");
|
||||||
}
|
}
|
||||||
|
|
||||||
dt.setValuesAsQueryTokens(theContext, theParamName, theString.get(0));
|
dt.setValuesAsQueryTokens(theContext, theParamName, theString.get(0));
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1954) + e);
|
||||||
}
|
}
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,18 +20,18 @@ package ca.uhn.fhir.rest.param.binder;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||||
import ca.uhn.fhir.rest.param.ParameterUtil;
|
import ca.uhn.fhir.rest.param.ParameterUtil;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class QueryParameterTypeBinder extends BaseBinder<IQueryParameterType> implements IParamBinder<IQueryParameterType> {
|
public final class QueryParameterTypeBinder extends BaseBinder<IQueryParameterType> implements IParamBinder<IQueryParameterType> {
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public final class QueryParameterTypeBinder extends BaseBinder<IQueryParameterTy
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
if (theParams.size() > 1 || theParams.get(0).size() > 1) {
|
if (theParams.size() > 1 || theParams.get(0).size() > 1) {
|
||||||
throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theParamName + "'. This server is not configured to allow multiple (AND/OR) values for this param.");
|
throw new InvalidRequestException(Msg.code(1962) + "Multiple values detected for non-repeatable parameter '" + theParamName + "'. This server is not configured to allow multiple (AND/OR) values for this param.");
|
||||||
}
|
}
|
||||||
|
|
||||||
dt.setValueAsQueryToken(theContext, theParamName, theParams.get(0).getQualifier(), value);
|
dt.setValueAsQueryToken(theContext, theParamName, theParams.get(0).getQualifier(), value);
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package ca.uhn.fhir.rest.server.exceptions;
|
package ca.uhn.fhir.rest.server.exceptions;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -304,17 +309,17 @@ public abstract class BaseServerResponseException extends RuntimeException {
|
||||||
try {
|
try {
|
||||||
return ourStatusCodeToExceptionType.get(theStatusCode).getConstructor(new Class[]{String.class}).newInstance(theMessage);
|
return ourStatusCodeToExceptionType.get(theStatusCode).getConstructor(new Class[]{String.class}).newInstance(theMessage);
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1912) + e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1913) + e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1914) + e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1915) + e);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1916) + e);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1917) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new UnclassifiedServerFailureException(theStatusCode, theMessage);
|
return new UnclassifiedServerFailureException(theStatusCode, theMessage);
|
||||||
|
@ -322,7 +327,7 @@ public abstract class BaseServerResponseException extends RuntimeException {
|
||||||
|
|
||||||
static void registerExceptionType(int theStatusCode, Class<? extends BaseServerResponseException> theType) {
|
static void registerExceptionType(int theStatusCode, Class<? extends BaseServerResponseException> theType) {
|
||||||
if (ourStatusCodeToExceptionType.containsKey(theStatusCode)) {
|
if (ourStatusCodeToExceptionType.containsKey(theStatusCode)) {
|
||||||
throw new Error("Can not register " + theType + " to status code " + theStatusCode + " because " + ourStatusCodeToExceptionType.get(theStatusCode) + " already registers that code");
|
throw new Error(Msg.code(1918) + "Can not register " + theType + " to status code " + theStatusCode + " because " + ourStatusCodeToExceptionType.get(theStatusCode) + " already registers that code");
|
||||||
}
|
}
|
||||||
ourStatusCodeToExceptionType.put(theStatusCode, theType);
|
ourStatusCodeToExceptionType.put(theStatusCode, theType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
|
||||||
|
@ -91,11 +92,11 @@ public class ResourceNotFoundException extends BaseServerResponseException {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String createErrorMessage(Class<? extends IResource> theClass, IIdType theId) {
|
private static String createErrorMessage(Class<? extends IResource> theClass, IIdType theId) {
|
||||||
return "Resource of type " + theClass.getSimpleName() + " with ID " + theId + " is not known";
|
return Msg.code(970) + "Resource of type " + theClass.getSimpleName() + " with ID " + theId + " is not known";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String createErrorMessage(IIdType theId) {
|
private static String createErrorMessage(IIdType theId) {
|
||||||
return "Resource " + (theId != null ? theId.getValue() : "") + " is not known";
|
return Msg.code(971) + "Resource " + (theId != null ? theId.getValue() : "") + " is not known";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.util;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -58,7 +59,7 @@ public class AsyncUtil {
|
||||||
return theInitialCollectionLatch.await(theTime, theTimeUnit);
|
return theInitialCollectionLatch.await(theTime, theTimeUnit);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1805) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.api.PatchTypeEnum;
|
import ca.uhn.fhir.rest.api.PatchTypeEnum;
|
||||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
@ -235,7 +236,7 @@ public class BundleUtil {
|
||||||
|
|
||||||
private static void validatePartsNotNull(LinkedHashSet<IBase> theDeleteParts) {
|
private static void validatePartsNotNull(LinkedHashSet<IBase> theDeleteParts) {
|
||||||
if (theDeleteParts == null) {
|
if (theDeleteParts == null) {
|
||||||
throw new IllegalStateException("This transaction contains a cycle, so it cannot be sorted.");
|
throw new IllegalStateException(Msg.code(1745) + "This transaction contains a cycle, so it cannot be sorted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.util;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
@ -79,7 +80,7 @@ public class ClasspathUtil {
|
||||||
retVal = ClasspathUtil.class.getResourceAsStream("/" + classpath);
|
retVal = ClasspathUtil.class.getResourceAsStream("/" + classpath);
|
||||||
}
|
}
|
||||||
if (retVal == null) {
|
if (retVal == null) {
|
||||||
throw new InternalErrorException("Unable to find classpath resource: " + classpath);
|
throw new InternalErrorException(Msg.code(1758) + "Unable to find classpath resource: " + classpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -94,7 +95,7 @@ public class ClasspathUtil {
|
||||||
InputStream newStream = theStreamTransform.apply(stream);
|
InputStream newStream = theStreamTransform.apply(stream);
|
||||||
return IOUtils.toString(newStream, Charsets.UTF_8);
|
return IOUtils.toString(newStream, Charsets.UTF_8);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1759) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ public class ClasspathUtil {
|
||||||
try {
|
try {
|
||||||
return new GZIPInputStream(t);
|
return new GZIPInputStream(t);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1760) + e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return loadResource(theClasspath, streamTransform);
|
return loadResource(theClasspath, streamTransform);
|
||||||
|
@ -135,7 +136,7 @@ public class ClasspathUtil {
|
||||||
try {
|
try {
|
||||||
return IOUtils.toByteArray(stream);
|
return IOUtils.toByteArray(stream);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(Msg.code(1761) + e);
|
||||||
} finally {
|
} finally {
|
||||||
close(stream);
|
close(stream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.util;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import com.google.common.io.CountingInputStream;
|
import com.google.common.io.CountingInputStream;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -52,7 +53,7 @@ public class CountingAndLimitingInputStream extends InputStream {
|
||||||
|
|
||||||
private void validateCount() throws IOException {
|
private void validateCount() throws IOException {
|
||||||
if (myWrap.getCount() > myMaxBytes) {
|
if (myWrap.getCount() > myMaxBytes) {
|
||||||
throw new IOException("Stream exceeds maximum allowable size: " + myMaxBytes);
|
throw new IOException(Msg.code(1807) + "Stream exceeds maximum allowable size: " + myMaxBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,11 @@ package ca.uhn.fhir.util;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
|
@ -31,10 +36,6 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A utility class for parsing and formatting HTTP dates as used in cookies and
|
* A utility class for parsing and formatting HTTP dates as used in cookies and
|
||||||
* other headers. This class handles dates as defined by RFC 2616 section
|
* other headers. This class handles dates as defined by RFC 2616 section
|
||||||
|
@ -222,7 +223,7 @@ public final class DateUtils {
|
||||||
|
|
||||||
public static <T> T notNull(final T argument, final String name) {
|
public static <T> T notNull(final T argument, final String name) {
|
||||||
if (argument == null) {
|
if (argument == null) {
|
||||||
throw new IllegalArgumentException(name + " may not be null");
|
throw new IllegalArgumentException(Msg.code(1783) + name + " may not be null");
|
||||||
}
|
}
|
||||||
return argument;
|
return argument;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,13 @@ package ca.uhn.fhir.util;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ICompositeElement;
|
import ca.uhn.fhir.model.api.ICompositeElement;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ElementUtil {
|
public class ElementUtil {
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class ElementUtil {
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
List<?> elements = theElements;
|
List<?> elements = theElements;
|
||||||
String s = "Found instance of " + elements.get(i).getClass() + " - Did you set a field value to the incorrect type? Expected " + IBase.class.getName();
|
String s = "Found instance of " + elements.get(i).getClass() + " - Did you set a field value to the incorrect type? Expected " + IBase.class.getName();
|
||||||
throw new ClassCastException(s);
|
throw new ClassCastException(Msg.code(1748) + s);
|
||||||
}
|
}
|
||||||
if (next != null && !next.isEmpty()) {
|
if (next != null && !next.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -109,12 +109,12 @@ public class ElementUtil {
|
||||||
} else if (next instanceof List) {
|
} else if (next instanceof List) {
|
||||||
for (Object nextElement : ((List<?>)next)) {
|
for (Object nextElement : ((List<?>)next)) {
|
||||||
if (!(nextElement instanceof IBase)) {
|
if (!(nextElement instanceof IBase)) {
|
||||||
throw new IllegalArgumentException("Found element of "+nextElement.getClass());
|
throw new IllegalArgumentException(Msg.code(1749) + "Found element of "+nextElement.getClass());
|
||||||
}
|
}
|
||||||
addElement(retVal, (IElement) nextElement, theType);
|
addElement(retVal, (IElement) nextElement, theType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Found element of "+next.getClass());
|
throw new IllegalArgumentException(Msg.code(1750) + "Found element of "+next.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ package ca.uhn.fhir.util;
|
||||||
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||||
|
@ -105,7 +106,7 @@ public class ExtensionUtil {
|
||||||
|
|
||||||
private static IBaseHasExtensions validateExtensionSupport(IBase theBase) {
|
private static IBaseHasExtensions validateExtensionSupport(IBase theBase) {
|
||||||
if (!(theBase instanceof IBaseHasExtensions)) {
|
if (!(theBase instanceof IBaseHasExtensions)) {
|
||||||
throw new IllegalArgumentException(String.format("Expected instance that supports extensions, but got %s", theBase));
|
throw new IllegalArgumentException(Msg.code(1747) + String.format("Expected instance that supports extensions, but got %s", theBase));
|
||||||
}
|
}
|
||||||
return (IBaseHasExtensions) theBase;
|
return (IBaseHasExtensions) theBase;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import ca.uhn.fhir.context.RuntimeChildDirectResource;
|
||||||
import ca.uhn.fhir.context.RuntimeExtensionDtDefinition;
|
import ca.uhn.fhir.context.RuntimeExtensionDtDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
@ -183,7 +184,7 @@ public class FhirTerser {
|
||||||
if (theIgnoreMissingFields) {
|
if (theIgnoreMissingFields) {
|
||||||
return theSource;
|
return theSource;
|
||||||
}
|
}
|
||||||
throw new DataFormatException("Can not copy value from primitive of type " + theSource.getClass().getName() + " into type " + theTarget.getClass().getName());
|
throw new DataFormatException(Msg.code(1788) + "Can not copy value from primitive of type " + theSource.getClass().getName() + " into type " + theTarget.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseRuntimeElementCompositeDefinition<?> sourceDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(theSource.getClass());
|
BaseRuntimeElementCompositeDefinition<?> sourceDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(theSource.getClass());
|
||||||
|
@ -202,7 +203,7 @@ public class FhirTerser {
|
||||||
if (theIgnoreMissingFields) {
|
if (theIgnoreMissingFields) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
throw new DataFormatException("Type " + theTarget.getClass().getName() + " does not have a child with name " + elementName);
|
throw new DataFormatException(Msg.code(1789) + "Type " + theTarget.getClass().getName() + " does not have a child with name " + elementName);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseRuntimeElementDefinition<?> element = myContext.getElementDefinition(nextValue.getClass());
|
BaseRuntimeElementDefinition<?> element = myContext.getElementDefinition(nextValue.getClass());
|
||||||
|
@ -288,7 +289,7 @@ public class FhirTerser {
|
||||||
List<String> parts = Arrays.asList(thePath.split("\\."));
|
List<String> parts = Arrays.asList(thePath.split("\\."));
|
||||||
List<String> subList = parts.subList(1, parts.size());
|
List<String> subList = parts.subList(1, parts.size());
|
||||||
if (subList.size() < 1) {
|
if (subList.size() < 1) {
|
||||||
throw new ConfigurationException("Invalid path: " + thePath);
|
throw new ConfigurationException(Msg.code(1790) + "Invalid path: " + thePath);
|
||||||
}
|
}
|
||||||
return getDefinition(def, subList);
|
return getDefinition(def, subList);
|
||||||
|
|
||||||
|
@ -306,7 +307,7 @@ public class FhirTerser {
|
||||||
|
|
||||||
BaseRuntimeElementDefinition<?> def = myContext.getElementDefinition(theTarget.getClass());
|
BaseRuntimeElementDefinition<?> def = myContext.getElementDefinition(theTarget.getClass());
|
||||||
if (!(def instanceof BaseRuntimeElementCompositeDefinition)) {
|
if (!(def instanceof BaseRuntimeElementCompositeDefinition)) {
|
||||||
throw new IllegalArgumentException("Target is not a composite type: " + theTarget.getClass().getName());
|
throw new IllegalArgumentException(Msg.code(1791) + "Target is not a composite type: " + theTarget.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseRuntimeElementCompositeDefinition<?> currentDef = (BaseRuntimeElementCompositeDefinition<?>) def;
|
BaseRuntimeElementCompositeDefinition<?> currentDef = (BaseRuntimeElementCompositeDefinition<?>) def;
|
||||||
|
@ -699,7 +700,7 @@ public class FhirTerser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parts.size() < 1) {
|
if (parts.size() < 1) {
|
||||||
throw new ConfigurationException("Invalid path: " + thePath);
|
throw new ConfigurationException(Msg.code(1792) + "Invalid path: " + thePath);
|
||||||
}
|
}
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
@ -897,7 +898,7 @@ public class FhirTerser {
|
||||||
}
|
}
|
||||||
case EXTENSION_DECLARED:
|
case EXTENSION_DECLARED:
|
||||||
case UNDECL_EXT: {
|
case UNDECL_EXT: {
|
||||||
throw new IllegalStateException("state should not happen: " + theDefinition.getChildType());
|
throw new IllegalStateException(Msg.code(1793) + "state should not happen: " + theDefinition.getChildType());
|
||||||
}
|
}
|
||||||
case CONTAINED_RESOURCE_LIST: {
|
case CONTAINED_RESOURCE_LIST: {
|
||||||
if (theElement != null) {
|
if (theElement != null) {
|
||||||
|
@ -1012,7 +1013,7 @@ public class FhirTerser {
|
||||||
nextValue = (IBase) nextValueObject;
|
nextValue = (IBase) nextValueObject;
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
String s = "Found instance of " + nextValueObject.getClass() + " - Did you set a field value to the incorrect type? Expected " + IBase.class.getName();
|
String s = "Found instance of " + nextValueObject.getClass() + " - Did you set a field value to the incorrect type? Expected " + IBase.class.getName();
|
||||||
throw new ClassCastException(s);
|
throw new ClassCastException(Msg.code(1794) + s);
|
||||||
}
|
}
|
||||||
if (nextValue == null) {
|
if (nextValue == null) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1051,7 +1052,7 @@ public class FhirTerser {
|
||||||
case CONTAINED_RESOURCE_LIST:
|
case CONTAINED_RESOURCE_LIST:
|
||||||
case EXTENSION_DECLARED:
|
case EXTENSION_DECLARED:
|
||||||
case UNDECL_EXT: {
|
case UNDECL_EXT: {
|
||||||
throw new IllegalStateException("state should not happen: " + def.getChildType());
|
throw new IllegalStateException(Msg.code(1795) + "state should not happen: " + def.getChildType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1269,7 +1270,7 @@ public class FhirTerser {
|
||||||
|
|
||||||
BaseRuntimeChildDefinition nextChild = def.getChildByName(nextPart);
|
BaseRuntimeChildDefinition nextChild = def.getChildByName(nextPart);
|
||||||
if (nextChild == null) {
|
if (nextChild == null) {
|
||||||
throw new DataFormatException("Invalid path " + thePath + ": Element of type " + def.getName() + " has no child named " + nextPart + ". Valid names: " + def.getChildrenAndExtension().stream().map(t -> t.getElementName()).sorted().collect(Collectors.joining(", ")));
|
throw new DataFormatException(Msg.code(1796) + "Invalid path " + thePath + ": Element of type " + def.getName() + " has no child named " + nextPart + ". Valid names: " + def.getChildrenAndExtension().stream().map(t -> t.getElementName()).sorted().collect(Collectors.joining(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IBase> childValues = nextChild.getAccessor().getValues(target);
|
List<IBase> childValues = nextChild.getAccessor().getValues(target);
|
||||||
|
@ -1283,7 +1284,7 @@ public class FhirTerser {
|
||||||
if (theElementsToAdd == -1) {
|
if (theElementsToAdd == -1) {
|
||||||
return (List<T>) Collections.singletonList(childValues.get(0));
|
return (List<T>) Collections.singletonList(childValues.get(0));
|
||||||
} else if (nextChild.getMax() == 1 && !childValues.get(0).isEmpty()) {
|
} else if (nextChild.getMax() == 1 && !childValues.get(0).isEmpty()) {
|
||||||
throw new DataFormatException("Element at path " + thePath + " is not repeatable and not empty");
|
throw new DataFormatException(Msg.code(1797) + "Element at path " + thePath + " is not repeatable and not empty");
|
||||||
} else if (nextChild.getMax() == 1 && childValues.get(0).isEmpty()) {
|
} else if (nextChild.getMax() == 1 && childValues.get(0).isEmpty()) {
|
||||||
return (List<T>) Collections.singletonList(childValues.get(0));
|
return (List<T>) Collections.singletonList(childValues.get(0));
|
||||||
}
|
}
|
||||||
|
@ -1299,7 +1300,7 @@ public class FhirTerser {
|
||||||
return (List<T>) Collections.singletonList(childValue);
|
return (List<T>) Collections.singletonList(childValue);
|
||||||
} else {
|
} else {
|
||||||
if (nextChild.getMax() == 1) {
|
if (nextChild.getMax() == 1) {
|
||||||
throw new DataFormatException("Can not add multiple values at path " + thePath + ": Element does not repeat");
|
throw new DataFormatException(Msg.code(1798) + "Can not add multiple values at path " + thePath + ": Element does not repeat");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<T> values = (List<T>) Lists.newArrayList(childValue);
|
List<T> values = (List<T>) Lists.newArrayList(childValue);
|
||||||
|
@ -1320,7 +1321,7 @@ public class FhirTerser {
|
||||||
if (!lastPart) {
|
if (!lastPart) {
|
||||||
BaseRuntimeElementDefinition<?> nextDef = myContext.getElementDefinition(target.getClass());
|
BaseRuntimeElementDefinition<?> nextDef = myContext.getElementDefinition(target.getClass());
|
||||||
if (!(nextDef instanceof BaseRuntimeElementCompositeDefinition)) {
|
if (!(nextDef instanceof BaseRuntimeElementCompositeDefinition)) {
|
||||||
throw new DataFormatException("Invalid path " + thePath + ": Element of type " + def.getName() + " has no child named " + nextPart + " (this is a primitive type)");
|
throw new DataFormatException(Msg.code(1799) + "Invalid path " + thePath + ": Element of type " + def.getName() + " has no child named " + nextPart + " (this is a primitive type)");
|
||||||
}
|
}
|
||||||
def = (BaseRuntimeElementCompositeDefinition<?>) nextDef;
|
def = (BaseRuntimeElementCompositeDefinition<?>) nextDef;
|
||||||
}
|
}
|
||||||
|
@ -1350,7 +1351,7 @@ public class FhirTerser {
|
||||||
public <T extends IBase> T addElement(@Nonnull IBase theTarget, @Nonnull String thePath, @Nullable String theValue) {
|
public <T extends IBase> T addElement(@Nonnull IBase theTarget, @Nonnull String thePath, @Nullable String theValue) {
|
||||||
T value = (T) doAddElement(theTarget, thePath, 1).get(0);
|
T value = (T) doAddElement(theTarget, thePath, 1).get(0);
|
||||||
if (!(value instanceof IPrimitiveType)) {
|
if (!(value instanceof IPrimitiveType)) {
|
||||||
throw new DataFormatException("Element at path " + thePath + " is not a primitive datatype. Found: " + myContext.getElementDefinition(value.getClass()).getName());
|
throw new DataFormatException(Msg.code(1800) + "Element at path " + thePath + " is not a primitive datatype. Found: " + myContext.getElementDefinition(value.getClass()).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
((IPrimitiveType<?>) value).setValueAsString(theValue);
|
((IPrimitiveType<?>) value).setValueAsString(theValue);
|
||||||
|
@ -1381,7 +1382,7 @@ public class FhirTerser {
|
||||||
public <T extends IBase> T setElement(@Nonnull IBase theTarget, @Nonnull String thePath, @Nullable String theValue) {
|
public <T extends IBase> T setElement(@Nonnull IBase theTarget, @Nonnull String thePath, @Nullable String theValue) {
|
||||||
T value = (T) doAddElement(theTarget, thePath, -1).get(0);
|
T value = (T) doAddElement(theTarget, thePath, -1).get(0);
|
||||||
if (!(value instanceof IPrimitiveType)) {
|
if (!(value instanceof IPrimitiveType)) {
|
||||||
throw new DataFormatException("Element at path " + thePath + " is not a primitive datatype. Found: " + myContext.getElementDefinition(value.getClass()).getName());
|
throw new DataFormatException(Msg.code(1801) + "Element at path " + thePath + " is not a primitive datatype. Found: " + myContext.getElementDefinition(value.getClass()).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
((IPrimitiveType<?>) value).setValueAsString(theValue);
|
((IPrimitiveType<?>) value).setValueAsString(theValue);
|
||||||
|
@ -1405,7 +1406,7 @@ public class FhirTerser {
|
||||||
for (IBase target : targets) {
|
for (IBase target : targets) {
|
||||||
|
|
||||||
if (!(target instanceof IPrimitiveType)) {
|
if (!(target instanceof IPrimitiveType)) {
|
||||||
throw new DataFormatException("Element at path " + thePath + " is not a primitive datatype. Found: " + myContext.getElementDefinition(target.getClass()).getName());
|
throw new DataFormatException(Msg.code(1802) + "Element at path " + thePath + " is not a primitive datatype. Found: " + myContext.getElementDefinition(target.getClass()).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
((IPrimitiveType<?>) target).setValueAsString(valuesIter.next());
|
((IPrimitiveType<?>) target).setValueAsString(valuesIter.next());
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.util;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.IModelJson;
|
import ca.uhn.fhir.model.api.IModelJson;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
@ -89,7 +90,7 @@ public class JsonUtil {
|
||||||
try {
|
try {
|
||||||
return ourMapperNonPrettyPrint.writeValueAsString(theJson);
|
return ourMapperNonPrettyPrint.writeValueAsString(theJson);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new InvalidRequestException("Failed to encode " + theJson.getClass(), e);
|
throw new InvalidRequestException(Msg.code(1741) + "Failed to encode " + theJson.getClass(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||||
|
@ -49,7 +50,7 @@ public class MetaUtil {
|
||||||
} else if (theContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU3)) {
|
} else if (theContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU3)) {
|
||||||
return getSourceDstu3((IBaseHasExtensions) theMeta);
|
return getSourceDstu3((IBaseHasExtensions) theMeta);
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException(MetaUtil.class.getSimpleName() + ".getSource() not supported on FHIR Version " + theContext.getVersion().getVersion());
|
throw new UnsupportedOperationException(Msg.code(1782) + MetaUtil.class.getSimpleName() + ".getSource() not supported on FHIR Version " + theContext.getVersion().getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ca.uhn.fhir.util;
|
package ca.uhn.fhir.util;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -36,13 +37,13 @@ public class ObjectUtil {
|
||||||
|
|
||||||
public static <T> T requireNonNull(T obj, String message) {
|
public static <T> T requireNonNull(T obj, String message) {
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
throw new NullPointerException(message);
|
throw new NullPointerException(Msg.code(1776) + message);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void requireNotEmpty(String str, String message) {
|
public static void requireNotEmpty(String str, String message) {
|
||||||
if (StringUtils.isBlank(str)) {
|
if (StringUtils.isBlank(str)) {
|
||||||
throw new IllegalArgumentException(message);
|
throw new IllegalArgumentException(Msg.code(1777) + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,12 @@ package ca.uhn.fhir.util;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.*;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||||
|
@ -114,9 +119,9 @@ public class OperationOutcomeUtil {
|
||||||
try {
|
try {
|
||||||
return (IBaseOperationOutcome) ooDef.getImplementingClass().newInstance();
|
return (IBaseOperationOutcome) ooDef.getImplementingClass().newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
throw new InternalErrorException("Unable to instantiate OperationOutcome", e);
|
throw new InternalErrorException(Msg.code(1803) + "Unable to instantiate OperationOutcome", e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new InternalErrorException("Unable to instantiate OperationOutcome", e);
|
throw new InternalErrorException(Msg.code(1804) + "Unable to instantiate OperationOutcome", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
@ -38,7 +39,6 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.AnnotatedElement;
|
import java.lang.reflect.AnnotatedElement;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -156,7 +156,7 @@ public class ParametersUtil {
|
||||||
addClientParameter(theContext, next, theTargetResource, paramChild, paramChildElem, theName);
|
addClientParameter(theContext, next, theTargetResource, paramChild, paramChildElem, theName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Don't know how to handle value of type " + theValue.getClass() + " for parameter " + theName);
|
throw new IllegalArgumentException(Msg.code(1806) + "Don't know how to handle value of type " + theValue.getClass() + " for parameter " + theName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
package ca.uhn.fhir.util;
|
package ca.uhn.fhir.util;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR - Core Library
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||||
|
* %%
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.phonetic.ApacheEncoder;
|
import ca.uhn.fhir.context.phonetic.ApacheEncoder;
|
||||||
import ca.uhn.fhir.context.phonetic.IPhoneticEncoder;
|
import ca.uhn.fhir.context.phonetic.IPhoneticEncoder;
|
||||||
import ca.uhn.fhir.context.phonetic.NumericEncoder;
|
import ca.uhn.fhir.context.phonetic.NumericEncoder;
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.util;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ public class PropertyModifyingHelper {
|
||||||
*/
|
*/
|
||||||
public PropertyModifyingHelper(FhirContext theFhirContext, IBase theBase) {
|
public PropertyModifyingHelper(FhirContext theFhirContext, IBase theBase) {
|
||||||
if (findGetPropertyMethod(theBase) == null) {
|
if (findGetPropertyMethod(theBase) == null) {
|
||||||
throw new IllegalArgumentException("Specified base instance does not support property retrieval.");
|
throw new IllegalArgumentException(Msg.code(1771) + "Specified base instance does not support property retrieval.");
|
||||||
}
|
}
|
||||||
myBase = theBase;
|
myBase = theBase;
|
||||||
myFhirContext = theFhirContext;
|
myFhirContext = theFhirContext;
|
||||||
|
@ -129,7 +130,7 @@ public class PropertyModifyingHelper {
|
||||||
int hashCode = thePropertyName.hashCode();
|
int hashCode = thePropertyName.hashCode();
|
||||||
setPropertyMethod.invoke(myBase, hashCode, thePropertyName, value);
|
setPropertyMethod.invoke(myBase, hashCode, thePropertyName, value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException(String.format("Unable to set property %s on %s", thePropertyName, myBase), e);
|
throw new IllegalStateException(Msg.code(1772) + String.format("Unable to set property %s on %s", thePropertyName, myBase), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ public class PropertyModifyingHelper {
|
||||||
try {
|
try {
|
||||||
values = (Object[]) getPropertyMethod.invoke(myBase, thePropertyName.hashCode(), thePropertyName, true);
|
values = (Object[]) getPropertyMethod.invoke(myBase, thePropertyName.hashCode(), thePropertyName, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException(String.format("Instance %s does not supply property %s", myBase, thePropertyName), e);
|
throw new IllegalStateException(Msg.code(1773) + String.format("Instance %s does not supply property %s", myBase, thePropertyName), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays.stream(values)
|
return Arrays.stream(values)
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.util;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
@ -35,8 +36,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -202,7 +201,7 @@ public class ReflectionUtil {
|
||||||
try {
|
try {
|
||||||
return theType.getConstructor().newInstance();
|
return theType.getConstructor().newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException("Failed to instantiate " + theType.getName(), e);
|
throw new ConfigurationException(Msg.code(1784) + "Failed to instantiate " + theType.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +211,7 @@ public class ReflectionUtil {
|
||||||
Constructor<T> constructor = theType.getConstructor(theArgumentType);
|
Constructor<T> constructor = theType.getConstructor(theArgumentType);
|
||||||
return constructor.newInstance(theArgument);
|
return constructor.newInstance(theArgument);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException("Failed to instantiate " + theType.getName(), e);
|
throw new ConfigurationException(Msg.code(1785) + "Failed to instantiate " + theType.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +230,7 @@ public class ReflectionUtil {
|
||||||
Validate.isTrue(serverType.isAssignableFrom(type));
|
Validate.isTrue(serverType.isAssignableFrom(type));
|
||||||
fhirServerVersion = type.getConstructor(theParameterArgTypes).newInstance(theConstructorArgs);
|
fhirServerVersion = type.getConstructor(theParameterArgTypes).newInstance(theConstructorArgs);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException(errorMessage, e);
|
throw new ConfigurationException(Msg.code(1786) + errorMessage, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ourFhirServerVersions.put(theKey, fhirServerVersion);
|
ourFhirServerVersions.put(theKey, fhirServerVersion);
|
||||||
|
@ -248,7 +247,7 @@ public class ReflectionUtil {
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName(theClassName);
|
Class<?> clazz = Class.forName(theClassName);
|
||||||
if (!theType.isAssignableFrom(clazz)) {
|
if (!theType.isAssignableFrom(clazz)) {
|
||||||
throw new ConfigurationException(theClassName + " is not assignable to " + theType);
|
throw new ConfigurationException(Msg.code(1787) + theClassName + " is not assignable to " + theType);
|
||||||
}
|
}
|
||||||
return (T) clazz.getConstructor(theArgTypes).newInstance(theArgs);
|
return (T) clazz.getConstructor(theArgTypes).newInstance(theArgs);
|
||||||
} catch (ConfigurationException e) {
|
} catch (ConfigurationException e) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
@ -87,12 +88,12 @@ public class SearchParameterUtil {
|
||||||
List<RuntimeSearchParam> searchParams = runtimeResourceDefinition.getSearchParamsForCompartmentName("Patient");
|
List<RuntimeSearchParam> searchParams = runtimeResourceDefinition.getSearchParamsForCompartmentName("Patient");
|
||||||
if (searchParams == null || searchParams.size() == 0) {
|
if (searchParams == null || searchParams.size() == 0) {
|
||||||
String errorMessage = String.format("Resource type [%s] is not eligible for this type of export, as it contains no Patient compartment, and no `patient` or `subject` search parameter", runtimeResourceDefinition.getId());
|
String errorMessage = String.format("Resource type [%s] is not eligible for this type of export, as it contains no Patient compartment, and no `patient` or `subject` search parameter", runtimeResourceDefinition.getId());
|
||||||
throw new IllegalArgumentException(errorMessage);
|
throw new IllegalArgumentException(Msg.code(1774) + errorMessage);
|
||||||
} else if (searchParams.size() == 1) {
|
} else if (searchParams.size() == 1) {
|
||||||
patientSearchParam = searchParams.get(0);
|
patientSearchParam = searchParams.get(0);
|
||||||
} else {
|
} else {
|
||||||
String errorMessage = String.format("Resource type %s has more than one Search Param which references a patient compartment. We are unable to disambiguate which patient search parameter we should be searching by.", runtimeResourceDefinition.getId());
|
String errorMessage = String.format("Resource type %s has more than one Search Param which references a patient compartment. We are unable to disambiguate which patient search parameter we should be searching by.", runtimeResourceDefinition.getId());
|
||||||
throw new IllegalArgumentException(errorMessage);
|
throw new IllegalArgumentException(Msg.code(1775) + errorMessage);
|
||||||
}
|
}
|
||||||
return patientSearchParam;
|
return patientSearchParam;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeChildChoiceDefinition;
|
import ca.uhn.fhir.context.RuntimeChildChoiceDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
@ -230,7 +231,7 @@ public final class TerserUtil {
|
||||||
try {
|
try {
|
||||||
return (Boolean) theMethod.invoke(theItem1, theItem2);
|
return (Boolean) theMethod.invoke(theItem1, theItem2);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(String.format("Unable to compare equality via %s", EQUALS_DEEP), e);
|
throw new RuntimeException(Msg.code(1746) + String.format("Unable to compare equality via %s", EQUALS_DEEP), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return theItem1.equals(theItem2);
|
return theItem1.equals(theItem2);
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.util;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
@ -91,11 +92,11 @@ public class TestUtil {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50);
|
Thread.sleep(50);
|
||||||
} catch (InterruptedException theE) {
|
} catch (InterruptedException theE) {
|
||||||
throw new Error(theE);
|
throw new Error(Msg.code(1778) + theE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((System.currentTimeMillis() - start) >= 15000) {
|
if ((System.currentTimeMillis() - start) >= 15000) {
|
||||||
throw new IllegalStateException("Size " + theInteger.get() + " is != target " + theTarget);
|
throw new IllegalStateException(Msg.code(1779) + "Size " + theInteger.get() + " is != target " + theTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,11 +111,11 @@ public class TestUtil {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50);
|
Thread.sleep(50);
|
||||||
} catch (InterruptedException theE) {
|
} catch (InterruptedException theE) {
|
||||||
throw new Error(theE);
|
throw new Error(Msg.code(1780) + theE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((System.currentTimeMillis() - start) >= 15000) {
|
if ((System.currentTimeMillis() - start) >= 15000) {
|
||||||
throw new IllegalStateException("Size " + theSource.call() + " is != target " + theTarget);
|
throw new IllegalStateException(Msg.code(1781) + "Size " + theSource.call() + " is != target " + theTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.util;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import ca.uhn.fhir.rest.api.Constants;
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
|
@ -9,7 +10,6 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import com.google.common.escape.Escaper;
|
import com.google.common.escape.Escaper;
|
||||||
import com.google.common.net.PercentEscaper;
|
import com.google.common.net.PercentEscaper;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.text.StringSubstitutor;
|
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
import org.apache.http.client.utils.URLEncodedUtils;
|
import org.apache.http.client.utils.URLEncodedUtils;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
@ -394,7 +394,7 @@ public class UrlUtil {
|
||||||
if (nextSubstring.equals(Constants.URL_TOKEN_HISTORY)) {
|
if (nextSubstring.equals(Constants.URL_TOKEN_HISTORY)) {
|
||||||
nextIsHistory = true;
|
nextIsHistory = true;
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidRequestException("Invalid FHIR resource URL: " + url);
|
throw new InvalidRequestException(Msg.code(1742) + "Invalid FHIR resource URL: " + url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextChar == '?') {
|
if (nextChar == '?') {
|
||||||
|
@ -522,7 +522,7 @@ public class UrlUtil {
|
||||||
// method that takes Charset is JDK10+ only... sigh....
|
// method that takes Charset is JDK10+ only... sigh....
|
||||||
return URLDecoder.decode(theString, "UTF-8");
|
return URLDecoder.decode(theString, "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new Error("UTF-8 not supported, this shouldn't happen", e);
|
throw new Error(Msg.code(1743) + "UTF-8 not supported, this shouldn't happen", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -555,7 +555,7 @@ public class UrlUtil {
|
||||||
};
|
};
|
||||||
matchUrl = StringUtils.replaceEach(matchUrl, searchList, replacementList);
|
matchUrl = StringUtils.replaceEach(matchUrl, searchList, replacementList);
|
||||||
if (matchUrl.contains(" ")) {
|
if (matchUrl.contains(" ")) {
|
||||||
throw new InvalidRequestException("Failed to parse match URL[" + theMatchUrl + "] - URL is invalid (must not contain spaces)");
|
throw new InvalidRequestException(Msg.code(1744) + "Failed to parse match URL[" + theMatchUrl + "] - URL is invalid (must not contain spaces)");
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters = URLEncodedUtils.parse((matchUrl), Constants.CHARSET_UTF8, '&');
|
parameters = URLEncodedUtils.parse((matchUrl), Constants.CHARSET_UTF8, '&');
|
||||||
|
|
|
@ -20,10 +20,12 @@ package ca.uhn.fhir.util;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.length;
|
||||||
|
|
||||||
public class ValidateUtil {
|
public class ValidateUtil {
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ public class ValidateUtil {
|
||||||
*/
|
*/
|
||||||
public static void isGreaterThan(long theValue, long theMinimum, String theMessage) {
|
public static void isGreaterThan(long theValue, long theMinimum, String theMessage) {
|
||||||
if (theValue <= theMinimum) {
|
if (theValue <= theMinimum) {
|
||||||
throw new IllegalArgumentException(theMessage);
|
throw new IllegalArgumentException(Msg.code(1762) + theMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,43 +43,43 @@ public class ValidateUtil {
|
||||||
*/
|
*/
|
||||||
public static void isGreaterThanOrEqualTo(long theValue, long theMinimum, String theMessage) {
|
public static void isGreaterThanOrEqualTo(long theValue, long theMinimum, String theMessage) {
|
||||||
if (theValue < theMinimum) {
|
if (theValue < theMinimum) {
|
||||||
throw new IllegalArgumentException(theMessage);
|
throw new IllegalArgumentException(Msg.code(1763) + theMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isNotBlankOrThrowIllegalArgument(String theString, String theMessage) {
|
public static void isNotBlankOrThrowIllegalArgument(String theString, String theMessage) {
|
||||||
if (isBlank(theString)) {
|
if (isBlank(theString)) {
|
||||||
throw new IllegalArgumentException(theMessage);
|
throw new IllegalArgumentException(Msg.code(1764) + theMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isNotBlankOrThrowInvalidRequest(String theString, String theMessage) {
|
public static void isNotBlankOrThrowInvalidRequest(String theString, String theMessage) {
|
||||||
if (isBlank(theString)) {
|
if (isBlank(theString)) {
|
||||||
throw new InvalidRequestException(theMessage);
|
throw new InvalidRequestException(Msg.code(1765) + theMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isNotBlankOrThrowUnprocessableEntity(String theString, String theMessage) {
|
public static void isNotBlankOrThrowUnprocessableEntity(String theString, String theMessage) {
|
||||||
if (isBlank(theString)) {
|
if (isBlank(theString)) {
|
||||||
throw new UnprocessableEntityException(theMessage);
|
throw new UnprocessableEntityException(Msg.code(1766) + theMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isNotNullOrThrowUnprocessableEntity(Object theObject, String theMessage, Object... theValues) {
|
public static void isNotNullOrThrowUnprocessableEntity(Object theObject, String theMessage, Object... theValues) {
|
||||||
if (theObject == null) {
|
if (theObject == null) {
|
||||||
throw new UnprocessableEntityException(String.format(theMessage, theValues));
|
throw new UnprocessableEntityException(Msg.code(1767) + String.format(theMessage, theValues));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isNotTooLongOrThrowIllegalArgument(String theString, int theMaxLength, String theMessage) {
|
public static void isNotTooLongOrThrowIllegalArgument(String theString, int theMaxLength, String theMessage) {
|
||||||
if (length(theString) > theMaxLength) {
|
if (length(theString) > theMaxLength) {
|
||||||
throw new IllegalArgumentException(theMessage);
|
throw new IllegalArgumentException(Msg.code(1768) + theMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isTrueOrThrowInvalidRequest(boolean theSuccess, String theMessage, Object... theValues) {
|
public static void isTrueOrThrowInvalidRequest(boolean theSuccess, String theMessage, Object... theValues) {
|
||||||
if (!theSuccess) {
|
if (!theSuccess) {
|
||||||
throw new InvalidRequestException(String.format(theMessage, theValues));
|
throw new InvalidRequestException(Msg.code(1769) + String.format(theMessage, theValues));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +91,7 @@ public class ValidateUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count != 1) {
|
if (count != 1) {
|
||||||
throw new InvalidRequestException(theMessage);
|
throw new InvalidRequestException(Msg.code(1770) + theMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.util;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
@ -1684,9 +1685,9 @@ public class XmlUtil {
|
||||||
ew.close();
|
ew.close();
|
||||||
return w.toString();
|
return w.toString();
|
||||||
} catch (XMLStreamException e) {
|
} catch (XMLStreamException e) {
|
||||||
throw new DataFormatException("Problem with the contained XML events", e);
|
throw new DataFormatException(Msg.code(1751) + "Problem with the contained XML events", e);
|
||||||
} catch (FactoryConfigurationError e) {
|
} catch (FactoryConfigurationError e) {
|
||||||
throw new ConfigurationException(e);
|
throw new ConfigurationException(Msg.code(1752) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1788,7 +1789,7 @@ public class XmlUtil {
|
||||||
}
|
}
|
||||||
throwUnitTestExceptionIfConfiguredToDoSo();
|
throwUnitTestExceptionIfConfiguredToDoSo();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new ConfigurationException("Unable to initialize StAX - XML processing is disabled", e);
|
throw new ConfigurationException(Msg.code(1753) + "Unable to initialize StAX - XML processing is disabled", e);
|
||||||
}
|
}
|
||||||
return inputFactory;
|
return inputFactory;
|
||||||
}
|
}
|
||||||
|
@ -1799,7 +1800,7 @@ public class XmlUtil {
|
||||||
outputFactory = XMLOutputFactory.newInstance();
|
outputFactory = XMLOutputFactory.newInstance();
|
||||||
throwUnitTestExceptionIfConfiguredToDoSo();
|
throwUnitTestExceptionIfConfiguredToDoSo();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new ConfigurationException("Unable to initialize StAX - XML processing is disabled", e);
|
throw new ConfigurationException(Msg.code(1754) + "Unable to initialize StAX - XML processing is disabled", e);
|
||||||
}
|
}
|
||||||
return outputFactory;
|
return outputFactory;
|
||||||
}
|
}
|
||||||
|
@ -1841,9 +1842,9 @@ public class XmlUtil {
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
} catch (XMLStreamException e) {
|
} catch (XMLStreamException e) {
|
||||||
throw new DataFormatException("String does not appear to be valid XML/XHTML (error is \"" + e.getMessage() + "\"): " + theValue, e);
|
throw new DataFormatException(Msg.code(1755) + "String does not appear to be valid XML/XHTML (error is \"" + e.getMessage() + "\"): " + theValue, e);
|
||||||
} catch (FactoryConfigurationError e) {
|
} catch (FactoryConfigurationError e) {
|
||||||
throw new ConfigurationException(e);
|
throw new ConfigurationException(Msg.code(1756) + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1892,7 +1893,7 @@ public class XmlUtil {
|
||||||
|
|
||||||
builder = docBuilderFactory.newDocumentBuilder();
|
builder = docBuilderFactory.newDocumentBuilder();
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
throw new ConfigurationException(e);
|
throw new ConfigurationException(Msg.code(1757) + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
InputSource src = new InputSource(theReader);
|
InputSource src = new InputSource(theReader);
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.validation;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.interceptor.api.HookParams;
|
import ca.uhn.fhir.interceptor.api.HookParams;
|
||||||
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
|
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
|
||||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||||
|
@ -147,7 +148,7 @@ public class FhirValidator {
|
||||||
*/
|
*/
|
||||||
public synchronized FhirValidator setValidateAgainstStandardSchematron(boolean theValidateAgainstStandardSchematron) {
|
public synchronized FhirValidator setValidateAgainstStandardSchematron(boolean theValidateAgainstStandardSchematron) {
|
||||||
if (theValidateAgainstStandardSchematron && !ourPhPresentOnClasspath) {
|
if (theValidateAgainstStandardSchematron && !ourPhPresentOnClasspath) {
|
||||||
throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_KEY_NO_PH_ERROR));
|
throw new IllegalArgumentException(Msg.code(1970) + myContext.getLocalizer().getMessage(I18N_KEY_NO_PH_ERROR));
|
||||||
}
|
}
|
||||||
if (!theValidateAgainstStandardSchematron && !ourPhPresentOnClasspath) {
|
if (!theValidateAgainstStandardSchematron && !ourPhPresentOnClasspath) {
|
||||||
return this;
|
return this;
|
||||||
|
@ -332,7 +333,7 @@ public class FhirValidator {
|
||||||
retval.addAll(messages);
|
retval.addAll(messages);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException | ExecutionException exp) {
|
} catch (InterruptedException | ExecutionException exp) {
|
||||||
throw new InternalErrorException(exp);
|
throw new InternalErrorException(Msg.code(1975) + exp);
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue