001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.http.response; 014 015import static org.apache.juneau.http.response.Gone.*; 016 017import java.text.*; 018import java.util.*; 019 020import org.apache.http.*; 021import org.apache.http.Header; 022import org.apache.juneau.annotation.*; 023import org.apache.juneau.http.*; 024import org.apache.juneau.http.annotation.*; 025import org.apache.juneau.http.header.*; 026import org.apache.juneau.internal.*; 027 028/** 029 * Exception representing an HTTP 410 (). 030 * 031 * <p> 032 * Indicates that the resource requested is no longer available and will not be available again. 033 * <br>This should be used when a resource has been intentionally removed and the resource should be purged. 034 * <br>Upon receiving a 410 status code, the client should not request the resource in the future. 035 * <br>Clients such as search engines should remove the resource from their indices. 036 * <br>Most use cases do not require clients and search engines to purge the resource, and a <js>"404 Not Found"</js> may be used instead. 037 * 038 * <h5 class='section'>See Also:</h5><ul> 039 * <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a> 040 * </ul> 041 * 042 * @serial exclude 043 */ 044@Response 045@StatusCode(STATUS_CODE) 046@Schema(description=REASON_PHRASE) 047@FluentSetters 048public class Gone extends BasicHttpException { 049 private static final long serialVersionUID = 1L; 050 051 /** HTTP status code */ 052 public static final int STATUS_CODE = 410; 053 054 /** Reason phrase */ 055 public static final String REASON_PHRASE = "Gone"; 056 057 /** Default status line */ 058 private static final BasicStatusLine STATUS_LINE = BasicStatusLine.create(STATUS_CODE, REASON_PHRASE); 059 060 /** Reusable unmodifiable instance */ 061 public static final Gone INSTANCE = new Gone().setUnmodifiable(); 062 063 /** 064 * Constructor. 065 * 066 * @param cause The caused-by exception. Can be <jk>null</jk>. 067 * @param msg The message. Can be <jk>null</jk>. 068 * @param args The message arguments. 069 */ 070 public Gone(Throwable cause, String msg, Object...args) { 071 super(STATUS_CODE, cause, msg, args); 072 setStatusLine(STATUS_LINE.copy()); 073 } 074 075 /** 076 * Constructor. 077 */ 078 public Gone() { 079 this((Throwable)null, REASON_PHRASE); 080 } 081 082 /** 083 * Constructor. 084 * 085 * @param msg The message. Can be <jk>null</jk>. 086 * @param args Optional {@link MessageFormat}-style arguments in the message. 087 */ 088 public Gone(String msg, Object...args) { 089 this((Throwable)null, msg, args); 090 } 091 092 /** 093 * Constructor. 094 * 095 * @param cause The cause. Can be <jk>null</jk>. 096 */ 097 public Gone(Throwable cause) { 098 this(cause, cause == null ? REASON_PHRASE : cause.getMessage()); 099 } 100 101 /** 102 * Constructor. 103 * 104 * <p> 105 * This is the constructor used when parsing an HTTP response. 106 * 107 * @param response The HTTP response to copy from. Must not be <jk>null</jk>. 108 * @throws AssertionError If HTTP response status code does not match what was expected. 109 */ 110 public Gone(HttpResponse response) { 111 super(response); 112 assertStatusCode(response); 113 } 114 115 /** 116 * Copy constructor. 117 * 118 * @param copyFrom The bean to copy. 119 */ 120 protected Gone(Gone copyFrom) { 121 super(copyFrom); 122 } 123 124 /** 125 * Creates a modifiable copy of this bean. 126 * 127 * @return A new modifiable bean. 128 */ 129 public Gone copy() { 130 return new Gone(this); 131 } 132 133 // <FluentSetters> 134 135 @Override /* GENERATED - org.apache.juneau.BasicRuntimeException */ 136 public Gone setMessage(String message, Object...args) { 137 super.setMessage(message, args); 138 return this; 139 } 140 141 @Override /* GENERATED - org.apache.juneau.BasicRuntimeException */ 142 public Gone setUnmodifiable() { 143 super.setUnmodifiable(); 144 return this; 145 } 146 147 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 148 public Gone setHeader2(String name, Object value) { 149 super.setHeader2(name, value); 150 return this; 151 } 152 153 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 154 public Gone setHeaders(HeaderList value) { 155 super.setHeaders(value); 156 return this; 157 } 158 159 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 160 public Gone setHeaders2(Header...values) { 161 super.setHeaders2(values); 162 return this; 163 } 164 165 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 166 public Gone setLocale2(Locale value) { 167 super.setLocale2(value); 168 return this; 169 } 170 171 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 172 public Gone setProtocolVersion(ProtocolVersion value) { 173 super.setProtocolVersion(value); 174 return this; 175 } 176 177 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 178 public Gone setReasonPhrase2(String value) { 179 super.setReasonPhrase2(value); 180 return this; 181 } 182 183 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 184 public Gone setReasonPhraseCatalog(ReasonPhraseCatalog value) { 185 super.setReasonPhraseCatalog(value); 186 return this; 187 } 188 189 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 190 public Gone setStatusCode2(int code) throws IllegalStateException{ 191 super.setStatusCode2(code); 192 return this; 193 } 194 195 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpException */ 196 public Gone setStatusLine(BasicStatusLine value) { 197 super.setStatusLine(value); 198 return this; 199 } 200 201 // </FluentSetters> 202}