Start working on action interceptor framework

This commit is contained in:
James Agnew 2015-08-14 17:05:07 -04:00
parent c859c9da91
commit 89a7750bf4
34 changed files with 464 additions and 755 deletions

View File

@ -1,140 +0,0 @@
package ca.uhn.fhir.model.dstu.valueset;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 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.HashMap;
import java.util.Map;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
@CoverageIgnore
public enum RestfulOperationSystemEnum {
/**
* Code Value: <b>transaction</b>
*/
TRANSACTION("transaction", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>search-system</b>
*/
SEARCH_SYSTEM("search-system", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>history-system</b>
*/
HISTORY_SYSTEM("history-system", "http://hl7.org/fhir/restful-operation"),
;
/**
* Identifier for this Value Set:
* http://hl7.org/fhir/vs/system-restful-operation
*/
public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/system-restful-operation";
/**
* Name for this Value Set:
* RestfulOperationSystem
*/
public static final String VALUESET_NAME = "RestfulOperationSystem";
private static Map<String, RestfulOperationSystemEnum> CODE_TO_ENUM = new HashMap<String, RestfulOperationSystemEnum>();
private static Map<String, Map<String, RestfulOperationSystemEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, RestfulOperationSystemEnum>>();
private final String myCode;
private final String mySystem;
static {
for (RestfulOperationSystemEnum next : RestfulOperationSystemEnum.values()) {
CODE_TO_ENUM.put(next.getCode(), next);
if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, RestfulOperationSystemEnum>());
}
SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
}
}
/**
* Returns the code associated with this enumerated value
*/
public String getCode() {
return myCode;
}
/**
* Returns the code system associated with this enumerated value
*/
public String getSystem() {
return mySystem;
}
/**
* Returns the enumerated value associated with this code
*/
public RestfulOperationSystemEnum forCode(String theCode) {
RestfulOperationSystemEnum retVal = CODE_TO_ENUM.get(theCode);
return retVal;
}
/**
* Converts codes to their respective enumerated values
*/
public static final IValueSetEnumBinder<RestfulOperationSystemEnum> VALUESET_BINDER = new IValueSetEnumBinder<RestfulOperationSystemEnum>() {
@Override
public String toCodeString(RestfulOperationSystemEnum theEnum) {
return theEnum.getCode();
}
@Override
public String toSystemString(RestfulOperationSystemEnum theEnum) {
return theEnum.getSystem();
}
@Override
public RestfulOperationSystemEnum fromCodeString(String theCodeString) {
return CODE_TO_ENUM.get(theCodeString);
}
@Override
public RestfulOperationSystemEnum fromCodeString(String theCodeString, String theSystemString) {
Map<String, RestfulOperationSystemEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
if (map == null) {
return null;
}
return map.get(theCodeString);
}
};
/**
* Constructor
*/
RestfulOperationSystemEnum(String theCode, String theSystem) {
myCode = theCode;
mySystem = theSystem;
}
}

View File

@ -1,170 +0,0 @@
package ca.uhn.fhir.model.dstu.valueset;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 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.HashMap;
import java.util.Map;
import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
@CoverageIgnore
public enum RestfulOperationTypeEnum {
/**
* Code Value: <b>read</b>
*/
READ("read", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>vread</b>
*/
VREAD("vread", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>update</b>
*/
UPDATE("update", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>delete</b>
*/
DELETE("delete", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>history-instance</b>
*/
HISTORY_INSTANCE("history-instance", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>validate</b>
*/
VALIDATE("validate", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>history-type</b>
*/
HISTORY_TYPE("history-type", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>create</b>
*/
CREATE("create", "http://hl7.org/fhir/restful-operation"),
/**
* Code Value: <b>search-type</b>
*/
SEARCH_TYPE("search-type", "http://hl7.org/fhir/restful-operation"),
;
/**
* Identifier for this Value Set:
* http://hl7.org/fhir/vs/type-restful-operation
*/
public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/type-restful-operation";
/**
* Name for this Value Set:
* RestfulOperationType
*/
public static final String VALUESET_NAME = "RestfulOperationType";
private static Map<String, RestfulOperationTypeEnum> CODE_TO_ENUM = new HashMap<String, RestfulOperationTypeEnum>();
private static Map<String, Map<String, RestfulOperationTypeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, RestfulOperationTypeEnum>>();
private final String myCode;
private final String mySystem;
static {
for (RestfulOperationTypeEnum next : RestfulOperationTypeEnum.values()) {
CODE_TO_ENUM.put(next.getCode(), next);
if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, RestfulOperationTypeEnum>());
}
SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
}
}
/**
* Returns the code associated with this enumerated value
*/
public String getCode() {
return myCode;
}
/**
* Returns the code system associated with this enumerated value
*/
public String getSystem() {
return mySystem;
}
/**
* Returns the enumerated value associated with this code
*/
public RestfulOperationTypeEnum forCode(String theCode) {
RestfulOperationTypeEnum retVal = CODE_TO_ENUM.get(theCode);
return retVal;
}
/**
* Converts codes to their respective enumerated values
*/
public static final IValueSetEnumBinder<RestfulOperationTypeEnum> VALUESET_BINDER = new IValueSetEnumBinder<RestfulOperationTypeEnum>() {
@Override
public String toCodeString(RestfulOperationTypeEnum theEnum) {
return theEnum.getCode();
}
@Override
public String toSystemString(RestfulOperationTypeEnum theEnum) {
return theEnum.getSystem();
}
@Override
public RestfulOperationTypeEnum fromCodeString(String theCodeString) {
return CODE_TO_ENUM.get(theCodeString);
}
@Override
public RestfulOperationTypeEnum fromCodeString(String theCodeString, String theSystemString) {
Map<String, RestfulOperationTypeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
if (map == null) {
return null;
}
return map.get(theCodeString);
}
};
/**
* Constructor
*/
RestfulOperationTypeEnum(String theCode, String theSystem) {
myCode = theCode;
mySystem = theSystem;
}
}

View File

@ -0,0 +1,164 @@
package ca.uhn.fhir.rest.api;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 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.HashMap;
import java.util.Map;
import net.sourceforge.cobertura.CoverageIgnore;
@CoverageIgnore
public enum RestOperationTypeEnum {
ADD_TAGS("add-tags"),
DELETE_TAGS("delete-tags"),
GET_TAGS("get-tags"),
GET_PAGE("get-page"),
/**
* E.g. $everything, $validate, etc.
*/
EXTENDED_OPERATION_SERVER("extended-operation-server"),
/**
* E.g. $everything, $validate, etc.
*/
EXTENDED_OPERATION_TYPE("extended-operation-type"),
/**
* E.g. $everything, $validate, etc.
*/
EXTENDED_OPERATION_INSTANCE("extended-operation-instance"),
/**
* Code Value: <b>create</b>
*/
CREATE("create"),
/**
* Code Value: <b>delete</b>
*/
DELETE("delete"),
/**
* Code Value: <b>history-instance</b>
*/
HISTORY_INSTANCE("history-instance"),
/**
* Code Value: <b>history-system</b>
*/
HISTORY_SYSTEM("history-system"),
/**
* Code Value: <b>history-type</b>
*/
HISTORY_TYPE("history-type"),
/**
* Code Value: <b>read</b>
*/
READ("read"),
/**
* Code Value: <b>search-system</b>
*/
SEARCH_SYSTEM("search-system"),
/**
* Code Value: <b>search-type</b>
*/
SEARCH_TYPE("search-type"),
/**
* Code Value: <b>transaction</b>
*/
TRANSACTION("transaction"),
/**
* Code Value: <b>update</b>
*/
UPDATE("update"),
/**
* Code Value: <b>validate</b>
*/
VALIDATE("validate"),
/**
* Code Value: <b>vread</b>
*/
VREAD("vread"),
/**
* Load the server's metadata
*/
METADATA("metadata"),
;
private static Map<String, RestOperationTypeEnum> CODE_TO_ENUM = new HashMap<String, RestOperationTypeEnum>();
/**
* Identifier for this Value Set: http://hl7.org/fhir/vs/type-restful-operation
*/
public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/type-restful-operation";
/**
* Name for this Value Set: RestfulOperationType
*/
public static final String VALUESET_NAME = "RestfulOperationType";
static {
for (RestOperationTypeEnum next : RestOperationTypeEnum.values()) {
CODE_TO_ENUM.put(next.getCode(), next);
}
}
private final String myCode;
/**
* Constructor
*/
RestOperationTypeEnum(String theCode) {
myCode = theCode;
}
/**
* Returns the enumerated value associated with this code
*/
public RestOperationTypeEnum forCode(String theCode) {
RestOperationTypeEnum retVal = CODE_TO_ENUM.get(theCode);
return retVal;
}
/**
* Returns the code associated with this enumerated value
*/
public String getCode() {
return myCode;
}
}

View File

@ -24,6 +24,7 @@ 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 {
@ -37,8 +38,8 @@ class AddTagsMethodBinding extends BaseAddOrDeleteTagsMethodBinding {
}
@Override
public OtherOperationTypeEnum getOtherOperationType() {
return OtherOperationTypeEnum.ADD_TAGS;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.ADD_TAGS;
}
}

View File

@ -36,13 +36,12 @@ 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.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.TagListParam;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.IResourceProvider;
@ -90,7 +89,7 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void>
}
@Override
public Void invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException, BaseServerResponseException {
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:
@ -108,12 +107,7 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void>
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return null;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
public RestOperationTypeEnum getResourceOperationType() {
return null;
}

View File

@ -19,8 +19,7 @@ package ca.uhn.fhir.rest.method;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.io.IOException;
import java.io.InputStream;
@ -46,8 +45,6 @@ import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.annotation.AddTags;
import ca.uhn.fhir.rest.annotation.Create;
@ -63,6 +60,7 @@ import ca.uhn.fhir.rest.annotation.Transaction;
import ca.uhn.fhir.rest.annotation.Update;
import ca.uhn.fhir.rest.annotation.Validate;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.client.exceptions.NonFhirResponseException;
import ca.uhn.fhir.rest.server.BundleProviders;
@ -185,10 +183,6 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
return myMethod;
}
public OtherOperationTypeEnum getOtherOperationType() {
return null;
}
public List<IParameter> getParameters() {
return myParameters;
}
@ -238,29 +232,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
*/
public abstract String getResourceName();
public abstract RestfulOperationTypeEnum getResourceOperationType();
/**
* Returns the value of {@link #getResourceOperationType()} or {@link #getSystemOperationType()} or
* {@link #getOtherOperationType()}
*/
public String getResourceOrSystemOperationType() {
Enum<?> retVal = getResourceOperationType();
if (retVal != null) {
return retVal.name();
}
retVal = getSystemOperationType();
if (retVal != null) {
return retVal.name();
}
retVal = getOtherOperationType();
if (retVal != null) {
return retVal.name();
}
return null;
}
public abstract RestfulOperationSystemEnum getSystemOperationType();
public abstract RestOperationTypeEnum getResourceOperationType();
public abstract boolean incomingServerRequestMatchesMethod(RequestDetails theRequest);

View File

@ -19,8 +19,7 @@ package ca.uhn.fhir.rest.method;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.lang.reflect.Method;
import java.util.Collection;
@ -31,17 +30,17 @@ import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
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;
class ConditionalParamBinder implements IParameter {
private RestfulOperationTypeEnum myOperationType;
private RestOperationTypeEnum myOperationType;
private boolean mySupportsMultiple;
ConditionalParamBinder(RestfulOperationTypeEnum theOperationType, boolean theSupportsMultiple) {
ConditionalParamBinder(RestOperationTypeEnum theOperationType, boolean theSupportsMultiple) {
Validate.notNull(theOperationType, "theOperationType can not be null");
myOperationType = theOperationType;
mySupportsMultiple = theSupportsMultiple;
@ -64,7 +63,7 @@ class ConditionalParamBinder implements IParameter {
@Override
public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, byte[] theRequestContents, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException {
if (myOperationType == RestfulOperationTypeEnum.CREATE) {
if (myOperationType == RestOperationTypeEnum.CREATE) {
String retVal = theRequest.getServletRequest().getHeader(Constants.HEADER_IF_NONE_EXIST);
if (isBlank(retVal)) {
return null;
@ -73,7 +72,7 @@ class ConditionalParamBinder implements IParameter {
retVal = retVal.substring(theRequest.getFhirServerBase().length());
}
return retVal;
} else if (myOperationType != RestfulOperationTypeEnum.DELETE && myOperationType != RestfulOperationTypeEnum.UPDATE) {
} else if (myOperationType != RestOperationTypeEnum.DELETE && myOperationType != RestOperationTypeEnum.UPDATE) {
return null;
}

View File

@ -27,10 +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.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.server.IBundleProvider;
import ca.uhn.fhir.rest.server.SimpleBundleProvider;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
@ -91,18 +90,8 @@ public class ConformanceMethodBinding extends BaseResourceReturningMethodBinding
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return null;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
}
@Override
public OtherOperationTypeEnum getOtherOperationType() {
return OtherOperationTypeEnum.METADATA;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.METADATA;
}
@Override

View File

@ -26,10 +26,9 @@ import java.util.Set;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.rest.annotation.Create;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
public class CreateMethodBinding extends BaseOutcomeReturningMethodBindingWithResourceParam {
@ -39,13 +38,8 @@ public class CreateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return RestfulOperationTypeEnum.CREATE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.CREATE;
}
@Override

View File

@ -32,13 +32,12 @@ 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.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.annotation.Delete;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.VersionIdParam;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -87,13 +86,8 @@ public class DeleteMethodBinding extends BaseOutcomeReturningMethodBinding {
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return RestfulOperationTypeEnum.DELETE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.DELETE;
}
@Override

View File

@ -24,6 +24,7 @@ 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 {
@ -37,8 +38,8 @@ public class DeleteTagsMethodBinding extends BaseAddOrDeleteTagsMethodBinding {
}
@Override
public OtherOperationTypeEnum getOtherOperationType() {
return OtherOperationTypeEnum.DELETE_TAGS;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.DELETE_TAGS;
}
}

View File

@ -30,10 +30,9 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.IBundleProvider;
@ -96,13 +95,8 @@ public class DynamicSearchMethodBinding extends BaseResourceReturningMethodBindi
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return RestfulOperationTypeEnum.SEARCH_TYPE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.SEARCH_TYPE;
}
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DynamicSearchMethodBinding.class);

View File

@ -36,13 +36,12 @@ 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.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
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.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.EncodingEnum;
@ -55,10 +54,10 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
private Class<? extends IBaseResource> myType;
private Integer myIdParamIndex;
private Integer myVersionIdParamIndex;
private String myResourceName;
private Class<? extends IBaseResource> myType;
private Integer myVersionIdParamIndex;
public GetTagsMethodBinding(Method theMethod, FhirContext theConetxt, Object theProvider, GetTags theAnnotation) {
super(theMethod, theConetxt, theProvider);
@ -68,7 +67,7 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
} else {
myType = theAnnotation.type();
}
if (!Modifier.isInterface(myType.getModifiers())) {
myResourceName = theConetxt.getResourceDefinition(myType).getName();
}
@ -77,35 +76,44 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
myVersionIdParamIndex = MethodUtil.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");
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 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);
TagList retVal = parser.parseTagList(theResponseReader);
return retVal;
} else {
throw processNon2xxResponseAndReturnExceptionToThrow(theResponseStatusCode, theResponseMimeType, theResponseReader);
}
}
@Override
public String getResourceName() {
return myResourceName;
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return null;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.GET_TAGS;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
if (theRequest.getRequestType() != RequestTypeEnum.GET) {
return false;
}
if (!Constants.PARAM_TAGS.equals(theRequest.getOperation())) {
return false;
}
if (myResourceName == null) {
if (getResourceName() != null) {
return false;
}
} else if (!myResourceName.equals(theRequest.getResourceName())) {
return false;
}
if ((myIdParamIndex != null) != (theRequest.getId() != null)) {
return false;
}
// if ((myVersionIdParamIndex != null) != (theRequest.getVersionId() != null)) {
// return false;
// }
return true;
}
@Override
@ -125,7 +133,7 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
if (id != null) {
if (versionId != null) {
retVal = new HttpGetClientInvocation(getResourceName(), id.getIdPart(), Constants.PARAM_HISTORY, versionId.getValue(), Constants.PARAM_TAGS);
} else if (id.hasVersionIdPart()){
} else if (id.hasVersionIdPart()) {
retVal = new HttpGetClientInvocation(getResourceName(), id.getIdPart(), Constants.PARAM_HISTORY, id.getVersionIdPart(), Constants.PARAM_TAGS);
} else {
retVal = new HttpGetClientInvocation(getResourceName(), id.getIdPart(), Constants.PARAM_TAGS);
@ -147,6 +155,18 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
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);
TagList retVal = parser.parseTagList(theResponseReader);
return retVal;
} else {
throw processNon2xxResponseAndReturnExceptionToThrow(theResponseStatusCode, theResponseMimeType, theResponseReader);
}
}
@Override
public void invokeServer(RestfulServer theServer, RequestDetails theRequest) throws BaseServerResponseException, IOException {
Object[] params = createParametersForServerRequest(theRequest, null);
@ -167,7 +187,7 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
return;
}
}
EncodingEnum responseEncoding = RestfulServerUtils.determineResponseEncodingWithDefault(theServer, theRequest.getServletRequest());
HttpServletResponse response = theRequest.getServletResponse();
@ -187,34 +207,4 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
}
}
@Override
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
if (theRequest.getRequestType()!=RequestTypeEnum.GET) {
return false;
}
if (!Constants.PARAM_TAGS.equals(theRequest.getOperation())) {
return false;
}
if (myResourceName == null) {
if (getResourceName() != null) {
return false;
}
} else if (!myResourceName.equals(theRequest.getResourceName())) {
return false;
}
if ((myIdParamIndex != null) != (theRequest.getId() != null)) {
return false;
}
// if ((myVersionIdParamIndex != null) != (theRequest.getVersionId() != null)) {
// return false;
// }
return true;
}
@Override
public OtherOperationTypeEnum getOtherOperationType() {
return OtherOperationTypeEnum.GET_TAGS;
}
}

View File

@ -19,26 +19,26 @@ package ca.uhn.fhir.rest.method;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.BaseDateTimeDt;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.History;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.IBundleProvider;
@ -50,8 +50,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
private final Integer myIdParamIndex;
private String myResourceName;
private final RestfulOperationTypeEnum myResourceOperationType;
private final RestfulOperationSystemEnum mySystemOperationType;
private final RestOperationTypeEnum myResourceOperationType;
public HistoryMethodBinding(Method theMethod, FhirContext theConetxt, Object theProvider) {
super(toReturnType(theMethod, theProvider), theMethod, theConetxt, theProvider);
@ -64,22 +63,19 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
if (theProvider instanceof IResourceProvider) {
type = ((IResourceProvider) theProvider).getResourceType();
if (myIdParamIndex != null) {
myResourceOperationType = RestfulOperationTypeEnum.HISTORY_INSTANCE;
myResourceOperationType = RestOperationTypeEnum.HISTORY_INSTANCE;
} else {
myResourceOperationType = RestfulOperationTypeEnum.HISTORY_TYPE;
myResourceOperationType = RestOperationTypeEnum.HISTORY_TYPE;
}
mySystemOperationType = null;
} else {
myResourceOperationType = null;
mySystemOperationType = RestfulOperationSystemEnum.HISTORY_SYSTEM;
myResourceOperationType = RestOperationTypeEnum.HISTORY_SYSTEM;
}
} else {
if (myIdParamIndex != null) {
myResourceOperationType = RestfulOperationTypeEnum.HISTORY_INSTANCE;
myResourceOperationType = RestOperationTypeEnum.HISTORY_INSTANCE;
} else {
myResourceOperationType = RestfulOperationTypeEnum.HISTORY_TYPE;
myResourceOperationType = RestOperationTypeEnum.HISTORY_TYPE;
}
mySystemOperationType = null;
}
if (type != IResource.class) {
@ -91,7 +87,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
public RestOperationTypeEnum getResourceOperationType() {
return myResourceOperationType;
}
@ -105,22 +101,16 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
return ReturnTypeEnum.BUNDLE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return mySystemOperationType;
}
// ObjectUtils.equals is replaced by a JDK7 method..
@SuppressWarnings("deprecation")
@Override
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
if (!Constants.PARAM_HISTORY.equals(theRequest.getOperation())) {
return false;
}
if (theRequest.getResourceName() == null) {
return mySystemOperationType == RestfulOperationSystemEnum.HISTORY_SYSTEM;
return myResourceOperationType == RestOperationTypeEnum.HISTORY_SYSTEM;
}
if (!ObjectUtils.equals(theRequest.getResourceName(), myResourceName)) {
if (!StringUtils.equals(theRequest.getResourceName(), myResourceName)) {
return false;
}
@ -131,7 +121,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
}
if (theRequest.getId() == null) {
return myResourceOperationType == RestfulOperationTypeEnum.HISTORY_TYPE;
return myResourceOperationType == RestOperationTypeEnum.HISTORY_TYPE;
} else if (theRequest.getId().hasVersionIdPart()) {
return false;
}

View File

@ -1,6 +1,7 @@
package ca.uhn.fhir.rest.method;
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.io.IOException;
import java.io.PushbackReader;
@ -45,7 +46,6 @@ import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.StringDt;
@ -68,6 +68,7 @@ import ca.uhn.fhir.rest.annotation.TransactionParam;
import ca.uhn.fhir.rest.annotation.Validate;
import ca.uhn.fhir.rest.annotation.VersionIdParam;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.api.ValidationModeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.method.OperationParameter.IConverter;
@ -348,7 +349,7 @@ public class MethodUtil {
}
@SuppressWarnings("unchecked")
public static List<IParameter> getResourceParameters(FhirContext theContext, Method theMethod, Object theProvider, RestfulOperationTypeEnum theRestfulOperationTypeEnum) {
public static List<IParameter> getResourceParameters(FhirContext theContext, Method theMethod, Object theProvider, RestOperationTypeEnum theRestfulOperationTypeEnum) {
List<IParameter> parameters = new ArrayList<IParameter>();
Class<?>[] parameterTypes = theMethod.getParameterTypes();

View File

@ -19,8 +19,8 @@ package ca.uhn.fhir.rest.method;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@ -41,13 +41,12 @@ 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.annotation.Description;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.server.IBundleProvider;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
@ -64,7 +63,7 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
private final boolean myIdempotent;
private final Integer myIdParamIndex;
private final String myName;
private final OtherOperationTypeEnum myOtherOperatiopnType;
private final RestOperationTypeEnum myOtherOperatiopnType;
private List<ReturnType> myReturnParams;
private final ReturnTypeEnum myReturnType;
@ -118,11 +117,11 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
}
if (getResourceName() == null) {
myOtherOperatiopnType = OtherOperationTypeEnum.EXTENDED_OPERATION_SERVER;
myOtherOperatiopnType = RestOperationTypeEnum.EXTENDED_OPERATION_SERVER;
} else if (myIdParamIndex == null) {
myOtherOperatiopnType = OtherOperationTypeEnum.EXTENDED_OPERATION_TYPE;
myOtherOperatiopnType = RestOperationTypeEnum.EXTENDED_OPERATION_TYPE;
} else {
myOtherOperatiopnType = OtherOperationTypeEnum.EXTENDED_OPERATION_INSTANCE;
myOtherOperatiopnType = RestOperationTypeEnum.EXTENDED_OPERATION_INSTANCE;
}
myReturnParams = new ArrayList<OperationMethodBinding.ReturnType>();
@ -167,15 +166,10 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
}
@Override
public OtherOperationTypeEnum getOtherOperationType() {
public RestOperationTypeEnum getResourceOperationType() {
return myOtherOperatiopnType;
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return null;
}
@Override
protected BundleTypeEnum getResponseBundleType() {
return null;
@ -190,11 +184,6 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
return myReturnType;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
}
@Override
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
if (getResourceName() == null) {

View File

@ -1,60 +0,0 @@
package ca.uhn.fhir.rest.method;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
public enum OtherOperationTypeEnum {
METADATA("metadata"),
ADD_TAGS("add-tags"),
DELETE_TAGS("delete-tags"),
GET_TAGS("get-tags"),
GET_PAGE("get-page"),
/**
* E.g. $everything, $validate, etc.
*/
EXTENDED_OPERATION_SERVER("extended-operation-server"),
/**
* E.g. $everything, $validate, etc.
*/
EXTENDED_OPERATION_TYPE("extended-operation-type"),
/**
* E.g. $everything, $validate, etc.
*/
EXTENDED_OPERATION_INSTANCE("extended-operation-instance");
private String myCode;
OtherOperationTypeEnum(String theName) {
myCode=theName;
}
public String getCode() {
return myCode;
}
}

View File

@ -39,13 +39,12 @@ import ca.uhn.fhir.context.ConfigurationException;
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.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.ETagSupportEnum;
import ca.uhn.fhir.rest.server.IBundleProvider;
@ -100,8 +99,8 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return isVread() ? RestfulOperationTypeEnum.VREAD : RestfulOperationTypeEnum.READ;
public RestOperationTypeEnum getResourceOperationType() {
return isVread() ? RestOperationTypeEnum.VREAD : RestOperationTypeEnum.READ;
}
@Override
@ -109,11 +108,6 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
return ReturnTypeEnum.RESOURCE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
}
@Override
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
if (!theRequest.getResourceName().equals(getResourceName())) {

View File

@ -30,10 +30,9 @@ import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.server.RestfulServer;
public class RequestDetails {
@ -43,18 +42,16 @@ public class RequestDetails {
private String myFhirServerBase;
private IdDt myId;
private String myOperation;
private OtherOperationTypeEnum myOtherOperationType;
private Map<String, String[]> myParameters;
private String myRequestPath;
private RequestTypeEnum myRequestType;
private String myResourceName;
private RestfulOperationTypeEnum myResourceOperationType;
private RestOperationTypeEnum myResourceOperationType;
private boolean myRespondGzip;
private String mySecondaryOperation;
private RestfulServer myServer;
private HttpServletRequest myServletRequest;
private HttpServletResponse myServletResponse;
private RestfulOperationSystemEnum mySystemOperationType;
private Map<String, List<String>> myUnqualifiedToQualifiedNames;
public String getCompartmentName() {
@ -77,10 +74,6 @@ public class RequestDetails {
return myOperation;
}
public OtherOperationTypeEnum getOtherOperationType() {
return myOtherOperationType;
}
public Map<String, String[]> getParameters() {
return myParameters;
}
@ -103,7 +96,7 @@ public class RequestDetails {
return myResourceName;
}
public RestfulOperationTypeEnum getResourceOperationType() {
public RestOperationTypeEnum getResourceOperationType() {
return myResourceOperationType;
}
@ -123,10 +116,6 @@ public class RequestDetails {
return myServletResponse;
}
public RestfulOperationSystemEnum getSystemOperationType() {
return mySystemOperationType;
}
public Map<String, List<String>> getUnqualifiedToQualifiedNames() {
return myUnqualifiedToQualifiedNames;
}
@ -155,10 +144,6 @@ public class RequestDetails {
myOperation = theOperation;
}
public void setOtherOperationType(OtherOperationTypeEnum theOtherOperationType) {
myOtherOperationType = theOtherOperationType;
}
public void setParameters(Map<String, String[]> theParams) {
myParameters = theParams;
@ -200,7 +185,7 @@ public class RequestDetails {
myResourceName = theResourceName;
}
public void setResourceOperationType(RestfulOperationTypeEnum theResourceOperationType) {
public void setResourceOperationType(RestOperationTypeEnum theResourceOperationType) {
myResourceOperationType = theResourceOperationType;
}
@ -224,10 +209,6 @@ public class RequestDetails {
myServletResponse = theServletResponse;
}
public void setSystemOperationType(RestfulOperationSystemEnum theSystemOperationType) {
mySystemOperationType = theSystemOperationType;
}
public static RequestDetails withResourceAndParams(String theResourceName, RequestTypeEnum theRequestType, Set<String> theParamNames) {
RequestDetails retVal = new RequestDetails();
retVal.setResourceName(theResourceName);

View File

@ -19,8 +19,8 @@ package ca.uhn.fhir.rest.method;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -39,12 +39,11 @@ 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.annotation.Description;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.param.BaseQueryParameter;
import ca.uhn.fhir.rest.server.Constants;
@ -128,8 +127,8 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return RestfulOperationTypeEnum.SEARCH_TYPE;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.SEARCH_TYPE;
}
@Override
@ -142,11 +141,6 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
return ReturnTypeEnum.BUNDLE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
}
@Override
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
if (!theRequest.getResourceName().equals(getResourceName())) {

View File

@ -19,8 +19,7 @@ package ca.uhn.fhir.rest.method;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.lang.reflect.Method;
import java.util.IdentityHashMap;
@ -35,13 +34,12 @@ import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.Transaction;
import ca.uhn.fhir.rest.annotation.TransactionParam;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.param.TransactionParameter;
import ca.uhn.fhir.rest.param.TransactionParameter.ParamStyle;
@ -77,8 +75,8 @@ public class TransactionMethodBinding extends BaseResourceReturningMethodBinding
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return null;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.TRANSACTION;
}
@Override
@ -91,11 +89,6 @@ public class TransactionMethodBinding extends BaseResourceReturningMethodBinding
return ReturnTypeEnum.BUNDLE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return RestfulOperationSystemEnum.TRANSACTION;
}
@Override
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
if (theRequest.getRequestType() != RequestTypeEnum.POST) {

View File

@ -19,8 +19,7 @@ package ca.uhn.fhir.rest.method;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.lang.reflect.Method;
import java.util.Collections;
@ -28,12 +27,11 @@ import java.util.Set;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.annotation.Update;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
@ -49,13 +47,8 @@ class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithResourceP
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return RestfulOperationTypeEnum.UPDATE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.UPDATE;
}
@Override

View File

@ -26,11 +26,10 @@ import java.util.Set;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.annotation.Validate;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.server.Constants;
@ -45,13 +44,8 @@ public class ValidateMethodBindingDstu1 extends BaseOutcomeReturningMethodBindin
}
@Override
public RestfulOperationTypeEnum getResourceOperationType() {
return RestfulOperationTypeEnum.VALIDATE;
}
@Override
public RestfulOperationSystemEnum getSystemOperationType() {
return null;
public RestOperationTypeEnum getResourceOperationType() {
return RestOperationTypeEnum.VALIDATE;
}
@Override

View File

@ -166,7 +166,7 @@ public class ResourceParameter implements IParameter {
String ctValue = theRequest.getServletRequest().getHeader(Constants.HEADER_CONTENT_TYPE);
if (ctValue != null) {
if (ctValue.startsWith("application/x-www-form-urlencoded")) {
String msg = theRequest.getServer().getFhirContext().getLocalizer().getMessage(ResourceParameter.class, "invalidContentTypeInRequest", ctValue, theMethodBinding.getResourceOrSystemOperationType());
String msg = theRequest.getServer().getFhirContext().getLocalizer().getMessage(ResourceParameter.class, "invalidContentTypeInRequest", ctValue, theMethodBinding.getResourceOperationType());
throw new InvalidRequestException(msg);
}
}
@ -183,13 +183,13 @@ public class ResourceParameter implements IParameter {
}
encoding = MethodUtil.detectEncodingNoDefault(body);
if (encoding == null) {
String msg = ctx.getLocalizer().getMessage(ResourceParameter.class, "noContentTypeInRequest", theMethodBinding.getResourceOrSystemOperationType());
String msg = ctx.getLocalizer().getMessage(ResourceParameter.class, "noContentTypeInRequest", theMethodBinding.getResourceOperationType());
throw new InvalidRequestException(msg);
} else {
requestReader = new InputStreamReader(new ByteArrayInputStream(theRequestContents), charset);
}
} else {
String msg = ctx.getLocalizer().getMessage(ResourceParameter.class, "invalidContentTypeInRequest", ctValue, theMethodBinding.getResourceOrSystemOperationType());
String msg = ctx.getLocalizer().getMessage(ResourceParameter.class, "invalidContentTypeInRequest", ctValue, theMethodBinding.getResourceOperationType());
throw new InvalidRequestException(msg);
}
}

View File

@ -19,8 +19,8 @@ package ca.uhn.fhir.rest.server;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.io.IOException;
import java.lang.annotation.Annotation;
@ -59,9 +59,9 @@ import ca.uhn.fhir.rest.annotation.Destroy;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Initialize;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.method.BaseMethodBinding;
import ca.uhn.fhir.rest.method.ConformanceMethodBinding;
import ca.uhn.fhir.rest.method.OtherOperationTypeEnum;
import ca.uhn.fhir.rest.method.RequestDetails;
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
@ -501,7 +501,7 @@ public class RestfulServer extends HttpServlet {
requestDetails.setRequestType(theRequestType);
requestDetails.setServletRequest(theRequest);
requestDetails.setServletResponse(theResponse);
try {
for (IServerInterceptor next : myInterceptors) {
@ -640,7 +640,7 @@ public class RestfulServer extends HttpServlet {
String pagingAction = theRequest.getParameter(Constants.PARAM_PAGINGACTION);
if (getPagingProvider() != null && isNotBlank(pagingAction)) {
requestDetails.setOtherOperationType(OtherOperationTypeEnum.GET_PAGE);
requestDetails.setResourceOperationType(RestOperationTypeEnum.GET_PAGE);
if (theRequestType != RequestTypeEnum.GET) {
/*
* We reconstruct the link-self URL using the request parameters, and this would break if the parameters came in using a POST. We could probably work around that but why bother unless
@ -666,8 +666,6 @@ public class RestfulServer extends HttpServlet {
}
requestDetails.setResourceOperationType(resourceMethod.getResourceOperationType());
requestDetails.setSystemOperationType(resourceMethod.getSystemOperationType());
requestDetails.setOtherOperationType(resourceMethod.getOtherOperationType());
for (IServerInterceptor next : myInterceptors) {
boolean continueProcessing = next.incomingRequestPostProcessed(requestDetails, theRequest, theResponse);

View File

@ -0,0 +1,64 @@
package ca.uhn.fhir.rest.server.interceptor;
import javax.servlet.http.HttpServletRequest;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
/**
* Action interceptors are invoked by the server upon specific fhir operations, such as "read" (HTTP GET) or "create" (HTTP POST). They can be thought of as being a layer "above"
* {@link IServerInterceptor} interceptors.
* <p>
* These interceptors are useful as a means of adding authentication checks or audit operations on top of a server, since the HAPI RestfulServer translates the incoming requests into higher level
* operations.
* </p>
* <p>
* Note that unlike {@link IServerInterceptor}s, {@link IServerActionInterceptor}s do not have the ability to handle a request themselves and stop processing.
* </p>
*/
public interface IServerActionInterceptor extends IServerInterceptor {
/**
* Invoked before an incoming request is processed
*
* @param theServletRequest
* The incoming servlet request as provided by the servlet container
* @param theOperation
* The type of operation that the FHIR server has determined that the client is trying to invoke
* @param theRequestDetails
* An object which will be populated with any relevant details about the incoming request
*/
void preAction(HttpServletRequest theServletRequest, ActionOperationEnum theOperation, ActionRequestDetails theRequestDetails);
/**
* Represents the type of operation being invoked for a {@link IServerActionInterceptor#preAction(HttpServletRequest, ActionOperationEnum, ActionRequestDetails) preAction} call
*/
public static enum ActionOperationEnum {
READ, VREAD
}
public static class ActionRequestDetails {
private final IIdType myId;
private final IBaseResource myRequestResource;
public ActionRequestDetails(IIdType theId, IBaseResource theRequestResource) {
super();
myId = theId;
myRequestResource = theRequestResource;
}
/**
* Returns the ID of the incoming request (typically this is from the request URL)
*/
public IIdType getId() {
return myId;
}
/**
* Returns the incoming resource from the request (this will be populated only for operations which receive a resource, such as "create" and "update")
*/
public IBaseResource getRequestResource() {
return myRequestResource;
}
}
}

View File

@ -44,6 +44,8 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
* <b>See:</b> See the <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_server_interceptor.html">server
* interceptor documentation</a> for more information on how to use this class.
* </p>
*
* @see
*/
public interface IServerInterceptor {

View File

@ -39,7 +39,7 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
* of all methods, always returning <code>true</code>
*/
@SuppressWarnings("unused")
public class InterceptorAdapter implements IServerInterceptor {
public class InterceptorAdapter implements IServerInterceptor, IServerActionInterceptor {
@Override
public boolean incomingRequestPreProcessed(HttpServletRequest theRequest, HttpServletResponse theResponse) {
@ -82,4 +82,9 @@ public class InterceptorAdapter implements IServerInterceptor {
return true;
}
@Override
public void preAction(HttpServletRequest theServletRequest, ActionOperationEnum theOperation, ActionRequestDetails theRequestDetails) {
// nothing
}
}

View File

@ -144,16 +144,10 @@ public class LoggingInterceptor extends InterceptorAdapter {
if (myRequestDetails.getResourceOperationType() != null) {
return myRequestDetails.getResourceOperationType().getCode();
}
if (myRequestDetails.getSystemOperationType() != null) {
return myRequestDetails.getSystemOperationType().getCode();
}
if (myRequestDetails.getOtherOperationType() != null) {
return myRequestDetails.getOtherOperationType().getCode();
}
return "";
} else if ("operationName".equals(theKey)) {
if (myRequestDetails.getOtherOperationType() != null) {
switch (myRequestDetails.getOtherOperationType()) {
if (myRequestDetails.getResourceOperationType() != null) {
switch (myRequestDetails.getResourceOperationType()) {
case EXTENDED_OPERATION_INSTANCE:
case EXTENDED_OPERATION_SERVER:
case EXTENDED_OPERATION_TYPE:

View File

@ -442,14 +442,14 @@ public class AuditingInterceptor extends InterceptorAdapter {
/**
* Returns the SecurityEventActionEnum corresponding to the specified RestfulOperationTypeEnum
*
* @param resourceOperationType
* @param theRestfulOperationTypeEnum
* the type of operation (Read, Create, Delete, etc)
* @return the corresponding SecurityEventActionEnum (Read/View/Print, Create, Delete, etc)
*/
protected SecurityEventActionEnum mapResourceTypeToSecurityEventAction(RestfulOperationTypeEnum resourceOperationType) {
if (resourceOperationType == null)
protected SecurityEventActionEnum mapResourceTypeToSecurityEventAction(ca.uhn.fhir.rest.api.RestOperationTypeEnum theRestfulOperationTypeEnum) {
if (theRestfulOperationTypeEnum == null)
return null;
switch (resourceOperationType) {
switch (theRestfulOperationTypeEnum) {
case READ:
return SecurityEventActionEnum.READ_VIEW_PRINT;
case CREATE:
@ -476,15 +476,15 @@ public class AuditingInterceptor extends InterceptorAdapter {
/**
* Returns the SecurityEventObjectLifecycleEnum corresponding to the specified RestfulOperationTypeEnum
*
* @param resourceOperationType
* @param theRestfulOperationTypeEnum
* the type of operation (Read, Create, Delete, etc)
* @return the corresponding SecurityEventObjectLifecycleEnum (Access/Use, Origination/Creation, Logical Deletion,
* etc)
*/
protected SecurityEventObjectLifecycleEnum mapResourceTypeToSecurityLifecycle(RestfulOperationTypeEnum resourceOperationType) {
if (resourceOperationType == null)
protected SecurityEventObjectLifecycleEnum mapResourceTypeToSecurityLifecycle(ca.uhn.fhir.rest.api.RestOperationTypeEnum theRestfulOperationTypeEnum) {
if (theRestfulOperationTypeEnum == null)
return null;
switch (resourceOperationType) {
switch (theRestfulOperationTypeEnum) {
case READ:
return SecurityEventObjectLifecycleEnum.ACCESS_OR_USE;
case CREATE:

View File

@ -145,22 +145,24 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
// Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String,
// Conformance.RestResourceSearchParam>();
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
RestfulOperationTypeEnum resOp = nextMethodBinding.getResourceOperationType();
if (resOp != null) {
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addOperation().setCode(resOp);
if (nextMethodBinding.getResourceOperationType() != null) {
RestfulOperationTypeEnum resOp = RestfulOperationTypeEnum.VALUESET_BINDER.fromCodeString(nextMethodBinding.getResourceOperationType().getCode());
if (resOp != null) {
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addOperation().setCode(resOp);
}
}
RestfulOperationSystemEnum sysOp = RestfulOperationSystemEnum.VALUESET_BINDER.fromCodeString(nextMethodBinding.getResourceOperationType().getCode());
if (sysOp != null) {
if (systemOps.contains(sysOp) == false) {
systemOps.add(sysOp);
rest.addOperation().setCode(sysOp);
}
}
}
RestfulOperationSystemEnum sysOp = nextMethodBinding.getSystemOperationType();
if (sysOp != null) {
if (systemOps.contains(sysOp) == false) {
systemOps.add(sysOp);
rest.addOperation().setCode(sysOp);
}
}
if (nextMethodBinding instanceof SearchMethodBinding) {
handleSearchMethodBinding(rest, resource, resourceName, def, includes, (SearchMethodBinding) nextMethodBinding);
} else if (nextMethodBinding instanceof DynamicSearchMethodBinding) {

View File

@ -83,10 +83,8 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
*
* <p>
* Note: This class is safe to extend, but it is important to note that the same instance of {@link Conformance} is
* always returned unless {@link #setCache(boolean)} is called with a value of <code>false</code>. This means that if
* you are adding anything to the returned conformance instance on each call you should call
* <code>setCache(false)</code> in your provider constructor.
* Note: This class is safe to extend, but it is important to note that the same instance of {@link Conformance} is always returned unless {@link #setCache(boolean)} is called with a value of
* <code>false</code>. This means that if you are adding anything to the returned conformance instance on each call you should call <code>setCache(false)</code> in your provider constructor.
* </p>
*/
public class ServerConformanceProvider implements IServerConformanceProvider<Conformance> {
@ -103,12 +101,12 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
}
private void checkBindingForSystemOps(Rest rest, Set<SystemRestfulInteractionEnum> systemOps, BaseMethodBinding<?> nextMethodBinding) {
if (nextMethodBinding.getSystemOperationType() != null) {
String sysOpCode = nextMethodBinding.getSystemOperationType().getCode();
if (nextMethodBinding.getResourceOperationType() != null) {
String sysOpCode = nextMethodBinding.getResourceOperationType().getCode();
if (sysOpCode != null) {
SystemRestfulInteractionEnum sysOp = SystemRestfulInteractionEnum.VALUESET_BINDER.fromCodeString(sysOpCode);
if (sysOp == null) {
throw new InternalErrorException("Unknown system-restful-interaction: " + sysOpCode);
return;
}
if (systemOps.contains(sysOp) == false) {
systemOps.add(sysOp);
@ -144,9 +142,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
}
/**
* Gets the value of the "publisher" that will be placed in the generated conformance statement. As this is a
* mandatory element, the value should not be null (although this is not enforced). The value defaults to
* "Not provided" but may be set to null, which will cause this element to be omitted.
* Gets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
*/
public String getPublisher() {
return myPublisher;
@ -200,39 +197,38 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
String resOpCode = nextMethodBinding.getResourceOperationType().getCode();
if (resOpCode != null) {
TypeRestfulInteractionEnum resOp = TypeRestfulInteractionEnum.VALUESET_BINDER.fromCodeString(resOpCode);
if (resOp == null) {
throw new InternalErrorException("Unknown type-restful-interaction: " + resOpCode);
}
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addInteraction().setCode(resOp);
}
if ("vread".equals(resOpCode)) {
// vread implies read
resOp = TypeRestfulInteractionEnum.READ;
if (resOp != null) {
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addInteraction().setCode(resOp);
}
}
if (nextMethodBinding.isSupportsConditional()) {
switch (resOp) {
case CREATE:
resource.setConditionalCreate(true);
break;
case DELETE:
if (nextMethodBinding.isSupportsConditionalMultiple()) {
resource.setConditionalDelete(ConditionalDeleteStatusEnum.MULTIPLE_DELETES_SUPPORTED);
} else {
resource.setConditionalDelete(ConditionalDeleteStatusEnum.SINGLE_DELETES_SUPPORTED);
if ("vread".equals(resOpCode)) {
// vread implies read
resOp = TypeRestfulInteractionEnum.READ;
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addInteraction().setCode(resOp);
}
}
if (nextMethodBinding.isSupportsConditional()) {
switch (resOp) {
case CREATE:
resource.setConditionalCreate(true);
break;
case DELETE:
if (nextMethodBinding.isSupportsConditionalMultiple()) {
resource.setConditionalDelete(ConditionalDeleteStatusEnum.MULTIPLE_DELETES_SUPPORTED);
} else {
resource.setConditionalDelete(ConditionalDeleteStatusEnum.SINGLE_DELETES_SUPPORTED);
}
break;
case UPDATE:
resource.setConditionalUpdate(true);
break;
default:
break;
}
break;
case UPDATE:
resource.setConditionalUpdate(true);
break;
default:
break;
}
}
}
@ -452,7 +448,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
Set<String> inParams = new HashSet<String>();
Set<String> outParams = new HashSet<String>();
for (OperationMethodBinding sharedDescription : sharedDescriptions) {
if (isNotBlank(sharedDescription.getDescription())) {
op.setDescription(sharedDescription.getDescription());
@ -517,9 +513,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
}
/**
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a
* mandatory element, the value should not be null (although this is not enforced). The value defaults to
* "Not provided" but may be set to null, which will cause this element to be omitted.
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
*/
public void setPublisher(String thePublisher) {
myPublisher = thePublisher;

View File

@ -19,8 +19,7 @@ package org.hl7.fhir.instance.conf;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.ArrayList;
import java.util.Collections;
@ -50,7 +49,6 @@ import org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode;
import org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction;
import org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction;
import org.hl7.fhir.instance.model.Conformance.UnknownContentCode;
import org.hl7.fhir.instance.model.Enumerations.ConceptMapEquivalence;
import org.hl7.fhir.instance.model.Enumerations.ConformanceResourceStatus;
import org.hl7.fhir.instance.model.Enumerations.ResourceType;
import org.hl7.fhir.instance.model.OperationDefinition;
@ -104,8 +102,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
private void checkBindingForSystemOps(ConformanceRestComponent rest, Set<SystemRestfulInteraction> systemOps,
BaseMethodBinding<?> nextMethodBinding) {
if (nextMethodBinding.getSystemOperationType() != null) {
String sysOpCode = nextMethodBinding.getSystemOperationType().getCode();
if (nextMethodBinding.getResourceOperationType() != null) {
String sysOpCode = nextMethodBinding.getResourceOperationType().getCode();
if (sysOpCode != null) {
SystemRestfulInteraction sysOp;
try {
@ -114,7 +112,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
sysOp = null;
}
if (sysOp == null) {
throw new InternalErrorException("Unknown system-restful-interaction: " + sysOpCode);
return;
}
if (systemOps.contains(sysOp) == false) {
systemOps.add(sysOp);
@ -211,35 +209,34 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
} catch (Exception e) {
resOp = null;
}
if (resOp == null) {
throw new InternalErrorException("Unknown type-restful-interaction: " + resOpCode);
}
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addInteraction().setCode(resOp);
}
if ("vread".equals(resOpCode)) {
// vread implies read
resOp = TypeRestfulInteraction.READ;
if (resOp != null) {
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addInteraction().setCode(resOp);
}
}
if ("vread".equals(resOpCode)) {
// vread implies read
resOp = TypeRestfulInteraction.READ;
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addInteraction().setCode(resOp);
}
}
if (nextMethodBinding.isSupportsConditional()) {
switch (resOp) {
case CREATE:
resource.setConditionalCreate(true);
break;
case DELETE:
resource.setConditionalDelete(ConditionalDeleteStatus.SINGLE);
break;
case UPDATE:
resource.setConditionalUpdate(true);
break;
default:
break;
if (nextMethodBinding.isSupportsConditional()) {
switch (resOp) {
case CREATE:
resource.setConditionalCreate(true);
break;
case DELETE:
resource.setConditionalDelete(ConditionalDeleteStatus.SINGLE);
break;
case UPDATE:
resource.setConditionalUpdate(true);
break;
default:
break;
}
}
}
}

View File

@ -1,7 +1,8 @@
package ca.uhn.fhir.rest.server;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
@ -20,13 +21,13 @@ import org.hl7.fhir.instance.model.OperationDefinition;
import org.hl7.fhir.instance.model.Organization;
import org.hl7.fhir.instance.model.Parameters;
import org.hl7.fhir.instance.model.Patient;
import org.hl7.fhir.instance.model.StringType;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.util.PortUtil;
@ -110,7 +111,7 @@ public class OperationDuplicateServerHl7OrgDstu2Test {
public static class BaseProvider {
@Operation(name = "$myoperation", idempotent = true)
public Parameters opInstanceReturnsBundleProvider(@OperationParam(name = "myparam") StringDt theString) {
public Parameters opInstanceReturnsBundleProvider(@OperationParam(name = "myparam") StringType theString) {
return null;
}
@ -137,7 +138,7 @@ public class OperationDuplicateServerHl7OrgDstu2Test {
public static class PlainProvider {
@Operation(name = "$myoperation", idempotent = true)
public Parameters opInstanceReturnsBundleProvider(@OperationParam(name = "myparam") StringDt theString) {
public Parameters opInstanceReturnsBundleProvider(@OperationParam(name = "myparam") StringType theString) {
return null;
}