Clean up warnings

This commit is contained in:
James Agnew 2015-06-24 12:26:40 -04:00
parent e616fc85d3
commit dd9f80ecb1
10 changed files with 297 additions and 334 deletions

View File

@ -160,7 +160,7 @@
<version>${junit_version}</version> <version>${junit_version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
@ -180,25 +180,11 @@
<id>SITE</id> <id>SITE</id>
<reporting> <reporting>
<plugins> <plugins>
<!-- <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId>
<plugin> <reportSets> <reportSet> <reports> <report>checkstyle</report> </reports>
<groupId>org.apache.maven.plugins</groupId> </reportSet> </reportSets> <configuration> <linkXRef>false</linkXRef> <sourceDirectories>
<artifactId>maven-checkstyle-plugin</artifactId> <sourceDirectory>hapi-fhir-base/src/main/java</sourceDirectory> </sourceDirectories>
<reportSets> </configuration> </plugin> -->
<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> <!--<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version> <configuration> </configuration> </plugin> --> <version>3.0.0</version> <configuration> </configuration> </plugin> -->
<plugin> <plugin>
@ -224,26 +210,23 @@
</plugin> --> </plugin> -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<reportSets> <reportSets>
<reportSet> <reportSet>
<reports> <reports>
<report>checkstyle</report> <report>checkstyle</report>
</reports> </reports>
</reportSet> </reportSet>
</reportSets> </reportSets>
<configuration> <configuration>
<linkXRef>false</linkXRef> <linkXRef>false</linkXRef>
<configLocation>file://${project.basedir}/../src/checkstyle/checkstyle.xml</configLocation> <configLocation>file://${project.basedir}/../src/checkstyle/checkstyle.xml</configLocation>
<!--<sourceDirectories> <!--<sourceDirectories> <sourceDirectory> ${project.basedir}/../hapi-fhir-base/src/main/java
<sourceDirectory> </sourceDirectory> </sourceDirectories> -->
${project.basedir}/../hapi-fhir-base/src/main/java </configuration>
</sourceDirectory> </plugin>
</sourceDirectories>-->
</configuration>
</plugin>
</plugins> </plugins>

View File

@ -30,29 +30,30 @@ import ca.uhn.fhir.model.api.annotation.Description;
public class RuntimeChildEnumerationDatatypeDefinition extends RuntimeChildPrimitiveDatatypeDefinition { public class RuntimeChildEnumerationDatatypeDefinition extends RuntimeChildPrimitiveDatatypeDefinition {
private Class<? extends IBaseEnumFactory<?>> myBinderType; private Class<? extends IBaseEnumFactory<?>> myBinderType;
private volatile IBaseEnumFactory<?> myBinder; private volatile IBaseEnumFactory<?> myBinder;
public RuntimeChildEnumerationDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype, Class<? extends IBaseEnumFactory<?>> theBinderType) { public RuntimeChildEnumerationDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype,
super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype); Class<? extends IBaseEnumFactory<?>> theBinderType) {
super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype);
myBinderType = theBinderType; myBinderType = theBinderType;
} }
@Override @Override
public IBaseEnumFactory<?> getInstanceConstructorArguments() { public IBaseEnumFactory<?> getInstanceConstructorArguments() {
IBaseEnumFactory<?> retVal = myBinder; IBaseEnumFactory<?> retVal = myBinder;
if (retVal == null) { if (retVal == null) {
try { try {
retVal = myBinderType.newInstance(); retVal = myBinderType.newInstance();
} catch (InstantiationException e) { } catch (InstantiationException e) {
throw new IllegalStateException("Failed to instantiate " + myBinderType, e); throw new IllegalStateException("Failed to instantiate " + myBinderType, e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new IllegalStateException("Failed to instantiate " + myBinderType, e); throw new IllegalStateException("Failed to instantiate " + myBinderType, e);
} }
myBinder = retVal; myBinder = retVal;
} }
return retVal; return retVal;
} }
} }

View File

@ -62,8 +62,8 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
private static final FastDateFormat ourYearMonthFormat = FastDateFormat.getInstance("yyyy-MM"); private static final FastDateFormat ourYearMonthFormat = FastDateFormat.getInstance("yyyy-MM");
private static final FastDateFormat ourYearMonthNoDashesFormat = FastDateFormat.getInstance("yyyyMM"); private static final FastDateFormat ourYearMonthNoDashesFormat = FastDateFormat.getInstance("yyyyMM");
private static final FastDateFormat ourHumanDateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM); private static final FastDateFormat ourHumanDateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM);
private static final FastDateFormat ourHumanDateFormat = FastDateFormat.getDateInstance(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 Pattern ourYearMonthPattern = Pattern.compile("[0-9]{4}[0-9]{2}");
private static final Pattern ourYearPattern = Pattern.compile("[0-9]{4}"); private static final Pattern ourYearPattern = Pattern.compile("[0-9]{4}");
static { static {
@ -88,55 +88,50 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
private boolean myTimeZoneZulu = false; private boolean myTimeZoneZulu = false;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseDateTimeDt.class); 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. * Returns a human readable version of this date/time using the system local format.
* <p> * <p>
* <b>Note on time zones:</b> This method renders the value using the time zone * <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",
* that is contained within the value. For example, if this date object contains the * 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
* value "2012-01-05T12:00:00-08:00", the human display will be rendered as "12:00:00" * {@link #toHumanDisplayLocalTimezone()} instead.
* even if the application is being executed on a system in a different time zone. If * </p>
* this behaviour is not what you want, use {@link #toHumanDisplayLocalTimezone()} */
* instead. public String toHumanDisplay() {
* </p> TimeZone tz = getTimeZone();
*/ Calendar value = tz != null ? Calendar.getInstance(tz) : Calendar.getInstance();
public String toHumanDisplay() { value.setTime(getValue());
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());
}
}
/** 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 * Constructor
*/ */
public BaseDateTimeDt() { public BaseDateTimeDt() {
@ -147,7 +142,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
* Constructor * Constructor
* *
* @throws DataFormatException * @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) { public BaseDateTimeDt(Date theDate, TemporalPrecisionEnum thePrecision) {
setValue(theDate, thePrecision); setValue(theDate, thePrecision);
@ -160,7 +155,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
* Constructor * Constructor
* *
* @throws DataFormatException * @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) { public BaseDateTimeDt(String theString) {
setValueAsString(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 * Returns the TimeZone associated with this dateTime's value. May return <code>null</code> if no timezone was supplied.
* supplied.
*/ */
public TimeZone getTimeZone() { public TimeZone getTimeZone() {
return myTimeZone; 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 * Returns <code>true</code> if this object represents a date that is today's date
* *
* @throws NullPointerException * @throws NullPointerException
* if {@link #getValue()} returns <code>null</code> * if {@link #getValue()} returns <code>null</code>
*/ */
public boolean isToday() { public boolean isToday() {
Validate.notNull(getValue(), getClass().getSimpleName() + " contains null value"); 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 * 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
* default precision for this datatype, as well as the local timezone as determined by the * system. Both of these properties may be modified in subsequent calls if neccesary.
* local operating system. Both of these properties may be modified in subsequent calls
* if neccesary.
*/ */
@Override @Override
public BaseDateTimeDt setValue(Date theValue) { 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 * 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
* specified precision, as well as the local timezone as determined by the * these properties may be modified in subsequent calls if neccesary.
* local operating system. Both of these properties may be modified in subsequent calls
* if neccesary.
* *
* @param theValue * @param theValue
* The date value * The date value
* @param thePrecision * @param thePrecision
* The precision * The precision
* @throws DataFormatException * @throws DataFormatException
*/ */
public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException { public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException {

View File

@ -105,8 +105,8 @@ class ParserState<T> {
myState.endingElement(); myState.endingElement();
} }
public void enteringNewElement(String theNamespaceURI, String theName) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theName) throws DataFormatException {
myState.enteringNewElement(theNamespaceURI, theName); myState.enteringNewElement(theNamespaceUri, theName);
} }
public void enteringNewElementExtension(StartElement theElem, String theUrlAttr, boolean theIsModifier) { 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 * Invoked after any new XML event is individually processed, containing a copy of the XML event. This is basically intended for embedded XHTML content
* intended for embedded XHTML content
*/ */
public void xmlEvent(XMLEvent theNextEvent) { public void xmlEvent(XMLEvent theNextEvent) {
myState.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); ParserState<Bundle> retVal = new ParserState<Bundle>(theContext, theJsonMode, theErrorHandler);
if (theContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) { if (theContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
retVal.push(retVal.new PreAtomState(theResourceType)); retVal.push(retVal.new PreAtomState(theResourceType));
@ -227,7 +227,8 @@ class ParserState<T> {
* @param theResourceType * @param theResourceType
* May be null * 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); ParserState<T> retVal = new ParserState<T>(theContext, theJsonMode, theErrorHandler);
if (theResourceType == null) { if (theResourceType == null) {
if (theContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) { if (theContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) {
@ -266,7 +267,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("name".equals(theLocalPart)) { if ("name".equals(theLocalPart)) {
push(new AtomPrimitiveState(myInstance.getAuthorName())); push(new AtomPrimitiveState(myInstance.getAuthorName()));
} else if ("uri".equals(theLocalPart)) { } else if ("uri".equals(theLocalPart)) {
@ -306,8 +307,7 @@ class ParserState<T> {
myScheme = theValue; myScheme = theValue;
} else if ("value".equals(theName)) { } else if ("value".equals(theName)) {
/* /*
* This handles XML parsing, which is odd for this quasi-resource type, since the tag has three values * This handles XML parsing, which is odd for this quasi-resource type, since the tag has three values instead of one like everything else.
* instead of one like everything else.
*/ */
switch (myCatState) { switch (myCatState) {
case STATE_LABEL: case STATE_LABEL:
@ -340,7 +340,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theName) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theName) throws DataFormatException {
if (myCatState != STATE_NONE) { if (myCatState != STATE_NONE) {
throw new DataFormatException("Unexpected element in entry: " + theName); throw new DataFormatException("Unexpected element in entry: " + theName);
} }
@ -370,7 +370,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("name".equals(theLocalPart)) { if ("name".equals(theLocalPart)) {
push(new AtomPrimitiveState(myEntry.getDeletedByName())); push(new AtomPrimitiveState(myEntry.getDeletedByName()));
} else if ("email".equals(theLocalPart)) { } else if ("email".equals(theLocalPart)) {
@ -404,13 +404,13 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("by".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, theNamespaceURI)) { if ("by".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, theNamespaceUri)) {
push(new AtomDeletedEntryByState(getEntry())); push(new AtomDeletedEntryByState(getEntry()));
} else if ("comment".equals(theLocalPart)) { } else if ("comment".equals(theLocalPart)) {
push(new AtomPrimitiveState(getEntry().getDeletedComment())); push(new AtomPrimitiveState(getEntry().getDeletedComment()));
} else { } else {
super.enteringNewElement(theNamespaceURI, theLocalPart); super.enteringNewElement(theNamespaceUri, theLocalPart);
} }
} }
@ -439,7 +439,7 @@ class ParserState<T> {
} }
@Override @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); throw new DataFormatException("Unexpected nested element in atom tag: " + theLocalPart);
} }
@ -474,7 +474,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("title".equals(theLocalPart)) { if ("title".equals(theLocalPart)) {
push(new AtomPrimitiveState(myEntry.getTitle())); push(new AtomPrimitiveState(myEntry.getTitle()));
} else if ("id".equals(theLocalPart)) { } else if ("id".equals(theLocalPart)) {
@ -610,7 +610,7 @@ class ParserState<T> {
} }
@Override @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>"); throw new DataFormatException("Found unexpected element content '" + theLocalPart + "' within <link>");
} }
@ -642,7 +642,7 @@ class ParserState<T> {
} }
@Override @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); throw new DataFormatException("Unexpected nested element in atom tag: " + theLocalPart);
} }
@ -681,8 +681,8 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("entry".equals(theLocalPart) && verifyNamespace(XmlParser.ATOM_NS, theNamespaceURI)) { if ("entry".equals(theLocalPart) && verifyNamespace(XmlParser.ATOM_NS, theNamespaceUri)) {
push(new AtomEntryState(myInstance, myResourceType)); push(new AtomEntryState(myInstance, myResourceType));
} else if (theLocalPart.equals("title")) { } else if (theLocalPart.equals("title")) {
push(new AtomPrimitiveState(myInstance.getTitle())); push(new AtomPrimitiveState(myInstance.getTitle()));
@ -690,7 +690,7 @@ class ParserState<T> {
push(new AtomPrimitiveState(myInstance.getBundleId())); push(new AtomPrimitiveState(myInstance.getBundleId()));
} else if ("link".equals(theLocalPart)) { } else if ("link".equals(theLocalPart)) {
push(new AtomLinkState(myInstance)); 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())); push(new AtomPrimitiveState(myInstance.getTotalResults()));
} else if ("updated".equals(theLocalPart)) { } else if ("updated".equals(theLocalPart)) {
push(new AtomPrimitiveState(myInstance.getUpdated())); push(new AtomPrimitiveState(myInstance.getUpdated()));
@ -698,11 +698,11 @@ class ParserState<T> {
push(new AtomAuthorState(myInstance)); push(new AtomAuthorState(myInstance));
} else if ("category".equals(theLocalPart)) { } else if ("category".equals(theLocalPart)) {
push(new AtomCategoryState(myInstance.getCategories())); 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)); push(new AtomDeletedEntryState(myInstance, myResourceType));
} else { } else {
if (theNamespaceURI != null) { if (theNamespaceUri != null) {
throw new DataFormatException("Unexpected element: {" + theNamespaceURI + "}" + theLocalPart); throw new DataFormatException("Unexpected element: {" + theNamespaceUri + "}" + theLocalPart);
} else { } else {
throw new DataFormatException("Unexpected element: " + theLocalPart); throw new DataFormatException("Unexpected element: " + theLocalPart);
} }
@ -802,7 +802,7 @@ class ParserState<T> {
// ignore by default // 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); myErrorHandler.unknownElement(null, theLocalPart);
} }
@ -927,7 +927,7 @@ class ParserState<T> {
} }
@Override @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) { if (myJsonMode && "contentType".equals(theLocalPart) && mySubState == 0) {
mySubState = SUBSTATE_CT; mySubState = SUBSTATE_CT;
} else if (myJsonMode && "content".equals(theLocalPart) && mySubState == 0) { } else if (myJsonMode && "content".equals(theLocalPart) && mySubState == 0) {
@ -975,7 +975,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("type".equals(theLocalPart)) { if ("type".equals(theLocalPart)) {
push(new PrimitiveState(getPreResourceState(), myEntry.getDeletedResourceType())); push(new PrimitiveState(getPreResourceState(), myEntry.getDeletedResourceType()));
} else if ("id".equals(theLocalPart)) { } else if ("id".equals(theLocalPart)) {
@ -1010,7 +1010,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("mode".equals(theLocalPart)) { if ("mode".equals(theLocalPart)) {
push(new PrimitiveState(getPreResourceState(), myEntry.getSearchMode())); push(new PrimitiveState(getPreResourceState(), myEntry.getSearchMode()));
} else if ("score".equals(theLocalPart)) { } else if ("score".equals(theLocalPart)) {
@ -1041,7 +1041,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("base".equals(theLocalPart)) { if ("base".equals(theLocalPart)) {
push(new PrimitiveState(getPreResourceState(), myEntry.getLinkBase())); push(new PrimitiveState(getPreResourceState(), myEntry.getLinkBase()));
} else if ("transaction".equals(theLocalPart)) { } else if ("transaction".equals(theLocalPart)) {
@ -1135,7 +1135,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("method".equals(theLocalPart)) { if ("method".equals(theLocalPart)) {
push(new PrimitiveState(getPreResourceState(), myEntry.getTransactionMethod())); push(new PrimitiveState(getPreResourceState(), myEntry.getTransactionMethod()));
} else if ("url".equals(theLocalPart)) { } else if ("url".equals(theLocalPart)) {
@ -1210,7 +1210,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if (myInRelation || myInUrl) { if (myInRelation || myInUrl) {
throw new DataFormatException("Unexpected element '" + theLocalPart + "' in element 'link'"); throw new DataFormatException("Unexpected element '" + theLocalPart + "' in element 'link'");
} }
@ -1242,7 +1242,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if ("id".equals(theLocalPart)) { if ("id".equals(theLocalPart)) {
push(new PrimitiveState(null, myInstance.getId())); push(new PrimitiveState(null, myInstance.getId()));
} else if ("meta".equals(theLocalPart)) { } else if ("meta".equals(theLocalPart)) {
@ -1263,7 +1263,7 @@ class ParserState<T> {
throw new DataFormatException("Unxpected element '" + theLocalPart + "' in element 'Bundle'"); 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)); // push(new AtomEntryState(myInstance, myResourceType));
// } else if (theLocalPart.equals("published")) { // } else if (theLocalPart.equals("published")) {
// push(new AtomPrimitiveState(myInstance.getPublished())); // push(new AtomPrimitiveState(myInstance.getPublished()));
@ -1274,7 +1274,7 @@ class ParserState<T> {
// } else if ("link".equals(theLocalPart)) { // } else if ("link".equals(theLocalPart)) {
// push(new AtomLinkState(myInstance)); // push(new AtomLinkState(myInstance));
// } else if ("totalResults".equals(theLocalPart) && (verifyNamespace(XmlParser.OPENSEARCH_NS, // } 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())); // push(new AtomPrimitiveState(myInstance.getTotalResults()));
// } else if ("updated".equals(theLocalPart)) { // } else if ("updated".equals(theLocalPart)) {
// push(new AtomPrimitiveState(myInstance.getUpdated())); // push(new AtomPrimitiveState(myInstance.getUpdated()));
@ -1283,11 +1283,11 @@ class ParserState<T> {
// } else if ("category".equals(theLocalPart)) { // } else if ("category".equals(theLocalPart)) {
// push(new AtomCategoryState(myInstance.getCategories())); // push(new AtomCategoryState(myInstance.getCategories()));
// } else if ("deleted-entry".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS, // } else if ("deleted-entry".equals(theLocalPart) && verifyNamespace(XmlParser.TOMBSTONES_NS,
// theNamespaceURI)) { // theNamespaceUri)) {
// push(new AtomDeletedEntryState(myInstance, myResourceType)); // push(new AtomDeletedEntryState(myInstance, myResourceType));
// } else { // } else {
// if (theNamespaceURI != null) { // if (theNamespaceUri != null) {
// throw new DataFormatException("Unexpected element: {" + theNamespaceURI + "}" + theLocalPart); // throw new DataFormatException("Unexpected element: {" + theNamespaceUri + "}" + theLocalPart);
// } else { // } else {
// throw new DataFormatException("Unexpected element: " + theLocalPart); // throw new DataFormatException("Unexpected element: " + theLocalPart);
// } // }
@ -1428,7 +1428,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
BaseRuntimeElementDefinition<?> target = myDefinition.getChildByName(theLocalPart); BaseRuntimeElementDefinition<?> target = myDefinition.getChildByName(theLocalPart);
if (target == null) { if (target == null) {
myErrorHandler.unknownElement(null, theLocalPart); myErrorHandler.unknownElement(null, theLocalPart);
@ -1544,8 +1544,7 @@ class ParserState<T> {
child = myDefinition.getChildByNameOrThrowDataFormatException(theChildName); child = myDefinition.getChildByNameOrThrowDataFormatException(theChildName);
} catch (DataFormatException e) { } catch (DataFormatException e) {
/* /*
* This means we've found an element that doesn't exist on the structure. If the error handler doesn't * 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
* throw an exception, swallow the element silently along with any child elements
*/ */
myErrorHandler.unknownElement(null, theChildName); myErrorHandler.unknownElement(null, theChildName);
push(new SwallowChildrenWholeState(getPreResourceState())); push(new SwallowChildrenWholeState(getPreResourceState()));
@ -1691,7 +1690,7 @@ class ParserState<T> {
} }
@Override @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); BaseRuntimeElementDefinition<?> target = myContext.getRuntimeChildUndeclaredExtensionDefinition().getChildByName(theLocalPart);
if (target == null) { if (target == null) {
myErrorHandler.unknownElement(null, theLocalPart); myErrorHandler.unknownElement(null, theLocalPart);
@ -1775,7 +1774,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if (theLocalPart.equals("versionId")) { if (theLocalPart.equals("versionId")) {
push(new MetaVersionElementState(getPreResourceState(), myMap)); push(new MetaVersionElementState(getPreResourceState(), myMap));
// } else if (theLocalPart.equals("profile")) { // } else if (theLocalPart.equals("profile")) {
@ -1841,7 +1840,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
myErrorHandler.unknownElement(null, theLocalPart); myErrorHandler.unknownElement(null, theLocalPart);
push(new SwallowChildrenWholeState(getPreResourceState())); push(new SwallowChildrenWholeState(getPreResourceState()));
return; return;
@ -1861,7 +1860,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if (!"feed".equals(theLocalPart)) { if (!"feed".equals(theLocalPart)) {
throw new DataFormatException("Expecting outer element called 'feed', found: " + theLocalPart); throw new DataFormatException("Expecting outer element called 'feed', found: " + theLocalPart);
} }
@ -1885,7 +1884,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
if (!"Bundle".equals(theLocalPart)) { if (!"Bundle".equals(theLocalPart)) {
throw new DataFormatException("Expecting outer element called 'Bundle', found: " + theLocalPart); throw new DataFormatException("Expecting outer element called 'Bundle', found: " + theLocalPart);
} }
@ -1940,8 +1939,8 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
super.enteringNewElement(theNamespaceURI, theLocalPart); super.enteringNewElement(theNamespaceUri, theLocalPart);
if (myEntry != null) { if (myEntry != null) {
myEntry.setResource((IResource) getCurrentElement()); myEntry.setResource((IResource) getCurrentElement());
} }
@ -1990,8 +1989,8 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
super.enteringNewElement(theNamespaceURI, theLocalPart); super.enteringNewElement(theNamespaceUri, theLocalPart);
if (myMutator != null) { if (myMutator != null) {
myMutator.addValue(myTarget, getCurrentElement()); myMutator.addValue(myTarget, getCurrentElement());
} }
@ -2034,7 +2033,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
BaseRuntimeElementDefinition<?> definition; BaseRuntimeElementDefinition<?> definition;
if (myResourceType == null) { if (myResourceType == null) {
definition = myContext.getResourceDefinition(myParentVersion, theLocalPart); definition = myContext.getResourceDefinition(myParentVersion, theLocalPart);
@ -2043,7 +2042,7 @@ class ParserState<T> {
} }
} else { } else {
definition = myContext.getResourceDefinition(myResourceType); definition = myContext.getResourceDefinition(myResourceType);
if (!StringUtils.equals(theLocalPart, definition.getName())) { if (!StringUtils.equals(theLocalPart, definition.getName())) {
if (myRequireResourceType) { if (myRequireResourceType) {
throw new DataFormatException(myContext.getLocalizer().getMessage(ParserState.class, "wrongResourceTypeFound", definition.getName(), theLocalPart)); throw new DataFormatException(myContext.getLocalizer().getMessage(ParserState.class, "wrongResourceTypeFound", definition.getName(), theLocalPart));
} }
@ -2128,7 +2127,8 @@ class ParserState<T> {
} }
@Override @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); acceptElement(theNextExt.getValue(), null, null, null);
} }
}); });
@ -2181,7 +2181,7 @@ class ParserState<T> {
} }
@Override @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())) { if (!TagList.ELEMENT_NAME_LC.equals(theLocalPart.toLowerCase())) {
throw new DataFormatException("resourceType does not appear to be 'TagList', found: " + theLocalPart); throw new DataFormatException("resourceType does not appear to be 'TagList', found: " + theLocalPart);
} }
@ -2251,7 +2251,7 @@ class ParserState<T> {
// } // }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
myErrorHandler.unknownElement(null, theLocalPart); myErrorHandler.unknownElement(null, theLocalPart);
push(new SwallowChildrenWholeState(getPreResourceState())); push(new SwallowChildrenWholeState(getPreResourceState()));
return; return;
@ -2306,7 +2306,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
switch (mySubState) { switch (mySubState) {
case INITIAL: case INITIAL:
if ("display".equals(theLocalPart)) { if ("display".equals(theLocalPart)) {
@ -2375,7 +2375,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
switch (mySubState) { switch (mySubState) {
case INITIAL: case INITIAL:
if ("display".equals(theLocalPart)) { if ("display".equals(theLocalPart)) {
@ -2457,7 +2457,7 @@ class ParserState<T> {
} }
@Override @Override
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException { public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException {
myDepth++; myDepth++;
} }
@ -2488,7 +2488,7 @@ class ParserState<T> {
} }
@Override @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)) { if (TagList.ATTR_CATEGORY.equals(theLocalPart)) {
push(new TagState(myTagList)); push(new TagState(myTagList));
} else { } else {
@ -2552,7 +2552,7 @@ class ParserState<T> {
} }
@Override @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 * We allow for both the DSTU1 and DSTU2 names here
*/ */
@ -2606,7 +2606,7 @@ class ParserState<T> {
} }
@Override @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 // IGNORE - don't handle this as an error, we process these as XML events
} }

View File

@ -163,11 +163,11 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
return retVal; return retVal;
} }
public Method getMethod() { public Method getMethod() {
return myMethod; return myMethod;
} }
public OtherOperationTypeEnum getOtherOperationType() { public OtherOperationTypeEnum getOtherOperationType() {
return null; return null;
} }
@ -181,42 +181,42 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
public Set<Include> getRequestIncludesFromParams(Object[] params) { public Set<Include> getRequestIncludesFromParams(Object[] params) {
if (params == null || params.length == 0) if (params == null || params.length == 0) {
return null; return null;
int index = 0; }
boolean match = false; int index = 0;
for (IParameter parameter : myParameters) { boolean match = false;
if (parameter instanceof IncludeParameter) { for (IParameter parameter : myParameters) {
match = true; if (parameter instanceof IncludeParameter) {
break; match = true;
} break;
index++; }
} index++;
if (!match) }
return null; if (!match)
if (index >= params.length) { return null;
ourLog.warn("index out of parameter range (should never happen"); if (index >= params.length) {
return null; 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 Set) {
} return (Set<Include>) params[index];
if (params[index] instanceof Iterable) { }
Set includes = new HashSet<Include>(); if (params[index] instanceof Iterable) {
for (Object o : (Iterable)params[index]) { Set includes = new HashSet<Include>();
if (o instanceof Include) { for (Object o : (Iterable) params[index]) {
includes.add(o); if (o instanceof Include) {
} includes.add(o);
} }
return includes; }
} return includes;
ourLog.warn("include params wasn't Set or Iterable, it was {}", params[index].getClass()); }
return null; 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 * Returns the name of the resource this method handles, or <code>null</code> if this method is not resource specific
* specific
*/ */
public abstract String getResourceName(); public abstract String getResourceName();
@ -266,12 +266,9 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
protected byte[] loadRequestContents(RequestDetails theRequest) throws IOException { protected byte[] loadRequestContents(RequestDetails theRequest) throws IOException {
/* /*
* This is weird, but this class is used both in clients and in servers, and * 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
* we want to avoid needing to depend on servlet-api in clients since there is * 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
* no point. So we dynamically load a class that does the servlet processing in * don't think.
* 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; IRequestReader reader = ourRequestReader;
if (reader == null) { if (reader == null) {
@ -293,7 +290,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
} }
ourRequestReader = reader; ourRequestReader = reader;
} }
InputStream inputStream = reader.getInputStream(theRequest); InputStream inputStream = reader.getInputStream(theRequest);
byte[] requestContents = IOUtils.toByteArray(inputStream); byte[] requestContents = IOUtils.toByteArray(inputStream);
return requestContents; return requestContents;
@ -336,7 +333,7 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
public void setParameters(List<IParameter> theParameters) { public void setParameters(List<IParameter> theParameters) {
myParameters = theParameters; myParameters = theParameters;
} }
protected IBundleProvider toResourceList(Object response) throws InternalErrorException { protected IBundleProvider toResourceList(Object response) throws InternalErrorException {
if (response == null) { if (response == null) {
return BundleProviders.newEmptyList(); return BundleProviders.newEmptyList();
@ -388,14 +385,16 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
if (theProvider instanceof IResourceProvider) { if (theProvider instanceof IResourceProvider) {
returnTypeFromRp = ((IResourceProvider) theProvider).getResourceType(); returnTypeFromRp = ((IResourceProvider) theProvider).getResourceType();
if (!verifyIsValidResourceReturnType(returnTypeFromRp)) { 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(); Class<?> returnTypeFromMethod = theMethod.getReturnType();
if (getTags != null) { if (getTags != null) {
if (!TagList.class.equals(returnTypeFromMethod)) { 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)) { } else if (MethodOutcome.class.equals(returnTypeFromMethod)) {
// returns a method outcome // returns a method outcome
@ -408,13 +407,15 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
} else if (Collection.class.isAssignableFrom(returnTypeFromMethod)) { } else if (Collection.class.isAssignableFrom(returnTypeFromMethod)) {
returnTypeFromMethod = ReflectionUtil.getGenericCollectionTypeOfMethodReturnType(theMethod); returnTypeFromMethod = ReflectionUtil.getGenericCollectionTypeOfMethodReturnType(theMethod);
if (!verifyIsValidResourceReturnType(returnTypeFromMethod) && !IResource.class.equals(returnTypeFromMethod)) { 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> )"); + " - Must return a resource type or a collection (List, Set) with a resource type parameter (e.g. List<Patient> or List<IResource> )");
} }
} else { } else {
if (!IResource.class.equals(returnTypeFromMethod) && !verifyIsValidResourceReturnType(returnTypeFromMethod)) { if (!IResource.class.equals(returnTypeFromMethod) && !verifyIsValidResourceReturnType(returnTypeFromMethod)) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returns " + toLogString(returnTypeFromMethod) throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName()
+ " - Must return a resource type (eg Patient, " + Bundle.class.getSimpleName() + ", " + IBundleProvider.class.getSimpleName() + ", etc., see the documentation for more details)"); + " 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 (returnTypeFromRp != null) {
if (returnTypeFromAnnotation != null && returnTypeFromAnnotation != IResource.class) { if (returnTypeFromAnnotation != null && returnTypeFromAnnotation != IResource.class) {
if (!returnTypeFromRp.isAssignableFrom(returnTypeFromAnnotation)) { if (!returnTypeFromRp.isAssignableFrom(returnTypeFromAnnotation)) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " returns type " + returnTypeFromMethod.getCanonicalName() + " - Must return " + returnTypeFromRp.getCanonicalName() throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " returns type "
+ " (or a subclass of it) per IResourceProvider contract"); + returnTypeFromMethod.getCanonicalName() + " - Must return " + returnTypeFromRp.getCanonicalName() + " (or a subclass of it) per IResourceProvider contract");
} }
if (!returnTypeFromRp.isAssignableFrom(returnTypeFromAnnotation)) { 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 " throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " claims to return type "
+ returnTypeFromRp.getCanonicalName() + " (or a subclass of it) per IResourceProvider contract"); + returnTypeFromAnnotation.getCanonicalName() + " per method annotation - Must return " + returnTypeFromRp.getCanonicalName()
+ " (or a subclass of it) per IResourceProvider contract");
} }
returnType = returnTypeFromAnnotation; returnType = returnTypeFromAnnotation;
} else { } else {
@ -458,19 +460,19 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
} else { } else {
if (returnTypeFromAnnotation != IResource.class) { if (returnTypeFromAnnotation != IResource.class) {
if (!verifyIsValidResourceReturnType(returnTypeFromAnnotation)) { if (!verifyIsValidResourceReturnType(returnTypeFromAnnotation)) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returns " + toLogString(returnTypeFromAnnotation) throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName()
+ " according to annotation - Must return a resource type"); + " returns " + toLogString(returnTypeFromAnnotation) + " according to annotation - Must return a resource type");
} }
returnType = returnTypeFromAnnotation; returnType = returnTypeFromAnnotation;
} else { } else {
//if (IRestfulClient.class.isAssignableFrom(theMethod.getDeclaringClass())) { // if (IRestfulClient.class.isAssignableFrom(theMethod.getDeclaringClass())) {
// Clients don't define their methods in resource specific types, so they can // Clients don't define their methods in resource specific types, so they can
// infer their resource type from the method return type. // infer their resource type from the method return type.
returnType = (Class<? extends IResource>) returnTypeFromMethod; returnType = (Class<? extends IResource>) returnTypeFromMethod;
// } else { // } else {
// This is a plain provider method returning a resource, so it should be // This is a plain provider method returning a resource, so it should be
// an operation or global search presumably // 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 false;
} }
return true; return true;
// boolean retVal = Modifier.isAbstract(theReturnType.getModifiers()) == false; // boolean retVal = Modifier.isAbstract(theReturnType.getModifiers()) == false;
// return retVal; // return retVal;
} }
public static boolean verifyMethodHasZeroOrOneOperationAnnotation(Method theNextMethod, Object... theAnnotations) { public static boolean verifyMethodHasZeroOrOneOperationAnnotation(Method theNextMethod, Object... theAnnotations) {
@ -570,8 +572,8 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
if (obj1 == null) { if (obj1 == null) {
obj1 = object; obj1 = object;
} else { } else {
throw new ConfigurationException("Method " + theNextMethod.getName() + " on type '" + theNextMethod.getDeclaringClass().getSimpleName() + " has annotations @" + obj1.getClass().getSimpleName() + " and @" + object.getClass().getSimpleName() throw new ConfigurationException("Method " + theNextMethod.getName() + " on type '" + theNextMethod.getDeclaringClass().getSimpleName() + " has annotations @"
+ ". Can not have both."); + 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; return true;
} }
/** /**
* @see BaseMethodBinding#loadRequestContents(RequestDetails) * @see BaseMethodBinding#loadRequestContents(RequestDetails)
*/ */
private static volatile IRequestReader ourRequestReader; private static volatile IRequestReader ourRequestReader;
/** /**
* @see BaseMethodBinding#loadRequestContents(RequestDetails) * @see BaseMethodBinding#loadRequestContents(RequestDetails)
*/ */
@ -601,18 +603,16 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
/** /**
* @see BaseMethodBinding#loadRequestContents(RequestDetails) * @see BaseMethodBinding#loadRequestContents(RequestDetails)
*/ */
@SuppressWarnings("unused")
static class ActiveRequestReader implements IRequestReader { static class ActiveRequestReader implements IRequestReader {
@Override @Override
public InputStream getInputStream(RequestDetails theRequestDetails) throws IOException { public InputStream getInputStream(RequestDetails theRequestDetails) throws IOException {
return theRequestDetails.getServletRequest().getInputStream(); return theRequestDetails.getServletRequest().getInputStream();
} }
} }
/** /**
* @see BaseMethodBinding#loadRequestContents(RequestDetails) * @see BaseMethodBinding#loadRequestContents(RequestDetails)
*/ */
@SuppressWarnings("unused")
static class InactiveRequestReader implements IRequestReader { static class InactiveRequestReader implements IRequestReader {
@Override @Override
public InputStream getInputStream(RequestDetails theRequestDetails) { public InputStream getInputStream(RequestDetails theRequestDetails) {

View File

@ -24,72 +24,68 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
/** /**
* Works like the normal {@link ca.uhn.fhir.rest.server.IncomingRequestAddressStrategy} unless there's an * 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.
* 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 * 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
* 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 * <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)
* 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 * 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>.
* 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 * 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>
* any proxy server that sets <i>x-forwarded-host</i>
* *
* Created by Bill de Beaubien on 3/30/2015. * Created by Bill de Beaubien on 3/30/2015.
*/ */
public class ApacheProxyAddressStrategy extends IncomingRequestAddressStrategy { public class ApacheProxyAddressStrategy extends IncomingRequestAddressStrategy {
private boolean myUseHttps = false; private boolean myUseHttps = false;
protected ApacheProxyAddressStrategy(boolean theUseHttps) { protected ApacheProxyAddressStrategy(boolean theUseHttps) {
myUseHttps = theUseHttps; myUseHttps = theUseHttps;
} }
public static ApacheProxyAddressStrategy forHttp() { public static ApacheProxyAddressStrategy forHttp() {
return new ApacheProxyAddressStrategy(false); return new ApacheProxyAddressStrategy(false);
} }
public static ApacheProxyAddressStrategy forHttps() { public static ApacheProxyAddressStrategy forHttps() {
return new ApacheProxyAddressStrategy(true); return new ApacheProxyAddressStrategy(true);
} }
@Override @Override
public String determineServerBase(ServletContext theServletContext, HttpServletRequest theRequest) { public String determineServerBase(ServletContext theServletContext, HttpServletRequest theRequest) {
String forwardedHost = getForwardedHost(theRequest); String forwardedHost = getForwardedHost(theRequest);
if (forwardedHost != null) { if (forwardedHost != null) {
return forwardedServerBase(theServletContext, theRequest, forwardedHost); return forwardedServerBase(theServletContext, theRequest, forwardedHost);
} }
return super.determineServerBase(theServletContext, theRequest); return super.determineServerBase(theServletContext, theRequest);
} }
private String getForwardedHost(HttpServletRequest theRequest) { private String getForwardedHost(HttpServletRequest theRequest) {
String forwardedHost = theRequest.getHeader("x-forwarded-host"); String forwardedHost = theRequest.getHeader("x-forwarded-host");
if (forwardedHost != null) { if (forwardedHost != null) {
int commaPos = forwardedHost.indexOf(','); int commaPos = forwardedHost.indexOf(',');
if (commaPos >= 0) { if (commaPos >= 0) {
forwardedHost = forwardedHost.substring(0, commaPos - 1); forwardedHost = forwardedHost.substring(0, commaPos - 1);
} }
} }
return forwardedHost; return forwardedHost;
} }
public String forwardedServerBase(ServletContext theServletContext, HttpServletRequest theRequest, String theForwardedHost) { public String forwardedServerBase(ServletContext theServletContext, HttpServletRequest theRequest, String theForwardedHost) {
String serverBase = super.determineServerBase(theServletContext, theRequest); String serverBase = super.determineServerBase(theServletContext, theRequest);
String host = theRequest.getHeader("host"); String host = theRequest.getHeader("host");
if (host != null) { if (host != null) {
serverBase = serverBase.replace(host, theForwardedHost); serverBase = serverBase.replace(host, theForwardedHost);
serverBase = serverBase.substring(serverBase.indexOf("://")); serverBase = serverBase.substring(serverBase.indexOf("://"));
return protocol(theRequest) + serverBase; return protocol(theRequest) + serverBase;
} }
return serverBase; return serverBase;
} }
protected String protocol(HttpServletRequest theRequest) { protected String protocol(HttpServletRequest theRequest) {
String protocol = theRequest.getHeader("x-forwarded-proto"); String protocol = theRequest.getHeader("x-forwarded-proto");
if (protocol != null) { if (protocol != null) {
return protocol; return protocol;
} }
return myUseHttps ? "https" : "http"; return myUseHttps ? "https" : "http";
} }
} }

View File

@ -2,17 +2,22 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <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> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>1.1-SNAPSHOT</version> <version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>
<artifactId>hapi-fhir-cobertura</artifactId> <artifactId>hapi-fhir-cobertura</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HAPI FHIR - Consolidated Test Project</name> <name>HAPI FHIR - Cobertura Test Coverage</name>
<dependencies> <dependencies>
<dependency> <dependency>
@ -70,13 +75,6 @@
<version>${logback_version}</version> <version>${logback_version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
<version>${hamcrest_version}</version>
<scope>test</scope>
</dependency>
<!-- Test Database --> <!-- Test Database -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -122,12 +120,6 @@
<version>${jetty_version}</version> <version>${jetty_version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId> <artifactId>jetty-util</artifactId>
@ -371,7 +363,7 @@
</build> </build>
<reporting> <reporting>
<plugins> <plugins>
<!--<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId> <artifactId>cobertura-maven-plugin</artifactId>
<version>${maven_cobertura_plugin_version}</version> <version>${maven_cobertura_plugin_version}</version>
@ -382,7 +374,7 @@
</reports> </reports>
</reportSet> </reportSet>
</reportSets> </reportSets>
</plugin>--> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId> <artifactId>maven-project-info-reports-plugin</artifactId>

View File

@ -275,12 +275,6 @@
<version>${jetty_version}</version> <version>${jetty_version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId> <artifactId>jetty-util</artifactId>

View File

@ -457,6 +457,11 @@
<configLocation>file://${project.basedir}/src/checkstyle/checkstyle.xml</configLocation> <configLocation>file://${project.basedir}/src/checkstyle/checkstyle.xml</configLocation>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
<plugins> <plugins>

View File

@ -76,7 +76,9 @@
<module name="OneStatementPerLine"/> <module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/> <module name="MultipleVariableDeclarations"/>
<module name="ArrayTypeStyle"/> <module name="ArrayTypeStyle"/>
<!--
<module name="MissingSwitchDefault"/> <module name="MissingSwitchDefault"/>
-->
<module name="FallThrough"/> <module name="FallThrough"/>
<module name="UpperEll"/> <module name="UpperEll"/>
<module name="ModifierOrder"/> <module name="ModifierOrder"/>
@ -141,7 +143,7 @@
<module name="Indentation"> <module name="Indentation">
<property name="basicOffset" value="3"/> <property name="basicOffset" value="3"/>
<property name="braceAdjustment" value="0"/> <property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="3"/> <property name="caseIndent" value="0"/>
<property name="throwsIndent" value="6"/> <property name="throwsIndent" value="6"/>
<property name="lineWrappingIndentation" value="6"/> <property name="lineWrappingIndentation" value="6"/>
<property name="arrayInitIndent" value="3"/> <property name="arrayInitIndent" value="3"/>