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  import org.hl7.fhir.instance.model.api.*;
23  
24  import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
25  import ca.uhn.fhir.rest.api.Constants;
26  import ca.uhn.fhir.util.CoverageIgnore;
27  
28  /**
29   * Represents an <b>HTTP 410 Resource Gone</b> response, which geenerally
30   * indicates that the resource has been deleted
31   */
32  @CoverageIgnore
33  public class ResourceGoneException extends BaseServerResponseException {
34  
35  	public static final int STATUS_CODE = Constants.STATUS_HTTP_410_GONE;
36  
37  	/**
38  	 * Constructor which creates an error message based on a given resource ID
39  	 * 
40  	 * @param theResourceId
41  	 *           The ID of the resource that could not be found
42  	 */
43  	public ResourceGoneException(IIdType theResourceId) {
44  		super(STATUS_CODE, "Resource " + (theResourceId != null ? theResourceId.getValue() : "") + " is gone/deleted");
45  	}
46  
47  	/**
48  	 * @deprecated This constructor has a dependency on a specific model version and will be removed. Deprecated in HAPI
49  	 *             1.6 - 2016-07-02
50  	 */
51  	@Deprecated
52  	public ResourceGoneException(Class<? extends IBaseResource> theClass, BaseIdentifierDt thePatientId) {
53  		super(STATUS_CODE, "Resource of type " + theClass.getSimpleName() + " with ID " + thePatientId + " is gone/deleted");
54  	}
55  
56  	/**
57  	 * Constructor which creates an error message based on a given resource ID
58  	 * 
59  	 * @param theClass
60  	 *           The type of resource that could not be found
61  	 * @param theResourceId
62  	 *           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
72  	 *           The message
73  	 * @param theOperationOutcome
74  	 *           The OperationOutcome resource to return to the client
75  	 */
76  	public ResourceGoneException(String theMessage, IBaseOperationOutcome theOperationOutcome) {
77  		super(STATUS_CODE, theMessage, theOperationOutcome);
78  	}
79  
80  	public ResourceGoneException(String theMessage) {
81  		super(STATUS_CODE, theMessage);
82  	}
83  
84  	private static final long serialVersionUID = 1L;
85  
86  }