More cleanup of legacy code

This commit is contained in:
James 2017-07-30 07:11:45 -04:00
parent ebd3eeb5ee
commit 9ae7295705
18 changed files with 37 additions and 615 deletions

View File

@ -1,30 +1,7 @@
package ca.uhn.fhir.rest.client.api; package ca.uhn.fhir.rest.client.api;
/*
* #%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.util.List;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.UriDt; import ca.uhn.fhir.model.primitive.UriDt;
import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.MethodOutcome;
@ -45,11 +22,7 @@ public interface IGenericClient extends IRestfulClient {
* Fluent method for the "delete" operation, which performs a logical delete on a server resource * Fluent method for the "delete" operation, which performs a logical delete on a server resource
*/ */
IDelete delete(); IDelete delete();
/** /**
* Retrieves the server's conformance statement * Retrieves the server's conformance statement
*/ */
@ -75,24 +48,6 @@ public interface IGenericClient extends IRestfulClient {
*/ */
IGetPage loadPage(); IGetPage loadPage();
// /**
// * Implementation of the "instance read" method. This method will only ever do a "read" for the latest version of a
// * given resource instance, even if the ID passed in contains a version. If you wish to request a specific version
// * of a resource (the "vread" operation), use {@link #vread(Class, IdDt)} instead.
// * <p>
// * Note that if an absolute resource ID is passed in (i.e. a URL containing a protocol and host as well as the
// * resource type and ID) the server base for the client will be ignored, and the URL passed in will be queried.
// * </p>
// *
// * @param theType
// * The type of resource to load
// * @param theId
// * The ID to load, including the resource ID and the resource version ID. Valid values include
// * "Patient/123/_history/222", or "http://example.com/fhir/Patient/123/_history/222"
// * @return The resource
// */
// <T extends IBaseResource> T read(Class<T> theType, IdDt theId);
/** /**
* Fluent method for the "meta" operations, which can be used to get, add and remove tags and other * Fluent method for the "meta" operations, which can be used to get, add and remove tags and other
* Meta elements from a resource or across the server. * Meta elements from a resource or across the server.
@ -119,7 +74,10 @@ public interface IGenericClient extends IRestfulClient {
* @param theId * @param theId
* The ID to load * The ID to load
* @return The resource * @return The resource
*
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
*/ */
@Deprecated
<T extends IBaseResource> T read(Class<T> theType, String theId); <T extends IBaseResource> T read(Class<T> theType, String theId);
/** /**
@ -130,7 +88,9 @@ public interface IGenericClient extends IRestfulClient {
* @param theUrl * @param theUrl
* The absolute URL, e.g. "http://example.com/fhir/Patient/123" * The absolute URL, e.g. "http://example.com/fhir/Patient/123"
* @return The returned resource from the server * @return The returned resource from the server
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
*/ */
@Deprecated
<T extends IBaseResource> T read(Class<T> theType, UriDt theUrl); <T extends IBaseResource> T read(Class<T> theType, UriDt theUrl);
/** /**
@ -139,7 +99,9 @@ public interface IGenericClient extends IRestfulClient {
* @param theUrl * @param theUrl
* The absolute URL, e.g. "http://example.com/fhir/Patient/123" * The absolute URL, e.g. "http://example.com/fhir/Patient/123"
* @return The returned resource from the server * @return The returned resource from the server
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
*/ */
@Deprecated
IBaseResource read(UriDt theUrl); IBaseResource read(UriDt theUrl);
/** /**
@ -179,17 +141,6 @@ public interface IGenericClient extends IRestfulClient {
*/ */
ITransaction transaction(); ITransaction transaction();
/**
* Implementation of the "transaction" method.
*
* @param theResources
* The resources to create/update in a single transaction
* @return A list of resource stubs (<b>these will not be fully populated</b>) containing IDs and other {@link IResource#getResourceMetadata() metadata}
* @deprecated Use {@link #transaction()}
*
*/
@Deprecated
List<IBaseResource> transaction(List<IBaseResource> theResources);
/** /**
* Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)} * Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)}
@ -210,7 +161,9 @@ public interface IGenericClient extends IRestfulClient {
* @param theResource * @param theResource
* The new resource body * The new resource body
* @return An outcome containing the results and possibly the new version ID * @return An outcome containing the results and possibly the new version ID
* @deprecated Use {@link #update() update() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
*/ */
@Deprecated
MethodOutcome update(IdDt theId, IBaseResource theResource); MethodOutcome update(IdDt theId, IBaseResource theResource);
/** /**
@ -221,7 +174,9 @@ public interface IGenericClient extends IRestfulClient {
* @param theResource * @param theResource
* The new resource body * The new resource body
* @return An outcome containing the results and possibly the new version ID * @return An outcome containing the results and possibly the new version ID
* @deprecated Use {@link #update() update() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
*/ */
@Deprecated
MethodOutcome update(String theId, IBaseResource theResource); MethodOutcome update(String theId, IBaseResource theResource);
/** /**
@ -235,7 +190,9 @@ public interface IGenericClient extends IRestfulClient {
* @param theResource * @param theResource
* The resource to validate * The resource to validate
* @return An outcome containing any validation issues * @return An outcome containing any validation issues
* @deprecated Use {@link #validate() validate() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
*/ */
@Deprecated
MethodOutcome validate(IBaseResource theResource); MethodOutcome validate(IBaseResource theResource);
/** /**
@ -250,7 +207,9 @@ public interface IGenericClient extends IRestfulClient {
* @param theId * @param theId
* The ID to load, including the resource ID and the resource version ID. Valid values include "Patient/123/_history/222", or "http://example.com/fhir/Patient/123/_history/222" * The ID to load, including the resource ID and the resource version ID. Valid values include "Patient/123/_history/222", or "http://example.com/fhir/Patient/123/_history/222"
* @return The resource * @return The resource
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
*/ */
@Deprecated
<T extends IBaseResource> T vread(Class<T> theType, IdDt theId); <T extends IBaseResource> T vread(Class<T> theType, IdDt theId);
/** /**
@ -263,22 +222,9 @@ public interface IGenericClient extends IRestfulClient {
* @param theVersionId * @param theVersionId
* The version ID * The version ID
* @return The resource * @return The resource
* @deprecated Deprecated in 0.7 - IdDt can contain an ID and a version, so this class doesn't make a lot of sense * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
*/ */
@Deprecated @Deprecated
<T extends IBaseResource> T vread(Class<T> theType, IdDt theId, IdDt theVersionId);
/**
* Implementation of the "instance vread" method.
*
* @param theType
* The type of resource to load
* @param theId
* The ID to load
* @param theVersionId
* The version ID
* @return The resource
*/
<T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId); <T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId);
} }

View File

@ -34,7 +34,6 @@ import org.hl7.fhir.instance.model.api.*;
import ca.uhn.fhir.context.*; import ca.uhn.fhir.context.*;
import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.base.resource.BaseConformance;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome; import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.model.primitive.*; import ca.uhn.fhir.model.primitive.*;
import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.DataFormatException;
@ -71,68 +70,17 @@ public class GenericClient extends BaseClient implements IGenericClient {
myContext = theContext; myContext = theContext;
} }
@Deprecated // override deprecated method
@Override
public IBaseConformance conformance() {
if (myContext.getVersion().getVersion().isRi()) {
throw new IllegalArgumentException("Must call fetchConformance() instead of conformance() for RI/STU3+ structures");
}
HttpGetClientInvocation invocation = MethodUtil.createConformanceInvocation(getFhirContext());
if (isKeepResponses()) {
myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding(), isPrettyPrint());
}
@SuppressWarnings("unchecked")
Class<BaseConformance> conformance = (Class<BaseConformance>) myContext.getResourceDefinition("Conformance").getImplementingClass();
ResourceResponseHandler<? extends BaseConformance> binding = new ResourceResponseHandler<BaseConformance>(conformance);
IBaseConformance resp = invokeClient(myContext, binding, invocation, myLogRequestAndResponse);
return resp;
}
@Override @Override
public ICreate create() { public ICreate create() {
return new CreateInternal(); return new CreateInternal();
} }
@Deprecated // overide deprecated method
@Override
public MethodOutcome create(IBaseResource theResource) {
BaseHttpClientInvocation invocation = MethodUtil.createCreateInvocation(theResource, myContext);
if (isKeepResponses()) {
myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding(), isPrettyPrint());
}
OutcomeResponseHandler binding = new OutcomeResponseHandler();
MethodOutcome resp = invokeClient(myContext, binding, invocation, myLogRequestAndResponse);
return resp;
}
@Override @Override
public IDelete delete() { public IDelete delete() {
return new DeleteInternal(); 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)));
if (isKeepResponses()) {
myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding(), isPrettyPrint());
}
OutcomeResponseHandler binding = new OutcomeResponseHandler();
MethodOutcome resp = invokeClient(myContext, binding, invocation, myLogRequestAndResponse);
return resp;
}
@Deprecated // override deprecated method
@Override
public MethodOutcome delete(Class<? extends IBaseResource> theType, String theId) {
return delete(theType, new IdDt(theId));
}
private <T extends IBaseResource> T doReadOrVRead(final Class<T> theType, IIdType theId, boolean theVRead, ICallable<T> theNotModifiedHandler, String theIfVersionMatches, Boolean thePrettyPrint, private <T extends IBaseResource> T doReadOrVRead(final Class<T> theType, IIdType theId, boolean theVRead, ICallable<T> theNotModifiedHandler, String theIfVersionMatches, Boolean thePrettyPrint,
SummaryEnum theSummary, EncodingEnum theEncoding, Set<String> theSubsetElements) { SummaryEnum theSummary, EncodingEnum theEncoding, Set<String> theSubsetElements) {
@ -369,13 +317,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
return doReadOrVRead(theType, theId, true, null, null, false, null, null, null); return doReadOrVRead(theType, theId, true, null, null, false, null, null, null);
} }
/* also deprecated in interface */
@Deprecated
@Override
public <T extends IBaseResource> T vread(final Class<T> theType, IdDt theId, IdDt theVersionId) {
return vread(theType, theId.withVersion(theVersionId.getIdPart()));
}
@Override @Override
public <T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId) { public <T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId) {
IdDt resId = new IdDt(toResourceName(theType), theId, theVersionId); IdDt resId = new IdDt(toResourceName(theType), theId, theVersionId);
@ -1881,7 +1822,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
} }
@SuppressWarnings("rawtypes")
private static class SortInternal implements ISort { private static class SortInternal implements ISort {
private SearchInternal myFor; private SearchInternal myFor;

View File

@ -1,45 +0,0 @@
package ca.uhn.fhir.rest.client.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 ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.annotation.AddTags;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
class AddTagsMethodBinding extends BaseAddOrDeleteTagsMethodBinding {
public AddTagsMethodBinding(Method theMethod, FhirContext theContext, Object theProvider, AddTags theAnnotation) {
super(theMethod, theContext, theProvider, theAnnotation.type());
}
@Override
protected boolean isDelete() {
return false;
}
@Override
public RestOperationTypeEnum getRestOperationType() {
return RestOperationTypeEnum.ADD_TAGS;
}
}

View File

@ -1,123 +0,0 @@
package ca.uhn.fhir.rest.client.method;
import java.io.Reader;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Map;
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.api.TagList;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.TagListParam;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.param.ParameterUtil;
import ca.uhn.fhir.rest.server.exceptions.*;
abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void> {
private Class<? extends IBaseResource> myType;
private Integer myIdParamIndex;
private Integer myVersionIdParamIndex;
private String myResourceName;
private Integer myTagListParamIndex;
public BaseAddOrDeleteTagsMethodBinding(Method theMethod, FhirContext theContext, Object theProvider, Class<? extends IBaseResource> theTypeFromMethodAnnotation) {
super(theMethod, theContext, theProvider);
myType = theTypeFromMethodAnnotation;
if (Modifier.isInterface(myType.getModifiers())) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' does not specify a resource type, but has an @" + IdParam.class.getSimpleName() + " parameter. Please specity a resource type in the method annotation on this method");
}
myResourceName = theContext.getResourceDefinition(myType).getName();
myIdParamIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext());
myVersionIdParamIndex = ParameterUtil.findVersionIdParameterIndex(theMethod);
myTagListParamIndex = ParameterUtil.findTagListParameterIndex(theMethod);
if (myIdParamIndex == null) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' does not have an @" + IdParam.class.getSimpleName() + " parameter.");
}
if (myTagListParamIndex == null) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' does not have a parameter of type " + TagList.class.getSimpleName() + ", or paramater is not annotated with the @" + TagListParam.class.getSimpleName() + " annotation");
}
}
@Override
public Void invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws BaseServerResponseException {
switch (theResponseStatusCode) {
case Constants.STATUS_HTTP_200_OK:
case Constants.STATUS_HTTP_201_CREATED:
case Constants.STATUS_HTTP_204_NO_CONTENT:
return null;
default:
throw processNon2xxResponseAndReturnExceptionToThrow(theResponseStatusCode, theResponseMimeType, theResponseReader);
}
}
@Override
public String getResourceName() {
return myResourceName;
}
@Override
public RestOperationTypeEnum getRestOperationType() {
return null;
}
protected abstract boolean isDelete();
@Override
public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
HttpPostClientInvocation retVal;
IdDt id = (IdDt) theArgs[myIdParamIndex];
if (id == null || id.isEmpty()) {
throw new InvalidRequestException("ID must not be null or empty for this operation");
}
IdDt versionId = null;
if (myVersionIdParamIndex != null) {
versionId = (IdDt) theArgs[myVersionIdParamIndex];
}
TagList tagList = (TagList) theArgs[myTagListParamIndex];
Class<? extends IBaseResource> type = myType;
assert type != null;
if (isDelete()) {
if (versionId != null) {
retVal = new HttpPostClientInvocation(getContext(), tagList, getResourceName(), id.getValue(), Constants.PARAM_HISTORY, versionId.getValue(), Constants.PARAM_TAGS, Constants.PARAM_DELETE);
} else {
retVal = new HttpPostClientInvocation(getContext(), tagList, getResourceName(), id.getValue(), Constants.PARAM_TAGS, Constants.PARAM_DELETE);
}
} else {
if (versionId != null) {
retVal = new HttpPostClientInvocation(getContext(), tagList, getResourceName(), id.getValue(), Constants.PARAM_HISTORY, versionId.getValue(), Constants.PARAM_TAGS);
} else {
retVal = new HttpPostClientInvocation(getContext(), tagList, getResourceName(), id.getValue(), Constants.PARAM_TAGS);
}
}
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, null);
}
return retVal;
}
}

View File

@ -27,20 +27,14 @@ import java.util.Map;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBaseBinary; import org.hl7.fhir.instance.model.api.*;
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.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.*;
import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.client.api.IHttpClient; import ca.uhn.fhir.rest.client.api.IHttpClient;
import ca.uhn.fhir.rest.client.api.IHttpRequest; import ca.uhn.fhir.rest.client.api.IHttpRequest;
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation; import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
@ -53,14 +47,12 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
private final BundleTypeEnum myBundleType; private final BundleTypeEnum myBundleType;
private final String myContents; private final String myContents;
private boolean myContentsIsBundle;
private Map<String, List<String>> myIfNoneExistParams; private Map<String, List<String>> myIfNoneExistParams;
private String myIfNoneExistString; private String myIfNoneExistString;
private boolean myOmitResourceId = false; private boolean myOmitResourceId = false;
private Map<String, List<String>> myParams; private Map<String, List<String>> myParams;
private final IBaseResource myResource; private final IBaseResource myResource;
private final List<? extends IBaseResource> myResources; private final List<? extends IBaseResource> myResources;
private final TagList myTagList;
private final String myUrlPath; private final String myUrlPath;
private IIdType myForceResourceId; private IIdType myForceResourceId;
@ -69,11 +61,9 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
public BaseHttpClientInvocationWithContents(FhirContext theContext, IBaseResource theResource, Map<String, List<String>> theParams, String... theUrlPath) { public BaseHttpClientInvocationWithContents(FhirContext theContext, IBaseResource theResource, Map<String, List<String>> theParams, String... theUrlPath) {
super(theContext); super(theContext);
myResource = theResource; myResource = theResource;
myTagList = null;
myUrlPath = StringUtils.join(theUrlPath, '/'); myUrlPath = StringUtils.join(theUrlPath, '/');
myResources = null; myResources = null;
myContents = null; myContents = null;
myContentsIsBundle = false;
myParams = theParams; myParams = theParams;
myBundleType = null; myBundleType = null;
} }
@ -82,7 +72,6 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
super(theContext); super(theContext);
myResource = theResource; myResource = theResource;
myUrlPath = theUrlPath; myUrlPath = theUrlPath;
myTagList = null;
myResources = null; myResources = null;
myContents = null; myContents = null;
myBundleType = null; myBundleType = null;
@ -91,7 +80,6 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
public BaseHttpClientInvocationWithContents(FhirContext theContext, List<? extends IBaseResource> theResources, BundleTypeEnum theBundleType) { public BaseHttpClientInvocationWithContents(FhirContext theContext, List<? extends IBaseResource> theResources, BundleTypeEnum theBundleType) {
super(theContext); super(theContext);
myResource = null; myResource = null;
myTagList = null;
myUrlPath = null; myUrlPath = null;
myResources = theResources; myResources = theResources;
myContents = null; myContents = null;
@ -101,11 +89,9 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
public BaseHttpClientInvocationWithContents(FhirContext theContext, Map<String, List<String>> theParams, String... theUrlPath) { public BaseHttpClientInvocationWithContents(FhirContext theContext, Map<String, List<String>> theParams, String... theUrlPath) {
super(theContext); super(theContext);
myResource = null; myResource = null;
myTagList = null;
myUrlPath = StringUtils.join(theUrlPath, '/'); myUrlPath = StringUtils.join(theUrlPath, '/');
myResources = null; myResources = null;
myContents = null; myContents = null;
myContentsIsBundle = false;
myParams = theParams; myParams = theParams;
myBundleType = null; myBundleType = null;
} }
@ -113,41 +99,22 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca
public BaseHttpClientInvocationWithContents(FhirContext theContext, String theContents, boolean theIsBundle, String theUrlPath) { public BaseHttpClientInvocationWithContents(FhirContext theContext, String theContents, boolean theIsBundle, String theUrlPath) {
super(theContext); super(theContext);
myResource = null; myResource = null;
myTagList = null;
myUrlPath = theUrlPath; myUrlPath = theUrlPath;
myResources = null; myResources = null;
myContents = theContents; myContents = theContents;
myContentsIsBundle = theIsBundle;
myBundleType = null; myBundleType = null;
} }
public BaseHttpClientInvocationWithContents(FhirContext theContext, String theContents, Map<String, List<String>> theParams, String... theUrlPath) { public BaseHttpClientInvocationWithContents(FhirContext theContext, String theContents, Map<String, List<String>> theParams, String... theUrlPath) {
super(theContext); super(theContext);
myResource = null; myResource = null;
myTagList = null;
myUrlPath = StringUtils.join(theUrlPath, '/'); myUrlPath = StringUtils.join(theUrlPath, '/');
myResources = null; myResources = null;
myContents = theContents; myContents = theContents;
myContentsIsBundle = false;
myParams = theParams; myParams = theParams;
myBundleType = null; myBundleType = null;
} }
public BaseHttpClientInvocationWithContents(FhirContext theContext, TagList theTagList, String... theUrlPath) {
super(theContext);
if (theTagList == null) {
throw new NullPointerException("Tag list must not be null");
}
myResource = null;
myTagList = theTagList;
myResources = null;
myBundle = null;
myContents = null;
myBundleType = null;
myUrlPath = StringUtils.join(theUrlPath, '/');
}
@Override @Override
public IHttpRequest asHttpRequest(String theUrlBase, Map<String, List<String>> theExtraParams, EncodingEnum theEncoding, Boolean thePrettyPrint) throws DataFormatException { public IHttpRequest asHttpRequest(String theUrlBase, Map<String, List<String>> theExtraParams, EncodingEnum theEncoding, Boolean thePrettyPrint) throws DataFormatException {

View File

@ -167,7 +167,6 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
Delete delete = theMethod.getAnnotation(Delete.class); Delete delete = theMethod.getAnnotation(Delete.class);
History history = theMethod.getAnnotation(History.class); History history = theMethod.getAnnotation(History.class);
Validate validate = theMethod.getAnnotation(Validate.class); Validate validate = theMethod.getAnnotation(Validate.class);
GetTags getTags = theMethod.getAnnotation(GetTags.class);
AddTags addTags = theMethod.getAnnotation(AddTags.class); AddTags addTags = theMethod.getAnnotation(AddTags.class);
DeleteTags deleteTags = theMethod.getAnnotation(DeleteTags.class); DeleteTags deleteTags = theMethod.getAnnotation(DeleteTags.class);
Transaction transaction = theMethod.getAnnotation(Transaction.class); Transaction transaction = theMethod.getAnnotation(Transaction.class);
@ -176,7 +175,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
Patch patch = theMethod.getAnnotation(Patch.class); Patch patch = theMethod.getAnnotation(Patch.class);
// ** if you add another annotation above, also add it to the next line: // ** if you add another annotation above, also add it to the next line:
if (!verifyMethodHasZeroOrOneOperationAnnotation(theMethod, read, search, conformance, create, update, delete, history, validate, getTags, addTags, deleteTags, transaction, operation, getPage, if (!verifyMethodHasZeroOrOneOperationAnnotation(theMethod, read, search, conformance, create, update, delete, history, validate, addTags, deleteTags, transaction, operation, getPage,
patch)) { patch)) {
return null; return null;
} }
@ -190,12 +189,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
Class<? extends IBaseResource> returnTypeFromRp = null; Class<? extends IBaseResource> returnTypeFromRp = null;
Class<?> returnTypeFromMethod = theMethod.getReturnType(); Class<?> returnTypeFromMethod = theMethod.getReturnType();
if (getTags != null) { if (MethodOutcome.class.isAssignableFrom(returnTypeFromMethod)) {
if (!TagList.class.equals(returnTypeFromMethod)) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' from type " + theMethod.getDeclaringClass().getCanonicalName() + " is annotated with @"
+ GetTags.class.getSimpleName() + " but does not return type " + TagList.class.getName());
}
} else if (MethodOutcome.class.isAssignableFrom(returnTypeFromMethod)) {
// returns a method outcome // returns a method outcome
} else if (void.class.equals(returnTypeFromMethod)) { } else if (void.class.equals(returnTypeFromMethod)) {
// returns a bundle // returns a bundle
@ -233,8 +227,6 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
returnTypeFromAnnotation = update.type(); returnTypeFromAnnotation = update.type();
} else if (validate != null) { } else if (validate != null) {
returnTypeFromAnnotation = validate.type(); returnTypeFromAnnotation = validate.type();
} else if (getTags != null) {
returnTypeFromAnnotation = getTags.type();
} else if (addTags != null) { } else if (addTags != null) {
returnTypeFromAnnotation = addTags.type(); returnTypeFromAnnotation = addTags.type();
} else if (deleteTags != null) { } else if (deleteTags != null) {
@ -276,12 +268,6 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
return new HistoryMethodBinding(theMethod, theContext, theProvider); return new HistoryMethodBinding(theMethod, theContext, theProvider);
} else if (validate != null) { } else if (validate != null) {
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) {
return new AddTagsMethodBinding(theMethod, theContext, theProvider, addTags);
} else if (deleteTags != null) {
return new DeleteTagsMethodBinding(theMethod, theContext, theProvider, deleteTags);
} else if (transaction != null) { } else if (transaction != null) {
return new TransactionMethodBinding(theMethod, theContext, theProvider); return new TransactionMethodBinding(theMethod, theContext, theProvider);
} else if (operation != null) { } else if (operation != null) {

View File

@ -3,23 +3,12 @@ package ca.uhn.fhir.rest.client.method;
import java.io.Reader; import java.io.Reader;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.instance.model.api.*;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.parser.IParser;
@ -120,15 +109,15 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
switch (getReturnType()) { switch (getReturnType()) {
case BUNDLE: { case BUNDLE: {
IBaseBundle dstu2bundle = null; IBaseBundle bundle = null;
List<? extends IBaseResource> listOfResources = null; List<? extends IBaseResource> listOfResources = null;
Class<? extends IBaseResource> type = getContext().getResourceDefinition("Bundle").getImplementingClass(); Class<? extends IBaseResource> type = getContext().getResourceDefinition("Bundle").getImplementingClass();
dstu2bundle = (IBaseBundle) parser.parseResource(type, theResponseReader); bundle = (IBaseBundle) parser.parseResource(type, theResponseReader);
listOfResources = BundleUtil.toListOfResources(getContext(), dstu2bundle); listOfResources = BundleUtil.toListOfResources(getContext(), bundle);
switch (getMethodReturnType()) { switch (getMethodReturnType()) {
case BUNDLE_RESOURCE: case BUNDLE_RESOURCE:
return dstu2bundle; return bundle;
case LIST_OF_RESOURCES: case LIST_OF_RESOURCES:
if (myResourceListCollectionType != null) { if (myResourceListCollectionType != null) {
for (Iterator<? extends IBaseResource> iter = listOfResources.iterator(); iter.hasNext();) { for (Iterator<? extends IBaseResource> iter = listOfResources.iterator(); iter.hasNext();) {
@ -141,8 +130,7 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
} }
return listOfResources; return listOfResources;
case RESOURCE: case RESOURCE:
// FIXME null access on dstu1bundle List<IBaseResource> list = BundleUtil.toListOfResources(getContext(), bundle);
List<IResource> list = dstu1bundle.toListOfResources();
if (list.size() == 0) { if (list.size() == 0) {
return null; return null;
} else if (list.size() == 1) { } else if (list.size() == 1) {

View File

@ -1,45 +0,0 @@
package ca.uhn.fhir.rest.client.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 ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.annotation.DeleteTags;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
public class DeleteTagsMethodBinding extends BaseAddOrDeleteTagsMethodBinding {
public DeleteTagsMethodBinding(Method theMethod, FhirContext theContext, Object theProvider, DeleteTags theDeleteTags) {
super(theMethod, theContext, theProvider, theDeleteTags.type());
}
@Override
protected boolean isDelete() {
return true;
}
@Override
public RestOperationTypeEnum getRestOperationType() {
return RestOperationTypeEnum.DELETE_TAGS;
}
}

View File

@ -1,111 +0,0 @@
package ca.uhn.fhir.rest.client.method;
import java.io.Reader;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Map;
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.api.IResource;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.annotation.GetTags;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.param.ParameterUtil;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
private Integer myIdParamIndex;
private String myResourceName;
private Class<? extends IBaseResource> myType;
private Integer myVersionIdParamIndex;
public GetTagsMethodBinding(Method theMethod, FhirContext theContext, Object theProvider, GetTags theAnnotation) {
super(theMethod, theContext, theProvider);
myType = theAnnotation.type();
if (!Modifier.isInterface(myType.getModifiers())) {
myResourceName = theContext.getResourceDefinition(myType).getName();
}
myIdParamIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext());
myVersionIdParamIndex = ParameterUtil.findVersionIdParameterIndex(theMethod);
if (myIdParamIndex != null && myType.equals(IResource.class)) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' does not specify a resource type, but has an @" + IdParam.class.getSimpleName()
+ " parameter. Please specity a resource type in the @" + GetTags.class.getSimpleName() + " annotation");
}
}
@Override
public String getResourceName() {
return myResourceName;
}
@Override
public RestOperationTypeEnum getRestOperationType() {
return RestOperationTypeEnum.GET_TAGS;
}
@Override
public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
HttpGetClientInvocation retVal;
IdDt id = null;
IdDt versionId = null;
if (myIdParamIndex != null) {
id = (IdDt) theArgs[myIdParamIndex];
if (myVersionIdParamIndex != null) {
versionId = (IdDt) theArgs[myVersionIdParamIndex];
}
}
if (myType != IResource.class) {
if (id != null) {
if (versionId != null) {
retVal = new HttpGetClientInvocation(getContext(), getResourceName(), id.getIdPart(), Constants.PARAM_HISTORY, versionId.getValue(), Constants.PARAM_TAGS);
} else if (id.hasVersionIdPart()) {
retVal = new HttpGetClientInvocation(getContext(), getResourceName(), id.getIdPart(), Constants.PARAM_HISTORY, id.getVersionIdPart(), Constants.PARAM_TAGS);
} else {
retVal = new HttpGetClientInvocation(getContext(), getResourceName(), id.getIdPart(), Constants.PARAM_TAGS);
}
} else {
retVal = new HttpGetClientInvocation(getContext(), getResourceName(), Constants.PARAM_TAGS);
}
} else {
retVal = new HttpGetClientInvocation(getContext(), Constants.PARAM_TAGS);
}
if (theArgs != null) {
for (int idx = 0; idx < theArgs.length; idx++) {
IParameter nextParam = getParameters().get(idx);
nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, null);
}
}
return retVal;
}
@Override
public TagList invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws BaseServerResponseException {
if (theResponseStatusCode == Constants.STATUS_HTTP_200_OK) {
IParser parser = createAppropriateParserForParsingResponse(theResponseMimeType, theResponseReader, theResponseStatusCode, null);
TagList retVal = parser.parseTagList(theResponseReader);
return retVal;
}
throw processNon2xxResponseAndReturnExceptionToThrow(theResponseStatusCode, theResponseMimeType, theResponseReader);
}
}

View File

@ -26,8 +26,6 @@ import java.util.Map;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.api.RequestTypeEnum; import ca.uhn.fhir.rest.api.RequestTypeEnum;
@ -42,18 +40,10 @@ public class HttpPostClientInvocation extends BaseHttpClientInvocationWithConten
super(theContext, theResource, null); super(theContext, theResource, null);
} }
public HttpPostClientInvocation(FhirContext theContext, TagList theTagList, String... theUrlExtension) {
super(theContext, theTagList, theUrlExtension);
}
public HttpPostClientInvocation(FhirContext theContext, List<? extends IBaseResource> theResources, BundleTypeEnum theBundleType) { public HttpPostClientInvocation(FhirContext theContext, List<? extends IBaseResource> theResources, BundleTypeEnum theBundleType) {
super(theContext, theResources, theBundleType); super(theContext, theResources, theBundleType);
} }
public HttpPostClientInvocation(FhirContext theContext, Bundle theBundle) {
super(theContext, theBundle);
}
public HttpPostClientInvocation(FhirContext theContext, String theContents, boolean theIsBundle, String theUrlExtension) { public HttpPostClientInvocation(FhirContext theContext, String theContents, boolean theIsBundle, String theUrlExtension) {
super(theContext, theContents, theIsBundle, theUrlExtension); super(theContext, theContents, theIsBundle, theUrlExtension);
} }

View File

@ -29,8 +29,8 @@ import java.util.*;
import org.hl7.fhir.instance.model.api.*; import org.hl7.fhir.instance.model.api.*;
import ca.uhn.fhir.context.*; import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.*; import ca.uhn.fhir.rest.annotation.*;
@ -103,11 +103,6 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
} }
} }
if (theMethod.getReturnType().isAssignableFrom(Bundle.class)) {
throw new ConfigurationException("Can not return a DSTU1 bundle from an @" + Operation.class.getSimpleName() + " method. Found in method " + theMethod.getName() + " defined in type "
+ theMethod.getDeclaringClass().getName());
}
myReturnType = ReturnTypeEnum.RESOURCE; myReturnType = ReturnTypeEnum.RESOURCE;
if (getResourceName() == null) { if (getResourceName() == null) {

View File

@ -23,26 +23,17 @@ package ca.uhn.fhir.rest.client.method;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBaseBinary; import org.hl7.fhir.instance.model.api.*;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.Elements; import ca.uhn.fhir.rest.annotation.*;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum; import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.param.ParameterUtil; import ca.uhn.fhir.rest.param.ParameterUtil;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;

View File

@ -8,7 +8,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.Transaction; import ca.uhn.fhir.rest.annotation.Transaction;
import ca.uhn.fhir.rest.annotation.TransactionParam; import ca.uhn.fhir.rest.annotation.TransactionParam;
@ -60,20 +59,12 @@ public class TransactionMethodBinding extends BaseResourceReturningMethodBinding
@Override @Override
public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException { public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
FhirContext context = getContext(); FhirContext context = getContext();
if (theArgs[myTransactionParamIndex] instanceof Bundle) {
Bundle bundle = (Bundle) theArgs[myTransactionParamIndex];
return createTransactionInvocation(bundle, context);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<IBaseResource> resources = (List<IBaseResource>) theArgs[myTransactionParamIndex]; List<IBaseResource> resources = (List<IBaseResource>) theArgs[myTransactionParamIndex];
return createTransactionInvocation(resources, context); return createTransactionInvocation(resources, context);
} }
public static BaseHttpClientInvocation createTransactionInvocation(Bundle theBundle, FhirContext theContext) {
return new HttpPostClientInvocation(theContext, theBundle);
}
public static BaseHttpClientInvocation createTransactionInvocation(IBaseBundle theBundle, FhirContext theContext) { public static BaseHttpClientInvocation createTransactionInvocation(IBaseBundle theBundle, FhirContext theContext) {
return new HttpPostClientInvocation(theContext, theBundle); return new HttpPostClientInvocation(theContext, theBundle);
} }

View File

@ -2,16 +2,11 @@ package ca.uhn.fhir.rest.client.method;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Collection; import java.util.*;
import java.util.List;
import java.util.Map;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.*;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.rest.annotation.TransactionParam; import ca.uhn.fhir.rest.annotation.TransactionParam;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -37,12 +32,7 @@ public class TransactionParameter implements IParameter {
throw new ConfigurationException("Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is annotated with @" throw new ConfigurationException("Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is annotated with @"
+ TransactionParam.class.getName() + " but can not be a collection of collections"); + TransactionParam.class.getName() + " but can not be a collection of collections");
} }
if (theParameterType.equals(Bundle.class)) { if (Modifier.isInterface(theParameterType.getModifiers()) == false && IBaseResource.class.isAssignableFrom(theParameterType)) {
myParamStyle = ParamStyle.DSTU1_BUNDLE;
if (theInnerCollectionType != null) {
throw new ConfigurationException(createParameterTypeError(theMethod));
}
} else if (Modifier.isInterface(theParameterType.getModifiers()) == false && IBaseResource.class.isAssignableFrom(theParameterType)) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Class<? extends IBaseResource> parameterType = (Class<? extends IBaseResource>) theParameterType; Class<? extends IBaseResource> parameterType = (Class<? extends IBaseResource>) theParameterType;
RuntimeResourceDefinition def = myContext.getResourceDefinition(parameterType); RuntimeResourceDefinition def = myContext.getResourceDefinition(parameterType);
@ -74,8 +64,6 @@ public class TransactionParameter implements IParameter {
} }
public enum ParamStyle { public enum ParamStyle {
/** Old style bundle (defined in hapi-fhir-base) */
DSTU1_BUNDLE,
/** New style bundle (defined in hapi-fhir-structures-* as a resource definition itself */ /** New style bundle (defined in hapi-fhir-structures-* as a resource definition itself */
RESOURCE_BUNDLE, RESOURCE_BUNDLE,
/** List of resources */ /** List of resources */

View File

@ -264,11 +264,6 @@ public class Dstu3BundleFactory implements IVersionSpecificBundleFactory {
} }
} }
@Override
public ca.uhn.fhir.model.api.Bundle getDstu1Bundle() {
return null;
}
@Override @Override
public IBaseResource getResourceBundle() { public IBaseResource getResourceBundle() {
return myBundle; return myBundle;

View File

@ -5,11 +5,7 @@ import java.util.List;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.validation.*;
import ca.uhn.fhir.validation.IValidationContext;
import ca.uhn.fhir.validation.IValidatorModule;
import ca.uhn.fhir.validation.ResultSeverityEnum;
import ca.uhn.fhir.validation.SingleValidationMessage;
/** /**
* Base class for a bridge between the RI validation tools and HAPI * Base class for a bridge between the RI validation tools and HAPI
@ -42,11 +38,6 @@ abstract class BaseValidatorBridge implements IValidatorModule {
protected abstract List<ValidationMessage> validate(IValidationContext<?> theCtx); protected abstract List<ValidationMessage> validate(IValidationContext<?> theCtx);
@Override
public void validateBundle(IValidationContext<Bundle> theCtx) {
doValidate(theCtx);
}
@Override @Override
public void validateResource(IValidationContext<IBaseResource> theCtx) { public void validateResource(IValidationContext<IBaseResource> theCtx) {
doValidate(theCtx); doValidate(theCtx);

View File

@ -923,18 +923,6 @@ public class GenericClientDstu3Test {
} }
@SuppressWarnings("deprecation")
@Test
public void testInvalidConformanceCall() {
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
try {
client.conformance();
fail();
} catch (IllegalArgumentException e) {
assertEquals("Must call fetchConformance() instead of conformance() for RI/STU3+ structures", e.getMessage());
}
}
/** /**
* See #150 * See #150
*/ */

View File

@ -6,14 +6,10 @@ import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Patient;
import org.junit.After; import org.junit.*;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.DataFormatException;
public class XmlUtilDstu3Test { public class XmlUtilDstu3Test {
@ -57,12 +53,6 @@ public class XmlUtilDstu3Test {
} catch (ConfigurationException e) { } catch (ConfigurationException e) {
// good // good
} }
try {
ourCtx.newXmlParser().encodeBundleToString(new Bundle());
fail();
} catch (ConfigurationException e) {
// good
}
} }
public void testXmlFactoryThrowsFactoryConfigurationError() { public void testXmlFactoryThrowsFactoryConfigurationError() {