diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index fe15a80ac2e..c87a1d8c161 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -160,7 +160,7 @@ ${junit_version} test - + @@ -180,25 +180,11 @@ SITE - + @@ -224,26 +210,23 @@ --> - - org.apache.maven.plugins - maven-checkstyle-plugin - - - - checkstyle - - - - - false - file://${project.basedir}/../src/checkstyle/checkstyle.xml - - - + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + checkstyle + + + + + false + file://${project.basedir}/../src/checkstyle/checkstyle.xml + + + diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildEnumerationDatatypeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildEnumerationDatatypeDefinition.java index c0e68774836..fe9e8a9e402 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildEnumerationDatatypeDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildEnumerationDatatypeDefinition.java @@ -30,29 +30,30 @@ import ca.uhn.fhir.model.api.annotation.Description; public class RuntimeChildEnumerationDatatypeDefinition extends RuntimeChildPrimitiveDatatypeDefinition { - private Class> myBinderType; - private volatile IBaseEnumFactory myBinder; + private Class> myBinderType; + private volatile IBaseEnumFactory myBinder; - public RuntimeChildEnumerationDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class theDatatype, Class> theBinderType) { - super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype); + public RuntimeChildEnumerationDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class theDatatype, + Class> theBinderType) { + super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype); - myBinderType = theBinderType; - } + myBinderType = theBinderType; + } - @Override - public IBaseEnumFactory getInstanceConstructorArguments() { - IBaseEnumFactory retVal = myBinder; - if (retVal == null) { - try { - retVal = myBinderType.newInstance(); - } catch (InstantiationException e) { - throw new IllegalStateException("Failed to instantiate " + myBinderType, e); - } catch (IllegalAccessException e) { - throw new IllegalStateException("Failed to instantiate " + myBinderType, e); - } - myBinder = retVal; - } - return retVal; - } + @Override + public IBaseEnumFactory getInstanceConstructorArguments() { + IBaseEnumFactory retVal = myBinder; + if (retVal == null) { + try { + retVal = myBinderType.newInstance(); + } catch (InstantiationException e) { + throw new IllegalStateException("Failed to instantiate " + myBinderType, e); + } catch (IllegalAccessException e) { + throw new IllegalStateException("Failed to instantiate " + myBinderType, e); + } + myBinder = retVal; + } + return retVal; + } } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java index 0fcce6792e9..dc2052b5ac2 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java @@ -62,8 +62,8 @@ public abstract class BaseDateTimeDt extends BasePrimitive { private static final FastDateFormat ourYearMonthFormat = FastDateFormat.getInstance("yyyy-MM"); private static final FastDateFormat ourYearMonthNoDashesFormat = FastDateFormat.getInstance("yyyyMM"); private static final FastDateFormat ourHumanDateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM); - private static final FastDateFormat ourHumanDateFormat = FastDateFormat.getDateInstance(FastDateFormat.MEDIUM); - private static final Pattern ourYearMonthPattern = Pattern.compile("[0-9]{4}[0-9]{2}"); + private static final FastDateFormat ourHumanDateFormat = FastDateFormat.getDateInstance(FastDateFormat.MEDIUM); + private static final Pattern ourYearMonthPattern = Pattern.compile("[0-9]{4}[0-9]{2}"); private static final Pattern ourYearPattern = Pattern.compile("[0-9]{4}"); static { @@ -88,55 +88,50 @@ public abstract class BaseDateTimeDt extends BasePrimitive { private boolean myTimeZoneZulu = false; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseDateTimeDt.class); - /** - * Returns a human readable version of this date/time using the system local format. - *

- * Note on time zones: This method renders the value using the time zone - * that is contained within the value. For example, if this date object contains the - * value "2012-01-05T12:00:00-08:00", the human display will be rendered as "12:00:00" - * even if the application is being executed on a system in a different time zone. If - * this behaviour is not what you want, use {@link #toHumanDisplayLocalTimezone()} - * instead. - *

- */ - public String toHumanDisplay() { - TimeZone tz = getTimeZone(); - Calendar value = tz != null ? Calendar.getInstance(tz) : Calendar.getInstance(); - value.setTime(getValue()); - - switch (getPrecision()) { - case YEAR: - case MONTH: - case DAY: - return ourHumanDateFormat.format(value); - case MILLI: - case SECOND: - default: - return ourHumanDateTimeFormat.format(value); - } - } - - /** - * Returns a human readable version of this date/time using the system local format, - * converted to the local timezone if neccesary. - * - * @see #toHumanDisplay() for a method which does not convert the time to the local - * timezone before rendering it. - */ - public String toHumanDisplayLocalTimezone() { - switch (getPrecision()) { - case YEAR: - case MONTH: - case DAY: - return ourHumanDateFormat.format(getValue()); - case MILLI: - case SECOND: - default: - return ourHumanDateTimeFormat.format(getValue()); - } - } + /** + * Returns a human readable version of this date/time using the system local format. + *

+ * Note on time zones: This method renders the value using the time zone that is contained within the value. For example, if this date object contains the value "2012-01-05T12:00:00-08:00", + * the human display will be rendered as "12:00:00" even if the application is being executed on a system in a different time zone. If this behaviour is not what you want, use + * {@link #toHumanDisplayLocalTimezone()} instead. + *

+ */ + public String toHumanDisplay() { + TimeZone tz = getTimeZone(); + Calendar value = tz != null ? Calendar.getInstance(tz) : Calendar.getInstance(); + value.setTime(getValue()); - /** + switch (getPrecision()) { + case YEAR: + case MONTH: + case DAY: + return ourHumanDateFormat.format(value); + case MILLI: + case SECOND: + default: + return ourHumanDateTimeFormat.format(value); + } + } + + /** + * Returns a human readable version of this date/time using the system local format, converted to the local timezone if neccesary. + * + * @see #toHumanDisplay() for a method which does not convert the time to the local timezone before rendering it. + */ + public String toHumanDisplayLocalTimezone() { + switch (getPrecision()) { + case YEAR: + case MONTH: + case DAY: + return ourHumanDateFormat.format(getValue()); + case MILLI: + case SECOND: + default: + return ourHumanDateTimeFormat.format(getValue()); + } + } + + /** * Constructor */ public BaseDateTimeDt() { @@ -147,7 +142,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive { * Constructor * * @throws DataFormatException - * If the specified precision is not allowed for this type + * If the specified precision is not allowed for this type */ public BaseDateTimeDt(Date theDate, TemporalPrecisionEnum thePrecision) { setValue(theDate, thePrecision); @@ -160,7 +155,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive { * Constructor * * @throws DataFormatException - * If the specified precision is not allowed for this type + * If the specified precision is not allowed for this type */ public BaseDateTimeDt(String theString) { setValueAsString(theString); @@ -241,8 +236,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive { } /** - * Returns the TimeZone associated with this dateTime's value. May return null if no timezone was - * supplied. + * Returns the TimeZone associated with this dateTime's value. May return null if no timezone was supplied. */ public TimeZone getTimeZone() { return myTimeZone; @@ -279,7 +273,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive { * Returns true if this object represents a date that is today's date * * @throws NullPointerException - * if {@link #getValue()} returns null + * if {@link #getValue()} returns null */ public boolean isToday() { Validate.notNull(getValue(), getClass().getSimpleName() + " contains null value"); @@ -417,10 +411,8 @@ public abstract class BaseDateTimeDt extends BasePrimitive { } /** - * Sets the value for this type using the given Java Date object as the time, and using the - * default precision for this datatype, as well as the local timezone as determined by the - * local operating system. Both of these properties may be modified in subsequent calls - * if neccesary. + * Sets the value for this type using the given Java Date object as the time, and using the default precision for this datatype, as well as the local timezone as determined by the local operating + * system. Both of these properties may be modified in subsequent calls if neccesary. */ @Override public BaseDateTimeDt setValue(Date theValue) { @@ -429,15 +421,13 @@ public abstract class BaseDateTimeDt extends BasePrimitive { } /** - * Sets the value for this type using the given Java Date object as the time, and using the - * specified precision, as well as the local timezone as determined by the - * local operating system. Both of these properties may be modified in subsequent calls - * if neccesary. + * Sets the value for this type using the given Java Date object as the time, and using the specified precision, as well as the local timezone as determined by the local operating system. Both of + * these properties may be modified in subsequent calls if neccesary. * * @param theValue - * The date value + * The date value * @param thePrecision - * The precision + * The precision * @throws DataFormatException */ public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException { 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 3cede5145ab..96774956ad6 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 @@ -105,8 +105,8 @@ class ParserState { myState.endingElement(); } - public void enteringNewElement(String theNamespaceURI, String theName) throws DataFormatException { - myState.enteringNewElement(theNamespaceURI, theName); + public void enteringNewElement(String theNamespaceUri, String theName) throws DataFormatException { + myState.enteringNewElement(theNamespaceUri, theName); } public void enteringNewElementExtension(StartElement theElem, String theUrlAttr, boolean theIsModifier) { @@ -206,14 +206,14 @@ class ParserState { } /** - * Invoked after any new XML event is individually processed, containing a copy of the XML event. This is basically - * intended for embedded XHTML content + * Invoked after any new XML event is individually processed, containing a copy of the XML event. This is basically intended for embedded XHTML content */ public void xmlEvent(XMLEvent theNextEvent) { myState.xmlEvent(theNextEvent); } - public static ParserState getPreAtomInstance(FhirContext theContext, Class theResourceType, boolean theJsonMode, IParserErrorHandler theErrorHandler) throws DataFormatException { + public static ParserState getPreAtomInstance(FhirContext theContext, Class theResourceType, boolean theJsonMode, IParserErrorHandler theErrorHandler) + throws DataFormatException { ParserState retVal = new ParserState(theContext, theJsonMode, theErrorHandler); if (theContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) { retVal.push(retVal.new PreAtomState(theResourceType)); @@ -227,7 +227,8 @@ class ParserState { * @param theResourceType * May be null */ - public static ParserState getPreResourceInstance(Class theResourceType, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) throws DataFormatException { + public static ParserState getPreResourceInstance(Class theResourceType, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) + throws DataFormatException { ParserState retVal = new ParserState(theContext, theJsonMode, theErrorHandler); if (theResourceType == null) { if (theContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) { @@ -266,7 +267,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if ("name".equals(theLocalPart)) { push(new AtomPrimitiveState(myInstance.getAuthorName())); } else if ("uri".equals(theLocalPart)) { @@ -306,8 +307,7 @@ class ParserState { myScheme = theValue; } else if ("value".equals(theName)) { /* - * This handles XML parsing, which is odd for this quasi-resource type, since the tag has three values - * instead of one like everything else. + * This handles XML parsing, which is odd for this quasi-resource type, since the tag has three values instead of one like everything else. */ switch (myCatState) { case STATE_LABEL: @@ -340,7 +340,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theName) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theName) throws DataFormatException { if (myCatState != STATE_NONE) { throw new DataFormatException("Unexpected element in entry: " + theName); } @@ -370,7 +370,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if ("name".equals(theLocalPart)) { push(new AtomPrimitiveState(myEntry.getDeletedByName())); } else if ("email".equals(theLocalPart)) { @@ -404,13 +404,13 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { - if ("by".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, theNamespaceURI)) { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { + if ("by".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, theNamespaceUri)) { push(new AtomDeletedEntryByState(getEntry())); } else if ("comment".equals(theLocalPart)) { push(new AtomPrimitiveState(getEntry().getDeletedComment())); } else { - super.enteringNewElement(theNamespaceURI, theLocalPart); + super.enteringNewElement(theNamespaceUri, theLocalPart); } } @@ -439,7 +439,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { throw new DataFormatException("Unexpected nested element in atom tag: " + theLocalPart); } @@ -474,7 +474,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if ("title".equals(theLocalPart)) { push(new AtomPrimitiveState(myEntry.getTitle())); } else if ("id".equals(theLocalPart)) { @@ -610,7 +610,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { throw new DataFormatException("Found unexpected element content '" + theLocalPart + "' within "); } @@ -642,7 +642,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { throw new DataFormatException("Unexpected nested element in atom tag: " + theLocalPart); } @@ -681,8 +681,8 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { - if ("entry".equals(theLocalPart) && verifyNamespace(XmlParser.ATOM_NS, theNamespaceURI)) { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { + if ("entry".equals(theLocalPart) && verifyNamespace(XmlParser.ATOM_NS, theNamespaceUri)) { push(new AtomEntryState(myInstance, myResourceType)); } else if (theLocalPart.equals("title")) { push(new AtomPrimitiveState(myInstance.getTitle())); @@ -690,7 +690,7 @@ class ParserState { push(new AtomPrimitiveState(myInstance.getBundleId())); } else if ("link".equals(theLocalPart)) { push(new AtomLinkState(myInstance)); - } else if ("totalResults".equals(theLocalPart) && (verifyNamespace(XmlParser.OPENSEARCH_NS, theNamespaceURI) || verifyNamespace(Constants.OPENSEARCH_NS_OLDER, theNamespaceURI))) { + } else if ("totalResults".equals(theLocalPart) && (verifyNamespace(XmlParser.OPENSEARCH_NS, theNamespaceUri) || verifyNamespace(Constants.OPENSEARCH_NS_OLDER, theNamespaceUri))) { push(new AtomPrimitiveState(myInstance.getTotalResults())); } else if ("updated".equals(theLocalPart)) { push(new AtomPrimitiveState(myInstance.getUpdated())); @@ -698,11 +698,11 @@ class ParserState { push(new AtomAuthorState(myInstance)); } else if ("category".equals(theLocalPart)) { push(new AtomCategoryState(myInstance.getCategories())); - } else if ("deleted-entry".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, theNamespaceURI)) { + } else if ("deleted-entry".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, theNamespaceUri)) { push(new AtomDeletedEntryState(myInstance, myResourceType)); } else { - if (theNamespaceURI != null) { - throw new DataFormatException("Unexpected element: {" + theNamespaceURI + "}" + theLocalPart); + if (theNamespaceUri != null) { + throw new DataFormatException("Unexpected element: {" + theNamespaceUri + "}" + theLocalPart); } else { throw new DataFormatException("Unexpected element: " + theLocalPart); } @@ -802,7 +802,7 @@ class ParserState { // ignore by default } - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { myErrorHandler.unknownElement(null, theLocalPart); } @@ -927,7 +927,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if (myJsonMode && "contentType".equals(theLocalPart) && mySubState == 0) { mySubState = SUBSTATE_CT; } else if (myJsonMode && "content".equals(theLocalPart) && mySubState == 0) { @@ -975,7 +975,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if ("type".equals(theLocalPart)) { push(new PrimitiveState(getPreResourceState(), myEntry.getDeletedResourceType())); } else if ("id".equals(theLocalPart)) { @@ -1010,7 +1010,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if ("mode".equals(theLocalPart)) { push(new PrimitiveState(getPreResourceState(), myEntry.getSearchMode())); } else if ("score".equals(theLocalPart)) { @@ -1041,7 +1041,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if ("base".equals(theLocalPart)) { push(new PrimitiveState(getPreResourceState(), myEntry.getLinkBase())); } else if ("transaction".equals(theLocalPart)) { @@ -1135,7 +1135,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if ("method".equals(theLocalPart)) { push(new PrimitiveState(getPreResourceState(), myEntry.getTransactionMethod())); } else if ("url".equals(theLocalPart)) { @@ -1210,7 +1210,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if (myInRelation || myInUrl) { throw new DataFormatException("Unexpected element '" + theLocalPart + "' in element 'link'"); } @@ -1242,7 +1242,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if ("id".equals(theLocalPart)) { push(new PrimitiveState(null, myInstance.getId())); } else if ("meta".equals(theLocalPart)) { @@ -1263,7 +1263,7 @@ class ParserState { throw new DataFormatException("Unxpected element '" + theLocalPart + "' in element 'Bundle'"); } - // if ("entry".equals(theLocalPart) && verifyNamespace(XmlParser.ATOM_NS, theNamespaceURI)) { + // if ("entry".equals(theLocalPart) && verifyNamespace(XmlParser.ATOM_NS, theNamespaceUri)) { // push(new AtomEntryState(myInstance, myResourceType)); // } else if (theLocalPart.equals("published")) { // push(new AtomPrimitiveState(myInstance.getPublished())); @@ -1274,7 +1274,7 @@ class ParserState { // } else if ("link".equals(theLocalPart)) { // push(new AtomLinkState(myInstance)); // } else if ("totalResults".equals(theLocalPart) && (verifyNamespace(XmlParser.OPENSEARCH_NS, - // theNamespaceURI) || verifyNamespace(Constants.OPENSEARCH_NS_OLDER, theNamespaceURI))) { + // theNamespaceUri) || verifyNamespace(Constants.OPENSEARCH_NS_OLDER, theNamespaceUri))) { // push(new AtomPrimitiveState(myInstance.getTotalResults())); // } else if ("updated".equals(theLocalPart)) { // push(new AtomPrimitiveState(myInstance.getUpdated())); @@ -1283,11 +1283,11 @@ class ParserState { // } else if ("category".equals(theLocalPart)) { // push(new AtomCategoryState(myInstance.getCategories())); // } else if ("deleted-entry".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, - // theNamespaceURI)) { + // theNamespaceUri)) { // push(new AtomDeletedEntryState(myInstance, myResourceType)); // } else { - // if (theNamespaceURI != null) { - // throw new DataFormatException("Unexpected element: {" + theNamespaceURI + "}" + theLocalPart); + // if (theNamespaceUri != null) { + // throw new DataFormatException("Unexpected element: {" + theNamespaceUri + "}" + theLocalPart); // } else { // throw new DataFormatException("Unexpected element: " + theLocalPart); // } @@ -1428,7 +1428,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { BaseRuntimeElementDefinition target = myDefinition.getChildByName(theLocalPart); if (target == null) { myErrorHandler.unknownElement(null, theLocalPart); @@ -1544,8 +1544,7 @@ class ParserState { child = myDefinition.getChildByNameOrThrowDataFormatException(theChildName); } catch (DataFormatException e) { /* - * This means we've found an element that doesn't exist on the structure. If the error handler doesn't - * throw an exception, swallow the element silently along with any child elements + * This means we've found an element that doesn't exist on the structure. If the error handler doesn't throw an exception, swallow the element silently along with any child elements */ myErrorHandler.unknownElement(null, theChildName); push(new SwallowChildrenWholeState(getPreResourceState())); @@ -1691,7 +1690,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { BaseRuntimeElementDefinition target = myContext.getRuntimeChildUndeclaredExtensionDefinition().getChildByName(theLocalPart); if (target == null) { myErrorHandler.unknownElement(null, theLocalPart); @@ -1775,7 +1774,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if (theLocalPart.equals("versionId")) { push(new MetaVersionElementState(getPreResourceState(), myMap)); // } else if (theLocalPart.equals("profile")) { @@ -1841,7 +1840,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { myErrorHandler.unknownElement(null, theLocalPart); push(new SwallowChildrenWholeState(getPreResourceState())); return; @@ -1861,7 +1860,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if (!"feed".equals(theLocalPart)) { throw new DataFormatException("Expecting outer element called 'feed', found: " + theLocalPart); } @@ -1885,7 +1884,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if (!"Bundle".equals(theLocalPart)) { throw new DataFormatException("Expecting outer element called 'Bundle', found: " + theLocalPart); } @@ -1940,8 +1939,8 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { - super.enteringNewElement(theNamespaceURI, theLocalPart); + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { + super.enteringNewElement(theNamespaceUri, theLocalPart); if (myEntry != null) { myEntry.setResource((IResource) getCurrentElement()); } @@ -1990,8 +1989,8 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { - super.enteringNewElement(theNamespaceURI, theLocalPart); + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { + super.enteringNewElement(theNamespaceUri, theLocalPart); if (myMutator != null) { myMutator.addValue(myTarget, getCurrentElement()); } @@ -2034,7 +2033,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { BaseRuntimeElementDefinition definition; if (myResourceType == null) { definition = myContext.getResourceDefinition(myParentVersion, theLocalPart); @@ -2043,7 +2042,7 @@ class ParserState { } } else { definition = myContext.getResourceDefinition(myResourceType); - if (!StringUtils.equals(theLocalPart, definition.getName())) { + if (!StringUtils.equals(theLocalPart, definition.getName())) { if (myRequireResourceType) { throw new DataFormatException(myContext.getLocalizer().getMessage(ParserState.class, "wrongResourceTypeFound", definition.getName(), theLocalPart)); } @@ -2128,7 +2127,8 @@ class ParserState { } @Override - public void acceptUndeclaredExtension(ISupportsUndeclaredExtensions theContainingElement, List thePathToElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition theDefinition, ExtensionDt theNextExt) { + public void acceptUndeclaredExtension(ISupportsUndeclaredExtensions theContainingElement, List thePathToElement, BaseRuntimeChildDefinition theChildDefinition, + BaseRuntimeElementDefinition theDefinition, ExtensionDt theNextExt) { acceptElement(theNextExt.getValue(), null, null, null); } }); @@ -2181,7 +2181,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if (!TagList.ELEMENT_NAME_LC.equals(theLocalPart.toLowerCase())) { throw new DataFormatException("resourceType does not appear to be 'TagList', found: " + theLocalPart); } @@ -2251,7 +2251,7 @@ class ParserState { // } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { myErrorHandler.unknownElement(null, theLocalPart); push(new SwallowChildrenWholeState(getPreResourceState())); return; @@ -2306,7 +2306,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { switch (mySubState) { case INITIAL: if ("display".equals(theLocalPart)) { @@ -2375,7 +2375,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { switch (mySubState) { case INITIAL: if ("display".equals(theLocalPart)) { @@ -2457,7 +2457,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { myDepth++; } @@ -2488,7 +2488,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { if (TagList.ATTR_CATEGORY.equals(theLocalPart)) { push(new TagState(myTagList)); } else { @@ -2552,7 +2552,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { /* * We allow for both the DSTU1 and DSTU2 names here */ @@ -2606,7 +2606,7 @@ class ParserState { } @Override - public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { + public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { // IGNORE - don't handle this as an error, we process these as XML events } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseMethodBinding.java index 71c99c193ae..b53951aa047 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseMethodBinding.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseMethodBinding.java @@ -163,11 +163,11 @@ public abstract class BaseMethodBinding implements IClientResponseHandler return retVal; } - public Method getMethod() { + public Method getMethod() { return myMethod; } - public OtherOperationTypeEnum getOtherOperationType() { + public OtherOperationTypeEnum getOtherOperationType() { return null; } @@ -181,42 +181,42 @@ public abstract class BaseMethodBinding implements IClientResponseHandler @SuppressWarnings({ "unchecked", "rawtypes" }) public Set getRequestIncludesFromParams(Object[] params) { - if (params == null || params.length == 0) - return null; - int index = 0; - boolean match = false; - for (IParameter parameter : myParameters) { - if (parameter instanceof IncludeParameter) { - match = true; - break; - } - index++; - } - if (!match) - return null; - if (index >= params.length) { - ourLog.warn("index out of parameter range (should never happen"); - return null; - } - if (params[index] instanceof Set) { - return (Set)params[index]; - } - if (params[index] instanceof Iterable) { - Set includes = new HashSet(); - for (Object o : (Iterable)params[index]) { - if (o instanceof Include) { - includes.add(o); - } - } - return includes; - } - ourLog.warn("include params wasn't Set or Iterable, it was {}", params[index].getClass()); - return null; - } + if (params == null || params.length == 0) { + return null; + } + int index = 0; + boolean match = false; + for (IParameter parameter : myParameters) { + if (parameter instanceof IncludeParameter) { + match = true; + break; + } + index++; + } + if (!match) + return null; + if (index >= params.length) { + ourLog.warn("index out of parameter range (should never happen"); + return null; + } + if (params[index] instanceof Set) { + return (Set) params[index]; + } + if (params[index] instanceof Iterable) { + Set includes = new HashSet(); + for (Object o : (Iterable) params[index]) { + if (o instanceof Include) { + includes.add(o); + } + } + return includes; + } + ourLog.warn("include params wasn't Set or Iterable, it was {}", params[index].getClass()); + return null; + } /** - * Returns the name of the resource this method handles, or null if this method is not resource - * specific + * Returns the name of the resource this method handles, or null if this method is not resource specific */ public abstract String getResourceName(); @@ -266,12 +266,9 @@ public abstract class BaseMethodBinding implements IClientResponseHandler protected byte[] loadRequestContents(RequestDetails theRequest) throws IOException { /* - * This is weird, but this class is used both in clients and in servers, and - * we want to avoid needing to depend on servlet-api in clients since there is - * no point. So we dynamically load a class that does the servlet processing in - * servers. Down the road it may make sense to just split the method binding - * classes into server and client versions, but this isn't actually a huge deal - * I don't think. + * This is weird, but this class is used both in clients and in servers, and we want to avoid needing to depend on servlet-api in clients since there is no point. So we dynamically load a class + * that does the servlet processing in servers. Down the road it may make sense to just split the method binding classes into server and client versions, but this isn't actually a huge deal I + * don't think. */ IRequestReader reader = ourRequestReader; if (reader == null) { @@ -293,7 +290,7 @@ public abstract class BaseMethodBinding implements IClientResponseHandler } ourRequestReader = reader; } - + InputStream inputStream = reader.getInputStream(theRequest); byte[] requestContents = IOUtils.toByteArray(inputStream); return requestContents; @@ -336,7 +333,7 @@ public abstract class BaseMethodBinding implements IClientResponseHandler public void setParameters(List theParameters) { myParameters = theParameters; } - + protected IBundleProvider toResourceList(Object response) throws InternalErrorException { if (response == null) { return BundleProviders.newEmptyList(); @@ -388,14 +385,16 @@ public abstract class BaseMethodBinding implements IClientResponseHandler if (theProvider instanceof IResourceProvider) { returnTypeFromRp = ((IResourceProvider) theProvider).getResourceType(); if (!verifyIsValidResourceReturnType(returnTypeFromRp)) { - throw new ConfigurationException("getResourceType() from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returned " + toLogString(returnTypeFromRp) + " - Must return a resource type"); + throw new ConfigurationException("getResourceType() from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returned " + + toLogString(returnTypeFromRp) + " - Must return a resource type"); } } Class returnTypeFromMethod = theMethod.getReturnType(); if (getTags != null) { if (!TagList.class.equals(returnTypeFromMethod)) { - throw new ConfigurationException("Method '" + theMethod.getName() + "' from type " + theMethod.getDeclaringClass().getCanonicalName() + " is annotated with @" + GetTags.class.getSimpleName() + " but does not return type " + TagList.class.getName()); + throw new ConfigurationException("Method '" + theMethod.getName() + "' from type " + theMethod.getDeclaringClass().getCanonicalName() + " is annotated with @" + + GetTags.class.getSimpleName() + " but does not return type " + TagList.class.getName()); } } else if (MethodOutcome.class.equals(returnTypeFromMethod)) { // returns a method outcome @@ -408,13 +407,15 @@ public abstract class BaseMethodBinding implements IClientResponseHandler } else if (Collection.class.isAssignableFrom(returnTypeFromMethod)) { returnTypeFromMethod = ReflectionUtil.getGenericCollectionTypeOfMethodReturnType(theMethod); if (!verifyIsValidResourceReturnType(returnTypeFromMethod) && !IResource.class.equals(returnTypeFromMethod)) { - throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returns a collection with generic type " + toLogString(returnTypeFromMethod) + throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + + " returns a collection with generic type " + toLogString(returnTypeFromMethod) + " - Must return a resource type or a collection (List, Set) with a resource type parameter (e.g. List or List )"); } } else { if (!IResource.class.equals(returnTypeFromMethod) && !verifyIsValidResourceReturnType(returnTypeFromMethod)) { - throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returns " + toLogString(returnTypeFromMethod) - + " - Must return a resource type (eg Patient, " + Bundle.class.getSimpleName() + ", " + IBundleProvider.class.getSimpleName() + ", etc., see the documentation for more details)"); + throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + + " returns " + toLogString(returnTypeFromMethod) + " - Must return a resource type (eg Patient, " + Bundle.class.getSimpleName() + ", " + IBundleProvider.class.getSimpleName() + + ", etc., see the documentation for more details)"); } } @@ -444,12 +445,13 @@ public abstract class BaseMethodBinding implements IClientResponseHandler if (returnTypeFromRp != null) { if (returnTypeFromAnnotation != null && returnTypeFromAnnotation != IResource.class) { if (!returnTypeFromRp.isAssignableFrom(returnTypeFromAnnotation)) { - throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " returns type " + returnTypeFromMethod.getCanonicalName() + " - Must return " + returnTypeFromRp.getCanonicalName() - + " (or a subclass of it) per IResourceProvider contract"); + throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " returns type " + + returnTypeFromMethod.getCanonicalName() + " - Must return " + returnTypeFromRp.getCanonicalName() + " (or a subclass of it) per IResourceProvider contract"); } if (!returnTypeFromRp.isAssignableFrom(returnTypeFromAnnotation)) { - throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " claims to return type " + returnTypeFromAnnotation.getCanonicalName() + " per method annotation - Must return " - + returnTypeFromRp.getCanonicalName() + " (or a subclass of it) per IResourceProvider contract"); + throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " claims to return type " + + returnTypeFromAnnotation.getCanonicalName() + " per method annotation - Must return " + returnTypeFromRp.getCanonicalName() + + " (or a subclass of it) per IResourceProvider contract"); } returnType = returnTypeFromAnnotation; } else { @@ -458,19 +460,19 @@ public abstract class BaseMethodBinding implements IClientResponseHandler } else { if (returnTypeFromAnnotation != IResource.class) { if (!verifyIsValidResourceReturnType(returnTypeFromAnnotation)) { - throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returns " + toLogString(returnTypeFromAnnotation) - + " according to annotation - Must return a resource type"); + throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + + " returns " + toLogString(returnTypeFromAnnotation) + " according to annotation - Must return a resource type"); } returnType = returnTypeFromAnnotation; - } else { - //if (IRestfulClient.class.isAssignableFrom(theMethod.getDeclaringClass())) { + } else { + // if (IRestfulClient.class.isAssignableFrom(theMethod.getDeclaringClass())) { // Clients don't define their methods in resource specific types, so they can // infer their resource type from the method return type. returnType = (Class) returnTypeFromMethod; -// } else { + // } else { // This is a plain provider method returning a resource, so it should be // an operation or global search presumably - // returnType = null; + // returnType = null; } } @@ -559,8 +561,8 @@ public abstract class BaseMethodBinding implements IClientResponseHandler return false; } return true; -// boolean retVal = Modifier.isAbstract(theReturnType.getModifiers()) == false; -// return retVal; + // boolean retVal = Modifier.isAbstract(theReturnType.getModifiers()) == false; + // return retVal; } public static boolean verifyMethodHasZeroOrOneOperationAnnotation(Method theNextMethod, Object... theAnnotations) { @@ -570,8 +572,8 @@ public abstract class BaseMethodBinding implements IClientResponseHandler if (obj1 == null) { obj1 = object; } else { - throw new ConfigurationException("Method " + theNextMethod.getName() + " on type '" + theNextMethod.getDeclaringClass().getSimpleName() + " has annotations @" + obj1.getClass().getSimpleName() + " and @" + object.getClass().getSimpleName() - + ". Can not have both."); + throw new ConfigurationException("Method " + theNextMethod.getName() + " on type '" + theNextMethod.getDeclaringClass().getSimpleName() + " has annotations @" + + obj1.getClass().getSimpleName() + " and @" + object.getClass().getSimpleName() + ". Can not have both."); } } @@ -585,12 +587,12 @@ public abstract class BaseMethodBinding implements IClientResponseHandler } return true; } - + /** * @see BaseMethodBinding#loadRequestContents(RequestDetails) */ private static volatile IRequestReader ourRequestReader; - + /** * @see BaseMethodBinding#loadRequestContents(RequestDetails) */ @@ -601,18 +603,16 @@ public abstract class BaseMethodBinding implements IClientResponseHandler /** * @see BaseMethodBinding#loadRequestContents(RequestDetails) */ - @SuppressWarnings("unused") static class ActiveRequestReader implements IRequestReader { @Override public InputStream getInputStream(RequestDetails theRequestDetails) throws IOException { return theRequestDetails.getServletRequest().getInputStream(); } } - + /** * @see BaseMethodBinding#loadRequestContents(RequestDetails) */ - @SuppressWarnings("unused") static class InactiveRequestReader implements IRequestReader { @Override public InputStream getInputStream(RequestDetails theRequestDetails) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/ApacheProxyAddressStrategy.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/ApacheProxyAddressStrategy.java index ba5a207a529..6c514e2eef8 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/ApacheProxyAddressStrategy.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/ApacheProxyAddressStrategy.java @@ -24,72 +24,68 @@ import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; /** - * Works like the normal {@link ca.uhn.fhir.rest.server.IncomingRequestAddressStrategy} unless there's an - * x-forwarded-host present, in which case that's used in place of the server's address. + * Works like the normal {@link ca.uhn.fhir.rest.server.IncomingRequestAddressStrategy} unless there's an x-forwarded-host present, in which case that's used in place of the server's address. * - * If the Apache Http Server mod_proxy isn't configured to supply x-forwarded-proto, the factory method that you use - * to create the address strategy will determine the default. Note that mod_proxy doesn't set this by default, but it can be - * configured via RequestHeader set X-Forwarded-Proto http (or https) + * If the Apache Http Server mod_proxy isn't configured to supply x-forwarded-proto, the factory method that you use to create the address strategy will determine the default. Note that + * mod_proxy doesn't set this by default, but it can be configured via RequestHeader set X-Forwarded-Proto http (or https) * - * If you want to set the protocol based on something other than the constructor argument, you should be able to do so - * by overriding protocol. + * If you want to set the protocol based on something other than the constructor argument, you should be able to do so by overriding protocol. * - * Note that while this strategy was designed to work with Apache Http Server, and has been tested against it, it should work with - * any proxy server that sets x-forwarded-host + * Note that while this strategy was designed to work with Apache Http Server, and has been tested against it, it should work with any proxy server that sets x-forwarded-host * * Created by Bill de Beaubien on 3/30/2015. */ public class ApacheProxyAddressStrategy extends IncomingRequestAddressStrategy { - private boolean myUseHttps = false; + private boolean myUseHttps = false; - protected ApacheProxyAddressStrategy(boolean theUseHttps) { - myUseHttps = theUseHttps; - } + protected ApacheProxyAddressStrategy(boolean theUseHttps) { + myUseHttps = theUseHttps; + } - public static ApacheProxyAddressStrategy forHttp() { - return new ApacheProxyAddressStrategy(false); - } + public static ApacheProxyAddressStrategy forHttp() { + return new ApacheProxyAddressStrategy(false); + } - public static ApacheProxyAddressStrategy forHttps() { - return new ApacheProxyAddressStrategy(true); - } + public static ApacheProxyAddressStrategy forHttps() { + return new ApacheProxyAddressStrategy(true); + } - @Override - public String determineServerBase(ServletContext theServletContext, HttpServletRequest theRequest) { - String forwardedHost = getForwardedHost(theRequest); - if (forwardedHost != null) { - return forwardedServerBase(theServletContext, theRequest, forwardedHost); - } - return super.determineServerBase(theServletContext, theRequest); - } + @Override + public String determineServerBase(ServletContext theServletContext, HttpServletRequest theRequest) { + String forwardedHost = getForwardedHost(theRequest); + if (forwardedHost != null) { + return forwardedServerBase(theServletContext, theRequest, forwardedHost); + } + return super.determineServerBase(theServletContext, theRequest); + } - private String getForwardedHost(HttpServletRequest theRequest) { - String forwardedHost = theRequest.getHeader("x-forwarded-host"); - if (forwardedHost != null) { - int commaPos = forwardedHost.indexOf(','); - if (commaPos >= 0) { - forwardedHost = forwardedHost.substring(0, commaPos - 1); - } - } - return forwardedHost; - } + private String getForwardedHost(HttpServletRequest theRequest) { + String forwardedHost = theRequest.getHeader("x-forwarded-host"); + if (forwardedHost != null) { + int commaPos = forwardedHost.indexOf(','); + if (commaPos >= 0) { + forwardedHost = forwardedHost.substring(0, commaPos - 1); + } + } + return forwardedHost; + } - public String forwardedServerBase(ServletContext theServletContext, HttpServletRequest theRequest, String theForwardedHost) { - String serverBase = super.determineServerBase(theServletContext, theRequest); - String host = theRequest.getHeader("host"); - if (host != null) { - serverBase = serverBase.replace(host, theForwardedHost); - serverBase = serverBase.substring(serverBase.indexOf("://")); - return protocol(theRequest) + serverBase; - } - return serverBase; - } + public String forwardedServerBase(ServletContext theServletContext, HttpServletRequest theRequest, String theForwardedHost) { + String serverBase = super.determineServerBase(theServletContext, theRequest); + String host = theRequest.getHeader("host"); + if (host != null) { + serverBase = serverBase.replace(host, theForwardedHost); + serverBase = serverBase.substring(serverBase.indexOf("://")); + return protocol(theRequest) + serverBase; + } + return serverBase; + } - protected String protocol(HttpServletRequest theRequest) { - String protocol = theRequest.getHeader("x-forwarded-proto"); - if (protocol != null) { - return protocol; - } - return myUseHttps ? "https" : "http"; - } + protected String protocol(HttpServletRequest theRequest) { + String protocol = theRequest.getHeader("x-forwarded-proto"); + if (protocol != null) { + return protocol; + } + return myUseHttps ? "https" : "http"; + } } diff --git a/hapi-fhir-cobertura/pom.xml b/hapi-fhir-cobertura/pom.xml index 124e7f9dcba..76949cfafc5 100644 --- a/hapi-fhir-cobertura/pom.xml +++ b/hapi-fhir-cobertura/pom.xml @@ -2,17 +2,22 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + ca.uhn.hapi.fhir - hapi-fhir - 1.1-SNAPSHOT - ../pom.xml + hapi-deployable-pom + 1.1-SNAPSHOT + ../hapi-deployable-pom/pom.xml hapi-fhir-cobertura jar - HAPI FHIR - Consolidated Test Project + HAPI FHIR - Cobertura Test Coverage @@ -70,13 +75,6 @@ ${logback_version} - - org.hamcrest - java-hamcrest - ${hamcrest_version} - test - - junit @@ -122,12 +120,6 @@ ${jetty_version} test - - org.eclipse.jetty - jetty-servlet - ${jetty_version} - test - org.eclipse.jetty jetty-util @@ -371,7 +363,7 @@
- + org.apache.maven.plugins maven-project-info-reports-plugin diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 493fcad36c3..1a20f09843d 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -275,12 +275,6 @@ ${jetty_version} test - - org.eclipse.jetty - jetty-servlet - ${jetty_version} - test - org.eclipse.jetty jetty-util diff --git a/pom.xml b/pom.xml index aa789aec626..7fc3b9dbeca 100644 --- a/pom.xml +++ b/pom.xml @@ -457,6 +457,11 @@ file://${project.basedir}/src/checkstyle/checkstyle.xml + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 06f1a53ef8b..6319038d848 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -76,7 +76,9 @@ + @@ -141,7 +143,7 @@ - +