Merge branch 'master' into jaxrs-sever-evolution
This commit is contained in:
commit
45e4bd92ee
|
@ -0,0 +1,9 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
[*.java]
|
||||
charset = utf-8
|
||||
indent_style = tab
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -1,11 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,4 +0,0 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
|
@ -1,3 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
|
@ -1,5 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,4 +0,0 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
|
@ -5,7 +5,7 @@
|
|||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.3-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
@ -47,7 +47,7 @@
|
|||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
|
@ -1,5 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
@ -1,4 +0,0 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
|
@ -5,7 +5,7 @@
|
|||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.3-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>hapi-fhir-standalone-overlay-example</artifactId>
|
||||
<build>
|
||||
|
@ -37,14 +37,14 @@
|
|||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-testpage-overlay</artifactId>
|
||||
<version>2.3-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-testpage-overlay</artifactId>
|
||||
<version>2.3-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<classifier>classes</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package example;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.okhttp.client.OkHttpRestfulClientFactory;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
|
@ -35,6 +38,26 @@ public class ClientExamples {
|
|||
// END SNIPPET: proxy
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void processMessage() {
|
||||
// START SNIPPET: processMessage
|
||||
FhirContext ctx = FhirContext.forDstu3();
|
||||
|
||||
// Create the client
|
||||
IGenericClient client = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
// ..populate the bundle..
|
||||
|
||||
Bundle response = client
|
||||
.operation()
|
||||
.processMessage() // New operation for sending messages
|
||||
.setMessageBundle(bundle)
|
||||
.asynchronous(Bundle.class)
|
||||
.execute();
|
||||
// END SNIPPET: processMessage
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void createOkHttp() {
|
||||
// START SNIPPET: okhttp
|
||||
|
|
|
@ -70,7 +70,7 @@ public class ClientTransactionExamples {
|
|||
.setResource(patient)
|
||||
.getRequest()
|
||||
.setUrl("Patient")
|
||||
.setIfNoneExist("Patient?identifier=http://acme.org/mrns|12345")
|
||||
.setIfNoneExist("identifier=http://acme.org/mrns|12345")
|
||||
.setMethod(HTTPVerbEnum.POST);
|
||||
|
||||
// Add the observation. This entry is a POST with no header
|
||||
|
|
|
@ -60,6 +60,11 @@ public class PagingPatientProvider implements IResourceProvider {
|
|||
// Typically this method just returns null
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -474,9 +474,8 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> ext
|
|||
for (String nextName : next.getValidChildNames()) {
|
||||
if (myNameToChild.containsKey(nextName)) {
|
||||
throw new ConfigurationException("Duplicate child name[" + nextName + "] in Element[" + getName() + "]");
|
||||
} else {
|
||||
myNameToChild.put(nextName, next);
|
||||
}
|
||||
myNameToChild.put(nextName, next);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,10 +159,10 @@ public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
|||
public T newInstance(Object theArgument) {
|
||||
try {
|
||||
if (theArgument == null) {
|
||||
return getConstructor(null).newInstance(null);
|
||||
} else {
|
||||
return getConstructor(theArgument).newInstance(theArgument);
|
||||
return getConstructor(null).newInstance();
|
||||
}
|
||||
return getConstructor(theArgument).newInstance(theArgument);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("Failed to instantiate type:" + getImplementingClass().getName(), e);
|
||||
}
|
||||
|
@ -182,9 +182,8 @@ public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
|||
String extUrl = next.getExtensionUrl();
|
||||
if (myUrlToExtension.containsKey(extUrl)) {
|
||||
throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]");
|
||||
} else {
|
||||
myUrlToExtension.put(extUrl, next);
|
||||
}
|
||||
myUrlToExtension.put(extUrl, next);
|
||||
if (next.isModifier()) {
|
||||
myExtensionsModifier.add(next);
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
|
|
@ -244,7 +244,9 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
|
||||
if (blockDefinition == null && datatypeDefinition == null && resourceDefinition == null) {
|
||||
if (blockDefinition == null
|
||||
//Redundant checking && datatypeDefinition == null && resourceDefinition == null
|
||||
) {
|
||||
throw new ConfigurationException("Resource class[" + theClass.getName() + "] does not contain any valid HAPI-FHIR annotations");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,9 +114,9 @@ public class RuntimeChildDeclaredExtensionDefinition extends RuntimeChildChoiceD
|
|||
if (retVal == null) {
|
||||
if (myModifier) {
|
||||
return "modifierExtension";
|
||||
} else {
|
||||
return "extension";
|
||||
}
|
||||
return "extension";
|
||||
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import ca.uhn.fhir.model.api.annotation.Description;
|
|||
|
||||
public class RuntimeChildDirectResource extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
private RuntimeElemContainedResources myElem;
|
||||
// private RuntimeElemContainedResources myElem;
|
||||
private FhirContext myContext;
|
||||
|
||||
RuntimeChildDirectResource(Field theField, Child theChildAnnotation, Description theDescriptionAnnotation, String theElementName) throws ConfigurationException {
|
||||
|
|
|
@ -31,7 +31,7 @@ import ca.uhn.fhir.model.api.annotation.Description;
|
|||
|
||||
public class RuntimeChildExtension extends RuntimeChildAny {
|
||||
|
||||
private RuntimeChildUndeclaredExtensionDefinition myExtensionElement;
|
||||
// private RuntimeChildUndeclaredExtensionDefinition myExtensionElement;
|
||||
|
||||
public RuntimeChildExtension(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation) {
|
||||
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation);
|
||||
|
|
|
@ -32,7 +32,7 @@ import ca.uhn.fhir.model.api.annotation.Description;
|
|||
|
||||
public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
private RuntimeResourceBlockDefinition myElementDef;
|
||||
// private RuntimeResourceBlockDefinition myElementDef;
|
||||
private Class<? extends IBase> myResourceBlockType;
|
||||
private FhirContext myContext;
|
||||
|
||||
|
@ -46,9 +46,8 @@ public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChil
|
|||
public RuntimeResourceBlockDefinition getChildByName(String theName) {
|
||||
if (getElementName().equals(theName)) {
|
||||
return getDefinition();
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private RuntimeResourceBlockDefinition getDefinition() {
|
||||
|
|
|
@ -21,21 +21,16 @@ package ca.uhn.fhir.context;
|
|||
*/
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.util.Map;
|
||||
|
||||
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 ca.uhn.fhir.model.api.BasePrimitive;
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.util.CoverageIgnore;
|
||||
|
||||
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveType<?>> implements IRuntimeDatatypeDefinition {
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import static org.apache.commons.lang3.StringUtils.trim;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
|
@ -32,6 +30,7 @@ import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
|
|||
|
||||
public class RuntimeSearchParam {
|
||||
private final IIdType myId;
|
||||
private final Set<String> myBase;
|
||||
private final List<RuntimeSearchParam> myCompositeOf;
|
||||
private final String myDescription;
|
||||
private final String myName;
|
||||
|
@ -71,6 +70,17 @@ public class RuntimeSearchParam {
|
|||
} else {
|
||||
myTargets = null;
|
||||
}
|
||||
|
||||
HashSet<String> base = new HashSet<String>();
|
||||
int indexOf = thePath.indexOf('.');
|
||||
if (indexOf != -1) {
|
||||
base.add(trim(thePath.substring(0, indexOf)));
|
||||
}
|
||||
myBase = Collections.unmodifiableSet(base);
|
||||
}
|
||||
|
||||
public Set<String> getBase() {
|
||||
return myBase;
|
||||
}
|
||||
|
||||
public Set<String> getTargets() {
|
||||
|
|
|
@ -93,12 +93,10 @@ public class HapiLocalizer {
|
|||
format = new MessageFormat(formatString.trim());
|
||||
myKeyToMessageFormat.put(theQualifiedKey, format);
|
||||
return format.format(theParameters).toString();
|
||||
} else {
|
||||
}
|
||||
String retVal = findFormatString(theQualifiedKey);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Set<String> getAllKeys(){
|
||||
HashSet<String> retVal = new HashSet<String>();
|
||||
|
|
|
@ -24,8 +24,9 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
|||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
|
||||
public class BaseBundle extends BaseElement implements IElement {
|
||||
public class BaseBundle extends BaseElement /*implements IElement*/ {
|
||||
|
||||
private static final long serialVersionUID = 3349586533271409727L;
|
||||
private StringDt myAuthorName;
|
||||
private StringDt myAuthorUri;
|
||||
private IdDt myId;
|
||||
|
|
|
@ -30,8 +30,9 @@ import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
|||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
||||
public abstract class BaseElement implements IElement, ISupportsUndeclaredExtensions {
|
||||
public abstract class BaseElement implements /*IElement, */ISupportsUndeclaredExtensions {
|
||||
|
||||
private static final long serialVersionUID = -3092659584634499332L;
|
||||
private List<String> myFormatCommentsPost;
|
||||
private List<String> myFormatCommentsPre;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import ca.uhn.fhir.util.CoverageIgnore;
|
|||
|
||||
public abstract class BaseIdentifiableElement extends BaseElement implements IIdentifiableElement {
|
||||
|
||||
private static final long serialVersionUID = -7816838417076777914L;
|
||||
private String myElementSpecificId;
|
||||
|
||||
@Override
|
||||
|
@ -43,9 +44,8 @@ public abstract class BaseIdentifiableElement extends BaseElement implements IId
|
|||
public IdDt getId() {
|
||||
if (myElementSpecificId == null) {
|
||||
return new LockedId();
|
||||
} else {
|
||||
return new LockedId(myElementSpecificId);
|
||||
}
|
||||
return new LockedId(myElementSpecificId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.io.ObjectOutput;
|
|||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
|
@ -47,8 +46,9 @@ import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
|||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class Bundle extends BaseBundle implements IBase /* implements IElement */{
|
||||
public class Bundle extends BaseBundle /* implements IBase implements IElement */{
|
||||
|
||||
private static final long serialVersionUID = 5811989173275366745L;
|
||||
private ResourceMetadataMap myResourceMetadata;
|
||||
private BoundCodeDt<BundleTypeEnum> myType;
|
||||
private StringDt myBundleId;
|
||||
|
@ -127,6 +127,7 @@ public class Bundle extends BaseBundle implements IBase /* implements IElement *
|
|||
if (theResource.getId().isAbsolute()) {
|
||||
|
||||
entry.getLinkSelf().setValue(theResource.getId().getValue());
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
entry.getId().setValue(theResource.getId().toVersionless().getValue());
|
||||
|
||||
} else if (StringUtils.isNotBlank(theResource.getId().getValue())) {
|
||||
|
@ -141,6 +142,7 @@ public class Bundle extends BaseBundle implements IBase /* implements IElement *
|
|||
String resId = theResource.getId().getIdPart();
|
||||
b.append(resId);
|
||||
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
entry.getId().setValue(b.toString());
|
||||
|
||||
if (isNotBlank(theResource.getId().getVersionIdPart())) {
|
||||
|
@ -149,6 +151,7 @@ public class Bundle extends BaseBundle implements IBase /* implements IElement *
|
|||
b.append('/');
|
||||
b.append(theResource.getId().getVersionIdPart());
|
||||
} else {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
IdDt versionId = (IdDt) ResourceMetadataKeyEnum.VERSION_ID.get(theResource);
|
||||
if (versionId != null) {
|
||||
b.append('/');
|
||||
|
@ -176,6 +179,7 @@ public class Bundle extends BaseBundle implements IBase /* implements IElement *
|
|||
|
||||
InstantDt updated = ResourceMetadataKeyEnum.UPDATED.get(theResource);
|
||||
if (updated != null) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
entry.setUpdated(updated);
|
||||
}
|
||||
|
||||
|
@ -323,6 +327,7 @@ public class Bundle extends BaseBundle implements IBase /* implements IElement *
|
|||
if (map == null) {
|
||||
map = new HashMap<IdDt, IResource>();
|
||||
for (BundleEntry next : this.getEntries()) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
if (next.getId().isEmpty() == false) {
|
||||
map.put(next.getId().toUnqualified(), next.getResource());
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import ca.uhn.fhir.util.ElementUtil;
|
|||
|
||||
public class BundleEntry extends BaseBundle {
|
||||
|
||||
private static final long serialVersionUID = 2635639739195593736L;
|
||||
//@formatter:off
|
||||
/* ****************************************************
|
||||
* NB: add any new fields to the isEmpty() method!!!
|
||||
|
|
|
@ -36,6 +36,8 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
|||
@DatatypeDef(name = "Extension")
|
||||
public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDatatype, IBaseExtension<ExtensionDt, IDatatype> {
|
||||
|
||||
private static final long serialVersionUID = 6399491332783085935L;
|
||||
|
||||
private boolean myModifier;
|
||||
|
||||
@Child(name="url", type=StringDt.class, order=0, min=1, max=1)
|
||||
|
@ -75,6 +77,7 @@ public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDa
|
|||
* since the URL itself can not contain extensions and it was therefore misleading.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return myUrl != null ? myUrl.getValue() : null;
|
||||
}
|
||||
|
@ -95,6 +98,7 @@ public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDa
|
|||
* {@link #getUndeclaredModifierExtensions()} to retrieve the child extensions.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public IBaseDatatype getValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
@ -148,6 +152,7 @@ public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDa
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated //override deprecated method
|
||||
public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
|
||||
return new ArrayList<T>();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ public interface IResource extends ICompositeElement, org.hl7.fhir.instance.mode
|
|||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
IBaseMetaType getMeta();
|
||||
|
||||
/**
|
||||
|
|
|
@ -142,9 +142,8 @@ public class Include {
|
|||
int secondColon = myValue.indexOf(':', firstColon + 1);
|
||||
if (secondColon != -1) {
|
||||
return myValue.substring(firstColon + 1, secondColon);
|
||||
} else {
|
||||
return myValue.substring(firstColon + 1);
|
||||
}
|
||||
return myValue.substring(firstColon + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,9 +157,8 @@ public class Include {
|
|||
int secondColon = myValue.indexOf(':', firstColon + 1);
|
||||
if (secondColon != -1) {
|
||||
return myValue.substring(secondColon + 1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -307,22 +307,20 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
Object obj = resource.getResourceMetadata().get(SECURITY_LABELS);
|
||||
if (obj == null) {
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<BaseCodingDt> securityLabels = (List<BaseCodingDt>) obj;
|
||||
if (securityLabels.isEmpty())
|
||||
if (securityLabels.isEmpty()) {
|
||||
return null;
|
||||
else
|
||||
}
|
||||
return securityLabels;
|
||||
} catch (ClassCastException e) {
|
||||
throw new InternalErrorException("Found an object of type '" + obj.getClass().getCanonicalName() + "' in resource metadata for key SECURITY_LABELS - Expected "
|
||||
+ BaseCodingDt.class.getCanonicalName());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IResource iResource, List<BaseCodingDt> labels) {
|
||||
|
@ -349,9 +347,8 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
} else if (retValObj instanceof TagList) {
|
||||
if (((TagList) retValObj).isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return (TagList) retValObj;
|
||||
}
|
||||
return (TagList) retValObj;
|
||||
}
|
||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + TAG_LIST.name() + " - Expected "
|
||||
+ TagList.class.getCanonicalName());
|
||||
|
@ -496,9 +493,8 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
} else if (retValObj instanceof DecimalDt) {
|
||||
if (((DecimalDt) retValObj).isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return (DecimalDt) retValObj;
|
||||
}
|
||||
return (DecimalDt) retValObj;
|
||||
} else if (retValObj instanceof String) {
|
||||
if (StringUtils.isBlank((String) retValObj)) {
|
||||
return null;
|
||||
|
@ -562,9 +558,8 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
} else if (retValObj instanceof InstantDt) {
|
||||
if (((InstantDt) retValObj).isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
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 "
|
||||
+ InstantDt.class.getCanonicalName());
|
||||
|
@ -577,9 +572,8 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
} else if (retValObj instanceof String) {
|
||||
if (StringUtils.isBlank(((String) retValObj))) {
|
||||
return null;
|
||||
} else {
|
||||
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 "
|
||||
+ String.class.getCanonicalName());
|
||||
|
@ -591,15 +585,13 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
} else if (retValObj instanceof String) {
|
||||
if (isNotBlank((String) retValObj)) {
|
||||
return new IdDt((String) retValObj);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
} else if (retValObj instanceof IdDt) {
|
||||
if (((IdDt) retValObj).isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return (IdDt) retValObj;
|
||||
}
|
||||
return (IdDt) retValObj;
|
||||
} else if (retValObj instanceof Number) {
|
||||
return new IdDt(((Number) retValObj).toString());
|
||||
}
|
||||
|
|
|
@ -39,5 +39,5 @@ import java.lang.annotation.RetentionPolicy;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ProvidesResources {
|
||||
Class[] resources();
|
||||
Class<?>[] resources();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import ca.uhn.fhir.rest.param.TokenParam;
|
|||
|
||||
public abstract class BaseCodingDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
||||
|
||||
private static final long serialVersionUID = 4425182816398730643L;
|
||||
|
||||
/**
|
||||
* Gets the value(s) for <b>code</b> (Symbol in syntax defined by the system). creating it if it does not exist. Will not return <code>null</code>.
|
||||
*
|
||||
|
@ -85,9 +87,8 @@ public abstract class BaseCodingDt extends BaseIdentifiableElement implements IC
|
|||
public String getValueAsQueryToken(FhirContext theContext) {
|
||||
if (getSystemElement().getValueAsString() != null) {
|
||||
return ParameterUtil.escape(StringUtils.defaultString(getSystemElement().getValueAsString())) + '|' + ParameterUtil.escape(getCodeElement().getValueAsString());
|
||||
} else {
|
||||
return ParameterUtil.escape(getCodeElement().getValueAsString());
|
||||
}
|
||||
return ParameterUtil.escape(getCodeElement().getValueAsString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,8 @@ import ca.uhn.fhir.util.DatatypeUtil;
|
|||
|
||||
public abstract class BaseHumanNameDt extends BaseIdentifiableElement {
|
||||
|
||||
private static final long serialVersionUID = 2765500013165698259L;
|
||||
|
||||
/**
|
||||
* Gets the value(s) for <b>family</b> (Family name (often called 'Surname')). creating it if it does not exist. Will not return <code>null</code>.
|
||||
*
|
||||
|
@ -146,9 +148,8 @@ public abstract class BaseHumanNameDt extends BaseIdentifiableElement {
|
|||
nameParts.addAll(getSuffix());
|
||||
if (nameParts.size() > 0) {
|
||||
return ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated(nameParts);
|
||||
} else {
|
||||
return getTextElement().getValue();
|
||||
}
|
||||
return getTextElement().getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ import ca.uhn.fhir.rest.param.StringParam;
|
|||
|
||||
public abstract class BaseIdentifierDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
||||
|
||||
private static final long serialVersionUID = 4400972469749953077L;
|
||||
|
||||
@Override
|
||||
public String getQueryParameterQualifier() {
|
||||
return null;
|
||||
|
@ -61,13 +63,12 @@ public abstract class BaseIdentifierDt extends BaseIdentifiableElement implement
|
|||
*/
|
||||
@Override
|
||||
public String getValueAsQueryToken(FhirContext theContext) {
|
||||
UriDt system = (UriDt) getSystemElement();
|
||||
StringDt value = (StringDt) getValueElement();
|
||||
UriDt system = getSystemElement();
|
||||
StringDt value = getValueElement();
|
||||
if (system.getValueAsString() != null) {
|
||||
return ParameterUtil.escape(StringUtils.defaultString(system.getValueAsString())) + '|' + ParameterUtil.escape(value.getValueAsString());
|
||||
} else {
|
||||
return ParameterUtil.escape(value.getValueAsString());
|
||||
}
|
||||
return ParameterUtil.escape(value.getValueAsString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,8 @@ import ca.uhn.fhir.model.primitive.XhtmlDt;
|
|||
*/
|
||||
public abstract class BaseNarrativeDt<T extends Enum<?>> extends BaseIdentifiableElement implements ICompositeDatatype, INarrative {
|
||||
|
||||
private static final long serialVersionUID = -525238683230100077L;
|
||||
|
||||
public abstract BoundCodeDt<T> getStatus();
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,7 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
|
@ -38,6 +39,7 @@ import ca.uhn.fhir.rest.param.QuantityParam;
|
|||
|
||||
public abstract class BaseQuantityDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
||||
|
||||
private static final long serialVersionUID = -925486613033086056L;
|
||||
|
||||
/**
|
||||
* Sets the value(s) for <b>value</b> (Numerical value (with implicit precision))
|
||||
|
@ -64,15 +66,19 @@ public abstract class BaseQuantityDt extends BaseIdentifiableElement implements
|
|||
String[] parts = theValue.split("\\|");
|
||||
if (parts.length > 0 && StringUtils.isNotBlank(parts[0])) {
|
||||
if (parts[0].startsWith("<=")) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getComparatorElement().setValue(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS.getCode());
|
||||
setValue(new BigDecimal(parts[0].substring(2)));
|
||||
} else if (parts[0].startsWith("<")) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getComparatorElement().setValue(QuantityCompararatorEnum.LESSTHAN.getCode());
|
||||
setValue(new BigDecimal(parts[0].substring(1)));
|
||||
} else if (parts[0].startsWith(">=")) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getComparatorElement().setValue(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS.getCode());
|
||||
setValue(new BigDecimal(parts[0].substring(2)));
|
||||
} else if (parts[0].startsWith(">")) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getComparatorElement().setValue(QuantityCompararatorEnum.GREATERTHAN.getCode());
|
||||
setValue(new BigDecimal(parts[0].substring(1)));
|
||||
} else {
|
||||
|
|
|
@ -40,6 +40,8 @@ public interface BaseOperationOutcome extends IResource, IBaseOperationOutcome {
|
|||
|
||||
public static abstract class BaseIssue extends BaseIdentifiableElement implements IResourceBlock {
|
||||
|
||||
private static final long serialVersionUID = 6700020892151450738L;
|
||||
|
||||
public abstract CodeDt getSeverityElement();
|
||||
|
||||
public abstract StringDt getDetailsElement();
|
||||
|
|
|
@ -119,6 +119,7 @@ public enum QuantityCompararatorEnum {
|
|||
/**
|
||||
* Converts codes to their respective enumerated values
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public static final IValueSetEnumBinder<QuantityCompararatorEnum> VALUESET_BINDER = new IValueSetEnumBinder<QuantityCompararatorEnum>() {
|
||||
@Override
|
||||
public String toCodeString(QuantityCompararatorEnum theEnum) {
|
||||
|
|
|
@ -98,7 +98,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
|||
protected String encode(Date theValue) {
|
||||
if (theValue == null) {
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
GregorianCalendar cal;
|
||||
if (myTimeZoneZulu) {
|
||||
cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
|
||||
|
@ -157,7 +157,6 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
|||
}
|
||||
return b.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default precision for the given datatype
|
||||
|
|
|
@ -60,9 +60,8 @@ public class BooleanDt extends BasePrimitive<Boolean> implements IBaseBooleanDat
|
|||
protected String encode(Boolean theValue) {
|
||||
if (Boolean.TRUE.equals(theValue)) {
|
||||
return "true";
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.hl7.fhir.instance.model.api.IAnyResource;
|
|||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||
|
@ -54,7 +53,7 @@ import ca.uhn.fhir.util.UrlUtil;
|
|||
* </p>
|
||||
*/
|
||||
@DatatypeDef(name = "id", profileOf = StringDt.class)
|
||||
public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
||||
public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdType {
|
||||
|
||||
private String myBaseUrl;
|
||||
private boolean myHaveComponentParts;
|
||||
|
@ -183,6 +182,7 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
|||
setValue(theUrl.getValueAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(IBaseResource theResouce) {
|
||||
if (theResouce == null) {
|
||||
throw new NullPointerException("theResource can not be null");
|
||||
|
@ -332,12 +332,12 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
|||
return myUnqualifiedVersionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getVersionIdPartAsLong() {
|
||||
if (!hasVersionIdPart()) {
|
||||
return null;
|
||||
} else {
|
||||
return Long.parseLong(getVersionIdPart());
|
||||
}
|
||||
return Long.parseLong(getVersionIdPart());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,6 +345,7 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
|||
*
|
||||
* @see #getBaseUrl()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasBaseUrl() {
|
||||
return isNotBlank(myBaseUrl);
|
||||
}
|
||||
|
@ -440,7 +441,9 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
|||
|
||||
/**
|
||||
* Copies the value from the given IdDt to <code>this</code> IdDt. It is generally not neccesary to use this method but it is provided for consistency with the rest of the API.
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public void setId(IdDt theId) {
|
||||
setValue(theId.getValue());
|
||||
|
@ -666,7 +669,7 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
|||
public static IdDt of(IBaseResource theResouce) {
|
||||
if (theResouce == null) {
|
||||
throw new NullPointerException("theResource can not be null");
|
||||
} else {
|
||||
}
|
||||
IIdType retVal = theResouce.getIdElement();
|
||||
if (retVal == null) {
|
||||
return null;
|
||||
|
@ -676,7 +679,6 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
|||
return new IdDt(retVal.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String toPlainStringWithNpeThrowIfNeeded(BigDecimal theIdPart) {
|
||||
if (theIdPart == null) {
|
||||
|
|
|
@ -90,6 +90,9 @@ public enum BundleEntrySearchModeEnum {
|
|||
* Converts codes to their respective enumerated values
|
||||
*/
|
||||
public static final IValueSetEnumBinder<BundleEntrySearchModeEnum> VALUESET_BINDER = new IValueSetEnumBinder<BundleEntrySearchModeEnum>() {
|
||||
|
||||
private static final long serialVersionUID = -3836039426814809083L;
|
||||
|
||||
@Override
|
||||
public String toCodeString(BundleEntrySearchModeEnum theEnum) {
|
||||
return theEnum.getCode();
|
||||
|
|
|
@ -97,6 +97,9 @@ public enum BundleEntryTransactionMethodEnum {
|
|||
* Converts codes to their respective enumerated values
|
||||
*/
|
||||
public static final IValueSetEnumBinder<BundleEntryTransactionMethodEnum> VALUESET_BINDER = new IValueSetEnumBinder<BundleEntryTransactionMethodEnum>() {
|
||||
|
||||
private static final long serialVersionUID = 7569681479045998433L;
|
||||
|
||||
@Override
|
||||
public String toCodeString(BundleEntryTransactionMethodEnum theEnum) {
|
||||
return theEnum.getCode();
|
||||
|
|
|
@ -102,6 +102,9 @@ public enum BundleTypeEnum {
|
|||
* Converts codes to their respective enumerated values
|
||||
*/
|
||||
public static final IValueSetEnumBinder<BundleTypeEnum> VALUESET_BINDER = new IValueSetEnumBinder<BundleTypeEnum>() {
|
||||
|
||||
private static final long serialVersionUID = -305725916208867517L;
|
||||
|
||||
@Override
|
||||
public String toCodeString(BundleTypeEnum theEnum) {
|
||||
return theEnum.getCode();
|
||||
|
|
|
@ -85,10 +85,7 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
|||
initialize(theContext);
|
||||
}
|
||||
|
||||
String name = null;
|
||||
if (name == null) {
|
||||
name = myClassToName.get(theResource.getClass());
|
||||
}
|
||||
String name = myClassToName.get(theResource.getClass());
|
||||
if (name == null) {
|
||||
name = theContext.getResourceDefinition(theResource).getName().toLowerCase();
|
||||
}
|
||||
|
@ -97,9 +94,8 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
|||
if (myIgnoreMissingTemplates) {
|
||||
ourLog.debug("No narrative template available for resorce: {}", name);
|
||||
return;
|
||||
} else {
|
||||
throw new DataFormatException("No narrative template for class " + theResource.getClass().getCanonicalName());
|
||||
}
|
||||
throw new DataFormatException("No narrative template for class " + theResource.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -132,9 +128,8 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
|||
}
|
||||
theNarrative.setStatusAsString("empty");
|
||||
return;
|
||||
} else {
|
||||
throw new DataFormatException(e);
|
||||
}
|
||||
throw new DataFormatException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,6 +224,7 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
|||
String narrativePropName = name + ".narrative";
|
||||
String narrativeName = file.getProperty(narrativePropName);
|
||||
if (isBlank(narrativeName)) {
|
||||
//FIXME resource leak
|
||||
throw new ConfigurationException("Found property '" + nextKey + "' but no corresponding property '" + narrativePropName + "' in file " + propFileName);
|
||||
}
|
||||
|
||||
|
@ -289,6 +285,7 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
|||
throw new IOException("Can not find '" + cpName + "' on classpath");
|
||||
}
|
||||
}
|
||||
//FIXME resource leak
|
||||
return resource;
|
||||
} else if (name.startsWith("file:")) {
|
||||
File file = new File(name.substring("file:".length()));
|
||||
|
@ -418,7 +415,7 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
|||
context.setVariable("resource", value);
|
||||
|
||||
String name = null;
|
||||
if (value != null) {
|
||||
|
||||
Class<? extends Object> nextClass = value.getClass();
|
||||
do {
|
||||
name = myClassToName.get(nextClass);
|
||||
|
@ -444,15 +441,13 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
|||
name = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
if (myIgnoreMissingTemplates) {
|
||||
ourLog.debug("No narrative template available for type: {}", value.getClass());
|
||||
return;
|
||||
} else {
|
||||
throw new DataFormatException("No narrative template for class " + value.getClass());
|
||||
}
|
||||
throw new DataFormatException("No narrative template for class " + value.getClass());
|
||||
}
|
||||
|
||||
String result = myProfileTemplateEngine.process(name, context);
|
||||
|
|
|
@ -306,25 +306,21 @@ public abstract class BaseParser implements IParser {
|
|||
}
|
||||
}
|
||||
return reference;
|
||||
} else {
|
||||
}
|
||||
if (!ref.hasResourceType() && !ref.isLocal() && theRef.getResource() != null) {
|
||||
ref = ref.withResourceType(myContext.getResourceDefinition(theRef.getResource()).getName());
|
||||
}
|
||||
if (isNotBlank(myServerBaseUrl) && StringUtils.equals(myServerBaseUrl, ref.getBaseUrl())) {
|
||||
if (isStripVersionsFromReferences(theCompositeChildElement)) {
|
||||
return ref.toUnqualifiedVersionless().getValue();
|
||||
} else {
|
||||
}
|
||||
return ref.toUnqualified().getValue();
|
||||
}
|
||||
} else {
|
||||
if (isStripVersionsFromReferences(theCompositeChildElement)) {
|
||||
return ref.toVersionless().getValue();
|
||||
} else {
|
||||
}
|
||||
return ref.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isStripVersionsFromReferences(CompositeChildElement theCompositeChildElement) {
|
||||
Boolean stripVersionsFromReferences = myStripVersionsFromReferences;
|
||||
|
@ -856,8 +852,18 @@ public abstract class BaseParser implements IParser {
|
|||
|
||||
@Override
|
||||
public void setPreferTypes(List<Class<? extends IBaseResource>> thePreferTypes) {
|
||||
if (thePreferTypes != null) {
|
||||
ArrayList<Class<? extends IBaseResource>> types = new ArrayList<Class<? extends IBaseResource>>();
|
||||
for (Class<? extends IBaseResource> next : thePreferTypes) {
|
||||
if (Modifier.isAbstract(next.getModifiers()) == false) {
|
||||
types.add(next);
|
||||
}
|
||||
}
|
||||
myPreferTypes = Collections.unmodifiableList(types);
|
||||
} else {
|
||||
myPreferTypes = thePreferTypes;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser setServerBaseUrl(String theUrl) {
|
||||
|
@ -1125,9 +1131,8 @@ public abstract class BaseParser implements IParser {
|
|||
}
|
||||
if (theElements.contains(thePathBuilder.toString())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
} else if (myParent != null) {
|
||||
boolean parentCheck;
|
||||
if (theCheckingForWhitelist) {
|
||||
|
|
|
@ -25,37 +25,74 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PushbackReader;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
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 com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
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.model.api.*;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
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.model.api.BaseBundle;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.BundleEntry;
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
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.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||
import ca.uhn.fhir.model.base.composite.BaseContainedDt;
|
||||
import ca.uhn.fhir.model.primitive.*;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.IntegerDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.narrative.INarrativeGenerator;
|
||||
import ca.uhn.fhir.parser.json.GsonStructure;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeArray;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeObject;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeStructure;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeValue;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeWriter;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeValue.ScalarType;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeValue.ValueType;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeWriter;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
|
||||
|
@ -110,9 +147,8 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
}
|
||||
theListToAddTo.get(valueIdx).addAll(theCommentsToAdd);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean addToHeldExtensions(int valueIdx, List<? extends IBaseExtension<?, ?>> ext, ArrayList<ArrayList<HeldExtension>> list, boolean theIsModifier, CompositeChildElement theChildElem) {
|
||||
|
@ -128,9 +164,8 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
list.get(valueIdx).add(new HeldExtension(next, theIsModifier, theChildElem));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void addToHeldIds(int theValueIdx, ArrayList<String> theListToAddTo, String theId) {
|
||||
|
@ -143,7 +178,7 @@ 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) {
|
||||
// throw new DataFormatException("Invalid JSON content detected, missing required element: '" + thePosition + "'");
|
||||
// }
|
||||
|
@ -151,7 +186,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
// if (theResourceTypeObj.getValueType() != theValueType) {
|
||||
// throw new DataFormatException("Invalid content of element " + thePosition + ", expected " + theValueType);
|
||||
// }
|
||||
}
|
||||
// }
|
||||
|
||||
private void beginArray(JsonLikeWriter theEventWriter, String arrayName) throws IOException {
|
||||
theEventWriter.beginArray(arrayName);
|
||||
|
@ -281,6 +316,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
writeTagWithTextNode(theEventWriter, "deleted", nextEntry.getDeletedAt());
|
||||
}
|
||||
writeTagWithTextNode(theEventWriter, "title", nextEntry.getTitle());
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeTagWithTextNode(theEventWriter, "id", nextEntry.getId());
|
||||
|
||||
linkStarted = false;
|
||||
|
@ -291,6 +327,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
theEventWriter.endArray();
|
||||
}
|
||||
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithTextNode(theEventWriter, "updated", nextEntry.getUpdated());
|
||||
writeOptionalTagWithTextNode(theEventWriter, "published", nextEntry.getPublished());
|
||||
|
||||
|
@ -575,7 +612,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
}
|
||||
if (narr != null && narr.isEmpty()) {
|
||||
gen.generateNarrative(myContext, theResource, narr);
|
||||
if (narr != null && !narr.isEmpty()) {
|
||||
if (!narr.isEmpty()) {
|
||||
RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
|
||||
String childName = nextChild.getChildNameByDatatype(child.getDatatype());
|
||||
BaseRuntimeElementDefinition<?> type = child.getChildByName(childName);
|
||||
|
@ -980,7 +1017,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
for (RuntimeChildDeclaredExtensionDefinition nextDef : resDef.getExtensionsNonModifier()) {
|
||||
for (IBase nextValue : nextDef.getAccessor().getValues(theResource)) {
|
||||
if (nextValue != null) {
|
||||
if (nextValue == null || nextValue.isEmpty()) {
|
||||
if (nextValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
extensions.add(new HeldExtension(nextDef, nextValue, theChildElem));
|
||||
|
@ -990,7 +1027,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
for (RuntimeChildDeclaredExtensionDefinition nextDef : resDef.getExtensionsModifier()) {
|
||||
for (IBase nextValue : nextDef.getAccessor().getValues(theResource)) {
|
||||
if (nextValue != null) {
|
||||
if (nextValue == null || nextValue.isEmpty()) {
|
||||
if (nextValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
modifierExtensions.add(new HeldExtension(nextDef, nextValue, theChildElem));
|
||||
|
@ -1106,7 +1143,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
}
|
||||
|
||||
JsonLikeValue alternateVal = theAlternateVal;
|
||||
if (alternateVal != null && alternateVal.isObject() == false) {
|
||||
if (alternateVal.isObject() == false) {
|
||||
getErrorHandler().incorrectJsonType(null, theAlternateName, ValueType.OBJECT, null, alternateVal.getJsonType(), null);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -142,6 +142,7 @@ class ParserState<T> {
|
|||
if (entry.getLinkSelf() != null && entry.getLinkSelf().isEmpty() == false) {
|
||||
id = new IdDt(entry.getLinkSelf().getValue());
|
||||
} else {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
id = entry.getId();
|
||||
}
|
||||
|
||||
|
@ -159,6 +160,7 @@ class ParserState<T> {
|
|||
|
||||
if (resource != null) {
|
||||
resource.getResourceMetadata().put(ResourceMetadataKeyEnum.DELETED_AT, entry.getDeletedAt());
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
resource.getResourceMetadata().put(ResourceMetadataKeyEnum.VERSION_ID, id);
|
||||
}
|
||||
}
|
||||
|
@ -364,6 +366,7 @@ class ParserState<T> {
|
|||
@Override
|
||||
public void attributeValue(String theName, String theValue) throws DataFormatException {
|
||||
if ("ref".equals(theName)) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getEntry().setId(new IdDt(theValue));
|
||||
} else if ("when".equals(theName)) {
|
||||
getEntry().setDeleted(new InstantDt(theValue));
|
||||
|
@ -451,10 +454,12 @@ class ParserState<T> {
|
|||
if ("title".equals(theLocalPart)) {
|
||||
push(new AtomPrimitiveState(myEntry.getTitle()));
|
||||
} else if ("id".equals(theLocalPart)) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
push(new AtomPrimitiveState(myEntry.getId()));
|
||||
} else if ("link".equals(theLocalPart)) {
|
||||
push(new AtomLinkState(myEntry));
|
||||
} else if ("updated".equals(theLocalPart)) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
push(new AtomPrimitiveState(myEntry.getUpdated()));
|
||||
} else if ("published".equals(theLocalPart)) {
|
||||
push(new AtomPrimitiveState(myEntry.getPublished()));
|
||||
|
@ -771,7 +776,7 @@ class ParserState<T> {
|
|||
myErrorHandler.unknownAttribute(null, theName);
|
||||
}
|
||||
|
||||
public boolean elementIsRepeating(@SuppressWarnings("unused") String theChildName) {
|
||||
public boolean elementIsRepeating(String theChildName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1031,6 +1036,7 @@ class ParserState<T> {
|
|||
@Override
|
||||
public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
|
||||
if ("base".equals(theLocalPart)) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
push(new PrimitiveState(getPreResourceState(), myEntry.getLinkBase()));
|
||||
} else if ("request".equals(theLocalPart)) {
|
||||
push(new BundleEntryTransactionState(myEntry));
|
||||
|
@ -1302,6 +1308,7 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
String bundleBaseUrl = myInstance.getLinkBase().getValue();
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
String entryBaseUrl = nextEntry.getLinkBase().getValue();
|
||||
String version = ResourceMetadataKeyEnum.VERSION.get(nextResource);
|
||||
String resourceName = myContext.getResourceDefinition(nextResource).getName();
|
||||
|
@ -2030,9 +2037,8 @@ class ParserState<T> {
|
|||
private PreResourceState getRootPreResourceState() {
|
||||
if (getPreResourceState() != null) {
|
||||
return getPreResourceState();
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2590,7 +2596,6 @@ class ParserState<T> {
|
|||
public void attributeValue(String theName, String theValue) throws DataFormatException {
|
||||
if (myJsonMode) {
|
||||
myDt.setValueAsString(theValue);
|
||||
return;
|
||||
} else {
|
||||
// IGNORE - don't handle this as an error, we process these as XML events
|
||||
}
|
||||
|
|
|
@ -45,17 +45,14 @@ import javax.xml.stream.events.Namespace;
|
|||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import ca.uhn.fhir.model.api.BaseBundle;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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.IBaseElement;
|
||||
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.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseXhtml;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
|
@ -65,17 +62,16 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
|||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeChildContainedResources;
|
||||
import ca.uhn.fhir.context.RuntimeChildDeclaredExtensionDefinition;
|
||||
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.model.api.BaseBundle;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.BundleEntry;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
@ -101,7 +97,7 @@ import ca.uhn.fhir.util.XmlUtil;
|
|||
* This class is the FHIR XML parser/encoder. Users should not interact with this class directly, but should use
|
||||
* {@link FhirContext#newXmlParser()} to get an instance.
|
||||
*/
|
||||
public class XmlParser extends BaseParser implements IParser {
|
||||
public class XmlParser extends BaseParser /*implements IParser */{
|
||||
|
||||
static final String ATOM_NS = "http://www.w3.org/2005/Atom";
|
||||
static final String FHIR_NS = "http://hl7.org/fhir";
|
||||
|
@ -149,11 +145,10 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
if (myPrettyPrint) {
|
||||
PrettyPrintWriterWrapper retVal = new PrettyPrintWriterWrapper(eventWriter);
|
||||
return retVal;
|
||||
} else {
|
||||
}
|
||||
NonPrettyPrintWriterWrapper retVal = new NonPrettyPrintWriterWrapper(eventWriter);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doEncodeBundleToWriter(Bundle theBundle, Writer theWriter) throws DataFormatException {
|
||||
|
@ -330,6 +325,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
eventWriter.writeNamespace("at", TOMBSTONES_NS);
|
||||
|
||||
if (nextEntry.getDeletedResourceId().isEmpty()) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalAttribute(eventWriter, "ref", nextEntry.getId().getValueAsString());
|
||||
} else {
|
||||
writeOptionalAttribute(eventWriter, "ref", nextEntry.getDeletedResourceId().getValueAsString());
|
||||
|
@ -361,12 +357,15 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
|
||||
writeOptionalTagWithTextNode(eventWriter, "title", nextEntry.getTitle());
|
||||
if (!deleted) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
if (nextEntry.getId().isEmpty() == false) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeTagWithTextNode(eventWriter, "id", nextEntry.getId());
|
||||
} else {
|
||||
writeTagWithTextNode(eventWriter, "id", nextEntry.getResource().getId());
|
||||
}
|
||||
}
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithTextNode(eventWriter, "updated", nextEntry.getUpdated());
|
||||
writeOptionalTagWithTextNode(eventWriter, "published", nextEntry.getPublished());
|
||||
|
||||
|
@ -420,6 +419,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
IdDt bundleId = theBundle.getId();
|
||||
if (bundleId != null && isNotBlank(bundleId.getVersionIdPart()) || (updated != null && !updated.isEmpty())) {
|
||||
theEventWriter.writeStartElement("meta");
|
||||
//FIXME potential null acces bundleId may be null at this time due to the OR clause
|
||||
writeOptionalTagWithValue(theEventWriter, "versionId", bundleId.getVersionIdPart());
|
||||
if (updated != null) {
|
||||
writeOptionalTagWithValue(theEventWriter, "lastUpdated", updated.getValueAsString());
|
||||
|
@ -476,8 +476,11 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
|
||||
if (deleted) {
|
||||
theEventWriter.writeStartElement("deleted");
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithValue(theEventWriter, "type", nextEntry.getId().getResourceType());
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithValue(theEventWriter, "id", nextEntry.getId().getIdPart());
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithValue(theEventWriter, "versionId", nextEntry.getId().getVersionIdPart());
|
||||
writeOptionalTagWithValue(theEventWriter, "instant", nextEntry.getDeletedAt().getValueAsString());
|
||||
theEventWriter.writeEndElement();
|
||||
|
@ -504,18 +507,16 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
|
||||
switch (childDef.getChildType()) {
|
||||
case ID_DATATYPE: {
|
||||
IIdType value = (IIdType) theElement;
|
||||
IIdType value = IIdType.class.cast(theElement);
|
||||
String encodedValue = "id".equals(childName) ? value.getIdPart() : value.getValue();
|
||||
if (value != null) {
|
||||
theEventWriter.writeStartElement(childName);
|
||||
theEventWriter.writeAttribute("value", encodedValue);
|
||||
encodeExtensionsIfPresent(theResource, theEventWriter, theElement, theIncludedResource);
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PRIMITIVE_DATATYPE: {
|
||||
IPrimitiveType<?> pd = (IPrimitiveType<?>) theElement;
|
||||
IPrimitiveType<?> pd = IPrimitiveType.class.cast(theElement);
|
||||
String value = pd.getValueAsString();
|
||||
if (value != null || super.hasExtensions(pd)) {
|
||||
theEventWriter.writeStartElement(childName);
|
||||
|
@ -568,23 +569,21 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
break;
|
||||
}
|
||||
case PRIMITIVE_XHTML: {
|
||||
XhtmlDt dt = (XhtmlDt) theElement;
|
||||
XhtmlDt dt = XhtmlDt.class.cast(theElement);
|
||||
if (dt.hasContent()) {
|
||||
encodeXhtml(dt, theEventWriter);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PRIMITIVE_XHTML_HL7ORG: {
|
||||
IBaseXhtml dt = (IBaseXhtml) theElement;
|
||||
if (dt.isEmpty()) {
|
||||
break;
|
||||
} else {
|
||||
IBaseXhtml dt = IBaseXhtml.class.cast(theElement);
|
||||
if (!dt.isEmpty()) {
|
||||
// TODO: this is probably not as efficient as it could be
|
||||
XhtmlDt hdt = new XhtmlDt();
|
||||
hdt.setValueAsString(dt.getValueAsString());
|
||||
encodeXhtml(hdt, theEventWriter);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EXTENSION_DECLARED:
|
||||
case UNDECL_EXT: {
|
||||
|
@ -621,6 +620,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
} else {
|
||||
narr = null;
|
||||
}
|
||||
//FIXME potential null access on narr see line 623
|
||||
if (gen != null && narr.isEmpty()) {
|
||||
gen.generateNarrative(myContext, theResource, narr);
|
||||
}
|
||||
|
@ -914,9 +914,8 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
childDef = myContext.getElementDefinition(value.getClass());
|
||||
if (childDef == null) {
|
||||
throw new ConfigurationException("Unable to encode extension, unrecognized child element type: " + value.getClass().getCanonicalName());
|
||||
} else {
|
||||
childName = RuntimeChildUndeclaredExtensionDefinition.createExtensionChildName(childDef);
|
||||
}
|
||||
childName = RuntimeChildUndeclaredExtensionDefinition.createExtensionChildName(childDef);
|
||||
} else {
|
||||
childDef = extDef.getChildElementDefinitionByDatatype(value.getClass());
|
||||
if (childDef == null) {
|
||||
|
|
|
@ -27,8 +27,6 @@ import java.lang.annotation.Target;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
||||
/**
|
||||
* RESTful method annotation to be used for the FHIR
|
||||
* <a href="http://hl7.org/implement/standards/fhir/http.html#delete">delete</a> method.
|
||||
|
|
|
@ -323,6 +323,7 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
}
|
||||
|
||||
} catch (DataFormatException e) {
|
||||
//FIXME potential null access on httpResquest
|
||||
String msg = getFhirContext().getLocalizer().getMessage(BaseClient.class, "failedToParseResponse", httpRequest.getHttpVerbName(), httpRequest.getUri(), e.toString());
|
||||
throw new FhirClientConnectionException(msg, e);
|
||||
} catch (IllegalStateException e) {
|
||||
|
|
|
@ -24,15 +24,41 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseConformance;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseMetaType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
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.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.IRuntimeDatatypeDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
|
@ -45,13 +71,84 @@ import ca.uhn.fhir.model.primitive.InstantDt;
|
|||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PatchTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.SortOrderEnum;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.api.SummaryEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IHttpClient;
|
||||
import ca.uhn.fhir.rest.client.api.IHttpRequest;
|
||||
import ca.uhn.fhir.rest.client.exceptions.NonFhirResponseException;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.gclient.*;
|
||||
import ca.uhn.fhir.rest.method.*;
|
||||
import ca.uhn.fhir.rest.gclient.IClientExecutable;
|
||||
import ca.uhn.fhir.rest.gclient.ICreate;
|
||||
import ca.uhn.fhir.rest.gclient.ICreateTyped;
|
||||
import ca.uhn.fhir.rest.gclient.ICreateWithQuery;
|
||||
import ca.uhn.fhir.rest.gclient.ICreateWithQueryTyped;
|
||||
import ca.uhn.fhir.rest.gclient.ICriterion;
|
||||
import ca.uhn.fhir.rest.gclient.ICriterionInternal;
|
||||
import ca.uhn.fhir.rest.gclient.IDelete;
|
||||
import ca.uhn.fhir.rest.gclient.IDeleteTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IDeleteWithQuery;
|
||||
import ca.uhn.fhir.rest.gclient.IDeleteWithQueryTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IFetchConformanceTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IFetchConformanceUntyped;
|
||||
import ca.uhn.fhir.rest.gclient.IGetPage;
|
||||
import ca.uhn.fhir.rest.gclient.IGetPageTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IGetPageUntyped;
|
||||
import ca.uhn.fhir.rest.gclient.IGetTags;
|
||||
import ca.uhn.fhir.rest.gclient.IHistory;
|
||||
import ca.uhn.fhir.rest.gclient.IHistoryTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IHistoryUntyped;
|
||||
import ca.uhn.fhir.rest.gclient.IMeta;
|
||||
import ca.uhn.fhir.rest.gclient.IMetaAddOrDeleteSourced;
|
||||
import ca.uhn.fhir.rest.gclient.IMetaAddOrDeleteUnsourced;
|
||||
import ca.uhn.fhir.rest.gclient.IMetaGetUnsourced;
|
||||
import ca.uhn.fhir.rest.gclient.IOperation;
|
||||
import ca.uhn.fhir.rest.gclient.IOperationProcessMsg;
|
||||
import ca.uhn.fhir.rest.gclient.IOperationProcessMsgMode;
|
||||
import ca.uhn.fhir.rest.gclient.IOperationUnnamed;
|
||||
import ca.uhn.fhir.rest.gclient.IOperationUntyped;
|
||||
import ca.uhn.fhir.rest.gclient.IOperationUntypedWithInput;
|
||||
import ca.uhn.fhir.rest.gclient.IOperationUntypedWithInputAndPartialOutput;
|
||||
import ca.uhn.fhir.rest.gclient.IParam;
|
||||
import ca.uhn.fhir.rest.gclient.IPatch;
|
||||
import ca.uhn.fhir.rest.gclient.IPatchExecutable;
|
||||
import ca.uhn.fhir.rest.gclient.IPatchWithBody;
|
||||
import ca.uhn.fhir.rest.gclient.IPatchWithQuery;
|
||||
import ca.uhn.fhir.rest.gclient.IPatchWithQueryTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IQuery;
|
||||
import ca.uhn.fhir.rest.gclient.IRead;
|
||||
import ca.uhn.fhir.rest.gclient.IReadExecutable;
|
||||
import ca.uhn.fhir.rest.gclient.IReadIfNoneMatch;
|
||||
import ca.uhn.fhir.rest.gclient.IReadTyped;
|
||||
import ca.uhn.fhir.rest.gclient.ISort;
|
||||
import ca.uhn.fhir.rest.gclient.ITransaction;
|
||||
import ca.uhn.fhir.rest.gclient.ITransactionTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IUntypedQuery;
|
||||
import ca.uhn.fhir.rest.gclient.IUpdate;
|
||||
import ca.uhn.fhir.rest.gclient.IUpdateExecutable;
|
||||
import ca.uhn.fhir.rest.gclient.IUpdateTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IUpdateWithQuery;
|
||||
import ca.uhn.fhir.rest.gclient.IUpdateWithQueryTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IValidate;
|
||||
import ca.uhn.fhir.rest.gclient.IValidateUntyped;
|
||||
import ca.uhn.fhir.rest.method.DeleteMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.HistoryMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.HttpDeleteClientInvocation;
|
||||
import ca.uhn.fhir.rest.method.HttpGetClientInvocation;
|
||||
import ca.uhn.fhir.rest.method.HttpSimpleGetClientInvocation;
|
||||
import ca.uhn.fhir.rest.method.IClientResponseHandler;
|
||||
import ca.uhn.fhir.rest.method.MethodUtil;
|
||||
import ca.uhn.fhir.rest.method.OperationMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.ReadMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.SearchMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.method.SortParameter;
|
||||
import ca.uhn.fhir.rest.method.TransactionMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.ValidateMethodBindingDstu1;
|
||||
import ca.uhn.fhir.rest.method.ValidateMethodBindingDstu2Plus;
|
||||
import ca.uhn.fhir.rest.param.DateParam;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
|
@ -87,6 +184,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
myContext = theContext;
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public IBaseConformance conformance() {
|
||||
if (myContext.getVersion().getVersion().isRi()) {
|
||||
|
@ -111,6 +209,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return new CreateInternal();
|
||||
}
|
||||
|
||||
@Deprecated // overide deprecated method
|
||||
@Override
|
||||
public MethodOutcome create(IBaseResource theResource) {
|
||||
BaseHttpClientInvocation invocation = MethodUtil.createCreateInvocation(theResource, myContext);
|
||||
|
@ -133,6 +232,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return new DeleteInternal();
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public MethodOutcome delete(final Class<? extends IBaseResource> theType, IdDt theId) {
|
||||
HttpDeleteClientInvocation invocation = DeleteMethodBinding.createDeleteInvocation(getFhirContext(), theId.withResourceType(toResourceName(theType)));
|
||||
|
@ -146,6 +246,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return resp;
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public MethodOutcome delete(Class<? extends IBaseResource> theType, String theId) {
|
||||
return delete(theType, new IdDt(theId));
|
||||
|
@ -186,13 +287,12 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
if (theNotModifiedHandler == null) {
|
||||
return invokeClient(myContext, binding, invocation, theEncoding, thePrettyPrint, myLogRequestAndResponse, theSummary, theSubsetElements);
|
||||
} else {
|
||||
}
|
||||
try {
|
||||
return invokeClient(myContext, binding, invocation, theEncoding, thePrettyPrint, myLogRequestAndResponse, theSummary, theSubsetElements);
|
||||
} catch (NotModifiedException e) {
|
||||
return theNotModifiedHandler.call();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -245,6 +345,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return new HistoryInternal();
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public <T extends IBaseResource> Bundle history(final Class<T> theType, IdDt theIdDt, DateTimeDt theSince, Integer theLimit) {
|
||||
String resourceName = theType != null ? toResourceName(theType) : null;
|
||||
|
@ -260,6 +361,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public <T extends IBaseResource> Bundle history(Class<T> theType, String theId, DateTimeDt theSince, Integer theLimit) {
|
||||
return history(theType, new IdDt(theId), theSince, theLimit);
|
||||
|
@ -409,6 +511,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
myLastRequest = theLastRequest;
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public void setLogRequestAndResponse(boolean theLogRequestAndResponse) {
|
||||
myLogRequestAndResponse = theLogRequestAndResponse;
|
||||
|
@ -423,6 +526,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return new TransactionInternal();
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public List<IBaseResource> transaction(List<IBaseResource> theResources) {
|
||||
BaseHttpClientInvocation invocation = TransactionMethodBinding.createTransactionInvocation(theResources, myContext);
|
||||
|
@ -569,6 +673,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
protected SummaryEnum mySummaryMode;
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T andLogRequestAndResponse(boolean theLogRequestAndResponse) {
|
||||
|
@ -612,9 +717,8 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
public List<Class<? extends IBaseResource>> getPreferResponseTypes(Class<? extends IBaseResource> theDefault) {
|
||||
if (myPreferResponseTypes != null) {
|
||||
return myPreferResponseTypes;
|
||||
} else {
|
||||
return toTypeList(theDefault);
|
||||
}
|
||||
return toTypeList(theDefault);
|
||||
}
|
||||
|
||||
protected HashSet<String> getSubsetElements() {
|
||||
|
@ -1207,6 +1311,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return nextOrPrevious(PREVIOUS, theBundle);
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public IGetPageTyped url(String thePageUrl) {
|
||||
return new GetPageInternal(thePageUrl);
|
||||
|
@ -1363,7 +1468,8 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private class OperationInternal extends BaseClientExecutable implements IOperation, IOperationUnnamed, IOperationUntyped, IOperationUntypedWithInput, IOperationUntypedWithInputAndPartialOutput {
|
||||
private class OperationInternal extends BaseClientExecutable
|
||||
implements IOperation, IOperationUnnamed, IOperationUntyped, IOperationUntypedWithInput, IOperationUntypedWithInputAndPartialOutput, IOperationProcessMsg, IOperationProcessMsgMode {
|
||||
|
||||
private IIdType myId;
|
||||
private String myOperationName;
|
||||
|
@ -1372,6 +1478,50 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
private Class<? extends IBaseResource> myType;
|
||||
private boolean myUseHttpGet;
|
||||
private Class myReturnResourceType;
|
||||
private IBaseBundle myMsgBundle;
|
||||
private String myResponseUrl;
|
||||
private Boolean myIsAsync;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public IOperationProcessMsgMode setMessageBundle(IBaseBundle theMsgBundle) {
|
||||
|
||||
Validate.notNull(theMsgBundle, "theMsgBundle must not be null");
|
||||
/*
|
||||
* Validate.isTrue(theMsgBundle.getType().getValueAsEnum() == BundleTypeEnum.MESSAGE);
|
||||
* Validate.isTrue(theMsgBundle.getEntries().size() > 0);
|
||||
* Validate.notNull(theMsgBundle.getEntries().get(0).getResource(), "Message Bundle first entry must be a MessageHeader resource");
|
||||
* Validate.isTrue(theMsgBundle.getEntries().get(0).getResource().getResourceName().equals("MessageHeader"), "Message Bundle first entry must be a MessageHeader resource");
|
||||
*/
|
||||
myMsgBundle = theMsgBundle;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOperationProcessMsg setResponseUrlParam(String responseUrl) {
|
||||
Validate.notEmpty(responseUrl, "responseUrl must not be null");
|
||||
Validate.matchesPattern(responseUrl, "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]", "responseUrl must be a valid URL");
|
||||
myResponseUrl = responseUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOperationProcessMsgMode asynchronous(Class theResponseClass) {
|
||||
myIsAsync = true;
|
||||
Validate.notNull(theResponseClass, "theReturnType must not be null");
|
||||
Validate.isTrue(IBaseResource.class.isAssignableFrom(theResponseClass), "theReturnType must be a class which extends from IBaseResource");
|
||||
myReturnResourceType = theResponseClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOperationProcessMsgMode synchronous(Class theResponseClass) {
|
||||
myIsAsync = false;
|
||||
Validate.notNull(theResponseClass, "theReturnType must not be null");
|
||||
Validate.isTrue(IBaseResource.class.isAssignableFrom(theResponseClass), "theReturnType must be a class which extends from IBaseResource");
|
||||
myReturnResourceType = theResponseClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void addParam(String theName, IBase theValue) {
|
||||
|
@ -1403,6 +1553,12 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOperationProcessMsg processMessage() {
|
||||
myOperationName = Constants.EXTOP_PROCESS_MESSAGE;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void addParam(String theName, IQueryParameterType theValue) {
|
||||
IPrimitiveType<?> stringType = ParametersUtil.createString(myContext, theValue.getValueAsQueryToken(myContext));
|
||||
addParam(theName, stringType);
|
||||
|
@ -1426,6 +1582,26 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object execute() {
|
||||
if (myOperationName != null && myOperationName.equals(Constants.EXTOP_PROCESS_MESSAGE)) {
|
||||
Map<String, List<String>> urlParams = new LinkedHashMap<String, List<String>>();
|
||||
// Set Url parameter Async and Response-Url
|
||||
if (myIsAsync != null) {
|
||||
urlParams.put(Constants.PARAM_ASYNC, Arrays.asList(String.valueOf(myIsAsync)));
|
||||
}
|
||||
|
||||
if (myResponseUrl != null && isNotBlank(myResponseUrl)) {
|
||||
urlParams.put(Constants.PARAM_RESPONSE_URL, Arrays.asList(String.valueOf(myResponseUrl)));
|
||||
}
|
||||
// If is $process-message operation
|
||||
BaseHttpClientInvocation invocation = OperationMethodBinding.createProcessMsgInvocation(myContext, myOperationName, myMsgBundle, urlParams);
|
||||
|
||||
ResourceResponseHandler handler = new ResourceResponseHandler();
|
||||
handler.setPreferResponseTypes(getPreferResponseTypes(myType));
|
||||
|
||||
Object retVal = invoke(null, handler, invocation);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
String resourceName;
|
||||
String id;
|
||||
if (myType != null) {
|
||||
|
@ -1446,7 +1622,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
handler = new ResourceResponseHandler(myReturnResourceType);
|
||||
Object retVal = invoke(null, handler, invocation);
|
||||
return retVal;
|
||||
} else {
|
||||
}
|
||||
ResourceResponseHandler handler;
|
||||
handler = new ResourceResponseHandler();
|
||||
handler.setPreferResponseTypes(getPreferResponseTypes(myType));
|
||||
|
@ -1454,7 +1630,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
Object retVal = invoke(null, handler, invocation);
|
||||
if (myContext.getResourceDefinition((IBaseResource) retVal).getName().equals("Parameters")) {
|
||||
return retVal;
|
||||
} else {
|
||||
}
|
||||
RuntimeResourceDefinition def = myContext.getResourceDefinition("Parameters");
|
||||
IBaseResource parameters = def.newInstance();
|
||||
|
||||
|
@ -1468,8 +1644,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOperationUntyped named(String theName) {
|
||||
|
@ -1591,10 +1765,10 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
private final class OutcomeResponseHandler implements IClientResponseHandler<MethodOutcome> {
|
||||
private PreferReturnEnum myPrefer;
|
||||
private final String myResourceName;
|
||||
// private final String myResourceName;
|
||||
|
||||
private OutcomeResponseHandler(String theResourceName) {
|
||||
myResourceName = theResourceName;
|
||||
// myResourceName = theResourceName;
|
||||
}
|
||||
|
||||
private OutcomeResponseHandler(String theResourceName, PreferReturnEnum thePrefer) {
|
||||
|
@ -1634,9 +1808,8 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
public Object execute() {// AAA
|
||||
if (myId.hasVersionIdPart()) {
|
||||
return doReadOrVRead(myType.getImplementingClass(), myId, true, myNotModifiedHandler, myIfVersionMatches, myPrettyPrint, mySummaryMode, myParamEncoding, getSubsetElements());
|
||||
} else {
|
||||
return doReadOrVRead(myType.getImplementingClass(), myId, false, myNotModifiedHandler, myIfVersionMatches, myPrettyPrint, mySummaryMode, myParamEncoding, getSubsetElements());
|
||||
}
|
||||
return doReadOrVRead(myType.getImplementingClass(), myId, false, myNotModifiedHandler, myIfVersionMatches, myPrettyPrint, mySummaryMode, myParamEncoding, getSubsetElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1774,9 +1947,8 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
IVersionSpecificBundleFactory bundleFactory = myContext.newBundleFactory();
|
||||
bundleFactory.initializeWithBundleResource(response);
|
||||
return bundleFactory.toListOfResources();
|
||||
} else {
|
||||
return new ArrayList<IBaseResource>(new BundleResponseHandler(myType).invokeClient(theResponseMimeType, theResponseReader, theResponseStatusCode, theHeaders).toListOfResources());
|
||||
}
|
||||
return new ArrayList<IBaseResource>(new BundleResponseHandler(myType).invokeClient(theResponseMimeType, theResponseReader, theResponseStatusCode, theHeaders).toListOfResources());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1850,6 +2022,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public IBase execute() {
|
||||
|
||||
|
@ -1889,8 +2062,12 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
}
|
||||
|
||||
for (Include next : myRevInclude) {
|
||||
if (next.isRecurse()) {
|
||||
addParam(params, Constants.PARAM_REVINCLUDE_RECURSE, next.getValue());
|
||||
} else {
|
||||
addParam(params, Constants.PARAM_REVINCLUDE, next.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU2)) {
|
||||
SortSpec rootSs = null;
|
||||
|
@ -1902,8 +2079,11 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
if (rootSs == null) {
|
||||
rootSs = nextSortSpec;
|
||||
} else {
|
||||
// FIXME lastSs is null never set
|
||||
// TODO unused assignment
|
||||
lastSs.setChain(nextSortSpec);
|
||||
}
|
||||
// TODO unused assignment
|
||||
lastSs = nextSortSpec;
|
||||
}
|
||||
if (rootSs != null) {
|
||||
|
@ -1979,6 +2159,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Deprecated // override deprecated method
|
||||
@Override
|
||||
public IQuery limitTo(int theLimitTo) {
|
||||
return count(theLimitTo);
|
||||
|
@ -2312,7 +2493,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPatchWithQueryTyped where(ICriterion<?> theCriterion) {
|
||||
myCriterionList.add((ICriterionInternal) theCriterion);
|
||||
|
|
|
@ -318,12 +318,13 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
String serverFhirVersionString = null;
|
||||
Object value = t.getSingleValueOrNull(conformance, "fhirVersion");
|
||||
if (value instanceof IPrimitiveType) {
|
||||
serverFhirVersionString = ((IPrimitiveType<?>) value).getValueAsString();
|
||||
serverFhirVersionString = IPrimitiveType.class.cast(value).getValueAsString();
|
||||
}
|
||||
FhirVersionEnum serverFhirVersionEnum = null;
|
||||
if (StringUtils.isBlank(serverFhirVersionString)) {
|
||||
// we'll be lenient and accept this
|
||||
} else {
|
||||
//FIXME null access on serverFhirVersionString
|
||||
if (serverFhirVersionString.startsWith("0.80") || serverFhirVersionString.startsWith("0.0.8")) {
|
||||
serverFhirVersionEnum = FhirVersionEnum.DSTU1;
|
||||
} else if (serverFhirVersionString.startsWith("0.4")) {
|
||||
|
@ -347,11 +348,13 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory {
|
|||
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public ServerValidationModeEnum getServerValidationModeEnum() {
|
||||
return getServerValidationMode();
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public void setServerValidationModeEnum(ServerValidationModeEnum theServerValidationMode) {
|
||||
setServerValidationMode(theServerValidationMode);
|
||||
|
|
|
@ -30,7 +30,13 @@ import org.apache.http.HttpEntity;
|
|||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpOptions;
|
||||
import org.apache.http.client.methods.HttpPatch;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
|
@ -47,7 +53,6 @@ import ca.uhn.fhir.rest.server.EncodingEnum;
|
|||
import ca.uhn.fhir.rest.server.RestfulServerUtils;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.util.CoverageIgnore;
|
||||
import ca.uhn.fhir.util.VersionUtil;
|
||||
|
||||
/**
|
||||
* A Http Client based on Apache. This is an adapter around the class
|
||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.rest.client.apache;
|
|||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -92,7 +93,8 @@ public class ApacheHttpRequest implements IHttpRequest {
|
|||
if (myRequest instanceof HttpEntityEnclosingRequest) {
|
||||
HttpEntity entity = ((HttpEntityEnclosingRequest) myRequest).getEntity();
|
||||
if (entity.isRepeatable()) {
|
||||
return IOUtils.toString(entity.getContent());
|
||||
//TODO verify the charset
|
||||
return IOUtils.toString(entity.getContent(), Charset.defaultCharset());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -61,6 +61,7 @@ public class ApacheHttpResponse implements IHttpResponse {
|
|||
this.myResponse = theResponse;
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public void bufferEntitity() throws IOException {
|
||||
bufferEntity();
|
||||
|
@ -77,6 +78,7 @@ public class ApacheHttpResponse implements IHttpResponse {
|
|||
try {
|
||||
this.myEntityBytes = IOUtils.toByteArray(respEntity);
|
||||
} catch (IllegalStateException e) {
|
||||
//FIXME resouce leak
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,12 +73,14 @@ public class ApacheRestfulClientFactory extends RestfulClientFactory {
|
|||
public synchronized HttpClient getNativeHttpClient() {
|
||||
if (myHttpClient == null) {
|
||||
|
||||
//FIXME potential resoource leak
|
||||
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
connectionManager.setMaxTotal(getPoolMaxTotal());
|
||||
connectionManager.setDefaultMaxPerRoute(getPoolMaxPerRoute());
|
||||
|
||||
// @formatter:off
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
RequestConfig defaultRequestConfig = RequestConfig.custom().setSocketTimeout(getSocketTimeout())
|
||||
.setConnectTimeout(getConnectTimeout()).setConnectionRequestTimeout(getConnectionRequestTimeout())
|
||||
.setStaleConnectionCheckEnabled(true).setProxy(myProxy).build();
|
||||
|
|
|
@ -120,6 +120,7 @@ public class LoggingInterceptor implements IClientInterceptor {
|
|||
}
|
||||
|
||||
if (myLogResponseBody) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
theResponse.bufferEntitity();
|
||||
InputStream respEntity = null;
|
||||
try {
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Date;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.rest.gclient.DateClientParam.IDateSpecifier;
|
||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,9 +19,40 @@ package ca.uhn.fhir.rest.gclient;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
public interface IOperation extends IBaseOn<IOperationUnnamed> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This operation is called <b><a href="https://www.hl7.org/fhir/messaging.html">$process-message</a></b> as defined by the FHIR
|
||||
* specification.<br><br>
|
||||
* Usage :<br>
|
||||
* <code>
|
||||
* <pre>
|
||||
* Bundle response = client
|
||||
* .operation()
|
||||
* .processMessage()
|
||||
* .synchronous(Bundle.class)
|
||||
* .setResponseUrlParam("http://myserver/fhir")
|
||||
* .setMessageBundle(msgBundle)
|
||||
* .execute();
|
||||
*
|
||||
* //if you want to send an async message
|
||||
*
|
||||
* OperationOutcome response = client
|
||||
* .operation()
|
||||
* .processMessage()
|
||||
* .asynchronous(OperationOutcome.class)
|
||||
* .setResponseUrlParam("http://myserver/fhir")
|
||||
* .setMessageBundle(msgBundle)
|
||||
* .execute();
|
||||
*
|
||||
* </pre>
|
||||
* </code>
|
||||
*
|
||||
* @see <a href="https://www.hl7.org/fhir/messaging.html">2.4 Messaging
|
||||
* using FHIR Resources</a>
|
||||
*
|
||||
* @return An interface that defines the operation related to sending
|
||||
* Messages to a Messaging Server
|
||||
*/
|
||||
IOperationProcessMsg processMessage();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package ca.uhn.fhir.rest.gclient;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author HGS
|
||||
*/
|
||||
public interface IOperationProcessMsg{
|
||||
|
||||
/**
|
||||
* Set the Message Bundle to POST to the messaging server.<br>
|
||||
* After this call you must choose either the method synchronous or asynchronous to set the processing mode.
|
||||
*
|
||||
* @param <R>
|
||||
* @param theMsgBundle A Bundle of type message
|
||||
* @return
|
||||
*/
|
||||
<R extends IBaseResource> IOperationProcessMsgMode<R> setMessageBundle(IBaseBundle theMsgBundle);
|
||||
|
||||
/**
|
||||
* An optional query parameter indicating that responses from the receiving server should be sent to this url
|
||||
*
|
||||
* @param respondToUri The receiving endpoint to witch server response messages should be sent.
|
||||
* @return
|
||||
*/
|
||||
IOperationProcessMsg setResponseUrlParam(String respondToUri);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package ca.uhn.fhir.rest.gclient;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2017 University Health Network
|
||||
* %%
|
||||
* 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 interface IOperationProcessMsgMode<T extends IBaseResource> extends IClientExecutable<IOperationProcessMsgMode<T>, T> {
|
||||
|
||||
<R extends IBaseResource> IOperationProcessMsgMode<R> asynchronous(Class<R> theResponseClass);
|
||||
|
||||
<R extends IBaseResource> IOperationProcessMsgMode<R> synchronous(Class<R> theResponseClass);
|
||||
}
|
|
@ -24,5 +24,4 @@ package ca.uhn.fhir.rest.gclient;
|
|||
public interface IOperationUnnamed {
|
||||
|
||||
IOperationUntyped named(String theName);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package ca.uhn.fhir.rest.gclient;
|
|||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ package ca.uhn.fhir.rest.method;
|
|||
*/
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
|
|
|
@ -200,13 +200,12 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
|
|||
|
||||
if (myParams != null) {
|
||||
return httpClient.createParamRequest(getContext(), myParams, encoding);
|
||||
} else {
|
||||
}
|
||||
encoding = ObjectUtils.defaultIfNull(encoding, EncodingEnum.XML);
|
||||
String contents = encodeContents(thePrettyPrint, encoding);
|
||||
String contentType = getContentType(encoding);
|
||||
return httpClient.createByteRequest(getContext(), contents, contentType, encoding);
|
||||
}
|
||||
}
|
||||
|
||||
private String getContentType(EncodingEnum encoding) {
|
||||
if (myBundle != null || (getContext().getVersion().getVersion() == FhirVersionEnum.DSTU1 && ((myContents != null && myContentsIsBundle) || myResources != null))) {
|
||||
|
@ -253,10 +252,9 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
|
|||
Bundle bundle = bundleFactory.getDstu1Bundle();
|
||||
if (bundle != null) {
|
||||
return parser.encodeBundleToString(bundle);
|
||||
} else {
|
||||
}
|
||||
IBaseResource bundleRes = bundleFactory.getResourceBundle();
|
||||
return parser.encodeResourceToString(bundleRes);
|
||||
}
|
||||
} else if (myContents != null) {
|
||||
return myContents;
|
||||
} else {
|
||||
|
|
|
@ -259,9 +259,8 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
} catch (InvocationTargetException e) {
|
||||
if (e.getCause() instanceof BaseServerResponseException) {
|
||||
throw (BaseServerResponseException) e.getCause();
|
||||
} else {
|
||||
throw new InternalErrorException("Failed to call access method", e);
|
||||
}
|
||||
throw new InternalErrorException("Failed to call access method", e);
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException("Failed to call access method", e);
|
||||
}
|
||||
|
@ -455,6 +454,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
if (returnTypeFromRp != null) {
|
||||
if (returnTypeFromAnnotation != null && !isResourceInterface(returnTypeFromAnnotation)) {
|
||||
if (!returnTypeFromRp.isAssignableFrom(returnTypeFromAnnotation)) {
|
||||
//FIXME potential null access on retunrTypeFromMethod
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " returns type "
|
||||
+ returnTypeFromMethod.getCanonicalName() + " - Must return " + returnTypeFromRp.getCanonicalName() + " (or a subclass of it) per IResourceProvider contract");
|
||||
}
|
||||
|
@ -492,9 +492,8 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
if (search.dynamic()) {
|
||||
IDynamicSearchResourceProvider provider = (IDynamicSearchResourceProvider) theProvider;
|
||||
return new DynamicSearchMethodBinding(returnType, theMethod, theContext, provider);
|
||||
} else {
|
||||
return new SearchMethodBinding(returnType, theMethod, theContext, theProvider);
|
||||
}
|
||||
return new SearchMethodBinding(returnType, theMethod, theContext, theProvider);
|
||||
} else if (conformance != null) {
|
||||
return new ConformanceMethodBinding(theMethod, theContext, theProvider);
|
||||
} else if (create != null) {
|
||||
|
@ -510,9 +509,8 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
} else if (validate != null) {
|
||||
if (theContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
|
||||
return new ValidateMethodBindingDstu1(theMethod, theContext, theProvider);
|
||||
} else {
|
||||
return new ValidateMethodBindingDstu2Plus(returnType, returnTypeFromRp, theMethod, theContext, theProvider, validate);
|
||||
}
|
||||
return new ValidateMethodBindingDstu2Plus(returnType, returnTypeFromRp, theMethod, theContext, theProvider, validate);
|
||||
} else if (getTags != null) {
|
||||
return new GetTagsMethodBinding(theMethod, theContext, theProvider, getTags);
|
||||
} else if (addTags != null) {
|
||||
|
|
|
@ -101,16 +101,14 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
|||
}
|
||||
if (response.getCreated() == null || Boolean.TRUE.equals(response.getCreated())) {
|
||||
return Constants.STATUS_HTTP_201_CREATED;
|
||||
} else {
|
||||
return Constants.STATUS_HTTP_200_OK;
|
||||
}
|
||||
return Constants.STATUS_HTTP_200_OK;
|
||||
|
||||
case UPDATE:
|
||||
if (response == null || response.getCreated() == null || Boolean.FALSE.equals(response.getCreated())) {
|
||||
return Constants.STATUS_HTTP_200_OK;
|
||||
} else {
|
||||
return Constants.STATUS_HTTP_201_CREATED;
|
||||
}
|
||||
return Constants.STATUS_HTTP_201_CREATED;
|
||||
|
||||
case VALIDATE:
|
||||
case DELETE:
|
||||
|
@ -120,15 +118,13 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
|||
throw new InternalErrorException("Method " + getMethod().getName() + " in type " + getMethod().getDeclaringClass().getCanonicalName() + " returned null");
|
||||
}
|
||||
return Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
} else {
|
||||
}
|
||||
if (response.getOperationOutcome() == null) {
|
||||
return Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
} else {
|
||||
}
|
||||
return Constants.STATUS_HTTP_200_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
|
||||
|
@ -168,9 +164,8 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
|||
}
|
||||
MethodOutcome retVal = MethodUtil.process2xxResponse(getContext(), theResponseStatusCode, theResponseMimeType, theResponseReader, theHeaders);
|
||||
return retVal;
|
||||
} else {
|
||||
throw processNon2xxResponseAndReturnExceptionToThrow(theResponseStatusCode, theResponseMimeType, theResponseReader);
|
||||
}
|
||||
throw processNon2xxResponseAndReturnExceptionToThrow(theResponseStatusCode, theResponseMimeType, theResponseReader);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,9 +27,9 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.annotation.Delete;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
//TODO Use of a deprecated method should be resolved
|
||||
import ca.uhn.fhir.rest.annotation.VersionIdParam;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
|
||||
|
@ -62,6 +62,7 @@ public abstract class BaseOutcomeReturningMethodBindingWithResourceIdButNoResour
|
|||
|
||||
Integer versionIdParameterIndex = MethodUtil.findVersionIdParameterIndex(theMethod);
|
||||
if (versionIdParameterIndex != null) {
|
||||
//TODO Use of a deprecated method should be resolved
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has a parameter annotated with the @" + VersionIdParam.class.getSimpleName() + " annotation but delete methods may not have this annotation");
|
||||
}
|
||||
|
||||
|
|
|
@ -152,9 +152,8 @@ abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOu
|
|||
/**
|
||||
* Subclasses may override
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected void validateResourceIdAndUrlIdForNonConditionalOperation(IBaseResource theResource, String theResourceId, String theUrlId, String theMatchUrl) {
|
||||
// nothing by default
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -190,6 +190,7 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
|||
}
|
||||
return listOfResources;
|
||||
case RESOURCE:
|
||||
//FIXME null access on dstu1bundle
|
||||
List<IResource> list = dstu1bundle.toListOfResources();
|
||||
if (list.size() == 0) {
|
||||
return null;
|
||||
|
@ -272,7 +273,7 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
|||
return theRequest.getResponse().streamResponseAsResource(responseObject.getResource(), prettyPrint, summaryMode, Constants.STATUS_HTTP_200_OK, null, theRequest.isRespondGzip(),
|
||||
isAddContentLocationHeader());
|
||||
|
||||
} else {
|
||||
}
|
||||
// Is this request coming from a browser
|
||||
String uaHeader = theRequest.getHeader("user-agent");
|
||||
boolean requestIsBrowser = false;
|
||||
|
@ -291,7 +292,6 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
|||
|
||||
return theRequest.getResponse().streamResponseAsBundle(responseObject.getDstu1Bundle(), summaryMode, theRequest.isRespondGzip(), requestIsBrowser);
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceOrDstu1Bundle doInvokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) {
|
||||
// Method params
|
||||
|
@ -363,8 +363,6 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
|||
bundleFactory.addRootPropertiesToBundle(null, theRequest.getFhirServerBase(), linkSelf, count, getResponseBundleType(), lastUpdated);
|
||||
|
||||
responseObject = new ResourceOrDstu1Bundle(resource);
|
||||
break;
|
||||
|
||||
} else {
|
||||
Set<Include> includes = getRequestIncludesFromParams(params);
|
||||
|
||||
|
@ -394,9 +392,8 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
|||
IBaseResource resBundle = bundleFactory.getResourceBundle();
|
||||
responseObject = new ResourceOrDstu1Bundle(resBundle);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RESOURCE: {
|
||||
IBundleProvider result = (IBundleProvider) resultObj;
|
||||
|
|
|
@ -19,14 +19,12 @@ package ca.uhn.fhir.rest.method;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
|
@ -34,7 +32,6 @@ import ca.uhn.fhir.context.ConfigurationException;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.annotation.ConditionalUrlParam;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
||||
|
|
|
@ -93,9 +93,8 @@ public class ConformanceMethodBinding extends BaseResourceReturningMethodBinding
|
|||
if ("metadata".equals(theRequest.getOperation())) {
|
||||
if (theRequest.getRequestType() == RequestTypeEnum.GET) {
|
||||
return true;
|
||||
} else {
|
||||
throw new MethodNotAllowedException("/metadata request must use HTTP GET", RequestTypeEnum.GET);
|
||||
}
|
||||
throw new MethodNotAllowedException("/metadata request must use HTTP GET", RequestTypeEnum.GET);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -86,7 +86,7 @@ public class DynamicSearchMethodBinding extends BaseResourceReturningMethodBindi
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBundleProvider invokeServer(IRestfulServer theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException {
|
||||
public IBundleProvider invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException {
|
||||
if (myIdParamIndex != null) {
|
||||
theMethodParams[myIdParamIndex] = theRequest.getId();
|
||||
}
|
||||
|
|
|
@ -113,9 +113,8 @@ public class ElementsParameter implements IParameter {
|
|||
retVal.add("meta");
|
||||
|
||||
return retVal;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,8 +20,6 @@ package ca.uhn.fhir.rest.method;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
|
|
|
@ -156,12 +156,9 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
|
|||
IParser parser = createAppropriateParserForParsingResponse(theResponseMimeType, theResponseReader, theResponseStatusCode, null);
|
||||
TagList retVal = parser.parseTagList(theResponseReader);
|
||||
return retVal;
|
||||
} else {
|
||||
}
|
||||
throw processNon2xxResponseAndReturnExceptionToThrow(theResponseStatusCode, theResponseMimeType, theResponseReader);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) throws BaseServerResponseException, IOException {
|
||||
Object[] params = createParametersForServerRequest(theRequest);
|
||||
|
|
|
@ -171,7 +171,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
return new IBundleProvider() {
|
||||
|
||||
@Override
|
||||
public InstantDt getPublished() {
|
||||
public IPrimitiveType<Date> getPublished() {
|
||||
return resources.getPublished();
|
||||
}
|
||||
|
||||
|
@ -184,6 +184,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
throw new InternalErrorException("Server provided resource at index " + index + " with no ID set (using IResource#setId(IdDt))");
|
||||
}
|
||||
if (isBlank(nextResource.getIdElement().getVersionIdPart()) && nextResource instanceof IResource) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
IdDt versionId = (IdDt) ResourceMetadataKeyEnum.VERSION_ID.get((IResource) nextResource);
|
||||
if (versionId == null || versionId.isEmpty()) {
|
||||
throw new InternalErrorException("Server provided resource at index " + index + " with no Version ID set (using IResource#setId(IdDt))");
|
||||
|
@ -201,7 +202,12 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
|
||||
@Override
|
||||
public Integer preferredPageSize() {
|
||||
return null;
|
||||
return resources.preferredPageSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return resources.getUuid();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -149,13 +149,12 @@ class IncludeParameter extends BaseQueryParameter {
|
|||
if (myInstantiableCollectionType == null) {
|
||||
if (mySpecType == String.class) {
|
||||
return value;
|
||||
} else {
|
||||
}
|
||||
return new Include(value, recurse);
|
||||
}
|
||||
} else {
|
||||
//FIXME null access
|
||||
retValCollection.add(new Include(value, recurse));
|
||||
}
|
||||
}
|
||||
|
||||
return retValCollection;
|
||||
}
|
||||
|
|
|
@ -482,9 +482,8 @@ public class MethodUtil {
|
|||
OperationParameter.throwInvalidMode(theObject.toString());
|
||||
}
|
||||
return retVal;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -671,6 +670,7 @@ public class MethodUtil {
|
|||
break;
|
||||
}
|
||||
|
||||
//FIXME null access
|
||||
return binder.parse(theContext, theUnqualifiedParamName, theParameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
@ -75,7 +76,8 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
private List<ReturnType> myReturnParams;
|
||||
private final ReturnTypeEnum myReturnType;
|
||||
|
||||
protected OperationMethodBinding(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider, boolean theIdempotent, String theOperationName, Class<? extends IBaseResource> theOperationType,
|
||||
protected OperationMethodBinding(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider,
|
||||
boolean theIdempotent, String theOperationName, Class<? extends IBaseResource> theOperationType,
|
||||
OperationParam[] theReturnParams, BundleTypeEnum theBundleType) {
|
||||
super(theReturnResourceType, theMethod, theContext, theProvider);
|
||||
|
||||
|
@ -104,7 +106,8 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
}
|
||||
|
||||
if (isBlank(theOperationName)) {
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' on type " + theMethod.getDeclaringClass().getName() + " is annotated with @" + Operation.class.getSimpleName() + " but this annotation has no name defined");
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' on type " + theMethod.getDeclaringClass().getName() + " is annotated with @" + Operation.class.getSimpleName()
|
||||
+ " but this annotation has no name defined");
|
||||
}
|
||||
if (theOperationName.startsWith("$") == false) {
|
||||
theOperationName = "$" + theOperationName;
|
||||
|
@ -112,7 +115,8 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
myName = theOperationName;
|
||||
|
||||
if (theContext.getVersion().getVersion().isEquivalentTo(FhirVersionEnum.DSTU1)) {
|
||||
throw new ConfigurationException("@" + Operation.class.getSimpleName() + " methods are not supported on servers for FHIR version " + theContext.getVersion().getVersion().name() + " - Found one on class " + theMethod.getDeclaringClass().getName());
|
||||
throw new ConfigurationException("@" + Operation.class.getSimpleName() + " methods are not supported on servers for FHIR version " + theContext.getVersion().getVersion().name()
|
||||
+ " - Found one on class " + theMethod.getDeclaringClass().getName());
|
||||
}
|
||||
|
||||
if (theReturnTypeFromRp != null) {
|
||||
|
@ -126,7 +130,8 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
}
|
||||
|
||||
if (theMethod.getReturnType().isAssignableFrom(Bundle.class)) {
|
||||
throw new ConfigurationException("Can not return a DSTU1 bundle from an @" + Operation.class.getSimpleName() + " method. Found in method " + theMethod.getName() + " defined in type " + theMethod.getDeclaringClass().getName());
|
||||
throw new ConfigurationException("Can not return a DSTU1 bundle from an @" + Operation.class.getSimpleName() + " method. Found in method " + theMethod.getName() + " defined in type "
|
||||
+ theMethod.getDeclaringClass().getName());
|
||||
}
|
||||
|
||||
if (theMethod.getReturnType().equals(IBundleProvider.class)) {
|
||||
|
@ -172,8 +177,10 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
|
||||
}
|
||||
|
||||
public OperationMethodBinding(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider, Operation theAnnotation) {
|
||||
this(theReturnResourceType, theReturnTypeFromRp, theMethod, theContext, theProvider, theAnnotation.idempotent(), theAnnotation.name(), theAnnotation.type(), theAnnotation.returnParameters(), theAnnotation.bundleType());
|
||||
public OperationMethodBinding(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider,
|
||||
Operation theAnnotation) {
|
||||
this(theReturnResourceType, theReturnTypeFromRp, theMethod, theContext, theProvider, theAnnotation.idempotent(), theAnnotation.name(), theAnnotation.type(), theAnnotation.returnParameters(),
|
||||
theAnnotation.bundleType());
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
@ -281,11 +288,10 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
if (!myIdempotent) {
|
||||
String message = getContext().getLocalizer().getMessage(OperationMethodBinding.class, "methodNotSupported", theRequest.getRequestType(), RequestTypeEnum.POST.name());
|
||||
throw new MethodNotAllowedException(message, RequestTypeEnum.POST);
|
||||
} else {
|
||||
}
|
||||
String message = getContext().getLocalizer().getMessage(OperationMethodBinding.class, "methodNotSupported", theRequest.getRequestType(), RequestTypeEnum.GET.name(), RequestTypeEnum.POST.name());
|
||||
throw new MethodNotAllowedException(message, RequestTypeEnum.GET, RequestTypeEnum.POST);
|
||||
}
|
||||
}
|
||||
|
||||
if (myIdParamIndex != null) {
|
||||
theMethodParams[myIdParamIndex] = theRequest.getId();
|
||||
|
@ -322,7 +328,8 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
myDescription = theDescription;
|
||||
}
|
||||
|
||||
public static BaseHttpClientInvocation createOperationInvocation(FhirContext theContext, String theResourceName, String theId, String theOperationName, IBaseParameters theInput, boolean theUseHttpGet) {
|
||||
public static BaseHttpClientInvocation createOperationInvocation(FhirContext theContext, String theResourceName, String theId, String theOperationName, IBaseParameters theInput,
|
||||
boolean theUseHttpGet) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
if (theResourceName != null) {
|
||||
b.append(theResourceName);
|
||||
|
@ -341,7 +348,7 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
|
||||
if (!theUseHttpGet) {
|
||||
return new HttpPostClientInvocation(theContext, theInput, b.toString());
|
||||
} else {
|
||||
}
|
||||
FhirTerser t = theContext.newTerser();
|
||||
List<Object> parameters = t.getValues(theInput, "Parameters.parameter");
|
||||
|
||||
|
@ -362,13 +369,30 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
continue;
|
||||
}
|
||||
if (!(value instanceof IPrimitiveType)) {
|
||||
throw new IllegalArgumentException("Can not invoke operation as HTTP GET when it has parameters with a composite (non priitive) datatype as the value. Found value: " + value.getClass().getName());
|
||||
throw new IllegalArgumentException(
|
||||
"Can not invoke operation as HTTP GET when it has parameters with a composite (non priitive) datatype as the value. Found value: " + value.getClass().getName());
|
||||
}
|
||||
IPrimitiveType<?> primitive = (IPrimitiveType<?>) value;
|
||||
params.get(nextName).add(primitive.getValueAsString());
|
||||
}
|
||||
return new HttpGetClientInvocation(theContext, params, b.toString());
|
||||
}
|
||||
|
||||
public static BaseHttpClientInvocation createProcessMsgInvocation(FhirContext theContext, String theOperationName, IBaseBundle theInput, Map<String, List<String>> urlParams) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
|
||||
if (b.length() > 0) {
|
||||
b.append('/');
|
||||
}
|
||||
if (!theOperationName.startsWith("$")) {
|
||||
b.append("$");
|
||||
}
|
||||
b.append(theOperationName);
|
||||
|
||||
BaseHttpClientInvocation.appendExtraParamsWithQuestionMark(urlParams, b, b.indexOf("?") == -1);
|
||||
|
||||
return new HttpPostClientInvocation(theContext, theInput, b.toString());
|
||||
|
||||
}
|
||||
|
||||
public static class ReturnType {
|
||||
|
|
|
@ -136,9 +136,8 @@ public class OperationParameter implements IParameter {
|
|||
public String getSearchParamType() {
|
||||
if (mySearchParameterBinding != null) {
|
||||
return mySearchParameterBinding.getParamType().getCode();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -326,7 +325,7 @@ public class OperationParameter implements IParameter {
|
|||
} else {
|
||||
for (String nextValue : paramValues) {
|
||||
FhirContext ctx = theRequest.getServer().getFhirContext();
|
||||
RuntimePrimitiveDatatypeDefinition def = (RuntimePrimitiveDatatypeDefinition) ctx.getElementDefinition((Class<? extends IBase>) myParameterType);
|
||||
RuntimePrimitiveDatatypeDefinition def = (RuntimePrimitiveDatatypeDefinition) ctx.getElementDefinition(myParameterType.asSubclass(IBase.class));
|
||||
IPrimitiveType<?> instance = def.newInstance();
|
||||
instance.setValueAsString(nextValue);
|
||||
matchingParamValues.add(instance);
|
||||
|
|
|
@ -81,9 +81,8 @@ public class PageMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
IBase bundle = handlePagingRequest(theServer, theRequest, theRequest.getParameters().get(Constants.PARAM_PAGINGACTION)[0]);
|
||||
if (bundle instanceof Bundle) {
|
||||
return new ResourceOrDstu1Bundle((Bundle) bundle);
|
||||
} else {
|
||||
return new ResourceOrDstu1Bundle((IBaseResource) bundle);
|
||||
}
|
||||
return new ResourceOrDstu1Bundle((IBaseResource) bundle);
|
||||
}
|
||||
|
||||
private IBase handlePagingRequest(IRestfulServer<?> theServer, RequestDetails theRequest, String thePagingAction) {
|
||||
|
@ -144,9 +143,8 @@ public class PageMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
Bundle bundle = bundleFactory.getDstu1Bundle();
|
||||
if (bundle != null) {
|
||||
return bundle;
|
||||
} else {
|
||||
return bundleFactory.getResourceBundle();
|
||||
}
|
||||
return bundleFactory.getResourceBundle();
|
||||
// if (bundle != null) {
|
||||
// for (int i = getInterceptors().size() - 1; i >= 0; i--) {
|
||||
// IServerInterceptor next = getInterceptors().get(i);
|
||||
|
|
|
@ -23,8 +23,6 @@ package ca.uhn.fhir.rest.method;
|
|||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import ca.uhn.fhir.rest.api.PatchTypeEnum;
|
|||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
|
||||
class PatchTypeParameter implements IParameter {
|
||||
@Override
|
||||
|
|
|
@ -120,9 +120,8 @@ public class QualifiedParamList extends ArrayList<String> {
|
|||
char nextChar = theString.charAt(i);
|
||||
if (nextChar != '\\') {
|
||||
break;
|
||||
} else {
|
||||
retVal++;
|
||||
}
|
||||
retVal++;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -99,9 +99,8 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
|
|||
public RestOperationTypeEnum getRestOperationType(RequestDetails theRequestDetails) {
|
||||
if (mySupportsVersion && theRequestDetails.getId().hasVersionIdPart()) {
|
||||
return RestOperationTypeEnum.VREAD;
|
||||
} else {
|
||||
return RestOperationTypeEnum.READ;
|
||||
}
|
||||
return RestOperationTypeEnum.READ;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,11 +30,10 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.CoverageIgnore;
|
||||
|
||||
class RequestOperationCallbackParameter implements IParameter {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServletRequestParameter.class);
|
||||
// private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServletRequestParameter.class);
|
||||
|
||||
@CoverageIgnore
|
||||
@Override
|
||||
|
|
|
@ -225,9 +225,8 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
if (!myQueryName.equals(queryName)) {
|
||||
ourLog.trace("Query name does not match {}", myQueryName);
|
||||
return false;
|
||||
} else {
|
||||
methodParamsTemp.add(Constants.PARAM_QUERY);
|
||||
}
|
||||
methodParamsTemp.add(Constants.PARAM_QUERY);
|
||||
} else {
|
||||
ourLog.trace("Query name does not match {}", myQueryName);
|
||||
return false;
|
||||
|
@ -346,9 +345,8 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
if (theId == null || !theId.hasIdPart()) {
|
||||
String msg = theContext.getLocalizer().getMessage(SearchMethodBinding.class.getName() + ".idNullForCompartmentSearch");
|
||||
throw new InvalidRequestException(msg);
|
||||
} else {
|
||||
compartmentSearch = true;
|
||||
}
|
||||
compartmentSearch = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -283,8 +283,10 @@ public class SearchParameter extends BaseQueryParameter {
|
|||
this.myRequired = required;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setType(FhirContext theContext, final Class<?> type, Class<? extends Collection<?>> theInnerCollectionType, Class<? extends Collection<?>> theOuterCollectionType) {
|
||||
|
||||
|
||||
this.myType = type;
|
||||
if (IQueryParameterType.class.isAssignableFrom(type)) {
|
||||
myParamBinder = new QueryParameterTypeBinder((Class<? extends IQueryParameterType>) type, myCompositeTypes);
|
||||
|
|
|
@ -20,36 +20,18 @@ package ca.uhn.fhir.rest.method;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.annotation.Since;
|
||||
import ca.uhn.fhir.rest.param.ParameterUtil;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
||||
class SinceOrAtParameter extends SearchParameter {
|
||||
|
||||
private Class<?> myType;
|
||||
private String myParamName;
|
||||
private Class<?> myAnnotationType;
|
||||
// private Class<?> myType;
|
||||
// private String myParamName;
|
||||
// private Class<?> myAnnotationType;
|
||||
|
||||
public SinceOrAtParameter(String theParamName, Class<?> theAnnotationType) {
|
||||
super(theParamName, false);
|
||||
myParamName = theParamName;
|
||||
myAnnotationType = theAnnotationType;
|
||||
// myParamName = theParamName;
|
||||
// myAnnotationType = theAnnotationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -112,16 +112,15 @@ public class TransactionMethodBinding extends BaseResourceReturningMethodBinding
|
|||
if (theArgs[myTransactionParamIndex] instanceof Bundle) {
|
||||
Bundle bundle = (Bundle) theArgs[myTransactionParamIndex];
|
||||
return createTransactionInvocation(bundle, context);
|
||||
} else {
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IBaseResource> resources = (List<IBaseResource>) theArgs[myTransactionParamIndex];
|
||||
return createTransactionInvocation(resources, context);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object invokeServer(IRestfulServer theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException {
|
||||
public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException {
|
||||
|
||||
/*
|
||||
* The design of HAPI's transaction method for DSTU1 support assumed that a transaction was just an update on a
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.Update;
|
||||
|
@ -150,12 +149,11 @@ public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
|||
if (isBlank(theResourceId)) {
|
||||
String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "noIdInBodyForUpdate");
|
||||
throw new InvalidRequestException(msg);
|
||||
} else {
|
||||
}
|
||||
if (!theResourceId.equals(theUrlId)) {
|
||||
String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "incorrectIdForUpdate", theResourceId, theUrlId);
|
||||
throw new InvalidRequestException(msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
theResource.setId((IIdType)null);
|
||||
}
|
||||
|
|
|
@ -151,9 +151,8 @@ public abstract class BaseQueryParameter implements IParameter {
|
|||
|
||||
if (handlesMissing()) {
|
||||
return parse(theRequest.getServer().getFhirContext(), paramList);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return parse(theRequest.getServer().getFhirContext(), paramList);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue