001package ca.uhn.fhir.rest.server.exceptions; 002 003/* 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2017 University Health Network 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022import org.hl7.fhir.instance.model.api.*; 023 024import ca.uhn.fhir.model.base.composite.BaseIdentifierDt; 025import ca.uhn.fhir.rest.api.Constants; 026import ca.uhn.fhir.util.CoverageIgnore; 027 028/** 029 * Represents an <b>HTTP 410 Resource Gone</b> response, which geenerally 030 * indicates that the resource has been deleted 031 */ 032@CoverageIgnore 033public class ResourceGoneException extends BaseServerResponseException { 034 035 public static final int STATUS_CODE = Constants.STATUS_HTTP_410_GONE; 036 037 /** 038 * Constructor which creates an error message based on a given resource ID 039 * 040 * @param theResourceId 041 * The ID of the resource that could not be found 042 */ 043 public ResourceGoneException(IIdType theResourceId) { 044 super(STATUS_CODE, "Resource " + (theResourceId != null ? theResourceId.getValue() : "") + " is gone/deleted"); 045 } 046 047 /** 048 * @deprecated This constructor has a dependency on a specific model version and will be removed. Deprecated in HAPI 049 * 1.6 - 2016-07-02 050 */ 051 @Deprecated 052 public ResourceGoneException(Class<? extends IBaseResource> theClass, BaseIdentifierDt thePatientId) { 053 super(STATUS_CODE, "Resource of type " + theClass.getSimpleName() + " with ID " + thePatientId + " is gone/deleted"); 054 } 055 056 /** 057 * Constructor which creates an error message based on a given resource ID 058 * 059 * @param theClass 060 * The type of resource that could not be found 061 * @param theResourceId 062 * The ID of the resource that could not be found 063 */ 064 public ResourceGoneException(Class<? extends IBaseResource> theClass, IIdType theResourceId) { 065 super(STATUS_CODE, "Resource of type " + theClass.getSimpleName() + " with ID " + theResourceId + " is gone/deleted"); 066 } 067 068 /** 069 * Constructor 070 * 071 * @param theMessage 072 * The message 073 * @param theOperationOutcome 074 * The OperationOutcome resource to return to the client 075 */ 076 public ResourceGoneException(String theMessage, IBaseOperationOutcome theOperationOutcome) { 077 super(STATUS_CODE, theMessage, theOperationOutcome); 078 } 079 080 public ResourceGoneException(String theMessage) { 081 super(STATUS_CODE, theMessage); 082 } 083 084 private static final long serialVersionUID = 1L; 085 086}