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