From f8e647511b4a82e7fde71a8850b8800e3d698b1f Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 6 Jul 2017 18:46:55 -0400 Subject: [PATCH] Work on hapi3 changes --- .../BaseAddOrDeleteTagsMethodBinding.java | 7 +++--- ...indingWithResourceIdButNoResourceBody.java | 5 ++-- .../client/method/GetTagsMethodBinding.java | 5 ++-- .../client/method/HistoryMethodBinding.java | 3 ++- .../client/method/OperationMethodBinding.java | 25 +++++-------------- .../rest/client/method/ReadMethodBinding.java | 5 ++-- .../client/method/SearchMethodBinding.java | 3 ++- .../client/method/UpdateMethodBinding.java | 3 ++- .../method/ValidateMethodBindingDstu1.java | 3 ++- 9 files changed, 27 insertions(+), 32 deletions(-) diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseAddOrDeleteTagsMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseAddOrDeleteTagsMethodBinding.java index 43a9ef94fd5..eb69747ae34 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseAddOrDeleteTagsMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseAddOrDeleteTagsMethodBinding.java @@ -17,6 +17,7 @@ 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 { @@ -38,9 +39,9 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding myResourceName = theContext.getResourceDefinition(myType).getName(); - myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); - myVersionIdParamIndex = MethodUtil.findVersionIdParameterIndex(theMethod); - myTagListParamIndex = MethodUtil.findTagListParameterIndex(theMethod); + 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."); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseOutcomeReturningMethodBindingWithResourceIdButNoResourceBody.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseOutcomeReturningMethodBindingWithResourceIdButNoResourceBody.java index cb140f83d4d..643b8b5393b 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseOutcomeReturningMethodBindingWithResourceIdButNoResourceBody.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseOutcomeReturningMethodBindingWithResourceIdButNoResourceBody.java @@ -27,6 +27,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource; import ca.uhn.fhir.context.*; //TODO Use of a deprecated method should be resolved import ca.uhn.fhir.rest.annotation.*; +import ca.uhn.fhir.rest.param.ParameterUtil; public abstract class BaseOutcomeReturningMethodBindingWithResourceIdButNoResourceBody extends BaseOutcomeReturningMethodBinding { @@ -45,12 +46,12 @@ public abstract class BaseOutcomeReturningMethodBindingWithResourceIdButNoResour "Can not determine resource type for method '" + theMethod.getName() + "' on type " + theMethod.getDeclaringClass().getCanonicalName() + " - Did you forget to include the resourceType() value on the @" + Delete.class.getSimpleName() + " method annotation?"); } - myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); + myIdParameterIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext()); if (myIdParameterIndex == null) { throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has no parameter annotated with the @" + IdParam.class.getSimpleName() + " annotation"); } - Integer versionIdParameterIndex = MethodUtil.findVersionIdParameterIndex(theMethod); + Integer versionIdParameterIndex = ParameterUtil.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"); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/GetTagsMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/GetTagsMethodBinding.java index 15b1ebd6453..6d31fa09dcd 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/GetTagsMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/GetTagsMethodBinding.java @@ -19,6 +19,7 @@ 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; @@ -38,8 +39,8 @@ public class GetTagsMethodBinding extends BaseMethodBinding { myResourceName = theContext.getResourceDefinition(myType).getName(); } - myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); - myVersionIdParamIndex = MethodUtil.findVersionIdParameterIndex(theMethod); + 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() diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HistoryMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HistoryMethodBinding.java index 08e5d2b5315..0886db3a5cf 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HistoryMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/HistoryMethodBinding.java @@ -37,6 +37,7 @@ import ca.uhn.fhir.rest.annotation.History; 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.InternalErrorException; public class HistoryMethodBinding extends BaseResourceReturningMethodBinding { @@ -48,7 +49,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding { public HistoryMethodBinding(Method theMethod, FhirContext theContext, Object theProvider) { super(toReturnType(theMethod, theProvider), theMethod, theContext, theProvider); - myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); + myIdParamIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext()); History historyAnnotation = theMethod.getAnnotation(History.class); Class type = historyAnnotation.type(); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/OperationMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/OperationMethodBinding.java index 493678eeebe..fdf8381ae73 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/OperationMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/OperationMethodBinding.java @@ -25,31 +25,18 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; -import org.hl7.fhir.instance.model.api.IBase; -import org.hl7.fhir.instance.model.api.IBaseBundle; -import org.hl7.fhir.instance.model.api.IBaseDatatype; -import org.hl7.fhir.instance.model.api.IBaseParameters; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.instance.model.api.IIdType; -import org.hl7.fhir.instance.model.api.IPrimitiveType; +import org.hl7.fhir.instance.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.*; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.model.valueset.BundleTypeEnum; -import ca.uhn.fhir.rest.annotation.IdParam; -import ca.uhn.fhir.rest.annotation.Operation; -import ca.uhn.fhir.rest.annotation.OperationParam; +import ca.uhn.fhir.rest.annotation.*; 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.InternalErrorException; import ca.uhn.fhir.util.FhirTerser; @@ -75,7 +62,7 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding { myBundleType = theBundleType; myIdempotent = theIdempotent; - myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); + myIdParamIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext()); if (myIdParamIndex != null) { for (Annotation next : theMethod.getParameterAnnotations()[myIdParamIndex]) { if (next instanceof IdParam) { diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/ReadMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/ReadMethodBinding.java index f30d0428a0f..f84a37de7cf 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/ReadMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/ReadMethodBinding.java @@ -37,6 +37,7 @@ import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.rest.annotation.*; import ca.uhn.fhir.rest.api.RestOperationTypeEnum; +import ca.uhn.fhir.rest.param.ParameterUtil; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; public class ReadMethodBinding extends BaseResourceReturningMethodBinding implements IClientResponseHandlerHandlesBinary { @@ -51,8 +52,8 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem Validate.notNull(theMethod, "Method must not be null"); - Integer idIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); - Integer versionIdIndex = MethodUtil.findVersionIdParameterIndex(theMethod); + Integer idIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext()); + Integer versionIdIndex = ParameterUtil.findVersionIdParameterIndex(theMethod); Class[] parameterTypes = theMethod.getParameterTypes(); diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/SearchMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/SearchMethodBinding.java index e7f27da265d..066ffcac56e 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/SearchMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/SearchMethodBinding.java @@ -37,6 +37,7 @@ import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.api.*; import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation; +import ca.uhn.fhir.rest.param.ParameterUtil; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; @@ -51,7 +52,7 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding { Search search = theMethod.getAnnotation(Search.class); this.myQueryName = StringUtils.defaultIfBlank(search.queryName(), null); this.myCompartmentName = StringUtils.defaultIfBlank(search.compartmentName(), null); - this.myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); + this.myIdParamIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext()); Description desc = theMethod.getAnnotation(Description.class); if (desc != null) { diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/UpdateMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/UpdateMethodBinding.java index 81d8da5709e..0d27fe6ad7c 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/UpdateMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/UpdateMethodBinding.java @@ -16,6 +16,7 @@ import ca.uhn.fhir.rest.annotation.Update; import ca.uhn.fhir.rest.api.RequestTypeEnum; 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.InvalidRequestException; public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithResourceParam { @@ -25,7 +26,7 @@ public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe public UpdateMethodBinding(Method theMethod, FhirContext theContext, Object theProvider) { super(theMethod, theContext, Update.class, theProvider); - myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); + myIdParameterIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext()); } diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/ValidateMethodBindingDstu1.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/ValidateMethodBindingDstu1.java index 969fcf85fe0..632fc366666 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/ValidateMethodBindingDstu1.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/ValidateMethodBindingDstu1.java @@ -32,6 +32,7 @@ import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.annotation.Validate; import ca.uhn.fhir.rest.api.*; import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation; +import ca.uhn.fhir.rest.param.ParameterUtil; public class ValidateMethodBindingDstu1 extends BaseOutcomeReturningMethodBindingWithResourceParam { @@ -40,7 +41,7 @@ public class ValidateMethodBindingDstu1 extends BaseOutcomeReturningMethodBindin public ValidateMethodBindingDstu1(Method theMethod, FhirContext theContext, Object theProvider) { super(theMethod, theContext, Validate.class, theProvider); - myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod, getContext()); + myIdParameterIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext()); } @Override