commit
faececb246
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -148,10 +148,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);
|
||||
}
|
||||
|
@ -171,9 +171,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 {
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -305,25 +305,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;
|
||||
|
@ -1112,9 +1108,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;
|
||||
}
|
||||
|
||||
|
@ -790,7 +795,6 @@ class ParserState<T> {
|
|||
/**
|
||||
* Default implementation just handles undeclared extensions
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public void enteringNewElementExtension(StartElement theElement, String theUrlAttr, boolean theIsModifier) {
|
||||
if (myPreResourceState != null && getCurrentElement() instanceof ISupportsUndeclaredExtensions) {
|
||||
ExtensionDt newExtension = new ExtensionDt(theIsModifier);
|
||||
|
@ -1031,6 +1035,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 +1307,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 +2036,8 @@ class ParserState<T> {
|
|||
private PreResourceState getRootPreResourceState() {
|
||||
if (getPreResourceState() != null) {
|
||||
return getPreResourceState();
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2590,7 +2595,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) {
|
||||
|
|
|
@ -87,6 +87,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 +112,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 +135,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 +149,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 +190,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 +248,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 +264,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 +414,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
myLastRequest = theLastRequest;
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public void setLogRequestAndResponse(boolean theLogRequestAndResponse) {
|
||||
myLogRequestAndResponse = theLogRequestAndResponse;
|
||||
|
@ -423,6 +429,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 +576,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 +620,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 +1214,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);
|
||||
|
@ -1446,7 +1454,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 +1462,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 +1476,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOperationUntyped named(String theName) {
|
||||
|
@ -1591,10 +1597,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 +1640,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 +1779,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 +1854,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public IBase execute() {
|
||||
|
||||
|
@ -1906,8 +1911,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) {
|
||||
|
@ -1983,6 +1991,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public IQuery limitTo(int theLimitTo) {
|
||||
return count(theLimitTo);
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,32 +1,10 @@
|
|||
package ca.uhn.fhir.rest.method;
|
||||
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
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 +12,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
|
||||
|
|
|
@ -1,27 +1,5 @@
|
|||
package ca.uhn.fhir.rest.method;
|
||||
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
|
||||
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);
|
||||
|
|
|
@ -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))");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -281,11 +281,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();
|
||||
|
@ -341,7 +340,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");
|
||||
|
||||
|
@ -369,7 +368,6 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
}
|
||||
return new HttpGetClientInvocation(theContext, params, b.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static class ReturnType {
|
||||
private int myMax;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,55 +1,17 @@
|
|||
package ca.uhn.fhir.rest.method;
|
||||
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
|
||||
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);
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.primitive.DateDt;
|
||||
|
@ -43,7 +42,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
import ca.uhn.fhir.util.ValidateUtil;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DateParam extends BaseParamWithPrefix<DateParam> implements IQueryParameterType , IQueryParameterOr<DateParam> {
|
||||
public class DateParam extends BaseParamWithPrefix<DateParam> implements /*IQueryParameterType , */IQueryParameterOr<DateParam> {
|
||||
|
||||
private final DateTimeDt myValue = new DateTimeDt();
|
||||
|
||||
|
@ -220,9 +219,8 @@ public class DateParam extends BaseParamWithPrefix<DateParam> implements IQueryP
|
|||
public String getValueAsString() {
|
||||
if (myValue != null) {
|
||||
return myValue.getValueAsString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -345,6 +345,7 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
|||
public void setRangeFromDatesInclusive(String theLowerBound, String theUpperBound) {
|
||||
myLowerBound = theLowerBound != null ? new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, theLowerBound) : null;
|
||||
myUpperBound = theUpperBound != null ? new DateParam(ParamPrefixEnum.LESSTHAN_OR_EQUALS, theUpperBound) : null;
|
||||
//FIXME potential null access on theLowerBound
|
||||
if (isNotBlank(theLowerBound) && isNotBlank(theUpperBound) && theLowerBound.equals(theUpperBound)) {
|
||||
myLowerBound.setPrefix(ParamPrefixEnum.EQUAL);
|
||||
myUpperBound.setPrefix(ParamPrefixEnum.EQUAL);
|
||||
|
|
|
@ -38,6 +38,8 @@ import ca.uhn.fhir.util.CoverageIgnore;
|
|||
@CoverageIgnore
|
||||
public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype {
|
||||
|
||||
private static final long serialVersionUID = 993056016725918652L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -78,6 +80,7 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
|||
return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(mySystem, myVersion, myCode, myDisplay, myPrimary);
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
|
||||
return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, mySystem, myVersion, myCode, myDisplay, myPrimary);
|
||||
|
@ -90,6 +93,7 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
|||
* <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public UriDt getSystemElement() {
|
||||
if (mySystem == null) {
|
||||
mySystem = new UriDt();
|
||||
|
@ -116,6 +120,7 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
|||
* <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public InternalCodingDt setSystem(String theUri) {
|
||||
mySystem = new UriDt(theUri);
|
||||
return this;
|
||||
|
@ -169,6 +174,7 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
|||
* <b>Definition:</b> A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public CodeDt getCodeElement() {
|
||||
if (myCode == null) {
|
||||
myCode = new CodeDt();
|
||||
|
@ -195,6 +201,7 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
|||
* <b>Definition:</b> A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public InternalCodingDt setCode(String theCode) {
|
||||
myCode = new CodeDt(theCode);
|
||||
return this;
|
||||
|
@ -233,6 +240,7 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
|||
* <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public InternalCodingDt setDisplay(String theString) {
|
||||
myDisplay = new StringDt(theString);
|
||||
return this;
|
||||
|
@ -292,11 +300,13 @@ public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype
|
|||
return getDisplay();
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public Boolean getMissing() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Deprecated //override deprecated method
|
||||
@Override
|
||||
public IQueryParameterType setMissing(Boolean theMissing) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -147,9 +147,8 @@ public enum ParamPrefixEnum {
|
|||
public String getValueForContext(FhirContext theContext) {
|
||||
if (theContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
|
||||
return getDstu1Value();
|
||||
} else {
|
||||
return getValue();
|
||||
}
|
||||
return getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -139,9 +139,8 @@ public class ParameterUtil {
|
|||
public static String escapeWithDefault(Object theValue) {
|
||||
if (theValue == null) {
|
||||
return "";
|
||||
} else {
|
||||
return escape(theValue.toString());
|
||||
}
|
||||
return escape(theValue.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,11 +29,10 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.util.CoverageIgnore;
|
||||
|
||||
public class ReferenceParam extends BaseParam implements IQueryParameterType {
|
||||
public class ReferenceParam extends BaseParam /*implements IQueryParameterType*/ {
|
||||
|
||||
private String myChain;
|
||||
|
||||
|
@ -93,9 +92,8 @@ public class ReferenceParam extends BaseParam implements IQueryParameterType {
|
|||
String doGetValueAsQueryToken(FhirContext theContext) {
|
||||
if (isBlank(myId.getResourceType())) {
|
||||
return myId.getValue(); // e.g. urn:asdjd or 123 or cid:wieiuru or #1
|
||||
} else {
|
||||
return myId.getIdPart();
|
||||
}
|
||||
return myId.getIdPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -150,6 +150,7 @@ public class ResourceParameter implements IParameter {
|
|||
String ctValue = theRequest.getHeader(Constants.HEADER_CONTENT_TYPE);
|
||||
if (ctValue != null) {
|
||||
if (ctValue.startsWith("application/x-www-form-urlencoded")) {
|
||||
//FIXME potential null access theMethodBinding
|
||||
String msg = theRequest.getServer().getFhirContext().getLocalizer().getMessage(ResourceParameter.class, "invalidContentTypeInRequest", ctValue, theMethodBinding.getRestOperationType());
|
||||
throw new InvalidRequestException(msg);
|
||||
}
|
||||
|
@ -169,9 +170,8 @@ public class ResourceParameter implements IParameter {
|
|||
if (encoding == null) {
|
||||
String msg = ctx.getLocalizer().getMessage(ResourceParameter.class, "noContentTypeInRequest", restOperationType);
|
||||
throw new InvalidRequestException(msg);
|
||||
} else {
|
||||
requestReader = new InputStreamReader(new ByteArrayInputStream(theRequest.loadRequestContents()), charset);
|
||||
}
|
||||
requestReader = new InputStreamReader(new ByteArrayInputStream(theRequest.loadRequestContents()), charset);
|
||||
} else {
|
||||
String msg = ctx.getLocalizer().getMessage(ResourceParameter.class, "invalidContentTypeInRequest", ctValue, restOperationType);
|
||||
throw new InvalidRequestException(msg);
|
||||
|
|
|
@ -27,12 +27,11 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
|
||||
public class TokenParam extends BaseParam implements IQueryParameterType {
|
||||
public class TokenParam extends BaseParam /*implements IQueryParameterType*/ {
|
||||
|
||||
private TokenParamModifier myModifier;
|
||||
private String mySystem;
|
||||
|
@ -86,9 +85,8 @@ public class TokenParam extends BaseParam implements IQueryParameterType {
|
|||
String doGetQueryParameterQualifier() {
|
||||
if (getModifier() != null) {
|
||||
return getModifier().getValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,9 +96,8 @@ public class TokenParam extends BaseParam implements IQueryParameterType {
|
|||
String doGetValueAsQueryToken(FhirContext theContext) {
|
||||
if (getSystem() != null) {
|
||||
return ParameterUtil.escape(StringUtils.defaultString(getSystem())) + '|' + ParameterUtil.escape(getValue());
|
||||
} else {
|
||||
return ParameterUtil.escape(getValue());
|
||||
}
|
||||
return ParameterUtil.escape(getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
|
||||
public class TransactionParameter implements IParameter {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionParameter.class);
|
||||
// private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionParameter.class);
|
||||
private FhirContext myContext;
|
||||
private ParamStyle myParamStyle;
|
||||
private Class<? extends IBaseResource> myResourceBundleType;
|
||||
|
@ -112,6 +112,7 @@ public class TransactionParameter implements IParameter {
|
|||
case DSTU1_BUNDLE: {
|
||||
Bundle bundle;
|
||||
bundle = parser.parseBundle(reader);
|
||||
//FIXME resource leak
|
||||
return bundle;
|
||||
}
|
||||
case RESOURCE_LIST: {
|
||||
|
@ -122,12 +123,15 @@ public class TransactionParameter implements IParameter {
|
|||
resourceList.add(next.getResource());
|
||||
}
|
||||
}
|
||||
//FIXME resource leak
|
||||
return resourceList;
|
||||
}
|
||||
case RESOURCE_BUNDLE:
|
||||
//FIXME resource leak
|
||||
return parser.parseResource(myResourceBundleType, reader);
|
||||
}
|
||||
|
||||
//FIXME resource leak
|
||||
throw new IllegalStateException("Unknown type: " + myParamStyle); // should not happen
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
|
|
@ -55,9 +55,8 @@ public class ResourceBinding {
|
|||
if (rm.incomingServerRequestMatchesMethod(theRequest)) {
|
||||
ourLog.debug("Handler {} matches", rm);
|
||||
return rm;
|
||||
} else {
|
||||
ourLog.trace("Handler {} does not match", rm);
|
||||
}
|
||||
ourLog.trace("Handler {} does not match", rm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -266,9 +266,8 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
if (resourceMethod == null) {
|
||||
if (isBlank(requestPath)) {
|
||||
throw new InvalidRequestException(myFhirContext.getLocalizer().getMessage(RestfulServer.class, "rootRequest"));
|
||||
} else {
|
||||
throw new InvalidRequestException(myFhirContext.getLocalizer().getMessage(RestfulServer.class, "unknownMethod", requestType.name(), requestPath, requestDetails.getParameters().keySet()));
|
||||
}
|
||||
throw new InvalidRequestException(myFhirContext.getLocalizer().getMessage(RestfulServer.class, "unknownMethod", requestType.name(), requestPath, requestDetails.getParameters().keySet()));
|
||||
}
|
||||
return resourceMethod;
|
||||
}
|
||||
|
@ -324,10 +323,10 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
|
||||
if (!Modifier.isPublic(m.getModifiers())) {
|
||||
throw new ConfigurationException("Method '" + m.getName() + "' is not public, FHIR RESTful methods must be public");
|
||||
} else {
|
||||
}
|
||||
if (Modifier.isStatic(m.getModifiers())) {
|
||||
throw new ConfigurationException("Method '" + m.getName() + "' is static, FHIR RESTful methods must not be static");
|
||||
} else {
|
||||
}
|
||||
ourLog.debug("Scanning public method: {}#{}", theProvider.getClass(), m.getName());
|
||||
|
||||
String resourceName = foundMethodBinding.getResourceName();
|
||||
|
@ -361,8 +360,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
|
||||
resourceBinding.addMethod(foundMethodBinding);
|
||||
ourLog.debug(" * Method: {}#{} is a handler", theProvider.getClass(), m.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return count;
|
||||
|
@ -406,6 +404,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
@Override
|
||||
public FhirContext getFhirContext() {
|
||||
if (myFhirContext == null) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
myFhirContext = new FhirContext();
|
||||
}
|
||||
return myFhirContext;
|
||||
|
|
|
@ -425,9 +425,8 @@ public class RestfulServerUtils {
|
|||
}
|
||||
if (encoding == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new ResponseEncoding(theFhirContext, encoding, theContentType);
|
||||
}
|
||||
return new ResponseEncoding(theFhirContext, encoding, theContentType);
|
||||
}
|
||||
|
||||
public static IParser getNewParser(FhirContext theContext, RequestDetails theRequestDetails) {
|
||||
|
@ -577,6 +576,7 @@ public class RestfulServerUtils {
|
|||
} catch (Exception e) {
|
||||
// always send a response, even if the parsing went wrong
|
||||
}
|
||||
//FIXME resource leak
|
||||
return theRequestDetails.getResponse().sendWriterResponse(status, contentType, charset, writer);
|
||||
}
|
||||
|
||||
|
@ -700,7 +700,7 @@ public class RestfulServerUtils {
|
|||
IParser parser = getNewParser(theServer.getFhirContext(), theRequestDetails);
|
||||
parser.encodeResourceToWriter(theResource, writer);
|
||||
}
|
||||
|
||||
//FIXME resource leak
|
||||
return restUtil.sendWriterResponse(theStausCode, contentType, charset, writer);
|
||||
}
|
||||
|
||||
|
@ -780,9 +780,8 @@ public class RestfulServerUtils {
|
|||
public String getResourceContentType() {
|
||||
if (Boolean.TRUE.equals(isNonLegacy())) {
|
||||
return getEncoding().getResourceContentTypeNonLegacy();
|
||||
} else {
|
||||
return getEncoding().getResourceContentType();
|
||||
}
|
||||
return getEncoding().getResourceContentType();
|
||||
}
|
||||
|
||||
public Boolean isNonLegacy() {
|
||||
|
|
|
@ -3,7 +3,6 @@ package ca.uhn.fhir.rest.server.exceptions;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -318,9 +317,8 @@ public abstract class BaseServerResponseException extends RuntimeException {
|
|||
} catch (SecurityException e) {
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
} else {
|
||||
return new UnclassifiedServerFailureException(theStatusCode, theMessage);
|
||||
}
|
||||
return new UnclassifiedServerFailureException(theStatusCode, theMessage);
|
||||
}
|
||||
|
||||
static void registerExceptionType(int theStatusCode, Class<? extends BaseServerResponseException> theType) {
|
||||
|
|
|
@ -42,7 +42,6 @@ import ca.uhn.fhir.rest.annotation.Search;
|
|||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.IRestfulServerDefaults;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
|
|
|
@ -33,7 +33,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.text.StrLookup;
|
||||
|
@ -47,7 +46,6 @@ import ca.uhn.fhir.rest.server.EncodingEnum;
|
|||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.RestfulServerUtils;
|
||||
import ca.uhn.fhir.rest.server.RestfulServerUtils.ResponseEncoding;
|
||||
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
|
||||
|
@ -259,9 +257,8 @@ public class LoggingInterceptor extends InterceptorAdapter {
|
|||
default:
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
} else if ("id".equals(theKey)) {
|
||||
if (myRequestDetails.getId() != null) {
|
||||
return myRequestDetails.getId().getValue();
|
||||
|
@ -305,9 +302,8 @@ public class LoggingInterceptor extends InterceptorAdapter {
|
|||
ResponseEncoding encoding = RestfulServerUtils.determineResponseEncodingNoDefault(myRequestDetails, myRequestDetails.getServer().getDefaultResponseEncoding());
|
||||
if (encoding != null) {
|
||||
return encoding.getEncoding().name();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
} else if (theKey.equals("exceptionMessage")) {
|
||||
return myException != null ? myException.getMessage() : null;
|
||||
} else if (theKey.equals("requestUrl")) {
|
||||
|
|
|
@ -44,7 +44,6 @@ import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerOperationInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
|
||||
import ca.uhn.fhir.util.BundleUtil;
|
||||
import ca.uhn.fhir.util.CoverageIgnore;
|
||||
|
||||
/**
|
||||
|
@ -209,9 +208,8 @@ public class AuthorizationInterceptor extends InterceptorAdapter implements ISer
|
|||
if (decision.getDecidingRule() != null) {
|
||||
String ruleName = defaultString(decision.getDecidingRule().getName(), "(unnamed rule)");
|
||||
throw new ForbiddenOperationException("Access denied by rule: " + ruleName);
|
||||
} else {
|
||||
throw new ForbiddenOperationException("Access denied by default policy (no applicable rules)");
|
||||
}
|
||||
throw new ForbiddenOperationException("Access denied by default policy (no applicable rules)");
|
||||
}
|
||||
|
||||
private void handleUserOperation(RequestDetails theRequest, IBaseResource theResource, RestOperationTypeEnum operation) {
|
||||
|
@ -230,7 +228,7 @@ public class AuthorizationInterceptor extends InterceptorAdapter implements ISer
|
|||
inputResourceId = theProcessedRequest.getId();
|
||||
break;
|
||||
case OUT:
|
||||
inputResource = null;
|
||||
// inputResource = null;
|
||||
inputResourceId = theProcessedRequest.getId();
|
||||
break;
|
||||
case NONE:
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ca.uhn.fhir.rest.server.interceptor.auth;
|
||||
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ca.uhn.fhir.rest.server.interceptor.auth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
|
|
@ -41,7 +41,7 @@ import ca.uhn.fhir.util.BundleUtil;
|
|||
import ca.uhn.fhir.util.BundleUtil.BundleEntryParts;
|
||||
import ca.uhn.fhir.util.FhirTerser;
|
||||
|
||||
class RuleImplOp extends BaseRule implements IAuthRule {
|
||||
class RuleImplOp extends BaseRule /*implements IAuthRule*/ {
|
||||
|
||||
private AppliesTypeEnum myAppliesTo;
|
||||
private Set<?> myAppliesToTypes;
|
||||
|
@ -108,9 +108,8 @@ class RuleImplOp extends BaseRule implements IAuthRule {
|
|||
if (theOperation == RestOperationTypeEnum.DELETE) {
|
||||
if (theInputResource == null) {
|
||||
return newVerdict();
|
||||
} else {
|
||||
appliesToResource = theInputResource;
|
||||
}
|
||||
appliesToResource = theInputResource;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -123,7 +122,7 @@ class RuleImplOp extends BaseRule implements IAuthRule {
|
|||
if (theInputResource != null && requestAppliesToTransaction(ctx, myOp, theInputResource)) {
|
||||
if (getMode() == PolicyEnum.DENY) {
|
||||
return new Verdict(PolicyEnum.DENY, this);
|
||||
} else {
|
||||
}
|
||||
List<BundleEntryParts> inputResources = BundleUtil.toListOfEntries(ctx, (IBaseBundle) theInputResource);
|
||||
Verdict verdict = null;
|
||||
for (BundleEntryParts nextPart : inputResources) {
|
||||
|
@ -161,7 +160,6 @@ class RuleImplOp extends BaseRule implements IAuthRule {
|
|||
}
|
||||
}
|
||||
return verdict;
|
||||
}
|
||||
} else if (theOutputResource != null) {
|
||||
List<BundleEntryParts> inputResources = BundleUtil.toListOfEntries(ctx, (IBaseBundle) theInputResource);
|
||||
Verdict verdict = null;
|
||||
|
@ -189,9 +187,8 @@ class RuleImplOp extends BaseRule implements IAuthRule {
|
|||
case METADATA:
|
||||
if (theOperation == RestOperationTypeEnum.METADATA) {
|
||||
return newVerdict();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
// Should not happen
|
||||
throw new IllegalStateException("Unable to apply security to event of type " + theOperation);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue