001package ca.uhn.fhir.rest.server.exceptions; 002 003/* 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2018 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 */ 022 023import ca.uhn.fhir.model.base.composite.BaseIdentifierDt; 024import ca.uhn.fhir.rest.api.Constants; 025import ca.uhn.fhir.util.CoverageIgnore; 026import org.hl7.fhir.instance.model.api.IBaseOperationOutcome; 027import org.hl7.fhir.instance.model.api.IBaseResource; 028import org.hl7.fhir.instance.model.api.IIdType; 029 030/** 031 * Represents an <b>HTTP 410 Resource Gone</b> response, which geenerally 032 * indicates that the resource has been deleted 033 */ 034@CoverageIgnore 035public class ResourceGoneException extends BaseServerResponseException { 036 037 public static final int STATUS_CODE = Constants.STATUS_HTTP_410_GONE; 038 private static final long serialVersionUID = 1L; 039 040 /** 041 * Constructor which creates an error message based on a given resource ID 042 * 043 * @param theResourceId The ID of the resource that could not be found 044 */ 045 public ResourceGoneException(IIdType theResourceId) { 046 super(STATUS_CODE, "Resource " + (theResourceId != null ? theResourceId.getValue() : "") + " is gone/deleted"); 047 } 048 049 /** 050 * @deprecated This constructor has a dependency on a specific model version and will be removed. Deprecated in HAPI 051 * 1.6 - 2016-07-02 052 */ 053 @Deprecated 054 public ResourceGoneException(Class<? extends IBaseResource> theClass, BaseIdentifierDt thePatientId) { 055 super(STATUS_CODE, "Resource of type " + theClass.getSimpleName() + " with ID " + thePatientId + " is gone/deleted"); 056 } 057 058 /** 059 * Constructor which creates an error message based on a given resource ID 060 * 061 * @param theClass The type of resource that could not be found 062 * @param theResourceId 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 The message 072 * @param theOperationOutcome The OperationOutcome resource to return to the client 073 */ 074 public ResourceGoneException(String theMessage, IBaseOperationOutcome theOperationOutcome) { 075 super(STATUS_CODE, theMessage, theOperationOutcome); 076 } 077 078 /** 079 * Constructor 080 * 081 * @param theMessage The message 082 */ 083 public ResourceGoneException(String theMessage) { 084 super(STATUS_CODE, theMessage); 085 } 086 087}