View Javadoc
1   package ca.uhn.fhir.rest.server.exceptions;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
24  import ca.uhn.fhir.rest.api.Constants;
25  import ca.uhn.fhir.util.CoverageIgnore;
26  import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
27  import org.hl7.fhir.instance.model.api.IBaseResource;
28  import org.hl7.fhir.instance.model.api.IIdType;
29  
30  /**
31   * Represents an <b>HTTP 410 Resource Gone</b> response, which geenerally
32   * indicates that the resource has been deleted
33   */
34  @CoverageIgnore
35  public class ResourceGoneException extends BaseServerResponseException {
36  
37  	public static final int STATUS_CODE = Constants.STATUS_HTTP_410_GONE;
38  	private static final long serialVersionUID = 1L;
39  
40  	/**
41  	 * Constructor which creates an error message based on a given resource ID
42  	 *
43  	 * @param theResourceId The ID of the resource that could not be found
44  	 */
45  	public ResourceGoneException(IIdType theResourceId) {
46  		super(STATUS_CODE, "Resource " + (theResourceId != null ? theResourceId.getValue() : "") + " is gone/deleted");
47  	}
48  
49  	/**
50  	 * @deprecated This constructor has a dependency on a specific model version and will be removed. Deprecated in HAPI
51  	 * 1.6 - 2016-07-02
52  	 */
53  	@Deprecated
54  	public ResourceGoneException(Class<? extends IBaseResource> theClass, BaseIdentifierDt thePatientId) {
55  		super(STATUS_CODE, "Resource of type " + theClass.getSimpleName() + " with ID " + thePatientId + " is gone/deleted");
56  	}
57  
58  	/**
59  	 * Constructor which creates an error message based on a given resource ID
60  	 *
61  	 * @param theClass      The type of resource that could not be found
62  	 * @param theResourceId The ID of the resource that could not be found
63  	 */
64  	public ResourceGoneException(Class<? extends IBaseResource> theClass, IIdType theResourceId) {
65  		super(STATUS_CODE, "Resource of type " + theClass.getSimpleName() + " with ID " + theResourceId + " is gone/deleted");
66  	}
67  
68  	/**
69  	 * Constructor
70  	 *
71  	 * @param theMessage          The message
72  	 * @param theOperationOutcome The OperationOutcome resource to return to the client
73  	 */
74  	public ResourceGoneException(String theMessage, IBaseOperationOutcome theOperationOutcome) {
75  		super(STATUS_CODE, theMessage, theOperationOutcome);
76  	}
77  
78  	/**
79  	 * Constructor
80  	 *
81  	 * @param theMessage The message
82  	 */
83  	public ResourceGoneException(String theMessage) {
84  		super(STATUS_CODE, theMessage);
85  	}
86  
87  }