Clean up warnings
This commit is contained in:
parent
e616fc85d3
commit
dd9f80ecb1
|
@ -160,7 +160,7 @@
|
|||
<version>${junit_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -180,25 +180,11 @@
|
|||
<id>SITE</id>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>checkstyle</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
<configuration>
|
||||
<linkXRef>false</linkXRef>
|
||||
<sourceDirectories>
|
||||
<sourceDirectory>hapi-fhir-base/src/main/java</sourceDirectory>
|
||||
</sourceDirectories>
|
||||
</configuration>
|
||||
</plugin>
|
||||
-->
|
||||
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<reportSets> <reportSet> <reports> <report>checkstyle</report> </reports>
|
||||
</reportSet> </reportSets> <configuration> <linkXRef>false</linkXRef> <sourceDirectories>
|
||||
<sourceDirectory>hapi-fhir-base/src/main/java</sourceDirectory> </sourceDirectories>
|
||||
</configuration> </plugin> -->
|
||||
<!--<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>3.0.0</version> <configuration> </configuration> </plugin> -->
|
||||
<plugin>
|
||||
|
@ -224,26 +210,23 @@
|
|||
</plugin> -->
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>checkstyle</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
<configuration>
|
||||
<linkXRef>false</linkXRef>
|
||||
<configLocation>file://${project.basedir}/../src/checkstyle/checkstyle.xml</configLocation>
|
||||
<!--<sourceDirectories>
|
||||
<sourceDirectory>
|
||||
${project.basedir}/../hapi-fhir-base/src/main/java
|
||||
</sourceDirectory>
|
||||
</sourceDirectories>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>checkstyle</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
<configuration>
|
||||
<linkXRef>false</linkXRef>
|
||||
<configLocation>file://${project.basedir}/../src/checkstyle/checkstyle.xml</configLocation>
|
||||
<!--<sourceDirectories> <sourceDirectory> ${project.basedir}/../hapi-fhir-base/src/main/java
|
||||
</sourceDirectory> </sourceDirectories> -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
|
|
|
@ -30,29 +30,30 @@ import ca.uhn.fhir.model.api.annotation.Description;
|
|||
|
||||
public class RuntimeChildEnumerationDatatypeDefinition extends RuntimeChildPrimitiveDatatypeDefinition {
|
||||
|
||||
private Class<? extends IBaseEnumFactory<?>> myBinderType;
|
||||
private volatile IBaseEnumFactory<?> myBinder;
|
||||
private Class<? extends IBaseEnumFactory<?>> myBinderType;
|
||||
private volatile IBaseEnumFactory<?> myBinder;
|
||||
|
||||
public RuntimeChildEnumerationDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype, Class<? extends IBaseEnumFactory<?>> theBinderType) {
|
||||
super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype);
|
||||
public RuntimeChildEnumerationDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype,
|
||||
Class<? extends IBaseEnumFactory<?>> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
|||
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<Date> {
|
|||
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.
|
||||
* <p>
|
||||
* <b>Note on time zones:</b> 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.
|
||||
* </p>
|
||||
*/
|
||||
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.
|
||||
* <p>
|
||||
* <b>Note on time zones:</b> 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.
|
||||
* </p>
|
||||
*/
|
||||
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<Date> {
|
|||
* 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<Date> {
|
|||
* 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<Date> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the TimeZone associated with this dateTime's value. May return <code>null</code> if no timezone was
|
||||
* supplied.
|
||||
* Returns the TimeZone associated with this dateTime's value. May return <code>null</code> if no timezone was supplied.
|
||||
*/
|
||||
public TimeZone getTimeZone() {
|
||||
return myTimeZone;
|
||||
|
@ -279,7 +273,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
|||
* Returns <code>true</code> if this object represents a date that is today's date
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* if {@link #getValue()} returns <code>null</code>
|
||||
* if {@link #getValue()} returns <code>null</code>
|
||||
*/
|
||||
public boolean isToday() {
|
||||
Validate.notNull(getValue(), getClass().getSimpleName() + " contains null value");
|
||||
|
@ -417,10 +411,8 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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<Date> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
|
|
@ -105,8 +105,8 @@ class ParserState<T> {
|
|||
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<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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<Bundle> getPreAtomInstance(FhirContext theContext, Class<? extends IBaseResource> theResourceType, boolean theJsonMode, IParserErrorHandler theErrorHandler) throws DataFormatException {
|
||||
public static ParserState<Bundle> getPreAtomInstance(FhirContext theContext, Class<? extends IBaseResource> theResourceType, boolean theJsonMode, IParserErrorHandler theErrorHandler)
|
||||
throws DataFormatException {
|
||||
ParserState<Bundle> retVal = new ParserState<Bundle>(theContext, theJsonMode, theErrorHandler);
|
||||
if (theContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
|
||||
retVal.push(retVal.new PreAtomState(theResourceType));
|
||||
|
@ -227,7 +227,8 @@ class ParserState<T> {
|
|||
* @param theResourceType
|
||||
* May be null
|
||||
*/
|
||||
public static <T extends IBaseResource> ParserState<T> getPreResourceInstance(Class<T> theResourceType, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) throws DataFormatException {
|
||||
public static <T extends IBaseResource> ParserState<T> getPreResourceInstance(Class<T> theResourceType, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler)
|
||||
throws DataFormatException {
|
||||
ParserState<T> retVal = new ParserState<T>(theContext, theJsonMode, theErrorHandler);
|
||||
if (theResourceType == null) {
|
||||
if (theContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) {
|
||||
|
@ -266,7 +267,7 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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 <link>");
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
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<T> {
|
|||
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<T> {
|
|||
// 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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
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<T> {
|
|||
// } 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<T> {
|
|||
// } 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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
} 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<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void acceptUndeclaredExtension(ISupportsUndeclaredExtensions theContainingElement, List<String> thePathToElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition<?> theDefinition, ExtensionDt theNextExt) {
|
||||
public void acceptUndeclaredExtension(ISupportsUndeclaredExtensions theContainingElement, List<String> thePathToElement, BaseRuntimeChildDefinition theChildDefinition,
|
||||
BaseRuntimeElementDefinition<?> theDefinition, ExtensionDt theNextExt) {
|
||||
acceptElement(theNextExt.getValue(), null, null, null);
|
||||
}
|
||||
});
|
||||
|
@ -2181,7 +2181,7 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
// }
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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<T> {
|
|||
}
|
||||
|
||||
@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
|
||||
}
|
||||
|
||||
|
|
|
@ -163,11 +163,11 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
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<T> implements IClientResponseHandler<T>
|
|||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Set<Include> 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<Include>)params[index];
|
||||
}
|
||||
if (params[index] instanceof Iterable) {
|
||||
Set includes = new HashSet<Include>();
|
||||
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<Include>) params[index];
|
||||
}
|
||||
if (params[index] instanceof Iterable) {
|
||||
Set includes = new HashSet<Include>();
|
||||
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 <code>null</code> if this method is not resource
|
||||
* specific
|
||||
* Returns the name of the resource this method handles, or <code>null</code> if this method is not resource specific
|
||||
*/
|
||||
public abstract String getResourceName();
|
||||
|
||||
|
@ -266,12 +266,9 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
|
||||
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<T> implements IClientResponseHandler<T>
|
|||
}
|
||||
ourRequestReader = reader;
|
||||
}
|
||||
|
||||
|
||||
InputStream inputStream = reader.getInputStream(theRequest);
|
||||
byte[] requestContents = IOUtils.toByteArray(inputStream);
|
||||
return requestContents;
|
||||
|
@ -336,7 +333,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
public void setParameters(List<IParameter> theParameters) {
|
||||
myParameters = theParameters;
|
||||
}
|
||||
|
||||
|
||||
protected IBundleProvider toResourceList(Object response) throws InternalErrorException {
|
||||
if (response == null) {
|
||||
return BundleProviders.newEmptyList();
|
||||
|
@ -388,14 +385,16 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
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<T> implements IClientResponseHandler<T>
|
|||
} 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<Patient> or List<IResource> )");
|
||||
}
|
||||
} 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<T> implements IClientResponseHandler<T>
|
|||
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<T> implements IClientResponseHandler<T>
|
|||
} 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<? extends IResource>) 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<T> implements IClientResponseHandler<T>
|
|||
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<T> implements IClientResponseHandler<T>
|
|||
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<T> implements IClientResponseHandler<T>
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see BaseMethodBinding#loadRequestContents(RequestDetails)
|
||||
*/
|
||||
private static volatile IRequestReader ourRequestReader;
|
||||
|
||||
|
||||
/**
|
||||
* @see BaseMethodBinding#loadRequestContents(RequestDetails)
|
||||
*/
|
||||
|
@ -601,18 +603,16 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
/**
|
||||
* @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) {
|
||||
|
|
|
@ -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 <i>mod_proxy</i> isn't configured to supply <i>x-forwarded-proto</i>, the factory method that you use
|
||||
* to create the address strategy will determine the default. Note that <i>mod_proxy</i> doesn't set this by default, but it can be
|
||||
* configured via <i>RequestHeader set X-Forwarded-Proto http</i> (or https)
|
||||
* If the Apache Http Server <i>mod_proxy</i> isn't configured to supply <i>x-forwarded-proto</i>, the factory method that you use to create the address strategy will determine the default. Note that
|
||||
* <i>mod_proxy</i> doesn't set this by default, but it can be configured via <i>RequestHeader set X-Forwarded-Proto http</i> (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 <i>protocol</i>.
|
||||
* If you want to set the protocol based on something other than the constructor argument, you should be able to do so by overriding <i>protocol</i>.
|
||||
*
|
||||
* 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 <i>x-forwarded-host</i>
|
||||
* 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 <i>x-forwarded-host</i>
|
||||
*
|
||||
* 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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,22 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<!--
|
||||
The parent of this project is the deployable POM. This project isn't deployable,
|
||||
but this keeps it before the root pom in the reactor order when building the site.
|
||||
I don't know why this works... Need to investigate this.
|
||||
-->
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-cobertura</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HAPI FHIR - Consolidated Test Project</name>
|
||||
<name>HAPI FHIR - Cobertura Test Coverage</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -70,13 +75,6 @@
|
|||
<version>${logback_version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>java-hamcrest</artifactId>
|
||||
<version>${hamcrest_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Test Database -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -122,12 +120,6 @@
|
|||
<version>${jetty_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
|
@ -371,7 +363,7 @@
|
|||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<!--<plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>${maven_cobertura_plugin_version}</version>
|
||||
|
@ -382,7 +374,7 @@
|
|||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>-->
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
|
|
|
@ -275,12 +275,6 @@
|
|||
<version>${jetty_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty_version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
|
|
5
pom.xml
5
pom.xml
|
@ -457,6 +457,11 @@
|
|||
<configLocation>file://${project.basedir}/src/checkstyle/checkstyle.xml</configLocation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
|
|
|
@ -76,7 +76,9 @@
|
|||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<!--
|
||||
<module name="MissingSwitchDefault"/>
|
||||
-->
|
||||
<module name="FallThrough"/>
|
||||
<module name="UpperEll"/>
|
||||
<module name="ModifierOrder"/>
|
||||
|
@ -141,7 +143,7 @@
|
|||
<module name="Indentation">
|
||||
<property name="basicOffset" value="3"/>
|
||||
<property name="braceAdjustment" value="0"/>
|
||||
<property name="caseIndent" value="3"/>
|
||||
<property name="caseIndent" value="0"/>
|
||||
<property name="throwsIndent" value="6"/>
|
||||
<property name="lineWrappingIndentation" value="6"/>
|
||||
<property name="arrayInitIndent" value="3"/>
|
||||
|
|
Loading…
Reference in New Issue