diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirVersionEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirVersionEnum.java
index dc55bd682e6..0884df8e653 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirVersionEnum.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirVersionEnum.java
@@ -181,7 +181,7 @@ public enum FhirVersionEnum {
private String myVersion;
- public Dstu3Version() {
+ Dstu3Version() {
try {
Class> c = Class.forName("org.hl7.fhir.dstu3.model.Constants");
myVersion = (String) c.getDeclaredField("VERSION").get(null);
@@ -201,7 +201,7 @@ public enum FhirVersionEnum {
private String myVersion;
- public R4Version() {
+ R4Version() {
try {
Class> c = Class.forName("org.hl7.fhir.r4.model.Constants");
myVersion = (String) c.getDeclaredField("VERSION").get(null);
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/IParserErrorHandler.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/IParserErrorHandler.java
index 485311e5736..f7562c95b92 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/IParserErrorHandler.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/IParserErrorHandler.java
@@ -55,7 +55,7 @@ public interface IParserErrorHandler {
void incorrectJsonType(IParseLocation theLocation, String theElementName, ValueType theExpectedValueType, ScalarType theExpectedScalarType, ValueType theFoundValueType, ScalarType theFoundScalarType);
/**
- * The parser detected an atttribute value that was invalid (such as: empty "" values are not permitted)
+ * The parser detected an attribute value that was invalid (such as: empty "" values are not permitted)
*
* @param theLocation
* The location in the document. Note that this may be null
as the ParseLocation feature is experimental. Use with caution, as the API may change.
@@ -70,7 +70,7 @@ public interface IParserErrorHandler {
*
* @param theLocation
* The location in the document. Note that this may be null
as the ParseLocation feature is experimental. Use with caution, as the API may change.
- * @param theReference The actual invalid reference (e.g. "#3")
+ * @param theElementName The missing element name
* @since 2.1
*/
void missingRequiredElement(IParseLocation theLocation, String theElementName);
@@ -123,7 +123,7 @@ public interface IParserErrorHandler {
* type which will currently always be set to null. This interface is included here so that
* locations can be added to the API in a future release without changing the API.
*/
- public interface IParseLocation {
+ interface IParseLocation {
/**
* Returns the name of the parent element (the element containing the element currently being parsed)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java
index b8fff2e30d4..d56aff6e5d2 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java
@@ -1033,7 +1033,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
} else {
parentElementName = "extension";
}
- getErrorHandler().missingRequiredElement(new ParseLocation(parentElementName), "url");
+ getErrorHandler().missingRequiredElement(new ParseLocation().setParentElementName(parentElementName), "url");
url = null;
} else {
url = getExtensionUrl(jsonElement.getAsString());
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParseLocation.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParseLocation.java
index 8df9a37aa96..2c0dc4eec4f 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParseLocation.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParseLocation.java
@@ -29,9 +29,8 @@ class ParseLocation implements IParseLocation {
/**
* Constructor
*/
- public ParseLocation(String theParentElementName) {
+ public ParseLocation() {
super();
- myParentElementName = theParentElementName;
}
@Override
@@ -39,4 +38,9 @@ class ParseLocation implements IParseLocation {
return myParentElementName;
}
+ public ParseLocation setParentElementName(String theParentElementName) {
+ myParentElementName = theParentElementName;
+ return this;
+ }
+
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java
index b4c6d6db00f..6f4c5d02ad6 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java
@@ -806,7 +806,7 @@ class ParserState {
@SuppressWarnings("unchecked")
List securityLabels = (List) myMap.get(ResourceMetadataKeyEnum.SECURITY_LABELS);
if (securityLabels == null) {
- securityLabels = new ArrayList();
+ securityLabels = new ArrayList<>();
myMap.put(ResourceMetadataKeyEnum.SECURITY_LABELS, securityLabels);
}
IBase securityLabel = myContext.getVersion().newCodingDt();
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
index ea266d7a13a..c1fcfa07577 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
@@ -139,7 +139,7 @@ public class XmlParser extends BaseParser /* implements IParser */ {
Attribute urlAttr = elem.getAttributeByName(new QName("url"));
String url;
if (urlAttr == null || isBlank(urlAttr.getValue())) {
- getErrorHandler().missingRequiredElement(new ParseLocation("extension"), "url");
+ getErrorHandler().missingRequiredElement(new ParseLocation().setParentElementName("extension"), "url");
url = null;
} else {
url = urlAttr.getValue();
@@ -149,7 +149,7 @@ public class XmlParser extends BaseParser /* implements IParser */ {
Attribute urlAttr = elem.getAttributeByName(new QName("url"));
String url;
if (urlAttr == null || isBlank(urlAttr.getValue())) {
- getErrorHandler().missingRequiredElement(new ParseLocation("modifierExtension"), "url");
+ getErrorHandler().missingRequiredElement(new ParseLocation().setParentElementName("modifierExtension"), "url");
url = null;
} else {
url = urlAttr.getValue();
diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java
index 5025b098918..f57946927a1 100644
--- a/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java
+++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java
@@ -7,6 +7,7 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
import ca.uhn.fhir.model.dstu2.resource.StructureDefinition;
import ca.uhn.fhir.model.dstu2.resource.ValueSet;
import ca.uhn.fhir.rest.client.api.IGenericClient;
+import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@@ -163,7 +164,7 @@ public class ValidationDataUploader extends BaseCommand {
ValueSet next = (ValueSet) i.getResource();
next.setId(next.getIdElement().toUnqualifiedVersionless());
- ourLog.info("Uploading ValueSet {}/{} : {}", new Object[]{count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()});
client.update().resource(next).execute();
count++;
@@ -182,7 +183,7 @@ public class ValidationDataUploader extends BaseCommand {
ValueSet next = (ValueSet) i.getResource();
next.setId(next.getIdElement().toUnqualifiedVersionless());
- ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[]{count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()});
client.update().resource(next).execute();
count++;
@@ -200,7 +201,7 @@ public class ValidationDataUploader extends BaseCommand {
ValueSet next = (ValueSet) i.getResource();
next.setId(next.getIdElement().toUnqualifiedVersionless());
- ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[]{count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()});
client.update().resource(next).execute();
count++;
}
@@ -225,7 +226,7 @@ public class ValidationDataUploader extends BaseCommand {
}
next.setId(next.getIdElement().toUnqualifiedVersionless());
- ourLog.info("Uploading StructureDefinition {}/{} : {}", new Object[]{count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading StructureDefinition {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()});
try {
client.update().resource(next).execute();
} catch (Exception e) {
@@ -268,12 +269,14 @@ public class ValidationDataUploader extends BaseCommand {
int bytes = ctx.newXmlParser().encodeResourceToString(next).length();
- ourLog.info("Uploading ValueSet {}/{} : {} ({} bytes}", new Object[]{count, total, next.getIdElement().getValue(), bytes});
+ ourLog.info("Uploading ValueSet {}/{} : {} ({} bytes}", new Object[] {count, total, next.getIdElement().getValue(), bytes});
try {
IIdType id = client.update().resource(next).execute().getId();
ourLog.info(" - Got ID: {}", id.getValue());
} catch (UnprocessableEntityException e) {
ourLog.warn("UnprocessableEntityException: " + e.toString());
+ } catch (BaseServerResponseException e) {
+ ourLog.warn("Server responded HTTP " + e.getStatusCode() + ": " + e.toString());
}
count++;
}
@@ -293,7 +296,7 @@ public class ValidationDataUploader extends BaseCommand {
org.hl7.fhir.dstu3.model.Resource next = i.getResource();
next.setId(next.getIdElement().toUnqualifiedVersionless());
- ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[]{count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()});
try {
client.update().resource(next).execute();
} catch (Exception e) {
@@ -318,7 +321,7 @@ public class ValidationDataUploader extends BaseCommand {
}
next.setId(next.getIdElement().toUnqualifiedVersionless());
- ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[]{count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()});
client.update().resource(next).execute();
count++;
}
@@ -364,7 +367,7 @@ public class ValidationDataUploader extends BaseCommand {
int bytes = theCtx.newXmlParser().encodeResourceToString(next).length();
- ourLog.info("Uploading ValueSet {}/{} : {} ({} bytes}", new Object[]{count, total, next.getIdElement().getValue(), bytes});
+ ourLog.info("Uploading ValueSet {}/{} : {} ({} bytes}", new Object[] {count, total, next.getIdElement().getValue(), bytes});
try {
IIdType id = client.update().resource(next).execute().getId();
ourLog.info(" - Got ID: {}", id.getValue());
@@ -388,7 +391,7 @@ public class ValidationDataUploader extends BaseCommand {
org.hl7.fhir.r4.model.Resource next = i.getResource();
next.setId(next.getIdElement().toUnqualifiedVersionless());
- ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[]{count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()});
client.update().resource(next).execute();
count++;
@@ -410,7 +413,7 @@ public class ValidationDataUploader extends BaseCommand {
}
next.setId(next.getIdElement().toUnqualifiedVersionless());
- ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[]{count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()});
client.update().resource(next).execute();
count++;
}
@@ -470,7 +473,7 @@ public class ValidationDataUploader extends BaseCommand {
continue;
}
- ourLog.info("Uploading {} StructureDefinition {}/{} : {}", new Object[]{name, count, total, next.getIdElement().getValue()});
+ ourLog.info("Uploading {} StructureDefinition {}/{} : {}", new Object[] {name, count, total, next.getIdElement().getValue()});
client.update().resource(next).execute();
count++;
@@ -518,8 +521,12 @@ public class ValidationDataUploader extends BaseCommand {
continue;
}
- ourLog.info("Uploading {} StructureDefinition {}/{} : {}", new Object[]{name, count, total, next.getIdElement().getValue()});
- client.update().resource(next).execute();
+ ourLog.info("Uploading {} StructureDefinition {}/{} : {}", new Object[] {name, count, total, next.getIdElement().getValue()});
+ try {
+ client.update().resource(next).execute();
+ } catch (BaseServerResponseException e) {
+ ourLog.warn("Server responded HTTP " + e.getStatusCode() + ": " + e.toString());
+ }
count++;
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
index 3a0fbe4b642..bb3ce1e6ec1 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
@@ -82,10 +82,11 @@ import java.util.Map.Entry;
import static org.apache.commons.lang3.StringUtils.*;
+@SuppressWarnings("WeakerAccess")
public abstract class BaseHapiFhirDao implements IDao {
- public static final long INDEX_STATUS_INDEXED = Long.valueOf(1L);
- public static final long INDEX_STATUS_INDEXING_FAILED = Long.valueOf(2L);
+ public static final long INDEX_STATUS_INDEXED = 1L;
+ public static final long INDEX_STATUS_INDEXING_FAILED = 2L;
public static final String NS_JPA_PROFILE = "https://github.com/jamesagnew/hapi-fhir/ns/jpa/profile";
public static final String OO_SEVERITY_ERROR = "error";
public static final String OO_SEVERITY_INFO = "information";
@@ -379,7 +380,7 @@ public abstract class BaseHapiFhirDao implements IDao {
} else {
ResourceLink resourceLink = new ResourceLink(nextPathAndRef.getPath(), theEntity, nextId, theUpdateTime);
if (theLinks.add(resourceLink)) {
- ourLog.info("Indexing remote resource reference URL: {}", nextId);
+ ourLog.debug("Indexing remote resource reference URL: {}", nextId);
}
continue;
}
@@ -417,7 +418,7 @@ public abstract class BaseHapiFhirDao implements IDao {
IBaseResource newResource = missingResourceDef.newInstance();
newResource.setId(resName + "/" + id);
IFhirResourceDao placeholderResourceDao = (IFhirResourceDao) getDao(newResource.getClass());
- ourLog.info("Automatically creating empty placeholder resource: {}", newResource.getIdElement().getValue());
+ ourLog.debug("Automatically creating empty placeholder resource: {}", newResource.getIdElement().getValue());
valueOf = placeholderResourceDao.update(newResource).getEntity().getId();
} else {
throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPathsUnsplit);
@@ -673,7 +674,7 @@ public abstract class BaseHapiFhirDao implements IDao {
@SuppressWarnings("unchecked")
public IFhirResourceDao getDao(Class theType) {
if (myResourceTypeToDao == null) {
- Map, IFhirResourceDao>> theResourceTypeToDao = new HashMap, IFhirResourceDao>>();
+ Map, IFhirResourceDao>> theResourceTypeToDao = new HashMap<>();
for (IFhirResourceDao> next : myResourceDaos) {
theResourceTypeToDao.put(next.getResourceType(), next);
}
@@ -1549,7 +1550,7 @@ public abstract class BaseHapiFhirDao implements IDao {
}
Long next = matches.iterator().next();
String newId = translatePidIdToForcedId(resourceTypeString, next);
- ourLog.info("Replacing inline match URL[{}] with ID[{}}", nextId.getValue(), newId);
+ ourLog.debug("Replacing inline match URL[{}] with ID[{}}", nextId.getValue(), newId);
nextRef.setReference(newId);
}
}
@@ -1615,7 +1616,7 @@ public abstract class BaseHapiFhirDao implements IDao {
}
if (!changed.isChanged() && !theForceUpdate && myConfig.isSuppressUpdatesWithNoChange()) {
- ourLog.info("Resource {} has not changed", theEntity.getIdDt().toUnqualified().getValue());
+ ourLog.debug("Resource {} has not changed", theEntity.getIdDt().toUnqualified().getValue());
if (theResource != null) {
populateResourceIdFromEntity(theEntity, theResource);
}
@@ -1657,7 +1658,7 @@ public abstract class BaseHapiFhirDao implements IDao {
historyEntry.setEncoding(changed.getEncoding());
historyEntry.setResource(changed.getResource());
- ourLog.info("Saving history entry {}", historyEntry.getIdDt());
+ ourLog.debug("Saving history entry {}", historyEntry.getIdDt());
myResourceHistoryTableDao.save(historyEntry);
}
@@ -1765,7 +1766,7 @@ public abstract class BaseHapiFhirDao implements IDao {
// Store composite string uniques
if (getConfig().isUniqueIndexesEnabled()) {
for (ResourceIndexedCompositeStringUnique next : removeCommon(existingCompositeStringUniques, compositeStringUniques)) {
- ourLog.info("Removing unique index: {}", next);
+ ourLog.debug("Removing unique index: {}", next);
myEntityManager.remove(next);
theEntity.getParamsCompositeStringUnique().remove(next);
}
@@ -1776,7 +1777,7 @@ public abstract class BaseHapiFhirDao implements IDao {
throw new PreconditionFailedException("Can not create resource of type " + theEntity.getResourceType() + " as it would create a duplicate index matching query: " + next.getIndexString() + " (existing index belongs to " + existing.getResource().getIdDt().toUnqualifiedVersionless().getValue() + ")");
}
}
- ourLog.info("Persisting unique index: {}", next);
+ ourLog.debug("Persisting unique index: {}", next);
myEntityManager.persist(next);
}
}
@@ -1821,7 +1822,7 @@ public abstract class BaseHapiFhirDao implements IDao {
if (nextChildDef instanceof RuntimeChildResourceDefinition) {
RuntimeChildResourceDefinition nextChildDefRes = (RuntimeChildResourceDefinition) nextChildDef;
- Set validTypes = new HashSet();
+ Set validTypes = new HashSet<>();
boolean allowAny = false;
for (Class extends IBaseResource> nextValidType : nextChildDefRes.getResourceTypes()) {
if (nextValidType.isInterface()) {
@@ -2147,7 +2148,7 @@ public abstract class BaseHapiFhirDao implements IDao {
}
if (forcedId.isEmpty() == false) {
- List retVal = new ArrayList(forcedId.size());
+ List retVal = new ArrayList<>(forcedId.size());
for (ForcedId next : forcedId) {
retVal.add(next.getResourcePid());
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java
index 9c26432e15c..4aa6732ec02 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java
@@ -127,7 +127,7 @@ public abstract class BaseHapiFhirResourceDao extends B
}
}
- ourLog.info("Processed addTag {}/{} on {} in {}ms", theScheme, theTerm, theId, w.getMillisAndRestart());
+ ourLog.debug("Processed addTag {}/{} on {} in {}ms", theScheme, theTerm, theId, w.getMillisAndRestart());
}
@Override
@@ -273,7 +273,7 @@ public abstract class BaseHapiFhirResourceDao extends B
validateDeleteConflictsEmptyOrThrowException(deleteConflicts);
- ourLog.info("Processed delete on {} in {}ms", theId.getValue(), w.getMillisAndRestart());
+ ourLog.debug("Processed delete on {} in {}ms", theId.getValue(), w.getMillisAndRestart());
return retVal;
}
@@ -350,7 +350,7 @@ public abstract class BaseHapiFhirResourceDao extends B
OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code);
}
- ourLog.info("Processed delete on {} (matched {} resource(s)) in {}ms", theUrl, deletedResources.size(), w.getMillis());
+ ourLog.debug("Processed delete on {} (matched {} resource(s)) in {}ms", theUrl, deletedResources.size(), w.getMillis());
DeleteMethodOutcome retVal = new DeleteMethodOutcome();
retVal.setDeletedEntities(deletedResources);
@@ -462,7 +462,7 @@ public abstract class BaseHapiFhirResourceDao extends B
String msg = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "successfulCreate", outcome.getId(), w.getMillisAndRestart());
outcome.setOperationOutcome(createInfoOperationOutcome(msg));
- ourLog.info(msg);
+ ourLog.debug(msg);
return outcome;
}
@@ -530,7 +530,7 @@ public abstract class BaseHapiFhirResourceDao extends B
StopWatch w = new StopWatch();
TagList tags = super.getTags(myResourceType, null);
- ourLog.info("Processed getTags on {} in {}ms", myResourceName, w.getMillisAndRestart());
+ ourLog.debug("Processed getTags on {} in {}ms", myResourceName, w.getMillisAndRestart());
return tags;
}
@@ -557,7 +557,7 @@ public abstract class BaseHapiFhirResourceDao extends B
StopWatch w = new StopWatch();
TagList retVal = super.getTags(myResourceType, theResourceId);
- ourLog.info("Processed getTags on {} in {}ms", theResourceId, w.getMillisAndRestart());
+ ourLog.debug("Processed getTags on {} in {}ms", theResourceId, w.getMillisAndRestart());
return retVal;
}
@@ -569,7 +569,7 @@ public abstract class BaseHapiFhirResourceDao extends B
StopWatch w = new StopWatch();
IBundleProvider retVal = super.history(myResourceName, null, theSince, theUntil);
- ourLog.info("Processed history on {} in {}ms", myResourceName, w.getMillisAndRestart());
+ ourLog.debug("Processed history on {} in {}ms", myResourceName, w.getMillisAndRestart());
return retVal;
}
@@ -586,7 +586,7 @@ public abstract class BaseHapiFhirResourceDao extends B
IBundleProvider retVal = super.history(myResourceName, entity.getId(), theSince, theUntil);
- ourLog.info("Processed history on {} in {}ms", id, w.getMillisAndRestart());
+ ourLog.debug("Processed history on {} in {}ms", id, w.getMillisAndRestart());
return retVal;
}
@@ -622,7 +622,7 @@ public abstract class BaseHapiFhirResourceDao extends B
if (myDaoConfig.isMarkResourcesForReindexingUponSearchParameterChange()) {
if (isNotBlank(theExpression)) {
final String resourceType = theExpression.substring(0, theExpression.indexOf('.'));
- ourLog.info("Marking all resources of type {} for reindexing due to updated search parameter with path: {}", resourceType, theExpression);
+ ourLog.debug("Marking all resources of type {} for reindexing due to updated search parameter with path: {}", resourceType, theExpression);
TransactionTemplate txTemplate = new TransactionTemplate(myPlatformTransactionManager);
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
@@ -633,7 +633,7 @@ public abstract class BaseHapiFhirResourceDao extends B
}
});
- ourLog.info("Marked {} resources for reindexing", updatedCount);
+ ourLog.debug("Marked {} resources for reindexing", updatedCount);
}
}
@@ -665,7 +665,7 @@ public abstract class BaseHapiFhirResourceDao extends B
doMetaAdd(theMetaAdd, history);
}
- ourLog.info("Processed metaAddOperation on {} in {}ms", new Object[]{theResourceId, w.getMillisAndRestart()});
+ ourLog.debug("Processed metaAddOperation on {} in {}ms", new Object[]{theResourceId, w.getMillisAndRestart()});
@SuppressWarnings("unchecked")
MT retVal = (MT) metaGetOperation(theMetaAdd.getClass(), theResourceId, theRequestDetails);
@@ -699,7 +699,7 @@ public abstract class BaseHapiFhirResourceDao extends B
myEntityManager.flush();
- ourLog.info("Processed metaDeleteOperation on {} in {}ms", new Object[]{theResourceId.getValue(), w.getMillisAndRestart()});
+ ourLog.debug("Processed metaDeleteOperation on {} in {}ms", new Object[]{theResourceId.getValue(), w.getMillisAndRestart()});
@SuppressWarnings("unchecked")
MT retVal = (MT) metaGetOperation(theMetaDel.getClass(), theResourceId, theRequestDetails);
@@ -864,7 +864,7 @@ public abstract class BaseHapiFhirResourceDao extends B
throw new ResourceGoneException("Resource was deleted at " + deleted.getValueAsString());
}
- ourLog.info("Processed read on {} in {}ms", theId.getValue(), w.getMillisAndRestart());
+ ourLog.debug("Processed read on {} in {}ms", theId.getValue(), w.getMillisAndRestart());
return retVal;
}
@@ -968,7 +968,7 @@ public abstract class BaseHapiFhirResourceDao extends B
myEntityManager.merge(entity);
- ourLog.info("Processed remove tag {}/{} on {} in {}ms", theScheme, theTerm, theId.getValue(), w.getMillisAndRestart());
+ ourLog.debug("Processed remove tag {}/{} on {} in {}ms", theScheme, theTerm, theId.getValue(), w.getMillisAndRestart());
}
@Transactional(propagation = Propagation.SUPPORTS)
@@ -1282,7 +1282,7 @@ public abstract class BaseHapiFhirResourceDao extends B
String msg = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "successfulCreate", outcome.getId(), w.getMillisAndRestart());
outcome.setOperationOutcome(createInfoOperationOutcome(msg));
- ourLog.info(msg);
+ ourLog.debug(msg);
return outcome;
}
@@ -1339,7 +1339,7 @@ public abstract class BaseHapiFhirResourceDao extends B
}
if (myDaoConfig.isEnforceReferentialIntegrityOnDelete() == false && !theForValidate) {
- ourLog.info("Deleting {} resource dependencies which can no longer be satisfied", resultList.size());
+ ourLog.debug("Deleting {} resource dependencies which can no longer be satisfied", resultList.size());
myResourceLinkDao.delete(resultList);
return;
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
index a2dab374bbc..816dfb55328 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
@@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.dao;
* 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.
@@ -83,7 +83,7 @@ public class SearchBuilder implements ISearchBuilder {
private static final List EMPTY_LONG_LIST = Collections.unmodifiableList(new ArrayList());
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchBuilder.class);
- private static Long NO_MORE = Long.valueOf(-1);
+ private static Long NO_MORE = -1L;
private static HandlerTypeEnum ourLastHandlerMechanismForUnitTest;
private List myAlsoIncludePids;
private CriteriaBuilder myBuilder;
@@ -331,10 +331,9 @@ public class SearchBuilder implements ISearchBuilder {
List codePredicates = new ArrayList();
for (IQueryParameterType nextOr : theList) {
- IQueryParameterType params = nextOr;
- if (params instanceof ReferenceParam) {
- ReferenceParam ref = (ReferenceParam) params;
+ if (nextOr instanceof ReferenceParam) {
+ ReferenceParam ref = (ReferenceParam) nextOr;
if (isBlank(ref.getChain())) {
IIdType dt = new IdDt(ref.getBaseUrl(), ref.getResourceType(), ref.getIdPart(), null);
@@ -471,7 +470,7 @@ public class SearchBuilder implements ISearchBuilder {
IQueryParameterType chainValue;
if (remainingChain != null) {
if (param == null || param.getParamType() != RestSearchParameterTypeEnum.REFERENCE) {
- ourLog.debug("Type {} parameter {} is not a reference, can not chain {}", new Object[]{nextType.getSimpleName(), chain, remainingChain});
+ ourLog.debug("Type {} parameter {} is not a reference, can not chain {}", new Object[] {nextType.getSimpleName(), chain, remainingChain});
continue;
}
@@ -533,7 +532,7 @@ public class SearchBuilder implements ISearchBuilder {
}
} else {
- throw new IllegalArgumentException("Invalid token type (expecting ReferenceParam): " + params.getClass());
+ throw new IllegalArgumentException("Invalid token type (expecting ReferenceParam): " + nextOr.getClass());
}
}
@@ -1475,37 +1474,37 @@ public class SearchBuilder implements ISearchBuilder {
switch (param.getParamType()) {
case STRING:
joinAttrName = "myParamsString";
- sortAttrName = new String[]{"myValueExact"};
+ sortAttrName = new String[] {"myValueExact"};
joinType = JoinEnum.STRING;
break;
case DATE:
joinAttrName = "myParamsDate";
- sortAttrName = new String[]{"myValueLow"};
+ sortAttrName = new String[] {"myValueLow"};
joinType = JoinEnum.DATE;
break;
case REFERENCE:
joinAttrName = "myResourceLinks";
- sortAttrName = new String[]{"myTargetResourcePid"};
+ sortAttrName = new String[] {"myTargetResourcePid"};
joinType = JoinEnum.REFERENCE;
break;
case TOKEN:
joinAttrName = "myParamsToken";
- sortAttrName = new String[]{"mySystem", "myValue"};
+ sortAttrName = new String[] {"mySystem", "myValue"};
joinType = JoinEnum.TOKEN;
break;
case NUMBER:
joinAttrName = "myParamsNumber";
- sortAttrName = new String[]{"myValue"};
+ sortAttrName = new String[] {"myValue"};
joinType = JoinEnum.NUMBER;
break;
case URI:
joinAttrName = "myParamsUri";
- sortAttrName = new String[]{"myUri"};
+ sortAttrName = new String[] {"myUri"};
joinType = JoinEnum.URI;
break;
case QUANTITY:
joinAttrName = "myParamsQuantity";
- sortAttrName = new String[]{"myValue"};
+ sortAttrName = new String[] {"myValue"};
joinType = JoinEnum.QUANTITY;
break;
default:
@@ -1780,7 +1779,7 @@ public class SearchBuilder implements ISearchBuilder {
nextRoundMatches = pidsToInclude;
} while (includes.size() > 0 && nextRoundMatches.size() > 0 && addedSomeThisRound);
- ourLog.info("Loaded {} {} in {} rounds and {} ms", new Object[]{allAdded.size(), theReverseMode ? "_revincludes" : "_includes", roundCounts, w.getMillisAndRestart()});
+ ourLog.info("Loaded {} {} in {} rounds and {} ms", new Object[] {allAdded.size(), theReverseMode ? "_revincludes" : "_includes", roundCounts, w.getMillisAndRestart()});
return allAdded;
}
@@ -2006,8 +2005,17 @@ public class SearchBuilder implements ISearchBuilder {
RuntimeResourceDefinition resourceDef = theContext.getResourceDefinition(theResourceType);
RuntimeSearchParam param = theCallingDao.getSearchParamByName(resourceDef, theParamName);
List path = param.getPathsSplit();
- Predicate type = theFrom.get("mySourcePath").in(path);
- return type;
+
+ /*
+ * SearchParameters can declare paths on multiple resources
+ * types. Here we only want the ones that actually apply.
+ */
+ for (Iterator iter = path.iterator(); iter.hasNext(); ) {
+ if (!iter.next().startsWith(theResourceType + ".")) {
+ iter.remove();
+ }
+ }
+ return theFrom.get("mySourcePath").in(path);
}
private static List filterResourceIdsByLastUpdated(EntityManager theEntityManager, final DateRangeParam theLastUpdated, Collection thePids) {
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3.java
index 5c8be60331e..7513d25ea8f 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3.java
@@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.dao.dstu3;
*/
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
+import static org.apache.commons.lang3.StringUtils.trim;
import java.math.BigDecimal;
import java.util.*;
@@ -478,8 +479,8 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
multiType = true;
}
- List systems = new ArrayList();
- List codes = new ArrayList();
+ List systems = new ArrayList<>();
+ List codes = new ArrayList<>();
// String needContactPointSystem = null;
// if (nextPath.contains(".where(system='phone')")) {
@@ -693,11 +694,11 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
IWorkerContext worker = new org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext(getContext(), myValidationSupport);
FHIRPathEngine fp = new FHIRPathEngine(worker);
- List