Improve test coverage and clean up UnclassifiedServerFailureException processing
This commit is contained in:
parent
785ce1deb9
commit
b3d8d453de
|
@ -1,45 +0,0 @@
|
||||||
package ca.uhn.fhir.model.api;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.util.CoverageIgnore;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR - Core Library
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 - 2016 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%
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a FHIR resource path specification, e.g.
|
|
||||||
* <code>Patient.gender.coding</code>
|
|
||||||
* <p>
|
|
||||||
* Note on equality: This class uses the {@link PathSpecification#setValue(String) value}
|
|
||||||
* as the single item used to provide {@link #hashCode()} and {@link #equals(Object)}.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @deprecated {@link Include} should be used instead
|
|
||||||
*/
|
|
||||||
@CoverageIgnore
|
|
||||||
@Deprecated
|
|
||||||
public class PathSpecification extends Include {
|
|
||||||
|
|
||||||
public PathSpecification(String theInclude) {
|
|
||||||
super(theInclude);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -52,6 +52,7 @@ public class TimeDt extends StringDt implements IQueryParameterType {
|
||||||
*/
|
*/
|
||||||
@SimpleSetter
|
@SimpleSetter
|
||||||
public TimeDt(@SimpleSetter.Parameter(name = "theString") String theValue) {
|
public TimeDt(@SimpleSetter.Parameter(name = "theString") String theValue) {
|
||||||
|
this();
|
||||||
setValue(theValue);
|
setValue(theValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
package ca.uhn.fhir.narrative;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR - Core Library
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 - 2016 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 org.thymeleaf.TemplateProcessingParameters;
|
|
||||||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
|
||||||
import org.thymeleaf.templateresolver.TemplateResolution;
|
|
||||||
|
|
||||||
public class ThymeleafResolver implements ITemplateResolver {
|
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ThymeleafResolver.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getOrder() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize() {
|
|
||||||
// nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TemplateResolution resolveTemplate(TemplateProcessingParameters theTemplateProcessingParameters) {
|
|
||||||
|
|
||||||
String templateName = theTemplateProcessingParameters.getTemplateName();
|
|
||||||
ourLog.info("Resolving template: {}", templateName);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -253,7 +253,7 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
||||||
boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theServer, theRequest);
|
boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theServer, theRequest);
|
||||||
Set<SummaryEnum> summaryMode = Collections.emptySet();
|
Set<SummaryEnum> summaryMode = Collections.emptySet();
|
||||||
|
|
||||||
return restfulResponse.streamResponseAsResource(outcome, prettyPrint, summaryMode, operationStatus, theRequest.isRespondGzip(), true);
|
return restfulResponse.streamResponseAsResource(outcome, prettyPrint, summaryMode, operationStatus, null, theRequest.isRespondGzip(), true);
|
||||||
// return theRequest.getResponse().returnResponse(ParseAction.create(outcome), operationStatus, allowPrefer, response, getResourceName());
|
// return theRequest.getResponse().returnResponse(ParseAction.create(outcome), operationStatus, allowPrefer, response, getResourceName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,8 +260,8 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
||||||
|
|
||||||
boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theServer, theRequest);
|
boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theServer, theRequest);
|
||||||
|
|
||||||
return theRequest.getResponse().streamResponseAsResource(responseObject.getResource(), prettyPrint, summaryMode, Constants.STATUS_HTTP_200_OK, theRequest.isRespondGzip(),
|
return theRequest.getResponse().streamResponseAsResource(responseObject.getResource(), prettyPrint, summaryMode, Constants.STATUS_HTTP_200_OK, null,
|
||||||
isAddContentLocationHeader());
|
theRequest.isRespondGzip(), isAddContentLocationHeader());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Is this request coming from a browser
|
// Is this request coming from a browser
|
||||||
|
|
|
@ -31,7 +31,6 @@ import java.util.TreeSet;
|
||||||
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.Include;
|
import ca.uhn.fhir.model.api.Include;
|
||||||
import ca.uhn.fhir.model.api.PathSpecification;
|
|
||||||
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
||||||
import ca.uhn.fhir.rest.param.BaseQueryParameter;
|
import ca.uhn.fhir.rest.param.BaseQueryParameter;
|
||||||
import ca.uhn.fhir.rest.server.Constants;
|
import ca.uhn.fhir.rest.server.Constants;
|
||||||
|
@ -60,7 +59,7 @@ class IncludeParameter extends BaseQueryParameter {
|
||||||
}
|
}
|
||||||
|
|
||||||
mySpecType = theSpecType;
|
mySpecType = theSpecType;
|
||||||
if (mySpecType != Include.class && mySpecType != PathSpecification.class && mySpecType != String.class) {
|
if (mySpecType != Include.class && mySpecType != String.class) {
|
||||||
throw new ConfigurationException("Invalid @" + IncludeParam.class.getSimpleName() + " parameter type: " + mySpecType);
|
throw new ConfigurationException("Invalid @" + IncludeParam.class.getSimpleName() + " parameter type: " + mySpecType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ class IncludeParameter extends BaseQueryParameter {
|
||||||
ArrayList<QualifiedParamList> retVal = new ArrayList<QualifiedParamList>();
|
ArrayList<QualifiedParamList> retVal = new ArrayList<QualifiedParamList>();
|
||||||
|
|
||||||
if (myInstantiableCollectionType == null) {
|
if (myInstantiableCollectionType == null) {
|
||||||
if (mySpecType == Include.class || mySpecType == PathSpecification.class) {
|
if (mySpecType == Include.class) {
|
||||||
convertAndAddIncludeToList(retVal, (Include) theObject);
|
convertAndAddIncludeToList(retVal, (Include) theObject);
|
||||||
} else {
|
} else {
|
||||||
retVal.add(QualifiedParamList.singleton(((String) theObject)));
|
retVal.add(QualifiedParamList.singleton(((String) theObject)));
|
||||||
|
|
|
@ -40,7 +40,6 @@ import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.Include;
|
import ca.uhn.fhir.model.api.Include;
|
||||||
import ca.uhn.fhir.model.api.PathSpecification;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||||
import ca.uhn.fhir.model.api.Tag;
|
import ca.uhn.fhir.model.api.Tag;
|
||||||
import ca.uhn.fhir.model.api.TagList;
|
import ca.uhn.fhir.model.api.TagList;
|
||||||
|
@ -442,7 +441,7 @@ public class MethodUtil {
|
||||||
if (parameterType == String.class) {
|
if (parameterType == String.class) {
|
||||||
instantiableCollectionType = null;
|
instantiableCollectionType = null;
|
||||||
specType = String.class;
|
specType = String.class;
|
||||||
} else if ((parameterType != Include.class && parameterType != PathSpecification.class) || innerCollectionType == null || outerCollectionType != null) {
|
} else if ((parameterType != Include.class) || innerCollectionType == null || outerCollectionType != null) {
|
||||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' is annotated with @" + IncludeParam.class.getSimpleName() + " but has a type other than Collection<" + Include.class.getSimpleName() + ">");
|
throw new ConfigurationException("Method '" + theMethod.getName() + "' is annotated with @" + IncludeParam.class.getSimpleName() + " but has a type other than Collection<" + Include.class.getSimpleName() + ">");
|
||||||
} else {
|
} else {
|
||||||
instantiableCollectionType = (Class<? extends Collection<Include>>) CollectionBinder.getInstantiableCollectionType(innerCollectionType, "Method '" + theMethod.getName() + "'");
|
instantiableCollectionType = (Class<? extends Collection<Include>>) CollectionBinder.getInstantiableCollectionType(innerCollectionType, "Method '" + theMethod.getName() + "'");
|
||||||
|
|
|
@ -59,7 +59,6 @@ import ca.uhn.fhir.rest.param.HasParam;
|
||||||
import ca.uhn.fhir.rest.param.NumberAndListParam;
|
import ca.uhn.fhir.rest.param.NumberAndListParam;
|
||||||
import ca.uhn.fhir.rest.param.NumberOrListParam;
|
import ca.uhn.fhir.rest.param.NumberOrListParam;
|
||||||
import ca.uhn.fhir.rest.param.NumberParam;
|
import ca.uhn.fhir.rest.param.NumberParam;
|
||||||
import ca.uhn.fhir.rest.param.QualifiedDateParam;
|
|
||||||
import ca.uhn.fhir.rest.param.QuantityAndListParam;
|
import ca.uhn.fhir.rest.param.QuantityAndListParam;
|
||||||
import ca.uhn.fhir.rest.param.QuantityOrListParam;
|
import ca.uhn.fhir.rest.param.QuantityOrListParam;
|
||||||
import ca.uhn.fhir.rest.param.QuantityParam;
|
import ca.uhn.fhir.rest.param.QuantityParam;
|
||||||
|
@ -81,7 +80,6 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.util.CollectionUtil;
|
import ca.uhn.fhir.util.CollectionUtil;
|
||||||
import ca.uhn.fhir.util.ReflectionUtil;
|
import ca.uhn.fhir.util.ReflectionUtil;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class SearchParameter extends BaseQueryParameter {
|
public class SearchParameter extends BaseQueryParameter {
|
||||||
|
|
||||||
private static final String EMPTY_STRING = "";
|
private static final String EMPTY_STRING = "";
|
||||||
|
@ -341,8 +339,6 @@ public class SearchParameter extends BaseQueryParameter {
|
||||||
// ok
|
// ok
|
||||||
} else if (StringDt.class.isAssignableFrom(type)) {
|
} else if (StringDt.class.isAssignableFrom(type)) {
|
||||||
myParamType = RestSearchParameterTypeEnum.STRING;
|
myParamType = RestSearchParameterTypeEnum.STRING;
|
||||||
} else if (QualifiedDateParam.class.isAssignableFrom(type)) {
|
|
||||||
myParamType = RestSearchParameterTypeEnum.DATE;
|
|
||||||
} else if (BaseIdentifierDt.class.isAssignableFrom(type)) {
|
} else if (BaseIdentifierDt.class.isAssignableFrom(type)) {
|
||||||
myParamType = RestSearchParameterTypeEnum.TOKEN;
|
myParamType = RestSearchParameterTypeEnum.TOKEN;
|
||||||
} else if (BaseQuantityDt.class.isAssignableFrom(type)) {
|
} else if (BaseQuantityDt.class.isAssignableFrom(type)) {
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
package ca.uhn.fhir.rest.param;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR - Core Library
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 - 2016 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.Date;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
|
||||||
import ca.uhn.fhir.util.CoverageIgnore;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link DateParam} instead (this class is identical, but was renamed to be less confusing)
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@CoverageIgnore
|
|
||||||
public class QualifiedDateParam extends DateParam {
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public QualifiedDateParam() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public QualifiedDateParam(QuantityCompararatorEnum theComparator, Date theDate) {
|
|
||||||
setComparator(theComparator);
|
|
||||||
setValue(theDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public QualifiedDateParam(QuantityCompararatorEnum theComparator, String theDate) {
|
|
||||||
setComparator(theComparator);
|
|
||||||
setValueAsString(theDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor which takes a complete [qualifier]{date} string.
|
|
||||||
*
|
|
||||||
* @param theString The string
|
|
||||||
*/
|
|
||||||
public QualifiedDateParam(String theString) {
|
|
||||||
setValueAsQueryToken(null, theString);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -38,7 +38,7 @@ import ca.uhn.fhir.rest.method.ParseAction;
|
||||||
|
|
||||||
public interface IRestfulResponse {
|
public interface IRestfulResponse {
|
||||||
|
|
||||||
Object streamResponseAsResource(IBaseResource theActualResourceToReturn, boolean prettyPrint, Set<SummaryEnum> summaryMode, int operationStatus, boolean respondGzip, boolean addContentLocationHeader) throws IOException;
|
Object streamResponseAsResource(IBaseResource theActualResourceToReturn, boolean thePrettyPrint, Set<SummaryEnum> theSummaryMode, int theStatusCode, String theStatusMessage, boolean theRespondGzip, boolean theAddContentLocation) throws IOException;
|
||||||
|
|
||||||
Object streamResponseAsBundle(Bundle bundle, Set<SummaryEnum> summaryMode, boolean respondGzip, boolean requestIsBrowser) throws IOException;
|
Object streamResponseAsBundle(Bundle bundle, Set<SummaryEnum> summaryMode, boolean respondGzip, boolean requestIsBrowser) throws IOException;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public interface IRestfulResponse {
|
||||||
*/
|
*/
|
||||||
Object returnResponse(ParseAction<?> outcome, int operationStatus, boolean allowPrefer, MethodOutcome response, String resourceName) throws IOException;
|
Object returnResponse(ParseAction<?> outcome, int operationStatus, boolean allowPrefer, MethodOutcome response, String resourceName) throws IOException;
|
||||||
|
|
||||||
Writer getResponseWriter(int statusCode, String contentType, String charset, boolean respondGzip) throws UnsupportedEncodingException, IOException;
|
Writer getResponseWriter(int theStatusCode, String theStatusMessage, String theContentType, String theCharset, boolean theRespondGzip) throws UnsupportedEncodingException, IOException;
|
||||||
|
|
||||||
Object sendWriterResponse(int status, String contentType, String charset, Writer writer) throws IOException;
|
Object sendWriterResponse(int status, String contentType, String charset, Writer writer) throws IOException;
|
||||||
|
|
||||||
|
|
|
@ -90,10 +90,10 @@ public abstract class RestfulResponse<T extends RequestDetails> implements IRest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Object streamResponseAsResource(IBaseResource resource, boolean prettyPrint, Set<SummaryEnum> summaryMode,
|
public final Object streamResponseAsResource(IBaseResource theResource, boolean thePrettyPrint, Set<SummaryEnum> theSummaryMode,
|
||||||
int statusCode, boolean respondGzip, boolean addContentLocationHeader)
|
int theStatusCode, String theStatusMessage, boolean theRespondGzip, boolean theAddContentLocation)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return RestfulServerUtils.streamResponseAsResource(theRequestDetails.getServer(), resource, summaryMode, statusCode, addContentLocationHeader, respondGzip, getRequestDetails(), myOperationResourceId, myOperationResourceLastUpdated);
|
return RestfulServerUtils.streamResponseAsResource(theRequestDetails.getServer(), theResource, theSummaryMode, theStatusCode, theStatusMessage, theAddContentLocation, theRespondGzip, getRequestDetails(), myOperationResourceId, myOperationResourceLastUpdated);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -537,7 +537,7 @@ public class RestfulServerUtils {
|
||||||
String contentType = responseEncoding.getBundleContentType();
|
String contentType = responseEncoding.getBundleContentType();
|
||||||
|
|
||||||
String charset = Constants.CHARSET_NAME_UTF8;
|
String charset = Constants.CHARSET_NAME_UTF8;
|
||||||
Writer writer = theRequestDetails.getResponse().getResponseWriter(status, contentType, charset, respondGzip);
|
Writer writer = theRequestDetails.getResponse().getResponseWriter(status, null, contentType, charset, respondGzip);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IParser parser = RestfulServerUtils.getNewParser(theServer.getFhirContext(), theRequestDetails);
|
IParser parser = RestfulServerUtils.getNewParser(theServer.getFhirContext(), theRequestDetails);
|
||||||
|
@ -552,11 +552,11 @@ public class RestfulServerUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object streamResponseAsResource(IRestfulServerDefaults theServer, IBaseResource theResource, Set<SummaryEnum> theSummaryMode, int stausCode, boolean theAddContentLocationHeader, boolean respondGzip, RequestDetails theRequestDetails) throws IOException {
|
public static Object streamResponseAsResource(IRestfulServerDefaults theServer, IBaseResource theResource, Set<SummaryEnum> theSummaryMode, int stausCode, boolean theAddContentLocationHeader, boolean respondGzip, RequestDetails theRequestDetails) throws IOException {
|
||||||
return streamResponseAsResource(theServer, theResource, theSummaryMode, stausCode, theAddContentLocationHeader, respondGzip, theRequestDetails, null, null);
|
return streamResponseAsResource(theServer, theResource, theSummaryMode, stausCode, null, theAddContentLocationHeader, respondGzip, theRequestDetails, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Object streamResponseAsResource(IRestfulServerDefaults theServer, IBaseResource theResource, Set<SummaryEnum> theSummaryMode, int stausCode, boolean theAddContentLocationHeader, boolean respondGzip, RequestDetails theRequestDetails, IIdType theOperationResourceId, IPrimitiveType<Date> theOperationResourceLastUpdated) throws IOException {
|
public static Object streamResponseAsResource(IRestfulServerDefaults theServer, IBaseResource theResource, Set<SummaryEnum> theSummaryMode, int theStausCode, String theStatusMessage, boolean theAddContentLocationHeader, boolean respondGzip, RequestDetails theRequestDetails, IIdType theOperationResourceId, IPrimitiveType<Date> theOperationResourceLastUpdated) throws IOException {
|
||||||
IRestfulResponse restUtil = theRequestDetails.getResponse();
|
IRestfulResponse restUtil = theRequestDetails.getResponse();
|
||||||
|
|
||||||
// Determine response encoding
|
// Determine response encoding
|
||||||
|
@ -596,7 +596,7 @@ public class RestfulServerUtils {
|
||||||
// malicious images or HTML blocks being served up as content.
|
// malicious images or HTML blocks being served up as content.
|
||||||
restUtil.addHeader(Constants.HEADER_CONTENT_DISPOSITION, "Attachment;");
|
restUtil.addHeader(Constants.HEADER_CONTENT_DISPOSITION, "Attachment;");
|
||||||
|
|
||||||
return restUtil.sendAttachmentResponse(bin, stausCode, contentType);
|
return restUtil.sendAttachmentResponse(bin, theStausCode, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, we're not serving a binary resource, so apply default encoding
|
// Ok, we're not serving a binary resource, so apply default encoding
|
||||||
|
@ -656,7 +656,7 @@ public class RestfulServerUtils {
|
||||||
}
|
}
|
||||||
String charset = Constants.CHARSET_NAME_UTF8;
|
String charset = Constants.CHARSET_NAME_UTF8;
|
||||||
|
|
||||||
Writer writer = restUtil.getResponseWriter(stausCode, contentType, charset, respondGzip);
|
Writer writer = restUtil.getResponseWriter(theStausCode, theStatusMessage, contentType, charset, respondGzip);
|
||||||
if (theResource == null) {
|
if (theResource == null) {
|
||||||
// No response is being returned
|
// No response is being returned
|
||||||
} else if (encodingDomainResourceAsText && theResource instanceof IResource) {
|
} else if (encodingDomainResourceAsText && theResource instanceof IResource) {
|
||||||
|
@ -666,7 +666,7 @@ public class RestfulServerUtils {
|
||||||
parser.encodeResourceToWriter(theResource, writer);
|
parser.encodeResourceToWriter(theResource, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return restUtil.sendWriterResponse(stausCode, contentType, charset, writer);
|
return restUtil.sendWriterResponse(theStausCode, contentType, charset, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IIdType fullyQualifyResourceIdOrReturnNull(IRestfulServerDefaults theServer, IBaseResource theResource, String theServerBase, IIdType theResourceId) {
|
public static IIdType fullyQualifyResourceIdOrReturnNull(IRestfulServerDefaults theServer, IBaseResource theResource, String theServerBase, IIdType theResourceId) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ import ca.uhn.fhir.rest.method.RequestDetails;
|
||||||
import ca.uhn.fhir.rest.server.IRestfulResponse;
|
import ca.uhn.fhir.rest.server.IRestfulResponse;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
|
import ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException;
|
||||||
import ca.uhn.fhir.util.OperationOutcomeUtil;
|
import ca.uhn.fhir.util.OperationOutcomeUtil;
|
||||||
|
|
||||||
public class ExceptionHandlingInterceptor extends InterceptorAdapter {
|
public class ExceptionHandlingInterceptor extends InterceptorAdapter {
|
||||||
|
@ -79,7 +80,15 @@ public class ExceptionHandlingInterceptor extends InterceptorAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.streamResponseAsResource(oo, true, Collections.singleton(SummaryEnum.FALSE), statusCode, false, false);
|
String statusMessage = null;
|
||||||
|
if (theException instanceof UnclassifiedServerFailureException) {
|
||||||
|
String sm = theException.getMessage();
|
||||||
|
if (isNotBlank(sm) && sm.indexOf('\n') == -1) {
|
||||||
|
statusMessage = sm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.streamResponseAsResource(oo, true, Collections.singleton(SummaryEnum.FALSE), statusCode, statusMessage, false, false);
|
||||||
// theResponse.setStatus(statusCode);
|
// theResponse.setStatus(statusCode);
|
||||||
// theRequestDetails.getServer().addHeadersToResponse(theResponse);
|
// theRequestDetails.getServer().addHeadersToResponse(theResponse);
|
||||||
// theResponse.setContentType("text/plain");
|
// theResponse.setContentType("text/plain");
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package ca.uhn.fhir.rest.server.servlet;
|
package ca.uhn.fhir.rest.server.servlet;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* HAPI FHIR - Core Library
|
* HAPI FHIR - Core Library
|
||||||
|
@ -61,12 +63,12 @@ public class ServletRestfulResponse extends RestfulResponse<ServletRequestDetail
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Writer getResponseWriter(int statusCode, String contentType, String charset, boolean theRespondGzip) throws UnsupportedEncodingException, IOException {
|
public Writer getResponseWriter(int theStatusCode, String theStatusMessage, String theContentType, String theCharset, boolean theRespondGzip) throws UnsupportedEncodingException, IOException {
|
||||||
addHeaders();
|
addHeaders();
|
||||||
HttpServletResponse theHttpResponse = getRequestDetails().getServletResponse();
|
HttpServletResponse theHttpResponse = getRequestDetails().getServletResponse();
|
||||||
theHttpResponse.setCharacterEncoding(charset);
|
theHttpResponse.setCharacterEncoding(theCharset);
|
||||||
theHttpResponse.setStatus(statusCode);
|
theHttpResponse.setStatus(theStatusCode);
|
||||||
theHttpResponse.setContentType(contentType);
|
theHttpResponse.setContentType(theContentType);
|
||||||
if (theRespondGzip) {
|
if (theRespondGzip) {
|
||||||
theHttpResponse.addHeader(Constants.HEADER_CONTENT_ENCODING, Constants.ENCODING_GZIP);
|
theHttpResponse.addHeader(Constants.HEADER_CONTENT_ENCODING, Constants.ENCODING_GZIP);
|
||||||
return new OutputStreamWriter(new GZIPOutputStream(theHttpResponse.getOutputStream()), Constants.CHARSET_NAME_UTF8);
|
return new OutputStreamWriter(new GZIPOutputStream(theHttpResponse.getOutputStream()), Constants.CHARSET_NAME_UTF8);
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package ca.uhn.fhir.validation;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR - Core Library
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 - 2016 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 class Problem {
|
|
||||||
|
|
||||||
private String myDescription;
|
|
||||||
|
|
||||||
public Problem(String theDescription) {
|
|
||||||
myDescription=theDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return myDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -194,7 +194,7 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
||||||
|
|
||||||
if (conformance != null) {
|
if (conformance != null) {
|
||||||
Set<SummaryEnum> summaryMode = Collections.emptySet();
|
Set<SummaryEnum> summaryMode = Collections.emptySet();
|
||||||
return (Response) response.streamResponseAsResource(conformance, false, summaryMode, Constants.STATUS_HTTP_200_OK, true, false);
|
return (Response) response.streamResponseAsResource(conformance, false, summaryMode, Constants.STATUS_HTTP_200_OK, null, true, false);
|
||||||
}
|
}
|
||||||
return (Response) response.returnResponse(null, Constants.STATUS_HTTP_500_INTERNAL_ERROR, true, null, getResourceType().getSimpleName());
|
return (Response) response.returnResponse(null, Constants.STATUS_HTTP_500_INTERNAL_ERROR, true, null, getResourceType().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class JaxRsResponse extends RestfulResponse<JaxRsRequest> {
|
||||||
* by the server.
|
* by the server.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Writer getResponseWriter(int statusCode, String contentType, String charset, boolean respondGzip)
|
public Writer getResponseWriter(int theStatusCode, String theStatusMessage, String theContentType, String theCharset, boolean theRespondGzip)
|
||||||
throws UnsupportedEncodingException, IOException {
|
throws UnsupportedEncodingException, IOException {
|
||||||
return new StringWriter();
|
return new StringWriter();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.provider;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR JPA Server
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 - 2016 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 ca.uhn.fhir.model.dstu2.resource.QuestionnaireResponse;
|
|
||||||
|
|
||||||
public class BaseJpaResourceProviderQuestionnaireResponseDstu2 extends JpaResourceProviderDstu2<QuestionnaireResponse> {
|
|
||||||
|
|
||||||
// nothing yet
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.util;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR JPA Server
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 - 2016 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 org.hibernate.cfg.ImprovedNamingStrategy;
|
|
||||||
|
|
||||||
public class CustomNamingStrategy extends ImprovedNamingStrategy {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final String PREFIX = "FR_";
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public String classToTableName(final String className) {
|
|
||||||
// return this.addPrefix(super.classToTableName(className));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String collectionTableName(final String ownerEntity,
|
|
||||||
// final String ownerEntityTable, final String associatedEntity,
|
|
||||||
// final String associatedEntityTable, final String propertyName) {
|
|
||||||
// return this.addPrefix(super.collectionTableName(ownerEntity,
|
|
||||||
// ownerEntityTable, associatedEntity, associatedEntityTable,
|
|
||||||
// propertyName));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String foreignKeyColumnName(String thePropertyName, String thePropertyEntityName, String thePropertyTableName, String theReferencedColumnName) {
|
|
||||||
// String foreignKeyColumnName = super.foreignKeyColumnName(thePropertyName, thePropertyEntityName, thePropertyTableName, theReferencedColumnName);
|
|
||||||
// return foreignKeyColumnName;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String logicalCollectionTableName(final String tableName,
|
|
||||||
// final String ownerEntityTable, final String associatedEntityTable,
|
|
||||||
// final String propertyName) {
|
|
||||||
// return this.addPrefix(super.logicalCollectionTableName(tableName,
|
|
||||||
// ownerEntityTable, associatedEntityTable, propertyName));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private String addPrefix(final String composedTableName) {
|
|
||||||
//
|
|
||||||
// return PREFIX
|
|
||||||
// + composedTableName.toUpperCase().replace("_", "");
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.util;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR JPA Server
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 - 2016 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 org.hibernate.dialect.DerbyTenSevenDialect;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* As of Hibernate 5.0.1, DerbyTenSevenDialect doesn't seem to work when updating
|
|
||||||
* the schema, as it tries to create a duplicate schema
|
|
||||||
*/
|
|
||||||
public class HapiDerbyTenSevenDialect extends DerbyTenSevenDialect {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getQuerySequencesString() {
|
|
||||||
return "select SEQUENCENAME from sys.syssequences";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -44,6 +44,7 @@ import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||||
import ca.uhn.fhir.model.dstu.resource.AllergyIntolerance;
|
import ca.uhn.fhir.model.dstu.resource.AllergyIntolerance;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Binary;
|
import ca.uhn.fhir.model.dstu.resource.Binary;
|
||||||
|
import ca.uhn.fhir.model.dstu.resource.CarePlan;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Composition;
|
import ca.uhn.fhir.model.dstu.resource.Composition;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Condition;
|
import ca.uhn.fhir.model.dstu.resource.Condition;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Conformance;
|
import ca.uhn.fhir.model.dstu.resource.Conformance;
|
||||||
|
@ -67,6 +68,7 @@ import ca.uhn.fhir.model.primitive.DateDt;
|
||||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
|
import ca.uhn.fhir.model.primitive.IdrefDt;
|
||||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||||
|
@ -95,6 +97,21 @@ public class XmlParserTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEncodeAndParseIdref() {
|
||||||
|
CarePlan cp = new CarePlan();
|
||||||
|
cp.addGoal().setNotes("Goal Notes").setElementSpecificId("goalId0");
|
||||||
|
|
||||||
|
IdrefDt idref = new IdrefDt();
|
||||||
|
idref.setValue("#goalId0");
|
||||||
|
idref.setTarget(cp);
|
||||||
|
idref.getTarget();
|
||||||
|
cp.addActivity().getGoal().add(idref);
|
||||||
|
|
||||||
|
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(cp);
|
||||||
|
ourLog.info(encoded);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for #82 - Not yet enabled because the test won't pass
|
* Test for #82 - Not yet enabled because the test won't pass
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,7 +32,7 @@ import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerExcept
|
||||||
import ca.uhn.fhir.rest.server.Constants;
|
import ca.uhn.fhir.rest.server.Constants;
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
public class ClientServerValidationTestDstu {
|
public class ClientServerValidationDstu1Test {
|
||||||
|
|
||||||
private FhirContext myCtx;
|
private FhirContext myCtx;
|
||||||
private HttpClient myHttpClient;
|
private HttpClient myHttpClient;
|
|
@ -24,6 +24,9 @@ public class ExceptionPropertiesTest {
|
||||||
new FhirClientConnectionException(new Exception());
|
new FhirClientConnectionException(new Exception());
|
||||||
new NotImplementedOperationException("");
|
new NotImplementedOperationException("");
|
||||||
new NotImplementedOperationException(null, new OperationOutcome());
|
new NotImplementedOperationException(null, new OperationOutcome());
|
||||||
|
new FhirClientConnectionException("");
|
||||||
|
new FhirClientConnectionException(new Exception());
|
||||||
|
new FhirClientConnectionException("", new Exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package ca.uhn.fhir.model.primitive;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class TimeDtTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEncode() {
|
||||||
|
TimeDt dt = new TimeDt("11:33:01.123");
|
||||||
|
assertEquals("11:33:01.123", dt.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -37,9 +37,9 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
|
public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultThymeleafNarrativeGeneratorTestDstu2.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultThymeleafNarrativeGeneratorDstu2Test.class);
|
||||||
private DefaultThymeleafNarrativeGenerator myGen;
|
private DefaultThymeleafNarrativeGenerator myGen;
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
|
@ -1,7 +1,12 @@
|
||||||
package ca.uhn.fhir.rest.client;
|
package ca.uhn.fhir.rest.client;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
@ -32,16 +37,15 @@ import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||||
import ca.uhn.fhir.model.primitive.UriDt;
|
import ca.uhn.fhir.model.primitive.UriDt;
|
||||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
|
||||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerException;
|
import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerException;
|
||||||
import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
|
import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
|
||||||
import ca.uhn.fhir.rest.server.Constants;
|
import ca.uhn.fhir.rest.server.Constants;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
public class ClientServerValidationTestDstu2 {
|
public class ClientServerValidationDstu2Test {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ClientServerValidationTestDstu2.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ClientServerValidationDstu2Test.class);
|
||||||
private FhirContext myCtx;
|
private FhirContext myCtx;
|
||||||
private boolean myFirstResponse;
|
private boolean myFirstResponse;
|
||||||
private HttpClient myHttpClient;
|
private HttpClient myHttpClient;
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,6 @@
|
||||||
package ca.uhn.fhir.rest.server;
|
package ca.uhn.fhir.rest.server;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -26,13 +24,10 @@ import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.rest.annotation.Count;
|
|
||||||
import ca.uhn.fhir.rest.annotation.OptionalParam;
|
|
||||||
import ca.uhn.fhir.rest.annotation.Search;
|
import ca.uhn.fhir.rest.annotation.Search;
|
||||||
import ca.uhn.fhir.rest.annotation.Sort;
|
import ca.uhn.fhir.rest.annotation.Sort;
|
||||||
import ca.uhn.fhir.rest.api.SortOrderEnum;
|
import ca.uhn.fhir.rest.api.SortOrderEnum;
|
||||||
import ca.uhn.fhir.rest.api.SortSpec;
|
import ca.uhn.fhir.rest.api.SortSpec;
|
||||||
import ca.uhn.fhir.rest.param.TokenParam;
|
|
||||||
import ca.uhn.fhir.util.PortUtil;
|
import ca.uhn.fhir.util.PortUtil;
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
package ca.uhn.fhir.rest.server;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||||
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.servlet.ServletHandler;
|
||||||
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
|
import org.hl7.fhir.dstu3.model.OperationOutcome;
|
||||||
|
import org.hl7.fhir.dstu3.model.OperationOutcome.IssueType;
|
||||||
|
import org.hl7.fhir.dstu3.model.Patient;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.rest.annotation.Search;
|
||||||
|
import ca.uhn.fhir.rest.api.SortSpec;
|
||||||
|
import ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException;
|
||||||
|
import ca.uhn.fhir.util.PortUtil;
|
||||||
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
|
public class UnclassifiedServerExceptionDstu3Test {
|
||||||
|
|
||||||
|
private static CloseableHttpClient ourClient;
|
||||||
|
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||||
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(UnclassifiedServerExceptionDstu3Test.class);
|
||||||
|
private static int ourPort;
|
||||||
|
private static Server ourServer;
|
||||||
|
public static UnclassifiedServerFailureException ourException;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearch() throws Exception {
|
||||||
|
|
||||||
|
OperationOutcome operationOutcome = new OperationOutcome();
|
||||||
|
operationOutcome.addIssue().setCode(IssueType.BUSINESSRULE);
|
||||||
|
ourException = new UnclassifiedServerFailureException(477, "SOME MESSAGE", operationOutcome);
|
||||||
|
|
||||||
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient");
|
||||||
|
CloseableHttpResponse status = ourClient.execute(httpGet);
|
||||||
|
try {
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
ourLog.info(status.getStatusLine().toString());
|
||||||
|
ourLog.info(responseContent);
|
||||||
|
assertEquals(477, status.getStatusLine().getStatusCode());
|
||||||
|
//assertEquals("SOME MESSAGE", status.getStatusLine().getReasonPhrase());
|
||||||
|
assertThat(responseContent, stringContainsInOrder("business-rule"));
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void afterClassClearContext() throws Exception {
|
||||||
|
ourServer.stop();
|
||||||
|
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void beforeClass() throws Exception {
|
||||||
|
ourPort = PortUtil.findFreePort();
|
||||||
|
ourServer = new Server(ourPort);
|
||||||
|
|
||||||
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
|
servlet.setPagingProvider(new FifoMemoryPagingProvider(10));
|
||||||
|
|
||||||
|
servlet.setResourceProviders(patientProvider);
|
||||||
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
ourServer.setHandler(proxyHandler);
|
||||||
|
ourServer.start();
|
||||||
|
|
||||||
|
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
|
||||||
|
HttpClientBuilder builder = HttpClientBuilder.create();
|
||||||
|
builder.setConnectionManager(connectionManager);
|
||||||
|
ourClient = builder.build();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DummyPatientResourceProvider implements IResourceProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends IBaseResource> getResourceType() {
|
||||||
|
return Patient.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Search()
|
||||||
|
public List<Patient> search() {
|
||||||
|
throw ourException;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,23 +1,20 @@
|
||||||
package ca.uhn.fhir.validation;
|
package ca.uhn.fhir.validation;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.hl7.fhir.dstu3.model.Patient;
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
public class SchemaValidationTestDstu3 {
|
public class SchemaValidationDstu3Test {
|
||||||
|
|
||||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SchemaValidationTestDstu3.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SchemaValidationDstu3Test.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #339
|
* See #339
|
|
@ -41,6 +41,16 @@
|
||||||
</ul>
|
</ul>
|
||||||
]]>
|
]]>
|
||||||
</action>
|
</action>
|
||||||
|
<action type="remove">
|
||||||
|
Remove some clases that were deprecated over a year ago and have
|
||||||
|
suitable replacements:
|
||||||
|
<![CDATA[
|
||||||
|
<ul>
|
||||||
|
<li>QualifiedDateParam has been removed, but DateParam may be used instead</li>
|
||||||
|
<li>PathSpecification has been removedm but Include may be used instead</li>
|
||||||
|
</ul>
|
||||||
|
]]>
|
||||||
|
</action>
|
||||||
<action type="fix" issue="345">
|
<action type="fix" issue="345">
|
||||||
ResponseValidatingInterceptor threw an InternalErrorException (HTTP 500) for operations
|
ResponseValidatingInterceptor threw an InternalErrorException (HTTP 500) for operations
|
||||||
that do not return any content (e.g. delete). Thanks to Mohammad Jafari for reporting!
|
that do not return any content (e.g. delete). Thanks to Mohammad Jafari for reporting!
|
||||||
|
@ -359,6 +369,14 @@
|
||||||
Server now supports the _at parameter (including multiple repetitions)
|
Server now supports the _at parameter (including multiple repetitions)
|
||||||
for history operation
|
for history operation
|
||||||
</action>
|
</action>
|
||||||
|
<!--
|
||||||
|
This one actually doesn't seem possible without using a deprecated servlet API
|
||||||
|
<action type="fix">
|
||||||
|
When throwing UnclassifiedServerException in server methods, the HTTP response
|
||||||
|
status line contained the response code specified in the exception, but not the
|
||||||
|
response message
|
||||||
|
</action>
|
||||||
|
-->
|
||||||
</release>
|
</release>
|
||||||
<release version="1.5" date="2016-04-20">
|
<release version="1.5" date="2016-04-20">
|
||||||
<action type="fix" issue="339">
|
<action type="fix" issue="339">
|
||||||
|
|
Loading…
Reference in New Issue