Merge branch 'master' of https://github.com/jamesagnew/hapi-fhir
This commit is contained in:
commit
5074da9002
|
@ -1,55 +0,0 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
|
||||||
<artifactId>hapi-fhir</artifactId>
|
|
||||||
<version>0.8-SNAPSHOT</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>hapi-fhir-base-examples</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>HAPI FHIR - Examples (for site)</name>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
|
||||||
<artifactId>hapi-fhir-base</artifactId>
|
|
||||||
<version>0.8-SNAPSHOT</version>
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
|
||||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
|
||||||
<version>0.8-SNAPSHOT</version>
|
|
||||||
>>>>>>> versions
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
<version>3.1.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>${junit_version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skip>true</skip>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -237,7 +237,6 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public List<? extends IElement> getValues(Object theTarget) {
|
public List<? extends IElement> getValues(Object theTarget) {
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<? extends IElement> retVal;
|
List<? extends IElement> retVal;
|
||||||
try {
|
try {
|
||||||
retVal = (List<? extends IElement>) myField.get(theTarget);
|
retVal = (List<? extends IElement>) myField.get(theTarget);
|
||||||
|
|
|
@ -23,7 +23,6 @@ package ca.uhn.fhir.context;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -34,7 +33,6 @@ import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
|
|
||||||
public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IResource> {
|
public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IResource> {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RuntimeResourceDefinition.class);
|
|
||||||
private RuntimeResourceDefinition myBaseDefinition;
|
private RuntimeResourceDefinition myBaseDefinition;
|
||||||
private Map<String, RuntimeSearchParam> myNameToSearchParam = new LinkedHashMap<String, RuntimeSearchParam>();
|
private Map<String, RuntimeSearchParam> myNameToSearchParam = new LinkedHashMap<String, RuntimeSearchParam>();
|
||||||
private IResource myProfileDef;
|
private IResource myProfileDef;
|
||||||
|
|
|
@ -23,7 +23,6 @@ package ca.uhn.fhir.model.base.composite;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
|
|
|
@ -20,12 +20,8 @@ package ca.uhn.fhir.model.primitive;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -35,9 +31,6 @@ import javax.xml.stream.XMLEventWriter;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
import javax.xml.stream.events.XMLEvent;
|
import javax.xml.stream.events.XMLEvent;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
|
||||||
import org.codehaus.stax2.io.EscapingWriterFactory;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.annotation.Target;
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2014 University Health Network
|
* Copyright (C) 2014 University Health Network
|
||||||
* %%
|
* %%
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
|
|
|
@ -21,7 +21,6 @@ package ca.uhn.fhir.rest.method;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
|
|
@ -23,9 +23,6 @@ package ca.uhn.fhir.rest.param;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
import ca.uhn.fhir.rest.method.QualifiedParamList;
|
import ca.uhn.fhir.rest.method.QualifiedParamList;
|
||||||
|
|
|
@ -1,301 +0,0 @@
|
||||||
package ca.uhn.fhir.rest.server.exceptions;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR - Core Library
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 University Health Network
|
|
||||||
* %%
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class for RESTful client and server exceptions. RESTful client methods will only throw exceptions which are subclasses of this exception type, and RESTful server methods should also only call
|
|
||||||
* subclasses of this exception type.
|
|
||||||
*/
|
|
||||||
public abstract class BaseServerResponseException extends RuntimeException {
|
|
||||||
|
|
||||||
private static final Map<Integer, Class<? extends BaseServerResponseException>> ourStatusCodeToExceptionType = new HashMap<Integer, Class<? extends BaseServerResponseException>>();
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
static {
|
|
||||||
registerExceptionType(AuthenticationException.STATUS_CODE, AuthenticationException.class);
|
|
||||||
registerExceptionType(InternalErrorException.STATUS_CODE, InternalErrorException.class);
|
|
||||||
registerExceptionType(InvalidRequestException.STATUS_CODE, InvalidRequestException.class);
|
|
||||||
registerExceptionType(MethodNotAllowedException.STATUS_CODE, MethodNotAllowedException.class);
|
|
||||||
registerExceptionType(ResourceNotFoundException.STATUS_CODE, ResourceNotFoundException.class);
|
|
||||||
registerExceptionType(ResourceVersionNotSpecifiedException.STATUS_CODE, ResourceVersionNotSpecifiedException.class);
|
|
||||||
registerExceptionType(ResourceVersionConflictException.STATUS_CODE, ResourceVersionConflictException.class);
|
|
||||||
registerExceptionType(UnprocessableEntityException.STATUS_CODE, UnprocessableEntityException.class);
|
|
||||||
registerExceptionType(ResourceGoneException.STATUS_CODE, ResourceGoneException.class);
|
|
||||||
registerExceptionType(NotImplementedOperationException.STATUS_CODE, NotImplementedOperationException.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
private List<String> myAdditionalMessages = null;
|
|
||||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
|
||||||
private BaseOperationOutcome myBaseOperationOutcome;
|
|
||||||
private String myResponseBody;
|
|
||||||
private String myResponseMimeType;
|
|
||||||
private int myStatusCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param theStatusCode
|
|
||||||
* The HTTP status code corresponding to this problem
|
|
||||||
* @param theMessage
|
|
||||||
* The message
|
|
||||||
*/
|
|
||||||
public BaseServerResponseException(int theStatusCode, String theMessage) {
|
|
||||||
super(theMessage);
|
|
||||||
myStatusCode = theStatusCode;
|
|
||||||
myBaseOperationOutcome = null;
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param theStatusCode
|
|
||||||
* The HTTP status code corresponding to this problem
|
|
||||||
* @param theMessage
|
|
||||||
* The message
|
|
||||||
*/
|
|
||||||
public BaseServerResponseException(int theStatusCode, String... theMessages) {
|
|
||||||
super(theMessages != null && theMessages.length > 0 ? theMessages[0] : null);
|
|
||||||
myStatusCode = theStatusCode;
|
|
||||||
myBaseOperationOutcome = null;
|
|
||||||
if (theMessages != null && theMessages.length > 1) {
|
|
||||||
myAdditionalMessages = Arrays.asList(Arrays.copyOfRange(theMessages, 1, theMessages.length, String[].class));
|
|
||||||
}
|
|
||||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param theStatusCode
|
|
||||||
* The HTTP status code corresponding to this problem
|
|
||||||
* @param theMessage
|
|
||||||
* The message
|
|
||||||
* @param theBaseOperationOutcome
|
|
||||||
<<<<<<< HEAD
|
|
||||||
* An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome
|
|
||||||
* that was returned from the server (in a client)
|
|
||||||
=======
|
|
||||||
* An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome that was returned from the server (in a client)
|
|
||||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
|
||||||
*/
|
|
||||||
public BaseServerResponseException(int theStatusCode, String theMessage, BaseOperationOutcome theBaseOperationOutcome) {
|
|
||||||
super(theMessage);
|
|
||||||
myStatusCode = theStatusCode;
|
|
||||||
myBaseOperationOutcome = theBaseOperationOutcome;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param theStatusCode
|
|
||||||
* The HTTP status code corresponding to this problem
|
|
||||||
* @param theMessage
|
|
||||||
* The message
|
|
||||||
* @param theCause
|
|
||||||
* The cause
|
|
||||||
*/
|
|
||||||
public BaseServerResponseException(int theStatusCode, String theMessage, Throwable theCause) {
|
|
||||||
super(theMessage, theCause);
|
|
||||||
myStatusCode = theStatusCode;
|
|
||||||
myBaseOperationOutcome = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param theStatusCode
|
|
||||||
* The HTTP status code corresponding to this problem
|
|
||||||
* @param theMessage
|
|
||||||
* The message
|
|
||||||
* @param theCause
|
|
||||||
* The underlying cause exception
|
|
||||||
* @param theBaseOperationOutcome
|
|
||||||
<<<<<<< HEAD
|
|
||||||
* An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome
|
|
||||||
* that was returned from the server (in a client)
|
|
||||||
=======
|
|
||||||
* An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome that was returned from the server (in a client)
|
|
||||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
|
||||||
*/
|
|
||||||
public BaseServerResponseException(int theStatusCode, String theMessage, Throwable theCause, BaseOperationOutcome theBaseOperationOutcome) {
|
|
||||||
super(theMessage, theCause);
|
|
||||||
myStatusCode = theStatusCode;
|
|
||||||
myBaseOperationOutcome = theBaseOperationOutcome;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param theStatusCode
|
|
||||||
* The HTTP status code corresponding to this problem
|
|
||||||
* @param theCause
|
|
||||||
* The underlying cause exception
|
|
||||||
*/
|
|
||||||
public BaseServerResponseException(int theStatusCode, Throwable theCause) {
|
|
||||||
super(theCause.toString(), theCause);
|
|
||||||
myStatusCode = theStatusCode;
|
|
||||||
myBaseOperationOutcome = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param theStatusCode
|
|
||||||
* The HTTP status code corresponding to this problem
|
|
||||||
* @param theCause
|
|
||||||
* The underlying cause exception
|
|
||||||
* @param theBaseOperationOutcome
|
|
||||||
<<<<<<< HEAD
|
|
||||||
* An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome
|
|
||||||
* that was returned from the server (in a client)
|
|
||||||
=======
|
|
||||||
* An BaseOperationOutcome resource to return to the calling client (in a server) or the BaseOperationOutcome that was returned from the server (in a client)
|
|
||||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
|
||||||
*/
|
|
||||||
public BaseServerResponseException(int theStatusCode, Throwable theCause, BaseOperationOutcome theBaseOperationOutcome) {
|
|
||||||
super(theCause.toString(), theCause);
|
|
||||||
myStatusCode = theStatusCode;
|
|
||||||
myBaseOperationOutcome = theBaseOperationOutcome;
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getAdditionalMessages() {
|
|
||||||
return myAdditionalMessages;
|
|
||||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link BaseOperationOutcome} resource if any which was supplied in the response, or <code>null</code>
|
|
||||||
*/
|
|
||||||
public BaseOperationOutcome getOperationOutcome() {
|
|
||||||
return myBaseOperationOutcome;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* In a RESTful client, this method will be populated with the body of the HTTP respone if one was provided by the server, or <code>null</code> otherwise.
|
|
||||||
* <p>
|
|
||||||
* In a restful server, this method is currently ignored.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public String getResponseBody() {
|
|
||||||
return myResponseBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* In a RESTful client, this method will be populated with the HTTP status code that was returned with the HTTP response.
|
|
||||||
* <p>
|
|
||||||
* In a restful server, this method is currently ignored.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public String getResponseMimeType() {
|
|
||||||
return myResponseMimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the HTTP status code corresponding to this problem
|
|
||||||
*/
|
|
||||||
public int getStatusCode() {
|
|
||||||
return myStatusCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
<<<<<<< HEAD
|
|
||||||
* Sets the BaseOperationOutcome resource associated with this exception. In server
|
|
||||||
* implementations, this is the OperartionOutcome resource to include with the HTTP response. In
|
|
||||||
* client implementations you should not call this method.
|
|
||||||
*
|
|
||||||
* @param theBaseOperationOutcome The BaseOperationOutcome resource
|
|
||||||
=======
|
|
||||||
* Sets the BaseOperationOutcome resource associated with this exception. In server implementations, this is the OperartionOutcome resource to include with the HTTP response. In client
|
|
||||||
* implementations you should not call this method.
|
|
||||||
*
|
|
||||||
* @param theBaseOperationOutcome
|
|
||||||
* The BaseOperationOutcome resource
|
|
||||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
|
||||||
*/
|
|
||||||
public void setOperationOutcome(BaseOperationOutcome theBaseOperationOutcome) {
|
|
||||||
myBaseOperationOutcome = theBaseOperationOutcome;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is currently only called internally by HAPI, it should not be called by user code.
|
|
||||||
*/
|
|
||||||
public void setResponseBody(String theResponseBody) {
|
|
||||||
myResponseBody = theResponseBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is currently only called internally by HAPI, it should not be called by user code.
|
|
||||||
*/
|
|
||||||
public void setResponseMimeType(String theResponseMimeType) {
|
|
||||||
myResponseMimeType = theResponseMimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* For unit tests only
|
|
||||||
*/
|
|
||||||
static boolean isExceptionTypeRegistered(Class<?> theType) {
|
|
||||||
return ourStatusCodeToExceptionType.values().contains(theType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BaseServerResponseException newInstance(int theStatusCode, String theMessage) {
|
|
||||||
if (ourStatusCodeToExceptionType.containsKey(theStatusCode)) {
|
|
||||||
try {
|
|
||||||
return ourStatusCodeToExceptionType.get(theStatusCode).getConstructor(new Class[] { String.class }).newInstance(theMessage);
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new InternalErrorException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new InternalErrorException(e);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
throw new InternalErrorException(e);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
throw new InternalErrorException(e);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new InternalErrorException(e);
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
throw new InternalErrorException(e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return new UnclassifiedServerFailureException(theStatusCode, theMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void registerExceptionType(int theStatusCode, Class<? extends BaseServerResponseException> theType) {
|
|
||||||
if (ourStatusCodeToExceptionType.containsKey(theStatusCode)) {
|
|
||||||
throw new Error("Can not register " + theType + " to status code " + theStatusCode + " because " + ourStatusCodeToExceptionType.get(theStatusCode) + " already registers that code");
|
|
||||||
}
|
|
||||||
ourStatusCodeToExceptionType.put(theStatusCode, theType);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -20,16 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
|
||||||
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
||||||
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
|
|
||||||
import ca.uhn.fhir.model.dstu.composite.NarrativeDt;
|
|
||||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
|
||||||
import ca.uhn.fhir.rest.server.Constants;
|
import ca.uhn.fhir.rest.server.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,87 +0,0 @@
|
||||||
package ca.uhn.fhir.rest.server.exceptions;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR - Core Library
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 University Health Network
|
|
||||||
* %%
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
|
||||||
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
|
||||||
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
|
|
||||||
import ca.uhn.fhir.model.dstu.composite.NarrativeDt;
|
|
||||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
|
||||||
import ca.uhn.fhir.rest.server.Constants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents an <b>HTTP 422 Unprocessable Entity</b> response, which means that a resource was rejected by the server because it "violated applicable FHIR profiles or server business rules".
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* This exception will generally contain an {@link BaseOperationOutcome} instance which details the failure.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @see InvalidRequestException Which corresponds to an <b>HTTP 400 Bad Request</b> failure
|
|
||||||
*/
|
|
||||||
public class UnprocessableEntityException extends BaseServerResponseException {
|
|
||||||
|
|
||||||
private static final String DEFAULT_MESSAGE = "Unprocessable Entity";
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
public static final int STATUS_CODE = Constants.STATUS_HTTP_422_UNPROCESSABLE_ENTITY;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param theMessage
|
|
||||||
* The message to add to the status line
|
|
||||||
* @param theOperationOutcome The BaseOperationOutcome resource to return to the client
|
|
||||||
*/
|
|
||||||
public UnprocessableEntityException(String theMessage, BaseOperationOutcome theOperationOutcome) {
|
|
||||||
super(STATUS_CODE, theMessage, theOperationOutcome);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor which accepts an {@link BaseOperationOutcome} resource which will be supplied in the response
|
|
||||||
*/
|
|
||||||
public UnprocessableEntityException(BaseOperationOutcome theOperationOutcome) {
|
|
||||||
super(STATUS_CODE, DEFAULT_MESSAGE, theOperationOutcome);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor which accepts a String describing the issue. This string will be translated into an {@link BaseOperationOutcome} resource which will be supplied in the response.
|
|
||||||
*/
|
|
||||||
public UnprocessableEntityException(String theMessage) {
|
|
||||||
super(STATUS_CODE, theMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor which accepts an array of Strings describing the issue. This strings will be translated into an {@link BaseOperationOutcome} resource which will be supplied in the response.
|
|
||||||
*/
|
|
||||||
public UnprocessableEntityException(String... theMessage) {
|
|
||||||
<<<<<<< HEAD
|
|
||||||
super(STATUS_CODE, theMessage[0]); // TODO: this used to generate an OperationOutcome - why?
|
|
||||||
=======
|
|
||||||
super(STATUS_CODE, theMessage);
|
|
||||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -31,10 +31,6 @@ import ca.uhn.fhir.model.api.Bundle;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource validator, which checks resources for compliance against various validation schemes (schemas, schematrons, etc.)
|
* Resource validator, which checks resources for compliance against various validation schemes (schemas, schematrons, etc.)
|
||||||
*
|
*
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>HAPI FHIR - OAUTH2 Support</name>
|
<name>HAPI FHIR - OAUTH2 Support</name>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
Loading…
Reference in New Issue