This commit is contained in:
James Agnew 2014-12-29 17:20:34 -05:00
parent 0e06e322c3
commit 0b44a32910
20 changed files with 111 additions and 38 deletions

View File

@ -28,9 +28,9 @@
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

BIN
hapi-fhir-base/.pom.xml.swp Normal file

Binary file not shown.

View File

@ -7,9 +7,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@ -97,4 +97,4 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.utility" version="1.0"/>
<installed facet="java" version="1.6"/>
<installed facet="java" version="1.8"/>
</faceted-project>

View File

@ -203,6 +203,11 @@
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-android</artifactId>
<version>${slf4j_version}</version>
</dependency>
</dependencies>
<build>
<plugins>
@ -225,10 +230,13 @@
<include>javax.json:javax.json-api</include>
-->
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
<include>org.glassfish:javax.json</include>
<include>org.codehaus.woodstox:woodstox-core-asl</include>
<include>javax.xml.stream:stax-api</include>
<include>org.codehaus.woodstox:stax2-api</include>
<include>org.slf4j:slf4j*</include>
<include>org.apache.commons:*</include>
</includes>
</artifactSet>
<relocations>

View File

@ -210,10 +210,21 @@ public class BundleEntry extends BaseBundle {
return myTitle;
}
/**
* @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata has been moved
* to the resource &lt;meta/&gt; element so it is redundant here). In preparation for DSTU2, it is recommended that you
* migrate code away from using this method and over to using resource metadata instead.
*/
public InstantDt getUpdated() {
if (myUpdated == null) {
myUpdated = new InstantDt();
}
if (myUpdated.isEmpty() && myResource != null) {
InstantDt resourceUpdated = ResourceMetadataKeyEnum.UPDATED.get(myResource);
if (resourceUpdated!=null && !resourceUpdated.isEmpty()) {
return resourceUpdated;
}
}
return myUpdated;
}
@ -279,6 +290,11 @@ public class BundleEntry extends BaseBundle {
myStatus = theStatus;
}
/**
* @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata has been moved
* to the resource &lt;meta/&gt; element so it is redundant here). In preparation for DSTU2, it is recommended that you
* migrate code away from using this method and over to using resource metadata instead.
*/
public void setUpdated(InstantDt theUpdated) {
Validate.notNull(theUpdated, "Updated may not be null");
myUpdated = theUpdated;

View File

@ -34,7 +34,9 @@ import java.util.Set;
import java.util.TreeSet;
import ca.uhn.fhir.rest.annotation.*;
import org.apache.commons.io.IOUtils;
import org.hl7.fhir.instance.model.IBaseResource;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
@ -435,7 +437,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
if (theReturnType == null) {
return false;
}
if (!IResource.class.isAssignableFrom(theReturnType)) {
if (!IBaseResource.class.isAssignableFrom(theReturnType)) {
return false;
}
return true;

View File

@ -34,6 +34,8 @@ import java.util.Set;
import javax.servlet.http.HttpServletResponse;
import org.hl7.fhir.instance.model.IBaseResource;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
@ -90,7 +92,7 @@ abstract class BaseResourceReturningMethodBinding extends BaseMethodBinding<Obje
}
myResourceListCollectionType = collectionType;
} else if (IResource.class.isAssignableFrom(methodReturnType)) {
} else if (IBaseResource.class.isAssignableFrom(methodReturnType)) {
myMethodReturnType = MethodReturnTypeEnum.RESOURCE;
} else if (Bundle.class.isAssignableFrom(methodReturnType)) {
myMethodReturnType = MethodReturnTypeEnum.BUNDLE;

View File

@ -42,7 +42,7 @@ public class ConformanceMethodBinding extends BaseResourceReturningMethodBinding
// if (Modifier.isAbstract(theMethod.getReturnType().getModifiers())) {
// throw new ConfigurationException("Conformance resource provider method '" + theMethod.getName() + "' must not be abstract");
// }
if (getMethodReturnType() != MethodReturnTypeEnum.RESOURCE || !BaseConformance.class.isAssignableFrom(theMethod.getReturnType())) {
if (getMethodReturnType() != MethodReturnTypeEnum.RESOURCE || !BaseConformance.class.isAssignableFrom((Class<?>) theMethod.getGenericReturnType())) {
throw new ConfigurationException("Conformance resource provider method '" + theMethod.getName() + "' should return a Conformance resource class, returns: " + theMethod.getReturnType());
}

View File

@ -222,7 +222,7 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
}
public static HttpGetClientInvocation createAbsoluteReadInvocation(IdDt theId) {
return new HttpGetClientInvocation(theId.getValue());
return new HttpGetClientInvocation(theId.toVersionless().getValue());
}
public static HttpGetClientInvocation createAbsoluteVReadInvocation(IdDt theId) {

View File

@ -41,6 +41,7 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.NotModifiedException;
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
import ca.uhn.fhir.util.ReflectionUtil;
import ca.uhn.fhir.util.VersionUtil;
import org.apache.commons.lang3.StringUtils;
@ -196,7 +197,7 @@ public class RestfulServer extends HttpServlet {
private int findResourceMethods(Object theProvider, Class<?> clazz) throws ConfigurationException {
int count = 0;
for (Method m : clazz.getDeclaredMethods()) {
for (Method m : ReflectionUtil.getDeclaredMethods(clazz)) {
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theProvider);
if (foundMethodBinding == null) {
continue;
@ -263,7 +264,7 @@ public class RestfulServer extends HttpServlet {
findSystemMethods(theSystemProvider, supertype);
}
for (Method m : clazz.getDeclaredMethods()) {
for (Method m : ReflectionUtil.getDeclaredMethods(clazz)) {
if (Modifier.isPublic(m.getModifiers())) {
ourLog.debug("Scanning public method: {}#{}", theSystemProvider.getClass(), m.getName());
@ -797,7 +798,7 @@ public class RestfulServer extends HttpServlet {
}
private void invokeDestroy(Object theProvider, Class<?> clazz) {
for (Method m : clazz.getDeclaredMethods()) {
for (Method m : ReflectionUtil.getDeclaredMethods(clazz)) {
Destroy destroy = m.getAnnotation(Destroy.class);
if (destroy != null) {
try {
@ -1392,7 +1393,7 @@ public class RestfulServer extends HttpServlet {
if (theServer.getETagSupport() == ETagSupportEnum.ENABLED) {
if (theResource.getId().hasVersionIdPart()) {
theHttpResponse.addHeader(Constants.HEADER_ETAG, '"' + theResource.getId().getVersionIdPart() + '"');
theHttpResponse.addHeader(Constants.HEADER_ETAG, "W/\"" + theResource.getId().getVersionIdPart() + '"');
}
}

View File

@ -26,6 +26,8 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.HashSet;
import java.util.LinkedHashSet;
public class ReflectionUtil {
@ -83,4 +85,19 @@ public class ReflectionUtil {
return type;
}
public static LinkedHashSet<Method> getDeclaredMethods(Class<?> theClazz) {
LinkedHashSet<Method> retVal = new LinkedHashSet<Method>();
for (Method next : theClazz.getDeclaredMethods()) {
try {
Method method = theClazz.getMethod(next.getName(), next.getParameterTypes());
retVal.add(method);
} catch (NoSuchMethodException e) {
retVal.add(next);
} catch (SecurityException e) {
retVal.add(next);
}
}
return retVal;
}
}

View File

@ -69,7 +69,7 @@ public class ETagServerTest {
Header cl = status.getFirstHeader(Constants.HEADER_ETAG_LC);
assertNotNull(cl);
assertEquals("\"222\"", cl.getValue());
assertEquals("W/\"222\"", cl.getValue());
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.utility" version="1.0"/>
<installed facet="java" version="1.6"/>
<installed facet="java" version="1.8"/>
</faceted-project>

View File

@ -97,6 +97,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
*
* See the class documentation for an important note if you are extending this class
*/
@Override
@Metadata
public Conformance getServerConformance(HttpServletRequest theRequest) {
if (myConformance != null && myCache) {

View File

@ -15,6 +15,7 @@ import com.google.common.reflect.ClassPath.ClassInfo;
public class ExceptionTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionTest.class);
@SuppressWarnings("deprecation")
@Test
public void testExceptionsAreGood() throws Exception {
ImmutableSet<ClassInfo> classes = ClassPath.from(Thread.currentThread().getContextClassLoader()).getTopLevelClasses(BaseServerResponseException.class.getPackage().getName());
@ -35,8 +36,12 @@ public class ExceptionTest {
if (next == UnclassifiedServerFailureException.class) {
continue;
}
if (next == ResourceVersionNotSpecifiedException.class) {
// This one is deprocated
continue;
}
assertTrue(BaseServerResponseException.isExceptionTypeRegistered(next));
assertTrue("Type " + next + " is not registered", BaseServerResponseException.isExceptionTypeRegistered(next));
if (next == AuthenticationException.class) {
continue;

View File

@ -45,6 +45,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.BundleEntry;
import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.Include;
@ -58,6 +59,7 @@ import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.DecimalDt;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.client.GenericClient;
import ca.uhn.fhir.rest.client.IClientInterceptor;
@ -343,7 +345,7 @@ public class Controller {
haveSearchParams = extractSearchParamsDstu1(conformance, resourceName, includes, sortParams, queries, haveSearchParams, queryIncludes);
break;
default:
throw new IllegalStateException("Unknown FHIR version: "+theRequest.getFhirVersion(myConfig));
throw new IllegalStateException("Unknown FHIR version: " + theRequest.getFhirVersion(myConfig));
}
theModel.put("includes", includes);
@ -366,7 +368,8 @@ public class Controller {
return "resource";
}
private boolean extractSearchParamsDstu1(IResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, List<List<String>> queryIncludes) {
private boolean extractSearchParamsDstu1(IResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams,
List<List<String>> queryIncludes) {
Conformance conformance = (Conformance) theConformance;
for (Rest nextRest : conformance.getRest()) {
for (RestResource nextRes : nextRest.getResource()) {
@ -414,8 +417,9 @@ public class Controller {
return haveSearchParams;
}
private boolean extractSearchParamsDev(IResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, List<List<String>> queryIncludes) {
ca.uhn.fhir.model.dev.resource.Conformance conformance = (ca.uhn.fhir.model.dev.resource.Conformance)theConformance;
private boolean extractSearchParamsDev(IResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams,
List<List<String>> queryIncludes) {
ca.uhn.fhir.model.dev.resource.Conformance conformance = (ca.uhn.fhir.model.dev.resource.Conformance) theConformance;
for (ca.uhn.fhir.model.dev.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dev.resource.Conformance.RestResource nextRes : nextRest.getResource()) {
if (nextRes.getTypeElement().getValue().equals(resourceName)) {
@ -456,7 +460,7 @@ public class Controller {
IQuery query;
if (isNotBlank(theReq.getParameter("resource"))) {
try {
query = search.forResource((Class<? extends IResource>)getResourceType(theRequest, theReq).getImplementingClass());
query = search.forResource((Class<? extends IResource>) getResourceType(theRequest, theReq).getImplementingClass());
} catch (ServletException e) {
theModel.put("errorMsg", e.toString());
return "resource";
@ -913,7 +917,7 @@ public class Controller {
private FhirContext getContext(HomeRequest theRequest) {
FhirVersionEnum version = theRequest.getFhirVersion(myConfig);
FhirContext retVal = myContexts.get(version);
if (retVal==null) {
if (retVal == null) {
retVal = new FhirContext(version);
myContexts.put(version, retVal);
}
@ -956,13 +960,13 @@ public class Controller {
}
List<String> values;
boolean addToWhere=true;
boolean addToWhere = true;
if ("token".equals(nextType)) {
if (isBlank(parts.get(2))) {
return true;
}
values = Collections.singletonList(StringUtils.join(parts, ""));
addToWhere=false;
addToWhere = false;
theQuery.where(new TokenClientParam(nextName + nextQualifier).exactly().systemAndCode(parts.get(0), parts.get(2)));
} else if ("date".equals(nextType)) {
values = new ArrayList<String>();
@ -991,13 +995,13 @@ public class Controller {
theClientCodeJsonWriter.write("value", nextValue);
theClientCodeJsonWriter.writeEnd();
if (addToWhere) {
theQuery.where(new StringClientParam(nextName + nextQualifier).matches().value(nextValue));
theQuery.where(new StringClientParam(nextName + nextQualifier).matches().value(nextValue));
}
}
if (StringUtils.isNotBlank(theReq.getParameter("param." + paramIdxString + ".0.name"))) {
handleSearchParam(paramIdxString + ".0", theReq, theQuery , theClientCodeJsonWriter);
handleSearchParam(paramIdxString + ".0", theReq, theQuery, theClientCodeJsonWriter);
}
return true;
@ -1010,7 +1014,7 @@ public class Controller {
case DSTU1:
return loadAndAddConfDstu1(theRequest, theModel);
}
throw new IllegalStateException("Unknown version: "+theRequest.getFhirVersion(myConfig));
throw new IllegalStateException("Unknown version: " + theRequest.getFhirVersion(myConfig));
}
private Conformance loadAndAddConfDstu1(final HomeRequest theRequest, final ModelMap theModel) {
@ -1018,7 +1022,7 @@ public class Controller {
Conformance conformance;
try {
conformance = (Conformance)client.conformance();
conformance = (Conformance) client.conformance();
} catch (Exception e) {
ourLog.warn("Failed to load conformance statement", e);
theModel.put("errorMsg", "Failed to load conformance statement, error was: " + e.toString());
@ -1077,7 +1081,7 @@ public class Controller {
ca.uhn.fhir.model.dev.resource.Conformance conformance;
try {
conformance = (ca.uhn.fhir.model.dev.resource.Conformance)client.conformance();
conformance = (ca.uhn.fhir.model.dev.resource.Conformance) client.conformance();
} catch (Exception e) {
ourLog.warn("Failed to load conformance statement", e);
theModel.put("errorMsg", "Failed to load conformance statement, error was: " + e.toString());
@ -1226,6 +1230,22 @@ public class Controller {
}
}
/*
* DSTU2 no longer has a title in the bundle format, but it's still
* useful here..
*/
if (bundle != null) {
INarrativeGenerator gen = getContext(theRequest).getNarrativeGenerator();
if (gen != null) {
for (BundleEntry next : bundle.getEntries()) {
if (next.getTitle().isEmpty() && next.getResource() != null) {
String title = gen.generateTitle(next.getResource());
next.getTitle().setValue(title);
}
}
}
}
resultDescription.append(" (").append(resultBody.length() + " bytes)");
Header[] requestHeaders = lastRequest != null ? applyHeaderFilters(lastRequest.getAllHeaders()) : new Header[0];

View File

@ -175,7 +175,7 @@
<table class="table table-condensed" style="padding-bottom: 0px; margin-bottom: 0px;">
<colgroup>
<col style="width: 100px;"/>
<col style="width: 100px;"/>
<col/>
<col/>
<col style="width: 100px;"/>
</colgroup>
@ -196,7 +196,7 @@
</th:block>
</td>
<td>
<small th:if="${entry.resource} != null" th:text="${entry.resource.id.toUnqualified()}"/>
<a th:if="${entry.resource} != null" th:href="${entry.resource.id}" th:text="${entry.resource.id.toUnqualified()}" style="font-size: 0.8em"/>
</td>
<td>
<small th:text="${entry.title}"/>

View File

@ -143,6 +143,7 @@ PRE.resultBodyPre {
border: none;
background-color: transparent;
overflow: visible;
/*white-space: normal;*/
}
/*

View File

@ -176,7 +176,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>